2 * Copyright IBM Corp. 2007, 2009
3 * Author(s): Utz Bacher <utz.bacher@de.ibm.com>,
4 * Frank Pavlic <fpavlic@de.ibm.com>,
5 * Thomas Spatzier <tspat@de.ibm.com>,
6 * Frank Blaschka <frank.blaschka@de.ibm.com>
9 #define KMSG_COMPONENT "qeth"
10 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
12 #include <linux/module.h>
13 #include <linux/moduleparam.h>
14 #include <linux/string.h>
15 #include <linux/errno.h>
16 #include <linux/kernel.h>
17 #include <linux/slab.h>
18 #include <linux/etherdevice.h>
20 #include <linux/list.h>
21 #include <linux/hash.h>
22 #include <linux/hashtable.h>
23 #include <linux/string.h>
24 #include <asm/setup.h>
25 #include "qeth_core.h"
28 static int qeth_l2_set_offline(struct ccwgroup_device
*);
29 static int qeth_l2_stop(struct net_device
*);
30 static void qeth_l2_set_rx_mode(struct net_device
*);
31 static void qeth_bridgeport_query_support(struct qeth_card
*card
);
32 static void qeth_bridge_state_change(struct qeth_card
*card
,
33 struct qeth_ipa_cmd
*cmd
);
34 static void qeth_bridge_host_event(struct qeth_card
*card
,
35 struct qeth_ipa_cmd
*cmd
);
37 static int qeth_l2_verify_dev(struct net_device
*dev
)
39 struct qeth_card
*card
;
43 read_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
44 list_for_each_entry(card
, &qeth_core_card_list
.list
, list
) {
45 if (card
->dev
== dev
) {
50 read_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
55 static struct net_device
*qeth_l2_netdev_by_devno(unsigned char *read_dev_no
)
57 struct qeth_card
*card
;
58 struct net_device
*ndev
;
61 struct ccw_dev_id read_devid
;
64 memcpy(&temp_dev_no
, read_dev_no
, 2);
65 read_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
66 list_for_each_entry(card
, &qeth_core_card_list
.list
, list
) {
67 ccw_device_get_id(CARD_RDEV(card
), &read_devid
);
68 if (read_devid
.devno
== temp_dev_no
) {
73 read_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
77 static int qeth_setdel_makerc(struct qeth_card
*card
, int retcode
)
82 QETH_CARD_TEXT_(card
, 2, "err%04x", retcode
);
87 case IPA_RC_L2_UNSUPPORTED_CMD
:
90 case IPA_RC_L2_ADDR_TABLE_FULL
:
93 case IPA_RC_L2_DUP_MAC
:
94 case IPA_RC_L2_DUP_LAYER3_MAC
:
97 case IPA_RC_L2_MAC_NOT_AUTH_BY_HYP
:
98 case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP
:
101 case IPA_RC_L2_MAC_NOT_FOUND
:
114 static int qeth_l2_send_setdelmac(struct qeth_card
*card
, __u8
*mac
,
115 enum qeth_ipa_cmds ipacmd
)
117 struct qeth_ipa_cmd
*cmd
;
118 struct qeth_cmd_buffer
*iob
;
120 QETH_CARD_TEXT(card
, 2, "L2sdmac");
121 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
124 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
125 cmd
->data
.setdelmac
.mac_length
= OSA_ADDR_LEN
;
126 memcpy(&cmd
->data
.setdelmac
.mac
, mac
, OSA_ADDR_LEN
);
127 return qeth_setdel_makerc(card
, qeth_send_ipa_cmd(card
, iob
,
131 static int qeth_l2_send_setmac(struct qeth_card
*card
, __u8
*mac
)
135 QETH_CARD_TEXT(card
, 2, "L2Setmac");
136 rc
= qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_SETVMAC
);
138 card
->info
.mac_bits
|= QETH_LAYER2_MAC_REGISTERED
;
139 memcpy(card
->dev
->dev_addr
, mac
, OSA_ADDR_LEN
);
140 dev_info(&card
->gdev
->dev
,
141 "MAC address %pM successfully registered on device %s\n",
142 card
->dev
->dev_addr
, card
->dev
->name
);
144 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
147 dev_warn(&card
->gdev
->dev
,
148 "MAC address %pM already exists\n", mac
);
151 dev_warn(&card
->gdev
->dev
,
152 "MAC address %pM is not authorized\n", mac
);
159 static int qeth_l2_send_delmac(struct qeth_card
*card
, __u8
*mac
)
163 QETH_CARD_TEXT(card
, 2, "L2Delmac");
164 if (!(card
->info
.mac_bits
& QETH_LAYER2_MAC_REGISTERED
))
166 rc
= qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_DELVMAC
);
168 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
172 static int qeth_l2_send_setgroupmac(struct qeth_card
*card
, __u8
*mac
)
176 QETH_CARD_TEXT(card
, 2, "L2Sgmac");
177 rc
= qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_SETGMAC
);
179 QETH_DBF_MESSAGE(2, "Group MAC %pM already existing on %s\n",
180 mac
, QETH_CARD_IFNAME(card
));
182 QETH_DBF_MESSAGE(2, "Could not set group MAC %pM on %s: %d\n",
183 mac
, QETH_CARD_IFNAME(card
), rc
);
187 static int qeth_l2_send_delgroupmac(struct qeth_card
*card
, __u8
*mac
)
191 QETH_CARD_TEXT(card
, 2, "L2Dgmac");
192 rc
= qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_DELGMAC
);
195 "Could not delete group MAC %pM on %s: %d\n",
196 mac
, QETH_CARD_IFNAME(card
), rc
);
200 static int qeth_l2_write_mac(struct qeth_card
*card
, struct qeth_mac
*mac
)
203 return qeth_l2_send_setdelmac(card
, mac
->mac_addr
,
206 return qeth_l2_send_setgroupmac(card
, mac
->mac_addr
);
210 static int qeth_l2_remove_mac(struct qeth_card
*card
, struct qeth_mac
*mac
)
213 return qeth_l2_send_setdelmac(card
, mac
->mac_addr
,
216 return qeth_l2_send_delgroupmac(card
, mac
->mac_addr
);
220 static void qeth_l2_del_all_macs(struct qeth_card
*card
)
222 struct qeth_mac
*mac
;
223 struct hlist_node
*tmp
;
226 spin_lock_bh(&card
->mclock
);
227 hash_for_each_safe(card
->mac_htable
, i
, tmp
, mac
, hnode
) {
228 hash_del(&mac
->hnode
);
231 spin_unlock_bh(&card
->mclock
);
234 static int qeth_l2_get_cast_type(struct qeth_card
*card
, struct sk_buff
*skb
)
236 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
238 if (is_broadcast_ether_addr(skb
->data
))
239 return RTN_BROADCAST
;
240 if (is_multicast_ether_addr(skb
->data
))
241 return RTN_MULTICAST
;
245 static void qeth_l2_hdr_csum(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
248 struct iphdr
*iph
= ip_hdr(skb
);
250 /* tcph->check contains already the pseudo hdr checksum
251 * so just set the header flags
253 if (iph
->protocol
== IPPROTO_UDP
)
254 hdr
->hdr
.l2
.flags
[1] |= QETH_HDR_EXT_UDP
;
255 hdr
->hdr
.l2
.flags
[1] |= QETH_HDR_EXT_CSUM_TRANSP_REQ
|
256 QETH_HDR_EXT_CSUM_HDR_REQ
;
258 if (card
->options
.performance_stats
)
259 card
->perf_stats
.tx_csum
++;
262 static void qeth_l2_fill_header(struct qeth_hdr
*hdr
, struct sk_buff
*skb
,
263 int cast_type
, unsigned int data_len
)
265 struct vlan_ethhdr
*veth
= (struct vlan_ethhdr
*)skb_mac_header(skb
);
267 memset(hdr
, 0, sizeof(struct qeth_hdr
));
268 hdr
->hdr
.l2
.id
= QETH_HEADER_TYPE_LAYER2
;
269 hdr
->hdr
.l2
.pkt_length
= data_len
;
271 /* set byte byte 3 to casting flags */
272 if (cast_type
== RTN_MULTICAST
)
273 hdr
->hdr
.l2
.flags
[2] |= QETH_LAYER2_FLAG_MULTICAST
;
274 else if (cast_type
== RTN_BROADCAST
)
275 hdr
->hdr
.l2
.flags
[2] |= QETH_LAYER2_FLAG_BROADCAST
;
277 hdr
->hdr
.l2
.flags
[2] |= QETH_LAYER2_FLAG_UNICAST
;
279 /* VSWITCH relies on the VLAN
280 * information to be present in
282 if (veth
->h_vlan_proto
== __constant_htons(ETH_P_8021Q
)) {
283 hdr
->hdr
.l2
.flags
[2] |= QETH_LAYER2_FLAG_VLAN
;
284 hdr
->hdr
.l2
.vlan_id
= ntohs(veth
->h_vlan_TCI
);
288 static int qeth_l2_send_setdelvlan_cb(struct qeth_card
*card
,
289 struct qeth_reply
*reply
, unsigned long data
)
291 struct qeth_ipa_cmd
*cmd
;
293 QETH_CARD_TEXT(card
, 2, "L2sdvcb");
294 cmd
= (struct qeth_ipa_cmd
*) data
;
295 if (cmd
->hdr
.return_code
) {
296 QETH_DBF_MESSAGE(2, "Error in processing VLAN %i on %s: 0x%x. "
297 "Continuing\n", cmd
->data
.setdelvlan
.vlan_id
,
298 QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
299 QETH_CARD_TEXT_(card
, 2, "L2VL%4x", cmd
->hdr
.command
);
300 QETH_CARD_TEXT_(card
, 2, "err%d", cmd
->hdr
.return_code
);
305 static int qeth_l2_send_setdelvlan(struct qeth_card
*card
, __u16 i
,
306 enum qeth_ipa_cmds ipacmd
)
308 struct qeth_ipa_cmd
*cmd
;
309 struct qeth_cmd_buffer
*iob
;
311 QETH_CARD_TEXT_(card
, 4, "L2sdv%x", ipacmd
);
312 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
315 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
316 cmd
->data
.setdelvlan
.vlan_id
= i
;
317 return qeth_send_ipa_cmd(card
, iob
,
318 qeth_l2_send_setdelvlan_cb
, NULL
);
321 static void qeth_l2_process_vlans(struct qeth_card
*card
)
323 struct qeth_vlan_vid
*id
;
324 QETH_CARD_TEXT(card
, 3, "L2prcvln");
325 spin_lock_bh(&card
->vlanlock
);
326 list_for_each_entry(id
, &card
->vid_list
, list
) {
327 qeth_l2_send_setdelvlan(card
, id
->vid
, IPA_CMD_SETVLAN
);
329 spin_unlock_bh(&card
->vlanlock
);
332 static int qeth_l2_vlan_rx_add_vid(struct net_device
*dev
,
333 __be16 proto
, u16 vid
)
335 struct qeth_card
*card
= dev
->ml_priv
;
336 struct qeth_vlan_vid
*id
;
339 QETH_CARD_TEXT_(card
, 4, "aid:%d", vid
);
342 if (card
->info
.type
== QETH_CARD_TYPE_OSM
) {
343 QETH_CARD_TEXT(card
, 3, "aidOSM");
346 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
347 QETH_CARD_TEXT(card
, 3, "aidREC");
350 id
= kmalloc(sizeof(struct qeth_vlan_vid
), GFP_ATOMIC
);
353 rc
= qeth_l2_send_setdelvlan(card
, vid
, IPA_CMD_SETVLAN
);
358 spin_lock_bh(&card
->vlanlock
);
359 list_add_tail(&id
->list
, &card
->vid_list
);
360 spin_unlock_bh(&card
->vlanlock
);
367 static int qeth_l2_vlan_rx_kill_vid(struct net_device
*dev
,
368 __be16 proto
, u16 vid
)
370 struct qeth_vlan_vid
*id
, *tmpid
= NULL
;
371 struct qeth_card
*card
= dev
->ml_priv
;
374 QETH_CARD_TEXT_(card
, 4, "kid:%d", vid
);
375 if (card
->info
.type
== QETH_CARD_TYPE_OSM
) {
376 QETH_CARD_TEXT(card
, 3, "kidOSM");
379 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
380 QETH_CARD_TEXT(card
, 3, "kidREC");
383 spin_lock_bh(&card
->vlanlock
);
384 list_for_each_entry(id
, &card
->vid_list
, list
) {
385 if (id
->vid
== vid
) {
391 spin_unlock_bh(&card
->vlanlock
);
393 rc
= qeth_l2_send_setdelvlan(card
, vid
, IPA_CMD_DELVLAN
);
396 qeth_l2_set_rx_mode(card
->dev
);
400 static void qeth_l2_stop_card(struct qeth_card
*card
, int recovery_mode
)
402 QETH_DBF_TEXT(SETUP
, 2, "stopcard");
403 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
405 qeth_set_allowed_threads(card
, 0, 1);
406 if (card
->read
.state
== CH_STATE_UP
&&
407 card
->write
.state
== CH_STATE_UP
&&
408 (card
->state
== CARD_STATE_UP
)) {
410 card
->info
.type
!= QETH_CARD_TYPE_OSN
) {
411 qeth_l2_stop(card
->dev
);
414 dev_close(card
->dev
);
417 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
418 card
->state
= CARD_STATE_SOFTSETUP
;
420 if (card
->state
== CARD_STATE_SOFTSETUP
) {
421 qeth_l2_del_all_macs(card
);
422 qeth_clear_ipacmd_list(card
);
423 card
->state
= CARD_STATE_HARDSETUP
;
425 if (card
->state
== CARD_STATE_HARDSETUP
) {
426 qeth_qdio_clear_card(card
, 0);
427 qeth_clear_qdio_buffers(card
);
428 qeth_clear_working_pool_list(card
);
429 card
->state
= CARD_STATE_DOWN
;
431 if (card
->state
== CARD_STATE_DOWN
) {
432 qeth_clear_cmd_buffers(&card
->read
);
433 qeth_clear_cmd_buffers(&card
->write
);
437 static int qeth_l2_process_inbound_buffer(struct qeth_card
*card
,
438 int budget
, int *done
)
442 struct qeth_hdr
*hdr
;
446 WARN_ON_ONCE(!budget
);
448 skb
= qeth_core_get_next_skb(card
,
449 &card
->qdio
.in_q
->bufs
[card
->rx
.b_index
],
450 &card
->rx
.b_element
, &card
->rx
.e_offset
, &hdr
);
455 skb
->dev
= card
->dev
;
456 switch (hdr
->hdr
.l2
.id
) {
457 case QETH_HEADER_TYPE_LAYER2
:
458 skb
->pkt_type
= PACKET_HOST
;
459 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
460 if ((card
->dev
->features
& NETIF_F_RXCSUM
)
461 && ((hdr
->hdr
.l2
.flags
[1] &
462 (QETH_HDR_EXT_CSUM_HDR_REQ
|
463 QETH_HDR_EXT_CSUM_TRANSP_REQ
)) ==
464 (QETH_HDR_EXT_CSUM_HDR_REQ
|
465 QETH_HDR_EXT_CSUM_TRANSP_REQ
)))
466 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
468 skb
->ip_summed
= CHECKSUM_NONE
;
469 if (skb
->protocol
== htons(ETH_P_802_2
))
470 *((__u32
*)skb
->cb
) = ++card
->seqno
.pkt_seqno
;
472 napi_gro_receive(&card
->napi
, skb
);
474 case QETH_HEADER_TYPE_OSN
:
475 if (card
->info
.type
== QETH_CARD_TYPE_OSN
) {
476 skb_push(skb
, sizeof(struct qeth_hdr
));
477 skb_copy_to_linear_data(skb
, hdr
,
478 sizeof(struct qeth_hdr
));
480 card
->osn_info
.data_cb(skb
);
485 dev_kfree_skb_any(skb
);
486 QETH_CARD_TEXT(card
, 3, "inbunkno");
487 QETH_DBF_HEX(CTRL
, 3, hdr
, QETH_DBF_CTRL_LEN
);
492 card
->stats
.rx_packets
++;
493 card
->stats
.rx_bytes
+= len
;
498 static int qeth_l2_request_initial_mac(struct qeth_card
*card
)
501 char vendor_pre
[] = {0x02, 0x00, 0x00};
503 QETH_DBF_TEXT(SETUP
, 2, "l2reqmac");
504 QETH_DBF_TEXT_(SETUP
, 2, "doL2%s", CARD_BUS_ID(card
));
507 rc
= qeth_vm_request_mac(card
);
510 QETH_DBF_MESSAGE(2, "z/VM MAC Service failed on device %s: x%x\n",
511 CARD_BUS_ID(card
), rc
);
512 QETH_DBF_TEXT_(SETUP
, 2, "err%04x", rc
);
513 /* fall back to alternative mechanism: */
516 if (card
->info
.type
== QETH_CARD_TYPE_IQD
||
517 card
->info
.type
== QETH_CARD_TYPE_OSM
||
518 card
->info
.type
== QETH_CARD_TYPE_OSX
||
519 card
->info
.guestlan
) {
520 rc
= qeth_setadpparms_change_macaddr(card
);
522 QETH_DBF_MESSAGE(2, "couldn't get MAC address on "
523 "device %s: x%x\n", CARD_BUS_ID(card
), rc
);
524 QETH_DBF_TEXT_(SETUP
, 2, "1err%04x", rc
);
528 eth_random_addr(card
->dev
->dev_addr
);
529 memcpy(card
->dev
->dev_addr
, vendor_pre
, 3);
532 QETH_DBF_HEX(SETUP
, 2, card
->dev
->dev_addr
, card
->dev
->addr_len
);
536 static int qeth_l2_set_mac_address(struct net_device
*dev
, void *p
)
538 struct sockaddr
*addr
= p
;
539 struct qeth_card
*card
= dev
->ml_priv
;
542 QETH_CARD_TEXT(card
, 3, "setmac");
544 if (qeth_l2_verify_dev(dev
) != QETH_REAL_CARD
) {
545 QETH_CARD_TEXT(card
, 3, "setmcINV");
549 if (card
->info
.type
== QETH_CARD_TYPE_OSN
||
550 card
->info
.type
== QETH_CARD_TYPE_OSM
||
551 card
->info
.type
== QETH_CARD_TYPE_OSX
) {
552 QETH_CARD_TEXT(card
, 3, "setmcTYP");
555 QETH_CARD_HEX(card
, 3, addr
->sa_data
, OSA_ADDR_LEN
);
556 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
557 QETH_CARD_TEXT(card
, 3, "setmcREC");
560 rc
= qeth_l2_send_delmac(card
, &card
->dev
->dev_addr
[0]);
561 if (!rc
|| (rc
== -ENOENT
))
562 rc
= qeth_l2_send_setmac(card
, addr
->sa_data
);
563 return rc
? -EINVAL
: 0;
566 static void qeth_promisc_to_bridge(struct qeth_card
*card
)
568 struct net_device
*dev
= card
->dev
;
569 enum qeth_ipa_promisc_modes promisc_mode
;
573 QETH_CARD_TEXT(card
, 3, "pmisc2br");
575 if (!card
->options
.sbp
.reflect_promisc
)
577 promisc_mode
= (dev
->flags
& IFF_PROMISC
) ? SET_PROMISC_MODE_ON
578 : SET_PROMISC_MODE_OFF
;
579 if (promisc_mode
== card
->info
.promisc_mode
)
582 if (promisc_mode
== SET_PROMISC_MODE_ON
) {
583 if (card
->options
.sbp
.reflect_promisc_primary
)
584 role
= QETH_SBP_ROLE_PRIMARY
;
586 role
= QETH_SBP_ROLE_SECONDARY
;
588 role
= QETH_SBP_ROLE_NONE
;
590 rc
= qeth_bridgeport_setrole(card
, role
);
591 QETH_DBF_TEXT_(SETUP
, 2, "bpm%c%04x",
592 (promisc_mode
== SET_PROMISC_MODE_ON
) ? '+' : '-', rc
);
594 card
->options
.sbp
.role
= role
;
595 card
->info
.promisc_mode
= promisc_mode
;
599 /* New MAC address is added to the hash table and marked to be written on card
600 * only if there is not in the hash table storage already
603 static void qeth_l2_add_mac(struct qeth_card
*card
, struct netdev_hw_addr
*ha
,
606 u32 mac_hash
= get_unaligned((u32
*)(&ha
->addr
[2]));
607 struct qeth_mac
*mac
;
609 hash_for_each_possible(card
->mac_htable
, mac
, hnode
, mac_hash
) {
610 if (is_uc
== mac
->is_uc
&&
611 !memcmp(ha
->addr
, mac
->mac_addr
, OSA_ADDR_LEN
)) {
612 mac
->disp_flag
= QETH_DISP_ADDR_DO_NOTHING
;
617 mac
= kzalloc(sizeof(struct qeth_mac
), GFP_ATOMIC
);
622 memcpy(mac
->mac_addr
, ha
->addr
, OSA_ADDR_LEN
);
624 mac
->disp_flag
= QETH_DISP_ADDR_ADD
;
626 hash_add(card
->mac_htable
, &mac
->hnode
, mac_hash
);
629 static void qeth_l2_set_rx_mode(struct net_device
*dev
)
631 struct qeth_card
*card
= dev
->ml_priv
;
632 struct netdev_hw_addr
*ha
;
633 struct qeth_mac
*mac
;
634 struct hlist_node
*tmp
;
638 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
641 QETH_CARD_TEXT(card
, 3, "setmulti");
642 if (qeth_threads_running(card
, QETH_RECOVER_THREAD
) &&
643 (card
->state
!= CARD_STATE_UP
))
646 spin_lock_bh(&card
->mclock
);
648 netdev_for_each_mc_addr(ha
, dev
)
649 qeth_l2_add_mac(card
, ha
, 0);
651 netdev_for_each_uc_addr(ha
, dev
)
652 qeth_l2_add_mac(card
, ha
, 1);
654 hash_for_each_safe(card
->mac_htable
, i
, tmp
, mac
, hnode
) {
655 if (mac
->disp_flag
== QETH_DISP_ADDR_DELETE
) {
656 qeth_l2_remove_mac(card
, mac
);
657 hash_del(&mac
->hnode
);
660 } else if (mac
->disp_flag
== QETH_DISP_ADDR_ADD
) {
661 rc
= qeth_l2_write_mac(card
, mac
);
663 hash_del(&mac
->hnode
);
666 mac
->disp_flag
= QETH_DISP_ADDR_DELETE
;
668 mac
->disp_flag
= QETH_DISP_ADDR_DELETE
;
671 spin_unlock_bh(&card
->mclock
);
673 if (qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
674 qeth_setadp_promisc_mode(card
);
676 qeth_promisc_to_bridge(card
);
679 static int qeth_l2_xmit_iqd(struct qeth_card
*card
, struct sk_buff
*skb
,
680 struct qeth_qdio_out_q
*queue
, int cast_type
)
682 unsigned int data_offset
= ETH_HLEN
;
683 struct qeth_hdr
*hdr
;
686 hdr
= kmem_cache_alloc(qeth_core_header_cache
, GFP_ATOMIC
);
689 qeth_l2_fill_header(hdr
, skb
, cast_type
, skb
->len
);
690 skb_copy_from_linear_data(skb
, ((char *)hdr
) + sizeof(*hdr
),
693 if (!qeth_get_elements_no(card
, skb
, 1, data_offset
)) {
697 rc
= qeth_do_send_packet_fast(card
, queue
, skb
, hdr
, data_offset
,
698 sizeof(*hdr
) + data_offset
);
701 kmem_cache_free(qeth_core_header_cache
, hdr
);
705 static int qeth_l2_xmit_osa(struct qeth_card
*card
, struct sk_buff
*skb
,
706 struct qeth_qdio_out_q
*queue
, int cast_type
)
708 int push_len
= sizeof(struct qeth_hdr
);
709 unsigned int elements
, nr_frags
;
710 unsigned int hdr_elements
= 0;
711 struct qeth_hdr
*hdr
= NULL
;
712 unsigned int hd_len
= 0;
715 /* fix hardware limitation: as long as we do not have sbal
716 * chaining we can not send long frag lists
718 if (!qeth_get_elements_no(card
, skb
, 0, 0)) {
719 rc
= skb_linearize(skb
);
721 if (card
->options
.performance_stats
) {
723 card
->perf_stats
.tx_linfail
++;
725 card
->perf_stats
.tx_lin
++;
730 nr_frags
= skb_shinfo(skb
)->nr_frags
;
732 rc
= skb_cow_head(skb
, push_len
);
735 push_len
= qeth_push_hdr(skb
, &hdr
, push_len
);
739 /* hdr was allocated from cache */
740 hd_len
= sizeof(*hdr
);
743 qeth_l2_fill_header(hdr
, skb
, cast_type
, skb
->len
- push_len
);
744 if (skb
->ip_summed
== CHECKSUM_PARTIAL
)
745 qeth_l2_hdr_csum(card
, hdr
, skb
);
747 elements
= qeth_get_elements_no(card
, skb
, hdr_elements
, 0);
752 elements
+= hdr_elements
;
754 /* TODO: remove the skb_orphan() once TX completion is fast enough */
756 rc
= qeth_do_send_packet(card
, queue
, skb
, hdr
, 0, hd_len
, elements
);
759 if (card
->options
.performance_stats
&& nr_frags
) {
760 card
->perf_stats
.sg_skbs_sent
++;
761 /* nr_frags + skb->data */
762 card
->perf_stats
.sg_frags_sent
+= nr_frags
+ 1;
766 kmem_cache_free(qeth_core_header_cache
, hdr
);
768 /* roll back to ETH header */
769 skb_pull(skb
, push_len
);
774 static int qeth_l2_xmit_osn(struct qeth_card
*card
, struct sk_buff
*skb
,
775 struct qeth_qdio_out_q
*queue
)
777 unsigned int elements
;
778 struct qeth_hdr
*hdr
;
780 if (skb
->protocol
== htons(ETH_P_IPV6
))
781 return -EPROTONOSUPPORT
;
783 hdr
= (struct qeth_hdr
*)skb
->data
;
784 elements
= qeth_get_elements_no(card
, skb
, 0, 0);
787 if (qeth_hdr_chk_and_bounce(skb
, &hdr
, sizeof(*hdr
)))
789 return qeth_do_send_packet(card
, queue
, skb
, hdr
, 0, 0, elements
);
792 static netdev_tx_t
qeth_l2_hard_start_xmit(struct sk_buff
*skb
,
793 struct net_device
*dev
)
795 struct qeth_card
*card
= dev
->ml_priv
;
796 int cast_type
= qeth_l2_get_cast_type(card
, skb
);
797 struct qeth_qdio_out_q
*queue
;
798 int tx_bytes
= skb
->len
;
801 if (card
->qdio
.do_prio_queueing
|| (cast_type
&&
802 card
->info
.is_multicast_different
))
803 queue
= card
->qdio
.out_qs
[qeth_get_priority_queue(card
, skb
,
804 qeth_get_ip_version(skb
), cast_type
)];
806 queue
= card
->qdio
.out_qs
[card
->qdio
.default_out_queue
];
808 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
809 card
->stats
.tx_carrier_errors
++;
813 if (card
->options
.performance_stats
) {
814 card
->perf_stats
.outbound_cnt
++;
815 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
817 netif_stop_queue(dev
);
819 switch (card
->info
.type
) {
820 case QETH_CARD_TYPE_OSN
:
821 rc
= qeth_l2_xmit_osn(card
, skb
, queue
);
823 case QETH_CARD_TYPE_IQD
:
824 rc
= qeth_l2_xmit_iqd(card
, skb
, queue
, cast_type
);
827 rc
= qeth_l2_xmit_osa(card
, skb
, queue
, cast_type
);
831 card
->stats
.tx_packets
++;
832 card
->stats
.tx_bytes
+= tx_bytes
;
833 if (card
->options
.performance_stats
)
834 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
835 card
->perf_stats
.outbound_start_time
;
836 netif_wake_queue(dev
);
838 } else if (rc
== -EBUSY
) {
839 return NETDEV_TX_BUSY
;
840 } /* else fall through */
843 card
->stats
.tx_dropped
++;
844 card
->stats
.tx_errors
++;
845 dev_kfree_skb_any(skb
);
846 netif_wake_queue(dev
);
850 static int __qeth_l2_open(struct net_device
*dev
)
852 struct qeth_card
*card
= dev
->ml_priv
;
855 QETH_CARD_TEXT(card
, 4, "qethopen");
856 if (card
->state
== CARD_STATE_UP
)
858 if (card
->state
!= CARD_STATE_SOFTSETUP
)
861 if ((card
->info
.type
!= QETH_CARD_TYPE_OSN
) &&
862 (!(card
->info
.mac_bits
& QETH_LAYER2_MAC_REGISTERED
))) {
863 QETH_CARD_TEXT(card
, 4, "nomacadr");
866 card
->data
.state
= CH_STATE_UP
;
867 card
->state
= CARD_STATE_UP
;
868 netif_start_queue(dev
);
870 if (qdio_stop_irq(card
->data
.ccwdev
, 0) >= 0) {
871 napi_enable(&card
->napi
);
872 napi_schedule(&card
->napi
);
878 static int qeth_l2_open(struct net_device
*dev
)
880 struct qeth_card
*card
= dev
->ml_priv
;
882 QETH_CARD_TEXT(card
, 5, "qethope_");
883 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
884 QETH_CARD_TEXT(card
, 3, "openREC");
887 return __qeth_l2_open(dev
);
890 static int qeth_l2_stop(struct net_device
*dev
)
892 struct qeth_card
*card
= dev
->ml_priv
;
894 QETH_CARD_TEXT(card
, 4, "qethstop");
895 netif_tx_disable(dev
);
896 if (card
->state
== CARD_STATE_UP
) {
897 card
->state
= CARD_STATE_SOFTSETUP
;
898 napi_disable(&card
->napi
);
903 static const struct device_type qeth_l2_devtype
= {
904 .name
= "qeth_layer2",
905 .groups
= qeth_l2_attr_groups
,
908 static int qeth_l2_probe_device(struct ccwgroup_device
*gdev
)
910 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
913 if (gdev
->dev
.type
== &qeth_generic_devtype
) {
914 rc
= qeth_l2_create_device_attributes(&gdev
->dev
);
918 INIT_LIST_HEAD(&card
->vid_list
);
919 hash_init(card
->mac_htable
);
920 card
->options
.layer2
= 1;
921 card
->info
.hwtrap
= 0;
925 static void qeth_l2_remove_device(struct ccwgroup_device
*cgdev
)
927 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
929 if (cgdev
->dev
.type
== &qeth_generic_devtype
)
930 qeth_l2_remove_device_attributes(&cgdev
->dev
);
931 qeth_set_allowed_threads(card
, 0, 1);
932 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
934 if (cgdev
->state
== CCWGROUP_ONLINE
)
935 qeth_l2_set_offline(cgdev
);
938 netif_napi_del(&card
->napi
);
939 unregister_netdev(card
->dev
);
945 static const struct ethtool_ops qeth_l2_ethtool_ops
= {
946 .get_link
= ethtool_op_get_link
,
947 .get_strings
= qeth_core_get_strings
,
948 .get_ethtool_stats
= qeth_core_get_ethtool_stats
,
949 .get_sset_count
= qeth_core_get_sset_count
,
950 .get_drvinfo
= qeth_core_get_drvinfo
,
951 .get_link_ksettings
= qeth_core_ethtool_get_link_ksettings
,
954 static const struct ethtool_ops qeth_l2_osn_ops
= {
955 .get_strings
= qeth_core_get_strings
,
956 .get_ethtool_stats
= qeth_core_get_ethtool_stats
,
957 .get_sset_count
= qeth_core_get_sset_count
,
958 .get_drvinfo
= qeth_core_get_drvinfo
,
961 static const struct net_device_ops qeth_l2_netdev_ops
= {
962 .ndo_open
= qeth_l2_open
,
963 .ndo_stop
= qeth_l2_stop
,
964 .ndo_get_stats
= qeth_get_stats
,
965 .ndo_start_xmit
= qeth_l2_hard_start_xmit
,
966 .ndo_validate_addr
= eth_validate_addr
,
967 .ndo_set_rx_mode
= qeth_l2_set_rx_mode
,
968 .ndo_do_ioctl
= qeth_do_ioctl
,
969 .ndo_set_mac_address
= qeth_l2_set_mac_address
,
970 .ndo_change_mtu
= qeth_change_mtu
,
971 .ndo_vlan_rx_add_vid
= qeth_l2_vlan_rx_add_vid
,
972 .ndo_vlan_rx_kill_vid
= qeth_l2_vlan_rx_kill_vid
,
973 .ndo_tx_timeout
= qeth_tx_timeout
,
974 .ndo_fix_features
= qeth_fix_features
,
975 .ndo_set_features
= qeth_set_features
978 static int qeth_l2_setup_netdev(struct qeth_card
*card
)
980 switch (card
->info
.type
) {
981 case QETH_CARD_TYPE_IQD
:
982 card
->dev
= alloc_netdev(0, "hsi%d", NET_NAME_UNKNOWN
,
985 case QETH_CARD_TYPE_OSN
:
986 card
->dev
= alloc_netdev(0, "osn%d", NET_NAME_UNKNOWN
,
990 card
->dev
= alloc_etherdev(0);
996 card
->dev
->ml_priv
= card
;
997 card
->dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
998 card
->dev
->mtu
= card
->info
.initial_mtu
;
999 card
->dev
->min_mtu
= 64;
1000 card
->dev
->max_mtu
= ETH_MAX_MTU
;
1001 card
->dev
->netdev_ops
= &qeth_l2_netdev_ops
;
1002 if (card
->info
.type
== QETH_CARD_TYPE_OSN
) {
1003 card
->dev
->ethtool_ops
= &qeth_l2_osn_ops
;
1004 card
->dev
->flags
|= IFF_NOARP
;
1006 card
->dev
->ethtool_ops
= &qeth_l2_ethtool_ops
;
1008 card
->dev
->features
|= NETIF_F_HW_VLAN_CTAG_FILTER
;
1009 if (card
->info
.type
== QETH_CARD_TYPE_OSD
&& !card
->info
.guestlan
) {
1010 card
->dev
->hw_features
= NETIF_F_SG
;
1011 card
->dev
->vlan_features
= NETIF_F_SG
;
1012 /* OSA 3S and earlier has no RX/TX support */
1013 if (qeth_is_supported(card
, IPA_OUTBOUND_CHECKSUM
)) {
1014 card
->dev
->hw_features
|= NETIF_F_IP_CSUM
;
1015 card
->dev
->vlan_features
|= NETIF_F_IP_CSUM
;
1017 if (qeth_is_supported(card
, IPA_INBOUND_CHECKSUM
)) {
1018 card
->dev
->hw_features
|= NETIF_F_RXCSUM
;
1019 card
->dev
->vlan_features
|= NETIF_F_RXCSUM
;
1022 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
&&
1023 card
->info
.type
!= QETH_CARD_TYPE_IQD
) {
1024 card
->dev
->priv_flags
&= ~IFF_TX_SKB_SHARING
;
1025 card
->dev
->needed_headroom
= sizeof(struct qeth_hdr
);
1028 card
->info
.broadcast_capable
= 1;
1029 qeth_l2_request_initial_mac(card
);
1030 card
->dev
->gso_max_size
= (QETH_MAX_BUFFER_ELEMENTS(card
) - 1) *
1032 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
1033 netif_napi_add(card
->dev
, &card
->napi
, qeth_poll
, QETH_NAPI_WEIGHT
);
1034 netif_carrier_off(card
->dev
);
1035 return register_netdev(card
->dev
);
1038 static int qeth_l2_start_ipassists(struct qeth_card
*card
)
1040 /* configure isolation level */
1041 if (qeth_set_access_ctrl_online(card
, 0))
1046 static void qeth_l2_trace_features(struct qeth_card
*card
)
1048 QETH_CARD_TEXT(card
, 2, "l2featur");
1049 QETH_CARD_HEX(card
, 2, &card
->options
.sbp
.supported_funcs
,
1050 sizeof(card
->options
.sbp
.supported_funcs
));
1053 static int __qeth_l2_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
)
1055 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
1057 enum qeth_card_states recover_flag
;
1059 mutex_lock(&card
->discipline_mutex
);
1060 mutex_lock(&card
->conf_mutex
);
1061 QETH_DBF_TEXT(SETUP
, 2, "setonlin");
1062 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
1064 recover_flag
= card
->state
;
1065 rc
= qeth_core_hardsetup_card(card
);
1067 QETH_DBF_TEXT_(SETUP
, 2, "2err%04x", rc
);
1071 qeth_bridgeport_query_support(card
);
1072 if (card
->options
.sbp
.supported_funcs
)
1073 dev_info(&card
->gdev
->dev
,
1074 "The device represents a Bridge Capable Port\n");
1075 qeth_trace_features(card
);
1076 qeth_l2_trace_features(card
);
1078 if (!card
->dev
&& qeth_l2_setup_netdev(card
)) {
1083 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
)
1084 qeth_l2_send_setmac(card
, &card
->dev
->dev_addr
[0]);
1086 if (qeth_is_diagass_supported(card
, QETH_DIAGS_CMD_TRAP
)) {
1087 if (card
->info
.hwtrap
&&
1088 qeth_hw_trap(card
, QETH_DIAGS_TRAP_ARM
))
1089 card
->info
.hwtrap
= 0;
1091 card
->info
.hwtrap
= 0;
1093 qeth_l2_setup_bridgeport_attrs(card
);
1095 card
->state
= CARD_STATE_HARDSETUP
;
1096 memset(&card
->rx
, 0, sizeof(struct qeth_rx
));
1097 qeth_print_status_message(card
);
1100 QETH_DBF_TEXT(SETUP
, 2, "softsetp");
1102 if ((card
->info
.type
== QETH_CARD_TYPE_OSD
) ||
1103 (card
->info
.type
== QETH_CARD_TYPE_OSX
)) {
1104 rc
= qeth_l2_start_ipassists(card
);
1109 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
&&
1110 card
->info
.type
!= QETH_CARD_TYPE_OSM
)
1111 qeth_l2_process_vlans(card
);
1113 netif_tx_disable(card
->dev
);
1115 rc
= qeth_init_qdio_queues(card
);
1117 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
1121 card
->state
= CARD_STATE_SOFTSETUP
;
1122 if (card
->lan_online
)
1123 netif_carrier_on(card
->dev
);
1125 netif_carrier_off(card
->dev
);
1127 qeth_set_allowed_threads(card
, 0xffffffff, 0);
1128 if (recover_flag
== CARD_STATE_RECOVER
) {
1129 if (recovery_mode
&&
1130 card
->info
.type
!= QETH_CARD_TYPE_OSN
) {
1131 __qeth_l2_open(card
->dev
);
1134 dev_open(card
->dev
);
1137 /* this also sets saved unicast addresses */
1138 qeth_l2_set_rx_mode(card
->dev
);
1140 qeth_recover_features(card
->dev
);
1143 /* let user_space know that device is online */
1144 kobject_uevent(&gdev
->dev
.kobj
, KOBJ_CHANGE
);
1145 mutex_unlock(&card
->conf_mutex
);
1146 mutex_unlock(&card
->discipline_mutex
);
1150 qeth_l2_stop_card(card
, 0);
1151 ccw_device_set_offline(CARD_DDEV(card
));
1152 ccw_device_set_offline(CARD_WDEV(card
));
1153 ccw_device_set_offline(CARD_RDEV(card
));
1154 qdio_free(CARD_DDEV(card
));
1155 if (recover_flag
== CARD_STATE_RECOVER
)
1156 card
->state
= CARD_STATE_RECOVER
;
1158 card
->state
= CARD_STATE_DOWN
;
1159 mutex_unlock(&card
->conf_mutex
);
1160 mutex_unlock(&card
->discipline_mutex
);
1164 static int qeth_l2_set_online(struct ccwgroup_device
*gdev
)
1166 return __qeth_l2_set_online(gdev
, 0);
1169 static int __qeth_l2_set_offline(struct ccwgroup_device
*cgdev
,
1172 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
1173 int rc
= 0, rc2
= 0, rc3
= 0;
1174 enum qeth_card_states recover_flag
;
1176 mutex_lock(&card
->discipline_mutex
);
1177 mutex_lock(&card
->conf_mutex
);
1178 QETH_DBF_TEXT(SETUP
, 3, "setoffl");
1179 QETH_DBF_HEX(SETUP
, 3, &card
, sizeof(void *));
1181 if (card
->dev
&& netif_carrier_ok(card
->dev
))
1182 netif_carrier_off(card
->dev
);
1183 recover_flag
= card
->state
;
1184 if ((!recovery_mode
&& card
->info
.hwtrap
) || card
->info
.hwtrap
== 2) {
1185 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
1186 card
->info
.hwtrap
= 1;
1188 qeth_l2_stop_card(card
, recovery_mode
);
1189 rc
= ccw_device_set_offline(CARD_DDEV(card
));
1190 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
1191 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
1193 rc
= (rc2
) ? rc2
: rc3
;
1195 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
1196 qdio_free(CARD_DDEV(card
));
1197 if (recover_flag
== CARD_STATE_UP
)
1198 card
->state
= CARD_STATE_RECOVER
;
1199 /* let user_space know that device is offline */
1200 kobject_uevent(&cgdev
->dev
.kobj
, KOBJ_CHANGE
);
1201 mutex_unlock(&card
->conf_mutex
);
1202 mutex_unlock(&card
->discipline_mutex
);
1206 static int qeth_l2_set_offline(struct ccwgroup_device
*cgdev
)
1208 return __qeth_l2_set_offline(cgdev
, 0);
1211 static int qeth_l2_recover(void *ptr
)
1213 struct qeth_card
*card
;
1216 card
= (struct qeth_card
*) ptr
;
1217 QETH_CARD_TEXT(card
, 2, "recover1");
1218 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
1220 QETH_CARD_TEXT(card
, 2, "recover2");
1221 dev_warn(&card
->gdev
->dev
,
1222 "A recovery process has been started for the device\n");
1223 qeth_set_recovery_task(card
);
1224 __qeth_l2_set_offline(card
->gdev
, 1);
1225 rc
= __qeth_l2_set_online(card
->gdev
, 1);
1227 dev_info(&card
->gdev
->dev
,
1228 "Device successfully recovered!\n");
1230 qeth_close_dev(card
);
1231 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
1232 "failed to recover an error on the device\n");
1234 qeth_clear_recovery_task(card
);
1235 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
1236 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
1240 static int __init
qeth_l2_init(void)
1242 pr_info("register layer 2 discipline\n");
1246 static void __exit
qeth_l2_exit(void)
1248 pr_info("unregister layer 2 discipline\n");
1251 static int qeth_l2_pm_suspend(struct ccwgroup_device
*gdev
)
1253 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
1256 netif_device_detach(card
->dev
);
1257 qeth_set_allowed_threads(card
, 0, 1);
1258 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
1259 if (gdev
->state
== CCWGROUP_OFFLINE
)
1261 if (card
->state
== CARD_STATE_UP
) {
1262 if (card
->info
.hwtrap
)
1263 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
1264 __qeth_l2_set_offline(card
->gdev
, 1);
1266 __qeth_l2_set_offline(card
->gdev
, 0);
1270 static int qeth_l2_pm_resume(struct ccwgroup_device
*gdev
)
1272 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
1275 if (gdev
->state
== CCWGROUP_OFFLINE
)
1278 if (card
->state
== CARD_STATE_RECOVER
) {
1279 rc
= __qeth_l2_set_online(card
->gdev
, 1);
1282 dev_close(card
->dev
);
1286 rc
= __qeth_l2_set_online(card
->gdev
, 0);
1288 qeth_set_allowed_threads(card
, 0xffffffff, 0);
1290 netif_device_attach(card
->dev
);
1292 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
1293 "failed to recover an error on the device\n");
1297 /* Returns zero if the command is successfully "consumed" */
1298 static int qeth_l2_control_event(struct qeth_card
*card
,
1299 struct qeth_ipa_cmd
*cmd
)
1301 switch (cmd
->hdr
.command
) {
1302 case IPA_CMD_SETBRIDGEPORT_OSA
:
1303 case IPA_CMD_SETBRIDGEPORT_IQD
:
1304 if (cmd
->data
.sbp
.hdr
.command_code
==
1305 IPA_SBP_BRIDGE_PORT_STATE_CHANGE
) {
1306 qeth_bridge_state_change(card
, cmd
);
1310 case IPA_CMD_ADDRESS_CHANGE_NOTIF
:
1311 qeth_bridge_host_event(card
, cmd
);
1318 struct qeth_discipline qeth_l2_discipline
= {
1319 .devtype
= &qeth_l2_devtype
,
1320 .start_poll
= qeth_qdio_start_poll
,
1321 .input_handler
= (qdio_handler_t
*) qeth_qdio_input_handler
,
1322 .output_handler
= (qdio_handler_t
*) qeth_qdio_output_handler
,
1323 .process_rx_buffer
= qeth_l2_process_inbound_buffer
,
1324 .recover
= qeth_l2_recover
,
1325 .setup
= qeth_l2_probe_device
,
1326 .remove
= qeth_l2_remove_device
,
1327 .set_online
= qeth_l2_set_online
,
1328 .set_offline
= qeth_l2_set_offline
,
1329 .freeze
= qeth_l2_pm_suspend
,
1330 .thaw
= qeth_l2_pm_resume
,
1331 .restore
= qeth_l2_pm_resume
,
1333 .control_event_handler
= qeth_l2_control_event
,
1335 EXPORT_SYMBOL_GPL(qeth_l2_discipline
);
1337 static int qeth_osn_send_control_data(struct qeth_card
*card
, int len
,
1338 struct qeth_cmd_buffer
*iob
)
1340 unsigned long flags
;
1343 QETH_CARD_TEXT(card
, 5, "osndctrd");
1345 wait_event(card
->wait_q
,
1346 atomic_cmpxchg(&card
->write
.irq_pending
, 0, 1) == 0);
1347 qeth_prepare_control_data(card
, len
, iob
);
1348 QETH_CARD_TEXT(card
, 6, "osnoirqp");
1349 spin_lock_irqsave(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1350 rc
= ccw_device_start(card
->write
.ccwdev
, &card
->write
.ccw
,
1351 (addr_t
) iob
, 0, 0);
1352 spin_unlock_irqrestore(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1354 QETH_DBF_MESSAGE(2, "qeth_osn_send_control_data: "
1355 "ccw_device_start rc = %i\n", rc
);
1356 QETH_CARD_TEXT_(card
, 2, " err%d", rc
);
1357 qeth_release_buffer(iob
->channel
, iob
);
1358 atomic_set(&card
->write
.irq_pending
, 0);
1359 wake_up(&card
->wait_q
);
1364 static int qeth_osn_send_ipa_cmd(struct qeth_card
*card
,
1365 struct qeth_cmd_buffer
*iob
, int data_len
)
1369 QETH_CARD_TEXT(card
, 4, "osndipa");
1371 qeth_prepare_ipa_cmd(card
, iob
, QETH_PROT_OSN2
);
1372 s1
= (u16
)(IPA_PDU_HEADER_SIZE
+ data_len
);
1374 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob
->data
), &s1
, 2);
1375 memcpy(QETH_IPA_PDU_LEN_PDU1(iob
->data
), &s2
, 2);
1376 memcpy(QETH_IPA_PDU_LEN_PDU2(iob
->data
), &s2
, 2);
1377 memcpy(QETH_IPA_PDU_LEN_PDU3(iob
->data
), &s2
, 2);
1378 return qeth_osn_send_control_data(card
, s1
, iob
);
1381 int qeth_osn_assist(struct net_device
*dev
, void *data
, int data_len
)
1383 struct qeth_cmd_buffer
*iob
;
1384 struct qeth_card
*card
;
1389 card
= dev
->ml_priv
;
1392 QETH_CARD_TEXT(card
, 2, "osnsdmc");
1393 if (!qeth_card_hw_is_reachable(card
))
1395 iob
= qeth_wait_for_buffer(&card
->write
);
1396 memcpy(iob
->data
+IPA_PDU_HEADER_SIZE
, data
, data_len
);
1397 rc
= qeth_osn_send_ipa_cmd(card
, iob
, data_len
);
1400 EXPORT_SYMBOL(qeth_osn_assist
);
1402 int qeth_osn_register(unsigned char *read_dev_no
, struct net_device
**dev
,
1403 int (*assist_cb
)(struct net_device
*, void *),
1404 int (*data_cb
)(struct sk_buff
*))
1406 struct qeth_card
*card
;
1408 *dev
= qeth_l2_netdev_by_devno(read_dev_no
);
1411 card
= (*dev
)->ml_priv
;
1414 QETH_CARD_TEXT(card
, 2, "osnreg");
1415 if ((assist_cb
== NULL
) || (data_cb
== NULL
))
1417 card
->osn_info
.assist_cb
= assist_cb
;
1418 card
->osn_info
.data_cb
= data_cb
;
1421 EXPORT_SYMBOL(qeth_osn_register
);
1423 void qeth_osn_deregister(struct net_device
*dev
)
1425 struct qeth_card
*card
;
1429 card
= dev
->ml_priv
;
1432 QETH_CARD_TEXT(card
, 2, "osndereg");
1433 card
->osn_info
.assist_cb
= NULL
;
1434 card
->osn_info
.data_cb
= NULL
;
1437 EXPORT_SYMBOL(qeth_osn_deregister
);
1439 /* SETBRIDGEPORT support, async notifications */
1441 enum qeth_an_event_type
{anev_reg_unreg
, anev_abort
, anev_reset
};
1444 * qeth_bridge_emit_host_event() - bridgeport address change notification
1445 * @card: qeth_card structure pointer, for udev events.
1446 * @evtype: "normal" register/unregister, or abort, or reset. For abort
1447 * and reset token and addr_lnid are unused and may be NULL.
1448 * @code: event bitmask: high order bit 0x80 value 1 means removal of an
1449 * object, 0 - addition of an object.
1450 * 0x01 - VLAN, 0x02 - MAC, 0x03 - VLAN and MAC.
1451 * @token: "network token" structure identifying physical address of the port.
1452 * @addr_lnid: pointer to structure with MAC address and VLAN ID.
1454 * This function is called when registrations and deregistrations are
1455 * reported by the hardware, and also when notifications are enabled -
1456 * for all currently registered addresses.
1458 static void qeth_bridge_emit_host_event(struct qeth_card
*card
,
1459 enum qeth_an_event_type evtype
,
1460 u8 code
, struct net_if_token
*token
, struct mac_addr_lnid
*addr_lnid
)
1467 case anev_reg_unreg
:
1468 snprintf(str
[i
], sizeof(str
[i
]), "BRIDGEDHOST=%s",
1469 (code
& IPA_ADDR_CHANGE_CODE_REMOVAL
)
1470 ? "deregister" : "register");
1471 env
[i
] = str
[i
]; i
++;
1472 if (code
& IPA_ADDR_CHANGE_CODE_VLANID
) {
1473 snprintf(str
[i
], sizeof(str
[i
]), "VLAN=%d",
1475 env
[i
] = str
[i
]; i
++;
1477 if (code
& IPA_ADDR_CHANGE_CODE_MACADDR
) {
1478 snprintf(str
[i
], sizeof(str
[i
]), "MAC=%pM",
1480 env
[i
] = str
[i
]; i
++;
1482 snprintf(str
[i
], sizeof(str
[i
]), "NTOK_BUSID=%x.%x.%04x",
1483 token
->cssid
, token
->ssid
, token
->devnum
);
1484 env
[i
] = str
[i
]; i
++;
1485 snprintf(str
[i
], sizeof(str
[i
]), "NTOK_IID=%02x", token
->iid
);
1486 env
[i
] = str
[i
]; i
++;
1487 snprintf(str
[i
], sizeof(str
[i
]), "NTOK_CHPID=%02x",
1489 env
[i
] = str
[i
]; i
++;
1490 snprintf(str
[i
], sizeof(str
[i
]), "NTOK_CHID=%04x", token
->chid
);
1491 env
[i
] = str
[i
]; i
++;
1494 snprintf(str
[i
], sizeof(str
[i
]), "BRIDGEDHOST=abort");
1495 env
[i
] = str
[i
]; i
++;
1498 snprintf(str
[i
], sizeof(str
[i
]), "BRIDGEDHOST=reset");
1499 env
[i
] = str
[i
]; i
++;
1503 kobject_uevent_env(&card
->gdev
->dev
.kobj
, KOBJ_CHANGE
, env
);
1506 struct qeth_bridge_state_data
{
1507 struct work_struct worker
;
1508 struct qeth_card
*card
;
1509 struct qeth_sbp_state_change qports
;
1512 static void qeth_bridge_state_change_worker(struct work_struct
*work
)
1514 struct qeth_bridge_state_data
*data
=
1515 container_of(work
, struct qeth_bridge_state_data
, worker
);
1516 /* We are only interested in the first entry - local port */
1517 struct qeth_sbp_port_entry
*entry
= &data
->qports
.entry
[0];
1518 char env_locrem
[32];
1528 /* Role should not change by itself, but if it did, */
1529 /* information from the hardware is authoritative. */
1530 mutex_lock(&data
->card
->conf_mutex
);
1531 data
->card
->options
.sbp
.role
= entry
->role
;
1532 mutex_unlock(&data
->card
->conf_mutex
);
1534 snprintf(env_locrem
, sizeof(env_locrem
), "BRIDGEPORT=statechange");
1535 snprintf(env_role
, sizeof(env_role
), "ROLE=%s",
1536 (entry
->role
== QETH_SBP_ROLE_NONE
) ? "none" :
1537 (entry
->role
== QETH_SBP_ROLE_PRIMARY
) ? "primary" :
1538 (entry
->role
== QETH_SBP_ROLE_SECONDARY
) ? "secondary" :
1540 snprintf(env_state
, sizeof(env_state
), "STATE=%s",
1541 (entry
->state
== QETH_SBP_STATE_INACTIVE
) ? "inactive" :
1542 (entry
->state
== QETH_SBP_STATE_STANDBY
) ? "standby" :
1543 (entry
->state
== QETH_SBP_STATE_ACTIVE
) ? "active" :
1545 kobject_uevent_env(&data
->card
->gdev
->dev
.kobj
,
1550 static void qeth_bridge_state_change(struct qeth_card
*card
,
1551 struct qeth_ipa_cmd
*cmd
)
1553 struct qeth_sbp_state_change
*qports
=
1554 &cmd
->data
.sbp
.data
.state_change
;
1555 struct qeth_bridge_state_data
*data
;
1558 QETH_CARD_TEXT(card
, 2, "brstchng");
1559 if (qports
->entry_length
!= sizeof(struct qeth_sbp_port_entry
)) {
1560 QETH_CARD_TEXT_(card
, 2, "BPsz%04x", qports
->entry_length
);
1563 extrasize
= sizeof(struct qeth_sbp_port_entry
) * qports
->num_entries
;
1564 data
= kzalloc(sizeof(struct qeth_bridge_state_data
) + extrasize
,
1567 QETH_CARD_TEXT(card
, 2, "BPSalloc");
1570 INIT_WORK(&data
->worker
, qeth_bridge_state_change_worker
);
1572 memcpy(&data
->qports
, qports
,
1573 sizeof(struct qeth_sbp_state_change
) + extrasize
);
1574 queue_work(qeth_wq
, &data
->worker
);
1577 struct qeth_bridge_host_data
{
1578 struct work_struct worker
;
1579 struct qeth_card
*card
;
1580 struct qeth_ipacmd_addr_change hostevs
;
1583 static void qeth_bridge_host_event_worker(struct work_struct
*work
)
1585 struct qeth_bridge_host_data
*data
=
1586 container_of(work
, struct qeth_bridge_host_data
, worker
);
1589 if (data
->hostevs
.lost_event_mask
) {
1590 dev_info(&data
->card
->gdev
->dev
,
1591 "Address notification from the Bridge Port stopped %s (%s)\n",
1592 data
->card
->dev
->name
,
1593 (data
->hostevs
.lost_event_mask
== 0x01)
1595 : (data
->hostevs
.lost_event_mask
== 0x02)
1596 ? "Bridge port state change"
1597 : "Unknown reason");
1598 mutex_lock(&data
->card
->conf_mutex
);
1599 data
->card
->options
.sbp
.hostnotification
= 0;
1600 mutex_unlock(&data
->card
->conf_mutex
);
1601 qeth_bridge_emit_host_event(data
->card
, anev_abort
,
1604 for (i
= 0; i
< data
->hostevs
.num_entries
; i
++) {
1605 struct qeth_ipacmd_addr_change_entry
*entry
=
1606 &data
->hostevs
.entry
[i
];
1607 qeth_bridge_emit_host_event(data
->card
,
1610 &entry
->token
, &entry
->addr_lnid
);
1615 static void qeth_bridge_host_event(struct qeth_card
*card
,
1616 struct qeth_ipa_cmd
*cmd
)
1618 struct qeth_ipacmd_addr_change
*hostevs
=
1619 &cmd
->data
.addrchange
;
1620 struct qeth_bridge_host_data
*data
;
1623 QETH_CARD_TEXT(card
, 2, "brhostev");
1624 if (cmd
->hdr
.return_code
!= 0x0000) {
1625 if (cmd
->hdr
.return_code
== 0x0010) {
1626 if (hostevs
->lost_event_mask
== 0x00)
1627 hostevs
->lost_event_mask
= 0xff;
1629 QETH_CARD_TEXT_(card
, 2, "BPHe%04x",
1630 cmd
->hdr
.return_code
);
1634 extrasize
= sizeof(struct qeth_ipacmd_addr_change_entry
) *
1635 hostevs
->num_entries
;
1636 data
= kzalloc(sizeof(struct qeth_bridge_host_data
) + extrasize
,
1639 QETH_CARD_TEXT(card
, 2, "BPHalloc");
1642 INIT_WORK(&data
->worker
, qeth_bridge_host_event_worker
);
1644 memcpy(&data
->hostevs
, hostevs
,
1645 sizeof(struct qeth_ipacmd_addr_change
) + extrasize
);
1646 queue_work(qeth_wq
, &data
->worker
);
1649 /* SETBRIDGEPORT support; sending commands */
1651 struct _qeth_sbp_cbctl
{
1657 enum qeth_sbp_roles
*role
;
1658 enum qeth_sbp_states
*state
;
1664 * qeth_bridgeport_makerc() - derive "traditional" error from hardware codes.
1665 * @card: qeth_card structure pointer, for debug messages.
1666 * @cbctl: state structure with hardware return codes.
1667 * @setcmd: IPA command code
1669 * Returns negative errno-compatible error indication or 0 on success.
1671 static int qeth_bridgeport_makerc(struct qeth_card
*card
,
1672 struct _qeth_sbp_cbctl
*cbctl
, enum qeth_ipa_sbp_cmd setcmd
)
1675 int is_iqd
= (card
->info
.type
== QETH_CARD_TYPE_IQD
);
1677 if ((is_iqd
&& (cbctl
->ipa_rc
== IPA_RC_SUCCESS
)) ||
1678 (!is_iqd
&& (cbctl
->ipa_rc
== cbctl
->cmd_rc
)))
1679 switch (cbctl
->cmd_rc
) {
1680 case IPA_RC_SUCCESS
:
1683 case IPA_RC_L2_UNSUPPORTED_CMD
:
1684 case IPA_RC_UNSUPPORTED_COMMAND
:
1687 case IPA_RC_SBP_OSA_NOT_CONFIGURED
:
1688 case IPA_RC_SBP_IQD_NOT_CONFIGURED
:
1689 rc
= -ENODEV
; /* maybe not the best code here? */
1690 dev_err(&card
->gdev
->dev
,
1691 "The device is not configured as a Bridge Port\n");
1693 case IPA_RC_SBP_OSA_OS_MISMATCH
:
1694 case IPA_RC_SBP_IQD_OS_MISMATCH
:
1696 dev_err(&card
->gdev
->dev
,
1697 "A Bridge Port is already configured by a different operating system\n");
1699 case IPA_RC_SBP_OSA_ANO_DEV_PRIMARY
:
1700 case IPA_RC_SBP_IQD_ANO_DEV_PRIMARY
:
1702 case IPA_SBP_SET_PRIMARY_BRIDGE_PORT
:
1704 dev_err(&card
->gdev
->dev
,
1705 "The LAN already has a primary Bridge Port\n");
1707 case IPA_SBP_SET_SECONDARY_BRIDGE_PORT
:
1709 dev_err(&card
->gdev
->dev
,
1710 "The device is already a primary Bridge Port\n");
1716 case IPA_RC_SBP_OSA_CURRENT_SECOND
:
1717 case IPA_RC_SBP_IQD_CURRENT_SECOND
:
1719 dev_err(&card
->gdev
->dev
,
1720 "The device is already a secondary Bridge Port\n");
1722 case IPA_RC_SBP_OSA_LIMIT_SECOND
:
1723 case IPA_RC_SBP_IQD_LIMIT_SECOND
:
1725 dev_err(&card
->gdev
->dev
,
1726 "The LAN cannot have more secondary Bridge Ports\n");
1728 case IPA_RC_SBP_OSA_CURRENT_PRIMARY
:
1729 case IPA_RC_SBP_IQD_CURRENT_PRIMARY
:
1731 dev_err(&card
->gdev
->dev
,
1732 "The device is already a primary Bridge Port\n");
1734 case IPA_RC_SBP_OSA_NOT_AUTHD_BY_ZMAN
:
1735 case IPA_RC_SBP_IQD_NOT_AUTHD_BY_ZMAN
:
1737 dev_err(&card
->gdev
->dev
,
1738 "The device is not authorized to be a Bridge Port\n");
1744 switch (cbctl
->ipa_rc
) {
1745 case IPA_RC_NOTSUPP
:
1748 case IPA_RC_UNSUPPORTED_COMMAND
:
1756 QETH_CARD_TEXT_(card
, 2, "SBPi%04x", cbctl
->ipa_rc
);
1757 QETH_CARD_TEXT_(card
, 2, "SBPc%04x", cbctl
->cmd_rc
);
1762 static struct qeth_cmd_buffer
*qeth_sbp_build_cmd(struct qeth_card
*card
,
1763 enum qeth_ipa_sbp_cmd sbp_cmd
,
1764 unsigned int cmd_length
)
1766 enum qeth_ipa_cmds ipa_cmd
= (card
->info
.type
== QETH_CARD_TYPE_IQD
) ?
1767 IPA_CMD_SETBRIDGEPORT_IQD
:
1768 IPA_CMD_SETBRIDGEPORT_OSA
;
1769 struct qeth_cmd_buffer
*iob
;
1770 struct qeth_ipa_cmd
*cmd
;
1772 iob
= qeth_get_ipacmd_buffer(card
, ipa_cmd
, 0);
1775 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1776 cmd
->data
.sbp
.hdr
.cmdlength
= sizeof(struct qeth_ipacmd_sbp_hdr
) +
1778 cmd
->data
.sbp
.hdr
.command_code
= sbp_cmd
;
1779 cmd
->data
.sbp
.hdr
.used_total
= 1;
1780 cmd
->data
.sbp
.hdr
.seq_no
= 1;
1784 static int qeth_bridgeport_query_support_cb(struct qeth_card
*card
,
1785 struct qeth_reply
*reply
, unsigned long data
)
1787 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*) data
;
1788 struct _qeth_sbp_cbctl
*cbctl
= (struct _qeth_sbp_cbctl
*)reply
->param
;
1789 QETH_CARD_TEXT(card
, 2, "brqsupcb");
1790 cbctl
->ipa_rc
= cmd
->hdr
.return_code
;
1791 cbctl
->cmd_rc
= cmd
->data
.sbp
.hdr
.return_code
;
1792 if ((cbctl
->ipa_rc
== 0) && (cbctl
->cmd_rc
== 0)) {
1793 cbctl
->data
.supported
=
1794 cmd
->data
.sbp
.data
.query_cmds_supp
.supported_cmds
;
1796 cbctl
->data
.supported
= 0;
1802 * qeth_bridgeport_query_support() - store bitmask of supported subfunctions.
1803 * @card: qeth_card structure pointer.
1805 * Sets bitmask of supported setbridgeport subfunctions in the qeth_card
1806 * strucutre: card->options.sbp.supported_funcs.
1808 static void qeth_bridgeport_query_support(struct qeth_card
*card
)
1810 struct qeth_cmd_buffer
*iob
;
1811 struct _qeth_sbp_cbctl cbctl
;
1813 QETH_CARD_TEXT(card
, 2, "brqsuppo");
1814 iob
= qeth_sbp_build_cmd(card
, IPA_SBP_QUERY_COMMANDS_SUPPORTED
,
1815 sizeof(struct qeth_sbp_query_cmds_supp
));
1818 if (qeth_send_ipa_cmd(card
, iob
, qeth_bridgeport_query_support_cb
,
1820 qeth_bridgeport_makerc(card
, &cbctl
,
1821 IPA_SBP_QUERY_COMMANDS_SUPPORTED
)) {
1822 /* non-zero makerc signifies failure, and produce messages */
1823 card
->options
.sbp
.role
= QETH_SBP_ROLE_NONE
;
1826 card
->options
.sbp
.supported_funcs
= cbctl
.data
.supported
;
1829 static int qeth_bridgeport_query_ports_cb(struct qeth_card
*card
,
1830 struct qeth_reply
*reply
, unsigned long data
)
1832 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*) data
;
1833 struct qeth_sbp_query_ports
*qports
= &cmd
->data
.sbp
.data
.query_ports
;
1834 struct _qeth_sbp_cbctl
*cbctl
= (struct _qeth_sbp_cbctl
*)reply
->param
;
1836 QETH_CARD_TEXT(card
, 2, "brqprtcb");
1837 cbctl
->ipa_rc
= cmd
->hdr
.return_code
;
1838 cbctl
->cmd_rc
= cmd
->data
.sbp
.hdr
.return_code
;
1839 if ((cbctl
->ipa_rc
!= 0) || (cbctl
->cmd_rc
!= 0))
1841 if (qports
->entry_length
!= sizeof(struct qeth_sbp_port_entry
)) {
1842 cbctl
->cmd_rc
= 0xffff;
1843 QETH_CARD_TEXT_(card
, 2, "SBPs%04x", qports
->entry_length
);
1846 /* first entry contains the state of the local port */
1847 if (qports
->num_entries
> 0) {
1848 if (cbctl
->data
.qports
.role
)
1849 *cbctl
->data
.qports
.role
= qports
->entry
[0].role
;
1850 if (cbctl
->data
.qports
.state
)
1851 *cbctl
->data
.qports
.state
= qports
->entry
[0].state
;
1857 * qeth_bridgeport_query_ports() - query local bridgeport status.
1858 * @card: qeth_card structure pointer.
1859 * @role: Role of the port: 0-none, 1-primary, 2-secondary.
1860 * @state: State of the port: 0-inactive, 1-standby, 2-active.
1862 * Returns negative errno-compatible error indication or 0 on success.
1864 * 'role' and 'state' are not updated in case of hardware operation failure.
1866 int qeth_bridgeport_query_ports(struct qeth_card
*card
,
1867 enum qeth_sbp_roles
*role
, enum qeth_sbp_states
*state
)
1870 struct qeth_cmd_buffer
*iob
;
1871 struct _qeth_sbp_cbctl cbctl
= {
1880 QETH_CARD_TEXT(card
, 2, "brqports");
1881 if (!(card
->options
.sbp
.supported_funcs
& IPA_SBP_QUERY_BRIDGE_PORTS
))
1883 iob
= qeth_sbp_build_cmd(card
, IPA_SBP_QUERY_BRIDGE_PORTS
, 0);
1886 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_bridgeport_query_ports_cb
,
1890 return qeth_bridgeport_makerc(card
, &cbctl
, IPA_SBP_QUERY_BRIDGE_PORTS
);
1892 EXPORT_SYMBOL_GPL(qeth_bridgeport_query_ports
);
1894 static int qeth_bridgeport_set_cb(struct qeth_card
*card
,
1895 struct qeth_reply
*reply
, unsigned long data
)
1897 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*)data
;
1898 struct _qeth_sbp_cbctl
*cbctl
= (struct _qeth_sbp_cbctl
*)reply
->param
;
1899 QETH_CARD_TEXT(card
, 2, "brsetrcb");
1900 cbctl
->ipa_rc
= cmd
->hdr
.return_code
;
1901 cbctl
->cmd_rc
= cmd
->data
.sbp
.hdr
.return_code
;
1906 * qeth_bridgeport_setrole() - Assign primary role to the port.
1907 * @card: qeth_card structure pointer.
1908 * @role: Role to assign.
1910 * Returns negative errno-compatible error indication or 0 on success.
1912 int qeth_bridgeport_setrole(struct qeth_card
*card
, enum qeth_sbp_roles role
)
1916 struct qeth_cmd_buffer
*iob
;
1917 struct _qeth_sbp_cbctl cbctl
;
1918 enum qeth_ipa_sbp_cmd setcmd
;
1920 QETH_CARD_TEXT(card
, 2, "brsetrol");
1922 case QETH_SBP_ROLE_NONE
:
1923 setcmd
= IPA_SBP_RESET_BRIDGE_PORT_ROLE
;
1924 cmdlength
= sizeof(struct qeth_sbp_reset_role
);
1926 case QETH_SBP_ROLE_PRIMARY
:
1927 setcmd
= IPA_SBP_SET_PRIMARY_BRIDGE_PORT
;
1928 cmdlength
= sizeof(struct qeth_sbp_set_primary
);
1930 case QETH_SBP_ROLE_SECONDARY
:
1931 setcmd
= IPA_SBP_SET_SECONDARY_BRIDGE_PORT
;
1932 cmdlength
= sizeof(struct qeth_sbp_set_secondary
);
1937 if (!(card
->options
.sbp
.supported_funcs
& setcmd
))
1939 iob
= qeth_sbp_build_cmd(card
, setcmd
, cmdlength
);
1942 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_bridgeport_set_cb
,
1946 return qeth_bridgeport_makerc(card
, &cbctl
, setcmd
);
1950 * qeth_anset_makerc() - derive "traditional" error from hardware codes.
1951 * @card: qeth_card structure pointer, for debug messages.
1953 * Returns negative errno-compatible error indication or 0 on success.
1955 static int qeth_anset_makerc(struct qeth_card
*card
, int pnso_rc
, u16 response
)
1968 dev_err(&card
->gdev
->dev
,
1969 "Setting address notification failed\n");
1981 QETH_CARD_TEXT_(card
, 2, "SBPp%04x", pnso_rc
);
1982 QETH_CARD_TEXT_(card
, 2, "SBPr%04x", response
);
1987 static void qeth_bridgeport_an_set_cb(void *priv
,
1988 enum qdio_brinfo_entry_type type
, void *entry
)
1990 struct qeth_card
*card
= (struct qeth_card
*)priv
;
1991 struct qdio_brinfo_entry_l2
*l2entry
;
1994 if (type
!= l2_addr_lnid
) {
1999 l2entry
= (struct qdio_brinfo_entry_l2
*)entry
;
2000 code
= IPA_ADDR_CHANGE_CODE_MACADDR
;
2001 if (l2entry
->addr_lnid
.lnid
)
2002 code
|= IPA_ADDR_CHANGE_CODE_VLANID
;
2003 qeth_bridge_emit_host_event(card
, anev_reg_unreg
, code
,
2004 (struct net_if_token
*)&l2entry
->nit
,
2005 (struct mac_addr_lnid
*)&l2entry
->addr_lnid
);
2009 * qeth_bridgeport_an_set() - Enable or disable bridgeport address notification
2010 * @card: qeth_card structure pointer.
2011 * @enable: 0 - disable, non-zero - enable notifications
2013 * Returns negative errno-compatible error indication or 0 on success.
2015 * On enable, emits a series of address notifications udev events for all
2016 * currently registered hosts.
2018 int qeth_bridgeport_an_set(struct qeth_card
*card
, int enable
)
2022 struct ccw_device
*ddev
;
2023 struct subchannel_id schid
;
2027 if (!card
->options
.sbp
.supported_funcs
)
2029 ddev
= CARD_DDEV(card
);
2030 ccw_device_get_schid(ddev
, &schid
);
2033 qeth_bridge_emit_host_event(card
, anev_reset
, 0, NULL
, NULL
);
2034 rc
= qdio_pnso_brinfo(schid
, 1, &response
,
2035 qeth_bridgeport_an_set_cb
, card
);
2037 rc
= qdio_pnso_brinfo(schid
, 0, &response
, NULL
, NULL
);
2038 return qeth_anset_makerc(card
, rc
, response
);
2040 EXPORT_SYMBOL_GPL(qeth_bridgeport_an_set
);
2042 module_init(qeth_l2_init
);
2043 module_exit(qeth_l2_exit
);
2044 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
2045 MODULE_DESCRIPTION("qeth layer 2 discipline");
2046 MODULE_LICENSE("GPL");