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>
19 #include <linux/mii.h>
21 #include <linux/list.h>
23 #include "qeth_core.h"
26 static int qeth_l2_set_offline(struct ccwgroup_device
*);
27 static int qeth_l2_stop(struct net_device
*);
28 static int qeth_l2_send_delmac(struct qeth_card
*, __u8
*);
29 static int qeth_l2_send_setdelmac(struct qeth_card
*, __u8
*,
31 int (*reply_cb
) (struct qeth_card
*,
34 static void qeth_l2_set_multicast_list(struct net_device
*);
35 static int qeth_l2_recover(void *);
36 static void qeth_bridgeport_query_support(struct qeth_card
*card
);
37 static void qeth_bridge_state_change(struct qeth_card
*card
,
38 struct qeth_ipa_cmd
*cmd
);
39 static void qeth_bridge_host_event(struct qeth_card
*card
,
40 struct qeth_ipa_cmd
*cmd
);
42 static int qeth_l2_do_ioctl(struct net_device
*dev
, struct ifreq
*rq
, int cmd
)
44 struct qeth_card
*card
= dev
->ml_priv
;
45 struct mii_ioctl_data
*mii_data
;
51 if ((card
->state
!= CARD_STATE_UP
) &&
52 (card
->state
!= CARD_STATE_SOFTSETUP
))
55 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
59 case SIOC_QETH_ADP_SET_SNMP_CONTROL
:
60 rc
= qeth_snmp_command(card
, rq
->ifr_ifru
.ifru_data
);
62 case SIOC_QETH_GET_CARD_TYPE
:
63 if ((card
->info
.type
== QETH_CARD_TYPE_OSD
||
64 card
->info
.type
== QETH_CARD_TYPE_OSM
||
65 card
->info
.type
== QETH_CARD_TYPE_OSX
) &&
71 mii_data
= if_mii(rq
);
75 mii_data
= if_mii(rq
);
76 if (mii_data
->phy_id
!= 0)
79 mii_data
->val_out
= qeth_mdio_read(dev
,
80 mii_data
->phy_id
, mii_data
->reg_num
);
82 case SIOC_QETH_QUERY_OAT
:
83 rc
= qeth_query_oat_command(card
, rq
->ifr_ifru
.ifru_data
);
89 QETH_CARD_TEXT_(card
, 2, "ioce%d", rc
);
93 static int qeth_l2_verify_dev(struct net_device
*dev
)
95 struct qeth_card
*card
;
99 read_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
100 list_for_each_entry(card
, &qeth_core_card_list
.list
, list
) {
101 if (card
->dev
== dev
) {
106 read_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
111 static struct net_device
*qeth_l2_netdev_by_devno(unsigned char *read_dev_no
)
113 struct qeth_card
*card
;
114 struct net_device
*ndev
;
117 struct ccw_dev_id read_devid
;
120 memcpy(&temp_dev_no
, read_dev_no
, 2);
121 read_lock_irqsave(&qeth_core_card_list
.rwlock
, flags
);
122 list_for_each_entry(card
, &qeth_core_card_list
.list
, list
) {
123 ccw_device_get_id(CARD_RDEV(card
), &read_devid
);
124 if (read_devid
.devno
== temp_dev_no
) {
129 read_unlock_irqrestore(&qeth_core_card_list
.rwlock
, flags
);
133 static int qeth_l2_send_setgroupmac_cb(struct qeth_card
*card
,
134 struct qeth_reply
*reply
,
137 struct qeth_ipa_cmd
*cmd
;
140 QETH_CARD_TEXT(card
, 2, "L2Sgmacb");
141 cmd
= (struct qeth_ipa_cmd
*) data
;
142 mac
= &cmd
->data
.setdelmac
.mac
[0];
143 /* MAC already registered, needed in couple/uncouple case */
144 if (cmd
->hdr
.return_code
== IPA_RC_L2_DUP_MAC
) {
145 QETH_DBF_MESSAGE(2, "Group MAC %pM already existing on %s \n",
146 mac
, QETH_CARD_IFNAME(card
));
147 cmd
->hdr
.return_code
= 0;
149 if (cmd
->hdr
.return_code
)
150 QETH_DBF_MESSAGE(2, "Could not set group MAC %pM on %s: %x\n",
151 mac
, QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
155 static int qeth_l2_send_setgroupmac(struct qeth_card
*card
, __u8
*mac
)
157 QETH_CARD_TEXT(card
, 2, "L2Sgmac");
158 return qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_SETGMAC
,
159 qeth_l2_send_setgroupmac_cb
);
162 static int qeth_l2_send_delgroupmac_cb(struct qeth_card
*card
,
163 struct qeth_reply
*reply
,
166 struct qeth_ipa_cmd
*cmd
;
169 QETH_CARD_TEXT(card
, 2, "L2Dgmacb");
170 cmd
= (struct qeth_ipa_cmd
*) data
;
171 mac
= &cmd
->data
.setdelmac
.mac
[0];
172 if (cmd
->hdr
.return_code
)
173 QETH_DBF_MESSAGE(2, "Could not delete group MAC %pM on %s: %x\n",
174 mac
, QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
178 static int qeth_l2_send_delgroupmac(struct qeth_card
*card
, __u8
*mac
)
180 QETH_CARD_TEXT(card
, 2, "L2Dgmac");
181 return qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_DELGMAC
,
182 qeth_l2_send_delgroupmac_cb
);
185 static void qeth_l2_add_mc(struct qeth_card
*card
, __u8
*mac
, int vmac
)
187 struct qeth_mc_mac
*mc
;
190 mc
= kmalloc(sizeof(struct qeth_mc_mac
), GFP_ATOMIC
);
195 memcpy(mc
->mc_addr
, mac
, OSA_ADDR_LEN
);
196 mc
->mc_addrlen
= OSA_ADDR_LEN
;
200 rc
= qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_SETVMAC
,
203 rc
= qeth_l2_send_setgroupmac(card
, mac
);
207 list_add_tail(&mc
->list
, &card
->mc_list
);
212 static void qeth_l2_del_all_mc(struct qeth_card
*card
, int del
)
214 struct qeth_mc_mac
*mc
, *tmp
;
216 spin_lock_bh(&card
->mclock
);
217 list_for_each_entry_safe(mc
, tmp
, &card
->mc_list
, list
) {
220 qeth_l2_send_setdelmac(card
, mc
->mc_addr
,
221 IPA_CMD_DELVMAC
, NULL
);
223 qeth_l2_send_delgroupmac(card
, mc
->mc_addr
);
228 spin_unlock_bh(&card
->mclock
);
231 static inline int qeth_l2_get_cast_type(struct qeth_card
*card
,
234 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
236 if (is_broadcast_ether_addr(skb
->data
))
237 return RTN_BROADCAST
;
238 if (is_multicast_ether_addr(skb
->data
))
239 return RTN_MULTICAST
;
243 static void qeth_l2_fill_header(struct qeth_card
*card
, struct qeth_hdr
*hdr
,
244 struct sk_buff
*skb
, int ipv
, int cast_type
)
246 struct vlan_ethhdr
*veth
= (struct vlan_ethhdr
*)skb_mac_header(skb
);
248 memset(hdr
, 0, sizeof(struct qeth_hdr
));
249 hdr
->hdr
.l2
.id
= QETH_HEADER_TYPE_LAYER2
;
251 /* set byte byte 3 to casting flags */
252 if (cast_type
== RTN_MULTICAST
)
253 hdr
->hdr
.l2
.flags
[2] |= QETH_LAYER2_FLAG_MULTICAST
;
254 else if (cast_type
== RTN_BROADCAST
)
255 hdr
->hdr
.l2
.flags
[2] |= QETH_LAYER2_FLAG_BROADCAST
;
257 hdr
->hdr
.l2
.flags
[2] |= QETH_LAYER2_FLAG_UNICAST
;
259 hdr
->hdr
.l2
.pkt_length
= skb
->len
-QETH_HEADER_SIZE
;
260 /* VSWITCH relies on the VLAN
261 * information to be present in
263 if (veth
->h_vlan_proto
== __constant_htons(ETH_P_8021Q
)) {
264 hdr
->hdr
.l2
.flags
[2] |= QETH_LAYER2_FLAG_VLAN
;
265 hdr
->hdr
.l2
.vlan_id
= ntohs(veth
->h_vlan_TCI
);
269 static int qeth_l2_send_setdelvlan_cb(struct qeth_card
*card
,
270 struct qeth_reply
*reply
, unsigned long data
)
272 struct qeth_ipa_cmd
*cmd
;
274 QETH_CARD_TEXT(card
, 2, "L2sdvcb");
275 cmd
= (struct qeth_ipa_cmd
*) data
;
276 if (cmd
->hdr
.return_code
) {
277 QETH_DBF_MESSAGE(2, "Error in processing VLAN %i on %s: 0x%x. "
278 "Continuing\n", cmd
->data
.setdelvlan
.vlan_id
,
279 QETH_CARD_IFNAME(card
), cmd
->hdr
.return_code
);
280 QETH_CARD_TEXT_(card
, 2, "L2VL%4x", cmd
->hdr
.command
);
281 QETH_CARD_TEXT_(card
, 2, "err%d", cmd
->hdr
.return_code
);
286 static int qeth_l2_send_setdelvlan(struct qeth_card
*card
, __u16 i
,
287 enum qeth_ipa_cmds ipacmd
)
289 struct qeth_ipa_cmd
*cmd
;
290 struct qeth_cmd_buffer
*iob
;
292 QETH_CARD_TEXT_(card
, 4, "L2sdv%x", ipacmd
);
293 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
294 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
295 cmd
->data
.setdelvlan
.vlan_id
= i
;
296 return qeth_send_ipa_cmd(card
, iob
,
297 qeth_l2_send_setdelvlan_cb
, NULL
);
300 static void qeth_l2_process_vlans(struct qeth_card
*card
)
302 struct qeth_vlan_vid
*id
;
303 QETH_CARD_TEXT(card
, 3, "L2prcvln");
304 spin_lock_bh(&card
->vlanlock
);
305 list_for_each_entry(id
, &card
->vid_list
, list
) {
306 qeth_l2_send_setdelvlan(card
, id
->vid
, IPA_CMD_SETVLAN
);
308 spin_unlock_bh(&card
->vlanlock
);
311 static int qeth_l2_vlan_rx_add_vid(struct net_device
*dev
,
312 __be16 proto
, u16 vid
)
314 struct qeth_card
*card
= dev
->ml_priv
;
315 struct qeth_vlan_vid
*id
;
317 QETH_CARD_TEXT_(card
, 4, "aid:%d", vid
);
320 if (card
->info
.type
== QETH_CARD_TYPE_OSM
) {
321 QETH_CARD_TEXT(card
, 3, "aidOSM");
324 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
325 QETH_CARD_TEXT(card
, 3, "aidREC");
328 id
= kmalloc(sizeof(struct qeth_vlan_vid
), GFP_ATOMIC
);
331 qeth_l2_send_setdelvlan(card
, vid
, IPA_CMD_SETVLAN
);
332 spin_lock_bh(&card
->vlanlock
);
333 list_add_tail(&id
->list
, &card
->vid_list
);
334 spin_unlock_bh(&card
->vlanlock
);
341 static int qeth_l2_vlan_rx_kill_vid(struct net_device
*dev
,
342 __be16 proto
, u16 vid
)
344 struct qeth_vlan_vid
*id
, *tmpid
= NULL
;
345 struct qeth_card
*card
= dev
->ml_priv
;
347 QETH_CARD_TEXT_(card
, 4, "kid:%d", vid
);
348 if (card
->info
.type
== QETH_CARD_TYPE_OSM
) {
349 QETH_CARD_TEXT(card
, 3, "kidOSM");
352 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
353 QETH_CARD_TEXT(card
, 3, "kidREC");
356 spin_lock_bh(&card
->vlanlock
);
357 list_for_each_entry(id
, &card
->vid_list
, list
) {
358 if (id
->vid
== vid
) {
364 spin_unlock_bh(&card
->vlanlock
);
366 qeth_l2_send_setdelvlan(card
, vid
, IPA_CMD_DELVLAN
);
369 qeth_l2_set_multicast_list(card
->dev
);
373 static int qeth_l2_stop_card(struct qeth_card
*card
, int recovery_mode
)
377 QETH_DBF_TEXT(SETUP
, 2, "stopcard");
378 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
380 qeth_set_allowed_threads(card
, 0, 1);
381 if (card
->read
.state
== CH_STATE_UP
&&
382 card
->write
.state
== CH_STATE_UP
&&
383 (card
->state
== CARD_STATE_UP
)) {
385 card
->info
.type
!= QETH_CARD_TYPE_OSN
) {
386 qeth_l2_stop(card
->dev
);
389 dev_close(card
->dev
);
392 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
393 card
->state
= CARD_STATE_SOFTSETUP
;
395 if (card
->state
== CARD_STATE_SOFTSETUP
) {
396 qeth_l2_del_all_mc(card
, 0);
397 qeth_clear_ipacmd_list(card
);
398 card
->state
= CARD_STATE_HARDSETUP
;
400 if (card
->state
== CARD_STATE_HARDSETUP
) {
401 qeth_qdio_clear_card(card
, 0);
402 qeth_clear_qdio_buffers(card
);
403 qeth_clear_working_pool_list(card
);
404 card
->state
= CARD_STATE_DOWN
;
406 if (card
->state
== CARD_STATE_DOWN
) {
407 qeth_clear_cmd_buffers(&card
->read
);
408 qeth_clear_cmd_buffers(&card
->write
);
413 static int qeth_l2_process_inbound_buffer(struct qeth_card
*card
,
414 int budget
, int *done
)
418 struct qeth_hdr
*hdr
;
422 WARN_ON_ONCE(!budget
);
424 skb
= qeth_core_get_next_skb(card
,
425 &card
->qdio
.in_q
->bufs
[card
->rx
.b_index
],
426 &card
->rx
.b_element
, &card
->rx
.e_offset
, &hdr
);
431 skb
->dev
= card
->dev
;
432 switch (hdr
->hdr
.l2
.id
) {
433 case QETH_HEADER_TYPE_LAYER2
:
434 skb
->pkt_type
= PACKET_HOST
;
435 skb
->protocol
= eth_type_trans(skb
, skb
->dev
);
436 skb
->ip_summed
= CHECKSUM_NONE
;
437 if (skb
->protocol
== htons(ETH_P_802_2
))
438 *((__u32
*)skb
->cb
) = ++card
->seqno
.pkt_seqno
;
440 netif_receive_skb(skb
);
442 case QETH_HEADER_TYPE_OSN
:
443 if (card
->info
.type
== QETH_CARD_TYPE_OSN
) {
444 skb_push(skb
, sizeof(struct qeth_hdr
));
445 skb_copy_to_linear_data(skb
, hdr
,
446 sizeof(struct qeth_hdr
));
448 card
->osn_info
.data_cb(skb
);
453 dev_kfree_skb_any(skb
);
454 QETH_CARD_TEXT(card
, 3, "inbunkno");
455 QETH_DBF_HEX(CTRL
, 3, hdr
, QETH_DBF_CTRL_LEN
);
460 card
->stats
.rx_packets
++;
461 card
->stats
.rx_bytes
+= len
;
466 static int qeth_l2_poll(struct napi_struct
*napi
, int budget
)
468 struct qeth_card
*card
= container_of(napi
, struct qeth_card
, napi
);
470 struct qeth_qdio_buffer
*buffer
;
472 int new_budget
= budget
;
474 if (card
->options
.performance_stats
) {
475 card
->perf_stats
.inbound_cnt
++;
476 card
->perf_stats
.inbound_start_time
= qeth_get_micros();
480 if (!card
->rx
.b_count
) {
481 card
->rx
.qdio_err
= 0;
482 card
->rx
.b_count
= qdio_get_next_buffers(
483 card
->data
.ccwdev
, 0, &card
->rx
.b_index
,
485 if (card
->rx
.b_count
<= 0) {
486 card
->rx
.b_count
= 0;
490 &card
->qdio
.in_q
->bufs
[card
->rx
.b_index
]
492 card
->rx
.e_offset
= 0;
495 while (card
->rx
.b_count
) {
496 buffer
= &card
->qdio
.in_q
->bufs
[card
->rx
.b_index
];
497 if (!(card
->rx
.qdio_err
&&
498 qeth_check_qdio_errors(card
, buffer
->buffer
,
499 card
->rx
.qdio_err
, "qinerr")))
500 work_done
+= qeth_l2_process_inbound_buffer(
501 card
, new_budget
, &done
);
506 if (card
->options
.performance_stats
)
507 card
->perf_stats
.bufs_rec
++;
508 qeth_put_buffer_pool_entry(card
,
510 qeth_queue_input_buffer(card
, card
->rx
.b_index
);
512 if (card
->rx
.b_count
) {
514 (card
->rx
.b_index
+ 1) %
515 QDIO_MAX_BUFFERS_PER_Q
;
518 ->bufs
[card
->rx
.b_index
]
520 card
->rx
.e_offset
= 0;
524 if (work_done
>= budget
)
527 new_budget
= budget
- work_done
;
532 if (qdio_start_irq(card
->data
.ccwdev
, 0))
533 napi_schedule(&card
->napi
);
535 if (card
->options
.performance_stats
)
536 card
->perf_stats
.inbound_time
+= qeth_get_micros() -
537 card
->perf_stats
.inbound_start_time
;
541 static int qeth_l2_send_setdelmac(struct qeth_card
*card
, __u8
*mac
,
542 enum qeth_ipa_cmds ipacmd
,
543 int (*reply_cb
) (struct qeth_card
*,
547 struct qeth_ipa_cmd
*cmd
;
548 struct qeth_cmd_buffer
*iob
;
550 QETH_CARD_TEXT(card
, 2, "L2sdmac");
551 iob
= qeth_get_ipacmd_buffer(card
, ipacmd
, QETH_PROT_IPV4
);
552 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
553 cmd
->data
.setdelmac
.mac_length
= OSA_ADDR_LEN
;
554 memcpy(&cmd
->data
.setdelmac
.mac
, mac
, OSA_ADDR_LEN
);
555 return qeth_send_ipa_cmd(card
, iob
, reply_cb
, NULL
);
558 static int qeth_l2_send_setmac_cb(struct qeth_card
*card
,
559 struct qeth_reply
*reply
,
562 struct qeth_ipa_cmd
*cmd
;
564 QETH_CARD_TEXT(card
, 2, "L2Smaccb");
565 cmd
= (struct qeth_ipa_cmd
*) data
;
566 if (cmd
->hdr
.return_code
) {
567 QETH_CARD_TEXT_(card
, 2, "L2er%x", cmd
->hdr
.return_code
);
568 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
569 switch (cmd
->hdr
.return_code
) {
570 case IPA_RC_L2_DUP_MAC
:
571 case IPA_RC_L2_DUP_LAYER3_MAC
:
572 dev_warn(&card
->gdev
->dev
,
573 "MAC address %pM already exists\n",
574 cmd
->data
.setdelmac
.mac
);
576 case IPA_RC_L2_MAC_NOT_AUTH_BY_HYP
:
577 case IPA_RC_L2_MAC_NOT_AUTH_BY_ADP
:
578 dev_warn(&card
->gdev
->dev
,
579 "MAC address %pM is not authorized\n",
580 cmd
->data
.setdelmac
.mac
);
586 card
->info
.mac_bits
|= QETH_LAYER2_MAC_REGISTERED
;
587 memcpy(card
->dev
->dev_addr
, cmd
->data
.setdelmac
.mac
,
589 dev_info(&card
->gdev
->dev
,
590 "MAC address %pM successfully registered on device %s\n",
591 card
->dev
->dev_addr
, card
->dev
->name
);
596 static int qeth_l2_send_setmac(struct qeth_card
*card
, __u8
*mac
)
598 QETH_CARD_TEXT(card
, 2, "L2Setmac");
599 return qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_SETVMAC
,
600 qeth_l2_send_setmac_cb
);
603 static int qeth_l2_send_delmac_cb(struct qeth_card
*card
,
604 struct qeth_reply
*reply
,
607 struct qeth_ipa_cmd
*cmd
;
609 QETH_CARD_TEXT(card
, 2, "L2Dmaccb");
610 cmd
= (struct qeth_ipa_cmd
*) data
;
611 if (cmd
->hdr
.return_code
) {
612 QETH_CARD_TEXT_(card
, 2, "err%d", cmd
->hdr
.return_code
);
615 card
->info
.mac_bits
&= ~QETH_LAYER2_MAC_REGISTERED
;
620 static int qeth_l2_send_delmac(struct qeth_card
*card
, __u8
*mac
)
622 QETH_CARD_TEXT(card
, 2, "L2Delmac");
623 if (!(card
->info
.mac_bits
& QETH_LAYER2_MAC_REGISTERED
))
625 return qeth_l2_send_setdelmac(card
, mac
, IPA_CMD_DELVMAC
,
626 qeth_l2_send_delmac_cb
);
629 static int qeth_l2_request_initial_mac(struct qeth_card
*card
)
632 char vendor_pre
[] = {0x02, 0x00, 0x00};
634 QETH_DBF_TEXT(SETUP
, 2, "doL2init");
635 QETH_DBF_TEXT_(SETUP
, 2, "doL2%s", CARD_BUS_ID(card
));
637 if (qeth_is_supported(card
, IPA_SETADAPTERPARMS
)) {
638 rc
= qeth_query_setadapterparms(card
);
640 QETH_DBF_MESSAGE(2, "could not query adapter "
641 "parameters on device %s: x%x\n",
642 CARD_BUS_ID(card
), rc
);
646 if (card
->info
.type
== QETH_CARD_TYPE_IQD
||
647 card
->info
.type
== QETH_CARD_TYPE_OSM
||
648 card
->info
.type
== QETH_CARD_TYPE_OSX
||
649 card
->info
.guestlan
) {
650 rc
= qeth_setadpparms_change_macaddr(card
);
652 QETH_DBF_MESSAGE(2, "couldn't get MAC address on "
653 "device %s: x%x\n", CARD_BUS_ID(card
), rc
);
654 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
657 QETH_DBF_HEX(SETUP
, 2, card
->dev
->dev_addr
, OSA_ADDR_LEN
);
659 eth_random_addr(card
->dev
->dev_addr
);
660 memcpy(card
->dev
->dev_addr
, vendor_pre
, 3);
665 static int qeth_l2_set_mac_address(struct net_device
*dev
, void *p
)
667 struct sockaddr
*addr
= p
;
668 struct qeth_card
*card
= dev
->ml_priv
;
671 QETH_CARD_TEXT(card
, 3, "setmac");
673 if (qeth_l2_verify_dev(dev
) != QETH_REAL_CARD
) {
674 QETH_CARD_TEXT(card
, 3, "setmcINV");
678 if (card
->info
.type
== QETH_CARD_TYPE_OSN
||
679 card
->info
.type
== QETH_CARD_TYPE_OSM
||
680 card
->info
.type
== QETH_CARD_TYPE_OSX
) {
681 QETH_CARD_TEXT(card
, 3, "setmcTYP");
684 QETH_CARD_HEX(card
, 3, addr
->sa_data
, OSA_ADDR_LEN
);
685 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
686 QETH_CARD_TEXT(card
, 3, "setmcREC");
689 rc
= qeth_l2_send_delmac(card
, &card
->dev
->dev_addr
[0]);
690 if (!rc
|| (rc
== IPA_RC_L2_MAC_NOT_FOUND
))
691 rc
= qeth_l2_send_setmac(card
, addr
->sa_data
);
692 return rc
? -EINVAL
: 0;
695 static void qeth_l2_set_multicast_list(struct net_device
*dev
)
697 struct qeth_card
*card
= dev
->ml_priv
;
698 struct netdev_hw_addr
*ha
;
700 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
703 QETH_CARD_TEXT(card
, 3, "setmulti");
704 if (qeth_threads_running(card
, QETH_RECOVER_THREAD
) &&
705 (card
->state
!= CARD_STATE_UP
))
707 qeth_l2_del_all_mc(card
, 1);
708 spin_lock_bh(&card
->mclock
);
709 netdev_for_each_mc_addr(ha
, dev
)
710 qeth_l2_add_mc(card
, ha
->addr
, 0);
712 netdev_for_each_uc_addr(ha
, dev
)
713 qeth_l2_add_mc(card
, ha
->addr
, 1);
715 spin_unlock_bh(&card
->mclock
);
716 if (!qeth_adp_supported(card
, IPA_SETADP_SET_PROMISC_MODE
))
718 qeth_setadp_promisc_mode(card
);
721 static int qeth_l2_hard_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
724 struct qeth_hdr
*hdr
= NULL
;
726 struct qeth_card
*card
= dev
->ml_priv
;
727 struct sk_buff
*new_skb
= skb
;
728 int ipv
= qeth_get_ip_version(skb
);
729 int cast_type
= qeth_l2_get_cast_type(card
, skb
);
730 struct qeth_qdio_out_q
*queue
= card
->qdio
.out_qs
731 [qeth_get_priority_queue(card
, skb
, ipv
, cast_type
)];
732 int tx_bytes
= skb
->len
;
733 int data_offset
= -1;
734 int elements_needed
= 0;
737 if ((card
->state
!= CARD_STATE_UP
) || !card
->lan_online
) {
738 card
->stats
.tx_carrier_errors
++;
742 if ((card
->info
.type
== QETH_CARD_TYPE_OSN
) &&
743 (skb
->protocol
== htons(ETH_P_IPV6
)))
746 if (card
->options
.performance_stats
) {
747 card
->perf_stats
.outbound_cnt
++;
748 card
->perf_stats
.outbound_start_time
= qeth_get_micros();
750 netif_stop_queue(dev
);
752 if (card
->info
.type
== QETH_CARD_TYPE_OSN
)
753 hdr
= (struct qeth_hdr
*)skb
->data
;
755 if (card
->info
.type
== QETH_CARD_TYPE_IQD
) {
757 data_offset
= ETH_HLEN
;
759 hdr
= kmem_cache_alloc(qeth_core_header_cache
,
764 skb_reset_mac_header(new_skb
);
765 qeth_l2_fill_header(card
, hdr
, new_skb
, ipv
, cast_type
);
766 hdr
->hdr
.l2
.pkt_length
= new_skb
->len
;
767 memcpy(((char *)hdr
) + sizeof(struct qeth_hdr
),
768 skb_mac_header(new_skb
), ETH_HLEN
);
770 /* create a clone with writeable headroom */
771 new_skb
= skb_realloc_headroom(skb
,
772 sizeof(struct qeth_hdr
));
775 hdr
= (struct qeth_hdr
*)skb_push(new_skb
,
776 sizeof(struct qeth_hdr
));
777 skb_set_mac_header(new_skb
, sizeof(struct qeth_hdr
));
778 qeth_l2_fill_header(card
, hdr
, new_skb
, ipv
, cast_type
);
782 elements
= qeth_get_elements_no(card
, new_skb
, elements_needed
);
784 if (data_offset
>= 0)
785 kmem_cache_free(qeth_core_header_cache
, hdr
);
789 if (card
->info
.type
!= QETH_CARD_TYPE_IQD
) {
790 if (qeth_hdr_chk_and_bounce(new_skb
, &hdr
,
791 sizeof(struct qeth_hdr_layer2
)))
793 rc
= qeth_do_send_packet(card
, queue
, new_skb
, hdr
,
796 rc
= qeth_do_send_packet_fast(card
, queue
, new_skb
, hdr
,
797 elements
, data_offset
, hd_len
);
799 card
->stats
.tx_packets
++;
800 card
->stats
.tx_bytes
+= tx_bytes
;
802 dev_kfree_skb_any(skb
);
805 if (data_offset
>= 0)
806 kmem_cache_free(qeth_core_header_cache
, hdr
);
810 dev_kfree_skb_any(new_skb
);
811 return NETDEV_TX_BUSY
;
816 netif_wake_queue(dev
);
817 if (card
->options
.performance_stats
)
818 card
->perf_stats
.outbound_time
+= qeth_get_micros() -
819 card
->perf_stats
.outbound_start_time
;
823 card
->stats
.tx_dropped
++;
824 card
->stats
.tx_errors
++;
825 if ((new_skb
!= skb
) && new_skb
)
826 dev_kfree_skb_any(new_skb
);
827 dev_kfree_skb_any(skb
);
828 netif_wake_queue(dev
);
832 static int __qeth_l2_open(struct net_device
*dev
)
834 struct qeth_card
*card
= dev
->ml_priv
;
837 QETH_CARD_TEXT(card
, 4, "qethopen");
838 if (card
->state
== CARD_STATE_UP
)
840 if (card
->state
!= CARD_STATE_SOFTSETUP
)
843 if ((card
->info
.type
!= QETH_CARD_TYPE_OSN
) &&
844 (!(card
->info
.mac_bits
& QETH_LAYER2_MAC_REGISTERED
))) {
845 QETH_CARD_TEXT(card
, 4, "nomacadr");
848 card
->data
.state
= CH_STATE_UP
;
849 card
->state
= CARD_STATE_UP
;
850 netif_start_queue(dev
);
852 if (qdio_stop_irq(card
->data
.ccwdev
, 0) >= 0) {
853 napi_enable(&card
->napi
);
854 napi_schedule(&card
->napi
);
860 static int qeth_l2_open(struct net_device
*dev
)
862 struct qeth_card
*card
= dev
->ml_priv
;
864 QETH_CARD_TEXT(card
, 5, "qethope_");
865 if (qeth_wait_for_threads(card
, QETH_RECOVER_THREAD
)) {
866 QETH_CARD_TEXT(card
, 3, "openREC");
869 return __qeth_l2_open(dev
);
872 static int qeth_l2_stop(struct net_device
*dev
)
874 struct qeth_card
*card
= dev
->ml_priv
;
876 QETH_CARD_TEXT(card
, 4, "qethstop");
877 netif_tx_disable(dev
);
878 if (card
->state
== CARD_STATE_UP
) {
879 card
->state
= CARD_STATE_SOFTSETUP
;
880 napi_disable(&card
->napi
);
885 static int qeth_l2_probe_device(struct ccwgroup_device
*gdev
)
887 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
889 qeth_l2_create_device_attributes(&gdev
->dev
);
890 INIT_LIST_HEAD(&card
->vid_list
);
891 INIT_LIST_HEAD(&card
->mc_list
);
892 card
->options
.layer2
= 1;
893 card
->info
.hwtrap
= 0;
897 static void qeth_l2_remove_device(struct ccwgroup_device
*cgdev
)
899 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
901 qeth_l2_remove_device_attributes(&cgdev
->dev
);
902 qeth_set_allowed_threads(card
, 0, 1);
903 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
905 if (cgdev
->state
== CCWGROUP_ONLINE
)
906 qeth_l2_set_offline(cgdev
);
909 unregister_netdev(card
->dev
);
915 static const struct ethtool_ops qeth_l2_ethtool_ops
= {
916 .get_link
= ethtool_op_get_link
,
917 .get_strings
= qeth_core_get_strings
,
918 .get_ethtool_stats
= qeth_core_get_ethtool_stats
,
919 .get_sset_count
= qeth_core_get_sset_count
,
920 .get_drvinfo
= qeth_core_get_drvinfo
,
921 .get_settings
= qeth_core_ethtool_get_settings
,
924 static const struct ethtool_ops qeth_l2_osn_ops
= {
925 .get_strings
= qeth_core_get_strings
,
926 .get_ethtool_stats
= qeth_core_get_ethtool_stats
,
927 .get_sset_count
= qeth_core_get_sset_count
,
928 .get_drvinfo
= qeth_core_get_drvinfo
,
931 static const struct net_device_ops qeth_l2_netdev_ops
= {
932 .ndo_open
= qeth_l2_open
,
933 .ndo_stop
= qeth_l2_stop
,
934 .ndo_get_stats
= qeth_get_stats
,
935 .ndo_start_xmit
= qeth_l2_hard_start_xmit
,
936 .ndo_validate_addr
= eth_validate_addr
,
937 .ndo_set_rx_mode
= qeth_l2_set_multicast_list
,
938 .ndo_do_ioctl
= qeth_l2_do_ioctl
,
939 .ndo_set_mac_address
= qeth_l2_set_mac_address
,
940 .ndo_change_mtu
= qeth_change_mtu
,
941 .ndo_vlan_rx_add_vid
= qeth_l2_vlan_rx_add_vid
,
942 .ndo_vlan_rx_kill_vid
= qeth_l2_vlan_rx_kill_vid
,
943 .ndo_tx_timeout
= qeth_tx_timeout
,
946 static int qeth_l2_setup_netdev(struct qeth_card
*card
)
948 switch (card
->info
.type
) {
949 case QETH_CARD_TYPE_IQD
:
950 card
->dev
= alloc_netdev(0, "hsi%d", ether_setup
);
952 case QETH_CARD_TYPE_OSN
:
953 card
->dev
= alloc_netdev(0, "osn%d", ether_setup
);
954 card
->dev
->flags
|= IFF_NOARP
;
957 card
->dev
= alloc_etherdev(0);
963 card
->dev
->ml_priv
= card
;
964 card
->dev
->watchdog_timeo
= QETH_TX_TIMEOUT
;
965 card
->dev
->mtu
= card
->info
.initial_mtu
;
966 card
->dev
->netdev_ops
= &qeth_l2_netdev_ops
;
967 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
)
968 SET_ETHTOOL_OPS(card
->dev
, &qeth_l2_ethtool_ops
);
970 SET_ETHTOOL_OPS(card
->dev
, &qeth_l2_osn_ops
);
971 card
->dev
->features
|= NETIF_F_HW_VLAN_CTAG_FILTER
;
972 card
->info
.broadcast_capable
= 1;
973 qeth_l2_request_initial_mac(card
);
974 SET_NETDEV_DEV(card
->dev
, &card
->gdev
->dev
);
975 netif_napi_add(card
->dev
, &card
->napi
, qeth_l2_poll
, QETH_NAPI_WEIGHT
);
976 return register_netdev(card
->dev
);
979 static int __qeth_l2_set_online(struct ccwgroup_device
*gdev
, int recovery_mode
)
981 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
983 enum qeth_card_states recover_flag
;
985 mutex_lock(&card
->discipline_mutex
);
986 mutex_lock(&card
->conf_mutex
);
987 QETH_DBF_TEXT(SETUP
, 2, "setonlin");
988 QETH_DBF_HEX(SETUP
, 2, &card
, sizeof(void *));
990 recover_flag
= card
->state
;
991 rc
= qeth_core_hardsetup_card(card
);
993 QETH_DBF_TEXT_(SETUP
, 2, "2err%d", rc
);
997 qeth_bridgeport_query_support(card
);
998 if (card
->options
.sbp
.supported_funcs
)
999 dev_info(&card
->gdev
->dev
,
1000 "The device represents a HiperSockets Bridge Capable Port\n");
1001 qeth_trace_features(card
);
1003 if (!card
->dev
&& qeth_l2_setup_netdev(card
)) {
1008 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
)
1009 qeth_l2_send_setmac(card
, &card
->dev
->dev_addr
[0]);
1011 if (qeth_is_diagass_supported(card
, QETH_DIAGS_CMD_TRAP
)) {
1012 if (card
->info
.hwtrap
&&
1013 qeth_hw_trap(card
, QETH_DIAGS_TRAP_ARM
))
1014 card
->info
.hwtrap
= 0;
1016 card
->info
.hwtrap
= 0;
1018 qeth_l2_setup_bridgeport_attrs(card
);
1020 card
->state
= CARD_STATE_HARDSETUP
;
1021 memset(&card
->rx
, 0, sizeof(struct qeth_rx
));
1022 qeth_print_status_message(card
);
1025 QETH_DBF_TEXT(SETUP
, 2, "softsetp");
1027 rc
= qeth_send_startlan(card
);
1029 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
1031 dev_warn(&card
->gdev
->dev
,
1032 "The LAN is offline\n");
1033 card
->lan_online
= 0;
1039 card
->lan_online
= 1;
1042 if ((card
->info
.type
== QETH_CARD_TYPE_OSD
) ||
1043 (card
->info
.type
== QETH_CARD_TYPE_OSX
)) {
1044 /* configure isolation level */
1045 rc
= qeth_set_access_ctrl_online(card
, 0);
1052 if (card
->info
.type
!= QETH_CARD_TYPE_OSN
&&
1053 card
->info
.type
!= QETH_CARD_TYPE_OSM
)
1054 qeth_l2_process_vlans(card
);
1056 netif_tx_disable(card
->dev
);
1058 rc
= qeth_init_qdio_queues(card
);
1060 QETH_DBF_TEXT_(SETUP
, 2, "6err%d", rc
);
1064 card
->state
= CARD_STATE_SOFTSETUP
;
1065 if (card
->lan_online
)
1066 netif_carrier_on(card
->dev
);
1068 netif_carrier_off(card
->dev
);
1070 qeth_set_allowed_threads(card
, 0xffffffff, 0);
1071 if (recover_flag
== CARD_STATE_RECOVER
) {
1072 if (recovery_mode
&&
1073 card
->info
.type
!= QETH_CARD_TYPE_OSN
) {
1074 __qeth_l2_open(card
->dev
);
1077 dev_open(card
->dev
);
1080 /* this also sets saved unicast addresses */
1081 qeth_l2_set_multicast_list(card
->dev
);
1083 /* let user_space know that device is online */
1084 kobject_uevent(&gdev
->dev
.kobj
, KOBJ_CHANGE
);
1085 mutex_unlock(&card
->conf_mutex
);
1086 mutex_unlock(&card
->discipline_mutex
);
1090 qeth_l2_stop_card(card
, 0);
1091 ccw_device_set_offline(CARD_DDEV(card
));
1092 ccw_device_set_offline(CARD_WDEV(card
));
1093 ccw_device_set_offline(CARD_RDEV(card
));
1094 if (recover_flag
== CARD_STATE_RECOVER
)
1095 card
->state
= CARD_STATE_RECOVER
;
1097 card
->state
= CARD_STATE_DOWN
;
1098 mutex_unlock(&card
->conf_mutex
);
1099 mutex_unlock(&card
->discipline_mutex
);
1103 static int qeth_l2_set_online(struct ccwgroup_device
*gdev
)
1105 return __qeth_l2_set_online(gdev
, 0);
1108 static int __qeth_l2_set_offline(struct ccwgroup_device
*cgdev
,
1111 struct qeth_card
*card
= dev_get_drvdata(&cgdev
->dev
);
1112 int rc
= 0, rc2
= 0, rc3
= 0;
1113 enum qeth_card_states recover_flag
;
1115 mutex_lock(&card
->discipline_mutex
);
1116 mutex_lock(&card
->conf_mutex
);
1117 QETH_DBF_TEXT(SETUP
, 3, "setoffl");
1118 QETH_DBF_HEX(SETUP
, 3, &card
, sizeof(void *));
1120 if (card
->dev
&& netif_carrier_ok(card
->dev
))
1121 netif_carrier_off(card
->dev
);
1122 recover_flag
= card
->state
;
1123 if ((!recovery_mode
&& card
->info
.hwtrap
) || card
->info
.hwtrap
== 2) {
1124 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
1125 card
->info
.hwtrap
= 1;
1127 qeth_l2_stop_card(card
, recovery_mode
);
1128 rc
= ccw_device_set_offline(CARD_DDEV(card
));
1129 rc2
= ccw_device_set_offline(CARD_WDEV(card
));
1130 rc3
= ccw_device_set_offline(CARD_RDEV(card
));
1132 rc
= (rc2
) ? rc2
: rc3
;
1134 QETH_DBF_TEXT_(SETUP
, 2, "1err%d", rc
);
1135 if (recover_flag
== CARD_STATE_UP
)
1136 card
->state
= CARD_STATE_RECOVER
;
1137 /* let user_space know that device is offline */
1138 kobject_uevent(&cgdev
->dev
.kobj
, KOBJ_CHANGE
);
1139 mutex_unlock(&card
->conf_mutex
);
1140 mutex_unlock(&card
->discipline_mutex
);
1144 static int qeth_l2_set_offline(struct ccwgroup_device
*cgdev
)
1146 return __qeth_l2_set_offline(cgdev
, 0);
1149 static int qeth_l2_recover(void *ptr
)
1151 struct qeth_card
*card
;
1154 card
= (struct qeth_card
*) ptr
;
1155 QETH_CARD_TEXT(card
, 2, "recover1");
1156 if (!qeth_do_run_thread(card
, QETH_RECOVER_THREAD
))
1158 QETH_CARD_TEXT(card
, 2, "recover2");
1159 dev_warn(&card
->gdev
->dev
,
1160 "A recovery process has been started for the device\n");
1161 qeth_set_recovery_task(card
);
1162 __qeth_l2_set_offline(card
->gdev
, 1);
1163 rc
= __qeth_l2_set_online(card
->gdev
, 1);
1165 dev_info(&card
->gdev
->dev
,
1166 "Device successfully recovered!\n");
1168 qeth_close_dev(card
);
1169 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
1170 "failed to recover an error on the device\n");
1172 qeth_clear_recovery_task(card
);
1173 qeth_clear_thread_start_bit(card
, QETH_RECOVER_THREAD
);
1174 qeth_clear_thread_running_bit(card
, QETH_RECOVER_THREAD
);
1178 static int __init
qeth_l2_init(void)
1180 pr_info("register layer 2 discipline\n");
1184 static void __exit
qeth_l2_exit(void)
1186 pr_info("unregister layer 2 discipline\n");
1189 static void qeth_l2_shutdown(struct ccwgroup_device
*gdev
)
1191 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
1192 qeth_set_allowed_threads(card
, 0, 1);
1193 if ((gdev
->state
== CCWGROUP_ONLINE
) && card
->info
.hwtrap
)
1194 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
1195 qeth_qdio_clear_card(card
, 0);
1196 qeth_clear_qdio_buffers(card
);
1199 static int qeth_l2_pm_suspend(struct ccwgroup_device
*gdev
)
1201 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
1204 netif_device_detach(card
->dev
);
1205 qeth_set_allowed_threads(card
, 0, 1);
1206 wait_event(card
->wait_q
, qeth_threads_running(card
, 0xffffffff) == 0);
1207 if (gdev
->state
== CCWGROUP_OFFLINE
)
1209 if (card
->state
== CARD_STATE_UP
) {
1210 if (card
->info
.hwtrap
)
1211 qeth_hw_trap(card
, QETH_DIAGS_TRAP_DISARM
);
1212 __qeth_l2_set_offline(card
->gdev
, 1);
1214 __qeth_l2_set_offline(card
->gdev
, 0);
1218 static int qeth_l2_pm_resume(struct ccwgroup_device
*gdev
)
1220 struct qeth_card
*card
= dev_get_drvdata(&gdev
->dev
);
1223 if (gdev
->state
== CCWGROUP_OFFLINE
)
1226 if (card
->state
== CARD_STATE_RECOVER
) {
1227 rc
= __qeth_l2_set_online(card
->gdev
, 1);
1230 dev_close(card
->dev
);
1234 rc
= __qeth_l2_set_online(card
->gdev
, 0);
1236 qeth_set_allowed_threads(card
, 0xffffffff, 0);
1238 netif_device_attach(card
->dev
);
1240 dev_warn(&card
->gdev
->dev
, "The qeth device driver "
1241 "failed to recover an error on the device\n");
1245 /* Returns zero if the command is successfully "consumed" */
1246 static int qeth_l2_control_event(struct qeth_card
*card
,
1247 struct qeth_ipa_cmd
*cmd
)
1249 switch (cmd
->hdr
.command
) {
1250 case IPA_CMD_SETBRIDGEPORT
:
1251 if (cmd
->data
.sbp
.hdr
.command_code
==
1252 IPA_SBP_BRIDGE_PORT_STATE_CHANGE
) {
1253 qeth_bridge_state_change(card
, cmd
);
1257 case IPA_CMD_ADDRESS_CHANGE_NOTIF
:
1258 qeth_bridge_host_event(card
, cmd
);
1265 struct qeth_discipline qeth_l2_discipline
= {
1266 .start_poll
= qeth_qdio_start_poll
,
1267 .input_handler
= (qdio_handler_t
*) qeth_qdio_input_handler
,
1268 .output_handler
= (qdio_handler_t
*) qeth_qdio_output_handler
,
1269 .recover
= qeth_l2_recover
,
1270 .setup
= qeth_l2_probe_device
,
1271 .remove
= qeth_l2_remove_device
,
1272 .set_online
= qeth_l2_set_online
,
1273 .set_offline
= qeth_l2_set_offline
,
1274 .shutdown
= qeth_l2_shutdown
,
1275 .freeze
= qeth_l2_pm_suspend
,
1276 .thaw
= qeth_l2_pm_resume
,
1277 .restore
= qeth_l2_pm_resume
,
1278 .control_event_handler
= qeth_l2_control_event
,
1280 EXPORT_SYMBOL_GPL(qeth_l2_discipline
);
1282 static int qeth_osn_send_control_data(struct qeth_card
*card
, int len
,
1283 struct qeth_cmd_buffer
*iob
)
1285 unsigned long flags
;
1288 QETH_CARD_TEXT(card
, 5, "osndctrd");
1290 wait_event(card
->wait_q
,
1291 atomic_cmpxchg(&card
->write
.irq_pending
, 0, 1) == 0);
1292 qeth_prepare_control_data(card
, len
, iob
);
1293 QETH_CARD_TEXT(card
, 6, "osnoirqp");
1294 spin_lock_irqsave(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1295 rc
= ccw_device_start(card
->write
.ccwdev
, &card
->write
.ccw
,
1296 (addr_t
) iob
, 0, 0);
1297 spin_unlock_irqrestore(get_ccwdev_lock(card
->write
.ccwdev
), flags
);
1299 QETH_DBF_MESSAGE(2, "qeth_osn_send_control_data: "
1300 "ccw_device_start rc = %i\n", rc
);
1301 QETH_CARD_TEXT_(card
, 2, " err%d", rc
);
1302 qeth_release_buffer(iob
->channel
, iob
);
1303 atomic_set(&card
->write
.irq_pending
, 0);
1304 wake_up(&card
->wait_q
);
1309 static int qeth_osn_send_ipa_cmd(struct qeth_card
*card
,
1310 struct qeth_cmd_buffer
*iob
, int data_len
)
1314 QETH_CARD_TEXT(card
, 4, "osndipa");
1316 qeth_prepare_ipa_cmd(card
, iob
, QETH_PROT_OSN2
);
1317 s1
= (u16
)(IPA_PDU_HEADER_SIZE
+ data_len
);
1319 memcpy(QETH_IPA_PDU_LEN_TOTAL(iob
->data
), &s1
, 2);
1320 memcpy(QETH_IPA_PDU_LEN_PDU1(iob
->data
), &s2
, 2);
1321 memcpy(QETH_IPA_PDU_LEN_PDU2(iob
->data
), &s2
, 2);
1322 memcpy(QETH_IPA_PDU_LEN_PDU3(iob
->data
), &s2
, 2);
1323 return qeth_osn_send_control_data(card
, s1
, iob
);
1326 int qeth_osn_assist(struct net_device
*dev
, void *data
, int data_len
)
1328 struct qeth_cmd_buffer
*iob
;
1329 struct qeth_card
*card
;
1334 card
= dev
->ml_priv
;
1337 QETH_CARD_TEXT(card
, 2, "osnsdmc");
1338 if ((card
->state
!= CARD_STATE_UP
) &&
1339 (card
->state
!= CARD_STATE_SOFTSETUP
))
1341 iob
= qeth_wait_for_buffer(&card
->write
);
1342 memcpy(iob
->data
+IPA_PDU_HEADER_SIZE
, data
, data_len
);
1343 rc
= qeth_osn_send_ipa_cmd(card
, iob
, data_len
);
1346 EXPORT_SYMBOL(qeth_osn_assist
);
1348 int qeth_osn_register(unsigned char *read_dev_no
, struct net_device
**dev
,
1349 int (*assist_cb
)(struct net_device
*, void *),
1350 int (*data_cb
)(struct sk_buff
*))
1352 struct qeth_card
*card
;
1354 *dev
= qeth_l2_netdev_by_devno(read_dev_no
);
1357 card
= (*dev
)->ml_priv
;
1360 QETH_CARD_TEXT(card
, 2, "osnreg");
1361 if ((assist_cb
== NULL
) || (data_cb
== NULL
))
1363 card
->osn_info
.assist_cb
= assist_cb
;
1364 card
->osn_info
.data_cb
= data_cb
;
1367 EXPORT_SYMBOL(qeth_osn_register
);
1369 void qeth_osn_deregister(struct net_device
*dev
)
1371 struct qeth_card
*card
;
1375 card
= dev
->ml_priv
;
1378 QETH_CARD_TEXT(card
, 2, "osndereg");
1379 card
->osn_info
.assist_cb
= NULL
;
1380 card
->osn_info
.data_cb
= NULL
;
1383 EXPORT_SYMBOL(qeth_osn_deregister
);
1385 /* SETBRIDGEPORT support, async notifications */
1387 enum qeth_an_event_type
{anev_reg_unreg
, anev_abort
, anev_reset
};
1390 * qeth_bridge_emit_host_event() - bridgeport address change notification
1391 * @card: qeth_card structure pointer, for udev events.
1392 * @evtype: "normal" register/unregister, or abort, or reset. For abort
1393 * and reset token and addr_lnid are unused and may be NULL.
1394 * @code: event bitmask: high order bit 0x80 value 1 means removal of an
1395 * object, 0 - addition of an object.
1396 * 0x01 - VLAN, 0x02 - MAC, 0x03 - VLAN and MAC.
1397 * @token: "network token" structure identifying physical address of the port.
1398 * @addr_lnid: pointer to structure with MAC address and VLAN ID.
1400 * This function is called when registrations and deregistrations are
1401 * reported by the hardware, and also when notifications are enabled -
1402 * for all currently registered addresses.
1404 static void qeth_bridge_emit_host_event(struct qeth_card
*card
,
1405 enum qeth_an_event_type evtype
,
1406 u8 code
, struct net_if_token
*token
, struct mac_addr_lnid
*addr_lnid
)
1413 case anev_reg_unreg
:
1414 snprintf(str
[i
], sizeof(str
[i
]), "BRIDGEDHOST=%s",
1415 (code
& IPA_ADDR_CHANGE_CODE_REMOVAL
)
1416 ? "deregister" : "register");
1417 env
[i
] = str
[i
]; i
++;
1418 if (code
& IPA_ADDR_CHANGE_CODE_VLANID
) {
1419 snprintf(str
[i
], sizeof(str
[i
]), "VLAN=%d",
1421 env
[i
] = str
[i
]; i
++;
1423 if (code
& IPA_ADDR_CHANGE_CODE_MACADDR
) {
1424 snprintf(str
[i
], sizeof(str
[i
]), "MAC=%pM6",
1426 env
[i
] = str
[i
]; i
++;
1428 snprintf(str
[i
], sizeof(str
[i
]), "NTOK_BUSID=%x.%x.%04x",
1429 token
->cssid
, token
->ssid
, token
->devnum
);
1430 env
[i
] = str
[i
]; i
++;
1431 snprintf(str
[i
], sizeof(str
[i
]), "NTOK_IID=%02x", token
->iid
);
1432 env
[i
] = str
[i
]; i
++;
1433 snprintf(str
[i
], sizeof(str
[i
]), "NTOK_CHPID=%02x",
1435 env
[i
] = str
[i
]; i
++;
1436 snprintf(str
[i
], sizeof(str
[i
]), "NTOK_CHID=%04x", token
->chid
);
1437 env
[i
] = str
[i
]; i
++;
1440 snprintf(str
[i
], sizeof(str
[i
]), "BRIDGEDHOST=abort");
1441 env
[i
] = str
[i
]; i
++;
1444 snprintf(str
[i
], sizeof(str
[i
]), "BRIDGEDHOST=reset");
1445 env
[i
] = str
[i
]; i
++;
1449 kobject_uevent_env(&card
->gdev
->dev
.kobj
, KOBJ_CHANGE
, env
);
1452 struct qeth_bridge_state_data
{
1453 struct work_struct worker
;
1454 struct qeth_card
*card
;
1455 struct qeth_sbp_state_change qports
;
1458 static void qeth_bridge_state_change_worker(struct work_struct
*work
)
1460 struct qeth_bridge_state_data
*data
=
1461 container_of(work
, struct qeth_bridge_state_data
, worker
);
1462 /* We are only interested in the first entry - local port */
1463 struct qeth_sbp_port_entry
*entry
= &data
->qports
.entry
[0];
1464 char env_locrem
[32];
1474 /* Role should not change by itself, but if it did, */
1475 /* information from the hardware is authoritative. */
1476 mutex_lock(&data
->card
->conf_mutex
);
1477 data
->card
->options
.sbp
.role
= entry
->role
;
1478 mutex_unlock(&data
->card
->conf_mutex
);
1480 snprintf(env_locrem
, sizeof(env_locrem
), "BRIDGEPORT=statechange");
1481 snprintf(env_role
, sizeof(env_role
), "ROLE=%s",
1482 (entry
->role
== QETH_SBP_ROLE_NONE
) ? "none" :
1483 (entry
->role
== QETH_SBP_ROLE_PRIMARY
) ? "primary" :
1484 (entry
->role
== QETH_SBP_ROLE_SECONDARY
) ? "secondary" :
1486 snprintf(env_state
, sizeof(env_state
), "STATE=%s",
1487 (entry
->state
== QETH_SBP_STATE_INACTIVE
) ? "inactive" :
1488 (entry
->state
== QETH_SBP_STATE_STANDBY
) ? "standby" :
1489 (entry
->state
== QETH_SBP_STATE_ACTIVE
) ? "active" :
1491 kobject_uevent_env(&data
->card
->gdev
->dev
.kobj
,
1496 static void qeth_bridge_state_change(struct qeth_card
*card
,
1497 struct qeth_ipa_cmd
*cmd
)
1499 struct qeth_sbp_state_change
*qports
=
1500 &cmd
->data
.sbp
.data
.state_change
;
1501 struct qeth_bridge_state_data
*data
;
1504 QETH_CARD_TEXT(card
, 2, "brstchng");
1505 if (qports
->entry_length
!= sizeof(struct qeth_sbp_port_entry
)) {
1506 QETH_CARD_TEXT_(card
, 2, "BPsz%.8d", qports
->entry_length
);
1509 extrasize
= sizeof(struct qeth_sbp_port_entry
) * qports
->num_entries
;
1510 data
= kzalloc(sizeof(struct qeth_bridge_state_data
) + extrasize
,
1513 QETH_CARD_TEXT(card
, 2, "BPSalloc");
1516 INIT_WORK(&data
->worker
, qeth_bridge_state_change_worker
);
1518 memcpy(&data
->qports
, qports
,
1519 sizeof(struct qeth_sbp_state_change
) + extrasize
);
1520 queue_work(qeth_wq
, &data
->worker
);
1523 struct qeth_bridge_host_data
{
1524 struct work_struct worker
;
1525 struct qeth_card
*card
;
1526 struct qeth_ipacmd_addr_change hostevs
;
1529 static void qeth_bridge_host_event_worker(struct work_struct
*work
)
1531 struct qeth_bridge_host_data
*data
=
1532 container_of(work
, struct qeth_bridge_host_data
, worker
);
1535 if (data
->hostevs
.lost_event_mask
) {
1536 dev_info(&data
->card
->gdev
->dev
,
1537 "Address notification from the HiperSockets Bridge Port stopped %s (%s)\n",
1538 data
->card
->dev
->name
,
1539 (data
->hostevs
.lost_event_mask
== 0x01)
1541 : (data
->hostevs
.lost_event_mask
== 0x02)
1542 ? "Bridge port state change"
1543 : "Unknown reason");
1544 mutex_lock(&data
->card
->conf_mutex
);
1545 data
->card
->options
.sbp
.hostnotification
= 0;
1546 mutex_unlock(&data
->card
->conf_mutex
);
1547 qeth_bridge_emit_host_event(data
->card
, anev_abort
,
1550 for (i
= 0; i
< data
->hostevs
.num_entries
; i
++) {
1551 struct qeth_ipacmd_addr_change_entry
*entry
=
1552 &data
->hostevs
.entry
[i
];
1553 qeth_bridge_emit_host_event(data
->card
,
1556 &entry
->token
, &entry
->addr_lnid
);
1561 static void qeth_bridge_host_event(struct qeth_card
*card
,
1562 struct qeth_ipa_cmd
*cmd
)
1564 struct qeth_ipacmd_addr_change
*hostevs
=
1565 &cmd
->data
.addrchange
;
1566 struct qeth_bridge_host_data
*data
;
1569 QETH_CARD_TEXT(card
, 2, "brhostev");
1570 if (cmd
->hdr
.return_code
!= 0x0000) {
1571 if (cmd
->hdr
.return_code
== 0x0010) {
1572 if (hostevs
->lost_event_mask
== 0x00)
1573 hostevs
->lost_event_mask
= 0xff;
1575 QETH_CARD_TEXT_(card
, 2, "BPHe%04x",
1576 cmd
->hdr
.return_code
);
1580 extrasize
= sizeof(struct qeth_ipacmd_addr_change_entry
) *
1581 hostevs
->num_entries
;
1582 data
= kzalloc(sizeof(struct qeth_bridge_host_data
) + extrasize
,
1585 QETH_CARD_TEXT(card
, 2, "BPHalloc");
1588 INIT_WORK(&data
->worker
, qeth_bridge_host_event_worker
);
1590 memcpy(&data
->hostevs
, hostevs
,
1591 sizeof(struct qeth_ipacmd_addr_change
) + extrasize
);
1592 queue_work(qeth_wq
, &data
->worker
);
1595 /* SETBRIDGEPORT support; sending commands */
1597 struct _qeth_sbp_cbctl
{
1603 enum qeth_sbp_roles
*role
;
1604 enum qeth_sbp_states
*state
;
1610 * qeth_bridgeport_makerc() - derive "traditional" error from hardware codes.
1611 * @card: qeth_card structure pointer, for debug messages.
1612 * @cbctl: state structure with hardware return codes.
1613 * @setcmd: IPA command code
1615 * Returns negative errno-compatible error indication or 0 on success.
1617 static int qeth_bridgeport_makerc(struct qeth_card
*card
,
1618 struct _qeth_sbp_cbctl
*cbctl
, enum qeth_ipa_sbp_cmd setcmd
)
1622 switch (cbctl
->ipa_rc
) {
1623 case IPA_RC_SUCCESS
:
1624 switch (cbctl
->cmd_rc
) {
1631 case 0x000C: /* Not configured as bridge Port */
1632 rc
= -ENODEV
; /* maybe not the best code here? */
1633 dev_err(&card
->gdev
->dev
,
1634 "The HiperSockets device is not configured as a Bridge Port\n");
1636 case 0x0014: /* Another device is Primary */
1638 case IPA_SBP_SET_PRIMARY_BRIDGE_PORT
:
1640 dev_err(&card
->gdev
->dev
,
1641 "The HiperSockets LAN already has a primary Bridge Port\n");
1643 case IPA_SBP_SET_SECONDARY_BRIDGE_PORT
:
1645 dev_err(&card
->gdev
->dev
,
1646 "The HiperSockets device is already a primary Bridge Port\n");
1652 case 0x0018: /* This device is currently Secondary */
1654 dev_err(&card
->gdev
->dev
,
1655 "The HiperSockets device is already a secondary Bridge Port\n");
1657 case 0x001C: /* Limit for Secondary devices reached */
1659 dev_err(&card
->gdev
->dev
,
1660 "The HiperSockets LAN cannot have more secondary Bridge Ports\n");
1662 case 0x0024: /* This device is currently Primary */
1664 dev_err(&card
->gdev
->dev
,
1665 "The HiperSockets device is already a primary Bridge Port\n");
1667 case 0x0020: /* Not authorized by zManager */
1669 dev_err(&card
->gdev
->dev
,
1670 "The HiperSockets device is not authorized to be a Bridge Port\n");
1676 case IPA_RC_NOTSUPP
:
1679 case IPA_RC_UNSUPPORTED_COMMAND
:
1686 QETH_CARD_TEXT_(card
, 2, "SBPi%04x", cbctl
->ipa_rc
);
1687 QETH_CARD_TEXT_(card
, 2, "SBPc%04x", cbctl
->cmd_rc
);
1692 static int qeth_bridgeport_query_support_cb(struct qeth_card
*card
,
1693 struct qeth_reply
*reply
, unsigned long data
)
1695 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*) data
;
1696 struct _qeth_sbp_cbctl
*cbctl
= (struct _qeth_sbp_cbctl
*)reply
->param
;
1697 QETH_CARD_TEXT(card
, 2, "brqsupcb");
1698 cbctl
->ipa_rc
= cmd
->hdr
.return_code
;
1699 cbctl
->cmd_rc
= cmd
->data
.sbp
.hdr
.return_code
;
1700 if ((cbctl
->ipa_rc
== 0) && (cbctl
->cmd_rc
== 0)) {
1701 cbctl
->data
.supported
=
1702 cmd
->data
.sbp
.data
.query_cmds_supp
.supported_cmds
;
1704 cbctl
->data
.supported
= 0;
1710 * qeth_bridgeport_query_support() - store bitmask of supported subfunctions.
1711 * @card: qeth_card structure pointer.
1713 * Sets bitmask of supported setbridgeport subfunctions in the qeth_card
1714 * strucutre: card->options.sbp.supported_funcs.
1716 static void qeth_bridgeport_query_support(struct qeth_card
*card
)
1718 struct qeth_cmd_buffer
*iob
;
1719 struct qeth_ipa_cmd
*cmd
;
1720 struct _qeth_sbp_cbctl cbctl
;
1722 QETH_CARD_TEXT(card
, 2, "brqsuppo");
1723 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETBRIDGEPORT
, 0);
1724 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1725 cmd
->data
.sbp
.hdr
.cmdlength
=
1726 sizeof(struct qeth_ipacmd_sbp_hdr
) +
1727 sizeof(struct qeth_sbp_query_cmds_supp
);
1728 cmd
->data
.sbp
.hdr
.command_code
=
1729 IPA_SBP_QUERY_COMMANDS_SUPPORTED
;
1730 cmd
->data
.sbp
.hdr
.used_total
= 1;
1731 cmd
->data
.sbp
.hdr
.seq_no
= 1;
1732 if (qeth_send_ipa_cmd(card
, iob
, qeth_bridgeport_query_support_cb
,
1734 qeth_bridgeport_makerc(card
, &cbctl
,
1735 IPA_SBP_QUERY_COMMANDS_SUPPORTED
)) {
1736 /* non-zero makerc signifies failure, and produce messages */
1737 card
->options
.sbp
.role
= QETH_SBP_ROLE_NONE
;
1740 card
->options
.sbp
.supported_funcs
= cbctl
.data
.supported
;
1743 static int qeth_bridgeport_query_ports_cb(struct qeth_card
*card
,
1744 struct qeth_reply
*reply
, unsigned long data
)
1746 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*) data
;
1747 struct qeth_sbp_query_ports
*qports
= &cmd
->data
.sbp
.data
.query_ports
;
1748 struct _qeth_sbp_cbctl
*cbctl
= (struct _qeth_sbp_cbctl
*)reply
->param
;
1750 QETH_CARD_TEXT(card
, 2, "brqprtcb");
1751 cbctl
->ipa_rc
= cmd
->hdr
.return_code
;
1752 cbctl
->cmd_rc
= cmd
->data
.sbp
.hdr
.return_code
;
1753 if ((cbctl
->ipa_rc
!= 0) || (cbctl
->cmd_rc
!= 0))
1755 if (qports
->entry_length
!= sizeof(struct qeth_sbp_port_entry
)) {
1756 cbctl
->cmd_rc
= 0xffff;
1757 QETH_CARD_TEXT_(card
, 2, "SBPs%04x", qports
->entry_length
);
1760 /* first entry contains the state of the local port */
1761 if (qports
->num_entries
> 0) {
1762 if (cbctl
->data
.qports
.role
)
1763 *cbctl
->data
.qports
.role
= qports
->entry
[0].role
;
1764 if (cbctl
->data
.qports
.state
)
1765 *cbctl
->data
.qports
.state
= qports
->entry
[0].state
;
1771 * qeth_bridgeport_query_ports() - query local bridgeport status.
1772 * @card: qeth_card structure pointer.
1773 * @role: Role of the port: 0-none, 1-primary, 2-secondary.
1774 * @state: State of the port: 0-inactive, 1-standby, 2-active.
1776 * Returns negative errno-compatible error indication or 0 on success.
1778 * 'role' and 'state' are not updated in case of hardware operation failure.
1780 int qeth_bridgeport_query_ports(struct qeth_card
*card
,
1781 enum qeth_sbp_roles
*role
, enum qeth_sbp_states
*state
)
1784 struct qeth_cmd_buffer
*iob
;
1785 struct qeth_ipa_cmd
*cmd
;
1786 struct _qeth_sbp_cbctl cbctl
= {
1795 QETH_CARD_TEXT(card
, 2, "brqports");
1796 if (!(card
->options
.sbp
.supported_funcs
& IPA_SBP_QUERY_BRIDGE_PORTS
))
1798 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETBRIDGEPORT
, 0);
1799 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1800 cmd
->data
.sbp
.hdr
.cmdlength
=
1801 sizeof(struct qeth_ipacmd_sbp_hdr
);
1802 cmd
->data
.sbp
.hdr
.command_code
=
1803 IPA_SBP_QUERY_BRIDGE_PORTS
;
1804 cmd
->data
.sbp
.hdr
.used_total
= 1;
1805 cmd
->data
.sbp
.hdr
.seq_no
= 1;
1806 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_bridgeport_query_ports_cb
,
1810 rc
= qeth_bridgeport_makerc(card
, &cbctl
, IPA_SBP_QUERY_BRIDGE_PORTS
);
1815 EXPORT_SYMBOL_GPL(qeth_bridgeport_query_ports
);
1817 static int qeth_bridgeport_set_cb(struct qeth_card
*card
,
1818 struct qeth_reply
*reply
, unsigned long data
)
1820 struct qeth_ipa_cmd
*cmd
= (struct qeth_ipa_cmd
*)data
;
1821 struct _qeth_sbp_cbctl
*cbctl
= (struct _qeth_sbp_cbctl
*)reply
->param
;
1822 QETH_CARD_TEXT(card
, 2, "brsetrcb");
1823 cbctl
->ipa_rc
= cmd
->hdr
.return_code
;
1824 cbctl
->cmd_rc
= cmd
->data
.sbp
.hdr
.return_code
;
1829 * qeth_bridgeport_setrole() - Assign primary role to the port.
1830 * @card: qeth_card structure pointer.
1831 * @role: Role to assign.
1833 * Returns negative errno-compatible error indication or 0 on success.
1835 int qeth_bridgeport_setrole(struct qeth_card
*card
, enum qeth_sbp_roles role
)
1839 struct qeth_cmd_buffer
*iob
;
1840 struct qeth_ipa_cmd
*cmd
;
1841 struct _qeth_sbp_cbctl cbctl
;
1842 enum qeth_ipa_sbp_cmd setcmd
;
1844 QETH_CARD_TEXT(card
, 2, "brsetrol");
1846 case QETH_SBP_ROLE_NONE
:
1847 setcmd
= IPA_SBP_RESET_BRIDGE_PORT_ROLE
;
1848 cmdlength
= sizeof(struct qeth_ipacmd_sbp_hdr
) +
1849 sizeof(struct qeth_sbp_reset_role
);
1851 case QETH_SBP_ROLE_PRIMARY
:
1852 setcmd
= IPA_SBP_SET_PRIMARY_BRIDGE_PORT
;
1853 cmdlength
= sizeof(struct qeth_ipacmd_sbp_hdr
) +
1854 sizeof(struct qeth_sbp_set_primary
);
1856 case QETH_SBP_ROLE_SECONDARY
:
1857 setcmd
= IPA_SBP_SET_SECONDARY_BRIDGE_PORT
;
1858 cmdlength
= sizeof(struct qeth_ipacmd_sbp_hdr
) +
1859 sizeof(struct qeth_sbp_set_secondary
);
1864 if (!(card
->options
.sbp
.supported_funcs
& setcmd
))
1866 iob
= qeth_get_ipacmd_buffer(card
, IPA_CMD_SETBRIDGEPORT
, 0);
1867 cmd
= (struct qeth_ipa_cmd
*)(iob
->data
+IPA_PDU_HEADER_SIZE
);
1868 cmd
->data
.sbp
.hdr
.cmdlength
= cmdlength
;
1869 cmd
->data
.sbp
.hdr
.command_code
= setcmd
;
1870 cmd
->data
.sbp
.hdr
.used_total
= 1;
1871 cmd
->data
.sbp
.hdr
.seq_no
= 1;
1872 rc
= qeth_send_ipa_cmd(card
, iob
, qeth_bridgeport_set_cb
,
1876 rc
= qeth_bridgeport_makerc(card
, &cbctl
, setcmd
);
1881 * qeth_anset_makerc() - derive "traditional" error from hardware codes.
1882 * @card: qeth_card structure pointer, for debug messages.
1884 * Returns negative errno-compatible error indication or 0 on success.
1886 static int qeth_anset_makerc(struct qeth_card
*card
, int pnso_rc
, u16 response
)
1899 dev_err(&card
->gdev
->dev
,
1900 "Setting address notification failed\n");
1912 QETH_CARD_TEXT_(card
, 2, "SBPp%04x", pnso_rc
);
1913 QETH_CARD_TEXT_(card
, 2, "SBPr%04x", response
);
1918 static void qeth_bridgeport_an_set_cb(void *priv
,
1919 enum qdio_brinfo_entry_type type
, void *entry
)
1921 struct qeth_card
*card
= (struct qeth_card
*)priv
;
1922 struct qdio_brinfo_entry_l2
*l2entry
;
1925 if (type
!= l2_addr_lnid
) {
1930 l2entry
= (struct qdio_brinfo_entry_l2
*)entry
;
1931 code
= IPA_ADDR_CHANGE_CODE_MACADDR
;
1932 if (l2entry
->addr_lnid
.lnid
)
1933 code
|= IPA_ADDR_CHANGE_CODE_VLANID
;
1934 qeth_bridge_emit_host_event(card
, anev_reg_unreg
, code
,
1935 (struct net_if_token
*)&l2entry
->nit
,
1936 (struct mac_addr_lnid
*)&l2entry
->addr_lnid
);
1940 * qeth_bridgeport_an_set() - Enable or disable bridgeport address notification
1941 * @card: qeth_card structure pointer.
1942 * @enable: 0 - disable, non-zero - enable notifications
1944 * Returns negative errno-compatible error indication or 0 on success.
1946 * On enable, emits a series of address notifications udev events for all
1947 * currently registered hosts.
1949 int qeth_bridgeport_an_set(struct qeth_card
*card
, int enable
)
1953 struct ccw_device
*ddev
;
1954 struct subchannel_id schid
;
1958 if (!card
->options
.sbp
.supported_funcs
)
1960 ddev
= CARD_DDEV(card
);
1961 ccw_device_get_schid(ddev
, &schid
);
1964 qeth_bridge_emit_host_event(card
, anev_reset
, 0, NULL
, NULL
);
1965 rc
= qdio_pnso_brinfo(schid
, 1, &response
,
1966 qeth_bridgeport_an_set_cb
, card
);
1968 rc
= qdio_pnso_brinfo(schid
, 0, &response
, NULL
, NULL
);
1969 return qeth_anset_makerc(card
, rc
, response
);
1971 EXPORT_SYMBOL_GPL(qeth_bridgeport_an_set
);
1973 module_init(qeth_l2_init
);
1974 module_exit(qeth_l2_exit
);
1975 MODULE_AUTHOR("Frank Blaschka <frank.blaschka@de.ibm.com>");
1976 MODULE_DESCRIPTION("qeth layer 2 discipline");
1977 MODULE_LICENSE("GPL");