.. | .. |
---|
17 | 17 | #include <linux/kernel.h> |
---|
18 | 18 | #include <linux/slab.h> |
---|
19 | 19 | #include <linux/etherdevice.h> |
---|
| 20 | +#include <linux/if_bridge.h> |
---|
20 | 21 | #include <linux/list.h> |
---|
21 | 22 | #include <linux/hash.h> |
---|
22 | 23 | #include <linux/hashtable.h> |
---|
| 24 | +#include <net/switchdev.h> |
---|
| 25 | +#include <asm/chsc.h> |
---|
| 26 | +#include <asm/css_chars.h> |
---|
23 | 27 | #include <asm/setup.h> |
---|
24 | 28 | #include "qeth_core.h" |
---|
25 | 29 | #include "qeth_l2.h" |
---|
26 | 30 | |
---|
27 | | -static int qeth_l2_set_offline(struct ccwgroup_device *); |
---|
28 | | -static int qeth_l2_stop(struct net_device *); |
---|
29 | | -static void qeth_bridgeport_query_support(struct qeth_card *card); |
---|
30 | | -static void qeth_bridge_state_change(struct qeth_card *card, |
---|
31 | | - struct qeth_ipa_cmd *cmd); |
---|
32 | | -static void qeth_bridge_host_event(struct qeth_card *card, |
---|
33 | | - struct qeth_ipa_cmd *cmd); |
---|
34 | | -static void qeth_l2_vnicc_set_defaults(struct qeth_card *card); |
---|
35 | | -static void qeth_l2_vnicc_init(struct qeth_card *card); |
---|
36 | | -static bool qeth_l2_vnicc_recover_timeout(struct qeth_card *card, u32 vnicc, |
---|
37 | | - u32 *timeout); |
---|
38 | | - |
---|
39 | | -static struct net_device *qeth_l2_netdev_by_devno(unsigned char *read_dev_no) |
---|
40 | | -{ |
---|
41 | | - struct qeth_card *card; |
---|
42 | | - struct net_device *ndev; |
---|
43 | | - __u16 temp_dev_no; |
---|
44 | | - unsigned long flags; |
---|
45 | | - struct ccw_dev_id read_devid; |
---|
46 | | - |
---|
47 | | - ndev = NULL; |
---|
48 | | - memcpy(&temp_dev_no, read_dev_no, 2); |
---|
49 | | - read_lock_irqsave(&qeth_core_card_list.rwlock, flags); |
---|
50 | | - list_for_each_entry(card, &qeth_core_card_list.list, list) { |
---|
51 | | - ccw_device_get_id(CARD_RDEV(card), &read_devid); |
---|
52 | | - if (read_devid.devno == temp_dev_no) { |
---|
53 | | - ndev = card->dev; |
---|
54 | | - break; |
---|
55 | | - } |
---|
56 | | - } |
---|
57 | | - read_unlock_irqrestore(&qeth_core_card_list.rwlock, flags); |
---|
58 | | - return ndev; |
---|
59 | | -} |
---|
60 | | - |
---|
61 | | -static int qeth_setdelmac_makerc(struct qeth_card *card, int retcode) |
---|
| 31 | +static int qeth_l2_setdelmac_makerc(struct qeth_card *card, u16 retcode) |
---|
62 | 32 | { |
---|
63 | 33 | int rc; |
---|
64 | 34 | |
---|
.. | .. |
---|
76 | 46 | break; |
---|
77 | 47 | case IPA_RC_L2_DUP_MAC: |
---|
78 | 48 | case IPA_RC_L2_DUP_LAYER3_MAC: |
---|
79 | | - rc = -EEXIST; |
---|
| 49 | + rc = -EADDRINUSE; |
---|
80 | 50 | break; |
---|
81 | 51 | case IPA_RC_L2_MAC_NOT_AUTH_BY_HYP: |
---|
82 | 52 | case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP: |
---|
83 | | - rc = -EPERM; |
---|
| 53 | + rc = -EADDRNOTAVAIL; |
---|
84 | 54 | break; |
---|
85 | 55 | case IPA_RC_L2_MAC_NOT_FOUND: |
---|
86 | 56 | rc = -ENOENT; |
---|
87 | | - break; |
---|
88 | | - case -ENOMEM: |
---|
89 | | - rc = -ENOMEM; |
---|
90 | 57 | break; |
---|
91 | 58 | default: |
---|
92 | 59 | rc = -EIO; |
---|
93 | 60 | break; |
---|
94 | 61 | } |
---|
95 | 62 | return rc; |
---|
| 63 | +} |
---|
| 64 | + |
---|
| 65 | +static int qeth_l2_send_setdelmac_cb(struct qeth_card *card, |
---|
| 66 | + struct qeth_reply *reply, |
---|
| 67 | + unsigned long data) |
---|
| 68 | +{ |
---|
| 69 | + struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
---|
| 70 | + |
---|
| 71 | + return qeth_l2_setdelmac_makerc(card, cmd->hdr.return_code); |
---|
96 | 72 | } |
---|
97 | 73 | |
---|
98 | 74 | static int qeth_l2_send_setdelmac(struct qeth_card *card, __u8 *mac, |
---|
.. | .. |
---|
102 | 78 | struct qeth_cmd_buffer *iob; |
---|
103 | 79 | |
---|
104 | 80 | QETH_CARD_TEXT(card, 2, "L2sdmac"); |
---|
105 | | - iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); |
---|
| 81 | + iob = qeth_ipa_alloc_cmd(card, ipacmd, QETH_PROT_IPV4, |
---|
| 82 | + IPA_DATA_SIZEOF(setdelmac)); |
---|
106 | 83 | if (!iob) |
---|
107 | 84 | return -ENOMEM; |
---|
108 | 85 | cmd = __ipa_cmd(iob); |
---|
109 | 86 | cmd->data.setdelmac.mac_length = ETH_ALEN; |
---|
110 | 87 | ether_addr_copy(cmd->data.setdelmac.mac, mac); |
---|
111 | | - return qeth_setdelmac_makerc(card, qeth_send_ipa_cmd(card, iob, |
---|
112 | | - NULL, NULL)); |
---|
| 88 | + return qeth_send_ipa_cmd(card, iob, qeth_l2_send_setdelmac_cb, NULL); |
---|
113 | 89 | } |
---|
114 | 90 | |
---|
115 | 91 | static int qeth_l2_send_setmac(struct qeth_card *card, __u8 *mac) |
---|
.. | .. |
---|
120 | 96 | rc = qeth_l2_send_setdelmac(card, mac, IPA_CMD_SETVMAC); |
---|
121 | 97 | if (rc == 0) { |
---|
122 | 98 | dev_info(&card->gdev->dev, |
---|
123 | | - "MAC address %pM successfully registered on device %s\n", |
---|
124 | | - mac, card->dev->name); |
---|
| 99 | + "MAC address %pM successfully registered\n", mac); |
---|
125 | 100 | } else { |
---|
126 | 101 | switch (rc) { |
---|
127 | | - case -EEXIST: |
---|
| 102 | + case -EADDRINUSE: |
---|
128 | 103 | dev_warn(&card->gdev->dev, |
---|
129 | 104 | "MAC address %pM already exists\n", mac); |
---|
130 | 105 | break; |
---|
131 | | - case -EPERM: |
---|
| 106 | + case -EADDRNOTAVAIL: |
---|
132 | 107 | dev_warn(&card->gdev->dev, |
---|
133 | 108 | "MAC address %pM is not authorized\n", mac); |
---|
134 | 109 | break; |
---|
.. | .. |
---|
145 | 120 | |
---|
146 | 121 | QETH_CARD_TEXT(card, 2, "L2Wmac"); |
---|
147 | 122 | rc = qeth_l2_send_setdelmac(card, mac, cmd); |
---|
148 | | - if (rc == -EEXIST) |
---|
149 | | - QETH_DBF_MESSAGE(2, "MAC %pM already registered on %s\n", |
---|
150 | | - mac, QETH_CARD_IFNAME(card)); |
---|
| 123 | + if (rc == -EADDRINUSE) |
---|
| 124 | + QETH_DBF_MESSAGE(2, "MAC already registered on device %x\n", |
---|
| 125 | + CARD_DEVID(card)); |
---|
151 | 126 | else if (rc) |
---|
152 | | - QETH_DBF_MESSAGE(2, "Failed to register MAC %pM on %s: %d\n", |
---|
153 | | - mac, QETH_CARD_IFNAME(card), rc); |
---|
| 127 | + QETH_DBF_MESSAGE(2, "Failed to register MAC on device %x: %d\n", |
---|
| 128 | + CARD_DEVID(card), rc); |
---|
154 | 129 | return rc; |
---|
155 | 130 | } |
---|
156 | 131 | |
---|
.. | .. |
---|
163 | 138 | QETH_CARD_TEXT(card, 2, "L2Rmac"); |
---|
164 | 139 | rc = qeth_l2_send_setdelmac(card, mac, cmd); |
---|
165 | 140 | if (rc) |
---|
166 | | - QETH_DBF_MESSAGE(2, "Failed to delete MAC %pM on %s: %d\n", |
---|
167 | | - mac, QETH_CARD_IFNAME(card), rc); |
---|
| 141 | + QETH_DBF_MESSAGE(2, "Failed to delete MAC on device %u: %d\n", |
---|
| 142 | + CARD_DEVID(card), rc); |
---|
168 | 143 | return rc; |
---|
169 | 144 | } |
---|
170 | 145 | |
---|
171 | | -static void qeth_l2_del_all_macs(struct qeth_card *card) |
---|
| 146 | +static void qeth_l2_drain_rx_mode_cache(struct qeth_card *card) |
---|
172 | 147 | { |
---|
173 | 148 | struct qeth_mac *mac; |
---|
174 | 149 | struct hlist_node *tmp; |
---|
175 | 150 | int i; |
---|
176 | 151 | |
---|
177 | | - spin_lock_bh(&card->mclock); |
---|
178 | | - hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) { |
---|
| 152 | + hash_for_each_safe(card->rx_mode_addrs, i, tmp, mac, hnode) { |
---|
179 | 153 | hash_del(&mac->hnode); |
---|
180 | 154 | kfree(mac); |
---|
181 | 155 | } |
---|
182 | | - spin_unlock_bh(&card->mclock); |
---|
183 | 156 | } |
---|
184 | 157 | |
---|
185 | | -static int qeth_l2_get_cast_type(struct qeth_card *card, struct sk_buff *skb) |
---|
| 158 | +static void qeth_l2_fill_header(struct qeth_qdio_out_q *queue, |
---|
| 159 | + struct qeth_hdr *hdr, struct sk_buff *skb, |
---|
| 160 | + int ipv, unsigned int data_len) |
---|
186 | 161 | { |
---|
187 | | - if (card->info.type == QETH_CARD_TYPE_OSN) |
---|
188 | | - return RTN_UNICAST; |
---|
189 | | - if (is_broadcast_ether_addr(skb->data)) |
---|
190 | | - return RTN_BROADCAST; |
---|
191 | | - if (is_multicast_ether_addr(skb->data)) |
---|
192 | | - return RTN_MULTICAST; |
---|
193 | | - return RTN_UNICAST; |
---|
194 | | -} |
---|
| 162 | + int cast_type = qeth_get_ether_cast_type(skb); |
---|
| 163 | + struct vlan_ethhdr *veth = vlan_eth_hdr(skb); |
---|
195 | 164 | |
---|
196 | | -static void qeth_l2_fill_header(struct qeth_hdr *hdr, struct sk_buff *skb, |
---|
197 | | - int cast_type, unsigned int data_len) |
---|
198 | | -{ |
---|
199 | | - struct vlan_ethhdr *veth = (struct vlan_ethhdr *)skb_mac_header(skb); |
---|
200 | | - |
---|
201 | | - memset(hdr, 0, sizeof(struct qeth_hdr)); |
---|
202 | | - hdr->hdr.l2.id = QETH_HEADER_TYPE_LAYER2; |
---|
203 | 165 | hdr->hdr.l2.pkt_length = data_len; |
---|
| 166 | + |
---|
| 167 | + if (skb_is_gso(skb)) { |
---|
| 168 | + hdr->hdr.l2.id = QETH_HEADER_TYPE_L2_TSO; |
---|
| 169 | + } else { |
---|
| 170 | + hdr->hdr.l2.id = QETH_HEADER_TYPE_LAYER2; |
---|
| 171 | + if (skb->ip_summed == CHECKSUM_PARTIAL) |
---|
| 172 | + qeth_tx_csum(skb, &hdr->hdr.l2.flags[1], ipv); |
---|
| 173 | + } |
---|
204 | 174 | |
---|
205 | 175 | /* set byte byte 3 to casting flags */ |
---|
206 | 176 | if (cast_type == RTN_MULTICAST) |
---|
.. | .. |
---|
213 | 183 | /* VSWITCH relies on the VLAN |
---|
214 | 184 | * information to be present in |
---|
215 | 185 | * the QDIO header */ |
---|
216 | | - if (veth->h_vlan_proto == __constant_htons(ETH_P_8021Q)) { |
---|
| 186 | + if (veth->h_vlan_proto == htons(ETH_P_8021Q)) { |
---|
217 | 187 | hdr->hdr.l2.flags[2] |= QETH_LAYER2_FLAG_VLAN; |
---|
218 | 188 | hdr->hdr.l2.vlan_id = ntohs(veth->h_vlan_TCI); |
---|
219 | 189 | } |
---|
220 | 190 | } |
---|
221 | 191 | |
---|
222 | | -static int qeth_setdelvlan_makerc(struct qeth_card *card, int retcode) |
---|
| 192 | +static int qeth_l2_setdelvlan_makerc(struct qeth_card *card, u16 retcode) |
---|
223 | 193 | { |
---|
224 | 194 | if (retcode) |
---|
225 | 195 | QETH_CARD_TEXT_(card, 2, "err%04x", retcode); |
---|
.. | .. |
---|
235 | 205 | return -ENOENT; |
---|
236 | 206 | case IPA_RC_L2_VLAN_ID_NOT_ALLOWED: |
---|
237 | 207 | return -EPERM; |
---|
238 | | - case -ENOMEM: |
---|
239 | | - return -ENOMEM; |
---|
240 | 208 | default: |
---|
241 | 209 | return -EIO; |
---|
242 | 210 | } |
---|
.. | .. |
---|
250 | 218 | |
---|
251 | 219 | QETH_CARD_TEXT(card, 2, "L2sdvcb"); |
---|
252 | 220 | if (cmd->hdr.return_code) { |
---|
253 | | - QETH_DBF_MESSAGE(2, "Error in processing VLAN %i on %s: 0x%x.\n", |
---|
| 221 | + QETH_DBF_MESSAGE(2, "Error in processing VLAN %u on device %x: %#x.\n", |
---|
254 | 222 | cmd->data.setdelvlan.vlan_id, |
---|
255 | | - QETH_CARD_IFNAME(card), cmd->hdr.return_code); |
---|
| 223 | + CARD_DEVID(card), cmd->hdr.return_code); |
---|
256 | 224 | QETH_CARD_TEXT_(card, 2, "L2VL%4x", cmd->hdr.command); |
---|
257 | | - QETH_CARD_TEXT_(card, 2, "err%d", cmd->hdr.return_code); |
---|
258 | 225 | } |
---|
259 | | - return 0; |
---|
| 226 | + return qeth_l2_setdelvlan_makerc(card, cmd->hdr.return_code); |
---|
260 | 227 | } |
---|
261 | 228 | |
---|
262 | 229 | static int qeth_l2_send_setdelvlan(struct qeth_card *card, __u16 i, |
---|
.. | .. |
---|
266 | 233 | struct qeth_cmd_buffer *iob; |
---|
267 | 234 | |
---|
268 | 235 | QETH_CARD_TEXT_(card, 4, "L2sdv%x", ipacmd); |
---|
269 | | - iob = qeth_get_ipacmd_buffer(card, ipacmd, QETH_PROT_IPV4); |
---|
| 236 | + iob = qeth_ipa_alloc_cmd(card, ipacmd, QETH_PROT_IPV4, |
---|
| 237 | + IPA_DATA_SIZEOF(setdelvlan)); |
---|
270 | 238 | if (!iob) |
---|
271 | 239 | return -ENOMEM; |
---|
272 | 240 | cmd = __ipa_cmd(iob); |
---|
273 | 241 | cmd->data.setdelvlan.vlan_id = i; |
---|
274 | | - return qeth_setdelvlan_makerc(card, qeth_send_ipa_cmd(card, iob, |
---|
275 | | - qeth_l2_send_setdelvlan_cb, NULL)); |
---|
276 | | -} |
---|
277 | | - |
---|
278 | | -static void qeth_l2_process_vlans(struct qeth_card *card) |
---|
279 | | -{ |
---|
280 | | - struct qeth_vlan_vid *id; |
---|
281 | | - |
---|
282 | | - QETH_CARD_TEXT(card, 3, "L2prcvln"); |
---|
283 | | - mutex_lock(&card->vid_list_mutex); |
---|
284 | | - list_for_each_entry(id, &card->vid_list, list) { |
---|
285 | | - qeth_l2_send_setdelvlan(card, id->vid, IPA_CMD_SETVLAN); |
---|
286 | | - } |
---|
287 | | - mutex_unlock(&card->vid_list_mutex); |
---|
| 242 | + return qeth_send_ipa_cmd(card, iob, qeth_l2_send_setdelvlan_cb, NULL); |
---|
288 | 243 | } |
---|
289 | 244 | |
---|
290 | 245 | static int qeth_l2_vlan_rx_add_vid(struct net_device *dev, |
---|
291 | 246 | __be16 proto, u16 vid) |
---|
292 | 247 | { |
---|
293 | 248 | struct qeth_card *card = dev->ml_priv; |
---|
294 | | - struct qeth_vlan_vid *id; |
---|
295 | | - int rc; |
---|
296 | 249 | |
---|
297 | 250 | QETH_CARD_TEXT_(card, 4, "aid:%d", vid); |
---|
298 | 251 | if (!vid) |
---|
299 | 252 | return 0; |
---|
300 | | - if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { |
---|
301 | | - QETH_CARD_TEXT(card, 3, "aidREC"); |
---|
302 | | - return 0; |
---|
303 | | - } |
---|
304 | | - id = kmalloc(sizeof(*id), GFP_KERNEL); |
---|
305 | | - if (id) { |
---|
306 | | - id->vid = vid; |
---|
307 | | - rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN); |
---|
308 | | - if (rc) { |
---|
309 | | - kfree(id); |
---|
310 | | - return rc; |
---|
311 | | - } |
---|
312 | | - mutex_lock(&card->vid_list_mutex); |
---|
313 | | - list_add_tail(&id->list, &card->vid_list); |
---|
314 | | - mutex_unlock(&card->vid_list_mutex); |
---|
315 | | - } else { |
---|
316 | | - return -ENOMEM; |
---|
317 | | - } |
---|
318 | | - return 0; |
---|
| 253 | + |
---|
| 254 | + return qeth_l2_send_setdelvlan(card, vid, IPA_CMD_SETVLAN); |
---|
319 | 255 | } |
---|
320 | 256 | |
---|
321 | 257 | static int qeth_l2_vlan_rx_kill_vid(struct net_device *dev, |
---|
322 | 258 | __be16 proto, u16 vid) |
---|
323 | 259 | { |
---|
324 | | - struct qeth_vlan_vid *id, *tmpid = NULL; |
---|
325 | 260 | struct qeth_card *card = dev->ml_priv; |
---|
326 | | - int rc = 0; |
---|
327 | 261 | |
---|
328 | 262 | QETH_CARD_TEXT_(card, 4, "kid:%d", vid); |
---|
329 | | - if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { |
---|
330 | | - QETH_CARD_TEXT(card, 3, "kidREC"); |
---|
| 263 | + if (!vid) |
---|
331 | 264 | return 0; |
---|
332 | | - } |
---|
333 | | - mutex_lock(&card->vid_list_mutex); |
---|
334 | | - list_for_each_entry(id, &card->vid_list, list) { |
---|
335 | | - if (id->vid == vid) { |
---|
336 | | - list_del(&id->list); |
---|
337 | | - tmpid = id; |
---|
338 | | - break; |
---|
339 | | - } |
---|
340 | | - } |
---|
341 | | - mutex_unlock(&card->vid_list_mutex); |
---|
342 | | - if (tmpid) { |
---|
343 | | - rc = qeth_l2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN); |
---|
344 | | - kfree(tmpid); |
---|
345 | | - } |
---|
346 | | - return rc; |
---|
| 265 | + |
---|
| 266 | + return qeth_l2_send_setdelvlan(card, vid, IPA_CMD_DELVLAN); |
---|
347 | 267 | } |
---|
348 | 268 | |
---|
349 | | -static void qeth_l2_stop_card(struct qeth_card *card, int recovery_mode) |
---|
| 269 | +static void qeth_l2_set_pnso_mode(struct qeth_card *card, |
---|
| 270 | + enum qeth_pnso_mode mode) |
---|
350 | 271 | { |
---|
351 | | - QETH_DBF_TEXT(SETUP , 2, "stopcard"); |
---|
352 | | - QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); |
---|
| 272 | + spin_lock_irq(get_ccwdev_lock(CARD_RDEV(card))); |
---|
| 273 | + WRITE_ONCE(card->info.pnso_mode, mode); |
---|
| 274 | + spin_unlock_irq(get_ccwdev_lock(CARD_RDEV(card))); |
---|
353 | 275 | |
---|
354 | | - qeth_set_allowed_threads(card, 0, 1); |
---|
355 | | - if (card->read.state == CH_STATE_UP && |
---|
356 | | - card->write.state == CH_STATE_UP && |
---|
357 | | - (card->state == CARD_STATE_UP)) { |
---|
358 | | - if (recovery_mode && |
---|
359 | | - card->info.type != QETH_CARD_TYPE_OSN) { |
---|
360 | | - qeth_l2_stop(card->dev); |
---|
361 | | - } else { |
---|
362 | | - rtnl_lock(); |
---|
363 | | - dev_close(card->dev); |
---|
364 | | - rtnl_unlock(); |
---|
365 | | - } |
---|
366 | | - card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED; |
---|
367 | | - card->state = CARD_STATE_SOFTSETUP; |
---|
368 | | - } |
---|
369 | | - if (card->state == CARD_STATE_SOFTSETUP) { |
---|
370 | | - qeth_l2_del_all_macs(card); |
---|
371 | | - qeth_clear_ipacmd_list(card); |
---|
372 | | - card->state = CARD_STATE_HARDSETUP; |
---|
373 | | - } |
---|
374 | | - if (card->state == CARD_STATE_HARDSETUP) { |
---|
375 | | - qeth_qdio_clear_card(card, 0); |
---|
376 | | - qeth_clear_qdio_buffers(card); |
---|
377 | | - qeth_clear_working_pool_list(card); |
---|
378 | | - card->state = CARD_STATE_DOWN; |
---|
379 | | - } |
---|
380 | | - if (card->state == CARD_STATE_DOWN) { |
---|
381 | | - qeth_clear_cmd_buffers(&card->read); |
---|
382 | | - qeth_clear_cmd_buffers(&card->write); |
---|
383 | | - } |
---|
| 276 | + if (mode == QETH_PNSO_NONE) |
---|
| 277 | + drain_workqueue(card->event_wq); |
---|
384 | 278 | } |
---|
385 | 279 | |
---|
386 | | -static int qeth_l2_process_inbound_buffer(struct qeth_card *card, |
---|
387 | | - int budget, int *done) |
---|
| 280 | +static void qeth_l2_dev2br_fdb_flush(struct qeth_card *card) |
---|
388 | 281 | { |
---|
389 | | - int work_done = 0; |
---|
390 | | - struct sk_buff *skb; |
---|
391 | | - struct qeth_hdr *hdr; |
---|
392 | | - unsigned int len; |
---|
| 282 | + struct switchdev_notifier_fdb_info info; |
---|
393 | 283 | |
---|
394 | | - *done = 0; |
---|
395 | | - WARN_ON_ONCE(!budget); |
---|
396 | | - while (budget) { |
---|
397 | | - skb = qeth_core_get_next_skb(card, |
---|
398 | | - &card->qdio.in_q->bufs[card->rx.b_index], |
---|
399 | | - &card->rx.b_element, &card->rx.e_offset, &hdr); |
---|
400 | | - if (!skb) { |
---|
401 | | - *done = 1; |
---|
402 | | - break; |
---|
403 | | - } |
---|
404 | | - switch (hdr->hdr.l2.id) { |
---|
405 | | - case QETH_HEADER_TYPE_LAYER2: |
---|
406 | | - skb->protocol = eth_type_trans(skb, skb->dev); |
---|
407 | | - qeth_rx_csum(card, skb, hdr->hdr.l2.flags[1]); |
---|
408 | | - if (skb->protocol == htons(ETH_P_802_2)) |
---|
409 | | - *((__u32 *)skb->cb) = ++card->seqno.pkt_seqno; |
---|
410 | | - len = skb->len; |
---|
411 | | - napi_gro_receive(&card->napi, skb); |
---|
412 | | - break; |
---|
413 | | - case QETH_HEADER_TYPE_OSN: |
---|
414 | | - if (card->info.type == QETH_CARD_TYPE_OSN) { |
---|
415 | | - skb_push(skb, sizeof(struct qeth_hdr)); |
---|
416 | | - skb_copy_to_linear_data(skb, hdr, |
---|
417 | | - sizeof(struct qeth_hdr)); |
---|
418 | | - len = skb->len; |
---|
419 | | - card->osn_info.data_cb(skb); |
---|
420 | | - break; |
---|
421 | | - } |
---|
422 | | - /* else unknown */ |
---|
423 | | - default: |
---|
424 | | - dev_kfree_skb_any(skb); |
---|
425 | | - QETH_CARD_TEXT(card, 3, "inbunkno"); |
---|
426 | | - QETH_DBF_HEX(CTRL, 3, hdr, sizeof(*hdr)); |
---|
427 | | - continue; |
---|
428 | | - } |
---|
429 | | - work_done++; |
---|
430 | | - budget--; |
---|
431 | | - card->stats.rx_packets++; |
---|
432 | | - card->stats.rx_bytes += len; |
---|
433 | | - } |
---|
434 | | - return work_done; |
---|
| 284 | + QETH_CARD_TEXT(card, 2, "fdbflush"); |
---|
| 285 | + |
---|
| 286 | + info.addr = NULL; |
---|
| 287 | + /* flush all VLANs: */ |
---|
| 288 | + info.vid = 0; |
---|
| 289 | + info.added_by_user = false; |
---|
| 290 | + info.offloaded = true; |
---|
| 291 | + |
---|
| 292 | + call_switchdev_notifiers(SWITCHDEV_FDB_FLUSH_TO_BRIDGE, |
---|
| 293 | + card->dev, &info.info, NULL); |
---|
435 | 294 | } |
---|
436 | 295 | |
---|
437 | 296 | static int qeth_l2_request_initial_mac(struct qeth_card *card) |
---|
438 | 297 | { |
---|
439 | 298 | int rc = 0; |
---|
440 | 299 | |
---|
441 | | - QETH_DBF_TEXT(SETUP, 2, "l2reqmac"); |
---|
442 | | - QETH_DBF_TEXT_(SETUP, 2, "doL2%s", CARD_BUS_ID(card)); |
---|
| 300 | + QETH_CARD_TEXT(card, 2, "l2reqmac"); |
---|
443 | 301 | |
---|
444 | 302 | if (MACHINE_IS_VM) { |
---|
445 | 303 | rc = qeth_vm_request_mac(card); |
---|
446 | 304 | if (!rc) |
---|
447 | 305 | goto out; |
---|
448 | | - QETH_DBF_MESSAGE(2, "z/VM MAC Service failed on device %s: x%x\n", |
---|
449 | | - CARD_BUS_ID(card), rc); |
---|
450 | | - QETH_DBF_TEXT_(SETUP, 2, "err%04x", rc); |
---|
| 306 | + QETH_DBF_MESSAGE(2, "z/VM MAC Service failed on device %x: %#x\n", |
---|
| 307 | + CARD_DEVID(card), rc); |
---|
| 308 | + QETH_CARD_TEXT_(card, 2, "err%04x", rc); |
---|
451 | 309 | /* fall back to alternative mechanism: */ |
---|
452 | 310 | } |
---|
453 | 311 | |
---|
454 | | - if (card->info.type == QETH_CARD_TYPE_IQD || |
---|
455 | | - card->info.type == QETH_CARD_TYPE_OSM || |
---|
456 | | - card->info.type == QETH_CARD_TYPE_OSX || |
---|
457 | | - card->info.guestlan) { |
---|
| 312 | + if (!IS_OSN(card)) { |
---|
458 | 313 | rc = qeth_setadpparms_change_macaddr(card); |
---|
459 | 314 | if (!rc) |
---|
460 | 315 | goto out; |
---|
461 | | - QETH_DBF_MESSAGE(2, "READ_MAC Assist failed on device %s: x%x\n", |
---|
462 | | - CARD_BUS_ID(card), rc); |
---|
463 | | - QETH_DBF_TEXT_(SETUP, 2, "1err%04x", rc); |
---|
| 316 | + QETH_DBF_MESSAGE(2, "READ_MAC Assist failed on device %x: %#x\n", |
---|
| 317 | + CARD_DEVID(card), rc); |
---|
| 318 | + QETH_CARD_TEXT_(card, 2, "1err%04x", rc); |
---|
464 | 319 | /* fall back once more: */ |
---|
465 | 320 | } |
---|
466 | 321 | |
---|
467 | 322 | /* some devices don't support a custom MAC address: */ |
---|
468 | | - if (card->info.type == QETH_CARD_TYPE_OSM || |
---|
469 | | - card->info.type == QETH_CARD_TYPE_OSX) |
---|
| 323 | + if (IS_OSM(card) || IS_OSX(card)) |
---|
470 | 324 | return (rc) ? rc : -EADDRNOTAVAIL; |
---|
471 | 325 | eth_hw_addr_random(card->dev); |
---|
472 | 326 | |
---|
473 | 327 | out: |
---|
474 | | - QETH_DBF_HEX(SETUP, 2, card->dev->dev_addr, card->dev->addr_len); |
---|
| 328 | + QETH_CARD_HEX(card, 2, card->dev->dev_addr, card->dev->addr_len); |
---|
475 | 329 | return 0; |
---|
| 330 | +} |
---|
| 331 | + |
---|
| 332 | +static void qeth_l2_register_dev_addr(struct qeth_card *card) |
---|
| 333 | +{ |
---|
| 334 | + if (!is_valid_ether_addr(card->dev->dev_addr)) |
---|
| 335 | + qeth_l2_request_initial_mac(card); |
---|
| 336 | + |
---|
| 337 | + if (!IS_OSN(card) && !qeth_l2_send_setmac(card, card->dev->dev_addr)) |
---|
| 338 | + card->info.dev_addr_is_registered = 1; |
---|
| 339 | + else |
---|
| 340 | + card->info.dev_addr_is_registered = 0; |
---|
| 341 | +} |
---|
| 342 | + |
---|
| 343 | +static int qeth_l2_validate_addr(struct net_device *dev) |
---|
| 344 | +{ |
---|
| 345 | + struct qeth_card *card = dev->ml_priv; |
---|
| 346 | + |
---|
| 347 | + if (card->info.dev_addr_is_registered) |
---|
| 348 | + return eth_validate_addr(dev); |
---|
| 349 | + |
---|
| 350 | + QETH_CARD_TEXT(card, 4, "nomacadr"); |
---|
| 351 | + return -EPERM; |
---|
476 | 352 | } |
---|
477 | 353 | |
---|
478 | 354 | static int qeth_l2_set_mac_address(struct net_device *dev, void *p) |
---|
.. | .. |
---|
484 | 360 | |
---|
485 | 361 | QETH_CARD_TEXT(card, 3, "setmac"); |
---|
486 | 362 | |
---|
487 | | - if (card->info.type == QETH_CARD_TYPE_OSN || |
---|
488 | | - card->info.type == QETH_CARD_TYPE_OSM || |
---|
489 | | - card->info.type == QETH_CARD_TYPE_OSX) { |
---|
| 363 | + if (IS_OSM(card) || IS_OSX(card)) { |
---|
490 | 364 | QETH_CARD_TEXT(card, 3, "setmcTYP"); |
---|
491 | 365 | return -EOPNOTSUPP; |
---|
492 | 366 | } |
---|
.. | .. |
---|
494 | 368 | if (!is_valid_ether_addr(addr->sa_data)) |
---|
495 | 369 | return -EADDRNOTAVAIL; |
---|
496 | 370 | |
---|
497 | | - if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { |
---|
498 | | - QETH_CARD_TEXT(card, 3, "setmcREC"); |
---|
499 | | - return -ERESTARTSYS; |
---|
500 | | - } |
---|
501 | | - |
---|
502 | | - /* avoid racing against concurrent state change: */ |
---|
503 | | - if (!mutex_trylock(&card->conf_mutex)) |
---|
504 | | - return -EAGAIN; |
---|
505 | | - |
---|
506 | | - if (!qeth_card_hw_is_reachable(card)) { |
---|
507 | | - ether_addr_copy(dev->dev_addr, addr->sa_data); |
---|
508 | | - goto out_unlock; |
---|
509 | | - } |
---|
510 | | - |
---|
511 | 371 | /* don't register the same address twice */ |
---|
512 | 372 | if (ether_addr_equal_64bits(dev->dev_addr, addr->sa_data) && |
---|
513 | | - (card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED)) |
---|
514 | | - goto out_unlock; |
---|
| 373 | + card->info.dev_addr_is_registered) |
---|
| 374 | + return 0; |
---|
515 | 375 | |
---|
516 | 376 | /* add the new address, switch over, drop the old */ |
---|
517 | 377 | rc = qeth_l2_send_setmac(card, addr->sa_data); |
---|
518 | 378 | if (rc) |
---|
519 | | - goto out_unlock; |
---|
| 379 | + return rc; |
---|
520 | 380 | ether_addr_copy(old_addr, dev->dev_addr); |
---|
521 | 381 | ether_addr_copy(dev->dev_addr, addr->sa_data); |
---|
522 | 382 | |
---|
523 | | - if (card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED) |
---|
| 383 | + if (card->info.dev_addr_is_registered) |
---|
524 | 384 | qeth_l2_remove_mac(card, old_addr); |
---|
525 | | - card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED; |
---|
526 | | - |
---|
527 | | -out_unlock: |
---|
528 | | - mutex_unlock(&card->conf_mutex); |
---|
529 | | - return rc; |
---|
| 385 | + card->info.dev_addr_is_registered = 1; |
---|
| 386 | + return 0; |
---|
530 | 387 | } |
---|
531 | 388 | |
---|
532 | | -static void qeth_promisc_to_bridge(struct qeth_card *card) |
---|
| 389 | +static void qeth_l2_promisc_to_bridge(struct qeth_card *card, bool enable) |
---|
533 | 390 | { |
---|
534 | | - struct net_device *dev = card->dev; |
---|
535 | | - enum qeth_ipa_promisc_modes promisc_mode; |
---|
536 | 391 | int role; |
---|
537 | 392 | int rc; |
---|
538 | 393 | |
---|
539 | 394 | QETH_CARD_TEXT(card, 3, "pmisc2br"); |
---|
540 | 395 | |
---|
541 | | - if (!card->options.sbp.reflect_promisc) |
---|
542 | | - return; |
---|
543 | | - promisc_mode = (dev->flags & IFF_PROMISC) ? SET_PROMISC_MODE_ON |
---|
544 | | - : SET_PROMISC_MODE_OFF; |
---|
545 | | - if (promisc_mode == card->info.promisc_mode) |
---|
546 | | - return; |
---|
547 | | - |
---|
548 | | - if (promisc_mode == SET_PROMISC_MODE_ON) { |
---|
| 396 | + if (enable) { |
---|
549 | 397 | if (card->options.sbp.reflect_promisc_primary) |
---|
550 | 398 | role = QETH_SBP_ROLE_PRIMARY; |
---|
551 | 399 | else |
---|
.. | .. |
---|
554 | 402 | role = QETH_SBP_ROLE_NONE; |
---|
555 | 403 | |
---|
556 | 404 | rc = qeth_bridgeport_setrole(card, role); |
---|
557 | | - QETH_DBF_TEXT_(SETUP, 2, "bpm%c%04x", |
---|
558 | | - (promisc_mode == SET_PROMISC_MODE_ON) ? '+' : '-', rc); |
---|
| 405 | + QETH_CARD_TEXT_(card, 2, "bpm%c%04x", enable ? '+' : '-', rc); |
---|
559 | 406 | if (!rc) { |
---|
560 | 407 | card->options.sbp.role = role; |
---|
561 | | - card->info.promisc_mode = promisc_mode; |
---|
| 408 | + card->info.promisc_mode = enable; |
---|
562 | 409 | } |
---|
563 | | - |
---|
564 | 410 | } |
---|
| 411 | + |
---|
| 412 | +static void qeth_l2_set_promisc_mode(struct qeth_card *card) |
---|
| 413 | +{ |
---|
| 414 | + bool enable = card->dev->flags & IFF_PROMISC; |
---|
| 415 | + |
---|
| 416 | + if (card->info.promisc_mode == enable) |
---|
| 417 | + return; |
---|
| 418 | + |
---|
| 419 | + if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) { |
---|
| 420 | + qeth_setadp_promisc_mode(card, enable); |
---|
| 421 | + } else { |
---|
| 422 | + mutex_lock(&card->sbp_lock); |
---|
| 423 | + if (card->options.sbp.reflect_promisc) |
---|
| 424 | + qeth_l2_promisc_to_bridge(card, enable); |
---|
| 425 | + mutex_unlock(&card->sbp_lock); |
---|
| 426 | + } |
---|
| 427 | +} |
---|
| 428 | + |
---|
565 | 429 | /* New MAC address is added to the hash table and marked to be written on card |
---|
566 | 430 | * only if there is not in the hash table storage already |
---|
567 | 431 | * |
---|
.. | .. |
---|
571 | 435 | u32 mac_hash = get_unaligned((u32 *)(&ha->addr[2])); |
---|
572 | 436 | struct qeth_mac *mac; |
---|
573 | 437 | |
---|
574 | | - hash_for_each_possible(card->mac_htable, mac, hnode, mac_hash) { |
---|
| 438 | + hash_for_each_possible(card->rx_mode_addrs, mac, hnode, mac_hash) { |
---|
575 | 439 | if (ether_addr_equal_64bits(ha->addr, mac->mac_addr)) { |
---|
576 | 440 | mac->disp_flag = QETH_DISP_ADDR_DO_NOTHING; |
---|
577 | 441 | return; |
---|
.. | .. |
---|
585 | 449 | ether_addr_copy(mac->mac_addr, ha->addr); |
---|
586 | 450 | mac->disp_flag = QETH_DISP_ADDR_ADD; |
---|
587 | 451 | |
---|
588 | | - hash_add(card->mac_htable, &mac->hnode, mac_hash); |
---|
| 452 | + hash_add(card->rx_mode_addrs, &mac->hnode, mac_hash); |
---|
589 | 453 | } |
---|
590 | 454 | |
---|
591 | | -static void qeth_l2_set_rx_mode(struct net_device *dev) |
---|
| 455 | +static void qeth_l2_rx_mode_work(struct work_struct *work) |
---|
592 | 456 | { |
---|
593 | | - struct qeth_card *card = dev->ml_priv; |
---|
| 457 | + struct qeth_card *card = container_of(work, struct qeth_card, |
---|
| 458 | + rx_mode_work); |
---|
| 459 | + struct net_device *dev = card->dev; |
---|
594 | 460 | struct netdev_hw_addr *ha; |
---|
595 | 461 | struct qeth_mac *mac; |
---|
596 | 462 | struct hlist_node *tmp; |
---|
597 | 463 | int i; |
---|
598 | 464 | int rc; |
---|
599 | 465 | |
---|
600 | | - if (card->info.type == QETH_CARD_TYPE_OSN) |
---|
601 | | - return; |
---|
602 | | - |
---|
603 | 466 | QETH_CARD_TEXT(card, 3, "setmulti"); |
---|
604 | | - if (qeth_threads_running(card, QETH_RECOVER_THREAD) && |
---|
605 | | - (card->state != CARD_STATE_UP)) |
---|
606 | | - return; |
---|
607 | 467 | |
---|
608 | | - spin_lock_bh(&card->mclock); |
---|
609 | | - |
---|
| 468 | + netif_addr_lock_bh(dev); |
---|
610 | 469 | netdev_for_each_mc_addr(ha, dev) |
---|
611 | 470 | qeth_l2_add_mac(card, ha); |
---|
612 | 471 | netdev_for_each_uc_addr(ha, dev) |
---|
613 | 472 | qeth_l2_add_mac(card, ha); |
---|
| 473 | + netif_addr_unlock_bh(dev); |
---|
614 | 474 | |
---|
615 | | - hash_for_each_safe(card->mac_htable, i, tmp, mac, hnode) { |
---|
| 475 | + hash_for_each_safe(card->rx_mode_addrs, i, tmp, mac, hnode) { |
---|
616 | 476 | switch (mac->disp_flag) { |
---|
617 | 477 | case QETH_DISP_ADDR_DELETE: |
---|
618 | 478 | qeth_l2_remove_mac(card, mac->mac_addr); |
---|
.. | .. |
---|
626 | 486 | kfree(mac); |
---|
627 | 487 | break; |
---|
628 | 488 | } |
---|
629 | | - /* fall through */ |
---|
| 489 | + fallthrough; |
---|
630 | 490 | default: |
---|
631 | 491 | /* for next call to set_rx_mode(): */ |
---|
632 | 492 | mac->disp_flag = QETH_DISP_ADDR_DELETE; |
---|
633 | 493 | } |
---|
634 | 494 | } |
---|
635 | 495 | |
---|
636 | | - spin_unlock_bh(&card->mclock); |
---|
637 | | - |
---|
638 | | - if (qeth_adp_supported(card, IPA_SETADP_SET_PROMISC_MODE)) |
---|
639 | | - qeth_setadp_promisc_mode(card); |
---|
640 | | - else |
---|
641 | | - qeth_promisc_to_bridge(card); |
---|
642 | | -} |
---|
643 | | - |
---|
644 | | -static int qeth_l2_xmit(struct qeth_card *card, struct sk_buff *skb, |
---|
645 | | - struct qeth_qdio_out_q *queue, int cast_type, int ipv) |
---|
646 | | -{ |
---|
647 | | - const unsigned int proto_len = IS_IQD(card) ? ETH_HLEN : 0; |
---|
648 | | - const unsigned int hw_hdr_len = sizeof(struct qeth_hdr); |
---|
649 | | - unsigned int frame_len = skb->len; |
---|
650 | | - unsigned int data_offset = 0; |
---|
651 | | - struct qeth_hdr *hdr = NULL; |
---|
652 | | - unsigned int hd_len = 0; |
---|
653 | | - unsigned int elements; |
---|
654 | | - int push_len, rc; |
---|
655 | | - bool is_sg; |
---|
656 | | - |
---|
657 | | - rc = skb_cow_head(skb, hw_hdr_len); |
---|
658 | | - if (rc) |
---|
659 | | - return rc; |
---|
660 | | - |
---|
661 | | - push_len = qeth_add_hw_header(card, skb, &hdr, hw_hdr_len, proto_len, |
---|
662 | | - &elements); |
---|
663 | | - if (push_len < 0) |
---|
664 | | - return push_len; |
---|
665 | | - if (!push_len) { |
---|
666 | | - /* HW header needs its own buffer element. */ |
---|
667 | | - hd_len = hw_hdr_len + proto_len; |
---|
668 | | - data_offset = proto_len; |
---|
669 | | - } |
---|
670 | | - qeth_l2_fill_header(hdr, skb, cast_type, frame_len); |
---|
671 | | - if (skb->ip_summed == CHECKSUM_PARTIAL) { |
---|
672 | | - qeth_tx_csum(skb, &hdr->hdr.l2.flags[1], ipv); |
---|
673 | | - if (card->options.performance_stats) |
---|
674 | | - card->perf_stats.tx_csum++; |
---|
675 | | - } |
---|
676 | | - |
---|
677 | | - is_sg = skb_is_nonlinear(skb); |
---|
678 | | - if (IS_IQD(card)) { |
---|
679 | | - rc = qeth_do_send_packet_fast(queue, skb, hdr, data_offset, |
---|
680 | | - hd_len); |
---|
681 | | - } else { |
---|
682 | | - /* TODO: drop skb_orphan() once TX completion is fast enough */ |
---|
683 | | - skb_orphan(skb); |
---|
684 | | - rc = qeth_do_send_packet(card, queue, skb, hdr, data_offset, |
---|
685 | | - hd_len, elements); |
---|
686 | | - } |
---|
687 | | - |
---|
688 | | - if (!rc) { |
---|
689 | | - if (card->options.performance_stats) { |
---|
690 | | - card->perf_stats.buf_elements_sent += elements; |
---|
691 | | - if (is_sg) |
---|
692 | | - card->perf_stats.sg_skbs_sent++; |
---|
693 | | - } |
---|
694 | | - } else { |
---|
695 | | - if (!push_len) |
---|
696 | | - kmem_cache_free(qeth_core_header_cache, hdr); |
---|
697 | | - if (rc == -EBUSY) |
---|
698 | | - /* roll back to ETH header */ |
---|
699 | | - skb_pull(skb, push_len); |
---|
700 | | - } |
---|
701 | | - return rc; |
---|
| 496 | + qeth_l2_set_promisc_mode(card); |
---|
702 | 497 | } |
---|
703 | 498 | |
---|
704 | 499 | static int qeth_l2_xmit_osn(struct qeth_card *card, struct sk_buff *skb, |
---|
705 | 500 | struct qeth_qdio_out_q *queue) |
---|
706 | 501 | { |
---|
707 | | - unsigned int elements; |
---|
708 | | - struct qeth_hdr *hdr; |
---|
| 502 | + gfp_t gfp = GFP_ATOMIC | (skb_pfmemalloc(skb) ? __GFP_MEMALLOC : 0); |
---|
| 503 | + struct qeth_hdr *hdr = (struct qeth_hdr *)skb->data; |
---|
| 504 | + addr_t end = (addr_t)(skb->data + sizeof(*hdr)); |
---|
| 505 | + addr_t start = (addr_t)skb->data; |
---|
| 506 | + unsigned int elements = 0; |
---|
| 507 | + unsigned int hd_len = 0; |
---|
| 508 | + int rc; |
---|
709 | 509 | |
---|
710 | 510 | if (skb->protocol == htons(ETH_P_IPV6)) |
---|
711 | 511 | return -EPROTONOSUPPORT; |
---|
712 | 512 | |
---|
713 | | - hdr = (struct qeth_hdr *)skb->data; |
---|
714 | | - elements = qeth_get_elements_no(card, skb, 0, 0); |
---|
715 | | - if (!elements) |
---|
716 | | - return -E2BIG; |
---|
717 | | - if (qeth_hdr_chk_and_bounce(skb, &hdr, sizeof(*hdr))) |
---|
718 | | - return -EINVAL; |
---|
719 | | - return qeth_do_send_packet(card, queue, skb, hdr, 0, 0, elements); |
---|
| 513 | + if (qeth_get_elements_for_range(start, end) > 1) { |
---|
| 514 | + /* Misaligned HW header, move it to its own buffer element. */ |
---|
| 515 | + hdr = kmem_cache_alloc(qeth_core_header_cache, gfp); |
---|
| 516 | + if (!hdr) |
---|
| 517 | + return -ENOMEM; |
---|
| 518 | + hd_len = sizeof(*hdr); |
---|
| 519 | + skb_copy_from_linear_data(skb, (char *)hdr, hd_len); |
---|
| 520 | + elements++; |
---|
| 521 | + } |
---|
| 522 | + |
---|
| 523 | + elements += qeth_count_elements(skb, hd_len); |
---|
| 524 | + if (elements > queue->max_elements) { |
---|
| 525 | + rc = -E2BIG; |
---|
| 526 | + goto out; |
---|
| 527 | + } |
---|
| 528 | + |
---|
| 529 | + rc = qeth_do_send_packet(card, queue, skb, hdr, hd_len, hd_len, |
---|
| 530 | + elements); |
---|
| 531 | +out: |
---|
| 532 | + if (rc && hd_len) |
---|
| 533 | + kmem_cache_free(qeth_core_header_cache, hdr); |
---|
| 534 | + return rc; |
---|
720 | 535 | } |
---|
721 | 536 | |
---|
722 | 537 | static netdev_tx_t qeth_l2_hard_start_xmit(struct sk_buff *skb, |
---|
723 | 538 | struct net_device *dev) |
---|
724 | 539 | { |
---|
725 | 540 | struct qeth_card *card = dev->ml_priv; |
---|
726 | | - int cast_type = qeth_l2_get_cast_type(card, skb); |
---|
727 | | - int ipv = qeth_get_ip_version(skb); |
---|
| 541 | + u16 txq = skb_get_queue_mapping(skb); |
---|
728 | 542 | struct qeth_qdio_out_q *queue; |
---|
729 | | - int tx_bytes = skb->len; |
---|
730 | 543 | int rc; |
---|
731 | 544 | |
---|
732 | | - if ((card->state != CARD_STATE_UP) || !card->lan_online) { |
---|
733 | | - card->stats.tx_carrier_errors++; |
---|
734 | | - goto tx_drop; |
---|
735 | | - } |
---|
736 | | - |
---|
737 | | - queue = qeth_get_tx_queue(card, skb, ipv, cast_type); |
---|
738 | | - |
---|
739 | | - if (card->options.performance_stats) { |
---|
740 | | - card->perf_stats.outbound_cnt++; |
---|
741 | | - card->perf_stats.outbound_start_time = qeth_get_micros(); |
---|
742 | | - } |
---|
743 | | - netif_stop_queue(dev); |
---|
| 545 | + if (!skb_is_gso(skb)) |
---|
| 546 | + qdisc_skb_cb(skb)->pkt_len = skb->len; |
---|
| 547 | + if (IS_IQD(card)) |
---|
| 548 | + txq = qeth_iqd_translate_txq(dev, txq); |
---|
| 549 | + queue = card->qdio.out_qs[txq]; |
---|
744 | 550 | |
---|
745 | 551 | if (IS_OSN(card)) |
---|
746 | 552 | rc = qeth_l2_xmit_osn(card, skb, queue); |
---|
747 | 553 | else |
---|
748 | | - rc = qeth_l2_xmit(card, skb, queue, cast_type, ipv); |
---|
| 554 | + rc = qeth_xmit(card, skb, queue, qeth_get_ip_version(skb), |
---|
| 555 | + qeth_l2_fill_header); |
---|
749 | 556 | |
---|
750 | | - if (!rc) { |
---|
751 | | - card->stats.tx_packets++; |
---|
752 | | - card->stats.tx_bytes += tx_bytes; |
---|
753 | | - if (card->options.performance_stats) |
---|
754 | | - card->perf_stats.outbound_time += qeth_get_micros() - |
---|
755 | | - card->perf_stats.outbound_start_time; |
---|
756 | | - netif_wake_queue(dev); |
---|
| 557 | + if (!rc) |
---|
757 | 558 | return NETDEV_TX_OK; |
---|
758 | | - } else if (rc == -EBUSY) { |
---|
759 | | - return NETDEV_TX_BUSY; |
---|
760 | | - } /* else fall through */ |
---|
761 | 559 | |
---|
762 | | -tx_drop: |
---|
763 | | - card->stats.tx_dropped++; |
---|
764 | | - card->stats.tx_errors++; |
---|
765 | | - dev_kfree_skb_any(skb); |
---|
766 | | - netif_wake_queue(dev); |
---|
| 560 | + QETH_TXQ_STAT_INC(queue, tx_dropped); |
---|
| 561 | + kfree_skb(skb); |
---|
767 | 562 | return NETDEV_TX_OK; |
---|
768 | 563 | } |
---|
769 | 564 | |
---|
770 | | -static int __qeth_l2_open(struct net_device *dev) |
---|
| 565 | +static u16 qeth_l2_select_queue(struct net_device *dev, struct sk_buff *skb, |
---|
| 566 | + struct net_device *sb_dev) |
---|
771 | 567 | { |
---|
772 | 568 | struct qeth_card *card = dev->ml_priv; |
---|
773 | | - int rc = 0; |
---|
774 | 569 | |
---|
775 | | - QETH_CARD_TEXT(card, 4, "qethopen"); |
---|
776 | | - if (card->state == CARD_STATE_UP) |
---|
777 | | - return rc; |
---|
778 | | - if (card->state != CARD_STATE_SOFTSETUP) |
---|
779 | | - return -ENODEV; |
---|
| 570 | + if (IS_IQD(card)) |
---|
| 571 | + return qeth_iqd_select_queue(dev, skb, |
---|
| 572 | + qeth_get_ether_cast_type(skb), |
---|
| 573 | + sb_dev); |
---|
| 574 | + if (qeth_uses_tx_prio_queueing(card)) |
---|
| 575 | + return qeth_get_priority_queue(card, skb); |
---|
780 | 576 | |
---|
781 | | - if ((card->info.type != QETH_CARD_TYPE_OSN) && |
---|
782 | | - (!(card->info.mac_bits & QETH_LAYER2_MAC_REGISTERED))) { |
---|
783 | | - QETH_CARD_TEXT(card, 4, "nomacadr"); |
---|
784 | | - return -EPERM; |
---|
785 | | - } |
---|
786 | | - card->data.state = CH_STATE_UP; |
---|
787 | | - card->state = CARD_STATE_UP; |
---|
788 | | - netif_start_queue(dev); |
---|
| 577 | + return netdev_pick_tx(dev, skb, sb_dev); |
---|
| 578 | +} |
---|
789 | 579 | |
---|
790 | | - if (qdio_stop_irq(card->data.ccwdev, 0) >= 0) { |
---|
791 | | - napi_enable(&card->napi); |
---|
792 | | - local_bh_disable(); |
---|
793 | | - napi_schedule(&card->napi); |
---|
794 | | - /* kick-start the NAPI softirq: */ |
---|
795 | | - local_bh_enable(); |
---|
796 | | - } else |
---|
797 | | - rc = -EIO; |
---|
| 580 | +static void qeth_l2_set_rx_mode(struct net_device *dev) |
---|
| 581 | +{ |
---|
| 582 | + struct qeth_card *card = dev->ml_priv; |
---|
| 583 | + |
---|
| 584 | + schedule_work(&card->rx_mode_work); |
---|
| 585 | +} |
---|
| 586 | + |
---|
| 587 | +/** |
---|
| 588 | + * qeth_l2_pnso() - perform network subchannel operation |
---|
| 589 | + * @card: qeth_card structure pointer |
---|
| 590 | + * @oc: Operation Code |
---|
| 591 | + * @cnc: Boolean Change-Notification Control |
---|
| 592 | + * @cb: Callback function will be executed for each element |
---|
| 593 | + * of the address list |
---|
| 594 | + * @priv: Pointer to pass to the callback function. |
---|
| 595 | + * |
---|
| 596 | + * Collects network information in a network address list and calls the |
---|
| 597 | + * callback function for every entry in the list. If "change-notification- |
---|
| 598 | + * control" is set, further changes in the address list will be reported |
---|
| 599 | + * via the IPA command. |
---|
| 600 | + */ |
---|
| 601 | +static int qeth_l2_pnso(struct qeth_card *card, u8 oc, int cnc, |
---|
| 602 | + void (*cb)(void *priv, struct chsc_pnso_naid_l2 *entry), |
---|
| 603 | + void *priv) |
---|
| 604 | +{ |
---|
| 605 | + struct ccw_device *ddev = CARD_DDEV(card); |
---|
| 606 | + struct chsc_pnso_area *rr; |
---|
| 607 | + u32 prev_instance = 0; |
---|
| 608 | + int isfirstblock = 1; |
---|
| 609 | + int i, size, elems; |
---|
| 610 | + int rc; |
---|
| 611 | + |
---|
| 612 | + rr = (struct chsc_pnso_area *)get_zeroed_page(GFP_KERNEL); |
---|
| 613 | + if (rr == NULL) |
---|
| 614 | + return -ENOMEM; |
---|
| 615 | + do { |
---|
| 616 | + QETH_CARD_TEXT(card, 2, "PNSO"); |
---|
| 617 | + /* on the first iteration, naihdr.resume_token will be zero */ |
---|
| 618 | + rc = ccw_device_pnso(ddev, rr, oc, rr->naihdr.resume_token, |
---|
| 619 | + cnc); |
---|
| 620 | + if (rc) |
---|
| 621 | + continue; |
---|
| 622 | + if (cb == NULL) |
---|
| 623 | + continue; |
---|
| 624 | + |
---|
| 625 | + size = rr->naihdr.naids; |
---|
| 626 | + if (size != sizeof(struct chsc_pnso_naid_l2)) { |
---|
| 627 | + WARN_ON_ONCE(1); |
---|
| 628 | + continue; |
---|
| 629 | + } |
---|
| 630 | + |
---|
| 631 | + elems = (rr->response.length - sizeof(struct chsc_header) - |
---|
| 632 | + sizeof(struct chsc_pnso_naihdr)) / size; |
---|
| 633 | + |
---|
| 634 | + if (!isfirstblock && (rr->naihdr.instance != prev_instance)) { |
---|
| 635 | + /* Inform the caller that they need to scrap */ |
---|
| 636 | + /* the data that was already reported via cb */ |
---|
| 637 | + rc = -EAGAIN; |
---|
| 638 | + break; |
---|
| 639 | + } |
---|
| 640 | + isfirstblock = 0; |
---|
| 641 | + prev_instance = rr->naihdr.instance; |
---|
| 642 | + for (i = 0; i < elems; i++) |
---|
| 643 | + (*cb)(priv, &rr->entries[i]); |
---|
| 644 | + } while ((rc == -EBUSY) || (!rc && /* list stored */ |
---|
| 645 | + /* resume token is non-zero => list incomplete */ |
---|
| 646 | + (rr->naihdr.resume_token.t1 || rr->naihdr.resume_token.t2))); |
---|
| 647 | + |
---|
| 648 | + if (rc) |
---|
| 649 | + QETH_CARD_TEXT_(card, 2, "PNrp%04x", rr->response.code); |
---|
| 650 | + |
---|
| 651 | + free_page((unsigned long)rr); |
---|
798 | 652 | return rc; |
---|
799 | 653 | } |
---|
800 | 654 | |
---|
801 | | -static int qeth_l2_open(struct net_device *dev) |
---|
| 655 | +static bool qeth_is_my_net_if_token(struct qeth_card *card, |
---|
| 656 | + struct net_if_token *token) |
---|
802 | 657 | { |
---|
803 | | - struct qeth_card *card = dev->ml_priv; |
---|
804 | | - |
---|
805 | | - QETH_CARD_TEXT(card, 5, "qethope_"); |
---|
806 | | - if (qeth_wait_for_threads(card, QETH_RECOVER_THREAD)) { |
---|
807 | | - QETH_CARD_TEXT(card, 3, "openREC"); |
---|
808 | | - return -ERESTARTSYS; |
---|
809 | | - } |
---|
810 | | - return __qeth_l2_open(dev); |
---|
| 658 | + return ((card->info.ddev_devno == token->devnum) && |
---|
| 659 | + (card->info.cssid == token->cssid) && |
---|
| 660 | + (card->info.iid == token->iid) && |
---|
| 661 | + (card->info.ssid == token->ssid) && |
---|
| 662 | + (card->info.chpid == token->chpid) && |
---|
| 663 | + (card->info.chid == token->chid)); |
---|
811 | 664 | } |
---|
812 | 665 | |
---|
813 | | -static int qeth_l2_stop(struct net_device *dev) |
---|
| 666 | +/** |
---|
| 667 | + * qeth_l2_dev2br_fdb_notify() - update fdb of master bridge |
---|
| 668 | + * @card: qeth_card structure pointer |
---|
| 669 | + * @code: event bitmask: high order bit 0x80 set to |
---|
| 670 | + * 1 - removal of an object |
---|
| 671 | + * 0 - addition of an object |
---|
| 672 | + * Object type(s): |
---|
| 673 | + * 0x01 - VLAN, 0x02 - MAC, 0x03 - VLAN and MAC |
---|
| 674 | + * @token: "network token" structure identifying 'physical' location |
---|
| 675 | + * of the target |
---|
| 676 | + * @addr_lnid: structure with MAC address and VLAN ID of the target |
---|
| 677 | + */ |
---|
| 678 | +static void qeth_l2_dev2br_fdb_notify(struct qeth_card *card, u8 code, |
---|
| 679 | + struct net_if_token *token, |
---|
| 680 | + struct mac_addr_lnid *addr_lnid) |
---|
814 | 681 | { |
---|
815 | | - struct qeth_card *card = dev->ml_priv; |
---|
| 682 | + struct switchdev_notifier_fdb_info info; |
---|
| 683 | + u8 ntfy_mac[ETH_ALEN]; |
---|
816 | 684 | |
---|
817 | | - QETH_CARD_TEXT(card, 4, "qethstop"); |
---|
818 | | - netif_tx_disable(dev); |
---|
819 | | - if (card->state == CARD_STATE_UP) { |
---|
820 | | - card->state = CARD_STATE_SOFTSETUP; |
---|
821 | | - napi_disable(&card->napi); |
---|
| 685 | + ether_addr_copy(ntfy_mac, addr_lnid->mac); |
---|
| 686 | + /* Ignore VLAN only changes */ |
---|
| 687 | + if (!(code & IPA_ADDR_CHANGE_CODE_MACADDR)) |
---|
| 688 | + return; |
---|
| 689 | + /* Ignore mcast entries */ |
---|
| 690 | + if (is_multicast_ether_addr(ntfy_mac)) |
---|
| 691 | + return; |
---|
| 692 | + /* Ignore my own addresses */ |
---|
| 693 | + if (qeth_is_my_net_if_token(card, token)) |
---|
| 694 | + return; |
---|
| 695 | + |
---|
| 696 | + info.addr = ntfy_mac; |
---|
| 697 | + /* don't report VLAN IDs */ |
---|
| 698 | + info.vid = 0; |
---|
| 699 | + info.added_by_user = false; |
---|
| 700 | + info.offloaded = true; |
---|
| 701 | + |
---|
| 702 | + if (code & IPA_ADDR_CHANGE_CODE_REMOVAL) { |
---|
| 703 | + call_switchdev_notifiers(SWITCHDEV_FDB_DEL_TO_BRIDGE, |
---|
| 704 | + card->dev, &info.info, NULL); |
---|
| 705 | + QETH_CARD_TEXT(card, 4, "andelmac"); |
---|
| 706 | + QETH_CARD_TEXT_(card, 4, |
---|
| 707 | + "mc%012lx", ether_addr_to_u64(ntfy_mac)); |
---|
| 708 | + } else { |
---|
| 709 | + call_switchdev_notifiers(SWITCHDEV_FDB_ADD_TO_BRIDGE, |
---|
| 710 | + card->dev, &info.info, NULL); |
---|
| 711 | + QETH_CARD_TEXT(card, 4, "anaddmac"); |
---|
| 712 | + QETH_CARD_TEXT_(card, 4, |
---|
| 713 | + "mc%012lx", ether_addr_to_u64(ntfy_mac)); |
---|
822 | 714 | } |
---|
823 | | - return 0; |
---|
824 | 715 | } |
---|
825 | 716 | |
---|
826 | | -static const struct device_type qeth_l2_devtype = { |
---|
827 | | - .name = "qeth_layer2", |
---|
828 | | - .groups = qeth_l2_attr_groups, |
---|
829 | | -}; |
---|
830 | | - |
---|
831 | | -static int qeth_l2_probe_device(struct ccwgroup_device *gdev) |
---|
| 717 | +static void qeth_l2_dev2br_an_set_cb(void *priv, |
---|
| 718 | + struct chsc_pnso_naid_l2 *entry) |
---|
832 | 719 | { |
---|
833 | | - struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
---|
| 720 | + u8 code = IPA_ADDR_CHANGE_CODE_MACADDR; |
---|
| 721 | + struct qeth_card *card = priv; |
---|
| 722 | + |
---|
| 723 | + if (entry->addr_lnid.lnid < VLAN_N_VID) |
---|
| 724 | + code |= IPA_ADDR_CHANGE_CODE_VLANID; |
---|
| 725 | + qeth_l2_dev2br_fdb_notify(card, code, |
---|
| 726 | + (struct net_if_token *)&entry->nit, |
---|
| 727 | + (struct mac_addr_lnid *)&entry->addr_lnid); |
---|
| 728 | +} |
---|
| 729 | + |
---|
| 730 | +/** |
---|
| 731 | + * qeth_l2_dev2br_an_set() - |
---|
| 732 | + * Enable or disable 'dev to bridge network address notification' |
---|
| 733 | + * @card: qeth_card structure pointer |
---|
| 734 | + * @enable: Enable or disable 'dev to bridge network address notification' |
---|
| 735 | + * |
---|
| 736 | + * Returns negative errno-compatible error indication or 0 on success. |
---|
| 737 | + * |
---|
| 738 | + * On enable, emits a series of address notifications for all |
---|
| 739 | + * currently registered hosts. |
---|
| 740 | + * |
---|
| 741 | + * Must be called under rtnl_lock |
---|
| 742 | + */ |
---|
| 743 | +static int qeth_l2_dev2br_an_set(struct qeth_card *card, bool enable) |
---|
| 744 | +{ |
---|
834 | 745 | int rc; |
---|
835 | 746 | |
---|
836 | | - if (gdev->dev.type == &qeth_generic_devtype) { |
---|
837 | | - rc = qeth_l2_create_device_attributes(&gdev->dev); |
---|
838 | | - if (rc) |
---|
839 | | - return rc; |
---|
| 747 | + if (enable) { |
---|
| 748 | + QETH_CARD_TEXT(card, 2, "anseton"); |
---|
| 749 | + rc = qeth_l2_pnso(card, PNSO_OC_NET_ADDR_INFO, 1, |
---|
| 750 | + qeth_l2_dev2br_an_set_cb, card); |
---|
| 751 | + if (rc == -EAGAIN) |
---|
| 752 | + /* address notification enabled, but inconsistent |
---|
| 753 | + * addresses reported -> disable address notification |
---|
| 754 | + */ |
---|
| 755 | + qeth_l2_pnso(card, PNSO_OC_NET_ADDR_INFO, 0, |
---|
| 756 | + NULL, NULL); |
---|
| 757 | + } else { |
---|
| 758 | + QETH_CARD_TEXT(card, 2, "ansetoff"); |
---|
| 759 | + rc = qeth_l2_pnso(card, PNSO_OC_NET_ADDR_INFO, 0, NULL, NULL); |
---|
840 | 760 | } |
---|
841 | | - INIT_LIST_HEAD(&card->vid_list); |
---|
842 | | - hash_init(card->mac_htable); |
---|
843 | | - card->options.layer2 = 1; |
---|
844 | | - card->info.hwtrap = 0; |
---|
845 | | - qeth_l2_vnicc_set_defaults(card); |
---|
846 | | - return 0; |
---|
| 761 | + |
---|
| 762 | + return rc; |
---|
847 | 763 | } |
---|
848 | 764 | |
---|
849 | | -static void qeth_l2_remove_device(struct ccwgroup_device *cgdev) |
---|
| 765 | +static int qeth_l2_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, |
---|
| 766 | + struct net_device *dev, u32 filter_mask, |
---|
| 767 | + int nlflags) |
---|
850 | 768 | { |
---|
851 | | - struct qeth_card *card = dev_get_drvdata(&cgdev->dev); |
---|
| 769 | + struct qeth_priv *priv = netdev_priv(dev); |
---|
| 770 | + struct qeth_card *card = dev->ml_priv; |
---|
| 771 | + u16 mode = BRIDGE_MODE_UNDEF; |
---|
852 | 772 | |
---|
853 | | - if (cgdev->dev.type == &qeth_generic_devtype) |
---|
854 | | - qeth_l2_remove_device_attributes(&cgdev->dev); |
---|
855 | | - qeth_set_allowed_threads(card, 0, 1); |
---|
856 | | - wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); |
---|
| 773 | + /* Do not even show qeth devs that cannot do bridge_setlink */ |
---|
| 774 | + if (!priv->brport_hw_features || !netif_device_present(dev) || |
---|
| 775 | + qeth_bridgeport_is_in_use(card)) |
---|
| 776 | + return -EOPNOTSUPP; |
---|
857 | 777 | |
---|
858 | | - if (cgdev->state == CCWGROUP_ONLINE) |
---|
859 | | - qeth_l2_set_offline(cgdev); |
---|
860 | | - |
---|
861 | | - cancel_work_sync(&card->close_dev_work); |
---|
862 | | - if (qeth_netdev_is_registered(card->dev)) |
---|
863 | | - unregister_netdev(card->dev); |
---|
| 778 | + return ndo_dflt_bridge_getlink(skb, pid, seq, dev, |
---|
| 779 | + mode, priv->brport_features, |
---|
| 780 | + priv->brport_hw_features, |
---|
| 781 | + nlflags, filter_mask, NULL); |
---|
864 | 782 | } |
---|
865 | 783 | |
---|
866 | | -static const struct ethtool_ops qeth_l2_ethtool_ops = { |
---|
867 | | - .get_link = ethtool_op_get_link, |
---|
868 | | - .get_strings = qeth_core_get_strings, |
---|
869 | | - .get_ethtool_stats = qeth_core_get_ethtool_stats, |
---|
870 | | - .get_sset_count = qeth_core_get_sset_count, |
---|
871 | | - .get_drvinfo = qeth_core_get_drvinfo, |
---|
872 | | - .get_link_ksettings = qeth_core_ethtool_get_link_ksettings, |
---|
| 784 | +static const struct nla_policy qeth_brport_policy[IFLA_BRPORT_MAX + 1] = { |
---|
| 785 | + [IFLA_BRPORT_LEARNING_SYNC] = { .type = NLA_U8 }, |
---|
873 | 786 | }; |
---|
874 | 787 | |
---|
875 | | -static const struct ethtool_ops qeth_l2_osn_ops = { |
---|
876 | | - .get_strings = qeth_core_get_strings, |
---|
877 | | - .get_ethtool_stats = qeth_core_get_ethtool_stats, |
---|
878 | | - .get_sset_count = qeth_core_get_sset_count, |
---|
879 | | - .get_drvinfo = qeth_core_get_drvinfo, |
---|
880 | | -}; |
---|
| 788 | +/** |
---|
| 789 | + * qeth_l2_bridge_setlink() - set bridgeport attributes |
---|
| 790 | + * @dev: netdevice |
---|
| 791 | + * @nlh: netlink message header |
---|
| 792 | + * @flags: bridge flags (here: BRIDGE_FLAGS_SELF) |
---|
| 793 | + * @extack: extended ACK report struct |
---|
| 794 | + * |
---|
| 795 | + * Called under rtnl_lock |
---|
| 796 | + */ |
---|
| 797 | +static int qeth_l2_bridge_setlink(struct net_device *dev, struct nlmsghdr *nlh, |
---|
| 798 | + u16 flags, struct netlink_ext_ack *extack) |
---|
| 799 | +{ |
---|
| 800 | + struct qeth_priv *priv = netdev_priv(dev); |
---|
| 801 | + struct nlattr *bp_tb[IFLA_BRPORT_MAX + 1]; |
---|
| 802 | + struct qeth_card *card = dev->ml_priv; |
---|
| 803 | + struct nlattr *attr, *nested_attr; |
---|
| 804 | + bool enable, has_protinfo = false; |
---|
| 805 | + int rem1, rem2; |
---|
| 806 | + int rc; |
---|
| 807 | + |
---|
| 808 | + if (!netif_device_present(dev)) |
---|
| 809 | + return -ENODEV; |
---|
| 810 | + if (!(priv->brport_hw_features)) |
---|
| 811 | + return -EOPNOTSUPP; |
---|
| 812 | + |
---|
| 813 | + nlmsg_for_each_attr(attr, nlh, sizeof(struct ifinfomsg), rem1) { |
---|
| 814 | + if (nla_type(attr) == IFLA_PROTINFO) { |
---|
| 815 | + rc = nla_parse_nested(bp_tb, IFLA_BRPORT_MAX, attr, |
---|
| 816 | + qeth_brport_policy, extack); |
---|
| 817 | + if (rc) |
---|
| 818 | + return rc; |
---|
| 819 | + has_protinfo = true; |
---|
| 820 | + } else if (nla_type(attr) == IFLA_AF_SPEC) { |
---|
| 821 | + nla_for_each_nested(nested_attr, attr, rem2) { |
---|
| 822 | + if (nla_type(nested_attr) == IFLA_BRIDGE_FLAGS) |
---|
| 823 | + continue; |
---|
| 824 | + NL_SET_ERR_MSG_ATTR(extack, nested_attr, |
---|
| 825 | + "Unsupported attribute"); |
---|
| 826 | + return -EINVAL; |
---|
| 827 | + } |
---|
| 828 | + } else { |
---|
| 829 | + NL_SET_ERR_MSG_ATTR(extack, attr, "Unsupported attribute"); |
---|
| 830 | + return -EINVAL; |
---|
| 831 | + } |
---|
| 832 | + } |
---|
| 833 | + if (!has_protinfo) |
---|
| 834 | + return 0; |
---|
| 835 | + if (!bp_tb[IFLA_BRPORT_LEARNING_SYNC]) |
---|
| 836 | + return -EINVAL; |
---|
| 837 | + enable = !!nla_get_u8(bp_tb[IFLA_BRPORT_LEARNING_SYNC]); |
---|
| 838 | + |
---|
| 839 | + if (enable == !!(priv->brport_features & BR_LEARNING_SYNC)) |
---|
| 840 | + return 0; |
---|
| 841 | + |
---|
| 842 | + mutex_lock(&card->sbp_lock); |
---|
| 843 | + /* do not change anything if BridgePort is enabled */ |
---|
| 844 | + if (qeth_bridgeport_is_in_use(card)) { |
---|
| 845 | + NL_SET_ERR_MSG(extack, "n/a (BridgePort)"); |
---|
| 846 | + rc = -EBUSY; |
---|
| 847 | + } else if (enable) { |
---|
| 848 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_ADDR_INFO); |
---|
| 849 | + rc = qeth_l2_dev2br_an_set(card, true); |
---|
| 850 | + if (rc) |
---|
| 851 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_NONE); |
---|
| 852 | + else |
---|
| 853 | + priv->brport_features |= BR_LEARNING_SYNC; |
---|
| 854 | + } else { |
---|
| 855 | + rc = qeth_l2_dev2br_an_set(card, false); |
---|
| 856 | + if (!rc) { |
---|
| 857 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_NONE); |
---|
| 858 | + priv->brport_features ^= BR_LEARNING_SYNC; |
---|
| 859 | + qeth_l2_dev2br_fdb_flush(card); |
---|
| 860 | + } |
---|
| 861 | + } |
---|
| 862 | + mutex_unlock(&card->sbp_lock); |
---|
| 863 | + |
---|
| 864 | + return rc; |
---|
| 865 | +} |
---|
881 | 866 | |
---|
882 | 867 | static const struct net_device_ops qeth_l2_netdev_ops = { |
---|
883 | | - .ndo_open = qeth_l2_open, |
---|
884 | | - .ndo_stop = qeth_l2_stop, |
---|
885 | | - .ndo_get_stats = qeth_get_stats, |
---|
| 868 | + .ndo_open = qeth_open, |
---|
| 869 | + .ndo_stop = qeth_stop, |
---|
| 870 | + .ndo_get_stats64 = qeth_get_stats64, |
---|
886 | 871 | .ndo_start_xmit = qeth_l2_hard_start_xmit, |
---|
887 | 872 | .ndo_features_check = qeth_features_check, |
---|
888 | | - .ndo_validate_addr = eth_validate_addr, |
---|
| 873 | + .ndo_select_queue = qeth_l2_select_queue, |
---|
| 874 | + .ndo_validate_addr = qeth_l2_validate_addr, |
---|
889 | 875 | .ndo_set_rx_mode = qeth_l2_set_rx_mode, |
---|
890 | 876 | .ndo_do_ioctl = qeth_do_ioctl, |
---|
891 | 877 | .ndo_set_mac_address = qeth_l2_set_mac_address, |
---|
892 | 878 | .ndo_vlan_rx_add_vid = qeth_l2_vlan_rx_add_vid, |
---|
893 | 879 | .ndo_vlan_rx_kill_vid = qeth_l2_vlan_rx_kill_vid, |
---|
894 | | - .ndo_tx_timeout = qeth_tx_timeout, |
---|
| 880 | + .ndo_tx_timeout = qeth_tx_timeout, |
---|
895 | 881 | .ndo_fix_features = qeth_fix_features, |
---|
896 | | - .ndo_set_features = qeth_set_features |
---|
| 882 | + .ndo_set_features = qeth_set_features, |
---|
| 883 | + .ndo_bridge_getlink = qeth_l2_bridge_getlink, |
---|
| 884 | + .ndo_bridge_setlink = qeth_l2_bridge_setlink, |
---|
| 885 | +}; |
---|
| 886 | + |
---|
| 887 | +static const struct net_device_ops qeth_osn_netdev_ops = { |
---|
| 888 | + .ndo_open = qeth_open, |
---|
| 889 | + .ndo_stop = qeth_stop, |
---|
| 890 | + .ndo_get_stats64 = qeth_get_stats64, |
---|
| 891 | + .ndo_start_xmit = qeth_l2_hard_start_xmit, |
---|
| 892 | + .ndo_validate_addr = eth_validate_addr, |
---|
| 893 | + .ndo_tx_timeout = qeth_tx_timeout, |
---|
897 | 894 | }; |
---|
898 | 895 | |
---|
899 | 896 | static int qeth_l2_setup_netdev(struct qeth_card *card) |
---|
900 | 897 | { |
---|
901 | | - int rc; |
---|
902 | | - |
---|
903 | | - if (qeth_netdev_is_registered(card->dev)) |
---|
904 | | - return 0; |
---|
905 | | - |
---|
906 | | - card->dev->priv_flags |= IFF_UNICAST_FLT; |
---|
907 | | - card->dev->netdev_ops = &qeth_l2_netdev_ops; |
---|
908 | | - if (card->info.type == QETH_CARD_TYPE_OSN) { |
---|
909 | | - card->dev->ethtool_ops = &qeth_l2_osn_ops; |
---|
| 898 | + if (IS_OSN(card)) { |
---|
| 899 | + card->dev->netdev_ops = &qeth_osn_netdev_ops; |
---|
910 | 900 | card->dev->flags |= IFF_NOARP; |
---|
911 | | - } else { |
---|
912 | | - card->dev->ethtool_ops = &qeth_l2_ethtool_ops; |
---|
913 | | - card->dev->needed_headroom = sizeof(struct qeth_hdr); |
---|
| 901 | + goto add_napi; |
---|
914 | 902 | } |
---|
915 | 903 | |
---|
916 | | - if (card->info.type == QETH_CARD_TYPE_OSM) |
---|
917 | | - card->dev->features |= NETIF_F_VLAN_CHALLENGED; |
---|
918 | | - else |
---|
919 | | - card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; |
---|
| 904 | + card->dev->needed_headroom = sizeof(struct qeth_hdr); |
---|
| 905 | + card->dev->netdev_ops = &qeth_l2_netdev_ops; |
---|
| 906 | + card->dev->priv_flags |= IFF_UNICAST_FLT; |
---|
920 | 907 | |
---|
921 | | - if (card->info.type == QETH_CARD_TYPE_OSD && !card->info.guestlan) { |
---|
| 908 | + if (IS_OSM(card)) { |
---|
| 909 | + card->dev->features |= NETIF_F_VLAN_CHALLENGED; |
---|
| 910 | + } else { |
---|
| 911 | + if (!IS_VM_NIC(card)) |
---|
| 912 | + card->dev->hw_features |= NETIF_F_HW_VLAN_CTAG_FILTER; |
---|
| 913 | + card->dev->features |= NETIF_F_HW_VLAN_CTAG_FILTER; |
---|
| 914 | + } |
---|
| 915 | + |
---|
| 916 | + if (IS_OSD(card) && !IS_VM_NIC(card)) { |
---|
922 | 917 | card->dev->features |= NETIF_F_SG; |
---|
923 | 918 | /* OSA 3S and earlier has no RX/TX support */ |
---|
924 | 919 | if (qeth_is_supported(card, IPA_OUTBOUND_CHECKSUM)) { |
---|
.. | .. |
---|
935 | 930 | card->dev->hw_features |= NETIF_F_RXCSUM; |
---|
936 | 931 | card->dev->vlan_features |= NETIF_F_RXCSUM; |
---|
937 | 932 | } |
---|
| 933 | + if (qeth_is_supported(card, IPA_OUTBOUND_TSO)) { |
---|
| 934 | + card->dev->hw_features |= NETIF_F_TSO; |
---|
| 935 | + card->dev->vlan_features |= NETIF_F_TSO; |
---|
| 936 | + } |
---|
| 937 | + if (qeth_is_supported6(card, IPA_OUTBOUND_TSO)) { |
---|
| 938 | + card->dev->hw_features |= NETIF_F_TSO6; |
---|
| 939 | + card->dev->vlan_features |= NETIF_F_TSO6; |
---|
| 940 | + } |
---|
938 | 941 | |
---|
939 | | - qeth_l2_request_initial_mac(card); |
---|
| 942 | + if (card->dev->hw_features & (NETIF_F_TSO | NETIF_F_TSO6)) { |
---|
| 943 | + card->dev->needed_headroom = sizeof(struct qeth_hdr_tso); |
---|
| 944 | + netif_keep_dst(card->dev); |
---|
| 945 | + netif_set_gso_max_size(card->dev, |
---|
| 946 | + PAGE_SIZE * (QDIO_MAX_ELEMENTS_PER_BUFFER - 1)); |
---|
| 947 | + } |
---|
| 948 | + |
---|
| 949 | +add_napi: |
---|
940 | 950 | netif_napi_add(card->dev, &card->napi, qeth_poll, QETH_NAPI_WEIGHT); |
---|
941 | | - rc = register_netdev(card->dev); |
---|
942 | | - if (rc) |
---|
943 | | - card->dev->netdev_ops = NULL; |
---|
944 | | - return rc; |
---|
945 | | -} |
---|
946 | | - |
---|
947 | | -static int qeth_l2_start_ipassists(struct qeth_card *card) |
---|
948 | | -{ |
---|
949 | | - /* configure isolation level */ |
---|
950 | | - if (qeth_set_access_ctrl_online(card, 0)) |
---|
951 | | - return -ENODEV; |
---|
952 | | - return 0; |
---|
| 951 | + return register_netdev(card->dev); |
---|
953 | 952 | } |
---|
954 | 953 | |
---|
955 | 954 | static void qeth_l2_trace_features(struct qeth_card *card) |
---|
.. | .. |
---|
964 | 963 | sizeof(card->options.vnicc.sup_chars)); |
---|
965 | 964 | } |
---|
966 | 965 | |
---|
967 | | -static int __qeth_l2_set_online(struct ccwgroup_device *gdev, int recovery_mode) |
---|
| 966 | +static void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card) |
---|
968 | 967 | { |
---|
969 | | - struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
---|
970 | | - int rc = 0; |
---|
971 | | - enum qeth_card_states recover_flag; |
---|
972 | | - |
---|
973 | | - mutex_lock(&card->discipline_mutex); |
---|
974 | | - mutex_lock(&card->conf_mutex); |
---|
975 | | - QETH_DBF_TEXT(SETUP, 2, "setonlin"); |
---|
976 | | - QETH_DBF_HEX(SETUP, 2, &card, sizeof(void *)); |
---|
977 | | - |
---|
978 | | - recover_flag = card->state; |
---|
979 | | - rc = qeth_core_hardsetup_card(card); |
---|
980 | | - if (rc) { |
---|
981 | | - QETH_DBF_TEXT_(SETUP, 2, "2err%04x", rc); |
---|
982 | | - rc = -ENODEV; |
---|
983 | | - goto out_remove; |
---|
| 968 | + if (!card->options.sbp.reflect_promisc && |
---|
| 969 | + card->options.sbp.role != QETH_SBP_ROLE_NONE) { |
---|
| 970 | + /* Conditional to avoid spurious error messages */ |
---|
| 971 | + qeth_bridgeport_setrole(card, card->options.sbp.role); |
---|
| 972 | + /* Let the callback function refresh the stored role value. */ |
---|
| 973 | + qeth_bridgeport_query_ports(card, &card->options.sbp.role, |
---|
| 974 | + NULL); |
---|
984 | 975 | } |
---|
985 | | - qeth_bridgeport_query_support(card); |
---|
986 | | - if (card->options.sbp.supported_funcs) |
---|
987 | | - dev_info(&card->gdev->dev, |
---|
988 | | - "The device represents a Bridge Capable Port\n"); |
---|
989 | | - |
---|
990 | | - rc = qeth_l2_setup_netdev(card); |
---|
991 | | - if (rc) |
---|
992 | | - goto out_remove; |
---|
993 | | - |
---|
994 | | - if (card->info.type != QETH_CARD_TYPE_OSN && |
---|
995 | | - !qeth_l2_send_setmac(card, card->dev->dev_addr)) |
---|
996 | | - card->info.mac_bits |= QETH_LAYER2_MAC_REGISTERED; |
---|
997 | | - |
---|
998 | | - if (qeth_is_diagass_supported(card, QETH_DIAGS_CMD_TRAP)) { |
---|
999 | | - if (card->info.hwtrap && |
---|
1000 | | - qeth_hw_trap(card, QETH_DIAGS_TRAP_ARM)) |
---|
1001 | | - card->info.hwtrap = 0; |
---|
1002 | | - } else |
---|
1003 | | - card->info.hwtrap = 0; |
---|
1004 | | - |
---|
1005 | | - /* for the rx_bcast characteristic, init VNICC after setmac */ |
---|
1006 | | - qeth_l2_vnicc_init(card); |
---|
1007 | | - |
---|
1008 | | - qeth_trace_features(card); |
---|
1009 | | - qeth_l2_trace_features(card); |
---|
1010 | | - |
---|
1011 | | - qeth_l2_setup_bridgeport_attrs(card); |
---|
1012 | | - |
---|
1013 | | - card->state = CARD_STATE_HARDSETUP; |
---|
1014 | | - qeth_print_status_message(card); |
---|
1015 | | - |
---|
1016 | | - /* softsetup */ |
---|
1017 | | - QETH_DBF_TEXT(SETUP, 2, "softsetp"); |
---|
1018 | | - |
---|
1019 | | - if ((card->info.type == QETH_CARD_TYPE_OSD) || |
---|
1020 | | - (card->info.type == QETH_CARD_TYPE_OSX)) { |
---|
1021 | | - rc = qeth_l2_start_ipassists(card); |
---|
1022 | | - if (rc) |
---|
1023 | | - goto out_remove; |
---|
| 976 | + if (card->options.sbp.hostnotification) { |
---|
| 977 | + if (qeth_bridgeport_an_set(card, 1)) |
---|
| 978 | + card->options.sbp.hostnotification = 0; |
---|
1024 | 979 | } |
---|
| 980 | +} |
---|
1025 | 981 | |
---|
1026 | | - if (card->info.type != QETH_CARD_TYPE_OSN) |
---|
1027 | | - qeth_l2_process_vlans(card); |
---|
| 982 | +/** |
---|
| 983 | + * qeth_l2_detect_dev2br_support() - |
---|
| 984 | + * Detect whether this card supports 'dev to bridge fdb network address |
---|
| 985 | + * change notification' and thus can support the learning_sync bridgeport |
---|
| 986 | + * attribute |
---|
| 987 | + * @card: qeth_card structure pointer |
---|
| 988 | + */ |
---|
| 989 | +static void qeth_l2_detect_dev2br_support(struct qeth_card *card) |
---|
| 990 | +{ |
---|
| 991 | + struct qeth_priv *priv = netdev_priv(card->dev); |
---|
| 992 | + bool dev2br_supported; |
---|
1028 | 993 | |
---|
1029 | | - netif_tx_disable(card->dev); |
---|
| 994 | + QETH_CARD_TEXT(card, 2, "d2brsup"); |
---|
| 995 | + if (!IS_IQD(card)) |
---|
| 996 | + return; |
---|
1030 | 997 | |
---|
1031 | | - rc = qeth_init_qdio_queues(card); |
---|
1032 | | - if (rc) { |
---|
1033 | | - QETH_DBF_TEXT_(SETUP, 2, "6err%d", rc); |
---|
1034 | | - rc = -ENODEV; |
---|
1035 | | - goto out_remove; |
---|
1036 | | - } |
---|
1037 | | - card->state = CARD_STATE_SOFTSETUP; |
---|
1038 | | - if (card->lan_online) |
---|
1039 | | - netif_carrier_on(card->dev); |
---|
| 998 | + /* dev2br requires valid cssid,iid,chid */ |
---|
| 999 | + dev2br_supported = card->info.ids_valid && |
---|
| 1000 | + css_general_characteristics.enarf; |
---|
| 1001 | + QETH_CARD_TEXT_(card, 2, "D2Bsup%02x", dev2br_supported); |
---|
| 1002 | + |
---|
| 1003 | + if (dev2br_supported) |
---|
| 1004 | + priv->brport_hw_features |= BR_LEARNING_SYNC; |
---|
1040 | 1005 | else |
---|
1041 | | - netif_carrier_off(card->dev); |
---|
| 1006 | + priv->brport_hw_features &= ~BR_LEARNING_SYNC; |
---|
| 1007 | +} |
---|
1042 | 1008 | |
---|
1043 | | - qeth_set_allowed_threads(card, 0xffffffff, 0); |
---|
| 1009 | +static void qeth_l2_enable_brport_features(struct qeth_card *card) |
---|
| 1010 | +{ |
---|
| 1011 | + struct qeth_priv *priv = netdev_priv(card->dev); |
---|
| 1012 | + int rc; |
---|
1044 | 1013 | |
---|
1045 | | - qeth_enable_hw_features(card->dev); |
---|
1046 | | - if (recover_flag == CARD_STATE_RECOVER) { |
---|
1047 | | - if (recovery_mode && |
---|
1048 | | - card->info.type != QETH_CARD_TYPE_OSN) { |
---|
1049 | | - __qeth_l2_open(card->dev); |
---|
1050 | | - qeth_l2_set_rx_mode(card->dev); |
---|
| 1014 | + if (priv->brport_features & BR_LEARNING_SYNC) { |
---|
| 1015 | + if (priv->brport_hw_features & BR_LEARNING_SYNC) { |
---|
| 1016 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_ADDR_INFO); |
---|
| 1017 | + rc = qeth_l2_dev2br_an_set(card, true); |
---|
| 1018 | + if (rc == -EAGAIN) { |
---|
| 1019 | + /* Recoverable error, retry once */ |
---|
| 1020 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_NONE); |
---|
| 1021 | + qeth_l2_dev2br_fdb_flush(card); |
---|
| 1022 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_ADDR_INFO); |
---|
| 1023 | + rc = qeth_l2_dev2br_an_set(card, true); |
---|
| 1024 | + } |
---|
| 1025 | + if (rc) { |
---|
| 1026 | + netdev_err(card->dev, |
---|
| 1027 | + "failed to enable bridge learning_sync: %d\n", |
---|
| 1028 | + rc); |
---|
| 1029 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_NONE); |
---|
| 1030 | + qeth_l2_dev2br_fdb_flush(card); |
---|
| 1031 | + priv->brport_features ^= BR_LEARNING_SYNC; |
---|
| 1032 | + } |
---|
1051 | 1033 | } else { |
---|
1052 | | - rtnl_lock(); |
---|
1053 | | - dev_open(card->dev); |
---|
1054 | | - rtnl_unlock(); |
---|
| 1034 | + dev_warn(&card->gdev->dev, |
---|
| 1035 | + "bridge learning_sync not supported\n"); |
---|
| 1036 | + priv->brport_features ^= BR_LEARNING_SYNC; |
---|
1055 | 1037 | } |
---|
1056 | 1038 | } |
---|
1057 | | - /* let user_space know that device is online */ |
---|
1058 | | - kobject_uevent(&gdev->dev.kobj, KOBJ_CHANGE); |
---|
1059 | | - mutex_unlock(&card->conf_mutex); |
---|
1060 | | - mutex_unlock(&card->discipline_mutex); |
---|
1061 | | - return 0; |
---|
1062 | | - |
---|
1063 | | -out_remove: |
---|
1064 | | - qeth_l2_stop_card(card, 0); |
---|
1065 | | - ccw_device_set_offline(CARD_DDEV(card)); |
---|
1066 | | - ccw_device_set_offline(CARD_WDEV(card)); |
---|
1067 | | - ccw_device_set_offline(CARD_RDEV(card)); |
---|
1068 | | - qdio_free(CARD_DDEV(card)); |
---|
1069 | | - if (recover_flag == CARD_STATE_RECOVER) |
---|
1070 | | - card->state = CARD_STATE_RECOVER; |
---|
1071 | | - else |
---|
1072 | | - card->state = CARD_STATE_DOWN; |
---|
1073 | | - mutex_unlock(&card->conf_mutex); |
---|
1074 | | - mutex_unlock(&card->discipline_mutex); |
---|
1075 | | - return rc; |
---|
1076 | 1039 | } |
---|
1077 | 1040 | |
---|
1078 | | -static int qeth_l2_set_online(struct ccwgroup_device *gdev) |
---|
| 1041 | +#ifdef CONFIG_QETH_OSN |
---|
| 1042 | +static void qeth_osn_assist_cb(struct qeth_card *card, |
---|
| 1043 | + struct qeth_cmd_buffer *iob, |
---|
| 1044 | + unsigned int data_length) |
---|
1079 | 1045 | { |
---|
1080 | | - return __qeth_l2_set_online(gdev, 0); |
---|
1081 | | -} |
---|
1082 | | - |
---|
1083 | | -static int __qeth_l2_set_offline(struct ccwgroup_device *cgdev, |
---|
1084 | | - int recovery_mode) |
---|
1085 | | -{ |
---|
1086 | | - struct qeth_card *card = dev_get_drvdata(&cgdev->dev); |
---|
1087 | | - int rc = 0, rc2 = 0, rc3 = 0; |
---|
1088 | | - enum qeth_card_states recover_flag; |
---|
1089 | | - |
---|
1090 | | - mutex_lock(&card->discipline_mutex); |
---|
1091 | | - mutex_lock(&card->conf_mutex); |
---|
1092 | | - QETH_DBF_TEXT(SETUP, 3, "setoffl"); |
---|
1093 | | - QETH_DBF_HEX(SETUP, 3, &card, sizeof(void *)); |
---|
1094 | | - |
---|
1095 | | - netif_carrier_off(card->dev); |
---|
1096 | | - recover_flag = card->state; |
---|
1097 | | - if ((!recovery_mode && card->info.hwtrap) || card->info.hwtrap == 2) { |
---|
1098 | | - qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); |
---|
1099 | | - card->info.hwtrap = 1; |
---|
1100 | | - } |
---|
1101 | | - qeth_l2_stop_card(card, recovery_mode); |
---|
1102 | | - rc = ccw_device_set_offline(CARD_DDEV(card)); |
---|
1103 | | - rc2 = ccw_device_set_offline(CARD_WDEV(card)); |
---|
1104 | | - rc3 = ccw_device_set_offline(CARD_RDEV(card)); |
---|
1105 | | - if (!rc) |
---|
1106 | | - rc = (rc2) ? rc2 : rc3; |
---|
1107 | | - if (rc) |
---|
1108 | | - QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); |
---|
1109 | | - qdio_free(CARD_DDEV(card)); |
---|
1110 | | - if (recover_flag == CARD_STATE_UP) |
---|
1111 | | - card->state = CARD_STATE_RECOVER; |
---|
1112 | | - /* let user_space know that device is offline */ |
---|
1113 | | - kobject_uevent(&cgdev->dev.kobj, KOBJ_CHANGE); |
---|
1114 | | - mutex_unlock(&card->conf_mutex); |
---|
1115 | | - mutex_unlock(&card->discipline_mutex); |
---|
1116 | | - return 0; |
---|
1117 | | -} |
---|
1118 | | - |
---|
1119 | | -static int qeth_l2_set_offline(struct ccwgroup_device *cgdev) |
---|
1120 | | -{ |
---|
1121 | | - return __qeth_l2_set_offline(cgdev, 0); |
---|
1122 | | -} |
---|
1123 | | - |
---|
1124 | | -static int qeth_l2_recover(void *ptr) |
---|
1125 | | -{ |
---|
1126 | | - struct qeth_card *card; |
---|
1127 | | - int rc = 0; |
---|
1128 | | - |
---|
1129 | | - card = (struct qeth_card *) ptr; |
---|
1130 | | - QETH_CARD_TEXT(card, 2, "recover1"); |
---|
1131 | | - if (!qeth_do_run_thread(card, QETH_RECOVER_THREAD)) |
---|
1132 | | - return 0; |
---|
1133 | | - QETH_CARD_TEXT(card, 2, "recover2"); |
---|
1134 | | - dev_warn(&card->gdev->dev, |
---|
1135 | | - "A recovery process has been started for the device\n"); |
---|
1136 | | - qeth_set_recovery_task(card); |
---|
1137 | | - __qeth_l2_set_offline(card->gdev, 1); |
---|
1138 | | - rc = __qeth_l2_set_online(card->gdev, 1); |
---|
1139 | | - if (!rc) |
---|
1140 | | - dev_info(&card->gdev->dev, |
---|
1141 | | - "Device successfully recovered!\n"); |
---|
1142 | | - else { |
---|
1143 | | - qeth_close_dev(card); |
---|
1144 | | - dev_warn(&card->gdev->dev, "The qeth device driver " |
---|
1145 | | - "failed to recover an error on the device\n"); |
---|
1146 | | - } |
---|
1147 | | - qeth_clear_recovery_task(card); |
---|
1148 | | - qeth_clear_thread_start_bit(card, QETH_RECOVER_THREAD); |
---|
1149 | | - qeth_clear_thread_running_bit(card, QETH_RECOVER_THREAD); |
---|
1150 | | - return 0; |
---|
1151 | | -} |
---|
1152 | | - |
---|
1153 | | -static int __init qeth_l2_init(void) |
---|
1154 | | -{ |
---|
1155 | | - pr_info("register layer 2 discipline\n"); |
---|
1156 | | - return 0; |
---|
1157 | | -} |
---|
1158 | | - |
---|
1159 | | -static void __exit qeth_l2_exit(void) |
---|
1160 | | -{ |
---|
1161 | | - pr_info("unregister layer 2 discipline\n"); |
---|
1162 | | -} |
---|
1163 | | - |
---|
1164 | | -static int qeth_l2_pm_suspend(struct ccwgroup_device *gdev) |
---|
1165 | | -{ |
---|
1166 | | - struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
---|
1167 | | - |
---|
1168 | | - netif_device_detach(card->dev); |
---|
1169 | | - qeth_set_allowed_threads(card, 0, 1); |
---|
1170 | | - wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); |
---|
1171 | | - if (gdev->state == CCWGROUP_OFFLINE) |
---|
1172 | | - return 0; |
---|
1173 | | - if (card->state == CARD_STATE_UP) { |
---|
1174 | | - if (card->info.hwtrap) |
---|
1175 | | - qeth_hw_trap(card, QETH_DIAGS_TRAP_DISARM); |
---|
1176 | | - __qeth_l2_set_offline(card->gdev, 1); |
---|
1177 | | - } else |
---|
1178 | | - __qeth_l2_set_offline(card->gdev, 0); |
---|
1179 | | - return 0; |
---|
1180 | | -} |
---|
1181 | | - |
---|
1182 | | -static int qeth_l2_pm_resume(struct ccwgroup_device *gdev) |
---|
1183 | | -{ |
---|
1184 | | - struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
---|
1185 | | - int rc = 0; |
---|
1186 | | - |
---|
1187 | | - if (gdev->state == CCWGROUP_OFFLINE) |
---|
1188 | | - goto out; |
---|
1189 | | - |
---|
1190 | | - if (card->state == CARD_STATE_RECOVER) { |
---|
1191 | | - rc = __qeth_l2_set_online(card->gdev, 1); |
---|
1192 | | - if (rc) { |
---|
1193 | | - rtnl_lock(); |
---|
1194 | | - dev_close(card->dev); |
---|
1195 | | - rtnl_unlock(); |
---|
1196 | | - } |
---|
1197 | | - } else |
---|
1198 | | - rc = __qeth_l2_set_online(card->gdev, 0); |
---|
1199 | | -out: |
---|
1200 | | - qeth_set_allowed_threads(card, 0xffffffff, 0); |
---|
1201 | | - netif_device_attach(card->dev); |
---|
1202 | | - if (rc) |
---|
1203 | | - dev_warn(&card->gdev->dev, "The qeth device driver " |
---|
1204 | | - "failed to recover an error on the device\n"); |
---|
1205 | | - return rc; |
---|
1206 | | -} |
---|
1207 | | - |
---|
1208 | | -/* Returns zero if the command is successfully "consumed" */ |
---|
1209 | | -static int qeth_l2_control_event(struct qeth_card *card, |
---|
1210 | | - struct qeth_ipa_cmd *cmd) |
---|
1211 | | -{ |
---|
1212 | | - switch (cmd->hdr.command) { |
---|
1213 | | - case IPA_CMD_SETBRIDGEPORT_OSA: |
---|
1214 | | - case IPA_CMD_SETBRIDGEPORT_IQD: |
---|
1215 | | - if (cmd->data.sbp.hdr.command_code == |
---|
1216 | | - IPA_SBP_BRIDGE_PORT_STATE_CHANGE) { |
---|
1217 | | - qeth_bridge_state_change(card, cmd); |
---|
1218 | | - return 0; |
---|
1219 | | - } else |
---|
1220 | | - return 1; |
---|
1221 | | - case IPA_CMD_ADDRESS_CHANGE_NOTIF: |
---|
1222 | | - qeth_bridge_host_event(card, cmd); |
---|
1223 | | - return 0; |
---|
1224 | | - default: |
---|
1225 | | - return 1; |
---|
1226 | | - } |
---|
1227 | | -} |
---|
1228 | | - |
---|
1229 | | -struct qeth_discipline qeth_l2_discipline = { |
---|
1230 | | - .devtype = &qeth_l2_devtype, |
---|
1231 | | - .process_rx_buffer = qeth_l2_process_inbound_buffer, |
---|
1232 | | - .recover = qeth_l2_recover, |
---|
1233 | | - .setup = qeth_l2_probe_device, |
---|
1234 | | - .remove = qeth_l2_remove_device, |
---|
1235 | | - .set_online = qeth_l2_set_online, |
---|
1236 | | - .set_offline = qeth_l2_set_offline, |
---|
1237 | | - .freeze = qeth_l2_pm_suspend, |
---|
1238 | | - .thaw = qeth_l2_pm_resume, |
---|
1239 | | - .restore = qeth_l2_pm_resume, |
---|
1240 | | - .do_ioctl = NULL, |
---|
1241 | | - .control_event_handler = qeth_l2_control_event, |
---|
1242 | | -}; |
---|
1243 | | -EXPORT_SYMBOL_GPL(qeth_l2_discipline); |
---|
1244 | | - |
---|
1245 | | -static int qeth_osn_send_control_data(struct qeth_card *card, int len, |
---|
1246 | | - struct qeth_cmd_buffer *iob) |
---|
1247 | | -{ |
---|
1248 | | - struct qeth_channel *channel = iob->channel; |
---|
1249 | | - unsigned long flags; |
---|
1250 | | - int rc = 0; |
---|
1251 | | - |
---|
1252 | | - QETH_CARD_TEXT(card, 5, "osndctrd"); |
---|
1253 | | - |
---|
1254 | | - wait_event(card->wait_q, |
---|
1255 | | - atomic_cmpxchg(&channel->irq_pending, 0, 1) == 0); |
---|
1256 | | - qeth_prepare_control_data(card, len, iob); |
---|
1257 | | - QETH_CARD_TEXT(card, 6, "osnoirqp"); |
---|
1258 | | - spin_lock_irqsave(get_ccwdev_lock(channel->ccwdev), flags); |
---|
1259 | | - rc = ccw_device_start_timeout(channel->ccwdev, channel->ccw, |
---|
1260 | | - (addr_t) iob, 0, 0, QETH_IPA_TIMEOUT); |
---|
1261 | | - spin_unlock_irqrestore(get_ccwdev_lock(channel->ccwdev), flags); |
---|
1262 | | - if (rc) { |
---|
1263 | | - QETH_DBF_MESSAGE(2, "qeth_osn_send_control_data: " |
---|
1264 | | - "ccw_device_start rc = %i\n", rc); |
---|
1265 | | - QETH_CARD_TEXT_(card, 2, " err%d", rc); |
---|
1266 | | - qeth_release_buffer(channel, iob); |
---|
1267 | | - atomic_set(&channel->irq_pending, 0); |
---|
1268 | | - wake_up(&card->wait_q); |
---|
1269 | | - } |
---|
1270 | | - return rc; |
---|
1271 | | -} |
---|
1272 | | - |
---|
1273 | | -static int qeth_osn_send_ipa_cmd(struct qeth_card *card, |
---|
1274 | | - struct qeth_cmd_buffer *iob, int data_len) |
---|
1275 | | -{ |
---|
1276 | | - u16 s1, s2; |
---|
1277 | | - |
---|
1278 | | - QETH_CARD_TEXT(card, 4, "osndipa"); |
---|
1279 | | - |
---|
1280 | | - qeth_prepare_ipa_cmd(card, iob); |
---|
1281 | | - s1 = (u16)(IPA_PDU_HEADER_SIZE + data_len); |
---|
1282 | | - s2 = (u16)data_len; |
---|
1283 | | - memcpy(QETH_IPA_PDU_LEN_TOTAL(iob->data), &s1, 2); |
---|
1284 | | - memcpy(QETH_IPA_PDU_LEN_PDU1(iob->data), &s2, 2); |
---|
1285 | | - memcpy(QETH_IPA_PDU_LEN_PDU2(iob->data), &s2, 2); |
---|
1286 | | - memcpy(QETH_IPA_PDU_LEN_PDU3(iob->data), &s2, 2); |
---|
1287 | | - return qeth_osn_send_control_data(card, s1, iob); |
---|
| 1046 | + qeth_notify_cmd(iob, 0); |
---|
| 1047 | + qeth_put_cmd(iob); |
---|
1288 | 1048 | } |
---|
1289 | 1049 | |
---|
1290 | 1050 | int qeth_osn_assist(struct net_device *dev, void *data, int data_len) |
---|
.. | .. |
---|
1292 | 1052 | struct qeth_cmd_buffer *iob; |
---|
1293 | 1053 | struct qeth_card *card; |
---|
1294 | 1054 | |
---|
| 1055 | + if (data_len < 0) |
---|
| 1056 | + return -EINVAL; |
---|
1295 | 1057 | if (!dev) |
---|
1296 | 1058 | return -ENODEV; |
---|
1297 | 1059 | card = dev->ml_priv; |
---|
.. | .. |
---|
1300 | 1062 | QETH_CARD_TEXT(card, 2, "osnsdmc"); |
---|
1301 | 1063 | if (!qeth_card_hw_is_reachable(card)) |
---|
1302 | 1064 | return -ENODEV; |
---|
1303 | | - iob = qeth_wait_for_buffer(&card->write); |
---|
| 1065 | + |
---|
| 1066 | + iob = qeth_alloc_cmd(&card->write, IPA_PDU_HEADER_SIZE + data_len, 1, |
---|
| 1067 | + QETH_IPA_TIMEOUT); |
---|
| 1068 | + if (!iob) |
---|
| 1069 | + return -ENOMEM; |
---|
| 1070 | + |
---|
| 1071 | + qeth_prepare_ipa_cmd(card, iob, (u16) data_len, NULL); |
---|
| 1072 | + |
---|
1304 | 1073 | memcpy(__ipa_cmd(iob), data, data_len); |
---|
1305 | | - return qeth_osn_send_ipa_cmd(card, iob, data_len); |
---|
| 1074 | + iob->callback = qeth_osn_assist_cb; |
---|
| 1075 | + return qeth_send_ipa_cmd(card, iob, NULL, NULL); |
---|
1306 | 1076 | } |
---|
1307 | 1077 | EXPORT_SYMBOL(qeth_osn_assist); |
---|
1308 | 1078 | |
---|
.. | .. |
---|
1311 | 1081 | int (*data_cb)(struct sk_buff *)) |
---|
1312 | 1082 | { |
---|
1313 | 1083 | struct qeth_card *card; |
---|
| 1084 | + char bus_id[16]; |
---|
| 1085 | + u16 devno; |
---|
1314 | 1086 | |
---|
1315 | | - *dev = qeth_l2_netdev_by_devno(read_dev_no); |
---|
1316 | | - if (*dev == NULL) |
---|
| 1087 | + memcpy(&devno, read_dev_no, 2); |
---|
| 1088 | + sprintf(bus_id, "0.0.%04x", devno); |
---|
| 1089 | + card = qeth_get_card_by_busid(bus_id); |
---|
| 1090 | + if (!card || !IS_OSN(card)) |
---|
1317 | 1091 | return -ENODEV; |
---|
1318 | | - card = (*dev)->ml_priv; |
---|
1319 | | - if (!card) |
---|
1320 | | - return -ENODEV; |
---|
| 1092 | + *dev = card->dev; |
---|
| 1093 | + |
---|
1321 | 1094 | QETH_CARD_TEXT(card, 2, "osnreg"); |
---|
1322 | 1095 | if ((assist_cb == NULL) || (data_cb == NULL)) |
---|
1323 | 1096 | return -EINVAL; |
---|
.. | .. |
---|
1339 | 1112 | QETH_CARD_TEXT(card, 2, "osndereg"); |
---|
1340 | 1113 | card->osn_info.assist_cb = NULL; |
---|
1341 | 1114 | card->osn_info.data_cb = NULL; |
---|
1342 | | - return; |
---|
1343 | 1115 | } |
---|
1344 | 1116 | EXPORT_SYMBOL(qeth_osn_deregister); |
---|
| 1117 | +#endif |
---|
1345 | 1118 | |
---|
1346 | 1119 | /* SETBRIDGEPORT support, async notifications */ |
---|
1347 | 1120 | |
---|
.. | .. |
---|
1363 | 1136 | * for all currently registered addresses. |
---|
1364 | 1137 | */ |
---|
1365 | 1138 | static void qeth_bridge_emit_host_event(struct qeth_card *card, |
---|
1366 | | - enum qeth_an_event_type evtype, |
---|
1367 | | - u8 code, struct net_if_token *token, struct mac_addr_lnid *addr_lnid) |
---|
| 1139 | + enum qeth_an_event_type evtype, |
---|
| 1140 | + u8 code, |
---|
| 1141 | + struct net_if_token *token, |
---|
| 1142 | + struct mac_addr_lnid *addr_lnid) |
---|
1368 | 1143 | { |
---|
1369 | 1144 | char str[7][32]; |
---|
1370 | 1145 | char *env[8]; |
---|
.. | .. |
---|
1413 | 1188 | struct qeth_bridge_state_data { |
---|
1414 | 1189 | struct work_struct worker; |
---|
1415 | 1190 | struct qeth_card *card; |
---|
1416 | | - struct qeth_sbp_state_change qports; |
---|
| 1191 | + u8 role; |
---|
| 1192 | + u8 state; |
---|
1417 | 1193 | }; |
---|
1418 | 1194 | |
---|
1419 | 1195 | static void qeth_bridge_state_change_worker(struct work_struct *work) |
---|
1420 | 1196 | { |
---|
1421 | 1197 | struct qeth_bridge_state_data *data = |
---|
1422 | 1198 | container_of(work, struct qeth_bridge_state_data, worker); |
---|
1423 | | - /* We are only interested in the first entry - local port */ |
---|
1424 | | - struct qeth_sbp_port_entry *entry = &data->qports.entry[0]; |
---|
1425 | 1199 | char env_locrem[32]; |
---|
1426 | 1200 | char env_role[32]; |
---|
1427 | 1201 | char env_state[32]; |
---|
.. | .. |
---|
1432 | 1206 | NULL |
---|
1433 | 1207 | }; |
---|
1434 | 1208 | |
---|
1435 | | - /* Role should not change by itself, but if it did, */ |
---|
1436 | | - /* information from the hardware is authoritative. */ |
---|
1437 | | - mutex_lock(&data->card->conf_mutex); |
---|
1438 | | - data->card->options.sbp.role = entry->role; |
---|
1439 | | - mutex_unlock(&data->card->conf_mutex); |
---|
1440 | | - |
---|
1441 | 1209 | snprintf(env_locrem, sizeof(env_locrem), "BRIDGEPORT=statechange"); |
---|
1442 | 1210 | snprintf(env_role, sizeof(env_role), "ROLE=%s", |
---|
1443 | | - (entry->role == QETH_SBP_ROLE_NONE) ? "none" : |
---|
1444 | | - (entry->role == QETH_SBP_ROLE_PRIMARY) ? "primary" : |
---|
1445 | | - (entry->role == QETH_SBP_ROLE_SECONDARY) ? "secondary" : |
---|
| 1211 | + (data->role == QETH_SBP_ROLE_NONE) ? "none" : |
---|
| 1212 | + (data->role == QETH_SBP_ROLE_PRIMARY) ? "primary" : |
---|
| 1213 | + (data->role == QETH_SBP_ROLE_SECONDARY) ? "secondary" : |
---|
1446 | 1214 | "<INVALID>"); |
---|
1447 | 1215 | snprintf(env_state, sizeof(env_state), "STATE=%s", |
---|
1448 | | - (entry->state == QETH_SBP_STATE_INACTIVE) ? "inactive" : |
---|
1449 | | - (entry->state == QETH_SBP_STATE_STANDBY) ? "standby" : |
---|
1450 | | - (entry->state == QETH_SBP_STATE_ACTIVE) ? "active" : |
---|
| 1216 | + (data->state == QETH_SBP_STATE_INACTIVE) ? "inactive" : |
---|
| 1217 | + (data->state == QETH_SBP_STATE_STANDBY) ? "standby" : |
---|
| 1218 | + (data->state == QETH_SBP_STATE_ACTIVE) ? "active" : |
---|
1451 | 1219 | "<INVALID>"); |
---|
1452 | 1220 | kobject_uevent_env(&data->card->gdev->dev.kobj, |
---|
1453 | 1221 | KOBJ_CHANGE, env); |
---|
.. | .. |
---|
1457 | 1225 | static void qeth_bridge_state_change(struct qeth_card *card, |
---|
1458 | 1226 | struct qeth_ipa_cmd *cmd) |
---|
1459 | 1227 | { |
---|
1460 | | - struct qeth_sbp_state_change *qports = |
---|
1461 | | - &cmd->data.sbp.data.state_change; |
---|
| 1228 | + struct qeth_sbp_port_data *qports = &cmd->data.sbp.data.port_data; |
---|
1462 | 1229 | struct qeth_bridge_state_data *data; |
---|
1463 | | - int extrasize; |
---|
1464 | 1230 | |
---|
1465 | 1231 | QETH_CARD_TEXT(card, 2, "brstchng"); |
---|
1466 | 1232 | if (qports->num_entries == 0) { |
---|
.. | .. |
---|
1471 | 1237 | QETH_CARD_TEXT_(card, 2, "BPsz%04x", qports->entry_length); |
---|
1472 | 1238 | return; |
---|
1473 | 1239 | } |
---|
1474 | | - extrasize = sizeof(struct qeth_sbp_port_entry) * qports->num_entries; |
---|
1475 | | - data = kzalloc(sizeof(struct qeth_bridge_state_data) + extrasize, |
---|
1476 | | - GFP_ATOMIC); |
---|
| 1240 | + |
---|
| 1241 | + data = kzalloc(sizeof(*data), GFP_ATOMIC); |
---|
1477 | 1242 | if (!data) { |
---|
1478 | 1243 | QETH_CARD_TEXT(card, 2, "BPSalloc"); |
---|
1479 | 1244 | return; |
---|
1480 | 1245 | } |
---|
1481 | 1246 | INIT_WORK(&data->worker, qeth_bridge_state_change_worker); |
---|
1482 | 1247 | data->card = card; |
---|
1483 | | - memcpy(&data->qports, qports, |
---|
1484 | | - sizeof(struct qeth_sbp_state_change) + extrasize); |
---|
1485 | | - queue_work(qeth_wq, &data->worker); |
---|
| 1248 | + /* Information for the local port: */ |
---|
| 1249 | + data->role = qports->entry[0].role; |
---|
| 1250 | + data->state = qports->entry[0].state; |
---|
| 1251 | + |
---|
| 1252 | + queue_work(card->event_wq, &data->worker); |
---|
1486 | 1253 | } |
---|
1487 | 1254 | |
---|
1488 | | -struct qeth_bridge_host_data { |
---|
1489 | | - struct work_struct worker; |
---|
| 1255 | +struct qeth_addr_change_data { |
---|
| 1256 | + struct delayed_work dwork; |
---|
1490 | 1257 | struct qeth_card *card; |
---|
1491 | | - struct qeth_ipacmd_addr_change hostevs; |
---|
| 1258 | + struct qeth_ipacmd_addr_change ac_event; |
---|
1492 | 1259 | }; |
---|
1493 | 1260 | |
---|
1494 | | -static void qeth_bridge_host_event_worker(struct work_struct *work) |
---|
| 1261 | +static void qeth_l2_dev2br_worker(struct work_struct *work) |
---|
1495 | 1262 | { |
---|
1496 | | - struct qeth_bridge_host_data *data = |
---|
1497 | | - container_of(work, struct qeth_bridge_host_data, worker); |
---|
1498 | | - int i; |
---|
| 1263 | + struct delayed_work *dwork = to_delayed_work(work); |
---|
| 1264 | + struct qeth_addr_change_data *data; |
---|
| 1265 | + struct qeth_card *card; |
---|
| 1266 | + struct qeth_priv *priv; |
---|
| 1267 | + unsigned int i; |
---|
| 1268 | + int rc; |
---|
1499 | 1269 | |
---|
1500 | | - if (data->hostevs.lost_event_mask) { |
---|
1501 | | - dev_info(&data->card->gdev->dev, |
---|
1502 | | -"Address notification from the Bridge Port stopped %s (%s)\n", |
---|
1503 | | - data->card->dev->name, |
---|
1504 | | - (data->hostevs.lost_event_mask == 0x01) |
---|
1505 | | - ? "Overflow" |
---|
1506 | | - : (data->hostevs.lost_event_mask == 0x02) |
---|
1507 | | - ? "Bridge port state change" |
---|
1508 | | - : "Unknown reason"); |
---|
1509 | | - mutex_lock(&data->card->conf_mutex); |
---|
1510 | | - data->card->options.sbp.hostnotification = 0; |
---|
1511 | | - mutex_unlock(&data->card->conf_mutex); |
---|
1512 | | - qeth_bridge_emit_host_event(data->card, anev_abort, |
---|
1513 | | - 0, NULL, NULL); |
---|
1514 | | - } else |
---|
1515 | | - for (i = 0; i < data->hostevs.num_entries; i++) { |
---|
1516 | | - struct qeth_ipacmd_addr_change_entry *entry = |
---|
1517 | | - &data->hostevs.entry[i]; |
---|
1518 | | - qeth_bridge_emit_host_event(data->card, |
---|
1519 | | - anev_reg_unreg, |
---|
1520 | | - entry->change_code, |
---|
1521 | | - &entry->token, &entry->addr_lnid); |
---|
| 1270 | + data = container_of(dwork, struct qeth_addr_change_data, dwork); |
---|
| 1271 | + card = data->card; |
---|
| 1272 | + priv = netdev_priv(card->dev); |
---|
| 1273 | + |
---|
| 1274 | + QETH_CARD_TEXT(card, 4, "dev2brew"); |
---|
| 1275 | + |
---|
| 1276 | + if (READ_ONCE(card->info.pnso_mode) == QETH_PNSO_NONE) |
---|
| 1277 | + goto free; |
---|
| 1278 | + |
---|
| 1279 | + /* Potential re-config in progress, try again later: */ |
---|
| 1280 | + if (!rtnl_trylock()) { |
---|
| 1281 | + queue_delayed_work(card->event_wq, dwork, |
---|
| 1282 | + msecs_to_jiffies(100)); |
---|
| 1283 | + return; |
---|
| 1284 | + } |
---|
| 1285 | + if (!netif_device_present(card->dev)) |
---|
| 1286 | + goto out_unlock; |
---|
| 1287 | + |
---|
| 1288 | + if (data->ac_event.lost_event_mask) { |
---|
| 1289 | + QETH_DBF_MESSAGE(3, |
---|
| 1290 | + "Address change notification overflow on device %x\n", |
---|
| 1291 | + CARD_DEVID(card)); |
---|
| 1292 | + /* Card fdb and bridge fdb are out of sync, card has stopped |
---|
| 1293 | + * notifications (no need to drain_workqueue). Purge all |
---|
| 1294 | + * 'extern_learn' entries from the parent bridge and restart |
---|
| 1295 | + * the notifications. |
---|
| 1296 | + */ |
---|
| 1297 | + qeth_l2_dev2br_fdb_flush(card); |
---|
| 1298 | + rc = qeth_l2_dev2br_an_set(card, true); |
---|
| 1299 | + if (rc) { |
---|
| 1300 | + /* TODO: if we want to retry after -EAGAIN, be |
---|
| 1301 | + * aware there could be stale entries in the |
---|
| 1302 | + * workqueue now, that need to be drained. |
---|
| 1303 | + * For now we give up: |
---|
| 1304 | + */ |
---|
| 1305 | + netdev_err(card->dev, |
---|
| 1306 | + "bridge learning_sync failed to recover: %d\n", |
---|
| 1307 | + rc); |
---|
| 1308 | + WRITE_ONCE(card->info.pnso_mode, |
---|
| 1309 | + QETH_PNSO_NONE); |
---|
| 1310 | + /* To remove fdb entries reported by an_set: */ |
---|
| 1311 | + qeth_l2_dev2br_fdb_flush(card); |
---|
| 1312 | + priv->brport_features ^= BR_LEARNING_SYNC; |
---|
| 1313 | + } else { |
---|
| 1314 | + QETH_DBF_MESSAGE(3, |
---|
| 1315 | + "Address Notification resynced on device %x\n", |
---|
| 1316 | + CARD_DEVID(card)); |
---|
1522 | 1317 | } |
---|
| 1318 | + } else { |
---|
| 1319 | + for (i = 0; i < data->ac_event.num_entries; i++) { |
---|
| 1320 | + struct qeth_ipacmd_addr_change_entry *entry = |
---|
| 1321 | + &data->ac_event.entry[i]; |
---|
| 1322 | + qeth_l2_dev2br_fdb_notify(card, |
---|
| 1323 | + entry->change_code, |
---|
| 1324 | + &entry->token, |
---|
| 1325 | + &entry->addr_lnid); |
---|
| 1326 | + } |
---|
| 1327 | + } |
---|
| 1328 | + |
---|
| 1329 | +out_unlock: |
---|
| 1330 | + rtnl_unlock(); |
---|
| 1331 | + |
---|
| 1332 | +free: |
---|
1523 | 1333 | kfree(data); |
---|
1524 | 1334 | } |
---|
1525 | 1335 | |
---|
1526 | | -static void qeth_bridge_host_event(struct qeth_card *card, |
---|
1527 | | - struct qeth_ipa_cmd *cmd) |
---|
| 1336 | +static void qeth_addr_change_event_worker(struct work_struct *work) |
---|
| 1337 | +{ |
---|
| 1338 | + struct delayed_work *dwork = to_delayed_work(work); |
---|
| 1339 | + struct qeth_addr_change_data *data; |
---|
| 1340 | + struct qeth_card *card; |
---|
| 1341 | + int i; |
---|
| 1342 | + |
---|
| 1343 | + data = container_of(dwork, struct qeth_addr_change_data, dwork); |
---|
| 1344 | + card = data->card; |
---|
| 1345 | + |
---|
| 1346 | + QETH_CARD_TEXT(data->card, 4, "adrchgew"); |
---|
| 1347 | + |
---|
| 1348 | + if (READ_ONCE(card->info.pnso_mode) == QETH_PNSO_NONE) |
---|
| 1349 | + goto free; |
---|
| 1350 | + |
---|
| 1351 | + if (data->ac_event.lost_event_mask) { |
---|
| 1352 | + /* Potential re-config in progress, try again later: */ |
---|
| 1353 | + if (!mutex_trylock(&card->sbp_lock)) { |
---|
| 1354 | + queue_delayed_work(card->event_wq, dwork, |
---|
| 1355 | + msecs_to_jiffies(100)); |
---|
| 1356 | + return; |
---|
| 1357 | + } |
---|
| 1358 | + |
---|
| 1359 | + dev_info(&data->card->gdev->dev, |
---|
| 1360 | + "Address change notification stopped on %s (%s)\n", |
---|
| 1361 | + netdev_name(card->dev), |
---|
| 1362 | + (data->ac_event.lost_event_mask == 0x01) |
---|
| 1363 | + ? "Overflow" |
---|
| 1364 | + : (data->ac_event.lost_event_mask == 0x02) |
---|
| 1365 | + ? "Bridge port state change" |
---|
| 1366 | + : "Unknown reason"); |
---|
| 1367 | + |
---|
| 1368 | + data->card->options.sbp.hostnotification = 0; |
---|
| 1369 | + card->info.pnso_mode = QETH_PNSO_NONE; |
---|
| 1370 | + mutex_unlock(&data->card->sbp_lock); |
---|
| 1371 | + qeth_bridge_emit_host_event(data->card, anev_abort, |
---|
| 1372 | + 0, NULL, NULL); |
---|
| 1373 | + } else |
---|
| 1374 | + for (i = 0; i < data->ac_event.num_entries; i++) { |
---|
| 1375 | + struct qeth_ipacmd_addr_change_entry *entry = |
---|
| 1376 | + &data->ac_event.entry[i]; |
---|
| 1377 | + qeth_bridge_emit_host_event(data->card, |
---|
| 1378 | + anev_reg_unreg, |
---|
| 1379 | + entry->change_code, |
---|
| 1380 | + &entry->token, |
---|
| 1381 | + &entry->addr_lnid); |
---|
| 1382 | + } |
---|
| 1383 | + |
---|
| 1384 | +free: |
---|
| 1385 | + kfree(data); |
---|
| 1386 | +} |
---|
| 1387 | + |
---|
| 1388 | +static void qeth_addr_change_event(struct qeth_card *card, |
---|
| 1389 | + struct qeth_ipa_cmd *cmd) |
---|
1528 | 1390 | { |
---|
1529 | 1391 | struct qeth_ipacmd_addr_change *hostevs = |
---|
1530 | 1392 | &cmd->data.addrchange; |
---|
1531 | | - struct qeth_bridge_host_data *data; |
---|
| 1393 | + struct qeth_addr_change_data *data; |
---|
1532 | 1394 | int extrasize; |
---|
1533 | 1395 | |
---|
1534 | | - QETH_CARD_TEXT(card, 2, "brhostev"); |
---|
| 1396 | + if (card->info.pnso_mode == QETH_PNSO_NONE) |
---|
| 1397 | + return; |
---|
| 1398 | + |
---|
| 1399 | + QETH_CARD_TEXT(card, 4, "adrchgev"); |
---|
1535 | 1400 | if (cmd->hdr.return_code != 0x0000) { |
---|
1536 | 1401 | if (cmd->hdr.return_code == 0x0010) { |
---|
1537 | 1402 | if (hostevs->lost_event_mask == 0x00) |
---|
1538 | 1403 | hostevs->lost_event_mask = 0xff; |
---|
1539 | 1404 | } else { |
---|
1540 | | - QETH_CARD_TEXT_(card, 2, "BPHe%04x", |
---|
| 1405 | + QETH_CARD_TEXT_(card, 2, "ACHN%04x", |
---|
1541 | 1406 | cmd->hdr.return_code); |
---|
1542 | 1407 | return; |
---|
1543 | 1408 | } |
---|
1544 | 1409 | } |
---|
1545 | 1410 | extrasize = sizeof(struct qeth_ipacmd_addr_change_entry) * |
---|
1546 | 1411 | hostevs->num_entries; |
---|
1547 | | - data = kzalloc(sizeof(struct qeth_bridge_host_data) + extrasize, |
---|
1548 | | - GFP_ATOMIC); |
---|
| 1412 | + data = kzalloc(sizeof(struct qeth_addr_change_data) + extrasize, |
---|
| 1413 | + GFP_ATOMIC); |
---|
1549 | 1414 | if (!data) { |
---|
1550 | | - QETH_CARD_TEXT(card, 2, "BPHalloc"); |
---|
| 1415 | + QETH_CARD_TEXT(card, 2, "ACNalloc"); |
---|
1551 | 1416 | return; |
---|
1552 | 1417 | } |
---|
1553 | | - INIT_WORK(&data->worker, qeth_bridge_host_event_worker); |
---|
| 1418 | + if (card->info.pnso_mode == QETH_PNSO_BRIDGEPORT) |
---|
| 1419 | + INIT_DELAYED_WORK(&data->dwork, qeth_addr_change_event_worker); |
---|
| 1420 | + else |
---|
| 1421 | + INIT_DELAYED_WORK(&data->dwork, qeth_l2_dev2br_worker); |
---|
1554 | 1422 | data->card = card; |
---|
1555 | | - memcpy(&data->hostevs, hostevs, |
---|
| 1423 | + memcpy(&data->ac_event, hostevs, |
---|
1556 | 1424 | sizeof(struct qeth_ipacmd_addr_change) + extrasize); |
---|
1557 | | - queue_work(qeth_wq, &data->worker); |
---|
| 1425 | + queue_delayed_work(card->event_wq, &data->dwork, 0); |
---|
1558 | 1426 | } |
---|
1559 | 1427 | |
---|
1560 | 1428 | /* SETBRIDGEPORT support; sending commands */ |
---|
1561 | 1429 | |
---|
1562 | 1430 | struct _qeth_sbp_cbctl { |
---|
1563 | | - u16 ipa_rc; |
---|
1564 | | - u16 cmd_rc; |
---|
1565 | 1431 | union { |
---|
1566 | 1432 | u32 supported; |
---|
1567 | 1433 | struct { |
---|
.. | .. |
---|
1571 | 1437 | } data; |
---|
1572 | 1438 | }; |
---|
1573 | 1439 | |
---|
1574 | | -/** |
---|
1575 | | - * qeth_bridgeport_makerc() - derive "traditional" error from hardware codes. |
---|
1576 | | - * @card: qeth_card structure pointer, for debug messages. |
---|
1577 | | - * @cbctl: state structure with hardware return codes. |
---|
1578 | | - * @setcmd: IPA command code |
---|
1579 | | - * |
---|
1580 | | - * Returns negative errno-compatible error indication or 0 on success. |
---|
1581 | | - */ |
---|
1582 | 1440 | static int qeth_bridgeport_makerc(struct qeth_card *card, |
---|
1583 | | - struct _qeth_sbp_cbctl *cbctl, enum qeth_ipa_sbp_cmd setcmd) |
---|
| 1441 | + struct qeth_ipa_cmd *cmd) |
---|
1584 | 1442 | { |
---|
| 1443 | + struct qeth_ipacmd_setbridgeport *sbp = &cmd->data.sbp; |
---|
| 1444 | + enum qeth_ipa_sbp_cmd setcmd = sbp->hdr.command_code; |
---|
| 1445 | + u16 ipa_rc = cmd->hdr.return_code; |
---|
| 1446 | + u16 sbp_rc = sbp->hdr.return_code; |
---|
1585 | 1447 | int rc; |
---|
1586 | | - int is_iqd = (card->info.type == QETH_CARD_TYPE_IQD); |
---|
1587 | 1448 | |
---|
1588 | | - if ((is_iqd && (cbctl->ipa_rc == IPA_RC_SUCCESS)) || |
---|
1589 | | - (!is_iqd && (cbctl->ipa_rc == cbctl->cmd_rc))) |
---|
1590 | | - switch (cbctl->cmd_rc) { |
---|
| 1449 | + if (ipa_rc == IPA_RC_SUCCESS && sbp_rc == IPA_RC_SUCCESS) |
---|
| 1450 | + return 0; |
---|
| 1451 | + |
---|
| 1452 | + if ((IS_IQD(card) && ipa_rc == IPA_RC_SUCCESS) || |
---|
| 1453 | + (!IS_IQD(card) && ipa_rc == sbp_rc)) { |
---|
| 1454 | + switch (sbp_rc) { |
---|
1591 | 1455 | case IPA_RC_SUCCESS: |
---|
1592 | 1456 | rc = 0; |
---|
1593 | 1457 | break; |
---|
.. | .. |
---|
1651 | 1515 | default: |
---|
1652 | 1516 | rc = -EIO; |
---|
1653 | 1517 | } |
---|
1654 | | - else |
---|
1655 | | - switch (cbctl->ipa_rc) { |
---|
| 1518 | + } else { |
---|
| 1519 | + switch (ipa_rc) { |
---|
1656 | 1520 | case IPA_RC_NOTSUPP: |
---|
1657 | 1521 | rc = -EOPNOTSUPP; |
---|
1658 | 1522 | break; |
---|
.. | .. |
---|
1662 | 1526 | default: |
---|
1663 | 1527 | rc = -EIO; |
---|
1664 | 1528 | } |
---|
| 1529 | + } |
---|
1665 | 1530 | |
---|
1666 | 1531 | if (rc) { |
---|
1667 | | - QETH_CARD_TEXT_(card, 2, "SBPi%04x", cbctl->ipa_rc); |
---|
1668 | | - QETH_CARD_TEXT_(card, 2, "SBPc%04x", cbctl->cmd_rc); |
---|
| 1532 | + QETH_CARD_TEXT_(card, 2, "SBPi%04x", ipa_rc); |
---|
| 1533 | + QETH_CARD_TEXT_(card, 2, "SBPc%04x", sbp_rc); |
---|
1669 | 1534 | } |
---|
1670 | 1535 | return rc; |
---|
1671 | 1536 | } |
---|
1672 | 1537 | |
---|
1673 | 1538 | static struct qeth_cmd_buffer *qeth_sbp_build_cmd(struct qeth_card *card, |
---|
1674 | 1539 | enum qeth_ipa_sbp_cmd sbp_cmd, |
---|
1675 | | - unsigned int cmd_length) |
---|
| 1540 | + unsigned int data_length) |
---|
1676 | 1541 | { |
---|
1677 | | - enum qeth_ipa_cmds ipa_cmd = (card->info.type == QETH_CARD_TYPE_IQD) ? |
---|
1678 | | - IPA_CMD_SETBRIDGEPORT_IQD : |
---|
1679 | | - IPA_CMD_SETBRIDGEPORT_OSA; |
---|
| 1542 | + enum qeth_ipa_cmds ipa_cmd = IS_IQD(card) ? IPA_CMD_SETBRIDGEPORT_IQD : |
---|
| 1543 | + IPA_CMD_SETBRIDGEPORT_OSA; |
---|
| 1544 | + struct qeth_ipacmd_sbp_hdr *hdr; |
---|
1680 | 1545 | struct qeth_cmd_buffer *iob; |
---|
1681 | | - struct qeth_ipa_cmd *cmd; |
---|
1682 | 1546 | |
---|
1683 | | - iob = qeth_get_ipacmd_buffer(card, ipa_cmd, 0); |
---|
| 1547 | + iob = qeth_ipa_alloc_cmd(card, ipa_cmd, QETH_PROT_NONE, |
---|
| 1548 | + data_length + |
---|
| 1549 | + offsetof(struct qeth_ipacmd_setbridgeport, |
---|
| 1550 | + data)); |
---|
1684 | 1551 | if (!iob) |
---|
1685 | 1552 | return iob; |
---|
1686 | | - cmd = __ipa_cmd(iob); |
---|
1687 | | - cmd->data.sbp.hdr.cmdlength = sizeof(struct qeth_ipacmd_sbp_hdr) + |
---|
1688 | | - cmd_length; |
---|
1689 | | - cmd->data.sbp.hdr.command_code = sbp_cmd; |
---|
1690 | | - cmd->data.sbp.hdr.used_total = 1; |
---|
1691 | | - cmd->data.sbp.hdr.seq_no = 1; |
---|
| 1553 | + |
---|
| 1554 | + hdr = &__ipa_cmd(iob)->data.sbp.hdr; |
---|
| 1555 | + hdr->cmdlength = sizeof(*hdr) + data_length; |
---|
| 1556 | + hdr->command_code = sbp_cmd; |
---|
| 1557 | + hdr->used_total = 1; |
---|
| 1558 | + hdr->seq_no = 1; |
---|
1692 | 1559 | return iob; |
---|
1693 | 1560 | } |
---|
1694 | 1561 | |
---|
.. | .. |
---|
1697 | 1564 | { |
---|
1698 | 1565 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
---|
1699 | 1566 | struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; |
---|
| 1567 | + int rc; |
---|
| 1568 | + |
---|
1700 | 1569 | QETH_CARD_TEXT(card, 2, "brqsupcb"); |
---|
1701 | | - cbctl->ipa_rc = cmd->hdr.return_code; |
---|
1702 | | - cbctl->cmd_rc = cmd->data.sbp.hdr.return_code; |
---|
1703 | | - if ((cbctl->ipa_rc == 0) && (cbctl->cmd_rc == 0)) { |
---|
1704 | | - cbctl->data.supported = |
---|
1705 | | - cmd->data.sbp.data.query_cmds_supp.supported_cmds; |
---|
1706 | | - } else { |
---|
1707 | | - cbctl->data.supported = 0; |
---|
1708 | | - } |
---|
| 1570 | + rc = qeth_bridgeport_makerc(card, cmd); |
---|
| 1571 | + if (rc) |
---|
| 1572 | + return rc; |
---|
| 1573 | + |
---|
| 1574 | + cbctl->data.supported = |
---|
| 1575 | + cmd->data.sbp.data.query_cmds_supp.supported_cmds; |
---|
1709 | 1576 | return 0; |
---|
1710 | 1577 | } |
---|
1711 | 1578 | |
---|
.. | .. |
---|
1723 | 1590 | |
---|
1724 | 1591 | QETH_CARD_TEXT(card, 2, "brqsuppo"); |
---|
1725 | 1592 | iob = qeth_sbp_build_cmd(card, IPA_SBP_QUERY_COMMANDS_SUPPORTED, |
---|
1726 | | - sizeof(struct qeth_sbp_query_cmds_supp)); |
---|
| 1593 | + SBP_DATA_SIZEOF(query_cmds_supp)); |
---|
1727 | 1594 | if (!iob) |
---|
1728 | 1595 | return; |
---|
| 1596 | + |
---|
1729 | 1597 | if (qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_support_cb, |
---|
1730 | | - (void *)&cbctl) || |
---|
1731 | | - qeth_bridgeport_makerc(card, &cbctl, |
---|
1732 | | - IPA_SBP_QUERY_COMMANDS_SUPPORTED)) { |
---|
1733 | | - /* non-zero makerc signifies failure, and produce messages */ |
---|
| 1598 | + &cbctl)) { |
---|
1734 | 1599 | card->options.sbp.role = QETH_SBP_ROLE_NONE; |
---|
| 1600 | + card->options.sbp.supported_funcs = 0; |
---|
1735 | 1601 | return; |
---|
1736 | 1602 | } |
---|
1737 | 1603 | card->options.sbp.supported_funcs = cbctl.data.supported; |
---|
.. | .. |
---|
1741 | 1607 | struct qeth_reply *reply, unsigned long data) |
---|
1742 | 1608 | { |
---|
1743 | 1609 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
---|
1744 | | - struct qeth_sbp_query_ports *qports = &cmd->data.sbp.data.query_ports; |
---|
1745 | 1610 | struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; |
---|
| 1611 | + struct qeth_sbp_port_data *qports; |
---|
| 1612 | + int rc; |
---|
1746 | 1613 | |
---|
1747 | 1614 | QETH_CARD_TEXT(card, 2, "brqprtcb"); |
---|
1748 | | - cbctl->ipa_rc = cmd->hdr.return_code; |
---|
1749 | | - cbctl->cmd_rc = cmd->data.sbp.hdr.return_code; |
---|
1750 | | - if ((cbctl->ipa_rc != 0) || (cbctl->cmd_rc != 0)) |
---|
1751 | | - return 0; |
---|
| 1615 | + rc = qeth_bridgeport_makerc(card, cmd); |
---|
| 1616 | + if (rc) |
---|
| 1617 | + return rc; |
---|
| 1618 | + |
---|
| 1619 | + qports = &cmd->data.sbp.data.port_data; |
---|
1752 | 1620 | if (qports->entry_length != sizeof(struct qeth_sbp_port_entry)) { |
---|
1753 | | - cbctl->cmd_rc = 0xffff; |
---|
1754 | 1621 | QETH_CARD_TEXT_(card, 2, "SBPs%04x", qports->entry_length); |
---|
1755 | | - return 0; |
---|
| 1622 | + return -EINVAL; |
---|
1756 | 1623 | } |
---|
1757 | 1624 | /* first entry contains the state of the local port */ |
---|
1758 | 1625 | if (qports->num_entries > 0) { |
---|
.. | .. |
---|
1777 | 1644 | int qeth_bridgeport_query_ports(struct qeth_card *card, |
---|
1778 | 1645 | enum qeth_sbp_roles *role, enum qeth_sbp_states *state) |
---|
1779 | 1646 | { |
---|
1780 | | - int rc = 0; |
---|
1781 | 1647 | struct qeth_cmd_buffer *iob; |
---|
1782 | 1648 | struct _qeth_sbp_cbctl cbctl = { |
---|
1783 | 1649 | .data = { |
---|
.. | .. |
---|
1794 | 1660 | iob = qeth_sbp_build_cmd(card, IPA_SBP_QUERY_BRIDGE_PORTS, 0); |
---|
1795 | 1661 | if (!iob) |
---|
1796 | 1662 | return -ENOMEM; |
---|
1797 | | - rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb, |
---|
1798 | | - (void *)&cbctl); |
---|
1799 | | - if (rc < 0) |
---|
1800 | | - return rc; |
---|
1801 | | - return qeth_bridgeport_makerc(card, &cbctl, IPA_SBP_QUERY_BRIDGE_PORTS); |
---|
| 1663 | + |
---|
| 1664 | + return qeth_send_ipa_cmd(card, iob, qeth_bridgeport_query_ports_cb, |
---|
| 1665 | + &cbctl); |
---|
1802 | 1666 | } |
---|
1803 | 1667 | |
---|
1804 | 1668 | static int qeth_bridgeport_set_cb(struct qeth_card *card, |
---|
1805 | 1669 | struct qeth_reply *reply, unsigned long data) |
---|
1806 | 1670 | { |
---|
1807 | 1671 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *)data; |
---|
1808 | | - struct _qeth_sbp_cbctl *cbctl = (struct _qeth_sbp_cbctl *)reply->param; |
---|
| 1672 | + |
---|
1809 | 1673 | QETH_CARD_TEXT(card, 2, "brsetrcb"); |
---|
1810 | | - cbctl->ipa_rc = cmd->hdr.return_code; |
---|
1811 | | - cbctl->cmd_rc = cmd->data.sbp.hdr.return_code; |
---|
1812 | | - return 0; |
---|
| 1674 | + return qeth_bridgeport_makerc(card, cmd); |
---|
1813 | 1675 | } |
---|
1814 | 1676 | |
---|
1815 | 1677 | /** |
---|
.. | .. |
---|
1821 | 1683 | */ |
---|
1822 | 1684 | int qeth_bridgeport_setrole(struct qeth_card *card, enum qeth_sbp_roles role) |
---|
1823 | 1685 | { |
---|
1824 | | - int rc = 0; |
---|
1825 | | - int cmdlength; |
---|
1826 | 1686 | struct qeth_cmd_buffer *iob; |
---|
1827 | | - struct _qeth_sbp_cbctl cbctl; |
---|
1828 | 1687 | enum qeth_ipa_sbp_cmd setcmd; |
---|
| 1688 | + unsigned int cmdlength = 0; |
---|
1829 | 1689 | |
---|
1830 | 1690 | QETH_CARD_TEXT(card, 2, "brsetrol"); |
---|
1831 | 1691 | switch (role) { |
---|
1832 | 1692 | case QETH_SBP_ROLE_NONE: |
---|
1833 | 1693 | setcmd = IPA_SBP_RESET_BRIDGE_PORT_ROLE; |
---|
1834 | | - cmdlength = sizeof(struct qeth_sbp_reset_role); |
---|
1835 | 1694 | break; |
---|
1836 | 1695 | case QETH_SBP_ROLE_PRIMARY: |
---|
1837 | 1696 | setcmd = IPA_SBP_SET_PRIMARY_BRIDGE_PORT; |
---|
1838 | | - cmdlength = sizeof(struct qeth_sbp_set_primary); |
---|
| 1697 | + cmdlength = SBP_DATA_SIZEOF(set_primary); |
---|
1839 | 1698 | break; |
---|
1840 | 1699 | case QETH_SBP_ROLE_SECONDARY: |
---|
1841 | 1700 | setcmd = IPA_SBP_SET_SECONDARY_BRIDGE_PORT; |
---|
1842 | | - cmdlength = sizeof(struct qeth_sbp_set_secondary); |
---|
1843 | 1701 | break; |
---|
1844 | 1702 | default: |
---|
1845 | 1703 | return -EINVAL; |
---|
.. | .. |
---|
1849 | 1707 | iob = qeth_sbp_build_cmd(card, setcmd, cmdlength); |
---|
1850 | 1708 | if (!iob) |
---|
1851 | 1709 | return -ENOMEM; |
---|
1852 | | - rc = qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb, |
---|
1853 | | - (void *)&cbctl); |
---|
1854 | | - if (rc < 0) |
---|
1855 | | - return rc; |
---|
1856 | | - return qeth_bridgeport_makerc(card, &cbctl, setcmd); |
---|
1857 | | -} |
---|
1858 | 1710 | |
---|
1859 | | -/** |
---|
1860 | | - * qeth_anset_makerc() - derive "traditional" error from hardware codes. |
---|
1861 | | - * @card: qeth_card structure pointer, for debug messages. |
---|
1862 | | - * |
---|
1863 | | - * Returns negative errno-compatible error indication or 0 on success. |
---|
1864 | | - */ |
---|
1865 | | -static int qeth_anset_makerc(struct qeth_card *card, int pnso_rc, u16 response) |
---|
1866 | | -{ |
---|
1867 | | - int rc; |
---|
1868 | | - |
---|
1869 | | - if (pnso_rc == 0) |
---|
1870 | | - switch (response) { |
---|
1871 | | - case 0x0001: |
---|
1872 | | - rc = 0; |
---|
1873 | | - break; |
---|
1874 | | - case 0x0004: |
---|
1875 | | - case 0x0100: |
---|
1876 | | - case 0x0106: |
---|
1877 | | - rc = -EOPNOTSUPP; |
---|
1878 | | - dev_err(&card->gdev->dev, |
---|
1879 | | - "Setting address notification failed\n"); |
---|
1880 | | - break; |
---|
1881 | | - case 0x0107: |
---|
1882 | | - rc = -EAGAIN; |
---|
1883 | | - break; |
---|
1884 | | - default: |
---|
1885 | | - rc = -EIO; |
---|
1886 | | - } |
---|
1887 | | - else |
---|
1888 | | - rc = -EIO; |
---|
1889 | | - |
---|
1890 | | - if (rc) { |
---|
1891 | | - QETH_CARD_TEXT_(card, 2, "SBPp%04x", pnso_rc); |
---|
1892 | | - QETH_CARD_TEXT_(card, 2, "SBPr%04x", response); |
---|
1893 | | - } |
---|
1894 | | - return rc; |
---|
| 1711 | + return qeth_send_ipa_cmd(card, iob, qeth_bridgeport_set_cb, NULL); |
---|
1895 | 1712 | } |
---|
1896 | 1713 | |
---|
1897 | 1714 | static void qeth_bridgeport_an_set_cb(void *priv, |
---|
1898 | | - enum qdio_brinfo_entry_type type, void *entry) |
---|
| 1715 | + struct chsc_pnso_naid_l2 *entry) |
---|
1899 | 1716 | { |
---|
1900 | 1717 | struct qeth_card *card = (struct qeth_card *)priv; |
---|
1901 | | - struct qdio_brinfo_entry_l2 *l2entry; |
---|
1902 | 1718 | u8 code; |
---|
1903 | 1719 | |
---|
1904 | | - if (type != l2_addr_lnid) { |
---|
1905 | | - WARN_ON_ONCE(1); |
---|
1906 | | - return; |
---|
1907 | | - } |
---|
1908 | | - |
---|
1909 | | - l2entry = (struct qdio_brinfo_entry_l2 *)entry; |
---|
1910 | 1720 | code = IPA_ADDR_CHANGE_CODE_MACADDR; |
---|
1911 | | - if (l2entry->addr_lnid.lnid < VLAN_N_VID) |
---|
| 1721 | + if (entry->addr_lnid.lnid < VLAN_N_VID) |
---|
1912 | 1722 | code |= IPA_ADDR_CHANGE_CODE_VLANID; |
---|
1913 | 1723 | qeth_bridge_emit_host_event(card, anev_reg_unreg, code, |
---|
1914 | | - (struct net_if_token *)&l2entry->nit, |
---|
1915 | | - (struct mac_addr_lnid *)&l2entry->addr_lnid); |
---|
| 1724 | + (struct net_if_token *)&entry->nit, |
---|
| 1725 | + (struct mac_addr_lnid *)&entry->addr_lnid); |
---|
1916 | 1726 | } |
---|
1917 | 1727 | |
---|
1918 | 1728 | /** |
---|
.. | .. |
---|
1928 | 1738 | int qeth_bridgeport_an_set(struct qeth_card *card, int enable) |
---|
1929 | 1739 | { |
---|
1930 | 1740 | int rc; |
---|
1931 | | - u16 response; |
---|
1932 | | - struct ccw_device *ddev; |
---|
1933 | | - struct subchannel_id schid; |
---|
1934 | 1741 | |
---|
1935 | | - if (!card) |
---|
1936 | | - return -EINVAL; |
---|
1937 | 1742 | if (!card->options.sbp.supported_funcs) |
---|
1938 | 1743 | return -EOPNOTSUPP; |
---|
1939 | | - ddev = CARD_DDEV(card); |
---|
1940 | | - ccw_device_get_schid(ddev, &schid); |
---|
1941 | 1744 | |
---|
1942 | 1745 | if (enable) { |
---|
1943 | 1746 | qeth_bridge_emit_host_event(card, anev_reset, 0, NULL, NULL); |
---|
1944 | | - rc = qdio_pnso_brinfo(schid, 1, &response, |
---|
1945 | | - qeth_bridgeport_an_set_cb, card); |
---|
1946 | | - } else |
---|
1947 | | - rc = qdio_pnso_brinfo(schid, 0, &response, NULL, NULL); |
---|
1948 | | - return qeth_anset_makerc(card, rc, response); |
---|
1949 | | -} |
---|
1950 | | - |
---|
1951 | | -static bool qeth_bridgeport_is_in_use(struct qeth_card *card) |
---|
1952 | | -{ |
---|
1953 | | - return (card->options.sbp.role || card->options.sbp.reflect_promisc || |
---|
1954 | | - card->options.sbp.hostnotification); |
---|
| 1747 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_BRIDGEPORT); |
---|
| 1748 | + rc = qeth_l2_pnso(card, PNSO_OC_NET_BRIDGE_INFO, 1, |
---|
| 1749 | + qeth_bridgeport_an_set_cb, card); |
---|
| 1750 | + if (rc) |
---|
| 1751 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_NONE); |
---|
| 1752 | + } else { |
---|
| 1753 | + rc = qeth_l2_pnso(card, PNSO_OC_NET_BRIDGE_INFO, 0, NULL, NULL); |
---|
| 1754 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_NONE); |
---|
| 1755 | + } |
---|
| 1756 | + return rc; |
---|
1955 | 1757 | } |
---|
1956 | 1758 | |
---|
1957 | 1759 | /* VNIC Characteristics support */ |
---|
1958 | 1760 | |
---|
1959 | 1761 | /* handle VNICC IPA command return codes; convert to error codes */ |
---|
1960 | | -static int qeth_l2_vnicc_makerc(struct qeth_card *card, int ipa_rc) |
---|
| 1762 | +static int qeth_l2_vnicc_makerc(struct qeth_card *card, u16 ipa_rc) |
---|
1961 | 1763 | { |
---|
1962 | 1764 | int rc; |
---|
1963 | 1765 | |
---|
.. | .. |
---|
1988 | 1790 | return rc; |
---|
1989 | 1791 | } |
---|
1990 | 1792 | |
---|
1991 | | -/* generic VNICC request call back control */ |
---|
1992 | | -struct _qeth_l2_vnicc_request_cbctl { |
---|
1993 | | - u32 sub_cmd; |
---|
1994 | | - struct { |
---|
1995 | | - u32 vnic_char; |
---|
1996 | | - u32 timeout; |
---|
1997 | | - } param; |
---|
1998 | | - struct { |
---|
1999 | | - union{ |
---|
2000 | | - u32 *sup_cmds; |
---|
2001 | | - u32 *timeout; |
---|
2002 | | - }; |
---|
2003 | | - } result; |
---|
2004 | | -}; |
---|
2005 | | - |
---|
2006 | 1793 | /* generic VNICC request call back */ |
---|
2007 | 1794 | static int qeth_l2_vnicc_request_cb(struct qeth_card *card, |
---|
2008 | 1795 | struct qeth_reply *reply, |
---|
2009 | 1796 | unsigned long data) |
---|
2010 | 1797 | { |
---|
2011 | | - struct _qeth_l2_vnicc_request_cbctl *cbctl = |
---|
2012 | | - (struct _qeth_l2_vnicc_request_cbctl *) reply->param; |
---|
2013 | 1798 | struct qeth_ipa_cmd *cmd = (struct qeth_ipa_cmd *) data; |
---|
2014 | 1799 | struct qeth_ipacmd_vnicc *rep = &cmd->data.vnicc; |
---|
| 1800 | + u32 sub_cmd = cmd->data.vnicc.hdr.sub_command; |
---|
2015 | 1801 | |
---|
2016 | 1802 | QETH_CARD_TEXT(card, 2, "vniccrcb"); |
---|
2017 | 1803 | if (cmd->hdr.return_code) |
---|
2018 | | - return 0; |
---|
| 1804 | + return qeth_l2_vnicc_makerc(card, cmd->hdr.return_code); |
---|
2019 | 1805 | /* return results to caller */ |
---|
2020 | | - card->options.vnicc.sup_chars = rep->hdr.sup; |
---|
2021 | | - card->options.vnicc.cur_chars = rep->hdr.cur; |
---|
| 1806 | + card->options.vnicc.sup_chars = rep->vnicc_cmds.supported; |
---|
| 1807 | + card->options.vnicc.cur_chars = rep->vnicc_cmds.enabled; |
---|
2022 | 1808 | |
---|
2023 | | - if (cbctl->sub_cmd == IPA_VNICC_QUERY_CMDS) |
---|
2024 | | - *cbctl->result.sup_cmds = rep->query_cmds.sup_cmds; |
---|
2025 | | - |
---|
2026 | | - if (cbctl->sub_cmd == IPA_VNICC_GET_TIMEOUT) |
---|
2027 | | - *cbctl->result.timeout = rep->getset_timeout.timeout; |
---|
| 1809 | + if (sub_cmd == IPA_VNICC_QUERY_CMDS) |
---|
| 1810 | + *(u32 *)reply->param = rep->data.query_cmds.sup_cmds; |
---|
| 1811 | + else if (sub_cmd == IPA_VNICC_GET_TIMEOUT) |
---|
| 1812 | + *(u32 *)reply->param = rep->data.getset_timeout.timeout; |
---|
2028 | 1813 | |
---|
2029 | 1814 | return 0; |
---|
2030 | 1815 | } |
---|
2031 | 1816 | |
---|
2032 | | -/* generic VNICC request */ |
---|
2033 | | -static int qeth_l2_vnicc_request(struct qeth_card *card, |
---|
2034 | | - struct _qeth_l2_vnicc_request_cbctl *cbctl) |
---|
| 1817 | +static struct qeth_cmd_buffer *qeth_l2_vnicc_build_cmd(struct qeth_card *card, |
---|
| 1818 | + u32 vnicc_cmd, |
---|
| 1819 | + unsigned int data_length) |
---|
2035 | 1820 | { |
---|
2036 | | - struct qeth_ipacmd_vnicc *req; |
---|
| 1821 | + struct qeth_ipacmd_vnicc_hdr *hdr; |
---|
2037 | 1822 | struct qeth_cmd_buffer *iob; |
---|
2038 | | - struct qeth_ipa_cmd *cmd; |
---|
2039 | | - int rc; |
---|
2040 | 1823 | |
---|
2041 | | - QETH_CARD_TEXT(card, 2, "vniccreq"); |
---|
2042 | | - |
---|
2043 | | - /* get new buffer for request */ |
---|
2044 | | - iob = qeth_get_ipacmd_buffer(card, IPA_CMD_VNICC, 0); |
---|
| 1824 | + iob = qeth_ipa_alloc_cmd(card, IPA_CMD_VNICC, QETH_PROT_NONE, |
---|
| 1825 | + data_length + |
---|
| 1826 | + offsetof(struct qeth_ipacmd_vnicc, data)); |
---|
2045 | 1827 | if (!iob) |
---|
2046 | | - return -ENOMEM; |
---|
| 1828 | + return NULL; |
---|
2047 | 1829 | |
---|
2048 | | - /* create header for request */ |
---|
2049 | | - cmd = __ipa_cmd(iob); |
---|
2050 | | - req = &cmd->data.vnicc; |
---|
2051 | | - |
---|
2052 | | - /* create sub command header for request */ |
---|
2053 | | - req->sub_hdr.data_length = sizeof(req->sub_hdr); |
---|
2054 | | - req->sub_hdr.sub_command = cbctl->sub_cmd; |
---|
2055 | | - |
---|
2056 | | - /* create sub command specific request fields */ |
---|
2057 | | - switch (cbctl->sub_cmd) { |
---|
2058 | | - case IPA_VNICC_QUERY_CHARS: |
---|
2059 | | - break; |
---|
2060 | | - case IPA_VNICC_QUERY_CMDS: |
---|
2061 | | - req->sub_hdr.data_length += sizeof(req->query_cmds); |
---|
2062 | | - req->query_cmds.vnic_char = cbctl->param.vnic_char; |
---|
2063 | | - break; |
---|
2064 | | - case IPA_VNICC_ENABLE: |
---|
2065 | | - case IPA_VNICC_DISABLE: |
---|
2066 | | - req->sub_hdr.data_length += sizeof(req->set_char); |
---|
2067 | | - req->set_char.vnic_char = cbctl->param.vnic_char; |
---|
2068 | | - break; |
---|
2069 | | - case IPA_VNICC_SET_TIMEOUT: |
---|
2070 | | - req->getset_timeout.timeout = cbctl->param.timeout; |
---|
2071 | | - /* fallthrough */ |
---|
2072 | | - case IPA_VNICC_GET_TIMEOUT: |
---|
2073 | | - req->sub_hdr.data_length += sizeof(req->getset_timeout); |
---|
2074 | | - req->getset_timeout.vnic_char = cbctl->param.vnic_char; |
---|
2075 | | - break; |
---|
2076 | | - default: |
---|
2077 | | - qeth_release_buffer(iob->channel, iob); |
---|
2078 | | - return -EOPNOTSUPP; |
---|
2079 | | - } |
---|
2080 | | - |
---|
2081 | | - /* send request */ |
---|
2082 | | - rc = qeth_send_ipa_cmd(card, iob, qeth_l2_vnicc_request_cb, |
---|
2083 | | - (void *) cbctl); |
---|
2084 | | - |
---|
2085 | | - return qeth_l2_vnicc_makerc(card, rc); |
---|
| 1830 | + hdr = &__ipa_cmd(iob)->data.vnicc.hdr; |
---|
| 1831 | + hdr->data_length = sizeof(*hdr) + data_length; |
---|
| 1832 | + hdr->sub_command = vnicc_cmd; |
---|
| 1833 | + return iob; |
---|
2086 | 1834 | } |
---|
2087 | 1835 | |
---|
2088 | 1836 | /* VNICC query VNIC characteristics request */ |
---|
2089 | 1837 | static int qeth_l2_vnicc_query_chars(struct qeth_card *card) |
---|
2090 | 1838 | { |
---|
2091 | | - struct _qeth_l2_vnicc_request_cbctl cbctl; |
---|
2092 | | - |
---|
2093 | | - /* prepare callback control */ |
---|
2094 | | - cbctl.sub_cmd = IPA_VNICC_QUERY_CHARS; |
---|
| 1839 | + struct qeth_cmd_buffer *iob; |
---|
2095 | 1840 | |
---|
2096 | 1841 | QETH_CARD_TEXT(card, 2, "vniccqch"); |
---|
2097 | | - return qeth_l2_vnicc_request(card, &cbctl); |
---|
| 1842 | + iob = qeth_l2_vnicc_build_cmd(card, IPA_VNICC_QUERY_CHARS, 0); |
---|
| 1843 | + if (!iob) |
---|
| 1844 | + return -ENOMEM; |
---|
| 1845 | + |
---|
| 1846 | + return qeth_send_ipa_cmd(card, iob, qeth_l2_vnicc_request_cb, NULL); |
---|
2098 | 1847 | } |
---|
2099 | 1848 | |
---|
2100 | 1849 | /* VNICC query sub commands request */ |
---|
2101 | 1850 | static int qeth_l2_vnicc_query_cmds(struct qeth_card *card, u32 vnic_char, |
---|
2102 | 1851 | u32 *sup_cmds) |
---|
2103 | 1852 | { |
---|
2104 | | - struct _qeth_l2_vnicc_request_cbctl cbctl; |
---|
2105 | | - |
---|
2106 | | - /* prepare callback control */ |
---|
2107 | | - cbctl.sub_cmd = IPA_VNICC_QUERY_CMDS; |
---|
2108 | | - cbctl.param.vnic_char = vnic_char; |
---|
2109 | | - cbctl.result.sup_cmds = sup_cmds; |
---|
| 1853 | + struct qeth_cmd_buffer *iob; |
---|
2110 | 1854 | |
---|
2111 | 1855 | QETH_CARD_TEXT(card, 2, "vniccqcm"); |
---|
2112 | | - return qeth_l2_vnicc_request(card, &cbctl); |
---|
| 1856 | + iob = qeth_l2_vnicc_build_cmd(card, IPA_VNICC_QUERY_CMDS, |
---|
| 1857 | + VNICC_DATA_SIZEOF(query_cmds)); |
---|
| 1858 | + if (!iob) |
---|
| 1859 | + return -ENOMEM; |
---|
| 1860 | + |
---|
| 1861 | + __ipa_cmd(iob)->data.vnicc.data.query_cmds.vnic_char = vnic_char; |
---|
| 1862 | + |
---|
| 1863 | + return qeth_send_ipa_cmd(card, iob, qeth_l2_vnicc_request_cb, sup_cmds); |
---|
2113 | 1864 | } |
---|
2114 | 1865 | |
---|
2115 | 1866 | /* VNICC enable/disable characteristic request */ |
---|
2116 | 1867 | static int qeth_l2_vnicc_set_char(struct qeth_card *card, u32 vnic_char, |
---|
2117 | 1868 | u32 cmd) |
---|
2118 | 1869 | { |
---|
2119 | | - struct _qeth_l2_vnicc_request_cbctl cbctl; |
---|
2120 | | - |
---|
2121 | | - /* prepare callback control */ |
---|
2122 | | - cbctl.sub_cmd = cmd; |
---|
2123 | | - cbctl.param.vnic_char = vnic_char; |
---|
| 1870 | + struct qeth_cmd_buffer *iob; |
---|
2124 | 1871 | |
---|
2125 | 1872 | QETH_CARD_TEXT(card, 2, "vniccedc"); |
---|
2126 | | - return qeth_l2_vnicc_request(card, &cbctl); |
---|
| 1873 | + iob = qeth_l2_vnicc_build_cmd(card, cmd, VNICC_DATA_SIZEOF(set_char)); |
---|
| 1874 | + if (!iob) |
---|
| 1875 | + return -ENOMEM; |
---|
| 1876 | + |
---|
| 1877 | + __ipa_cmd(iob)->data.vnicc.data.set_char.vnic_char = vnic_char; |
---|
| 1878 | + |
---|
| 1879 | + return qeth_send_ipa_cmd(card, iob, qeth_l2_vnicc_request_cb, NULL); |
---|
2127 | 1880 | } |
---|
2128 | 1881 | |
---|
2129 | 1882 | /* VNICC get/set timeout for characteristic request */ |
---|
2130 | 1883 | static int qeth_l2_vnicc_getset_timeout(struct qeth_card *card, u32 vnicc, |
---|
2131 | 1884 | u32 cmd, u32 *timeout) |
---|
2132 | 1885 | { |
---|
2133 | | - struct _qeth_l2_vnicc_request_cbctl cbctl; |
---|
2134 | | - |
---|
2135 | | - /* prepare callback control */ |
---|
2136 | | - cbctl.sub_cmd = cmd; |
---|
2137 | | - cbctl.param.vnic_char = vnicc; |
---|
2138 | | - if (cmd == IPA_VNICC_SET_TIMEOUT) |
---|
2139 | | - cbctl.param.timeout = *timeout; |
---|
2140 | | - if (cmd == IPA_VNICC_GET_TIMEOUT) |
---|
2141 | | - cbctl.result.timeout = timeout; |
---|
| 1886 | + struct qeth_vnicc_getset_timeout *getset_timeout; |
---|
| 1887 | + struct qeth_cmd_buffer *iob; |
---|
2142 | 1888 | |
---|
2143 | 1889 | QETH_CARD_TEXT(card, 2, "vniccgst"); |
---|
2144 | | - return qeth_l2_vnicc_request(card, &cbctl); |
---|
| 1890 | + iob = qeth_l2_vnicc_build_cmd(card, cmd, |
---|
| 1891 | + VNICC_DATA_SIZEOF(getset_timeout)); |
---|
| 1892 | + if (!iob) |
---|
| 1893 | + return -ENOMEM; |
---|
| 1894 | + |
---|
| 1895 | + getset_timeout = &__ipa_cmd(iob)->data.vnicc.data.getset_timeout; |
---|
| 1896 | + getset_timeout->vnic_char = vnicc; |
---|
| 1897 | + |
---|
| 1898 | + if (cmd == IPA_VNICC_SET_TIMEOUT) |
---|
| 1899 | + getset_timeout->timeout = *timeout; |
---|
| 1900 | + |
---|
| 1901 | + return qeth_send_ipa_cmd(card, iob, qeth_l2_vnicc_request_cb, timeout); |
---|
| 1902 | +} |
---|
| 1903 | + |
---|
| 1904 | +/* recover user timeout setting */ |
---|
| 1905 | +static bool qeth_l2_vnicc_recover_timeout(struct qeth_card *card, u32 vnicc, |
---|
| 1906 | + u32 *timeout) |
---|
| 1907 | +{ |
---|
| 1908 | + if (card->options.vnicc.sup_chars & vnicc && |
---|
| 1909 | + card->options.vnicc.getset_timeout_sup & vnicc && |
---|
| 1910 | + !qeth_l2_vnicc_getset_timeout(card, vnicc, IPA_VNICC_SET_TIMEOUT, |
---|
| 1911 | + timeout)) |
---|
| 1912 | + return false; |
---|
| 1913 | + *timeout = QETH_VNICC_DEFAULT_TIMEOUT; |
---|
| 1914 | + return true; |
---|
2145 | 1915 | } |
---|
2146 | 1916 | |
---|
2147 | 1917 | /* set current VNICC flag state; called from sysfs store function */ |
---|
.. | .. |
---|
2284 | 2054 | } |
---|
2285 | 2055 | |
---|
2286 | 2056 | /* check if VNICC is currently enabled */ |
---|
2287 | | -bool qeth_l2_vnicc_is_in_use(struct qeth_card *card) |
---|
| 2057 | +static bool _qeth_l2_vnicc_is_in_use(struct qeth_card *card) |
---|
2288 | 2058 | { |
---|
2289 | 2059 | if (!card->options.vnicc.sup_chars) |
---|
2290 | 2060 | return false; |
---|
.. | .. |
---|
2299 | 2069 | return true; |
---|
2300 | 2070 | } |
---|
2301 | 2071 | |
---|
2302 | | -/* recover user timeout setting */ |
---|
2303 | | -static bool qeth_l2_vnicc_recover_timeout(struct qeth_card *card, u32 vnicc, |
---|
2304 | | - u32 *timeout) |
---|
| 2072 | +/** |
---|
| 2073 | + * qeth_bridgeport_allowed - are any qeth_bridgeport functions allowed? |
---|
| 2074 | + * @card: qeth_card structure pointer |
---|
| 2075 | + * |
---|
| 2076 | + * qeth_bridgeport functionality is mutually exclusive with usage of the |
---|
| 2077 | + * VNIC Characteristics and dev2br address notifications |
---|
| 2078 | + */ |
---|
| 2079 | +bool qeth_bridgeport_allowed(struct qeth_card *card) |
---|
2305 | 2080 | { |
---|
2306 | | - if (card->options.vnicc.sup_chars & vnicc && |
---|
2307 | | - card->options.vnicc.getset_timeout_sup & vnicc && |
---|
2308 | | - !qeth_l2_vnicc_getset_timeout(card, vnicc, IPA_VNICC_SET_TIMEOUT, |
---|
2309 | | - timeout)) |
---|
2310 | | - return false; |
---|
2311 | | - *timeout = QETH_VNICC_DEFAULT_TIMEOUT; |
---|
2312 | | - return true; |
---|
| 2081 | + struct qeth_priv *priv = netdev_priv(card->dev); |
---|
| 2082 | + |
---|
| 2083 | + return (!_qeth_l2_vnicc_is_in_use(card) && |
---|
| 2084 | + !(priv->brport_features & BR_LEARNING_SYNC)); |
---|
2313 | 2085 | } |
---|
2314 | 2086 | |
---|
2315 | 2087 | /* recover user characteristic setting */ |
---|
.. | .. |
---|
2373 | 2145 | /* enforce assumed default values and recover settings, if changed */ |
---|
2374 | 2146 | error |= qeth_l2_vnicc_recover_timeout(card, QETH_VNICC_LEARNING, |
---|
2375 | 2147 | timeout); |
---|
2376 | | - chars_tmp = card->options.vnicc.wanted_chars ^ QETH_VNICC_DEFAULT; |
---|
| 2148 | + /* Change chars, if necessary */ |
---|
| 2149 | + chars_tmp = card->options.vnicc.wanted_chars ^ |
---|
| 2150 | + card->options.vnicc.cur_chars; |
---|
2377 | 2151 | chars_len = sizeof(card->options.vnicc.wanted_chars) * BITS_PER_BYTE; |
---|
2378 | 2152 | for_each_set_bit(i, &chars_tmp, chars_len) { |
---|
2379 | 2153 | vnicc = BIT(i); |
---|
.. | .. |
---|
2398 | 2172 | card->options.vnicc.wanted_chars = QETH_VNICC_DEFAULT; |
---|
2399 | 2173 | } |
---|
2400 | 2174 | |
---|
| 2175 | +static const struct device_type qeth_l2_devtype = { |
---|
| 2176 | + .name = "qeth_layer2", |
---|
| 2177 | + .groups = qeth_l2_attr_groups, |
---|
| 2178 | +}; |
---|
| 2179 | + |
---|
| 2180 | +static int qeth_l2_probe_device(struct ccwgroup_device *gdev) |
---|
| 2181 | +{ |
---|
| 2182 | + struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
---|
| 2183 | + int rc; |
---|
| 2184 | + |
---|
| 2185 | + if (IS_OSN(card)) |
---|
| 2186 | + dev_notice(&gdev->dev, "OSN support will be dropped in 2021\n"); |
---|
| 2187 | + |
---|
| 2188 | + qeth_l2_vnicc_set_defaults(card); |
---|
| 2189 | + mutex_init(&card->sbp_lock); |
---|
| 2190 | + |
---|
| 2191 | + if (gdev->dev.type == &qeth_generic_devtype) { |
---|
| 2192 | + rc = qeth_l2_create_device_attributes(&gdev->dev); |
---|
| 2193 | + if (rc) |
---|
| 2194 | + return rc; |
---|
| 2195 | + } |
---|
| 2196 | + |
---|
| 2197 | + INIT_WORK(&card->rx_mode_work, qeth_l2_rx_mode_work); |
---|
| 2198 | + return 0; |
---|
| 2199 | +} |
---|
| 2200 | + |
---|
| 2201 | +static void qeth_l2_remove_device(struct ccwgroup_device *gdev) |
---|
| 2202 | +{ |
---|
| 2203 | + struct qeth_card *card = dev_get_drvdata(&gdev->dev); |
---|
| 2204 | + |
---|
| 2205 | + if (gdev->dev.type == &qeth_generic_devtype) |
---|
| 2206 | + qeth_l2_remove_device_attributes(&gdev->dev); |
---|
| 2207 | + qeth_set_allowed_threads(card, 0, 1); |
---|
| 2208 | + wait_event(card->wait_q, qeth_threads_running(card, 0xffffffff) == 0); |
---|
| 2209 | + |
---|
| 2210 | + if (gdev->state == CCWGROUP_ONLINE) |
---|
| 2211 | + qeth_set_offline(card, card->discipline, false); |
---|
| 2212 | + |
---|
| 2213 | + cancel_work_sync(&card->close_dev_work); |
---|
| 2214 | + if (card->dev->reg_state == NETREG_REGISTERED) |
---|
| 2215 | + unregister_netdev(card->dev); |
---|
| 2216 | +} |
---|
| 2217 | + |
---|
| 2218 | +static int qeth_l2_set_online(struct qeth_card *card, bool carrier_ok) |
---|
| 2219 | +{ |
---|
| 2220 | + struct net_device *dev = card->dev; |
---|
| 2221 | + int rc = 0; |
---|
| 2222 | + |
---|
| 2223 | + qeth_l2_detect_dev2br_support(card); |
---|
| 2224 | + |
---|
| 2225 | + mutex_lock(&card->sbp_lock); |
---|
| 2226 | + qeth_bridgeport_query_support(card); |
---|
| 2227 | + if (card->options.sbp.supported_funcs) { |
---|
| 2228 | + qeth_l2_setup_bridgeport_attrs(card); |
---|
| 2229 | + dev_info(&card->gdev->dev, |
---|
| 2230 | + "The device represents a Bridge Capable Port\n"); |
---|
| 2231 | + } |
---|
| 2232 | + mutex_unlock(&card->sbp_lock); |
---|
| 2233 | + |
---|
| 2234 | + qeth_l2_register_dev_addr(card); |
---|
| 2235 | + |
---|
| 2236 | + /* for the rx_bcast characteristic, init VNICC after setmac */ |
---|
| 2237 | + qeth_l2_vnicc_init(card); |
---|
| 2238 | + |
---|
| 2239 | + qeth_l2_trace_features(card); |
---|
| 2240 | + |
---|
| 2241 | + /* softsetup */ |
---|
| 2242 | + QETH_CARD_TEXT(card, 2, "softsetp"); |
---|
| 2243 | + |
---|
| 2244 | + card->state = CARD_STATE_SOFTSETUP; |
---|
| 2245 | + |
---|
| 2246 | + qeth_set_allowed_threads(card, 0xffffffff, 0); |
---|
| 2247 | + |
---|
| 2248 | + if (dev->reg_state != NETREG_REGISTERED) { |
---|
| 2249 | + rc = qeth_l2_setup_netdev(card); |
---|
| 2250 | + if (rc) |
---|
| 2251 | + goto err_setup; |
---|
| 2252 | + |
---|
| 2253 | + if (carrier_ok) |
---|
| 2254 | + netif_carrier_on(dev); |
---|
| 2255 | + } else { |
---|
| 2256 | + rtnl_lock(); |
---|
| 2257 | + rc = qeth_set_real_num_tx_queues(card, |
---|
| 2258 | + qeth_tx_actual_queues(card)); |
---|
| 2259 | + if (rc) { |
---|
| 2260 | + rtnl_unlock(); |
---|
| 2261 | + goto err_set_queues; |
---|
| 2262 | + } |
---|
| 2263 | + |
---|
| 2264 | + if (carrier_ok) |
---|
| 2265 | + netif_carrier_on(dev); |
---|
| 2266 | + else |
---|
| 2267 | + netif_carrier_off(dev); |
---|
| 2268 | + |
---|
| 2269 | + netif_device_attach(dev); |
---|
| 2270 | + qeth_enable_hw_features(dev); |
---|
| 2271 | + qeth_l2_enable_brport_features(card); |
---|
| 2272 | + |
---|
| 2273 | + if (netif_running(dev)) { |
---|
| 2274 | + local_bh_disable(); |
---|
| 2275 | + napi_schedule(&card->napi); |
---|
| 2276 | + /* kick-start the NAPI softirq: */ |
---|
| 2277 | + local_bh_enable(); |
---|
| 2278 | + qeth_l2_set_rx_mode(dev); |
---|
| 2279 | + } |
---|
| 2280 | + rtnl_unlock(); |
---|
| 2281 | + } |
---|
| 2282 | + return 0; |
---|
| 2283 | + |
---|
| 2284 | +err_set_queues: |
---|
| 2285 | +err_setup: |
---|
| 2286 | + qeth_set_allowed_threads(card, 0, 1); |
---|
| 2287 | + card->state = CARD_STATE_DOWN; |
---|
| 2288 | + return rc; |
---|
| 2289 | +} |
---|
| 2290 | + |
---|
| 2291 | +static void qeth_l2_set_offline(struct qeth_card *card) |
---|
| 2292 | +{ |
---|
| 2293 | + struct qeth_priv *priv = netdev_priv(card->dev); |
---|
| 2294 | + |
---|
| 2295 | + qeth_set_allowed_threads(card, 0, 1); |
---|
| 2296 | + qeth_l2_drain_rx_mode_cache(card); |
---|
| 2297 | + |
---|
| 2298 | + if (card->state == CARD_STATE_SOFTSETUP) |
---|
| 2299 | + card->state = CARD_STATE_DOWN; |
---|
| 2300 | + |
---|
| 2301 | + qeth_l2_set_pnso_mode(card, QETH_PNSO_NONE); |
---|
| 2302 | + if (priv->brport_features & BR_LEARNING_SYNC) { |
---|
| 2303 | + rtnl_lock(); |
---|
| 2304 | + qeth_l2_dev2br_fdb_flush(card); |
---|
| 2305 | + rtnl_unlock(); |
---|
| 2306 | + } |
---|
| 2307 | +} |
---|
| 2308 | + |
---|
| 2309 | +/* Returns zero if the command is successfully "consumed" */ |
---|
| 2310 | +static int qeth_l2_control_event(struct qeth_card *card, |
---|
| 2311 | + struct qeth_ipa_cmd *cmd) |
---|
| 2312 | +{ |
---|
| 2313 | + switch (cmd->hdr.command) { |
---|
| 2314 | + case IPA_CMD_SETBRIDGEPORT_OSA: |
---|
| 2315 | + case IPA_CMD_SETBRIDGEPORT_IQD: |
---|
| 2316 | + if (cmd->data.sbp.hdr.command_code == |
---|
| 2317 | + IPA_SBP_BRIDGE_PORT_STATE_CHANGE) { |
---|
| 2318 | + qeth_bridge_state_change(card, cmd); |
---|
| 2319 | + return 0; |
---|
| 2320 | + } |
---|
| 2321 | + |
---|
| 2322 | + return 1; |
---|
| 2323 | + case IPA_CMD_ADDRESS_CHANGE_NOTIF: |
---|
| 2324 | + qeth_addr_change_event(card, cmd); |
---|
| 2325 | + return 0; |
---|
| 2326 | + default: |
---|
| 2327 | + return 1; |
---|
| 2328 | + } |
---|
| 2329 | +} |
---|
| 2330 | + |
---|
| 2331 | +const struct qeth_discipline qeth_l2_discipline = { |
---|
| 2332 | + .devtype = &qeth_l2_devtype, |
---|
| 2333 | + .setup = qeth_l2_probe_device, |
---|
| 2334 | + .remove = qeth_l2_remove_device, |
---|
| 2335 | + .set_online = qeth_l2_set_online, |
---|
| 2336 | + .set_offline = qeth_l2_set_offline, |
---|
| 2337 | + .do_ioctl = NULL, |
---|
| 2338 | + .control_event_handler = qeth_l2_control_event, |
---|
| 2339 | +}; |
---|
| 2340 | +EXPORT_SYMBOL_GPL(qeth_l2_discipline); |
---|
| 2341 | + |
---|
| 2342 | +static int __init qeth_l2_init(void) |
---|
| 2343 | +{ |
---|
| 2344 | + pr_info("register layer 2 discipline\n"); |
---|
| 2345 | + return 0; |
---|
| 2346 | +} |
---|
| 2347 | + |
---|
| 2348 | +static void __exit qeth_l2_exit(void) |
---|
| 2349 | +{ |
---|
| 2350 | + pr_info("unregister layer 2 discipline\n"); |
---|
| 2351 | +} |
---|
| 2352 | + |
---|
2401 | 2353 | module_init(qeth_l2_init); |
---|
2402 | 2354 | module_exit(qeth_l2_exit); |
---|
2403 | 2355 | MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>"); |
---|