2 * linux/drivers/net/ehea/ehea_main.c
4 * eHEA ethernet device driver for IBM eServer System p
6 * (C) Copyright IBM Corp. 2006
9 * Christoph Raisch <raisch@de.ibm.com>
10 * Jan-Bernd Themann <themann@de.ibm.com>
11 * Thomas Klein <tklein@de.ibm.com>
14 * This program is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation; either version 2, or (at your option)
19 * This program is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
24 * You should have received a copy of the GNU General Public License
25 * along with this program; if not, write to the Free Software
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
29 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
33 #include <linux/tcp.h>
34 #include <linux/udp.h>
36 #include <linux/list.h>
37 #include <linux/slab.h>
38 #include <linux/if_ether.h>
39 #include <linux/notifier.h>
40 #include <linux/reboot.h>
41 #include <linux/memory.h>
42 #include <asm/kexec.h>
43 #include <linux/mutex.h>
44 #include <linux/prefetch.h>
50 #include "ehea_phyp.h"
53 MODULE_LICENSE("GPL");
54 MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>");
55 MODULE_DESCRIPTION("IBM eServer HEA Driver");
56 MODULE_VERSION(DRV_VERSION
);
59 static int msg_level
= -1;
60 static int rq1_entries
= EHEA_DEF_ENTRIES_RQ1
;
61 static int rq2_entries
= EHEA_DEF_ENTRIES_RQ2
;
62 static int rq3_entries
= EHEA_DEF_ENTRIES_RQ3
;
63 static int sq_entries
= EHEA_DEF_ENTRIES_SQ
;
64 static int use_mcs
= 1;
66 static int lro_max_aggr
= EHEA_LRO_MAX_AGGR
;
67 static int prop_carrier_state
;
69 module_param(msg_level
, int, 0);
70 module_param(rq1_entries
, int, 0);
71 module_param(rq2_entries
, int, 0);
72 module_param(rq3_entries
, int, 0);
73 module_param(sq_entries
, int, 0);
74 module_param(prop_carrier_state
, int, 0);
75 module_param(use_mcs
, int, 0);
76 module_param(use_lro
, int, 0);
77 module_param(lro_max_aggr
, int, 0);
79 MODULE_PARM_DESC(msg_level
, "msg_level");
80 MODULE_PARM_DESC(prop_carrier_state
, "Propagate carrier state of physical "
81 "port to stack. 1:yes, 0:no. Default = 0 ");
82 MODULE_PARM_DESC(rq3_entries
, "Number of entries for Receive Queue 3 "
83 "[2^x - 1], x = [6..14]. Default = "
84 __MODULE_STRING(EHEA_DEF_ENTRIES_RQ3
) ")");
85 MODULE_PARM_DESC(rq2_entries
, "Number of entries for Receive Queue 2 "
86 "[2^x - 1], x = [6..14]. Default = "
87 __MODULE_STRING(EHEA_DEF_ENTRIES_RQ2
) ")");
88 MODULE_PARM_DESC(rq1_entries
, "Number of entries for Receive Queue 1 "
89 "[2^x - 1], x = [6..14]. Default = "
90 __MODULE_STRING(EHEA_DEF_ENTRIES_RQ1
) ")");
91 MODULE_PARM_DESC(sq_entries
, " Number of entries for the Send Queue "
92 "[2^x - 1], x = [6..14]. Default = "
93 __MODULE_STRING(EHEA_DEF_ENTRIES_SQ
) ")");
94 MODULE_PARM_DESC(use_mcs
, " Multiple receive queues, 1: enable, 0: disable, "
97 MODULE_PARM_DESC(lro_max_aggr
, " LRO: Max packets to be aggregated. Default = "
98 __MODULE_STRING(EHEA_LRO_MAX_AGGR
));
99 MODULE_PARM_DESC(use_lro
, " Large Receive Offload, 1: enable, 0: disable, "
102 static int port_name_cnt
;
103 static LIST_HEAD(adapter_list
);
104 static unsigned long ehea_driver_flags
;
105 static DEFINE_MUTEX(dlpar_mem_lock
);
106 struct ehea_fw_handle_array ehea_fw_handles
;
107 struct ehea_bcmc_reg_array ehea_bcmc_regs
;
110 static int __devinit
ehea_probe_adapter(struct platform_device
*dev
,
111 const struct of_device_id
*id
);
113 static int __devexit
ehea_remove(struct platform_device
*dev
);
115 static struct of_device_id ehea_device_table
[] = {
118 .compatible
= "IBM,lhea",
122 MODULE_DEVICE_TABLE(of
, ehea_device_table
);
124 static struct of_platform_driver ehea_driver
= {
127 .owner
= THIS_MODULE
,
128 .of_match_table
= ehea_device_table
,
130 .probe
= ehea_probe_adapter
,
131 .remove
= ehea_remove
,
134 void ehea_dump(void *adr
, int len
, char *msg
)
137 unsigned char *deb
= adr
;
138 for (x
= 0; x
< len
; x
+= 16) {
139 pr_info("%s adr=%p ofs=%04x %016llx %016llx\n",
140 msg
, deb
, x
, *((u64
*)&deb
[0]), *((u64
*)&deb
[8]));
145 void ehea_schedule_port_reset(struct ehea_port
*port
)
147 if (!test_bit(__EHEA_DISABLE_PORT_RESET
, &port
->flags
))
148 schedule_work(&port
->reset_task
);
151 static void ehea_update_firmware_handles(void)
153 struct ehea_fw_handle_entry
*arr
= NULL
;
154 struct ehea_adapter
*adapter
;
155 int num_adapters
= 0;
159 int num_fw_handles
, k
, l
;
161 /* Determine number of handles */
162 mutex_lock(&ehea_fw_handles
.lock
);
164 list_for_each_entry(adapter
, &adapter_list
, list
) {
167 for (k
= 0; k
< EHEA_MAX_PORTS
; k
++) {
168 struct ehea_port
*port
= adapter
->port
[k
];
170 if (!port
|| (port
->state
!= EHEA_PORT_UP
))
174 num_portres
+= port
->num_def_qps
;
178 num_fw_handles
= num_adapters
* EHEA_NUM_ADAPTER_FW_HANDLES
+
179 num_ports
* EHEA_NUM_PORT_FW_HANDLES
+
180 num_portres
* EHEA_NUM_PORTRES_FW_HANDLES
;
182 if (num_fw_handles
) {
183 arr
= kcalloc(num_fw_handles
, sizeof(*arr
), GFP_KERNEL
);
185 goto out
; /* Keep the existing array */
189 list_for_each_entry(adapter
, &adapter_list
, list
) {
190 if (num_adapters
== 0)
193 for (k
= 0; k
< EHEA_MAX_PORTS
; k
++) {
194 struct ehea_port
*port
= adapter
->port
[k
];
196 if (!port
|| (port
->state
!= EHEA_PORT_UP
) ||
200 for (l
= 0; l
< port
->num_def_qps
; l
++) {
201 struct ehea_port_res
*pr
= &port
->port_res
[l
];
203 arr
[i
].adh
= adapter
->handle
;
204 arr
[i
++].fwh
= pr
->qp
->fw_handle
;
205 arr
[i
].adh
= adapter
->handle
;
206 arr
[i
++].fwh
= pr
->send_cq
->fw_handle
;
207 arr
[i
].adh
= adapter
->handle
;
208 arr
[i
++].fwh
= pr
->recv_cq
->fw_handle
;
209 arr
[i
].adh
= adapter
->handle
;
210 arr
[i
++].fwh
= pr
->eq
->fw_handle
;
211 arr
[i
].adh
= adapter
->handle
;
212 arr
[i
++].fwh
= pr
->send_mr
.handle
;
213 arr
[i
].adh
= adapter
->handle
;
214 arr
[i
++].fwh
= pr
->recv_mr
.handle
;
216 arr
[i
].adh
= adapter
->handle
;
217 arr
[i
++].fwh
= port
->qp_eq
->fw_handle
;
221 arr
[i
].adh
= adapter
->handle
;
222 arr
[i
++].fwh
= adapter
->neq
->fw_handle
;
224 if (adapter
->mr
.handle
) {
225 arr
[i
].adh
= adapter
->handle
;
226 arr
[i
++].fwh
= adapter
->mr
.handle
;
232 kfree(ehea_fw_handles
.arr
);
233 ehea_fw_handles
.arr
= arr
;
234 ehea_fw_handles
.num_entries
= i
;
236 mutex_unlock(&ehea_fw_handles
.lock
);
239 static void ehea_update_bcmc_registrations(void)
242 struct ehea_bcmc_reg_entry
*arr
= NULL
;
243 struct ehea_adapter
*adapter
;
244 struct ehea_mc_list
*mc_entry
;
245 int num_registrations
= 0;
249 spin_lock_irqsave(&ehea_bcmc_regs
.lock
, flags
);
251 /* Determine number of registrations */
252 list_for_each_entry(adapter
, &adapter_list
, list
)
253 for (k
= 0; k
< EHEA_MAX_PORTS
; k
++) {
254 struct ehea_port
*port
= adapter
->port
[k
];
256 if (!port
|| (port
->state
!= EHEA_PORT_UP
))
259 num_registrations
+= 2; /* Broadcast registrations */
261 list_for_each_entry(mc_entry
, &port
->mc_list
->list
,list
)
262 num_registrations
+= 2;
265 if (num_registrations
) {
266 arr
= kcalloc(num_registrations
, sizeof(*arr
), GFP_ATOMIC
);
268 goto out
; /* Keep the existing array */
272 list_for_each_entry(adapter
, &adapter_list
, list
) {
273 for (k
= 0; k
< EHEA_MAX_PORTS
; k
++) {
274 struct ehea_port
*port
= adapter
->port
[k
];
276 if (!port
|| (port
->state
!= EHEA_PORT_UP
))
279 if (num_registrations
== 0)
282 arr
[i
].adh
= adapter
->handle
;
283 arr
[i
].port_id
= port
->logical_port_id
;
284 arr
[i
].reg_type
= EHEA_BCMC_BROADCAST
|
286 arr
[i
++].macaddr
= port
->mac_addr
;
288 arr
[i
].adh
= adapter
->handle
;
289 arr
[i
].port_id
= port
->logical_port_id
;
290 arr
[i
].reg_type
= EHEA_BCMC_BROADCAST
|
291 EHEA_BCMC_VLANID_ALL
;
292 arr
[i
++].macaddr
= port
->mac_addr
;
293 num_registrations
-= 2;
295 list_for_each_entry(mc_entry
,
296 &port
->mc_list
->list
, list
) {
297 if (num_registrations
== 0)
300 arr
[i
].adh
= adapter
->handle
;
301 arr
[i
].port_id
= port
->logical_port_id
;
302 arr
[i
].reg_type
= EHEA_BCMC_SCOPE_ALL
|
303 EHEA_BCMC_MULTICAST
|
305 arr
[i
++].macaddr
= mc_entry
->macaddr
;
307 arr
[i
].adh
= adapter
->handle
;
308 arr
[i
].port_id
= port
->logical_port_id
;
309 arr
[i
].reg_type
= EHEA_BCMC_SCOPE_ALL
|
310 EHEA_BCMC_MULTICAST
|
311 EHEA_BCMC_VLANID_ALL
;
312 arr
[i
++].macaddr
= mc_entry
->macaddr
;
313 num_registrations
-= 2;
319 kfree(ehea_bcmc_regs
.arr
);
320 ehea_bcmc_regs
.arr
= arr
;
321 ehea_bcmc_regs
.num_entries
= i
;
323 spin_unlock_irqrestore(&ehea_bcmc_regs
.lock
, flags
);
326 static struct net_device_stats
*ehea_get_stats(struct net_device
*dev
)
328 struct ehea_port
*port
= netdev_priv(dev
);
329 struct net_device_stats
*stats
= &port
->stats
;
330 u64 rx_packets
= 0, tx_packets
= 0, rx_bytes
= 0, tx_bytes
= 0;
333 for (i
= 0; i
< port
->num_def_qps
; i
++) {
334 rx_packets
+= port
->port_res
[i
].rx_packets
;
335 rx_bytes
+= port
->port_res
[i
].rx_bytes
;
338 for (i
= 0; i
< port
->num_def_qps
; i
++) {
339 tx_packets
+= port
->port_res
[i
].tx_packets
;
340 tx_bytes
+= port
->port_res
[i
].tx_bytes
;
343 stats
->tx_packets
= tx_packets
;
344 stats
->rx_bytes
= rx_bytes
;
345 stats
->tx_bytes
= tx_bytes
;
346 stats
->rx_packets
= rx_packets
;
351 static void ehea_update_stats(struct work_struct
*work
)
353 struct ehea_port
*port
=
354 container_of(work
, struct ehea_port
, stats_work
.work
);
355 struct net_device
*dev
= port
->netdev
;
356 struct net_device_stats
*stats
= &port
->stats
;
357 struct hcp_ehea_port_cb2
*cb2
;
360 cb2
= (void *)get_zeroed_page(GFP_KERNEL
);
362 netdev_err(dev
, "No mem for cb2. Some interface statistics were not updated\n");
366 hret
= ehea_h_query_ehea_port(port
->adapter
->handle
,
367 port
->logical_port_id
,
368 H_PORT_CB2
, H_PORT_CB2_ALL
, cb2
);
369 if (hret
!= H_SUCCESS
) {
370 netdev_err(dev
, "query_ehea_port failed\n");
374 if (netif_msg_hw(port
))
375 ehea_dump(cb2
, sizeof(*cb2
), "net_device_stats");
377 stats
->multicast
= cb2
->rxmcp
;
378 stats
->rx_errors
= cb2
->rxuerr
;
381 free_page((unsigned long)cb2
);
383 schedule_delayed_work(&port
->stats_work
, msecs_to_jiffies(1000));
386 static void ehea_refill_rq1(struct ehea_port_res
*pr
, int index
, int nr_of_wqes
)
388 struct sk_buff
**skb_arr_rq1
= pr
->rq1_skba
.arr
;
389 struct net_device
*dev
= pr
->port
->netdev
;
390 int max_index_mask
= pr
->rq1_skba
.len
- 1;
391 int fill_wqes
= pr
->rq1_skba
.os_skbs
+ nr_of_wqes
;
395 pr
->rq1_skba
.os_skbs
= 0;
397 if (unlikely(test_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
))) {
399 pr
->rq1_skba
.index
= index
;
400 pr
->rq1_skba
.os_skbs
= fill_wqes
;
404 for (i
= 0; i
< fill_wqes
; i
++) {
405 if (!skb_arr_rq1
[index
]) {
406 skb_arr_rq1
[index
] = netdev_alloc_skb(dev
,
408 if (!skb_arr_rq1
[index
]) {
409 netdev_info(dev
, "Unable to allocate enough skb in the array\n");
410 pr
->rq1_skba
.os_skbs
= fill_wqes
- i
;
415 index
&= max_index_mask
;
423 ehea_update_rq1a(pr
->qp
, adder
);
426 static void ehea_init_fill_rq1(struct ehea_port_res
*pr
, int nr_rq1a
)
428 struct sk_buff
**skb_arr_rq1
= pr
->rq1_skba
.arr
;
429 struct net_device
*dev
= pr
->port
->netdev
;
432 if (nr_rq1a
> pr
->rq1_skba
.len
) {
433 netdev_err(dev
, "NR_RQ1A bigger than skb array len\n");
437 for (i
= 0; i
< nr_rq1a
; i
++) {
438 skb_arr_rq1
[i
] = netdev_alloc_skb(dev
, EHEA_L_PKT_SIZE
);
439 if (!skb_arr_rq1
[i
]) {
440 netdev_info(dev
, "Not enough memory to allocate skb array\n");
445 ehea_update_rq1a(pr
->qp
, i
- 1);
448 static int ehea_refill_rq_def(struct ehea_port_res
*pr
,
449 struct ehea_q_skb_arr
*q_skba
, int rq_nr
,
450 int num_wqes
, int wqe_type
, int packet_size
)
452 struct net_device
*dev
= pr
->port
->netdev
;
453 struct ehea_qp
*qp
= pr
->qp
;
454 struct sk_buff
**skb_arr
= q_skba
->arr
;
455 struct ehea_rwqe
*rwqe
;
456 int i
, index
, max_index_mask
, fill_wqes
;
460 fill_wqes
= q_skba
->os_skbs
+ num_wqes
;
463 if (unlikely(test_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
))) {
464 q_skba
->os_skbs
= fill_wqes
;
468 index
= q_skba
->index
;
469 max_index_mask
= q_skba
->len
- 1;
470 for (i
= 0; i
< fill_wqes
; i
++) {
474 skb
= netdev_alloc_skb_ip_align(dev
, packet_size
);
476 q_skba
->os_skbs
= fill_wqes
- i
;
477 if (q_skba
->os_skbs
== q_skba
->len
- 2) {
478 netdev_info(pr
->port
->netdev
,
479 "rq%i ran dry - no mem for skb\n",
486 skb_arr
[index
] = skb
;
487 tmp_addr
= ehea_map_vaddr(skb
->data
);
488 if (tmp_addr
== -1) {
490 q_skba
->os_skbs
= fill_wqes
- i
;
495 rwqe
= ehea_get_next_rwqe(qp
, rq_nr
);
496 rwqe
->wr_id
= EHEA_BMASK_SET(EHEA_WR_ID_TYPE
, wqe_type
)
497 | EHEA_BMASK_SET(EHEA_WR_ID_INDEX
, index
);
498 rwqe
->sg_list
[0].l_key
= pr
->recv_mr
.lkey
;
499 rwqe
->sg_list
[0].vaddr
= tmp_addr
;
500 rwqe
->sg_list
[0].len
= packet_size
;
501 rwqe
->data_segments
= 1;
504 index
&= max_index_mask
;
508 q_skba
->index
= index
;
515 ehea_update_rq2a(pr
->qp
, adder
);
517 ehea_update_rq3a(pr
->qp
, adder
);
523 static int ehea_refill_rq2(struct ehea_port_res
*pr
, int nr_of_wqes
)
525 return ehea_refill_rq_def(pr
, &pr
->rq2_skba
, 2,
526 nr_of_wqes
, EHEA_RWQE2_TYPE
,
531 static int ehea_refill_rq3(struct ehea_port_res
*pr
, int nr_of_wqes
)
533 return ehea_refill_rq_def(pr
, &pr
->rq3_skba
, 3,
534 nr_of_wqes
, EHEA_RWQE3_TYPE
,
535 EHEA_MAX_PACKET_SIZE
);
538 static inline int ehea_check_cqe(struct ehea_cqe
*cqe
, int *rq_num
)
540 *rq_num
= (cqe
->type
& EHEA_CQE_TYPE_RQ
) >> 5;
541 if ((cqe
->status
& EHEA_CQE_STAT_ERR_MASK
) == 0)
543 if (((cqe
->status
& EHEA_CQE_STAT_ERR_TCP
) != 0) &&
544 (cqe
->header_length
== 0))
549 static inline void ehea_fill_skb(struct net_device
*dev
,
550 struct sk_buff
*skb
, struct ehea_cqe
*cqe
,
551 struct ehea_port_res
*pr
)
553 int length
= cqe
->num_bytes_transfered
- 4; /*remove CRC */
555 skb_put(skb
, length
);
556 skb
->protocol
= eth_type_trans(skb
, dev
);
558 /* The packet was not an IPV4 packet so a complemented checksum was
559 calculated. The value is found in the Internet Checksum field. */
560 if (cqe
->status
& EHEA_CQE_BLIND_CKSUM
) {
561 skb
->ip_summed
= CHECKSUM_COMPLETE
;
562 skb
->csum
= csum_unfold(~cqe
->inet_checksum_value
);
564 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
566 skb_record_rx_queue(skb
, pr
- &pr
->port
->port_res
[0]);
569 static inline struct sk_buff
*get_skb_by_index(struct sk_buff
**skb_array
,
571 struct ehea_cqe
*cqe
)
573 int skb_index
= EHEA_BMASK_GET(EHEA_WR_ID_INDEX
, cqe
->wr_id
);
584 prefetchw(pref
+ EHEA_CACHE_LINE
);
586 pref
= (skb_array
[x
]->data
);
588 prefetch(pref
+ EHEA_CACHE_LINE
);
589 prefetch(pref
+ EHEA_CACHE_LINE
* 2);
590 prefetch(pref
+ EHEA_CACHE_LINE
* 3);
593 skb
= skb_array
[skb_index
];
594 skb_array
[skb_index
] = NULL
;
598 static inline struct sk_buff
*get_skb_by_index_ll(struct sk_buff
**skb_array
,
599 int arr_len
, int wqe_index
)
611 prefetchw(pref
+ EHEA_CACHE_LINE
);
613 pref
= (skb_array
[x
]->data
);
615 prefetchw(pref
+ EHEA_CACHE_LINE
);
618 skb
= skb_array
[wqe_index
];
619 skb_array
[wqe_index
] = NULL
;
623 static int ehea_treat_poll_error(struct ehea_port_res
*pr
, int rq
,
624 struct ehea_cqe
*cqe
, int *processed_rq2
,
629 if (cqe
->status
& EHEA_CQE_STAT_ERR_TCP
)
630 pr
->p_stats
.err_tcp_cksum
++;
631 if (cqe
->status
& EHEA_CQE_STAT_ERR_IP
)
632 pr
->p_stats
.err_ip_cksum
++;
633 if (cqe
->status
& EHEA_CQE_STAT_ERR_CRC
)
634 pr
->p_stats
.err_frame_crc
++;
638 skb
= get_skb_by_index(pr
->rq2_skba
.arr
, pr
->rq2_skba
.len
, cqe
);
640 } else if (rq
== 3) {
642 skb
= get_skb_by_index(pr
->rq3_skba
.arr
, pr
->rq3_skba
.len
, cqe
);
646 if (cqe
->status
& EHEA_CQE_STAT_FAT_ERR_MASK
) {
647 if (netif_msg_rx_err(pr
->port
)) {
648 pr_err("Critical receive error for QP %d. Resetting port.\n",
649 pr
->qp
->init_attr
.qp_nr
);
650 ehea_dump(cqe
, sizeof(*cqe
), "CQE");
652 ehea_schedule_port_reset(pr
->port
);
659 static int get_skb_hdr(struct sk_buff
*skb
, void **iphdr
,
660 void **tcph
, u64
*hdr_flags
, void *priv
)
662 struct ehea_cqe
*cqe
= priv
;
666 /* non tcp/udp packets */
667 if (!cqe
->header_length
)
671 skb_reset_network_header(skb
);
673 if (iph
->protocol
!= IPPROTO_TCP
)
676 ip_len
= ip_hdrlen(skb
);
677 skb_set_transport_header(skb
, ip_len
);
678 *tcph
= tcp_hdr(skb
);
680 /* check if ip header and tcp header are complete */
681 if (ntohs(iph
->tot_len
) < ip_len
+ tcp_hdrlen(skb
))
684 *hdr_flags
= LRO_IPV4
| LRO_TCP
;
690 static void ehea_proc_skb(struct ehea_port_res
*pr
, struct ehea_cqe
*cqe
,
693 if (cqe
->status
& EHEA_CQE_VLAN_TAG_XTRACT
)
694 __vlan_hwaccel_put_tag(skb
, cqe
->vlan_tag
);
696 if (skb
->dev
->features
& NETIF_F_LRO
)
697 lro_receive_skb(&pr
->lro_mgr
, skb
, cqe
);
699 netif_receive_skb(skb
);
702 static int ehea_proc_rwqes(struct net_device
*dev
,
703 struct ehea_port_res
*pr
,
706 struct ehea_port
*port
= pr
->port
;
707 struct ehea_qp
*qp
= pr
->qp
;
708 struct ehea_cqe
*cqe
;
710 struct sk_buff
**skb_arr_rq1
= pr
->rq1_skba
.arr
;
711 struct sk_buff
**skb_arr_rq2
= pr
->rq2_skba
.arr
;
712 struct sk_buff
**skb_arr_rq3
= pr
->rq3_skba
.arr
;
713 int skb_arr_rq1_len
= pr
->rq1_skba
.len
;
714 int skb_arr_rq2_len
= pr
->rq2_skba
.len
;
715 int skb_arr_rq3_len
= pr
->rq3_skba
.len
;
716 int processed
, processed_rq1
, processed_rq2
, processed_rq3
;
717 u64 processed_bytes
= 0;
718 int wqe_index
, last_wqe_index
, rq
, port_reset
;
720 processed
= processed_rq1
= processed_rq2
= processed_rq3
= 0;
723 cqe
= ehea_poll_rq1(qp
, &wqe_index
);
724 while ((processed
< budget
) && cqe
) {
728 if (netif_msg_rx_status(port
))
729 ehea_dump(cqe
, sizeof(*cqe
), "CQE");
731 last_wqe_index
= wqe_index
;
733 if (!ehea_check_cqe(cqe
, &rq
)) {
736 skb
= get_skb_by_index_ll(skb_arr_rq1
,
739 if (unlikely(!skb
)) {
740 netif_info(port
, rx_err
, dev
,
741 "LL rq1: skb=NULL\n");
743 skb
= netdev_alloc_skb(dev
,
746 netdev_err(dev
, "Not enough memory to allocate skb\n");
750 skb_copy_to_linear_data(skb
, ((char *)cqe
) + 64,
751 cqe
->num_bytes_transfered
- 4);
752 ehea_fill_skb(dev
, skb
, cqe
, pr
);
753 } else if (rq
== 2) {
755 skb
= get_skb_by_index(skb_arr_rq2
,
756 skb_arr_rq2_len
, cqe
);
757 if (unlikely(!skb
)) {
758 netif_err(port
, rx_err
, dev
,
762 ehea_fill_skb(dev
, skb
, cqe
, pr
);
766 skb
= get_skb_by_index(skb_arr_rq3
,
767 skb_arr_rq3_len
, cqe
);
768 if (unlikely(!skb
)) {
769 netif_err(port
, rx_err
, dev
,
773 ehea_fill_skb(dev
, skb
, cqe
, pr
);
777 processed_bytes
+= skb
->len
;
778 ehea_proc_skb(pr
, cqe
, skb
);
780 pr
->p_stats
.poll_receive_errors
++;
781 port_reset
= ehea_treat_poll_error(pr
, rq
, cqe
,
787 cqe
= ehea_poll_rq1(qp
, &wqe_index
);
789 if (dev
->features
& NETIF_F_LRO
)
790 lro_flush_all(&pr
->lro_mgr
);
792 pr
->rx_packets
+= processed
;
793 pr
->rx_bytes
+= processed_bytes
;
795 ehea_refill_rq1(pr
, last_wqe_index
, processed_rq1
);
796 ehea_refill_rq2(pr
, processed_rq2
);
797 ehea_refill_rq3(pr
, processed_rq3
);
802 #define SWQE_RESTART_CHECK 0xdeadbeaff00d0000ull
804 static void reset_sq_restart_flag(struct ehea_port
*port
)
808 for (i
= 0; i
< port
->num_def_qps
; i
++) {
809 struct ehea_port_res
*pr
= &port
->port_res
[i
];
810 pr
->sq_restart_flag
= 0;
812 wake_up(&port
->restart_wq
);
815 static void check_sqs(struct ehea_port
*port
)
817 struct ehea_swqe
*swqe
;
821 for (i
= 0; i
< port
->num_def_qps
; i
++) {
822 struct ehea_port_res
*pr
= &port
->port_res
[i
];
825 swqe
= ehea_get_swqe(pr
->qp
, &swqe_index
);
826 memset(swqe
, 0, SWQE_HEADER_SIZE
);
827 atomic_dec(&pr
->swqe_avail
);
829 swqe
->tx_control
|= EHEA_SWQE_PURGE
;
830 swqe
->wr_id
= SWQE_RESTART_CHECK
;
831 swqe
->tx_control
|= EHEA_SWQE_SIGNALLED_COMPLETION
;
832 swqe
->tx_control
|= EHEA_SWQE_IMM_DATA_PRESENT
;
833 swqe
->immediate_data_length
= 80;
835 ehea_post_swqe(pr
->qp
, swqe
);
837 ret
= wait_event_timeout(port
->restart_wq
,
838 pr
->sq_restart_flag
== 0,
839 msecs_to_jiffies(100));
842 pr_err("HW/SW queues out of sync\n");
843 ehea_schedule_port_reset(pr
->port
);
850 static struct ehea_cqe
*ehea_proc_cqes(struct ehea_port_res
*pr
, int my_quota
)
853 struct ehea_cq
*send_cq
= pr
->send_cq
;
854 struct ehea_cqe
*cqe
;
855 int quota
= my_quota
;
859 struct netdev_queue
*txq
= netdev_get_tx_queue(pr
->port
->netdev
,
860 pr
- &pr
->port
->port_res
[0]);
862 cqe
= ehea_poll_cq(send_cq
);
863 while (cqe
&& (quota
> 0)) {
864 ehea_inc_cq(send_cq
);
869 if (cqe
->wr_id
== SWQE_RESTART_CHECK
) {
870 pr
->sq_restart_flag
= 1;
875 if (cqe
->status
& EHEA_CQE_STAT_ERR_MASK
) {
876 pr_err("Bad send completion status=0x%04X\n",
879 if (netif_msg_tx_err(pr
->port
))
880 ehea_dump(cqe
, sizeof(*cqe
), "Send CQE");
882 if (cqe
->status
& EHEA_CQE_STAT_RESET_MASK
) {
883 pr_err("Resetting port\n");
884 ehea_schedule_port_reset(pr
->port
);
889 if (netif_msg_tx_done(pr
->port
))
890 ehea_dump(cqe
, sizeof(*cqe
), "CQE");
892 if (likely(EHEA_BMASK_GET(EHEA_WR_ID_TYPE
, cqe
->wr_id
)
893 == EHEA_SWQE2_TYPE
)) {
895 index
= EHEA_BMASK_GET(EHEA_WR_ID_INDEX
, cqe
->wr_id
);
896 skb
= pr
->sq_skba
.arr
[index
];
898 pr
->sq_skba
.arr
[index
] = NULL
;
901 swqe_av
+= EHEA_BMASK_GET(EHEA_WR_ID_REFILL
, cqe
->wr_id
);
904 cqe
= ehea_poll_cq(send_cq
);
907 ehea_update_feca(send_cq
, cqe_counter
);
908 atomic_add(swqe_av
, &pr
->swqe_avail
);
910 if (unlikely(netif_tx_queue_stopped(txq
) &&
911 (atomic_read(&pr
->swqe_avail
) >= pr
->swqe_refill_th
))) {
912 __netif_tx_lock(txq
, smp_processor_id());
913 if (netif_tx_queue_stopped(txq
) &&
914 (atomic_read(&pr
->swqe_avail
) >= pr
->swqe_refill_th
))
915 netif_tx_wake_queue(txq
);
916 __netif_tx_unlock(txq
);
919 wake_up(&pr
->port
->swqe_avail_wq
);
924 #define EHEA_POLL_MAX_CQES 65535
926 static int ehea_poll(struct napi_struct
*napi
, int budget
)
928 struct ehea_port_res
*pr
= container_of(napi
, struct ehea_port_res
,
930 struct net_device
*dev
= pr
->port
->netdev
;
931 struct ehea_cqe
*cqe
;
932 struct ehea_cqe
*cqe_skb
= NULL
;
936 cqe_skb
= ehea_proc_cqes(pr
, EHEA_POLL_MAX_CQES
);
937 rx
+= ehea_proc_rwqes(dev
, pr
, budget
- rx
);
939 while (rx
!= budget
) {
941 ehea_reset_cq_ep(pr
->recv_cq
);
942 ehea_reset_cq_ep(pr
->send_cq
);
943 ehea_reset_cq_n1(pr
->recv_cq
);
944 ehea_reset_cq_n1(pr
->send_cq
);
946 cqe
= ehea_poll_rq1(pr
->qp
, &wqe_index
);
947 cqe_skb
= ehea_poll_cq(pr
->send_cq
);
949 if (!cqe
&& !cqe_skb
)
952 if (!napi_reschedule(napi
))
955 cqe_skb
= ehea_proc_cqes(pr
, EHEA_POLL_MAX_CQES
);
956 rx
+= ehea_proc_rwqes(dev
, pr
, budget
- rx
);
962 #ifdef CONFIG_NET_POLL_CONTROLLER
963 static void ehea_netpoll(struct net_device
*dev
)
965 struct ehea_port
*port
= netdev_priv(dev
);
968 for (i
= 0; i
< port
->num_def_qps
; i
++)
969 napi_schedule(&port
->port_res
[i
].napi
);
973 static irqreturn_t
ehea_recv_irq_handler(int irq
, void *param
)
975 struct ehea_port_res
*pr
= param
;
977 napi_schedule(&pr
->napi
);
982 static irqreturn_t
ehea_qp_aff_irq_handler(int irq
, void *param
)
984 struct ehea_port
*port
= param
;
985 struct ehea_eqe
*eqe
;
988 u64 resource_type
, aer
, aerr
;
991 eqe
= ehea_poll_eq(port
->qp_eq
);
994 qp_token
= EHEA_BMASK_GET(EHEA_EQE_QP_TOKEN
, eqe
->entry
);
995 pr_err("QP aff_err: entry=0x%llx, token=0x%x\n",
996 eqe
->entry
, qp_token
);
998 qp
= port
->port_res
[qp_token
].qp
;
1000 resource_type
= ehea_error_data(port
->adapter
, qp
->fw_handle
,
1003 if (resource_type
== EHEA_AER_RESTYPE_QP
) {
1004 if ((aer
& EHEA_AER_RESET_MASK
) ||
1005 (aerr
& EHEA_AERR_RESET_MASK
))
1008 reset_port
= 1; /* Reset in case of CQ or EQ error */
1010 eqe
= ehea_poll_eq(port
->qp_eq
);
1014 pr_err("Resetting port\n");
1015 ehea_schedule_port_reset(port
);
1021 static struct ehea_port
*ehea_get_port(struct ehea_adapter
*adapter
,
1026 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++)
1027 if (adapter
->port
[i
])
1028 if (adapter
->port
[i
]->logical_port_id
== logical_port
)
1029 return adapter
->port
[i
];
1033 int ehea_sense_port_attr(struct ehea_port
*port
)
1037 struct hcp_ehea_port_cb0
*cb0
;
1039 /* may be called via ehea_neq_tasklet() */
1040 cb0
= (void *)get_zeroed_page(GFP_ATOMIC
);
1042 pr_err("no mem for cb0\n");
1047 hret
= ehea_h_query_ehea_port(port
->adapter
->handle
,
1048 port
->logical_port_id
, H_PORT_CB0
,
1049 EHEA_BMASK_SET(H_PORT_CB0_ALL
, 0xFFFF),
1051 if (hret
!= H_SUCCESS
) {
1057 port
->mac_addr
= cb0
->port_mac_addr
<< 16;
1059 if (!is_valid_ether_addr((u8
*)&port
->mac_addr
)) {
1060 ret
= -EADDRNOTAVAIL
;
1065 switch (cb0
->port_speed
) {
1067 port
->port_speed
= EHEA_SPEED_10M
;
1068 port
->full_duplex
= 0;
1071 port
->port_speed
= EHEA_SPEED_10M
;
1072 port
->full_duplex
= 1;
1074 case H_SPEED_100M_H
:
1075 port
->port_speed
= EHEA_SPEED_100M
;
1076 port
->full_duplex
= 0;
1078 case H_SPEED_100M_F
:
1079 port
->port_speed
= EHEA_SPEED_100M
;
1080 port
->full_duplex
= 1;
1083 port
->port_speed
= EHEA_SPEED_1G
;
1084 port
->full_duplex
= 1;
1087 port
->port_speed
= EHEA_SPEED_10G
;
1088 port
->full_duplex
= 1;
1091 port
->port_speed
= 0;
1092 port
->full_duplex
= 0;
1097 port
->num_mcs
= cb0
->num_default_qps
;
1099 /* Number of default QPs */
1101 port
->num_def_qps
= cb0
->num_default_qps
;
1103 port
->num_def_qps
= 1;
1105 if (!port
->num_def_qps
) {
1112 if (ret
|| netif_msg_probe(port
))
1113 ehea_dump(cb0
, sizeof(*cb0
), "ehea_sense_port_attr");
1114 free_page((unsigned long)cb0
);
1119 int ehea_set_portspeed(struct ehea_port
*port
, u32 port_speed
)
1121 struct hcp_ehea_port_cb4
*cb4
;
1125 cb4
= (void *)get_zeroed_page(GFP_KERNEL
);
1127 pr_err("no mem for cb4\n");
1132 cb4
->port_speed
= port_speed
;
1134 netif_carrier_off(port
->netdev
);
1136 hret
= ehea_h_modify_ehea_port(port
->adapter
->handle
,
1137 port
->logical_port_id
,
1138 H_PORT_CB4
, H_PORT_CB4_SPEED
, cb4
);
1139 if (hret
== H_SUCCESS
) {
1140 port
->autoneg
= port_speed
== EHEA_SPEED_AUTONEG
? 1 : 0;
1142 hret
= ehea_h_query_ehea_port(port
->adapter
->handle
,
1143 port
->logical_port_id
,
1144 H_PORT_CB4
, H_PORT_CB4_SPEED
,
1146 if (hret
== H_SUCCESS
) {
1147 switch (cb4
->port_speed
) {
1149 port
->port_speed
= EHEA_SPEED_10M
;
1150 port
->full_duplex
= 0;
1153 port
->port_speed
= EHEA_SPEED_10M
;
1154 port
->full_duplex
= 1;
1156 case H_SPEED_100M_H
:
1157 port
->port_speed
= EHEA_SPEED_100M
;
1158 port
->full_duplex
= 0;
1160 case H_SPEED_100M_F
:
1161 port
->port_speed
= EHEA_SPEED_100M
;
1162 port
->full_duplex
= 1;
1165 port
->port_speed
= EHEA_SPEED_1G
;
1166 port
->full_duplex
= 1;
1169 port
->port_speed
= EHEA_SPEED_10G
;
1170 port
->full_duplex
= 1;
1173 port
->port_speed
= 0;
1174 port
->full_duplex
= 0;
1178 pr_err("Failed sensing port speed\n");
1182 if (hret
== H_AUTHORITY
) {
1183 pr_info("Hypervisor denied setting port speed\n");
1187 pr_err("Failed setting port speed\n");
1190 if (!prop_carrier_state
|| (port
->phy_link
== EHEA_PHY_LINK_UP
))
1191 netif_carrier_on(port
->netdev
);
1193 free_page((unsigned long)cb4
);
1198 static void ehea_parse_eqe(struct ehea_adapter
*adapter
, u64 eqe
)
1203 struct ehea_port
*port
;
1204 struct net_device
*dev
;
1206 ec
= EHEA_BMASK_GET(NEQE_EVENT_CODE
, eqe
);
1207 portnum
= EHEA_BMASK_GET(NEQE_PORTNUM
, eqe
);
1208 port
= ehea_get_port(adapter
, portnum
);
1212 case EHEA_EC_PORTSTATE_CHG
: /* port state change */
1215 netdev_err(dev
, "unknown portnum %x\n", portnum
);
1219 if (EHEA_BMASK_GET(NEQE_PORT_UP
, eqe
)) {
1220 if (!netif_carrier_ok(dev
)) {
1221 ret
= ehea_sense_port_attr(port
);
1223 netdev_err(dev
, "failed resensing port attributes\n");
1227 netif_info(port
, link
, dev
,
1228 "Logical port up: %dMbps %s Duplex\n",
1230 port
->full_duplex
== 1 ?
1233 netif_carrier_on(dev
);
1234 netif_wake_queue(dev
);
1237 if (netif_carrier_ok(dev
)) {
1238 netif_info(port
, link
, dev
,
1239 "Logical port down\n");
1240 netif_carrier_off(dev
);
1241 netif_tx_disable(dev
);
1244 if (EHEA_BMASK_GET(NEQE_EXTSWITCH_PORT_UP
, eqe
)) {
1245 port
->phy_link
= EHEA_PHY_LINK_UP
;
1246 netif_info(port
, link
, dev
,
1247 "Physical port up\n");
1248 if (prop_carrier_state
)
1249 netif_carrier_on(dev
);
1251 port
->phy_link
= EHEA_PHY_LINK_DOWN
;
1252 netif_info(port
, link
, dev
,
1253 "Physical port down\n");
1254 if (prop_carrier_state
)
1255 netif_carrier_off(dev
);
1258 if (EHEA_BMASK_GET(NEQE_EXTSWITCH_PRIMARY
, eqe
))
1260 "External switch port is primary port\n");
1263 "External switch port is backup port\n");
1266 case EHEA_EC_ADAPTER_MALFUNC
:
1267 netdev_err(dev
, "Adapter malfunction\n");
1269 case EHEA_EC_PORT_MALFUNC
:
1270 netdev_info(dev
, "Port malfunction\n");
1271 netif_carrier_off(dev
);
1272 netif_tx_disable(dev
);
1275 netdev_err(dev
, "unknown event code %x, eqe=0x%llX\n", ec
, eqe
);
1280 static void ehea_neq_tasklet(unsigned long data
)
1282 struct ehea_adapter
*adapter
= (struct ehea_adapter
*)data
;
1283 struct ehea_eqe
*eqe
;
1286 eqe
= ehea_poll_eq(adapter
->neq
);
1287 pr_debug("eqe=%p\n", eqe
);
1290 pr_debug("*eqe=%lx\n", (unsigned long) eqe
->entry
);
1291 ehea_parse_eqe(adapter
, eqe
->entry
);
1292 eqe
= ehea_poll_eq(adapter
->neq
);
1293 pr_debug("next eqe=%p\n", eqe
);
1296 event_mask
= EHEA_BMASK_SET(NELR_PORTSTATE_CHG
, 1)
1297 | EHEA_BMASK_SET(NELR_ADAPTER_MALFUNC
, 1)
1298 | EHEA_BMASK_SET(NELR_PORT_MALFUNC
, 1);
1300 ehea_h_reset_events(adapter
->handle
,
1301 adapter
->neq
->fw_handle
, event_mask
);
1304 static irqreturn_t
ehea_interrupt_neq(int irq
, void *param
)
1306 struct ehea_adapter
*adapter
= param
;
1307 tasklet_hi_schedule(&adapter
->neq_tasklet
);
1312 static int ehea_fill_port_res(struct ehea_port_res
*pr
)
1315 struct ehea_qp_init_attr
*init_attr
= &pr
->qp
->init_attr
;
1317 ehea_init_fill_rq1(pr
, pr
->rq1_skba
.len
);
1319 ret
= ehea_refill_rq2(pr
, init_attr
->act_nr_rwqes_rq2
- 1);
1321 ret
|= ehea_refill_rq3(pr
, init_attr
->act_nr_rwqes_rq3
- 1);
1326 static int ehea_reg_interrupts(struct net_device
*dev
)
1328 struct ehea_port
*port
= netdev_priv(dev
);
1329 struct ehea_port_res
*pr
;
1333 snprintf(port
->int_aff_name
, EHEA_IRQ_NAME_SIZE
- 1, "%s-aff",
1336 ret
= ibmebus_request_irq(port
->qp_eq
->attr
.ist1
,
1337 ehea_qp_aff_irq_handler
,
1338 IRQF_DISABLED
, port
->int_aff_name
, port
);
1340 netdev_err(dev
, "failed registering irq for qp_aff_irq_handler:ist=%X\n",
1341 port
->qp_eq
->attr
.ist1
);
1345 netif_info(port
, ifup
, dev
,
1346 "irq_handle 0x%X for function qp_aff_irq_handler registered\n",
1347 port
->qp_eq
->attr
.ist1
);
1350 for (i
= 0; i
< port
->num_def_qps
; i
++) {
1351 pr
= &port
->port_res
[i
];
1352 snprintf(pr
->int_send_name
, EHEA_IRQ_NAME_SIZE
- 1,
1353 "%s-queue%d", dev
->name
, i
);
1354 ret
= ibmebus_request_irq(pr
->eq
->attr
.ist1
,
1355 ehea_recv_irq_handler
,
1356 IRQF_DISABLED
, pr
->int_send_name
,
1359 netdev_err(dev
, "failed registering irq for ehea_queue port_res_nr:%d, ist=%X\n",
1360 i
, pr
->eq
->attr
.ist1
);
1363 netif_info(port
, ifup
, dev
,
1364 "irq_handle 0x%X for function ehea_queue_int %d registered\n",
1365 pr
->eq
->attr
.ist1
, i
);
1373 u32 ist
= port
->port_res
[i
].eq
->attr
.ist1
;
1374 ibmebus_free_irq(ist
, &port
->port_res
[i
]);
1378 ibmebus_free_irq(port
->qp_eq
->attr
.ist1
, port
);
1379 i
= port
->num_def_qps
;
1385 static void ehea_free_interrupts(struct net_device
*dev
)
1387 struct ehea_port
*port
= netdev_priv(dev
);
1388 struct ehea_port_res
*pr
;
1393 for (i
= 0; i
< port
->num_def_qps
; i
++) {
1394 pr
= &port
->port_res
[i
];
1395 ibmebus_free_irq(pr
->eq
->attr
.ist1
, pr
);
1396 netif_info(port
, intr
, dev
,
1397 "free send irq for res %d with handle 0x%X\n",
1398 i
, pr
->eq
->attr
.ist1
);
1401 /* associated events */
1402 ibmebus_free_irq(port
->qp_eq
->attr
.ist1
, port
);
1403 netif_info(port
, intr
, dev
,
1404 "associated event interrupt for handle 0x%X freed\n",
1405 port
->qp_eq
->attr
.ist1
);
1408 static int ehea_configure_port(struct ehea_port
*port
)
1412 struct hcp_ehea_port_cb0
*cb0
;
1415 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
1419 cb0
->port_rc
= EHEA_BMASK_SET(PXLY_RC_VALID
, 1)
1420 | EHEA_BMASK_SET(PXLY_RC_IP_CHKSUM
, 1)
1421 | EHEA_BMASK_SET(PXLY_RC_TCP_UDP_CHKSUM
, 1)
1422 | EHEA_BMASK_SET(PXLY_RC_VLAN_XTRACT
, 1)
1423 | EHEA_BMASK_SET(PXLY_RC_VLAN_TAG_FILTER
,
1424 PXLY_RC_VLAN_FILTER
)
1425 | EHEA_BMASK_SET(PXLY_RC_JUMBO_FRAME
, 1);
1427 for (i
= 0; i
< port
->num_mcs
; i
++)
1429 cb0
->default_qpn_arr
[i
] =
1430 port
->port_res
[i
].qp
->init_attr
.qp_nr
;
1432 cb0
->default_qpn_arr
[i
] =
1433 port
->port_res
[0].qp
->init_attr
.qp_nr
;
1435 if (netif_msg_ifup(port
))
1436 ehea_dump(cb0
, sizeof(*cb0
), "ehea_configure_port");
1438 mask
= EHEA_BMASK_SET(H_PORT_CB0_PRC
, 1)
1439 | EHEA_BMASK_SET(H_PORT_CB0_DEFQPNARRAY
, 1);
1441 hret
= ehea_h_modify_ehea_port(port
->adapter
->handle
,
1442 port
->logical_port_id
,
1443 H_PORT_CB0
, mask
, cb0
);
1445 if (hret
!= H_SUCCESS
)
1451 free_page((unsigned long)cb0
);
1456 int ehea_gen_smrs(struct ehea_port_res
*pr
)
1459 struct ehea_adapter
*adapter
= pr
->port
->adapter
;
1461 ret
= ehea_gen_smr(adapter
, &adapter
->mr
, &pr
->send_mr
);
1465 ret
= ehea_gen_smr(adapter
, &adapter
->mr
, &pr
->recv_mr
);
1472 ehea_rem_mr(&pr
->send_mr
);
1474 pr_err("Generating SMRS failed\n");
1478 int ehea_rem_smrs(struct ehea_port_res
*pr
)
1480 if ((ehea_rem_mr(&pr
->send_mr
)) ||
1481 (ehea_rem_mr(&pr
->recv_mr
)))
1487 static int ehea_init_q_skba(struct ehea_q_skb_arr
*q_skba
, int max_q_entries
)
1489 int arr_size
= sizeof(void *) * max_q_entries
;
1491 q_skba
->arr
= vzalloc(arr_size
);
1495 q_skba
->len
= max_q_entries
;
1497 q_skba
->os_skbs
= 0;
1502 static int ehea_init_port_res(struct ehea_port
*port
, struct ehea_port_res
*pr
,
1503 struct port_res_cfg
*pr_cfg
, int queue_token
)
1505 struct ehea_adapter
*adapter
= port
->adapter
;
1506 enum ehea_eq_type eq_type
= EHEA_EQ
;
1507 struct ehea_qp_init_attr
*init_attr
= NULL
;
1509 u64 tx_bytes
, rx_bytes
, tx_packets
, rx_packets
;
1511 tx_bytes
= pr
->tx_bytes
;
1512 tx_packets
= pr
->tx_packets
;
1513 rx_bytes
= pr
->rx_bytes
;
1514 rx_packets
= pr
->rx_packets
;
1516 memset(pr
, 0, sizeof(struct ehea_port_res
));
1518 pr
->tx_bytes
= rx_bytes
;
1519 pr
->tx_packets
= tx_packets
;
1520 pr
->rx_bytes
= rx_bytes
;
1521 pr
->rx_packets
= rx_packets
;
1525 pr
->eq
= ehea_create_eq(adapter
, eq_type
, EHEA_MAX_ENTRIES_EQ
, 0);
1527 pr_err("create_eq failed (eq)\n");
1531 pr
->recv_cq
= ehea_create_cq(adapter
, pr_cfg
->max_entries_rcq
,
1533 port
->logical_port_id
);
1535 pr_err("create_cq failed (cq_recv)\n");
1539 pr
->send_cq
= ehea_create_cq(adapter
, pr_cfg
->max_entries_scq
,
1541 port
->logical_port_id
);
1543 pr_err("create_cq failed (cq_send)\n");
1547 if (netif_msg_ifup(port
))
1548 pr_info("Send CQ: act_nr_cqes=%d, Recv CQ: act_nr_cqes=%d\n",
1549 pr
->send_cq
->attr
.act_nr_of_cqes
,
1550 pr
->recv_cq
->attr
.act_nr_of_cqes
);
1552 init_attr
= kzalloc(sizeof(*init_attr
), GFP_KERNEL
);
1555 pr_err("no mem for ehea_qp_init_attr\n");
1559 init_attr
->low_lat_rq1
= 1;
1560 init_attr
->signalingtype
= 1; /* generate CQE if specified in WQE */
1561 init_attr
->rq_count
= 3;
1562 init_attr
->qp_token
= queue_token
;
1563 init_attr
->max_nr_send_wqes
= pr_cfg
->max_entries_sq
;
1564 init_attr
->max_nr_rwqes_rq1
= pr_cfg
->max_entries_rq1
;
1565 init_attr
->max_nr_rwqes_rq2
= pr_cfg
->max_entries_rq2
;
1566 init_attr
->max_nr_rwqes_rq3
= pr_cfg
->max_entries_rq3
;
1567 init_attr
->wqe_size_enc_sq
= EHEA_SG_SQ
;
1568 init_attr
->wqe_size_enc_rq1
= EHEA_SG_RQ1
;
1569 init_attr
->wqe_size_enc_rq2
= EHEA_SG_RQ2
;
1570 init_attr
->wqe_size_enc_rq3
= EHEA_SG_RQ3
;
1571 init_attr
->rq2_threshold
= EHEA_RQ2_THRESHOLD
;
1572 init_attr
->rq3_threshold
= EHEA_RQ3_THRESHOLD
;
1573 init_attr
->port_nr
= port
->logical_port_id
;
1574 init_attr
->send_cq_handle
= pr
->send_cq
->fw_handle
;
1575 init_attr
->recv_cq_handle
= pr
->recv_cq
->fw_handle
;
1576 init_attr
->aff_eq_handle
= port
->qp_eq
->fw_handle
;
1578 pr
->qp
= ehea_create_qp(adapter
, adapter
->pd
, init_attr
);
1580 pr_err("create_qp failed\n");
1585 if (netif_msg_ifup(port
))
1586 pr_info("QP: qp_nr=%d\n act_nr_snd_wqe=%d\n nr_rwqe_rq1=%d\n nr_rwqe_rq2=%d\n nr_rwqe_rq3=%d\n",
1588 init_attr
->act_nr_send_wqes
,
1589 init_attr
->act_nr_rwqes_rq1
,
1590 init_attr
->act_nr_rwqes_rq2
,
1591 init_attr
->act_nr_rwqes_rq3
);
1593 pr
->sq_skba_size
= init_attr
->act_nr_send_wqes
+ 1;
1595 ret
= ehea_init_q_skba(&pr
->sq_skba
, pr
->sq_skba_size
);
1596 ret
|= ehea_init_q_skba(&pr
->rq1_skba
, init_attr
->act_nr_rwqes_rq1
+ 1);
1597 ret
|= ehea_init_q_skba(&pr
->rq2_skba
, init_attr
->act_nr_rwqes_rq2
+ 1);
1598 ret
|= ehea_init_q_skba(&pr
->rq3_skba
, init_attr
->act_nr_rwqes_rq3
+ 1);
1602 pr
->swqe_refill_th
= init_attr
->act_nr_send_wqes
/ 10;
1603 if (ehea_gen_smrs(pr
) != 0) {
1608 atomic_set(&pr
->swqe_avail
, init_attr
->act_nr_send_wqes
- 1);
1612 netif_napi_add(pr
->port
->netdev
, &pr
->napi
, ehea_poll
, 64);
1614 pr
->lro_mgr
.max_aggr
= pr
->port
->lro_max_aggr
;
1615 pr
->lro_mgr
.max_desc
= MAX_LRO_DESCRIPTORS
;
1616 pr
->lro_mgr
.lro_arr
= pr
->lro_desc
;
1617 pr
->lro_mgr
.get_skb_header
= get_skb_hdr
;
1618 pr
->lro_mgr
.features
= LRO_F_NAPI
| LRO_F_EXTRACT_VLAN_ID
;
1619 pr
->lro_mgr
.dev
= port
->netdev
;
1620 pr
->lro_mgr
.ip_summed
= CHECKSUM_UNNECESSARY
;
1621 pr
->lro_mgr
.ip_summed_aggr
= CHECKSUM_UNNECESSARY
;
1628 vfree(pr
->sq_skba
.arr
);
1629 vfree(pr
->rq1_skba
.arr
);
1630 vfree(pr
->rq2_skba
.arr
);
1631 vfree(pr
->rq3_skba
.arr
);
1632 ehea_destroy_qp(pr
->qp
);
1633 ehea_destroy_cq(pr
->send_cq
);
1634 ehea_destroy_cq(pr
->recv_cq
);
1635 ehea_destroy_eq(pr
->eq
);
1640 static int ehea_clean_portres(struct ehea_port
*port
, struct ehea_port_res
*pr
)
1645 netif_napi_del(&pr
->napi
);
1647 ret
= ehea_destroy_qp(pr
->qp
);
1650 ehea_destroy_cq(pr
->send_cq
);
1651 ehea_destroy_cq(pr
->recv_cq
);
1652 ehea_destroy_eq(pr
->eq
);
1654 for (i
= 0; i
< pr
->rq1_skba
.len
; i
++)
1655 if (pr
->rq1_skba
.arr
[i
])
1656 dev_kfree_skb(pr
->rq1_skba
.arr
[i
]);
1658 for (i
= 0; i
< pr
->rq2_skba
.len
; i
++)
1659 if (pr
->rq2_skba
.arr
[i
])
1660 dev_kfree_skb(pr
->rq2_skba
.arr
[i
]);
1662 for (i
= 0; i
< pr
->rq3_skba
.len
; i
++)
1663 if (pr
->rq3_skba
.arr
[i
])
1664 dev_kfree_skb(pr
->rq3_skba
.arr
[i
]);
1666 for (i
= 0; i
< pr
->sq_skba
.len
; i
++)
1667 if (pr
->sq_skba
.arr
[i
])
1668 dev_kfree_skb(pr
->sq_skba
.arr
[i
]);
1670 vfree(pr
->rq1_skba
.arr
);
1671 vfree(pr
->rq2_skba
.arr
);
1672 vfree(pr
->rq3_skba
.arr
);
1673 vfree(pr
->sq_skba
.arr
);
1674 ret
= ehea_rem_smrs(pr
);
1680 * The write_* functions store information in swqe which is used by
1681 * the hardware to calculate the ip/tcp/udp checksum
1684 static inline void write_ip_start_end(struct ehea_swqe
*swqe
,
1685 const struct sk_buff
*skb
)
1687 swqe
->ip_start
= skb_network_offset(skb
);
1688 swqe
->ip_end
= (u8
)(swqe
->ip_start
+ ip_hdrlen(skb
) - 1);
1691 static inline void write_tcp_offset_end(struct ehea_swqe
*swqe
,
1692 const struct sk_buff
*skb
)
1695 (u8
)(swqe
->ip_end
+ 1 + offsetof(struct tcphdr
, check
));
1697 swqe
->tcp_end
= (u16
)skb
->len
- 1;
1700 static inline void write_udp_offset_end(struct ehea_swqe
*swqe
,
1701 const struct sk_buff
*skb
)
1704 (u8
)(swqe
->ip_end
+ 1 + offsetof(struct udphdr
, check
));
1706 swqe
->tcp_end
= (u16
)skb
->len
- 1;
1710 static void write_swqe2_TSO(struct sk_buff
*skb
,
1711 struct ehea_swqe
*swqe
, u32 lkey
)
1713 struct ehea_vsgentry
*sg1entry
= &swqe
->u
.immdata_desc
.sg_entry
;
1714 u8
*imm_data
= &swqe
->u
.immdata_desc
.immediate_data
[0];
1715 int skb_data_size
= skb_headlen(skb
);
1718 /* Packet is TCP with TSO enabled */
1719 swqe
->tx_control
|= EHEA_SWQE_TSO
;
1720 swqe
->mss
= skb_shinfo(skb
)->gso_size
;
1721 /* copy only eth/ip/tcp headers to immediate data and
1722 * the rest of skb->data to sg1entry
1724 headersize
= ETH_HLEN
+ ip_hdrlen(skb
) + tcp_hdrlen(skb
);
1726 skb_data_size
= skb_headlen(skb
);
1728 if (skb_data_size
>= headersize
) {
1729 /* copy immediate data */
1730 skb_copy_from_linear_data(skb
, imm_data
, headersize
);
1731 swqe
->immediate_data_length
= headersize
;
1733 if (skb_data_size
> headersize
) {
1734 /* set sg1entry data */
1735 sg1entry
->l_key
= lkey
;
1736 sg1entry
->len
= skb_data_size
- headersize
;
1738 ehea_map_vaddr(skb
->data
+ headersize
);
1739 swqe
->descriptors
++;
1742 pr_err("cannot handle fragmented headers\n");
1745 static void write_swqe2_nonTSO(struct sk_buff
*skb
,
1746 struct ehea_swqe
*swqe
, u32 lkey
)
1748 int skb_data_size
= skb_headlen(skb
);
1749 u8
*imm_data
= &swqe
->u
.immdata_desc
.immediate_data
[0];
1750 struct ehea_vsgentry
*sg1entry
= &swqe
->u
.immdata_desc
.sg_entry
;
1752 /* Packet is any nonTSO type
1754 * Copy as much as possible skb->data to immediate data and
1755 * the rest to sg1entry
1757 if (skb_data_size
>= SWQE2_MAX_IMM
) {
1758 /* copy immediate data */
1759 skb_copy_from_linear_data(skb
, imm_data
, SWQE2_MAX_IMM
);
1761 swqe
->immediate_data_length
= SWQE2_MAX_IMM
;
1763 if (skb_data_size
> SWQE2_MAX_IMM
) {
1764 /* copy sg1entry data */
1765 sg1entry
->l_key
= lkey
;
1766 sg1entry
->len
= skb_data_size
- SWQE2_MAX_IMM
;
1768 ehea_map_vaddr(skb
->data
+ SWQE2_MAX_IMM
);
1769 swqe
->descriptors
++;
1772 skb_copy_from_linear_data(skb
, imm_data
, skb_data_size
);
1773 swqe
->immediate_data_length
= skb_data_size
;
1777 static inline void write_swqe2_data(struct sk_buff
*skb
, struct net_device
*dev
,
1778 struct ehea_swqe
*swqe
, u32 lkey
)
1780 struct ehea_vsgentry
*sg_list
, *sg1entry
, *sgentry
;
1782 int nfrags
, sg1entry_contains_frag_data
, i
;
1784 nfrags
= skb_shinfo(skb
)->nr_frags
;
1785 sg1entry
= &swqe
->u
.immdata_desc
.sg_entry
;
1786 sg_list
= (struct ehea_vsgentry
*)&swqe
->u
.immdata_desc
.sg_list
;
1787 swqe
->descriptors
= 0;
1788 sg1entry_contains_frag_data
= 0;
1790 if ((dev
->features
& NETIF_F_TSO
) && skb_shinfo(skb
)->gso_size
)
1791 write_swqe2_TSO(skb
, swqe
, lkey
);
1793 write_swqe2_nonTSO(skb
, swqe
, lkey
);
1795 /* write descriptors */
1797 if (swqe
->descriptors
== 0) {
1798 /* sg1entry not yet used */
1799 frag
= &skb_shinfo(skb
)->frags
[0];
1801 /* copy sg1entry data */
1802 sg1entry
->l_key
= lkey
;
1803 sg1entry
->len
= frag
->size
;
1805 ehea_map_vaddr(skb_frag_address(frag
));
1806 swqe
->descriptors
++;
1807 sg1entry_contains_frag_data
= 1;
1810 for (i
= sg1entry_contains_frag_data
; i
< nfrags
; i
++) {
1812 frag
= &skb_shinfo(skb
)->frags
[i
];
1813 sgentry
= &sg_list
[i
- sg1entry_contains_frag_data
];
1815 sgentry
->l_key
= lkey
;
1816 sgentry
->len
= frag
->size
;
1817 sgentry
->vaddr
= ehea_map_vaddr(skb_frag_address(frag
));
1818 swqe
->descriptors
++;
1823 static int ehea_broadcast_reg_helper(struct ehea_port
*port
, u32 hcallid
)
1829 /* De/Register untagged packets */
1830 reg_type
= EHEA_BCMC_BROADCAST
| EHEA_BCMC_UNTAGGED
;
1831 hret
= ehea_h_reg_dereg_bcmc(port
->adapter
->handle
,
1832 port
->logical_port_id
,
1833 reg_type
, port
->mac_addr
, 0, hcallid
);
1834 if (hret
!= H_SUCCESS
) {
1835 pr_err("%sregistering bc address failed (tagged)\n",
1836 hcallid
== H_REG_BCMC
? "" : "de");
1841 /* De/Register VLAN packets */
1842 reg_type
= EHEA_BCMC_BROADCAST
| EHEA_BCMC_VLANID_ALL
;
1843 hret
= ehea_h_reg_dereg_bcmc(port
->adapter
->handle
,
1844 port
->logical_port_id
,
1845 reg_type
, port
->mac_addr
, 0, hcallid
);
1846 if (hret
!= H_SUCCESS
) {
1847 pr_err("%sregistering bc address failed (vlan)\n",
1848 hcallid
== H_REG_BCMC
? "" : "de");
1855 static int ehea_set_mac_addr(struct net_device
*dev
, void *sa
)
1857 struct ehea_port
*port
= netdev_priv(dev
);
1858 struct sockaddr
*mac_addr
= sa
;
1859 struct hcp_ehea_port_cb0
*cb0
;
1863 if (!is_valid_ether_addr(mac_addr
->sa_data
)) {
1864 ret
= -EADDRNOTAVAIL
;
1868 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
1870 pr_err("no mem for cb0\n");
1875 memcpy(&(cb0
->port_mac_addr
), &(mac_addr
->sa_data
[0]), ETH_ALEN
);
1877 cb0
->port_mac_addr
= cb0
->port_mac_addr
>> 16;
1879 hret
= ehea_h_modify_ehea_port(port
->adapter
->handle
,
1880 port
->logical_port_id
, H_PORT_CB0
,
1881 EHEA_BMASK_SET(H_PORT_CB0_MAC
, 1), cb0
);
1882 if (hret
!= H_SUCCESS
) {
1887 memcpy(dev
->dev_addr
, mac_addr
->sa_data
, dev
->addr_len
);
1889 /* Deregister old MAC in pHYP */
1890 if (port
->state
== EHEA_PORT_UP
) {
1891 ret
= ehea_broadcast_reg_helper(port
, H_DEREG_BCMC
);
1896 port
->mac_addr
= cb0
->port_mac_addr
<< 16;
1898 /* Register new MAC in pHYP */
1899 if (port
->state
== EHEA_PORT_UP
) {
1900 ret
= ehea_broadcast_reg_helper(port
, H_REG_BCMC
);
1908 ehea_update_bcmc_registrations();
1910 free_page((unsigned long)cb0
);
1915 static void ehea_promiscuous_error(u64 hret
, int enable
)
1917 if (hret
== H_AUTHORITY
)
1918 pr_info("Hypervisor denied %sabling promiscuous mode\n",
1919 enable
== 1 ? "en" : "dis");
1921 pr_err("failed %sabling promiscuous mode\n",
1922 enable
== 1 ? "en" : "dis");
1925 static void ehea_promiscuous(struct net_device
*dev
, int enable
)
1927 struct ehea_port
*port
= netdev_priv(dev
);
1928 struct hcp_ehea_port_cb7
*cb7
;
1931 if (enable
== port
->promisc
)
1934 cb7
= (void *)get_zeroed_page(GFP_ATOMIC
);
1936 pr_err("no mem for cb7\n");
1940 /* Modify Pxs_DUCQPN in CB7 */
1941 cb7
->def_uc_qpn
= enable
== 1 ? port
->port_res
[0].qp
->fw_handle
: 0;
1943 hret
= ehea_h_modify_ehea_port(port
->adapter
->handle
,
1944 port
->logical_port_id
,
1945 H_PORT_CB7
, H_PORT_CB7_DUCQPN
, cb7
);
1947 ehea_promiscuous_error(hret
, enable
);
1951 port
->promisc
= enable
;
1953 free_page((unsigned long)cb7
);
1956 static u64
ehea_multicast_reg_helper(struct ehea_port
*port
, u64 mc_mac_addr
,
1962 reg_type
= EHEA_BCMC_SCOPE_ALL
| EHEA_BCMC_MULTICAST
1963 | EHEA_BCMC_UNTAGGED
;
1965 hret
= ehea_h_reg_dereg_bcmc(port
->adapter
->handle
,
1966 port
->logical_port_id
,
1967 reg_type
, mc_mac_addr
, 0, hcallid
);
1971 reg_type
= EHEA_BCMC_SCOPE_ALL
| EHEA_BCMC_MULTICAST
1972 | EHEA_BCMC_VLANID_ALL
;
1974 hret
= ehea_h_reg_dereg_bcmc(port
->adapter
->handle
,
1975 port
->logical_port_id
,
1976 reg_type
, mc_mac_addr
, 0, hcallid
);
1981 static int ehea_drop_multicast_list(struct net_device
*dev
)
1983 struct ehea_port
*port
= netdev_priv(dev
);
1984 struct ehea_mc_list
*mc_entry
= port
->mc_list
;
1985 struct list_head
*pos
;
1986 struct list_head
*temp
;
1990 list_for_each_safe(pos
, temp
, &(port
->mc_list
->list
)) {
1991 mc_entry
= list_entry(pos
, struct ehea_mc_list
, list
);
1993 hret
= ehea_multicast_reg_helper(port
, mc_entry
->macaddr
,
1996 pr_err("failed deregistering mcast MAC\n");
2006 static void ehea_allmulti(struct net_device
*dev
, int enable
)
2008 struct ehea_port
*port
= netdev_priv(dev
);
2011 if (!port
->allmulti
) {
2013 /* Enable ALLMULTI */
2014 ehea_drop_multicast_list(dev
);
2015 hret
= ehea_multicast_reg_helper(port
, 0, H_REG_BCMC
);
2020 "failed enabling IFF_ALLMULTI\n");
2024 /* Disable ALLMULTI */
2025 hret
= ehea_multicast_reg_helper(port
, 0, H_DEREG_BCMC
);
2030 "failed disabling IFF_ALLMULTI\n");
2034 static void ehea_add_multicast_entry(struct ehea_port
*port
, u8
*mc_mac_addr
)
2036 struct ehea_mc_list
*ehea_mcl_entry
;
2039 ehea_mcl_entry
= kzalloc(sizeof(*ehea_mcl_entry
), GFP_ATOMIC
);
2040 if (!ehea_mcl_entry
) {
2041 pr_err("no mem for mcl_entry\n");
2045 INIT_LIST_HEAD(&ehea_mcl_entry
->list
);
2047 memcpy(&ehea_mcl_entry
->macaddr
, mc_mac_addr
, ETH_ALEN
);
2049 hret
= ehea_multicast_reg_helper(port
, ehea_mcl_entry
->macaddr
,
2052 list_add(&ehea_mcl_entry
->list
, &port
->mc_list
->list
);
2054 pr_err("failed registering mcast MAC\n");
2055 kfree(ehea_mcl_entry
);
2059 static void ehea_set_multicast_list(struct net_device
*dev
)
2061 struct ehea_port
*port
= netdev_priv(dev
);
2062 struct netdev_hw_addr
*ha
;
2065 if (port
->promisc
) {
2066 ehea_promiscuous(dev
, 1);
2069 ehea_promiscuous(dev
, 0);
2071 if (dev
->flags
& IFF_ALLMULTI
) {
2072 ehea_allmulti(dev
, 1);
2075 ehea_allmulti(dev
, 0);
2077 if (!netdev_mc_empty(dev
)) {
2078 ret
= ehea_drop_multicast_list(dev
);
2080 /* Dropping the current multicast list failed.
2081 * Enabling ALL_MULTI is the best we can do.
2083 ehea_allmulti(dev
, 1);
2086 if (netdev_mc_count(dev
) > port
->adapter
->max_mc_mac
) {
2087 pr_info("Mcast registration limit reached (0x%llx). Use ALLMULTI!\n",
2088 port
->adapter
->max_mc_mac
);
2092 netdev_for_each_mc_addr(ha
, dev
)
2093 ehea_add_multicast_entry(port
, ha
->addr
);
2097 ehea_update_bcmc_registrations();
2100 static int ehea_change_mtu(struct net_device
*dev
, int new_mtu
)
2102 if ((new_mtu
< 68) || (new_mtu
> EHEA_MAX_PACKET_SIZE
))
2108 static void ehea_xmit2(struct sk_buff
*skb
, struct net_device
*dev
,
2109 struct ehea_swqe
*swqe
, u32 lkey
)
2111 if (skb
->protocol
== htons(ETH_P_IP
)) {
2112 const struct iphdr
*iph
= ip_hdr(skb
);
2115 swqe
->tx_control
|= EHEA_SWQE_CRC
2116 | EHEA_SWQE_IP_CHECKSUM
2117 | EHEA_SWQE_TCP_CHECKSUM
2118 | EHEA_SWQE_IMM_DATA_PRESENT
2119 | EHEA_SWQE_DESCRIPTORS_PRESENT
;
2121 write_ip_start_end(swqe
, skb
);
2123 if (iph
->protocol
== IPPROTO_UDP
) {
2124 if ((iph
->frag_off
& IP_MF
) ||
2125 (iph
->frag_off
& IP_OFFSET
))
2126 /* IP fragment, so don't change cs */
2127 swqe
->tx_control
&= ~EHEA_SWQE_TCP_CHECKSUM
;
2129 write_udp_offset_end(swqe
, skb
);
2130 } else if (iph
->protocol
== IPPROTO_TCP
) {
2131 write_tcp_offset_end(swqe
, skb
);
2134 /* icmp (big data) and ip segmentation packets (all other ip
2135 packets) do not require any special handling */
2138 /* Other Ethernet Protocol */
2139 swqe
->tx_control
|= EHEA_SWQE_CRC
2140 | EHEA_SWQE_IMM_DATA_PRESENT
2141 | EHEA_SWQE_DESCRIPTORS_PRESENT
;
2144 write_swqe2_data(skb
, dev
, swqe
, lkey
);
2147 static void ehea_xmit3(struct sk_buff
*skb
, struct net_device
*dev
,
2148 struct ehea_swqe
*swqe
)
2150 int nfrags
= skb_shinfo(skb
)->nr_frags
;
2151 u8
*imm_data
= &swqe
->u
.immdata_nodesc
.immediate_data
[0];
2155 if (skb
->protocol
== htons(ETH_P_IP
)) {
2156 const struct iphdr
*iph
= ip_hdr(skb
);
2159 write_ip_start_end(swqe
, skb
);
2161 if (iph
->protocol
== IPPROTO_TCP
) {
2162 swqe
->tx_control
|= EHEA_SWQE_CRC
2163 | EHEA_SWQE_IP_CHECKSUM
2164 | EHEA_SWQE_TCP_CHECKSUM
2165 | EHEA_SWQE_IMM_DATA_PRESENT
;
2167 write_tcp_offset_end(swqe
, skb
);
2169 } else if (iph
->protocol
== IPPROTO_UDP
) {
2170 if ((iph
->frag_off
& IP_MF
) ||
2171 (iph
->frag_off
& IP_OFFSET
))
2172 /* IP fragment, so don't change cs */
2173 swqe
->tx_control
|= EHEA_SWQE_CRC
2174 | EHEA_SWQE_IMM_DATA_PRESENT
;
2176 swqe
->tx_control
|= EHEA_SWQE_CRC
2177 | EHEA_SWQE_IP_CHECKSUM
2178 | EHEA_SWQE_TCP_CHECKSUM
2179 | EHEA_SWQE_IMM_DATA_PRESENT
;
2181 write_udp_offset_end(swqe
, skb
);
2184 /* icmp (big data) and
2185 ip segmentation packets (all other ip packets) */
2186 swqe
->tx_control
|= EHEA_SWQE_CRC
2187 | EHEA_SWQE_IP_CHECKSUM
2188 | EHEA_SWQE_IMM_DATA_PRESENT
;
2191 /* Other Ethernet Protocol */
2192 swqe
->tx_control
|= EHEA_SWQE_CRC
| EHEA_SWQE_IMM_DATA_PRESENT
;
2194 /* copy (immediate) data */
2196 /* data is in a single piece */
2197 skb_copy_from_linear_data(skb
, imm_data
, skb
->len
);
2199 /* first copy data from the skb->data buffer ... */
2200 skb_copy_from_linear_data(skb
, imm_data
,
2202 imm_data
+= skb_headlen(skb
);
2204 /* ... then copy data from the fragments */
2205 for (i
= 0; i
< nfrags
; i
++) {
2206 frag
= &skb_shinfo(skb
)->frags
[i
];
2207 memcpy(imm_data
, skb_frag_address(frag
), frag
->size
);
2208 imm_data
+= frag
->size
;
2211 swqe
->immediate_data_length
= skb
->len
;
2215 static int ehea_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
2217 struct ehea_port
*port
= netdev_priv(dev
);
2218 struct ehea_swqe
*swqe
;
2221 struct ehea_port_res
*pr
;
2222 struct netdev_queue
*txq
;
2224 pr
= &port
->port_res
[skb_get_queue_mapping(skb
)];
2225 txq
= netdev_get_tx_queue(dev
, skb_get_queue_mapping(skb
));
2227 swqe
= ehea_get_swqe(pr
->qp
, &swqe_index
);
2228 memset(swqe
, 0, SWQE_HEADER_SIZE
);
2229 atomic_dec(&pr
->swqe_avail
);
2231 if (vlan_tx_tag_present(skb
)) {
2232 swqe
->tx_control
|= EHEA_SWQE_VLAN_INSERT
;
2233 swqe
->vlan_tag
= vlan_tx_tag_get(skb
);
2237 pr
->tx_bytes
+= skb
->len
;
2239 if (skb
->len
<= SWQE3_MAX_IMM
) {
2240 u32 sig_iv
= port
->sig_comp_iv
;
2241 u32 swqe_num
= pr
->swqe_id_counter
;
2242 ehea_xmit3(skb
, dev
, swqe
);
2243 swqe
->wr_id
= EHEA_BMASK_SET(EHEA_WR_ID_TYPE
, EHEA_SWQE3_TYPE
)
2244 | EHEA_BMASK_SET(EHEA_WR_ID_COUNT
, swqe_num
);
2245 if (pr
->swqe_ll_count
>= (sig_iv
- 1)) {
2246 swqe
->wr_id
|= EHEA_BMASK_SET(EHEA_WR_ID_REFILL
,
2248 swqe
->tx_control
|= EHEA_SWQE_SIGNALLED_COMPLETION
;
2249 pr
->swqe_ll_count
= 0;
2251 pr
->swqe_ll_count
+= 1;
2254 EHEA_BMASK_SET(EHEA_WR_ID_TYPE
, EHEA_SWQE2_TYPE
)
2255 | EHEA_BMASK_SET(EHEA_WR_ID_COUNT
, pr
->swqe_id_counter
)
2256 | EHEA_BMASK_SET(EHEA_WR_ID_REFILL
, 1)
2257 | EHEA_BMASK_SET(EHEA_WR_ID_INDEX
, pr
->sq_skba
.index
);
2258 pr
->sq_skba
.arr
[pr
->sq_skba
.index
] = skb
;
2260 pr
->sq_skba
.index
++;
2261 pr
->sq_skba
.index
&= (pr
->sq_skba
.len
- 1);
2263 lkey
= pr
->send_mr
.lkey
;
2264 ehea_xmit2(skb
, dev
, swqe
, lkey
);
2265 swqe
->tx_control
|= EHEA_SWQE_SIGNALLED_COMPLETION
;
2267 pr
->swqe_id_counter
+= 1;
2269 netif_info(port
, tx_queued
, dev
,
2270 "post swqe on QP %d\n", pr
->qp
->init_attr
.qp_nr
);
2271 if (netif_msg_tx_queued(port
))
2272 ehea_dump(swqe
, 512, "swqe");
2274 if (unlikely(test_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
))) {
2275 netif_tx_stop_queue(txq
);
2276 swqe
->tx_control
|= EHEA_SWQE_PURGE
;
2279 ehea_post_swqe(pr
->qp
, swqe
);
2281 if (unlikely(atomic_read(&pr
->swqe_avail
) <= 1)) {
2282 pr
->p_stats
.queue_stopped
++;
2283 netif_tx_stop_queue(txq
);
2286 return NETDEV_TX_OK
;
2289 static void ehea_vlan_rx_add_vid(struct net_device
*dev
, unsigned short vid
)
2291 struct ehea_port
*port
= netdev_priv(dev
);
2292 struct ehea_adapter
*adapter
= port
->adapter
;
2293 struct hcp_ehea_port_cb1
*cb1
;
2297 cb1
= (void *)get_zeroed_page(GFP_KERNEL
);
2299 pr_err("no mem for cb1\n");
2303 hret
= ehea_h_query_ehea_port(adapter
->handle
, port
->logical_port_id
,
2304 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2305 if (hret
!= H_SUCCESS
) {
2306 pr_err("query_ehea_port failed\n");
2311 cb1
->vlan_filter
[index
] |= ((u64
)(0x8000000000000000 >> (vid
& 0x3F)));
2313 hret
= ehea_h_modify_ehea_port(adapter
->handle
, port
->logical_port_id
,
2314 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2315 if (hret
!= H_SUCCESS
)
2316 pr_err("modify_ehea_port failed\n");
2318 free_page((unsigned long)cb1
);
2322 static void ehea_vlan_rx_kill_vid(struct net_device
*dev
, unsigned short vid
)
2324 struct ehea_port
*port
= netdev_priv(dev
);
2325 struct ehea_adapter
*adapter
= port
->adapter
;
2326 struct hcp_ehea_port_cb1
*cb1
;
2330 cb1
= (void *)get_zeroed_page(GFP_KERNEL
);
2332 pr_err("no mem for cb1\n");
2336 hret
= ehea_h_query_ehea_port(adapter
->handle
, port
->logical_port_id
,
2337 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2338 if (hret
!= H_SUCCESS
) {
2339 pr_err("query_ehea_port failed\n");
2344 cb1
->vlan_filter
[index
] &= ~((u64
)(0x8000000000000000 >> (vid
& 0x3F)));
2346 hret
= ehea_h_modify_ehea_port(adapter
->handle
, port
->logical_port_id
,
2347 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2348 if (hret
!= H_SUCCESS
)
2349 pr_err("modify_ehea_port failed\n");
2351 free_page((unsigned long)cb1
);
2354 int ehea_activate_qp(struct ehea_adapter
*adapter
, struct ehea_qp
*qp
)
2360 struct hcp_modify_qp_cb0
*cb0
;
2362 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
2368 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2369 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF), cb0
);
2370 if (hret
!= H_SUCCESS
) {
2371 pr_err("query_ehea_qp failed (1)\n");
2375 cb0
->qp_ctl_reg
= H_QP_CR_STATE_INITIALIZED
;
2376 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2377 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
, 1), cb0
,
2378 &dummy64
, &dummy64
, &dummy16
, &dummy16
);
2379 if (hret
!= H_SUCCESS
) {
2380 pr_err("modify_ehea_qp failed (1)\n");
2384 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2385 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF), cb0
);
2386 if (hret
!= H_SUCCESS
) {
2387 pr_err("query_ehea_qp failed (2)\n");
2391 cb0
->qp_ctl_reg
= H_QP_CR_ENABLED
| H_QP_CR_STATE_INITIALIZED
;
2392 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2393 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
, 1), cb0
,
2394 &dummy64
, &dummy64
, &dummy16
, &dummy16
);
2395 if (hret
!= H_SUCCESS
) {
2396 pr_err("modify_ehea_qp failed (2)\n");
2400 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2401 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF), cb0
);
2402 if (hret
!= H_SUCCESS
) {
2403 pr_err("query_ehea_qp failed (3)\n");
2407 cb0
->qp_ctl_reg
= H_QP_CR_ENABLED
| H_QP_CR_STATE_RDY2SND
;
2408 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2409 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
, 1), cb0
,
2410 &dummy64
, &dummy64
, &dummy16
, &dummy16
);
2411 if (hret
!= H_SUCCESS
) {
2412 pr_err("modify_ehea_qp failed (3)\n");
2416 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2417 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF), cb0
);
2418 if (hret
!= H_SUCCESS
) {
2419 pr_err("query_ehea_qp failed (4)\n");
2425 free_page((unsigned long)cb0
);
2429 static int ehea_port_res_setup(struct ehea_port
*port
, int def_qps
)
2432 struct port_res_cfg pr_cfg
, pr_cfg_small_rx
;
2433 enum ehea_eq_type eq_type
= EHEA_EQ
;
2435 port
->qp_eq
= ehea_create_eq(port
->adapter
, eq_type
,
2436 EHEA_MAX_ENTRIES_EQ
, 1);
2439 pr_err("ehea_create_eq failed (qp_eq)\n");
2443 pr_cfg
.max_entries_rcq
= rq1_entries
+ rq2_entries
+ rq3_entries
;
2444 pr_cfg
.max_entries_scq
= sq_entries
* 2;
2445 pr_cfg
.max_entries_sq
= sq_entries
;
2446 pr_cfg
.max_entries_rq1
= rq1_entries
;
2447 pr_cfg
.max_entries_rq2
= rq2_entries
;
2448 pr_cfg
.max_entries_rq3
= rq3_entries
;
2450 pr_cfg_small_rx
.max_entries_rcq
= 1;
2451 pr_cfg_small_rx
.max_entries_scq
= sq_entries
;
2452 pr_cfg_small_rx
.max_entries_sq
= sq_entries
;
2453 pr_cfg_small_rx
.max_entries_rq1
= 1;
2454 pr_cfg_small_rx
.max_entries_rq2
= 1;
2455 pr_cfg_small_rx
.max_entries_rq3
= 1;
2457 for (i
= 0; i
< def_qps
; i
++) {
2458 ret
= ehea_init_port_res(port
, &port
->port_res
[i
], &pr_cfg
, i
);
2462 for (i
= def_qps
; i
< def_qps
; i
++) {
2463 ret
= ehea_init_port_res(port
, &port
->port_res
[i
],
2464 &pr_cfg_small_rx
, i
);
2473 ehea_clean_portres(port
, &port
->port_res
[i
]);
2476 ehea_destroy_eq(port
->qp_eq
);
2480 static int ehea_clean_all_portres(struct ehea_port
*port
)
2485 for (i
= 0; i
< port
->num_def_qps
; i
++)
2486 ret
|= ehea_clean_portres(port
, &port
->port_res
[i
]);
2488 ret
|= ehea_destroy_eq(port
->qp_eq
);
2493 static void ehea_remove_adapter_mr(struct ehea_adapter
*adapter
)
2495 if (adapter
->active_ports
)
2498 ehea_rem_mr(&adapter
->mr
);
2501 static int ehea_add_adapter_mr(struct ehea_adapter
*adapter
)
2503 if (adapter
->active_ports
)
2506 return ehea_reg_kernel_mr(adapter
, &adapter
->mr
);
2509 static int ehea_up(struct net_device
*dev
)
2512 struct ehea_port
*port
= netdev_priv(dev
);
2514 if (port
->state
== EHEA_PORT_UP
)
2517 ret
= ehea_port_res_setup(port
, port
->num_def_qps
);
2519 netdev_err(dev
, "port_res_failed\n");
2523 /* Set default QP for this port */
2524 ret
= ehea_configure_port(port
);
2526 netdev_err(dev
, "ehea_configure_port failed. ret:%d\n", ret
);
2530 ret
= ehea_reg_interrupts(dev
);
2532 netdev_err(dev
, "reg_interrupts failed. ret:%d\n", ret
);
2536 for (i
= 0; i
< port
->num_def_qps
; i
++) {
2537 ret
= ehea_activate_qp(port
->adapter
, port
->port_res
[i
].qp
);
2539 netdev_err(dev
, "activate_qp failed\n");
2544 for (i
= 0; i
< port
->num_def_qps
; i
++) {
2545 ret
= ehea_fill_port_res(&port
->port_res
[i
]);
2547 netdev_err(dev
, "out_free_irqs\n");
2552 ret
= ehea_broadcast_reg_helper(port
, H_REG_BCMC
);
2558 port
->state
= EHEA_PORT_UP
;
2564 ehea_free_interrupts(dev
);
2567 ehea_clean_all_portres(port
);
2570 netdev_info(dev
, "Failed starting. ret=%i\n", ret
);
2572 ehea_update_bcmc_registrations();
2573 ehea_update_firmware_handles();
2578 static void port_napi_disable(struct ehea_port
*port
)
2582 for (i
= 0; i
< port
->num_def_qps
; i
++)
2583 napi_disable(&port
->port_res
[i
].napi
);
2586 static void port_napi_enable(struct ehea_port
*port
)
2590 for (i
= 0; i
< port
->num_def_qps
; i
++)
2591 napi_enable(&port
->port_res
[i
].napi
);
2594 static int ehea_open(struct net_device
*dev
)
2597 struct ehea_port
*port
= netdev_priv(dev
);
2599 mutex_lock(&port
->port_lock
);
2601 netif_info(port
, ifup
, dev
, "enabling port\n");
2605 port_napi_enable(port
);
2606 netif_tx_start_all_queues(dev
);
2609 mutex_unlock(&port
->port_lock
);
2610 schedule_delayed_work(&port
->stats_work
, msecs_to_jiffies(1000));
2615 static int ehea_down(struct net_device
*dev
)
2618 struct ehea_port
*port
= netdev_priv(dev
);
2620 if (port
->state
== EHEA_PORT_DOWN
)
2623 ehea_drop_multicast_list(dev
);
2624 ehea_broadcast_reg_helper(port
, H_DEREG_BCMC
);
2626 ehea_free_interrupts(dev
);
2628 port
->state
= EHEA_PORT_DOWN
;
2630 ehea_update_bcmc_registrations();
2632 ret
= ehea_clean_all_portres(port
);
2634 netdev_info(dev
, "Failed freeing resources. ret=%i\n", ret
);
2636 ehea_update_firmware_handles();
2641 static int ehea_stop(struct net_device
*dev
)
2644 struct ehea_port
*port
= netdev_priv(dev
);
2646 netif_info(port
, ifdown
, dev
, "disabling port\n");
2648 set_bit(__EHEA_DISABLE_PORT_RESET
, &port
->flags
);
2649 cancel_work_sync(&port
->reset_task
);
2650 cancel_delayed_work_sync(&port
->stats_work
);
2651 mutex_lock(&port
->port_lock
);
2652 netif_tx_stop_all_queues(dev
);
2653 port_napi_disable(port
);
2654 ret
= ehea_down(dev
);
2655 mutex_unlock(&port
->port_lock
);
2656 clear_bit(__EHEA_DISABLE_PORT_RESET
, &port
->flags
);
2660 static void ehea_purge_sq(struct ehea_qp
*orig_qp
)
2662 struct ehea_qp qp
= *orig_qp
;
2663 struct ehea_qp_init_attr
*init_attr
= &qp
.init_attr
;
2664 struct ehea_swqe
*swqe
;
2668 for (i
= 0; i
< init_attr
->act_nr_send_wqes
; i
++) {
2669 swqe
= ehea_get_swqe(&qp
, &wqe_index
);
2670 swqe
->tx_control
|= EHEA_SWQE_PURGE
;
2674 static void ehea_flush_sq(struct ehea_port
*port
)
2678 for (i
= 0; i
< port
->num_def_qps
; i
++) {
2679 struct ehea_port_res
*pr
= &port
->port_res
[i
];
2680 int swqe_max
= pr
->sq_skba_size
- 2 - pr
->swqe_ll_count
;
2683 ret
= wait_event_timeout(port
->swqe_avail_wq
,
2684 atomic_read(&pr
->swqe_avail
) >= swqe_max
,
2685 msecs_to_jiffies(100));
2688 pr_err("WARNING: sq not flushed completely\n");
2694 int ehea_stop_qps(struct net_device
*dev
)
2696 struct ehea_port
*port
= netdev_priv(dev
);
2697 struct ehea_adapter
*adapter
= port
->adapter
;
2698 struct hcp_modify_qp_cb0
*cb0
;
2706 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
2712 for (i
= 0; i
< (port
->num_def_qps
); i
++) {
2713 struct ehea_port_res
*pr
= &port
->port_res
[i
];
2714 struct ehea_qp
*qp
= pr
->qp
;
2716 /* Purge send queue */
2719 /* Disable queue pair */
2720 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2721 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF),
2723 if (hret
!= H_SUCCESS
) {
2724 pr_err("query_ehea_qp failed (1)\n");
2728 cb0
->qp_ctl_reg
= (cb0
->qp_ctl_reg
& H_QP_CR_RES_STATE
) << 8;
2729 cb0
->qp_ctl_reg
&= ~H_QP_CR_ENABLED
;
2731 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2732 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
,
2734 &dummy64
, &dummy16
, &dummy16
);
2735 if (hret
!= H_SUCCESS
) {
2736 pr_err("modify_ehea_qp failed (1)\n");
2740 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2741 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF),
2743 if (hret
!= H_SUCCESS
) {
2744 pr_err("query_ehea_qp failed (2)\n");
2748 /* deregister shared memory regions */
2749 dret
= ehea_rem_smrs(pr
);
2751 pr_err("unreg shared memory region failed\n");
2758 free_page((unsigned long)cb0
);
2763 void ehea_update_rqs(struct ehea_qp
*orig_qp
, struct ehea_port_res
*pr
)
2765 struct ehea_qp qp
= *orig_qp
;
2766 struct ehea_qp_init_attr
*init_attr
= &qp
.init_attr
;
2767 struct ehea_rwqe
*rwqe
;
2768 struct sk_buff
**skba_rq2
= pr
->rq2_skba
.arr
;
2769 struct sk_buff
**skba_rq3
= pr
->rq3_skba
.arr
;
2770 struct sk_buff
*skb
;
2771 u32 lkey
= pr
->recv_mr
.lkey
;
2777 for (i
= 0; i
< init_attr
->act_nr_rwqes_rq2
+ 1; i
++) {
2778 rwqe
= ehea_get_next_rwqe(&qp
, 2);
2779 rwqe
->sg_list
[0].l_key
= lkey
;
2780 index
= EHEA_BMASK_GET(EHEA_WR_ID_INDEX
, rwqe
->wr_id
);
2781 skb
= skba_rq2
[index
];
2783 rwqe
->sg_list
[0].vaddr
= ehea_map_vaddr(skb
->data
);
2786 for (i
= 0; i
< init_attr
->act_nr_rwqes_rq3
+ 1; i
++) {
2787 rwqe
= ehea_get_next_rwqe(&qp
, 3);
2788 rwqe
->sg_list
[0].l_key
= lkey
;
2789 index
= EHEA_BMASK_GET(EHEA_WR_ID_INDEX
, rwqe
->wr_id
);
2790 skb
= skba_rq3
[index
];
2792 rwqe
->sg_list
[0].vaddr
= ehea_map_vaddr(skb
->data
);
2796 int ehea_restart_qps(struct net_device
*dev
)
2798 struct ehea_port
*port
= netdev_priv(dev
);
2799 struct ehea_adapter
*adapter
= port
->adapter
;
2803 struct hcp_modify_qp_cb0
*cb0
;
2808 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
2814 for (i
= 0; i
< (port
->num_def_qps
); i
++) {
2815 struct ehea_port_res
*pr
= &port
->port_res
[i
];
2816 struct ehea_qp
*qp
= pr
->qp
;
2818 ret
= ehea_gen_smrs(pr
);
2820 netdev_err(dev
, "creation of shared memory regions failed\n");
2824 ehea_update_rqs(qp
, pr
);
2826 /* Enable queue pair */
2827 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2828 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF),
2830 if (hret
!= H_SUCCESS
) {
2831 netdev_err(dev
, "query_ehea_qp failed (1)\n");
2835 cb0
->qp_ctl_reg
= (cb0
->qp_ctl_reg
& H_QP_CR_RES_STATE
) << 8;
2836 cb0
->qp_ctl_reg
|= H_QP_CR_ENABLED
;
2838 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2839 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
,
2841 &dummy64
, &dummy16
, &dummy16
);
2842 if (hret
!= H_SUCCESS
) {
2843 netdev_err(dev
, "modify_ehea_qp failed (1)\n");
2847 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2848 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF),
2850 if (hret
!= H_SUCCESS
) {
2851 netdev_err(dev
, "query_ehea_qp failed (2)\n");
2855 /* refill entire queue */
2856 ehea_refill_rq1(pr
, pr
->rq1_skba
.index
, 0);
2857 ehea_refill_rq2(pr
, 0);
2858 ehea_refill_rq3(pr
, 0);
2861 free_page((unsigned long)cb0
);
2866 static void ehea_reset_port(struct work_struct
*work
)
2869 struct ehea_port
*port
=
2870 container_of(work
, struct ehea_port
, reset_task
);
2871 struct net_device
*dev
= port
->netdev
;
2873 mutex_lock(&dlpar_mem_lock
);
2875 mutex_lock(&port
->port_lock
);
2876 netif_tx_disable(dev
);
2878 port_napi_disable(port
);
2886 ehea_set_multicast_list(dev
);
2888 netif_info(port
, timer
, dev
, "reset successful\n");
2890 port_napi_enable(port
);
2892 netif_tx_wake_all_queues(dev
);
2894 mutex_unlock(&port
->port_lock
);
2895 mutex_unlock(&dlpar_mem_lock
);
2898 static void ehea_rereg_mrs(void)
2901 struct ehea_adapter
*adapter
;
2903 pr_info("LPAR memory changed - re-initializing driver\n");
2905 list_for_each_entry(adapter
, &adapter_list
, list
)
2906 if (adapter
->active_ports
) {
2907 /* Shutdown all ports */
2908 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++) {
2909 struct ehea_port
*port
= adapter
->port
[i
];
2910 struct net_device
*dev
;
2917 if (dev
->flags
& IFF_UP
) {
2918 mutex_lock(&port
->port_lock
);
2919 netif_tx_disable(dev
);
2920 ehea_flush_sq(port
);
2921 ret
= ehea_stop_qps(dev
);
2923 mutex_unlock(&port
->port_lock
);
2926 port_napi_disable(port
);
2927 mutex_unlock(&port
->port_lock
);
2929 reset_sq_restart_flag(port
);
2932 /* Unregister old memory region */
2933 ret
= ehea_rem_mr(&adapter
->mr
);
2935 pr_err("unregister MR failed - driver inoperable!\n");
2940 clear_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
);
2942 list_for_each_entry(adapter
, &adapter_list
, list
)
2943 if (adapter
->active_ports
) {
2944 /* Register new memory region */
2945 ret
= ehea_reg_kernel_mr(adapter
, &adapter
->mr
);
2947 pr_err("register MR failed - driver inoperable!\n");
2951 /* Restart all ports */
2952 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++) {
2953 struct ehea_port
*port
= adapter
->port
[i
];
2956 struct net_device
*dev
= port
->netdev
;
2958 if (dev
->flags
& IFF_UP
) {
2959 mutex_lock(&port
->port_lock
);
2960 ret
= ehea_restart_qps(dev
);
2963 port_napi_enable(port
);
2964 netif_tx_wake_all_queues(dev
);
2966 netdev_err(dev
, "Unable to restart QPS\n");
2968 mutex_unlock(&port
->port_lock
);
2973 pr_info("re-initializing driver complete\n");
2978 static void ehea_tx_watchdog(struct net_device
*dev
)
2980 struct ehea_port
*port
= netdev_priv(dev
);
2982 if (netif_carrier_ok(dev
) &&
2983 !test_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
))
2984 ehea_schedule_port_reset(port
);
2987 int ehea_sense_adapter_attr(struct ehea_adapter
*adapter
)
2989 struct hcp_query_ehea
*cb
;
2993 cb
= (void *)get_zeroed_page(GFP_KERNEL
);
2999 hret
= ehea_h_query_ehea(adapter
->handle
, cb
);
3001 if (hret
!= H_SUCCESS
) {
3006 adapter
->max_mc_mac
= cb
->max_mc_mac
- 1;
3010 free_page((unsigned long)cb
);
3015 int ehea_get_jumboframe_status(struct ehea_port
*port
, int *jumbo
)
3017 struct hcp_ehea_port_cb4
*cb4
;
3023 /* (Try to) enable *jumbo frames */
3024 cb4
= (void *)get_zeroed_page(GFP_KERNEL
);
3026 pr_err("no mem for cb4\n");
3030 hret
= ehea_h_query_ehea_port(port
->adapter
->handle
,
3031 port
->logical_port_id
,
3033 H_PORT_CB4_JUMBO
, cb4
);
3034 if (hret
== H_SUCCESS
) {
3035 if (cb4
->jumbo_frame
)
3038 cb4
->jumbo_frame
= 1;
3039 hret
= ehea_h_modify_ehea_port(port
->adapter
->
3046 if (hret
== H_SUCCESS
)
3052 free_page((unsigned long)cb4
);
3058 static ssize_t
ehea_show_port_id(struct device
*dev
,
3059 struct device_attribute
*attr
, char *buf
)
3061 struct ehea_port
*port
= container_of(dev
, struct ehea_port
, ofdev
.dev
);
3062 return sprintf(buf
, "%d", port
->logical_port_id
);
3065 static DEVICE_ATTR(log_port_id
, S_IRUSR
| S_IRGRP
| S_IROTH
, ehea_show_port_id
,
3068 static void __devinit
logical_port_release(struct device
*dev
)
3070 struct ehea_port
*port
= container_of(dev
, struct ehea_port
, ofdev
.dev
);
3071 of_node_put(port
->ofdev
.dev
.of_node
);
3074 static struct device
*ehea_register_port(struct ehea_port
*port
,
3075 struct device_node
*dn
)
3079 port
->ofdev
.dev
.of_node
= of_node_get(dn
);
3080 port
->ofdev
.dev
.parent
= &port
->adapter
->ofdev
->dev
;
3081 port
->ofdev
.dev
.bus
= &ibmebus_bus_type
;
3083 dev_set_name(&port
->ofdev
.dev
, "port%d", port_name_cnt
++);
3084 port
->ofdev
.dev
.release
= logical_port_release
;
3086 ret
= of_device_register(&port
->ofdev
);
3088 pr_err("failed to register device. ret=%d\n", ret
);
3092 ret
= device_create_file(&port
->ofdev
.dev
, &dev_attr_log_port_id
);
3094 pr_err("failed to register attributes, ret=%d\n", ret
);
3095 goto out_unreg_of_dev
;
3098 return &port
->ofdev
.dev
;
3101 of_device_unregister(&port
->ofdev
);
3106 static void ehea_unregister_port(struct ehea_port
*port
)
3108 device_remove_file(&port
->ofdev
.dev
, &dev_attr_log_port_id
);
3109 of_device_unregister(&port
->ofdev
);
3112 static const struct net_device_ops ehea_netdev_ops
= {
3113 .ndo_open
= ehea_open
,
3114 .ndo_stop
= ehea_stop
,
3115 .ndo_start_xmit
= ehea_start_xmit
,
3116 #ifdef CONFIG_NET_POLL_CONTROLLER
3117 .ndo_poll_controller
= ehea_netpoll
,
3119 .ndo_get_stats
= ehea_get_stats
,
3120 .ndo_set_mac_address
= ehea_set_mac_addr
,
3121 .ndo_validate_addr
= eth_validate_addr
,
3122 .ndo_set_rx_mode
= ehea_set_multicast_list
,
3123 .ndo_change_mtu
= ehea_change_mtu
,
3124 .ndo_vlan_rx_add_vid
= ehea_vlan_rx_add_vid
,
3125 .ndo_vlan_rx_kill_vid
= ehea_vlan_rx_kill_vid
,
3126 .ndo_tx_timeout
= ehea_tx_watchdog
,
3129 struct ehea_port
*ehea_setup_single_port(struct ehea_adapter
*adapter
,
3130 u32 logical_port_id
,
3131 struct device_node
*dn
)
3134 struct net_device
*dev
;
3135 struct ehea_port
*port
;
3136 struct device
*port_dev
;
3139 /* allocate memory for the port structures */
3140 dev
= alloc_etherdev_mq(sizeof(struct ehea_port
), EHEA_MAX_PORT_RES
);
3143 pr_err("no mem for net_device\n");
3148 port
= netdev_priv(dev
);
3150 mutex_init(&port
->port_lock
);
3151 port
->state
= EHEA_PORT_DOWN
;
3152 port
->sig_comp_iv
= sq_entries
/ 10;
3154 port
->adapter
= adapter
;
3156 port
->logical_port_id
= logical_port_id
;
3158 port
->msg_enable
= netif_msg_init(msg_level
, EHEA_MSG_DEFAULT
);
3160 port
->mc_list
= kzalloc(sizeof(struct ehea_mc_list
), GFP_KERNEL
);
3161 if (!port
->mc_list
) {
3163 goto out_free_ethdev
;
3166 INIT_LIST_HEAD(&port
->mc_list
->list
);
3168 ret
= ehea_sense_port_attr(port
);
3170 goto out_free_mc_list
;
3172 netif_set_real_num_rx_queues(dev
, port
->num_def_qps
);
3173 netif_set_real_num_tx_queues(dev
, port
->num_def_qps
);
3175 port_dev
= ehea_register_port(port
, dn
);
3177 goto out_free_mc_list
;
3179 SET_NETDEV_DEV(dev
, port_dev
);
3181 /* initialize net_device structure */
3182 memcpy(dev
->dev_addr
, &port
->mac_addr
, ETH_ALEN
);
3184 dev
->netdev_ops
= &ehea_netdev_ops
;
3185 ehea_set_ethtool_ops(dev
);
3187 dev
->hw_features
= NETIF_F_SG
| NETIF_F_FRAGLIST
| NETIF_F_TSO
3188 | NETIF_F_IP_CSUM
| NETIF_F_HW_VLAN_TX
| NETIF_F_LRO
;
3189 dev
->features
= NETIF_F_SG
| NETIF_F_FRAGLIST
| NETIF_F_TSO
3190 | NETIF_F_HIGHDMA
| NETIF_F_IP_CSUM
| NETIF_F_HW_VLAN_TX
3191 | NETIF_F_HW_VLAN_RX
| NETIF_F_HW_VLAN_FILTER
3193 dev
->watchdog_timeo
= EHEA_WATCH_DOG_TIMEOUT
;
3196 dev
->features
|= NETIF_F_LRO
;
3198 INIT_WORK(&port
->reset_task
, ehea_reset_port
);
3199 INIT_DELAYED_WORK(&port
->stats_work
, ehea_update_stats
);
3201 init_waitqueue_head(&port
->swqe_avail_wq
);
3202 init_waitqueue_head(&port
->restart_wq
);
3204 memset(&port
->stats
, 0, sizeof(struct net_device_stats
));
3205 ret
= register_netdev(dev
);
3207 pr_err("register_netdev failed. ret=%d\n", ret
);
3208 goto out_unreg_port
;
3211 port
->lro_max_aggr
= lro_max_aggr
;
3213 ret
= ehea_get_jumboframe_status(port
, &jumbo
);
3215 netdev_err(dev
, "failed determining jumbo frame status\n");
3217 netdev_info(dev
, "Jumbo frames are %sabled\n",
3218 jumbo
== 1 ? "en" : "dis");
3220 adapter
->active_ports
++;
3225 ehea_unregister_port(port
);
3228 kfree(port
->mc_list
);
3234 pr_err("setting up logical port with id=%d failed, ret=%d\n",
3235 logical_port_id
, ret
);
3239 static void ehea_shutdown_single_port(struct ehea_port
*port
)
3241 struct ehea_adapter
*adapter
= port
->adapter
;
3243 cancel_work_sync(&port
->reset_task
);
3244 cancel_delayed_work_sync(&port
->stats_work
);
3245 unregister_netdev(port
->netdev
);
3246 ehea_unregister_port(port
);
3247 kfree(port
->mc_list
);
3248 free_netdev(port
->netdev
);
3249 adapter
->active_ports
--;
3252 static int ehea_setup_ports(struct ehea_adapter
*adapter
)
3254 struct device_node
*lhea_dn
;
3255 struct device_node
*eth_dn
= NULL
;
3257 const u32
*dn_log_port_id
;
3260 lhea_dn
= adapter
->ofdev
->dev
.of_node
;
3261 while ((eth_dn
= of_get_next_child(lhea_dn
, eth_dn
))) {
3263 dn_log_port_id
= of_get_property(eth_dn
, "ibm,hea-port-no",
3265 if (!dn_log_port_id
) {
3266 pr_err("bad device node: eth_dn name=%s\n",
3271 if (ehea_add_adapter_mr(adapter
)) {
3272 pr_err("creating MR failed\n");
3273 of_node_put(eth_dn
);
3277 adapter
->port
[i
] = ehea_setup_single_port(adapter
,
3280 if (adapter
->port
[i
])
3281 netdev_info(adapter
->port
[i
]->netdev
,
3282 "logical port id #%d\n", *dn_log_port_id
);
3284 ehea_remove_adapter_mr(adapter
);
3291 static struct device_node
*ehea_get_eth_dn(struct ehea_adapter
*adapter
,
3292 u32 logical_port_id
)
3294 struct device_node
*lhea_dn
;
3295 struct device_node
*eth_dn
= NULL
;
3296 const u32
*dn_log_port_id
;
3298 lhea_dn
= adapter
->ofdev
->dev
.of_node
;
3299 while ((eth_dn
= of_get_next_child(lhea_dn
, eth_dn
))) {
3301 dn_log_port_id
= of_get_property(eth_dn
, "ibm,hea-port-no",
3304 if (*dn_log_port_id
== logical_port_id
)
3311 static ssize_t
ehea_probe_port(struct device
*dev
,
3312 struct device_attribute
*attr
,
3313 const char *buf
, size_t count
)
3315 struct ehea_adapter
*adapter
= dev_get_drvdata(dev
);
3316 struct ehea_port
*port
;
3317 struct device_node
*eth_dn
= NULL
;
3320 u32 logical_port_id
;
3322 sscanf(buf
, "%d", &logical_port_id
);
3324 port
= ehea_get_port(adapter
, logical_port_id
);
3327 netdev_info(port
->netdev
, "adding port with logical port id=%d failed: port already configured\n",
3332 eth_dn
= ehea_get_eth_dn(adapter
, logical_port_id
);
3335 pr_info("no logical port with id %d found\n", logical_port_id
);
3339 if (ehea_add_adapter_mr(adapter
)) {
3340 pr_err("creating MR failed\n");
3344 port
= ehea_setup_single_port(adapter
, logical_port_id
, eth_dn
);
3346 of_node_put(eth_dn
);
3349 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++)
3350 if (!adapter
->port
[i
]) {
3351 adapter
->port
[i
] = port
;
3355 netdev_info(port
->netdev
, "added: (logical port id=%d)\n",
3358 ehea_remove_adapter_mr(adapter
);
3362 return (ssize_t
) count
;
3365 static ssize_t
ehea_remove_port(struct device
*dev
,
3366 struct device_attribute
*attr
,
3367 const char *buf
, size_t count
)
3369 struct ehea_adapter
*adapter
= dev_get_drvdata(dev
);
3370 struct ehea_port
*port
;
3372 u32 logical_port_id
;
3374 sscanf(buf
, "%d", &logical_port_id
);
3376 port
= ehea_get_port(adapter
, logical_port_id
);
3379 netdev_info(port
->netdev
, "removed: (logical port id=%d)\n",
3382 ehea_shutdown_single_port(port
);
3384 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++)
3385 if (adapter
->port
[i
] == port
) {
3386 adapter
->port
[i
] = NULL
;
3390 pr_err("removing port with logical port id=%d failed. port not configured.\n",
3395 ehea_remove_adapter_mr(adapter
);
3397 return (ssize_t
) count
;
3400 static DEVICE_ATTR(probe_port
, S_IWUSR
, NULL
, ehea_probe_port
);
3401 static DEVICE_ATTR(remove_port
, S_IWUSR
, NULL
, ehea_remove_port
);
3403 int ehea_create_device_sysfs(struct platform_device
*dev
)
3405 int ret
= device_create_file(&dev
->dev
, &dev_attr_probe_port
);
3409 ret
= device_create_file(&dev
->dev
, &dev_attr_remove_port
);
3414 void ehea_remove_device_sysfs(struct platform_device
*dev
)
3416 device_remove_file(&dev
->dev
, &dev_attr_probe_port
);
3417 device_remove_file(&dev
->dev
, &dev_attr_remove_port
);
3420 static int __devinit
ehea_probe_adapter(struct platform_device
*dev
,
3421 const struct of_device_id
*id
)
3423 struct ehea_adapter
*adapter
;
3424 const u64
*adapter_handle
;
3427 if (!dev
|| !dev
->dev
.of_node
) {
3428 pr_err("Invalid ibmebus device probed\n");
3432 adapter
= kzalloc(sizeof(*adapter
), GFP_KERNEL
);
3435 dev_err(&dev
->dev
, "no mem for ehea_adapter\n");
3439 list_add(&adapter
->list
, &adapter_list
);
3441 adapter
->ofdev
= dev
;
3443 adapter_handle
= of_get_property(dev
->dev
.of_node
, "ibm,hea-handle",
3446 adapter
->handle
= *adapter_handle
;
3448 if (!adapter
->handle
) {
3449 dev_err(&dev
->dev
, "failed getting handle for adapter"
3450 " '%s'\n", dev
->dev
.of_node
->full_name
);
3455 adapter
->pd
= EHEA_PD_ID
;
3457 dev_set_drvdata(&dev
->dev
, adapter
);
3460 /* initialize adapter and ports */
3461 /* get adapter properties */
3462 ret
= ehea_sense_adapter_attr(adapter
);
3464 dev_err(&dev
->dev
, "sense_adapter_attr failed: %d\n", ret
);
3468 adapter
->neq
= ehea_create_eq(adapter
,
3469 EHEA_NEQ
, EHEA_MAX_ENTRIES_EQ
, 1);
3470 if (!adapter
->neq
) {
3472 dev_err(&dev
->dev
, "NEQ creation failed\n");
3476 tasklet_init(&adapter
->neq_tasklet
, ehea_neq_tasklet
,
3477 (unsigned long)adapter
);
3479 ret
= ibmebus_request_irq(adapter
->neq
->attr
.ist1
,
3480 ehea_interrupt_neq
, IRQF_DISABLED
,
3481 "ehea_neq", adapter
);
3483 dev_err(&dev
->dev
, "requesting NEQ IRQ failed\n");
3487 ret
= ehea_create_device_sysfs(dev
);
3491 ret
= ehea_setup_ports(adapter
);
3493 dev_err(&dev
->dev
, "setup_ports failed\n");
3494 goto out_rem_dev_sysfs
;
3501 ehea_remove_device_sysfs(dev
);
3504 ibmebus_free_irq(adapter
->neq
->attr
.ist1
, adapter
);
3507 ehea_destroy_eq(adapter
->neq
);
3510 list_del(&adapter
->list
);
3514 ehea_update_firmware_handles();
3519 static int __devexit
ehea_remove(struct platform_device
*dev
)
3521 struct ehea_adapter
*adapter
= dev_get_drvdata(&dev
->dev
);
3524 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++)
3525 if (adapter
->port
[i
]) {
3526 ehea_shutdown_single_port(adapter
->port
[i
]);
3527 adapter
->port
[i
] = NULL
;
3530 ehea_remove_device_sysfs(dev
);
3532 ibmebus_free_irq(adapter
->neq
->attr
.ist1
, adapter
);
3533 tasklet_kill(&adapter
->neq_tasklet
);
3535 ehea_destroy_eq(adapter
->neq
);
3536 ehea_remove_adapter_mr(adapter
);
3537 list_del(&adapter
->list
);
3540 ehea_update_firmware_handles();
3545 void ehea_crash_handler(void)
3549 if (ehea_fw_handles
.arr
)
3550 for (i
= 0; i
< ehea_fw_handles
.num_entries
; i
++)
3551 ehea_h_free_resource(ehea_fw_handles
.arr
[i
].adh
,
3552 ehea_fw_handles
.arr
[i
].fwh
,
3555 if (ehea_bcmc_regs
.arr
)
3556 for (i
= 0; i
< ehea_bcmc_regs
.num_entries
; i
++)
3557 ehea_h_reg_dereg_bcmc(ehea_bcmc_regs
.arr
[i
].adh
,
3558 ehea_bcmc_regs
.arr
[i
].port_id
,
3559 ehea_bcmc_regs
.arr
[i
].reg_type
,
3560 ehea_bcmc_regs
.arr
[i
].macaddr
,
3564 static int ehea_mem_notifier(struct notifier_block
*nb
,
3565 unsigned long action
, void *data
)
3567 int ret
= NOTIFY_BAD
;
3568 struct memory_notify
*arg
= data
;
3570 mutex_lock(&dlpar_mem_lock
);
3573 case MEM_CANCEL_OFFLINE
:
3574 pr_info("memory offlining canceled");
3575 /* Readd canceled memory block */
3577 pr_info("memory is going online");
3578 set_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
);
3579 if (ehea_add_sect_bmap(arg
->start_pfn
, arg
->nr_pages
))
3583 case MEM_GOING_OFFLINE
:
3584 pr_info("memory is going offline");
3585 set_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
);
3586 if (ehea_rem_sect_bmap(arg
->start_pfn
, arg
->nr_pages
))
3594 ehea_update_firmware_handles();
3598 mutex_unlock(&dlpar_mem_lock
);
3602 static struct notifier_block ehea_mem_nb
= {
3603 .notifier_call
= ehea_mem_notifier
,
3606 static int ehea_reboot_notifier(struct notifier_block
*nb
,
3607 unsigned long action
, void *unused
)
3609 if (action
== SYS_RESTART
) {
3610 pr_info("Reboot: freeing all eHEA resources\n");
3611 ibmebus_unregister_driver(&ehea_driver
);
3616 static struct notifier_block ehea_reboot_nb
= {
3617 .notifier_call
= ehea_reboot_notifier
,
3620 static int check_module_parm(void)
3624 if ((rq1_entries
< EHEA_MIN_ENTRIES_QP
) ||
3625 (rq1_entries
> EHEA_MAX_ENTRIES_RQ1
)) {
3626 pr_info("Bad parameter: rq1_entries\n");
3629 if ((rq2_entries
< EHEA_MIN_ENTRIES_QP
) ||
3630 (rq2_entries
> EHEA_MAX_ENTRIES_RQ2
)) {
3631 pr_info("Bad parameter: rq2_entries\n");
3634 if ((rq3_entries
< EHEA_MIN_ENTRIES_QP
) ||
3635 (rq3_entries
> EHEA_MAX_ENTRIES_RQ3
)) {
3636 pr_info("Bad parameter: rq3_entries\n");
3639 if ((sq_entries
< EHEA_MIN_ENTRIES_QP
) ||
3640 (sq_entries
> EHEA_MAX_ENTRIES_SQ
)) {
3641 pr_info("Bad parameter: sq_entries\n");
3648 static ssize_t
ehea_show_capabilities(struct device_driver
*drv
,
3651 return sprintf(buf
, "%d", EHEA_CAPABILITIES
);
3654 static DRIVER_ATTR(capabilities
, S_IRUSR
| S_IRGRP
| S_IROTH
,
3655 ehea_show_capabilities
, NULL
);
3657 int __init
ehea_module_init(void)
3661 pr_info("IBM eHEA ethernet device driver (Release %s)\n", DRV_VERSION
);
3663 memset(&ehea_fw_handles
, 0, sizeof(ehea_fw_handles
));
3664 memset(&ehea_bcmc_regs
, 0, sizeof(ehea_bcmc_regs
));
3666 mutex_init(&ehea_fw_handles
.lock
);
3667 spin_lock_init(&ehea_bcmc_regs
.lock
);
3669 ret
= check_module_parm();
3673 ret
= ehea_create_busmap();
3677 ret
= register_reboot_notifier(&ehea_reboot_nb
);
3679 pr_info("failed registering reboot notifier\n");
3681 ret
= register_memory_notifier(&ehea_mem_nb
);
3683 pr_info("failed registering memory remove notifier\n");
3685 ret
= crash_shutdown_register(ehea_crash_handler
);
3687 pr_info("failed registering crash handler\n");
3689 ret
= ibmebus_register_driver(&ehea_driver
);
3691 pr_err("failed registering eHEA device driver on ebus\n");
3695 ret
= driver_create_file(&ehea_driver
.driver
,
3696 &driver_attr_capabilities
);
3698 pr_err("failed to register capabilities attribute, ret=%d\n",
3706 ibmebus_unregister_driver(&ehea_driver
);
3708 unregister_memory_notifier(&ehea_mem_nb
);
3709 unregister_reboot_notifier(&ehea_reboot_nb
);
3710 crash_shutdown_unregister(ehea_crash_handler
);
3715 static void __exit
ehea_module_exit(void)
3719 driver_remove_file(&ehea_driver
.driver
, &driver_attr_capabilities
);
3720 ibmebus_unregister_driver(&ehea_driver
);
3721 unregister_reboot_notifier(&ehea_reboot_nb
);
3722 ret
= crash_shutdown_unregister(ehea_crash_handler
);
3724 pr_info("failed unregistering crash handler\n");
3725 unregister_memory_notifier(&ehea_mem_nb
);
3726 kfree(ehea_fw_handles
.arr
);
3727 kfree(ehea_bcmc_regs
.arr
);
3728 ehea_destroy_busmap();
3731 module_init(ehea_module_init
);
3732 module_exit(ehea_module_exit
);