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.
31 #include <linux/tcp.h>
32 #include <linux/udp.h>
34 #include <linux/list.h>
35 #include <linux/slab.h>
36 #include <linux/if_ether.h>
37 #include <linux/notifier.h>
38 #include <linux/reboot.h>
39 #include <linux/memory.h>
40 #include <asm/kexec.h>
41 #include <linux/mutex.h>
47 #include "ehea_phyp.h"
50 MODULE_LICENSE("GPL");
51 MODULE_AUTHOR("Christoph Raisch <raisch@de.ibm.com>");
52 MODULE_DESCRIPTION("IBM eServer HEA Driver");
53 MODULE_VERSION(DRV_VERSION
);
56 static int msg_level
= -1;
57 static int rq1_entries
= EHEA_DEF_ENTRIES_RQ1
;
58 static int rq2_entries
= EHEA_DEF_ENTRIES_RQ2
;
59 static int rq3_entries
= EHEA_DEF_ENTRIES_RQ3
;
60 static int sq_entries
= EHEA_DEF_ENTRIES_SQ
;
63 static int lro_max_aggr
= EHEA_LRO_MAX_AGGR
;
64 static int num_tx_qps
= EHEA_NUM_TX_QP
;
65 static int prop_carrier_state
;
67 module_param(msg_level
, int, 0);
68 module_param(rq1_entries
, int, 0);
69 module_param(rq2_entries
, int, 0);
70 module_param(rq3_entries
, int, 0);
71 module_param(sq_entries
, int, 0);
72 module_param(prop_carrier_state
, int, 0);
73 module_param(use_mcs
, int, 0);
74 module_param(use_lro
, int, 0);
75 module_param(lro_max_aggr
, int, 0);
76 module_param(num_tx_qps
, int, 0);
78 MODULE_PARM_DESC(num_tx_qps
, "Number of TX-QPS");
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
, " 0:NAPI, 1:Multiple receive queues, Default = 0 ");
96 MODULE_PARM_DESC(lro_max_aggr
, " LRO: Max packets to be aggregated. Default = "
97 __MODULE_STRING(EHEA_LRO_MAX_AGGR
));
98 MODULE_PARM_DESC(use_lro
, " Large Receive Offload, 1: enable, 0: disable, "
101 static int port_name_cnt
;
102 static LIST_HEAD(adapter_list
);
103 static unsigned long ehea_driver_flags
;
104 struct work_struct ehea_rereg_mr_task
;
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 printk(DRV_NAME
" %s adr=%p ofs=%04x %016llx %016llx\n", msg
,
140 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
+ port
->num_add_tx_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
) ||
201 l
< port
->num_def_qps
+ port
->num_add_tx_qps
;
203 struct ehea_port_res
*pr
= &port
->port_res
[l
];
205 arr
[i
].adh
= adapter
->handle
;
206 arr
[i
++].fwh
= pr
->qp
->fw_handle
;
207 arr
[i
].adh
= adapter
->handle
;
208 arr
[i
++].fwh
= pr
->send_cq
->fw_handle
;
209 arr
[i
].adh
= adapter
->handle
;
210 arr
[i
++].fwh
= pr
->recv_cq
->fw_handle
;
211 arr
[i
].adh
= adapter
->handle
;
212 arr
[i
++].fwh
= pr
->eq
->fw_handle
;
213 arr
[i
].adh
= adapter
->handle
;
214 arr
[i
++].fwh
= pr
->send_mr
.handle
;
215 arr
[i
].adh
= adapter
->handle
;
216 arr
[i
++].fwh
= pr
->recv_mr
.handle
;
218 arr
[i
].adh
= adapter
->handle
;
219 arr
[i
++].fwh
= port
->qp_eq
->fw_handle
;
223 arr
[i
].adh
= adapter
->handle
;
224 arr
[i
++].fwh
= adapter
->neq
->fw_handle
;
226 if (adapter
->mr
.handle
) {
227 arr
[i
].adh
= adapter
->handle
;
228 arr
[i
++].fwh
= adapter
->mr
.handle
;
234 kfree(ehea_fw_handles
.arr
);
235 ehea_fw_handles
.arr
= arr
;
236 ehea_fw_handles
.num_entries
= i
;
238 mutex_unlock(&ehea_fw_handles
.lock
);
241 static void ehea_update_bcmc_registrations(void)
244 struct ehea_bcmc_reg_entry
*arr
= NULL
;
245 struct ehea_adapter
*adapter
;
246 struct ehea_mc_list
*mc_entry
;
247 int num_registrations
= 0;
251 spin_lock_irqsave(&ehea_bcmc_regs
.lock
, flags
);
253 /* Determine number of registrations */
254 list_for_each_entry(adapter
, &adapter_list
, list
)
255 for (k
= 0; k
< EHEA_MAX_PORTS
; k
++) {
256 struct ehea_port
*port
= adapter
->port
[k
];
258 if (!port
|| (port
->state
!= EHEA_PORT_UP
))
261 num_registrations
+= 2; /* Broadcast registrations */
263 list_for_each_entry(mc_entry
, &port
->mc_list
->list
,list
)
264 num_registrations
+= 2;
267 if (num_registrations
) {
268 arr
= kcalloc(num_registrations
, sizeof(*arr
), GFP_ATOMIC
);
270 goto out
; /* Keep the existing array */
274 list_for_each_entry(adapter
, &adapter_list
, list
) {
275 for (k
= 0; k
< EHEA_MAX_PORTS
; k
++) {
276 struct ehea_port
*port
= adapter
->port
[k
];
278 if (!port
|| (port
->state
!= EHEA_PORT_UP
))
281 if (num_registrations
== 0)
284 arr
[i
].adh
= adapter
->handle
;
285 arr
[i
].port_id
= port
->logical_port_id
;
286 arr
[i
].reg_type
= EHEA_BCMC_BROADCAST
|
288 arr
[i
++].macaddr
= port
->mac_addr
;
290 arr
[i
].adh
= adapter
->handle
;
291 arr
[i
].port_id
= port
->logical_port_id
;
292 arr
[i
].reg_type
= EHEA_BCMC_BROADCAST
|
293 EHEA_BCMC_VLANID_ALL
;
294 arr
[i
++].macaddr
= port
->mac_addr
;
295 num_registrations
-= 2;
297 list_for_each_entry(mc_entry
,
298 &port
->mc_list
->list
, list
) {
299 if (num_registrations
== 0)
302 arr
[i
].adh
= adapter
->handle
;
303 arr
[i
].port_id
= port
->logical_port_id
;
304 arr
[i
].reg_type
= EHEA_BCMC_SCOPE_ALL
|
305 EHEA_BCMC_MULTICAST
|
307 arr
[i
++].macaddr
= mc_entry
->macaddr
;
309 arr
[i
].adh
= adapter
->handle
;
310 arr
[i
].port_id
= port
->logical_port_id
;
311 arr
[i
].reg_type
= EHEA_BCMC_SCOPE_ALL
|
312 EHEA_BCMC_MULTICAST
|
313 EHEA_BCMC_VLANID_ALL
;
314 arr
[i
++].macaddr
= mc_entry
->macaddr
;
315 num_registrations
-= 2;
321 kfree(ehea_bcmc_regs
.arr
);
322 ehea_bcmc_regs
.arr
= arr
;
323 ehea_bcmc_regs
.num_entries
= i
;
325 spin_unlock_irqrestore(&ehea_bcmc_regs
.lock
, flags
);
328 static struct net_device_stats
*ehea_get_stats(struct net_device
*dev
)
330 struct ehea_port
*port
= netdev_priv(dev
);
331 struct net_device_stats
*stats
= &port
->stats
;
332 struct hcp_ehea_port_cb2
*cb2
;
333 u64 hret
, rx_packets
, tx_packets
;
336 memset(stats
, 0, sizeof(*stats
));
338 cb2
= (void *)get_zeroed_page(GFP_KERNEL
);
340 ehea_error("no mem for cb2");
344 hret
= ehea_h_query_ehea_port(port
->adapter
->handle
,
345 port
->logical_port_id
,
346 H_PORT_CB2
, H_PORT_CB2_ALL
, cb2
);
347 if (hret
!= H_SUCCESS
) {
348 ehea_error("query_ehea_port failed");
352 if (netif_msg_hw(port
))
353 ehea_dump(cb2
, sizeof(*cb2
), "net_device_stats");
356 for (i
= 0; i
< port
->num_def_qps
; i
++)
357 rx_packets
+= port
->port_res
[i
].rx_packets
;
360 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++)
361 tx_packets
+= port
->port_res
[i
].tx_packets
;
363 stats
->tx_packets
= tx_packets
;
364 stats
->multicast
= cb2
->rxmcp
;
365 stats
->rx_errors
= cb2
->rxuerr
;
366 stats
->rx_bytes
= cb2
->rxo
;
367 stats
->tx_bytes
= cb2
->txo
;
368 stats
->rx_packets
= rx_packets
;
371 free_page((unsigned long)cb2
);
376 static void ehea_refill_rq1(struct ehea_port_res
*pr
, int index
, int nr_of_wqes
)
378 struct sk_buff
**skb_arr_rq1
= pr
->rq1_skba
.arr
;
379 struct net_device
*dev
= pr
->port
->netdev
;
380 int max_index_mask
= pr
->rq1_skba
.len
- 1;
381 int fill_wqes
= pr
->rq1_skba
.os_skbs
+ nr_of_wqes
;
385 pr
->rq1_skba
.os_skbs
= 0;
387 if (unlikely(test_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
))) {
389 pr
->rq1_skba
.index
= index
;
390 pr
->rq1_skba
.os_skbs
= fill_wqes
;
394 for (i
= 0; i
< fill_wqes
; i
++) {
395 if (!skb_arr_rq1
[index
]) {
396 skb_arr_rq1
[index
] = netdev_alloc_skb(dev
,
398 if (!skb_arr_rq1
[index
]) {
399 pr
->rq1_skba
.os_skbs
= fill_wqes
- i
;
404 index
&= max_index_mask
;
412 ehea_update_rq1a(pr
->qp
, adder
);
415 static void ehea_init_fill_rq1(struct ehea_port_res
*pr
, int nr_rq1a
)
417 struct sk_buff
**skb_arr_rq1
= pr
->rq1_skba
.arr
;
418 struct net_device
*dev
= pr
->port
->netdev
;
421 for (i
= 0; i
< pr
->rq1_skba
.len
; i
++) {
422 skb_arr_rq1
[i
] = netdev_alloc_skb(dev
, EHEA_L_PKT_SIZE
);
427 ehea_update_rq1a(pr
->qp
, nr_rq1a
);
430 static int ehea_refill_rq_def(struct ehea_port_res
*pr
,
431 struct ehea_q_skb_arr
*q_skba
, int rq_nr
,
432 int num_wqes
, int wqe_type
, int packet_size
)
434 struct net_device
*dev
= pr
->port
->netdev
;
435 struct ehea_qp
*qp
= pr
->qp
;
436 struct sk_buff
**skb_arr
= q_skba
->arr
;
437 struct ehea_rwqe
*rwqe
;
438 int i
, index
, max_index_mask
, fill_wqes
;
442 fill_wqes
= q_skba
->os_skbs
+ num_wqes
;
445 if (unlikely(test_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
))) {
446 q_skba
->os_skbs
= fill_wqes
;
450 index
= q_skba
->index
;
451 max_index_mask
= q_skba
->len
- 1;
452 for (i
= 0; i
< fill_wqes
; i
++) {
456 skb
= netdev_alloc_skb_ip_align(dev
, packet_size
);
458 q_skba
->os_skbs
= fill_wqes
- i
;
459 if (q_skba
->os_skbs
== q_skba
->len
- 2) {
460 ehea_info("%s: rq%i ran dry - no mem for skb",
461 pr
->port
->netdev
->name
, rq_nr
);
467 skb_arr
[index
] = skb
;
468 tmp_addr
= ehea_map_vaddr(skb
->data
);
469 if (tmp_addr
== -1) {
471 q_skba
->os_skbs
= fill_wqes
- i
;
476 rwqe
= ehea_get_next_rwqe(qp
, rq_nr
);
477 rwqe
->wr_id
= EHEA_BMASK_SET(EHEA_WR_ID_TYPE
, wqe_type
)
478 | EHEA_BMASK_SET(EHEA_WR_ID_INDEX
, index
);
479 rwqe
->sg_list
[0].l_key
= pr
->recv_mr
.lkey
;
480 rwqe
->sg_list
[0].vaddr
= tmp_addr
;
481 rwqe
->sg_list
[0].len
= packet_size
;
482 rwqe
->data_segments
= 1;
485 index
&= max_index_mask
;
489 q_skba
->index
= index
;
496 ehea_update_rq2a(pr
->qp
, adder
);
498 ehea_update_rq3a(pr
->qp
, adder
);
504 static int ehea_refill_rq2(struct ehea_port_res
*pr
, int nr_of_wqes
)
506 return ehea_refill_rq_def(pr
, &pr
->rq2_skba
, 2,
507 nr_of_wqes
, EHEA_RWQE2_TYPE
,
512 static int ehea_refill_rq3(struct ehea_port_res
*pr
, int nr_of_wqes
)
514 return ehea_refill_rq_def(pr
, &pr
->rq3_skba
, 3,
515 nr_of_wqes
, EHEA_RWQE3_TYPE
,
516 EHEA_MAX_PACKET_SIZE
);
519 static inline int ehea_check_cqe(struct ehea_cqe
*cqe
, int *rq_num
)
521 *rq_num
= (cqe
->type
& EHEA_CQE_TYPE_RQ
) >> 5;
522 if ((cqe
->status
& EHEA_CQE_STAT_ERR_MASK
) == 0)
524 if (((cqe
->status
& EHEA_CQE_STAT_ERR_TCP
) != 0) &&
525 (cqe
->header_length
== 0))
530 static inline void ehea_fill_skb(struct net_device
*dev
,
531 struct sk_buff
*skb
, struct ehea_cqe
*cqe
)
533 int length
= cqe
->num_bytes_transfered
- 4; /*remove CRC */
535 skb_put(skb
, length
);
536 skb
->ip_summed
= CHECKSUM_UNNECESSARY
;
537 skb
->protocol
= eth_type_trans(skb
, dev
);
540 static inline struct sk_buff
*get_skb_by_index(struct sk_buff
**skb_array
,
542 struct ehea_cqe
*cqe
)
544 int skb_index
= EHEA_BMASK_GET(EHEA_WR_ID_INDEX
, cqe
->wr_id
);
555 prefetchw(pref
+ EHEA_CACHE_LINE
);
557 pref
= (skb_array
[x
]->data
);
559 prefetch(pref
+ EHEA_CACHE_LINE
);
560 prefetch(pref
+ EHEA_CACHE_LINE
* 2);
561 prefetch(pref
+ EHEA_CACHE_LINE
* 3);
564 skb
= skb_array
[skb_index
];
565 skb_array
[skb_index
] = NULL
;
569 static inline struct sk_buff
*get_skb_by_index_ll(struct sk_buff
**skb_array
,
570 int arr_len
, int wqe_index
)
582 prefetchw(pref
+ EHEA_CACHE_LINE
);
584 pref
= (skb_array
[x
]->data
);
586 prefetchw(pref
+ EHEA_CACHE_LINE
);
589 skb
= skb_array
[wqe_index
];
590 skb_array
[wqe_index
] = NULL
;
594 static int ehea_treat_poll_error(struct ehea_port_res
*pr
, int rq
,
595 struct ehea_cqe
*cqe
, int *processed_rq2
,
600 if (cqe
->status
& EHEA_CQE_STAT_ERR_TCP
)
601 pr
->p_stats
.err_tcp_cksum
++;
602 if (cqe
->status
& EHEA_CQE_STAT_ERR_IP
)
603 pr
->p_stats
.err_ip_cksum
++;
604 if (cqe
->status
& EHEA_CQE_STAT_ERR_CRC
)
605 pr
->p_stats
.err_frame_crc
++;
609 skb
= get_skb_by_index(pr
->rq2_skba
.arr
, pr
->rq2_skba
.len
, cqe
);
611 } else if (rq
== 3) {
613 skb
= get_skb_by_index(pr
->rq3_skba
.arr
, pr
->rq3_skba
.len
, cqe
);
617 if (cqe
->status
& EHEA_CQE_STAT_FAT_ERR_MASK
) {
618 if (netif_msg_rx_err(pr
->port
)) {
619 ehea_error("Critical receive error for QP %d. "
620 "Resetting port.", pr
->qp
->init_attr
.qp_nr
);
621 ehea_dump(cqe
, sizeof(*cqe
), "CQE");
623 ehea_schedule_port_reset(pr
->port
);
630 static int get_skb_hdr(struct sk_buff
*skb
, void **iphdr
,
631 void **tcph
, u64
*hdr_flags
, void *priv
)
633 struct ehea_cqe
*cqe
= priv
;
637 /* non tcp/udp packets */
638 if (!cqe
->header_length
)
642 skb_reset_network_header(skb
);
644 if (iph
->protocol
!= IPPROTO_TCP
)
647 ip_len
= ip_hdrlen(skb
);
648 skb_set_transport_header(skb
, ip_len
);
649 *tcph
= tcp_hdr(skb
);
651 /* check if ip header and tcp header are complete */
652 if (ntohs(iph
->tot_len
) < ip_len
+ tcp_hdrlen(skb
))
655 *hdr_flags
= LRO_IPV4
| LRO_TCP
;
661 static void ehea_proc_skb(struct ehea_port_res
*pr
, struct ehea_cqe
*cqe
,
664 int vlan_extracted
= ((cqe
->status
& EHEA_CQE_VLAN_TAG_XTRACT
) &&
669 lro_vlan_hwaccel_receive_skb(&pr
->lro_mgr
, skb
,
674 lro_receive_skb(&pr
->lro_mgr
, skb
, cqe
);
677 vlan_hwaccel_receive_skb(skb
, pr
->port
->vgrp
,
680 netif_receive_skb(skb
);
684 static int ehea_proc_rwqes(struct net_device
*dev
,
685 struct ehea_port_res
*pr
,
688 struct ehea_port
*port
= pr
->port
;
689 struct ehea_qp
*qp
= pr
->qp
;
690 struct ehea_cqe
*cqe
;
692 struct sk_buff
**skb_arr_rq1
= pr
->rq1_skba
.arr
;
693 struct sk_buff
**skb_arr_rq2
= pr
->rq2_skba
.arr
;
694 struct sk_buff
**skb_arr_rq3
= pr
->rq3_skba
.arr
;
695 int skb_arr_rq1_len
= pr
->rq1_skba
.len
;
696 int skb_arr_rq2_len
= pr
->rq2_skba
.len
;
697 int skb_arr_rq3_len
= pr
->rq3_skba
.len
;
698 int processed
, processed_rq1
, processed_rq2
, processed_rq3
;
699 int wqe_index
, last_wqe_index
, rq
, port_reset
;
701 processed
= processed_rq1
= processed_rq2
= processed_rq3
= 0;
704 cqe
= ehea_poll_rq1(qp
, &wqe_index
);
705 while ((processed
< budget
) && cqe
) {
709 if (netif_msg_rx_status(port
))
710 ehea_dump(cqe
, sizeof(*cqe
), "CQE");
712 last_wqe_index
= wqe_index
;
714 if (!ehea_check_cqe(cqe
, &rq
)) {
717 skb
= get_skb_by_index_ll(skb_arr_rq1
,
720 if (unlikely(!skb
)) {
721 if (netif_msg_rx_err(port
))
722 ehea_error("LL rq1: skb=NULL");
724 skb
= netdev_alloc_skb(dev
,
729 skb_copy_to_linear_data(skb
, ((char *)cqe
) + 64,
730 cqe
->num_bytes_transfered
- 4);
731 ehea_fill_skb(dev
, skb
, cqe
);
732 } else if (rq
== 2) {
734 skb
= get_skb_by_index(skb_arr_rq2
,
735 skb_arr_rq2_len
, cqe
);
736 if (unlikely(!skb
)) {
737 if (netif_msg_rx_err(port
))
738 ehea_error("rq2: skb=NULL");
741 ehea_fill_skb(dev
, skb
, cqe
);
745 skb
= get_skb_by_index(skb_arr_rq3
,
746 skb_arr_rq3_len
, cqe
);
747 if (unlikely(!skb
)) {
748 if (netif_msg_rx_err(port
))
749 ehea_error("rq3: skb=NULL");
752 ehea_fill_skb(dev
, skb
, cqe
);
756 ehea_proc_skb(pr
, cqe
, skb
);
758 pr
->p_stats
.poll_receive_errors
++;
759 port_reset
= ehea_treat_poll_error(pr
, rq
, cqe
,
765 cqe
= ehea_poll_rq1(qp
, &wqe_index
);
768 lro_flush_all(&pr
->lro_mgr
);
770 pr
->rx_packets
+= processed
;
772 ehea_refill_rq1(pr
, last_wqe_index
, processed_rq1
);
773 ehea_refill_rq2(pr
, processed_rq2
);
774 ehea_refill_rq3(pr
, processed_rq3
);
779 #define SWQE_RESTART_CHECK 0xdeadbeaff00d0000ull
781 static void reset_sq_restart_flag(struct ehea_port
*port
)
785 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++) {
786 struct ehea_port_res
*pr
= &port
->port_res
[i
];
787 pr
->sq_restart_flag
= 0;
789 wake_up(&port
->restart_wq
);
792 static void check_sqs(struct ehea_port
*port
)
794 struct ehea_swqe
*swqe
;
798 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++) {
799 struct ehea_port_res
*pr
= &port
->port_res
[i
];
802 swqe
= ehea_get_swqe(pr
->qp
, &swqe_index
);
803 memset(swqe
, 0, SWQE_HEADER_SIZE
);
804 atomic_dec(&pr
->swqe_avail
);
806 swqe
->tx_control
|= EHEA_SWQE_PURGE
;
807 swqe
->wr_id
= SWQE_RESTART_CHECK
;
808 swqe
->tx_control
|= EHEA_SWQE_SIGNALLED_COMPLETION
;
809 swqe
->tx_control
|= EHEA_SWQE_IMM_DATA_PRESENT
;
810 swqe
->immediate_data_length
= 80;
812 ehea_post_swqe(pr
->qp
, swqe
);
814 ret
= wait_event_timeout(port
->restart_wq
,
815 pr
->sq_restart_flag
== 0,
816 msecs_to_jiffies(100));
819 ehea_error("HW/SW queues out of sync");
820 ehea_schedule_port_reset(pr
->port
);
827 static struct ehea_cqe
*ehea_proc_cqes(struct ehea_port_res
*pr
, int my_quota
)
830 struct ehea_cq
*send_cq
= pr
->send_cq
;
831 struct ehea_cqe
*cqe
;
832 int quota
= my_quota
;
838 cqe
= ehea_poll_cq(send_cq
);
839 while (cqe
&& (quota
> 0)) {
840 ehea_inc_cq(send_cq
);
845 if (cqe
->wr_id
== SWQE_RESTART_CHECK
) {
846 pr
->sq_restart_flag
= 1;
851 if (cqe
->status
& EHEA_CQE_STAT_ERR_MASK
) {
852 ehea_error("Bad send completion status=0x%04X",
855 if (netif_msg_tx_err(pr
->port
))
856 ehea_dump(cqe
, sizeof(*cqe
), "Send CQE");
858 if (cqe
->status
& EHEA_CQE_STAT_RESET_MASK
) {
859 ehea_error("Resetting port");
860 ehea_schedule_port_reset(pr
->port
);
865 if (netif_msg_tx_done(pr
->port
))
866 ehea_dump(cqe
, sizeof(*cqe
), "CQE");
868 if (likely(EHEA_BMASK_GET(EHEA_WR_ID_TYPE
, cqe
->wr_id
)
869 == EHEA_SWQE2_TYPE
)) {
871 index
= EHEA_BMASK_GET(EHEA_WR_ID_INDEX
, cqe
->wr_id
);
872 skb
= pr
->sq_skba
.arr
[index
];
874 pr
->sq_skba
.arr
[index
] = NULL
;
877 swqe_av
+= EHEA_BMASK_GET(EHEA_WR_ID_REFILL
, cqe
->wr_id
);
880 cqe
= ehea_poll_cq(send_cq
);
883 ehea_update_feca(send_cq
, cqe_counter
);
884 atomic_add(swqe_av
, &pr
->swqe_avail
);
886 spin_lock_irqsave(&pr
->netif_queue
, flags
);
888 if (pr
->queue_stopped
&& (atomic_read(&pr
->swqe_avail
)
889 >= pr
->swqe_refill_th
)) {
890 netif_wake_queue(pr
->port
->netdev
);
891 pr
->queue_stopped
= 0;
893 spin_unlock_irqrestore(&pr
->netif_queue
, flags
);
894 wake_up(&pr
->port
->swqe_avail_wq
);
899 #define EHEA_NAPI_POLL_NUM_BEFORE_IRQ 16
900 #define EHEA_POLL_MAX_CQES 65535
902 static int ehea_poll(struct napi_struct
*napi
, int budget
)
904 struct ehea_port_res
*pr
= container_of(napi
, struct ehea_port_res
,
906 struct net_device
*dev
= pr
->port
->netdev
;
907 struct ehea_cqe
*cqe
;
908 struct ehea_cqe
*cqe_skb
= NULL
;
909 int force_irq
, wqe_index
;
912 force_irq
= (pr
->poll_counter
> EHEA_NAPI_POLL_NUM_BEFORE_IRQ
);
913 cqe_skb
= ehea_proc_cqes(pr
, EHEA_POLL_MAX_CQES
);
916 rx
+= ehea_proc_rwqes(dev
, pr
, budget
- rx
);
918 while ((rx
!= budget
) || force_irq
) {
919 pr
->poll_counter
= 0;
922 ehea_reset_cq_ep(pr
->recv_cq
);
923 ehea_reset_cq_ep(pr
->send_cq
);
924 ehea_reset_cq_n1(pr
->recv_cq
);
925 ehea_reset_cq_n1(pr
->send_cq
);
927 cqe
= ehea_poll_rq1(pr
->qp
, &wqe_index
);
928 cqe_skb
= ehea_poll_cq(pr
->send_cq
);
930 if (!cqe
&& !cqe_skb
)
933 if (!napi_reschedule(napi
))
936 cqe_skb
= ehea_proc_cqes(pr
, EHEA_POLL_MAX_CQES
);
937 rx
+= ehea_proc_rwqes(dev
, pr
, budget
- rx
);
944 #ifdef CONFIG_NET_POLL_CONTROLLER
945 static void ehea_netpoll(struct net_device
*dev
)
947 struct ehea_port
*port
= netdev_priv(dev
);
950 for (i
= 0; i
< port
->num_def_qps
; i
++)
951 napi_schedule(&port
->port_res
[i
].napi
);
955 static irqreturn_t
ehea_recv_irq_handler(int irq
, void *param
)
957 struct ehea_port_res
*pr
= param
;
959 napi_schedule(&pr
->napi
);
964 static irqreturn_t
ehea_qp_aff_irq_handler(int irq
, void *param
)
966 struct ehea_port
*port
= param
;
967 struct ehea_eqe
*eqe
;
970 u64 resource_type
, aer
, aerr
;
973 eqe
= ehea_poll_eq(port
->qp_eq
);
976 qp_token
= EHEA_BMASK_GET(EHEA_EQE_QP_TOKEN
, eqe
->entry
);
977 ehea_error("QP aff_err: entry=0x%llx, token=0x%x",
978 eqe
->entry
, qp_token
);
980 qp
= port
->port_res
[qp_token
].qp
;
982 resource_type
= ehea_error_data(port
->adapter
, qp
->fw_handle
,
985 if (resource_type
== EHEA_AER_RESTYPE_QP
) {
986 if ((aer
& EHEA_AER_RESET_MASK
) ||
987 (aerr
& EHEA_AERR_RESET_MASK
))
990 reset_port
= 1; /* Reset in case of CQ or EQ error */
992 eqe
= ehea_poll_eq(port
->qp_eq
);
996 ehea_error("Resetting port");
997 ehea_schedule_port_reset(port
);
1003 static struct ehea_port
*ehea_get_port(struct ehea_adapter
*adapter
,
1008 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++)
1009 if (adapter
->port
[i
])
1010 if (adapter
->port
[i
]->logical_port_id
== logical_port
)
1011 return adapter
->port
[i
];
1015 int ehea_sense_port_attr(struct ehea_port
*port
)
1019 struct hcp_ehea_port_cb0
*cb0
;
1021 /* may be called via ehea_neq_tasklet() */
1022 cb0
= (void *)get_zeroed_page(GFP_ATOMIC
);
1024 ehea_error("no mem for cb0");
1029 hret
= ehea_h_query_ehea_port(port
->adapter
->handle
,
1030 port
->logical_port_id
, H_PORT_CB0
,
1031 EHEA_BMASK_SET(H_PORT_CB0_ALL
, 0xFFFF),
1033 if (hret
!= H_SUCCESS
) {
1039 port
->mac_addr
= cb0
->port_mac_addr
<< 16;
1041 if (!is_valid_ether_addr((u8
*)&port
->mac_addr
)) {
1042 ret
= -EADDRNOTAVAIL
;
1047 switch (cb0
->port_speed
) {
1049 port
->port_speed
= EHEA_SPEED_10M
;
1050 port
->full_duplex
= 0;
1053 port
->port_speed
= EHEA_SPEED_10M
;
1054 port
->full_duplex
= 1;
1056 case H_SPEED_100M_H
:
1057 port
->port_speed
= EHEA_SPEED_100M
;
1058 port
->full_duplex
= 0;
1060 case H_SPEED_100M_F
:
1061 port
->port_speed
= EHEA_SPEED_100M
;
1062 port
->full_duplex
= 1;
1065 port
->port_speed
= EHEA_SPEED_1G
;
1066 port
->full_duplex
= 1;
1069 port
->port_speed
= EHEA_SPEED_10G
;
1070 port
->full_duplex
= 1;
1073 port
->port_speed
= 0;
1074 port
->full_duplex
= 0;
1079 port
->num_mcs
= cb0
->num_default_qps
;
1081 /* Number of default QPs */
1083 port
->num_def_qps
= cb0
->num_default_qps
;
1085 port
->num_def_qps
= 1;
1087 if (!port
->num_def_qps
) {
1092 port
->num_tx_qps
= num_tx_qps
;
1094 if (port
->num_def_qps
>= port
->num_tx_qps
)
1095 port
->num_add_tx_qps
= 0;
1097 port
->num_add_tx_qps
= port
->num_tx_qps
- port
->num_def_qps
;
1101 if (ret
|| netif_msg_probe(port
))
1102 ehea_dump(cb0
, sizeof(*cb0
), "ehea_sense_port_attr");
1103 free_page((unsigned long)cb0
);
1108 int ehea_set_portspeed(struct ehea_port
*port
, u32 port_speed
)
1110 struct hcp_ehea_port_cb4
*cb4
;
1114 cb4
= (void *)get_zeroed_page(GFP_KERNEL
);
1116 ehea_error("no mem for cb4");
1121 cb4
->port_speed
= port_speed
;
1123 netif_carrier_off(port
->netdev
);
1125 hret
= ehea_h_modify_ehea_port(port
->adapter
->handle
,
1126 port
->logical_port_id
,
1127 H_PORT_CB4
, H_PORT_CB4_SPEED
, cb4
);
1128 if (hret
== H_SUCCESS
) {
1129 port
->autoneg
= port_speed
== EHEA_SPEED_AUTONEG
? 1 : 0;
1131 hret
= ehea_h_query_ehea_port(port
->adapter
->handle
,
1132 port
->logical_port_id
,
1133 H_PORT_CB4
, H_PORT_CB4_SPEED
,
1135 if (hret
== H_SUCCESS
) {
1136 switch (cb4
->port_speed
) {
1138 port
->port_speed
= EHEA_SPEED_10M
;
1139 port
->full_duplex
= 0;
1142 port
->port_speed
= EHEA_SPEED_10M
;
1143 port
->full_duplex
= 1;
1145 case H_SPEED_100M_H
:
1146 port
->port_speed
= EHEA_SPEED_100M
;
1147 port
->full_duplex
= 0;
1149 case H_SPEED_100M_F
:
1150 port
->port_speed
= EHEA_SPEED_100M
;
1151 port
->full_duplex
= 1;
1154 port
->port_speed
= EHEA_SPEED_1G
;
1155 port
->full_duplex
= 1;
1158 port
->port_speed
= EHEA_SPEED_10G
;
1159 port
->full_duplex
= 1;
1162 port
->port_speed
= 0;
1163 port
->full_duplex
= 0;
1167 ehea_error("Failed sensing port speed");
1171 if (hret
== H_AUTHORITY
) {
1172 ehea_info("Hypervisor denied setting port speed");
1176 ehea_error("Failed setting port speed");
1179 if (!prop_carrier_state
|| (port
->phy_link
== EHEA_PHY_LINK_UP
))
1180 netif_carrier_on(port
->netdev
);
1182 free_page((unsigned long)cb4
);
1187 static void ehea_parse_eqe(struct ehea_adapter
*adapter
, u64 eqe
)
1192 struct ehea_port
*port
;
1194 ec
= EHEA_BMASK_GET(NEQE_EVENT_CODE
, eqe
);
1195 portnum
= EHEA_BMASK_GET(NEQE_PORTNUM
, eqe
);
1196 port
= ehea_get_port(adapter
, portnum
);
1199 case EHEA_EC_PORTSTATE_CHG
: /* port state change */
1202 ehea_error("unknown portnum %x", portnum
);
1206 if (EHEA_BMASK_GET(NEQE_PORT_UP
, eqe
)) {
1207 if (!netif_carrier_ok(port
->netdev
)) {
1208 ret
= ehea_sense_port_attr(port
);
1210 ehea_error("failed resensing port "
1215 if (netif_msg_link(port
))
1216 ehea_info("%s: Logical port up: %dMbps "
1220 port
->full_duplex
==
1221 1 ? "Full" : "Half");
1223 netif_carrier_on(port
->netdev
);
1224 netif_wake_queue(port
->netdev
);
1227 if (netif_carrier_ok(port
->netdev
)) {
1228 if (netif_msg_link(port
))
1229 ehea_info("%s: Logical port down",
1230 port
->netdev
->name
);
1231 netif_carrier_off(port
->netdev
);
1232 netif_stop_queue(port
->netdev
);
1235 if (EHEA_BMASK_GET(NEQE_EXTSWITCH_PORT_UP
, eqe
)) {
1236 port
->phy_link
= EHEA_PHY_LINK_UP
;
1237 if (netif_msg_link(port
))
1238 ehea_info("%s: Physical port up",
1239 port
->netdev
->name
);
1240 if (prop_carrier_state
)
1241 netif_carrier_on(port
->netdev
);
1243 port
->phy_link
= EHEA_PHY_LINK_DOWN
;
1244 if (netif_msg_link(port
))
1245 ehea_info("%s: Physical port down",
1246 port
->netdev
->name
);
1247 if (prop_carrier_state
)
1248 netif_carrier_off(port
->netdev
);
1251 if (EHEA_BMASK_GET(NEQE_EXTSWITCH_PRIMARY
, eqe
))
1252 ehea_info("External switch port is primary port");
1254 ehea_info("External switch port is backup port");
1257 case EHEA_EC_ADAPTER_MALFUNC
:
1258 ehea_error("Adapter malfunction");
1260 case EHEA_EC_PORT_MALFUNC
:
1261 ehea_info("Port malfunction: Device: %s", port
->netdev
->name
);
1262 netif_carrier_off(port
->netdev
);
1263 netif_stop_queue(port
->netdev
);
1266 ehea_error("unknown event code %x, eqe=0x%llX", ec
, eqe
);
1271 static void ehea_neq_tasklet(unsigned long data
)
1273 struct ehea_adapter
*adapter
= (struct ehea_adapter
*)data
;
1274 struct ehea_eqe
*eqe
;
1277 eqe
= ehea_poll_eq(adapter
->neq
);
1278 ehea_debug("eqe=%p", eqe
);
1281 ehea_debug("*eqe=%lx", eqe
->entry
);
1282 ehea_parse_eqe(adapter
, eqe
->entry
);
1283 eqe
= ehea_poll_eq(adapter
->neq
);
1284 ehea_debug("next eqe=%p", eqe
);
1287 event_mask
= EHEA_BMASK_SET(NELR_PORTSTATE_CHG
, 1)
1288 | EHEA_BMASK_SET(NELR_ADAPTER_MALFUNC
, 1)
1289 | EHEA_BMASK_SET(NELR_PORT_MALFUNC
, 1);
1291 ehea_h_reset_events(adapter
->handle
,
1292 adapter
->neq
->fw_handle
, event_mask
);
1295 static irqreturn_t
ehea_interrupt_neq(int irq
, void *param
)
1297 struct ehea_adapter
*adapter
= param
;
1298 tasklet_hi_schedule(&adapter
->neq_tasklet
);
1303 static int ehea_fill_port_res(struct ehea_port_res
*pr
)
1306 struct ehea_qp_init_attr
*init_attr
= &pr
->qp
->init_attr
;
1308 ehea_init_fill_rq1(pr
, init_attr
->act_nr_rwqes_rq1
1309 - init_attr
->act_nr_rwqes_rq2
1310 - init_attr
->act_nr_rwqes_rq3
- 1);
1312 ret
= ehea_refill_rq2(pr
, init_attr
->act_nr_rwqes_rq2
- 1);
1314 ret
|= ehea_refill_rq3(pr
, init_attr
->act_nr_rwqes_rq3
- 1);
1319 static int ehea_reg_interrupts(struct net_device
*dev
)
1321 struct ehea_port
*port
= netdev_priv(dev
);
1322 struct ehea_port_res
*pr
;
1326 snprintf(port
->int_aff_name
, EHEA_IRQ_NAME_SIZE
- 1, "%s-aff",
1329 ret
= ibmebus_request_irq(port
->qp_eq
->attr
.ist1
,
1330 ehea_qp_aff_irq_handler
,
1331 IRQF_DISABLED
, port
->int_aff_name
, port
);
1333 ehea_error("failed registering irq for qp_aff_irq_handler:"
1334 "ist=%X", port
->qp_eq
->attr
.ist1
);
1338 if (netif_msg_ifup(port
))
1339 ehea_info("irq_handle 0x%X for function qp_aff_irq_handler "
1340 "registered", port
->qp_eq
->attr
.ist1
);
1343 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++) {
1344 pr
= &port
->port_res
[i
];
1345 snprintf(pr
->int_send_name
, EHEA_IRQ_NAME_SIZE
- 1,
1346 "%s-queue%d", dev
->name
, i
);
1347 ret
= ibmebus_request_irq(pr
->eq
->attr
.ist1
,
1348 ehea_recv_irq_handler
,
1349 IRQF_DISABLED
, pr
->int_send_name
,
1352 ehea_error("failed registering irq for ehea_queue "
1353 "port_res_nr:%d, ist=%X", i
,
1357 if (netif_msg_ifup(port
))
1358 ehea_info("irq_handle 0x%X for function ehea_queue_int "
1359 "%d registered", pr
->eq
->attr
.ist1
, i
);
1367 u32 ist
= port
->port_res
[i
].eq
->attr
.ist1
;
1368 ibmebus_free_irq(ist
, &port
->port_res
[i
]);
1372 ibmebus_free_irq(port
->qp_eq
->attr
.ist1
, port
);
1373 i
= port
->num_def_qps
;
1379 static void ehea_free_interrupts(struct net_device
*dev
)
1381 struct ehea_port
*port
= netdev_priv(dev
);
1382 struct ehea_port_res
*pr
;
1387 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++) {
1388 pr
= &port
->port_res
[i
];
1389 ibmebus_free_irq(pr
->eq
->attr
.ist1
, pr
);
1390 if (netif_msg_intr(port
))
1391 ehea_info("free send irq for res %d with handle 0x%X",
1392 i
, pr
->eq
->attr
.ist1
);
1395 /* associated events */
1396 ibmebus_free_irq(port
->qp_eq
->attr
.ist1
, port
);
1397 if (netif_msg_intr(port
))
1398 ehea_info("associated event interrupt for handle 0x%X freed",
1399 port
->qp_eq
->attr
.ist1
);
1402 static int ehea_configure_port(struct ehea_port
*port
)
1406 struct hcp_ehea_port_cb0
*cb0
;
1409 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
1413 cb0
->port_rc
= EHEA_BMASK_SET(PXLY_RC_VALID
, 1)
1414 | EHEA_BMASK_SET(PXLY_RC_IP_CHKSUM
, 1)
1415 | EHEA_BMASK_SET(PXLY_RC_TCP_UDP_CHKSUM
, 1)
1416 | EHEA_BMASK_SET(PXLY_RC_VLAN_XTRACT
, 1)
1417 | EHEA_BMASK_SET(PXLY_RC_VLAN_TAG_FILTER
,
1418 PXLY_RC_VLAN_FILTER
)
1419 | EHEA_BMASK_SET(PXLY_RC_JUMBO_FRAME
, 1);
1421 for (i
= 0; i
< port
->num_mcs
; i
++)
1423 cb0
->default_qpn_arr
[i
] =
1424 port
->port_res
[i
].qp
->init_attr
.qp_nr
;
1426 cb0
->default_qpn_arr
[i
] =
1427 port
->port_res
[0].qp
->init_attr
.qp_nr
;
1429 if (netif_msg_ifup(port
))
1430 ehea_dump(cb0
, sizeof(*cb0
), "ehea_configure_port");
1432 mask
= EHEA_BMASK_SET(H_PORT_CB0_PRC
, 1)
1433 | EHEA_BMASK_SET(H_PORT_CB0_DEFQPNARRAY
, 1);
1435 hret
= ehea_h_modify_ehea_port(port
->adapter
->handle
,
1436 port
->logical_port_id
,
1437 H_PORT_CB0
, mask
, cb0
);
1439 if (hret
!= H_SUCCESS
)
1445 free_page((unsigned long)cb0
);
1450 int ehea_gen_smrs(struct ehea_port_res
*pr
)
1453 struct ehea_adapter
*adapter
= pr
->port
->adapter
;
1455 ret
= ehea_gen_smr(adapter
, &adapter
->mr
, &pr
->send_mr
);
1459 ret
= ehea_gen_smr(adapter
, &adapter
->mr
, &pr
->recv_mr
);
1466 ehea_rem_mr(&pr
->send_mr
);
1468 ehea_error("Generating SMRS failed\n");
1472 int ehea_rem_smrs(struct ehea_port_res
*pr
)
1474 if ((ehea_rem_mr(&pr
->send_mr
)) ||
1475 (ehea_rem_mr(&pr
->recv_mr
)))
1481 static int ehea_init_q_skba(struct ehea_q_skb_arr
*q_skba
, int max_q_entries
)
1483 int arr_size
= sizeof(void *) * max_q_entries
;
1485 q_skba
->arr
= vmalloc(arr_size
);
1489 memset(q_skba
->arr
, 0, arr_size
);
1491 q_skba
->len
= max_q_entries
;
1493 q_skba
->os_skbs
= 0;
1498 static int ehea_init_port_res(struct ehea_port
*port
, struct ehea_port_res
*pr
,
1499 struct port_res_cfg
*pr_cfg
, int queue_token
)
1501 struct ehea_adapter
*adapter
= port
->adapter
;
1502 enum ehea_eq_type eq_type
= EHEA_EQ
;
1503 struct ehea_qp_init_attr
*init_attr
= NULL
;
1506 memset(pr
, 0, sizeof(struct ehea_port_res
));
1509 spin_lock_init(&pr
->xmit_lock
);
1510 spin_lock_init(&pr
->netif_queue
);
1512 pr
->eq
= ehea_create_eq(adapter
, eq_type
, EHEA_MAX_ENTRIES_EQ
, 0);
1514 ehea_error("create_eq failed (eq)");
1518 pr
->recv_cq
= ehea_create_cq(adapter
, pr_cfg
->max_entries_rcq
,
1520 port
->logical_port_id
);
1522 ehea_error("create_cq failed (cq_recv)");
1526 pr
->send_cq
= ehea_create_cq(adapter
, pr_cfg
->max_entries_scq
,
1528 port
->logical_port_id
);
1530 ehea_error("create_cq failed (cq_send)");
1534 if (netif_msg_ifup(port
))
1535 ehea_info("Send CQ: act_nr_cqes=%d, Recv CQ: act_nr_cqes=%d",
1536 pr
->send_cq
->attr
.act_nr_of_cqes
,
1537 pr
->recv_cq
->attr
.act_nr_of_cqes
);
1539 init_attr
= kzalloc(sizeof(*init_attr
), GFP_KERNEL
);
1542 ehea_error("no mem for ehea_qp_init_attr");
1546 init_attr
->low_lat_rq1
= 1;
1547 init_attr
->signalingtype
= 1; /* generate CQE if specified in WQE */
1548 init_attr
->rq_count
= 3;
1549 init_attr
->qp_token
= queue_token
;
1550 init_attr
->max_nr_send_wqes
= pr_cfg
->max_entries_sq
;
1551 init_attr
->max_nr_rwqes_rq1
= pr_cfg
->max_entries_rq1
;
1552 init_attr
->max_nr_rwqes_rq2
= pr_cfg
->max_entries_rq2
;
1553 init_attr
->max_nr_rwqes_rq3
= pr_cfg
->max_entries_rq3
;
1554 init_attr
->wqe_size_enc_sq
= EHEA_SG_SQ
;
1555 init_attr
->wqe_size_enc_rq1
= EHEA_SG_RQ1
;
1556 init_attr
->wqe_size_enc_rq2
= EHEA_SG_RQ2
;
1557 init_attr
->wqe_size_enc_rq3
= EHEA_SG_RQ3
;
1558 init_attr
->rq2_threshold
= EHEA_RQ2_THRESHOLD
;
1559 init_attr
->rq3_threshold
= EHEA_RQ3_THRESHOLD
;
1560 init_attr
->port_nr
= port
->logical_port_id
;
1561 init_attr
->send_cq_handle
= pr
->send_cq
->fw_handle
;
1562 init_attr
->recv_cq_handle
= pr
->recv_cq
->fw_handle
;
1563 init_attr
->aff_eq_handle
= port
->qp_eq
->fw_handle
;
1565 pr
->qp
= ehea_create_qp(adapter
, adapter
->pd
, init_attr
);
1567 ehea_error("create_qp failed");
1572 if (netif_msg_ifup(port
))
1573 ehea_info("QP: qp_nr=%d\n act_nr_snd_wqe=%d\n nr_rwqe_rq1=%d\n "
1574 "nr_rwqe_rq2=%d\n nr_rwqe_rq3=%d", init_attr
->qp_nr
,
1575 init_attr
->act_nr_send_wqes
,
1576 init_attr
->act_nr_rwqes_rq1
,
1577 init_attr
->act_nr_rwqes_rq2
,
1578 init_attr
->act_nr_rwqes_rq3
);
1580 pr
->sq_skba_size
= init_attr
->act_nr_send_wqes
+ 1;
1582 ret
= ehea_init_q_skba(&pr
->sq_skba
, pr
->sq_skba_size
);
1583 ret
|= ehea_init_q_skba(&pr
->rq1_skba
, init_attr
->act_nr_rwqes_rq1
+ 1);
1584 ret
|= ehea_init_q_skba(&pr
->rq2_skba
, init_attr
->act_nr_rwqes_rq2
+ 1);
1585 ret
|= ehea_init_q_skba(&pr
->rq3_skba
, init_attr
->act_nr_rwqes_rq3
+ 1);
1589 pr
->swqe_refill_th
= init_attr
->act_nr_send_wqes
/ 10;
1590 if (ehea_gen_smrs(pr
) != 0) {
1595 atomic_set(&pr
->swqe_avail
, init_attr
->act_nr_send_wqes
- 1);
1599 netif_napi_add(pr
->port
->netdev
, &pr
->napi
, ehea_poll
, 64);
1601 pr
->lro_mgr
.max_aggr
= pr
->port
->lro_max_aggr
;
1602 pr
->lro_mgr
.max_desc
= MAX_LRO_DESCRIPTORS
;
1603 pr
->lro_mgr
.lro_arr
= pr
->lro_desc
;
1604 pr
->lro_mgr
.get_skb_header
= get_skb_hdr
;
1605 pr
->lro_mgr
.features
= LRO_F_NAPI
| LRO_F_EXTRACT_VLAN_ID
;
1606 pr
->lro_mgr
.dev
= port
->netdev
;
1607 pr
->lro_mgr
.ip_summed
= CHECKSUM_UNNECESSARY
;
1608 pr
->lro_mgr
.ip_summed_aggr
= CHECKSUM_UNNECESSARY
;
1615 vfree(pr
->sq_skba
.arr
);
1616 vfree(pr
->rq1_skba
.arr
);
1617 vfree(pr
->rq2_skba
.arr
);
1618 vfree(pr
->rq3_skba
.arr
);
1619 ehea_destroy_qp(pr
->qp
);
1620 ehea_destroy_cq(pr
->send_cq
);
1621 ehea_destroy_cq(pr
->recv_cq
);
1622 ehea_destroy_eq(pr
->eq
);
1627 static int ehea_clean_portres(struct ehea_port
*port
, struct ehea_port_res
*pr
)
1632 netif_napi_del(&pr
->napi
);
1634 ret
= ehea_destroy_qp(pr
->qp
);
1637 ehea_destroy_cq(pr
->send_cq
);
1638 ehea_destroy_cq(pr
->recv_cq
);
1639 ehea_destroy_eq(pr
->eq
);
1641 for (i
= 0; i
< pr
->rq1_skba
.len
; i
++)
1642 if (pr
->rq1_skba
.arr
[i
])
1643 dev_kfree_skb(pr
->rq1_skba
.arr
[i
]);
1645 for (i
= 0; i
< pr
->rq2_skba
.len
; i
++)
1646 if (pr
->rq2_skba
.arr
[i
])
1647 dev_kfree_skb(pr
->rq2_skba
.arr
[i
]);
1649 for (i
= 0; i
< pr
->rq3_skba
.len
; i
++)
1650 if (pr
->rq3_skba
.arr
[i
])
1651 dev_kfree_skb(pr
->rq3_skba
.arr
[i
]);
1653 for (i
= 0; i
< pr
->sq_skba
.len
; i
++)
1654 if (pr
->sq_skba
.arr
[i
])
1655 dev_kfree_skb(pr
->sq_skba
.arr
[i
]);
1657 vfree(pr
->rq1_skba
.arr
);
1658 vfree(pr
->rq2_skba
.arr
);
1659 vfree(pr
->rq3_skba
.arr
);
1660 vfree(pr
->sq_skba
.arr
);
1661 ret
= ehea_rem_smrs(pr
);
1667 * The write_* functions store information in swqe which is used by
1668 * the hardware to calculate the ip/tcp/udp checksum
1671 static inline void write_ip_start_end(struct ehea_swqe
*swqe
,
1672 const struct sk_buff
*skb
)
1674 swqe
->ip_start
= skb_network_offset(skb
);
1675 swqe
->ip_end
= (u8
)(swqe
->ip_start
+ ip_hdrlen(skb
) - 1);
1678 static inline void write_tcp_offset_end(struct ehea_swqe
*swqe
,
1679 const struct sk_buff
*skb
)
1682 (u8
)(swqe
->ip_end
+ 1 + offsetof(struct tcphdr
, check
));
1684 swqe
->tcp_end
= (u16
)skb
->len
- 1;
1687 static inline void write_udp_offset_end(struct ehea_swqe
*swqe
,
1688 const struct sk_buff
*skb
)
1691 (u8
)(swqe
->ip_end
+ 1 + offsetof(struct udphdr
, check
));
1693 swqe
->tcp_end
= (u16
)skb
->len
- 1;
1697 static void write_swqe2_TSO(struct sk_buff
*skb
,
1698 struct ehea_swqe
*swqe
, u32 lkey
)
1700 struct ehea_vsgentry
*sg1entry
= &swqe
->u
.immdata_desc
.sg_entry
;
1701 u8
*imm_data
= &swqe
->u
.immdata_desc
.immediate_data
[0];
1702 int skb_data_size
= skb_headlen(skb
);
1705 /* Packet is TCP with TSO enabled */
1706 swqe
->tx_control
|= EHEA_SWQE_TSO
;
1707 swqe
->mss
= skb_shinfo(skb
)->gso_size
;
1708 /* copy only eth/ip/tcp headers to immediate data and
1709 * the rest of skb->data to sg1entry
1711 headersize
= ETH_HLEN
+ ip_hdrlen(skb
) + tcp_hdrlen(skb
);
1713 skb_data_size
= skb_headlen(skb
);
1715 if (skb_data_size
>= headersize
) {
1716 /* copy immediate data */
1717 skb_copy_from_linear_data(skb
, imm_data
, headersize
);
1718 swqe
->immediate_data_length
= headersize
;
1720 if (skb_data_size
> headersize
) {
1721 /* set sg1entry data */
1722 sg1entry
->l_key
= lkey
;
1723 sg1entry
->len
= skb_data_size
- headersize
;
1725 ehea_map_vaddr(skb
->data
+ headersize
);
1726 swqe
->descriptors
++;
1729 ehea_error("cannot handle fragmented headers");
1732 static void write_swqe2_nonTSO(struct sk_buff
*skb
,
1733 struct ehea_swqe
*swqe
, u32 lkey
)
1735 int skb_data_size
= skb_headlen(skb
);
1736 u8
*imm_data
= &swqe
->u
.immdata_desc
.immediate_data
[0];
1737 struct ehea_vsgentry
*sg1entry
= &swqe
->u
.immdata_desc
.sg_entry
;
1739 /* Packet is any nonTSO type
1741 * Copy as much as possible skb->data to immediate data and
1742 * the rest to sg1entry
1744 if (skb_data_size
>= SWQE2_MAX_IMM
) {
1745 /* copy immediate data */
1746 skb_copy_from_linear_data(skb
, imm_data
, SWQE2_MAX_IMM
);
1748 swqe
->immediate_data_length
= SWQE2_MAX_IMM
;
1750 if (skb_data_size
> SWQE2_MAX_IMM
) {
1751 /* copy sg1entry data */
1752 sg1entry
->l_key
= lkey
;
1753 sg1entry
->len
= skb_data_size
- SWQE2_MAX_IMM
;
1755 ehea_map_vaddr(skb
->data
+ SWQE2_MAX_IMM
);
1756 swqe
->descriptors
++;
1759 skb_copy_from_linear_data(skb
, imm_data
, skb_data_size
);
1760 swqe
->immediate_data_length
= skb_data_size
;
1764 static inline void write_swqe2_data(struct sk_buff
*skb
, struct net_device
*dev
,
1765 struct ehea_swqe
*swqe
, u32 lkey
)
1767 struct ehea_vsgentry
*sg_list
, *sg1entry
, *sgentry
;
1769 int nfrags
, sg1entry_contains_frag_data
, i
;
1771 nfrags
= skb_shinfo(skb
)->nr_frags
;
1772 sg1entry
= &swqe
->u
.immdata_desc
.sg_entry
;
1773 sg_list
= (struct ehea_vsgentry
*)&swqe
->u
.immdata_desc
.sg_list
;
1774 swqe
->descriptors
= 0;
1775 sg1entry_contains_frag_data
= 0;
1777 if ((dev
->features
& NETIF_F_TSO
) && skb_shinfo(skb
)->gso_size
)
1778 write_swqe2_TSO(skb
, swqe
, lkey
);
1780 write_swqe2_nonTSO(skb
, swqe
, lkey
);
1782 /* write descriptors */
1784 if (swqe
->descriptors
== 0) {
1785 /* sg1entry not yet used */
1786 frag
= &skb_shinfo(skb
)->frags
[0];
1788 /* copy sg1entry data */
1789 sg1entry
->l_key
= lkey
;
1790 sg1entry
->len
= frag
->size
;
1792 ehea_map_vaddr(page_address(frag
->page
)
1793 + frag
->page_offset
);
1794 swqe
->descriptors
++;
1795 sg1entry_contains_frag_data
= 1;
1798 for (i
= sg1entry_contains_frag_data
; i
< nfrags
; i
++) {
1800 frag
= &skb_shinfo(skb
)->frags
[i
];
1801 sgentry
= &sg_list
[i
- sg1entry_contains_frag_data
];
1803 sgentry
->l_key
= lkey
;
1804 sgentry
->len
= frag
->size
;
1806 ehea_map_vaddr(page_address(frag
->page
)
1807 + frag
->page_offset
);
1808 swqe
->descriptors
++;
1813 static int ehea_broadcast_reg_helper(struct ehea_port
*port
, u32 hcallid
)
1819 /* De/Register untagged packets */
1820 reg_type
= EHEA_BCMC_BROADCAST
| EHEA_BCMC_UNTAGGED
;
1821 hret
= ehea_h_reg_dereg_bcmc(port
->adapter
->handle
,
1822 port
->logical_port_id
,
1823 reg_type
, port
->mac_addr
, 0, hcallid
);
1824 if (hret
!= H_SUCCESS
) {
1825 ehea_error("%sregistering bc address failed (tagged)",
1826 hcallid
== H_REG_BCMC
? "" : "de");
1831 /* De/Register VLAN packets */
1832 reg_type
= EHEA_BCMC_BROADCAST
| EHEA_BCMC_VLANID_ALL
;
1833 hret
= ehea_h_reg_dereg_bcmc(port
->adapter
->handle
,
1834 port
->logical_port_id
,
1835 reg_type
, port
->mac_addr
, 0, hcallid
);
1836 if (hret
!= H_SUCCESS
) {
1837 ehea_error("%sregistering bc address failed (vlan)",
1838 hcallid
== H_REG_BCMC
? "" : "de");
1845 static int ehea_set_mac_addr(struct net_device
*dev
, void *sa
)
1847 struct ehea_port
*port
= netdev_priv(dev
);
1848 struct sockaddr
*mac_addr
= sa
;
1849 struct hcp_ehea_port_cb0
*cb0
;
1853 if (!is_valid_ether_addr(mac_addr
->sa_data
)) {
1854 ret
= -EADDRNOTAVAIL
;
1858 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
1860 ehea_error("no mem for cb0");
1865 memcpy(&(cb0
->port_mac_addr
), &(mac_addr
->sa_data
[0]), ETH_ALEN
);
1867 cb0
->port_mac_addr
= cb0
->port_mac_addr
>> 16;
1869 hret
= ehea_h_modify_ehea_port(port
->adapter
->handle
,
1870 port
->logical_port_id
, H_PORT_CB0
,
1871 EHEA_BMASK_SET(H_PORT_CB0_MAC
, 1), cb0
);
1872 if (hret
!= H_SUCCESS
) {
1877 memcpy(dev
->dev_addr
, mac_addr
->sa_data
, dev
->addr_len
);
1879 /* Deregister old MAC in pHYP */
1880 if (port
->state
== EHEA_PORT_UP
) {
1881 ret
= ehea_broadcast_reg_helper(port
, H_DEREG_BCMC
);
1886 port
->mac_addr
= cb0
->port_mac_addr
<< 16;
1888 /* Register new MAC in pHYP */
1889 if (port
->state
== EHEA_PORT_UP
) {
1890 ret
= ehea_broadcast_reg_helper(port
, H_REG_BCMC
);
1898 ehea_update_bcmc_registrations();
1900 free_page((unsigned long)cb0
);
1905 static void ehea_promiscuous_error(u64 hret
, int enable
)
1907 if (hret
== H_AUTHORITY
)
1908 ehea_info("Hypervisor denied %sabling promiscuous mode",
1909 enable
== 1 ? "en" : "dis");
1911 ehea_error("failed %sabling promiscuous mode",
1912 enable
== 1 ? "en" : "dis");
1915 static void ehea_promiscuous(struct net_device
*dev
, int enable
)
1917 struct ehea_port
*port
= netdev_priv(dev
);
1918 struct hcp_ehea_port_cb7
*cb7
;
1921 if (enable
== port
->promisc
)
1924 cb7
= (void *)get_zeroed_page(GFP_ATOMIC
);
1926 ehea_error("no mem for cb7");
1930 /* Modify Pxs_DUCQPN in CB7 */
1931 cb7
->def_uc_qpn
= enable
== 1 ? port
->port_res
[0].qp
->fw_handle
: 0;
1933 hret
= ehea_h_modify_ehea_port(port
->adapter
->handle
,
1934 port
->logical_port_id
,
1935 H_PORT_CB7
, H_PORT_CB7_DUCQPN
, cb7
);
1937 ehea_promiscuous_error(hret
, enable
);
1941 port
->promisc
= enable
;
1943 free_page((unsigned long)cb7
);
1946 static u64
ehea_multicast_reg_helper(struct ehea_port
*port
, u64 mc_mac_addr
,
1952 reg_type
= EHEA_BCMC_SCOPE_ALL
| EHEA_BCMC_MULTICAST
1953 | EHEA_BCMC_UNTAGGED
;
1955 hret
= ehea_h_reg_dereg_bcmc(port
->adapter
->handle
,
1956 port
->logical_port_id
,
1957 reg_type
, mc_mac_addr
, 0, hcallid
);
1961 reg_type
= EHEA_BCMC_SCOPE_ALL
| EHEA_BCMC_MULTICAST
1962 | EHEA_BCMC_VLANID_ALL
;
1964 hret
= ehea_h_reg_dereg_bcmc(port
->adapter
->handle
,
1965 port
->logical_port_id
,
1966 reg_type
, mc_mac_addr
, 0, hcallid
);
1971 static int ehea_drop_multicast_list(struct net_device
*dev
)
1973 struct ehea_port
*port
= netdev_priv(dev
);
1974 struct ehea_mc_list
*mc_entry
= port
->mc_list
;
1975 struct list_head
*pos
;
1976 struct list_head
*temp
;
1980 list_for_each_safe(pos
, temp
, &(port
->mc_list
->list
)) {
1981 mc_entry
= list_entry(pos
, struct ehea_mc_list
, list
);
1983 hret
= ehea_multicast_reg_helper(port
, mc_entry
->macaddr
,
1986 ehea_error("failed deregistering mcast MAC");
1996 static void ehea_allmulti(struct net_device
*dev
, int enable
)
1998 struct ehea_port
*port
= netdev_priv(dev
);
2001 if (!port
->allmulti
) {
2003 /* Enable ALLMULTI */
2004 ehea_drop_multicast_list(dev
);
2005 hret
= ehea_multicast_reg_helper(port
, 0, H_REG_BCMC
);
2009 ehea_error("failed enabling IFF_ALLMULTI");
2013 /* Disable ALLMULTI */
2014 hret
= ehea_multicast_reg_helper(port
, 0, H_DEREG_BCMC
);
2018 ehea_error("failed disabling IFF_ALLMULTI");
2022 static void ehea_add_multicast_entry(struct ehea_port
*port
, u8
*mc_mac_addr
)
2024 struct ehea_mc_list
*ehea_mcl_entry
;
2027 ehea_mcl_entry
= kzalloc(sizeof(*ehea_mcl_entry
), GFP_ATOMIC
);
2028 if (!ehea_mcl_entry
) {
2029 ehea_error("no mem for mcl_entry");
2033 INIT_LIST_HEAD(&ehea_mcl_entry
->list
);
2035 memcpy(&ehea_mcl_entry
->macaddr
, mc_mac_addr
, ETH_ALEN
);
2037 hret
= ehea_multicast_reg_helper(port
, ehea_mcl_entry
->macaddr
,
2040 list_add(&ehea_mcl_entry
->list
, &port
->mc_list
->list
);
2042 ehea_error("failed registering mcast MAC");
2043 kfree(ehea_mcl_entry
);
2047 static void ehea_set_multicast_list(struct net_device
*dev
)
2049 struct ehea_port
*port
= netdev_priv(dev
);
2050 struct netdev_hw_addr
*ha
;
2053 if (dev
->flags
& IFF_PROMISC
) {
2054 ehea_promiscuous(dev
, 1);
2057 ehea_promiscuous(dev
, 0);
2059 if (dev
->flags
& IFF_ALLMULTI
) {
2060 ehea_allmulti(dev
, 1);
2063 ehea_allmulti(dev
, 0);
2065 if (!netdev_mc_empty(dev
)) {
2066 ret
= ehea_drop_multicast_list(dev
);
2068 /* Dropping the current multicast list failed.
2069 * Enabling ALL_MULTI is the best we can do.
2071 ehea_allmulti(dev
, 1);
2074 if (netdev_mc_count(dev
) > port
->adapter
->max_mc_mac
) {
2075 ehea_info("Mcast registration limit reached (0x%llx). "
2077 port
->adapter
->max_mc_mac
);
2081 netdev_for_each_mc_addr(ha
, dev
)
2082 ehea_add_multicast_entry(port
, ha
->addr
);
2086 ehea_update_bcmc_registrations();
2089 static int ehea_change_mtu(struct net_device
*dev
, int new_mtu
)
2091 if ((new_mtu
< 68) || (new_mtu
> EHEA_MAX_PACKET_SIZE
))
2097 static void ehea_xmit2(struct sk_buff
*skb
, struct net_device
*dev
,
2098 struct ehea_swqe
*swqe
, u32 lkey
)
2100 if (skb
->protocol
== htons(ETH_P_IP
)) {
2101 const struct iphdr
*iph
= ip_hdr(skb
);
2104 swqe
->tx_control
|= EHEA_SWQE_CRC
2105 | EHEA_SWQE_IP_CHECKSUM
2106 | EHEA_SWQE_TCP_CHECKSUM
2107 | EHEA_SWQE_IMM_DATA_PRESENT
2108 | EHEA_SWQE_DESCRIPTORS_PRESENT
;
2110 write_ip_start_end(swqe
, skb
);
2112 if (iph
->protocol
== IPPROTO_UDP
) {
2113 if ((iph
->frag_off
& IP_MF
) ||
2114 (iph
->frag_off
& IP_OFFSET
))
2115 /* IP fragment, so don't change cs */
2116 swqe
->tx_control
&= ~EHEA_SWQE_TCP_CHECKSUM
;
2118 write_udp_offset_end(swqe
, skb
);
2119 } else if (iph
->protocol
== IPPROTO_TCP
) {
2120 write_tcp_offset_end(swqe
, skb
);
2123 /* icmp (big data) and ip segmentation packets (all other ip
2124 packets) do not require any special handling */
2127 /* Other Ethernet Protocol */
2128 swqe
->tx_control
|= EHEA_SWQE_CRC
2129 | EHEA_SWQE_IMM_DATA_PRESENT
2130 | EHEA_SWQE_DESCRIPTORS_PRESENT
;
2133 write_swqe2_data(skb
, dev
, swqe
, lkey
);
2136 static void ehea_xmit3(struct sk_buff
*skb
, struct net_device
*dev
,
2137 struct ehea_swqe
*swqe
)
2139 int nfrags
= skb_shinfo(skb
)->nr_frags
;
2140 u8
*imm_data
= &swqe
->u
.immdata_nodesc
.immediate_data
[0];
2144 if (skb
->protocol
== htons(ETH_P_IP
)) {
2145 const struct iphdr
*iph
= ip_hdr(skb
);
2148 write_ip_start_end(swqe
, skb
);
2150 if (iph
->protocol
== IPPROTO_TCP
) {
2151 swqe
->tx_control
|= EHEA_SWQE_CRC
2152 | EHEA_SWQE_IP_CHECKSUM
2153 | EHEA_SWQE_TCP_CHECKSUM
2154 | EHEA_SWQE_IMM_DATA_PRESENT
;
2156 write_tcp_offset_end(swqe
, skb
);
2158 } else if (iph
->protocol
== IPPROTO_UDP
) {
2159 if ((iph
->frag_off
& IP_MF
) ||
2160 (iph
->frag_off
& IP_OFFSET
))
2161 /* IP fragment, so don't change cs */
2162 swqe
->tx_control
|= EHEA_SWQE_CRC
2163 | EHEA_SWQE_IMM_DATA_PRESENT
;
2165 swqe
->tx_control
|= EHEA_SWQE_CRC
2166 | EHEA_SWQE_IP_CHECKSUM
2167 | EHEA_SWQE_TCP_CHECKSUM
2168 | EHEA_SWQE_IMM_DATA_PRESENT
;
2170 write_udp_offset_end(swqe
, skb
);
2173 /* icmp (big data) and
2174 ip segmentation packets (all other ip packets) */
2175 swqe
->tx_control
|= EHEA_SWQE_CRC
2176 | EHEA_SWQE_IP_CHECKSUM
2177 | EHEA_SWQE_IMM_DATA_PRESENT
;
2180 /* Other Ethernet Protocol */
2181 swqe
->tx_control
|= EHEA_SWQE_CRC
| EHEA_SWQE_IMM_DATA_PRESENT
;
2183 /* copy (immediate) data */
2185 /* data is in a single piece */
2186 skb_copy_from_linear_data(skb
, imm_data
, skb
->len
);
2188 /* first copy data from the skb->data buffer ... */
2189 skb_copy_from_linear_data(skb
, imm_data
,
2191 imm_data
+= skb_headlen(skb
);
2193 /* ... then copy data from the fragments */
2194 for (i
= 0; i
< nfrags
; i
++) {
2195 frag
= &skb_shinfo(skb
)->frags
[i
];
2197 page_address(frag
->page
) + frag
->page_offset
,
2199 imm_data
+= frag
->size
;
2202 swqe
->immediate_data_length
= skb
->len
;
2206 static inline int ehea_hash_skb(struct sk_buff
*skb
, int num_qps
)
2211 if ((skb
->protocol
== htons(ETH_P_IP
)) &&
2212 (ip_hdr(skb
)->protocol
== IPPROTO_TCP
)) {
2213 tcp
= (struct tcphdr
*)(skb_network_header(skb
) +
2214 (ip_hdr(skb
)->ihl
* 4));
2215 tmp
= (tcp
->source
+ (tcp
->dest
<< 16)) % 31;
2216 tmp
+= ip_hdr(skb
)->daddr
% 31;
2217 return tmp
% num_qps
;
2222 static int ehea_start_xmit(struct sk_buff
*skb
, struct net_device
*dev
)
2224 struct ehea_port
*port
= netdev_priv(dev
);
2225 struct ehea_swqe
*swqe
;
2226 unsigned long flags
;
2229 struct ehea_port_res
*pr
;
2231 pr
= &port
->port_res
[ehea_hash_skb(skb
, port
->num_tx_qps
)];
2233 if (!spin_trylock(&pr
->xmit_lock
))
2234 return NETDEV_TX_BUSY
;
2236 if (pr
->queue_stopped
) {
2237 spin_unlock(&pr
->xmit_lock
);
2238 return NETDEV_TX_BUSY
;
2241 swqe
= ehea_get_swqe(pr
->qp
, &swqe_index
);
2242 memset(swqe
, 0, SWQE_HEADER_SIZE
);
2243 atomic_dec(&pr
->swqe_avail
);
2245 if (skb
->len
<= SWQE3_MAX_IMM
) {
2246 u32 sig_iv
= port
->sig_comp_iv
;
2247 u32 swqe_num
= pr
->swqe_id_counter
;
2248 ehea_xmit3(skb
, dev
, swqe
);
2249 swqe
->wr_id
= EHEA_BMASK_SET(EHEA_WR_ID_TYPE
, EHEA_SWQE3_TYPE
)
2250 | EHEA_BMASK_SET(EHEA_WR_ID_COUNT
, swqe_num
);
2251 if (pr
->swqe_ll_count
>= (sig_iv
- 1)) {
2252 swqe
->wr_id
|= EHEA_BMASK_SET(EHEA_WR_ID_REFILL
,
2254 swqe
->tx_control
|= EHEA_SWQE_SIGNALLED_COMPLETION
;
2255 pr
->swqe_ll_count
= 0;
2257 pr
->swqe_ll_count
+= 1;
2260 EHEA_BMASK_SET(EHEA_WR_ID_TYPE
, EHEA_SWQE2_TYPE
)
2261 | EHEA_BMASK_SET(EHEA_WR_ID_COUNT
, pr
->swqe_id_counter
)
2262 | EHEA_BMASK_SET(EHEA_WR_ID_REFILL
, 1)
2263 | EHEA_BMASK_SET(EHEA_WR_ID_INDEX
, pr
->sq_skba
.index
);
2264 pr
->sq_skba
.arr
[pr
->sq_skba
.index
] = skb
;
2266 pr
->sq_skba
.index
++;
2267 pr
->sq_skba
.index
&= (pr
->sq_skba
.len
- 1);
2269 lkey
= pr
->send_mr
.lkey
;
2270 ehea_xmit2(skb
, dev
, swqe
, lkey
);
2271 swqe
->tx_control
|= EHEA_SWQE_SIGNALLED_COMPLETION
;
2273 pr
->swqe_id_counter
+= 1;
2275 if (port
->vgrp
&& vlan_tx_tag_present(skb
)) {
2276 swqe
->tx_control
|= EHEA_SWQE_VLAN_INSERT
;
2277 swqe
->vlan_tag
= vlan_tx_tag_get(skb
);
2280 if (netif_msg_tx_queued(port
)) {
2281 ehea_info("post swqe on QP %d", pr
->qp
->init_attr
.qp_nr
);
2282 ehea_dump(swqe
, 512, "swqe");
2285 if (unlikely(test_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
))) {
2286 netif_stop_queue(dev
);
2287 swqe
->tx_control
|= EHEA_SWQE_PURGE
;
2290 ehea_post_swqe(pr
->qp
, swqe
);
2293 if (unlikely(atomic_read(&pr
->swqe_avail
) <= 1)) {
2294 spin_lock_irqsave(&pr
->netif_queue
, flags
);
2295 if (unlikely(atomic_read(&pr
->swqe_avail
) <= 1)) {
2296 pr
->p_stats
.queue_stopped
++;
2297 netif_stop_queue(dev
);
2298 pr
->queue_stopped
= 1;
2300 spin_unlock_irqrestore(&pr
->netif_queue
, flags
);
2302 dev
->trans_start
= jiffies
; /* NETIF_F_LLTX driver :( */
2303 spin_unlock(&pr
->xmit_lock
);
2305 return NETDEV_TX_OK
;
2308 static void ehea_vlan_rx_register(struct net_device
*dev
,
2309 struct vlan_group
*grp
)
2311 struct ehea_port
*port
= netdev_priv(dev
);
2312 struct ehea_adapter
*adapter
= port
->adapter
;
2313 struct hcp_ehea_port_cb1
*cb1
;
2318 cb1
= (void *)get_zeroed_page(GFP_KERNEL
);
2320 ehea_error("no mem for cb1");
2324 hret
= ehea_h_modify_ehea_port(adapter
->handle
, port
->logical_port_id
,
2325 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2326 if (hret
!= H_SUCCESS
)
2327 ehea_error("modify_ehea_port failed");
2329 free_page((unsigned long)cb1
);
2334 static void ehea_vlan_rx_add_vid(struct net_device
*dev
, unsigned short vid
)
2336 struct ehea_port
*port
= netdev_priv(dev
);
2337 struct ehea_adapter
*adapter
= port
->adapter
;
2338 struct hcp_ehea_port_cb1
*cb1
;
2342 cb1
= (void *)get_zeroed_page(GFP_KERNEL
);
2344 ehea_error("no mem for cb1");
2348 hret
= ehea_h_query_ehea_port(adapter
->handle
, port
->logical_port_id
,
2349 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2350 if (hret
!= H_SUCCESS
) {
2351 ehea_error("query_ehea_port failed");
2356 cb1
->vlan_filter
[index
] |= ((u64
)(0x8000000000000000 >> (vid
& 0x3F)));
2358 hret
= ehea_h_modify_ehea_port(adapter
->handle
, port
->logical_port_id
,
2359 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2360 if (hret
!= H_SUCCESS
)
2361 ehea_error("modify_ehea_port failed");
2363 free_page((unsigned long)cb1
);
2367 static void ehea_vlan_rx_kill_vid(struct net_device
*dev
, unsigned short vid
)
2369 struct ehea_port
*port
= netdev_priv(dev
);
2370 struct ehea_adapter
*adapter
= port
->adapter
;
2371 struct hcp_ehea_port_cb1
*cb1
;
2375 vlan_group_set_device(port
->vgrp
, vid
, NULL
);
2377 cb1
= (void *)get_zeroed_page(GFP_KERNEL
);
2379 ehea_error("no mem for cb1");
2383 hret
= ehea_h_query_ehea_port(adapter
->handle
, port
->logical_port_id
,
2384 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2385 if (hret
!= H_SUCCESS
) {
2386 ehea_error("query_ehea_port failed");
2391 cb1
->vlan_filter
[index
] &= ~((u64
)(0x8000000000000000 >> (vid
& 0x3F)));
2393 hret
= ehea_h_modify_ehea_port(adapter
->handle
, port
->logical_port_id
,
2394 H_PORT_CB1
, H_PORT_CB1_ALL
, cb1
);
2395 if (hret
!= H_SUCCESS
)
2396 ehea_error("modify_ehea_port failed");
2398 free_page((unsigned long)cb1
);
2401 int ehea_activate_qp(struct ehea_adapter
*adapter
, struct ehea_qp
*qp
)
2407 struct hcp_modify_qp_cb0
*cb0
;
2409 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
2415 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2416 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF), cb0
);
2417 if (hret
!= H_SUCCESS
) {
2418 ehea_error("query_ehea_qp failed (1)");
2422 cb0
->qp_ctl_reg
= H_QP_CR_STATE_INITIALIZED
;
2423 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2424 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
, 1), cb0
,
2425 &dummy64
, &dummy64
, &dummy16
, &dummy16
);
2426 if (hret
!= H_SUCCESS
) {
2427 ehea_error("modify_ehea_qp failed (1)");
2431 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2432 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF), cb0
);
2433 if (hret
!= H_SUCCESS
) {
2434 ehea_error("query_ehea_qp failed (2)");
2438 cb0
->qp_ctl_reg
= H_QP_CR_ENABLED
| H_QP_CR_STATE_INITIALIZED
;
2439 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2440 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
, 1), cb0
,
2441 &dummy64
, &dummy64
, &dummy16
, &dummy16
);
2442 if (hret
!= H_SUCCESS
) {
2443 ehea_error("modify_ehea_qp failed (2)");
2447 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2448 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF), cb0
);
2449 if (hret
!= H_SUCCESS
) {
2450 ehea_error("query_ehea_qp failed (3)");
2454 cb0
->qp_ctl_reg
= H_QP_CR_ENABLED
| H_QP_CR_STATE_RDY2SND
;
2455 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2456 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
, 1), cb0
,
2457 &dummy64
, &dummy64
, &dummy16
, &dummy16
);
2458 if (hret
!= H_SUCCESS
) {
2459 ehea_error("modify_ehea_qp failed (3)");
2463 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2464 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF), cb0
);
2465 if (hret
!= H_SUCCESS
) {
2466 ehea_error("query_ehea_qp failed (4)");
2472 free_page((unsigned long)cb0
);
2476 static int ehea_port_res_setup(struct ehea_port
*port
, int def_qps
,
2480 struct port_res_cfg pr_cfg
, pr_cfg_small_rx
;
2481 enum ehea_eq_type eq_type
= EHEA_EQ
;
2483 port
->qp_eq
= ehea_create_eq(port
->adapter
, eq_type
,
2484 EHEA_MAX_ENTRIES_EQ
, 1);
2487 ehea_error("ehea_create_eq failed (qp_eq)");
2491 pr_cfg
.max_entries_rcq
= rq1_entries
+ rq2_entries
+ rq3_entries
;
2492 pr_cfg
.max_entries_scq
= sq_entries
* 2;
2493 pr_cfg
.max_entries_sq
= sq_entries
;
2494 pr_cfg
.max_entries_rq1
= rq1_entries
;
2495 pr_cfg
.max_entries_rq2
= rq2_entries
;
2496 pr_cfg
.max_entries_rq3
= rq3_entries
;
2498 pr_cfg_small_rx
.max_entries_rcq
= 1;
2499 pr_cfg_small_rx
.max_entries_scq
= sq_entries
;
2500 pr_cfg_small_rx
.max_entries_sq
= sq_entries
;
2501 pr_cfg_small_rx
.max_entries_rq1
= 1;
2502 pr_cfg_small_rx
.max_entries_rq2
= 1;
2503 pr_cfg_small_rx
.max_entries_rq3
= 1;
2505 for (i
= 0; i
< def_qps
; i
++) {
2506 ret
= ehea_init_port_res(port
, &port
->port_res
[i
], &pr_cfg
, i
);
2510 for (i
= def_qps
; i
< def_qps
+ add_tx_qps
; i
++) {
2511 ret
= ehea_init_port_res(port
, &port
->port_res
[i
],
2512 &pr_cfg_small_rx
, i
);
2521 ehea_clean_portres(port
, &port
->port_res
[i
]);
2524 ehea_destroy_eq(port
->qp_eq
);
2528 static int ehea_clean_all_portres(struct ehea_port
*port
)
2533 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++)
2534 ret
|= ehea_clean_portres(port
, &port
->port_res
[i
]);
2536 ret
|= ehea_destroy_eq(port
->qp_eq
);
2541 static void ehea_remove_adapter_mr(struct ehea_adapter
*adapter
)
2543 if (adapter
->active_ports
)
2546 ehea_rem_mr(&adapter
->mr
);
2549 static int ehea_add_adapter_mr(struct ehea_adapter
*adapter
)
2551 if (adapter
->active_ports
)
2554 return ehea_reg_kernel_mr(adapter
, &adapter
->mr
);
2557 static int ehea_up(struct net_device
*dev
)
2560 struct ehea_port
*port
= netdev_priv(dev
);
2562 if (port
->state
== EHEA_PORT_UP
)
2565 ret
= ehea_port_res_setup(port
, port
->num_def_qps
,
2566 port
->num_add_tx_qps
);
2568 ehea_error("port_res_failed");
2572 /* Set default QP for this port */
2573 ret
= ehea_configure_port(port
);
2575 ehea_error("ehea_configure_port failed. ret:%d", ret
);
2579 ret
= ehea_reg_interrupts(dev
);
2581 ehea_error("reg_interrupts failed. ret:%d", ret
);
2585 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++) {
2586 ret
= ehea_activate_qp(port
->adapter
, port
->port_res
[i
].qp
);
2588 ehea_error("activate_qp failed");
2593 for (i
= 0; i
< port
->num_def_qps
; i
++) {
2594 ret
= ehea_fill_port_res(&port
->port_res
[i
]);
2596 ehea_error("out_free_irqs");
2601 ret
= ehea_broadcast_reg_helper(port
, H_REG_BCMC
);
2607 port
->state
= EHEA_PORT_UP
;
2613 ehea_free_interrupts(dev
);
2616 ehea_clean_all_portres(port
);
2619 ehea_info("Failed starting %s. ret=%i", dev
->name
, ret
);
2621 ehea_update_bcmc_registrations();
2622 ehea_update_firmware_handles();
2627 static void port_napi_disable(struct ehea_port
*port
)
2631 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++)
2632 napi_disable(&port
->port_res
[i
].napi
);
2635 static void port_napi_enable(struct ehea_port
*port
)
2639 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++)
2640 napi_enable(&port
->port_res
[i
].napi
);
2643 static int ehea_open(struct net_device
*dev
)
2646 struct ehea_port
*port
= netdev_priv(dev
);
2648 mutex_lock(&port
->port_lock
);
2650 if (netif_msg_ifup(port
))
2651 ehea_info("enabling port %s", dev
->name
);
2655 port_napi_enable(port
);
2656 netif_start_queue(dev
);
2659 init_waitqueue_head(&port
->swqe_avail_wq
);
2660 init_waitqueue_head(&port
->restart_wq
);
2662 mutex_unlock(&port
->port_lock
);
2667 static int ehea_down(struct net_device
*dev
)
2670 struct ehea_port
*port
= netdev_priv(dev
);
2672 if (port
->state
== EHEA_PORT_DOWN
)
2675 ehea_drop_multicast_list(dev
);
2676 ehea_broadcast_reg_helper(port
, H_DEREG_BCMC
);
2678 ehea_free_interrupts(dev
);
2680 port
->state
= EHEA_PORT_DOWN
;
2682 ehea_update_bcmc_registrations();
2684 ret
= ehea_clean_all_portres(port
);
2686 ehea_info("Failed freeing resources for %s. ret=%i",
2689 ehea_update_firmware_handles();
2694 static int ehea_stop(struct net_device
*dev
)
2697 struct ehea_port
*port
= netdev_priv(dev
);
2699 if (netif_msg_ifdown(port
))
2700 ehea_info("disabling port %s", dev
->name
);
2702 set_bit(__EHEA_DISABLE_PORT_RESET
, &port
->flags
);
2703 cancel_work_sync(&port
->reset_task
);
2704 mutex_lock(&port
->port_lock
);
2705 netif_stop_queue(dev
);
2706 port_napi_disable(port
);
2707 ret
= ehea_down(dev
);
2708 mutex_unlock(&port
->port_lock
);
2709 clear_bit(__EHEA_DISABLE_PORT_RESET
, &port
->flags
);
2713 static void ehea_purge_sq(struct ehea_qp
*orig_qp
)
2715 struct ehea_qp qp
= *orig_qp
;
2716 struct ehea_qp_init_attr
*init_attr
= &qp
.init_attr
;
2717 struct ehea_swqe
*swqe
;
2721 for (i
= 0; i
< init_attr
->act_nr_send_wqes
; i
++) {
2722 swqe
= ehea_get_swqe(&qp
, &wqe_index
);
2723 swqe
->tx_control
|= EHEA_SWQE_PURGE
;
2727 static void ehea_flush_sq(struct ehea_port
*port
)
2731 for (i
= 0; i
< port
->num_def_qps
+ port
->num_add_tx_qps
; i
++) {
2732 struct ehea_port_res
*pr
= &port
->port_res
[i
];
2733 int swqe_max
= pr
->sq_skba_size
- 2 - pr
->swqe_ll_count
;
2736 ret
= wait_event_timeout(port
->swqe_avail_wq
,
2737 atomic_read(&pr
->swqe_avail
) >= swqe_max
,
2738 msecs_to_jiffies(100));
2741 ehea_error("WARNING: sq not flushed completely");
2747 int ehea_stop_qps(struct net_device
*dev
)
2749 struct ehea_port
*port
= netdev_priv(dev
);
2750 struct ehea_adapter
*adapter
= port
->adapter
;
2751 struct hcp_modify_qp_cb0
*cb0
;
2759 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
2765 for (i
= 0; i
< (port
->num_def_qps
+ port
->num_add_tx_qps
); i
++) {
2766 struct ehea_port_res
*pr
= &port
->port_res
[i
];
2767 struct ehea_qp
*qp
= pr
->qp
;
2769 /* Purge send queue */
2772 /* Disable queue pair */
2773 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2774 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF),
2776 if (hret
!= H_SUCCESS
) {
2777 ehea_error("query_ehea_qp failed (1)");
2781 cb0
->qp_ctl_reg
= (cb0
->qp_ctl_reg
& H_QP_CR_RES_STATE
) << 8;
2782 cb0
->qp_ctl_reg
&= ~H_QP_CR_ENABLED
;
2784 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2785 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
,
2787 &dummy64
, &dummy16
, &dummy16
);
2788 if (hret
!= H_SUCCESS
) {
2789 ehea_error("modify_ehea_qp failed (1)");
2793 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2794 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF),
2796 if (hret
!= H_SUCCESS
) {
2797 ehea_error("query_ehea_qp failed (2)");
2801 /* deregister shared memory regions */
2802 dret
= ehea_rem_smrs(pr
);
2804 ehea_error("unreg shared memory region failed");
2811 free_page((unsigned long)cb0
);
2816 void ehea_update_rqs(struct ehea_qp
*orig_qp
, struct ehea_port_res
*pr
)
2818 struct ehea_qp qp
= *orig_qp
;
2819 struct ehea_qp_init_attr
*init_attr
= &qp
.init_attr
;
2820 struct ehea_rwqe
*rwqe
;
2821 struct sk_buff
**skba_rq2
= pr
->rq2_skba
.arr
;
2822 struct sk_buff
**skba_rq3
= pr
->rq3_skba
.arr
;
2823 struct sk_buff
*skb
;
2824 u32 lkey
= pr
->recv_mr
.lkey
;
2830 for (i
= 0; i
< init_attr
->act_nr_rwqes_rq2
+ 1; i
++) {
2831 rwqe
= ehea_get_next_rwqe(&qp
, 2);
2832 rwqe
->sg_list
[0].l_key
= lkey
;
2833 index
= EHEA_BMASK_GET(EHEA_WR_ID_INDEX
, rwqe
->wr_id
);
2834 skb
= skba_rq2
[index
];
2836 rwqe
->sg_list
[0].vaddr
= ehea_map_vaddr(skb
->data
);
2839 for (i
= 0; i
< init_attr
->act_nr_rwqes_rq3
+ 1; i
++) {
2840 rwqe
= ehea_get_next_rwqe(&qp
, 3);
2841 rwqe
->sg_list
[0].l_key
= lkey
;
2842 index
= EHEA_BMASK_GET(EHEA_WR_ID_INDEX
, rwqe
->wr_id
);
2843 skb
= skba_rq3
[index
];
2845 rwqe
->sg_list
[0].vaddr
= ehea_map_vaddr(skb
->data
);
2849 int ehea_restart_qps(struct net_device
*dev
)
2851 struct ehea_port
*port
= netdev_priv(dev
);
2852 struct ehea_adapter
*adapter
= port
->adapter
;
2856 struct hcp_modify_qp_cb0
*cb0
;
2861 cb0
= (void *)get_zeroed_page(GFP_KERNEL
);
2867 for (i
= 0; i
< (port
->num_def_qps
+ port
->num_add_tx_qps
); i
++) {
2868 struct ehea_port_res
*pr
= &port
->port_res
[i
];
2869 struct ehea_qp
*qp
= pr
->qp
;
2871 ret
= ehea_gen_smrs(pr
);
2873 ehea_error("creation of shared memory regions failed");
2877 ehea_update_rqs(qp
, pr
);
2879 /* Enable queue pair */
2880 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2881 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF),
2883 if (hret
!= H_SUCCESS
) {
2884 ehea_error("query_ehea_qp failed (1)");
2888 cb0
->qp_ctl_reg
= (cb0
->qp_ctl_reg
& H_QP_CR_RES_STATE
) << 8;
2889 cb0
->qp_ctl_reg
|= H_QP_CR_ENABLED
;
2891 hret
= ehea_h_modify_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2892 EHEA_BMASK_SET(H_QPCB0_QP_CTL_REG
,
2894 &dummy64
, &dummy16
, &dummy16
);
2895 if (hret
!= H_SUCCESS
) {
2896 ehea_error("modify_ehea_qp failed (1)");
2900 hret
= ehea_h_query_ehea_qp(adapter
->handle
, 0, qp
->fw_handle
,
2901 EHEA_BMASK_SET(H_QPCB0_ALL
, 0xFFFF),
2903 if (hret
!= H_SUCCESS
) {
2904 ehea_error("query_ehea_qp failed (2)");
2908 /* refill entire queue */
2909 ehea_refill_rq1(pr
, pr
->rq1_skba
.index
, 0);
2910 ehea_refill_rq2(pr
, 0);
2911 ehea_refill_rq3(pr
, 0);
2914 free_page((unsigned long)cb0
);
2919 static void ehea_reset_port(struct work_struct
*work
)
2922 struct ehea_port
*port
=
2923 container_of(work
, struct ehea_port
, reset_task
);
2924 struct net_device
*dev
= port
->netdev
;
2926 mutex_lock(&dlpar_mem_lock
);
2928 mutex_lock(&port
->port_lock
);
2929 netif_stop_queue(dev
);
2931 port_napi_disable(port
);
2939 ehea_set_multicast_list(dev
);
2941 if (netif_msg_timer(port
))
2942 ehea_info("Device %s resetted successfully", dev
->name
);
2944 port_napi_enable(port
);
2946 netif_wake_queue(dev
);
2948 mutex_unlock(&port
->port_lock
);
2949 mutex_unlock(&dlpar_mem_lock
);
2952 static void ehea_rereg_mrs(struct work_struct
*work
)
2955 struct ehea_adapter
*adapter
;
2957 ehea_info("LPAR memory changed - re-initializing driver");
2959 list_for_each_entry(adapter
, &adapter_list
, list
)
2960 if (adapter
->active_ports
) {
2961 /* Shutdown all ports */
2962 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++) {
2963 struct ehea_port
*port
= adapter
->port
[i
];
2964 struct net_device
*dev
;
2971 if (dev
->flags
& IFF_UP
) {
2972 mutex_lock(&port
->port_lock
);
2973 netif_stop_queue(dev
);
2974 ehea_flush_sq(port
);
2975 ret
= ehea_stop_qps(dev
);
2977 mutex_unlock(&port
->port_lock
);
2980 port_napi_disable(port
);
2981 mutex_unlock(&port
->port_lock
);
2983 reset_sq_restart_flag(port
);
2986 /* Unregister old memory region */
2987 ret
= ehea_rem_mr(&adapter
->mr
);
2989 ehea_error("unregister MR failed - driver"
2995 clear_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
);
2997 list_for_each_entry(adapter
, &adapter_list
, list
)
2998 if (adapter
->active_ports
) {
2999 /* Register new memory region */
3000 ret
= ehea_reg_kernel_mr(adapter
, &adapter
->mr
);
3002 ehea_error("register MR failed - driver"
3007 /* Restart all ports */
3008 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++) {
3009 struct ehea_port
*port
= adapter
->port
[i
];
3012 struct net_device
*dev
= port
->netdev
;
3014 if (dev
->flags
& IFF_UP
) {
3015 mutex_lock(&port
->port_lock
);
3016 port_napi_enable(port
);
3017 ret
= ehea_restart_qps(dev
);
3020 netif_wake_queue(dev
);
3021 mutex_unlock(&port
->port_lock
);
3026 ehea_info("re-initializing driver complete");
3031 static void ehea_tx_watchdog(struct net_device
*dev
)
3033 struct ehea_port
*port
= netdev_priv(dev
);
3035 if (netif_carrier_ok(dev
) &&
3036 !test_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
))
3037 ehea_schedule_port_reset(port
);
3040 int ehea_sense_adapter_attr(struct ehea_adapter
*adapter
)
3042 struct hcp_query_ehea
*cb
;
3046 cb
= (void *)get_zeroed_page(GFP_KERNEL
);
3052 hret
= ehea_h_query_ehea(adapter
->handle
, cb
);
3054 if (hret
!= H_SUCCESS
) {
3059 adapter
->max_mc_mac
= cb
->max_mc_mac
- 1;
3063 free_page((unsigned long)cb
);
3068 int ehea_get_jumboframe_status(struct ehea_port
*port
, int *jumbo
)
3070 struct hcp_ehea_port_cb4
*cb4
;
3076 /* (Try to) enable *jumbo frames */
3077 cb4
= (void *)get_zeroed_page(GFP_KERNEL
);
3079 ehea_error("no mem for cb4");
3083 hret
= ehea_h_query_ehea_port(port
->adapter
->handle
,
3084 port
->logical_port_id
,
3086 H_PORT_CB4_JUMBO
, cb4
);
3087 if (hret
== H_SUCCESS
) {
3088 if (cb4
->jumbo_frame
)
3091 cb4
->jumbo_frame
= 1;
3092 hret
= ehea_h_modify_ehea_port(port
->adapter
->
3099 if (hret
== H_SUCCESS
)
3105 free_page((unsigned long)cb4
);
3111 static ssize_t
ehea_show_port_id(struct device
*dev
,
3112 struct device_attribute
*attr
, char *buf
)
3114 struct ehea_port
*port
= container_of(dev
, struct ehea_port
, ofdev
.dev
);
3115 return sprintf(buf
, "%d", port
->logical_port_id
);
3118 static DEVICE_ATTR(log_port_id
, S_IRUSR
| S_IRGRP
| S_IROTH
, ehea_show_port_id
,
3121 static void __devinit
logical_port_release(struct device
*dev
)
3123 struct ehea_port
*port
= container_of(dev
, struct ehea_port
, ofdev
.dev
);
3124 of_node_put(port
->ofdev
.dev
.of_node
);
3127 static struct device
*ehea_register_port(struct ehea_port
*port
,
3128 struct device_node
*dn
)
3132 port
->ofdev
.dev
.of_node
= of_node_get(dn
);
3133 port
->ofdev
.dev
.parent
= &port
->adapter
->ofdev
->dev
;
3134 port
->ofdev
.dev
.bus
= &ibmebus_bus_type
;
3136 dev_set_name(&port
->ofdev
.dev
, "port%d", port_name_cnt
++);
3137 port
->ofdev
.dev
.release
= logical_port_release
;
3139 ret
= of_device_register(&port
->ofdev
);
3141 ehea_error("failed to register device. ret=%d", ret
);
3145 ret
= device_create_file(&port
->ofdev
.dev
, &dev_attr_log_port_id
);
3147 ehea_error("failed to register attributes, ret=%d", ret
);
3148 goto out_unreg_of_dev
;
3151 return &port
->ofdev
.dev
;
3154 of_device_unregister(&port
->ofdev
);
3159 static void ehea_unregister_port(struct ehea_port
*port
)
3161 device_remove_file(&port
->ofdev
.dev
, &dev_attr_log_port_id
);
3162 of_device_unregister(&port
->ofdev
);
3165 static const struct net_device_ops ehea_netdev_ops
= {
3166 .ndo_open
= ehea_open
,
3167 .ndo_stop
= ehea_stop
,
3168 .ndo_start_xmit
= ehea_start_xmit
,
3169 #ifdef CONFIG_NET_POLL_CONTROLLER
3170 .ndo_poll_controller
= ehea_netpoll
,
3172 .ndo_get_stats
= ehea_get_stats
,
3173 .ndo_set_mac_address
= ehea_set_mac_addr
,
3174 .ndo_validate_addr
= eth_validate_addr
,
3175 .ndo_set_multicast_list
= ehea_set_multicast_list
,
3176 .ndo_change_mtu
= ehea_change_mtu
,
3177 .ndo_vlan_rx_register
= ehea_vlan_rx_register
,
3178 .ndo_vlan_rx_add_vid
= ehea_vlan_rx_add_vid
,
3179 .ndo_vlan_rx_kill_vid
= ehea_vlan_rx_kill_vid
,
3180 .ndo_tx_timeout
= ehea_tx_watchdog
,
3183 struct ehea_port
*ehea_setup_single_port(struct ehea_adapter
*adapter
,
3184 u32 logical_port_id
,
3185 struct device_node
*dn
)
3188 struct net_device
*dev
;
3189 struct ehea_port
*port
;
3190 struct device
*port_dev
;
3193 /* allocate memory for the port structures */
3194 dev
= alloc_etherdev(sizeof(struct ehea_port
));
3197 ehea_error("no mem for net_device");
3202 port
= netdev_priv(dev
);
3204 mutex_init(&port
->port_lock
);
3205 port
->state
= EHEA_PORT_DOWN
;
3206 port
->sig_comp_iv
= sq_entries
/ 10;
3208 port
->adapter
= adapter
;
3210 port
->logical_port_id
= logical_port_id
;
3212 port
->msg_enable
= netif_msg_init(msg_level
, EHEA_MSG_DEFAULT
);
3214 port
->mc_list
= kzalloc(sizeof(struct ehea_mc_list
), GFP_KERNEL
);
3215 if (!port
->mc_list
) {
3217 goto out_free_ethdev
;
3220 INIT_LIST_HEAD(&port
->mc_list
->list
);
3222 ret
= ehea_sense_port_attr(port
);
3224 goto out_free_mc_list
;
3226 port_dev
= ehea_register_port(port
, dn
);
3228 goto out_free_mc_list
;
3230 SET_NETDEV_DEV(dev
, port_dev
);
3232 /* initialize net_device structure */
3233 memcpy(dev
->dev_addr
, &port
->mac_addr
, ETH_ALEN
);
3235 dev
->netdev_ops
= &ehea_netdev_ops
;
3236 ehea_set_ethtool_ops(dev
);
3238 dev
->features
= NETIF_F_SG
| NETIF_F_FRAGLIST
| NETIF_F_TSO
3239 | NETIF_F_HIGHDMA
| NETIF_F_IP_CSUM
| NETIF_F_HW_VLAN_TX
3240 | NETIF_F_HW_VLAN_RX
| NETIF_F_HW_VLAN_FILTER
3242 dev
->watchdog_timeo
= EHEA_WATCH_DOG_TIMEOUT
;
3244 INIT_WORK(&port
->reset_task
, ehea_reset_port
);
3246 ret
= register_netdev(dev
);
3248 ehea_error("register_netdev failed. ret=%d", ret
);
3249 goto out_unreg_port
;
3252 port
->lro_max_aggr
= lro_max_aggr
;
3254 ret
= ehea_get_jumboframe_status(port
, &jumbo
);
3256 ehea_error("failed determining jumbo frame status for %s",
3257 port
->netdev
->name
);
3259 ehea_info("%s: Jumbo frames are %sabled", dev
->name
,
3260 jumbo
== 1 ? "en" : "dis");
3262 adapter
->active_ports
++;
3267 ehea_unregister_port(port
);
3270 kfree(port
->mc_list
);
3276 ehea_error("setting up logical port with id=%d failed, ret=%d",
3277 logical_port_id
, ret
);
3281 static void ehea_shutdown_single_port(struct ehea_port
*port
)
3283 struct ehea_adapter
*adapter
= port
->adapter
;
3284 unregister_netdev(port
->netdev
);
3285 ehea_unregister_port(port
);
3286 kfree(port
->mc_list
);
3287 free_netdev(port
->netdev
);
3288 adapter
->active_ports
--;
3291 static int ehea_setup_ports(struct ehea_adapter
*adapter
)
3293 struct device_node
*lhea_dn
;
3294 struct device_node
*eth_dn
= NULL
;
3296 const u32
*dn_log_port_id
;
3299 lhea_dn
= adapter
->ofdev
->dev
.of_node
;
3300 while ((eth_dn
= of_get_next_child(lhea_dn
, eth_dn
))) {
3302 dn_log_port_id
= of_get_property(eth_dn
, "ibm,hea-port-no",
3304 if (!dn_log_port_id
) {
3305 ehea_error("bad device node: eth_dn name=%s",
3310 if (ehea_add_adapter_mr(adapter
)) {
3311 ehea_error("creating MR failed");
3312 of_node_put(eth_dn
);
3316 adapter
->port
[i
] = ehea_setup_single_port(adapter
,
3319 if (adapter
->port
[i
])
3320 ehea_info("%s -> logical port id #%d",
3321 adapter
->port
[i
]->netdev
->name
,
3324 ehea_remove_adapter_mr(adapter
);
3331 static struct device_node
*ehea_get_eth_dn(struct ehea_adapter
*adapter
,
3332 u32 logical_port_id
)
3334 struct device_node
*lhea_dn
;
3335 struct device_node
*eth_dn
= NULL
;
3336 const u32
*dn_log_port_id
;
3338 lhea_dn
= adapter
->ofdev
->dev
.of_node
;
3339 while ((eth_dn
= of_get_next_child(lhea_dn
, eth_dn
))) {
3341 dn_log_port_id
= of_get_property(eth_dn
, "ibm,hea-port-no",
3344 if (*dn_log_port_id
== logical_port_id
)
3351 static ssize_t
ehea_probe_port(struct device
*dev
,
3352 struct device_attribute
*attr
,
3353 const char *buf
, size_t count
)
3355 struct ehea_adapter
*adapter
= dev_get_drvdata(dev
);
3356 struct ehea_port
*port
;
3357 struct device_node
*eth_dn
= NULL
;
3360 u32 logical_port_id
;
3362 sscanf(buf
, "%d", &logical_port_id
);
3364 port
= ehea_get_port(adapter
, logical_port_id
);
3367 ehea_info("adding port with logical port id=%d failed. port "
3368 "already configured as %s.", logical_port_id
,
3369 port
->netdev
->name
);
3373 eth_dn
= ehea_get_eth_dn(adapter
, logical_port_id
);
3376 ehea_info("no logical port with id %d found", logical_port_id
);
3380 if (ehea_add_adapter_mr(adapter
)) {
3381 ehea_error("creating MR failed");
3385 port
= ehea_setup_single_port(adapter
, logical_port_id
, eth_dn
);
3387 of_node_put(eth_dn
);
3390 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++)
3391 if (!adapter
->port
[i
]) {
3392 adapter
->port
[i
] = port
;
3396 ehea_info("added %s (logical port id=%d)", port
->netdev
->name
,
3399 ehea_remove_adapter_mr(adapter
);
3403 return (ssize_t
) count
;
3406 static ssize_t
ehea_remove_port(struct device
*dev
,
3407 struct device_attribute
*attr
,
3408 const char *buf
, size_t count
)
3410 struct ehea_adapter
*adapter
= dev_get_drvdata(dev
);
3411 struct ehea_port
*port
;
3413 u32 logical_port_id
;
3415 sscanf(buf
, "%d", &logical_port_id
);
3417 port
= ehea_get_port(adapter
, logical_port_id
);
3420 ehea_info("removed %s (logical port id=%d)", port
->netdev
->name
,
3423 ehea_shutdown_single_port(port
);
3425 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++)
3426 if (adapter
->port
[i
] == port
) {
3427 adapter
->port
[i
] = NULL
;
3431 ehea_error("removing port with logical port id=%d failed. port "
3432 "not configured.", logical_port_id
);
3436 ehea_remove_adapter_mr(adapter
);
3438 return (ssize_t
) count
;
3441 static DEVICE_ATTR(probe_port
, S_IWUSR
, NULL
, ehea_probe_port
);
3442 static DEVICE_ATTR(remove_port
, S_IWUSR
, NULL
, ehea_remove_port
);
3444 int ehea_create_device_sysfs(struct platform_device
*dev
)
3446 int ret
= device_create_file(&dev
->dev
, &dev_attr_probe_port
);
3450 ret
= device_create_file(&dev
->dev
, &dev_attr_remove_port
);
3455 void ehea_remove_device_sysfs(struct platform_device
*dev
)
3457 device_remove_file(&dev
->dev
, &dev_attr_probe_port
);
3458 device_remove_file(&dev
->dev
, &dev_attr_remove_port
);
3461 static int __devinit
ehea_probe_adapter(struct platform_device
*dev
,
3462 const struct of_device_id
*id
)
3464 struct ehea_adapter
*adapter
;
3465 const u64
*adapter_handle
;
3468 if (!dev
|| !dev
->dev
.of_node
) {
3469 ehea_error("Invalid ibmebus device probed");
3473 adapter
= kzalloc(sizeof(*adapter
), GFP_KERNEL
);
3476 dev_err(&dev
->dev
, "no mem for ehea_adapter\n");
3480 list_add(&adapter
->list
, &adapter_list
);
3482 adapter
->ofdev
= dev
;
3484 adapter_handle
= of_get_property(dev
->dev
.of_node
, "ibm,hea-handle",
3487 adapter
->handle
= *adapter_handle
;
3489 if (!adapter
->handle
) {
3490 dev_err(&dev
->dev
, "failed getting handle for adapter"
3491 " '%s'\n", dev
->dev
.of_node
->full_name
);
3496 adapter
->pd
= EHEA_PD_ID
;
3498 dev_set_drvdata(&dev
->dev
, adapter
);
3501 /* initialize adapter and ports */
3502 /* get adapter properties */
3503 ret
= ehea_sense_adapter_attr(adapter
);
3505 dev_err(&dev
->dev
, "sense_adapter_attr failed: %d\n", ret
);
3509 adapter
->neq
= ehea_create_eq(adapter
,
3510 EHEA_NEQ
, EHEA_MAX_ENTRIES_EQ
, 1);
3511 if (!adapter
->neq
) {
3513 dev_err(&dev
->dev
, "NEQ creation failed\n");
3517 tasklet_init(&adapter
->neq_tasklet
, ehea_neq_tasklet
,
3518 (unsigned long)adapter
);
3520 ret
= ibmebus_request_irq(adapter
->neq
->attr
.ist1
,
3521 ehea_interrupt_neq
, IRQF_DISABLED
,
3522 "ehea_neq", adapter
);
3524 dev_err(&dev
->dev
, "requesting NEQ IRQ failed\n");
3528 ret
= ehea_create_device_sysfs(dev
);
3532 ret
= ehea_setup_ports(adapter
);
3534 dev_err(&dev
->dev
, "setup_ports failed\n");
3535 goto out_rem_dev_sysfs
;
3542 ehea_remove_device_sysfs(dev
);
3545 ibmebus_free_irq(adapter
->neq
->attr
.ist1
, adapter
);
3548 ehea_destroy_eq(adapter
->neq
);
3551 list_del(&adapter
->list
);
3555 ehea_update_firmware_handles();
3560 static int __devexit
ehea_remove(struct platform_device
*dev
)
3562 struct ehea_adapter
*adapter
= dev_get_drvdata(&dev
->dev
);
3565 for (i
= 0; i
< EHEA_MAX_PORTS
; i
++)
3566 if (adapter
->port
[i
]) {
3567 ehea_shutdown_single_port(adapter
->port
[i
]);
3568 adapter
->port
[i
] = NULL
;
3571 ehea_remove_device_sysfs(dev
);
3573 flush_scheduled_work();
3575 ibmebus_free_irq(adapter
->neq
->attr
.ist1
, adapter
);
3576 tasklet_kill(&adapter
->neq_tasklet
);
3578 ehea_destroy_eq(adapter
->neq
);
3579 ehea_remove_adapter_mr(adapter
);
3580 list_del(&adapter
->list
);
3583 ehea_update_firmware_handles();
3588 void ehea_crash_handler(void)
3592 if (ehea_fw_handles
.arr
)
3593 for (i
= 0; i
< ehea_fw_handles
.num_entries
; i
++)
3594 ehea_h_free_resource(ehea_fw_handles
.arr
[i
].adh
,
3595 ehea_fw_handles
.arr
[i
].fwh
,
3598 if (ehea_bcmc_regs
.arr
)
3599 for (i
= 0; i
< ehea_bcmc_regs
.num_entries
; i
++)
3600 ehea_h_reg_dereg_bcmc(ehea_bcmc_regs
.arr
[i
].adh
,
3601 ehea_bcmc_regs
.arr
[i
].port_id
,
3602 ehea_bcmc_regs
.arr
[i
].reg_type
,
3603 ehea_bcmc_regs
.arr
[i
].macaddr
,
3607 static int ehea_mem_notifier(struct notifier_block
*nb
,
3608 unsigned long action
, void *data
)
3610 int ret
= NOTIFY_BAD
;
3611 struct memory_notify
*arg
= data
;
3613 mutex_lock(&dlpar_mem_lock
);
3616 case MEM_CANCEL_OFFLINE
:
3617 ehea_info("memory offlining canceled");
3618 /* Readd canceled memory block */
3620 ehea_info("memory is going online");
3621 set_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
);
3622 if (ehea_add_sect_bmap(arg
->start_pfn
, arg
->nr_pages
))
3624 ehea_rereg_mrs(NULL
);
3626 case MEM_GOING_OFFLINE
:
3627 ehea_info("memory is going offline");
3628 set_bit(__EHEA_STOP_XFER
, &ehea_driver_flags
);
3629 if (ehea_rem_sect_bmap(arg
->start_pfn
, arg
->nr_pages
))
3631 ehea_rereg_mrs(NULL
);
3637 ehea_update_firmware_handles();
3641 mutex_unlock(&dlpar_mem_lock
);
3645 static struct notifier_block ehea_mem_nb
= {
3646 .notifier_call
= ehea_mem_notifier
,
3649 static int ehea_reboot_notifier(struct notifier_block
*nb
,
3650 unsigned long action
, void *unused
)
3652 if (action
== SYS_RESTART
) {
3653 ehea_info("Reboot: freeing all eHEA resources");
3654 ibmebus_unregister_driver(&ehea_driver
);
3659 static struct notifier_block ehea_reboot_nb
= {
3660 .notifier_call
= ehea_reboot_notifier
,
3663 static int check_module_parm(void)
3667 if ((rq1_entries
< EHEA_MIN_ENTRIES_QP
) ||
3668 (rq1_entries
> EHEA_MAX_ENTRIES_RQ1
)) {
3669 ehea_info("Bad parameter: rq1_entries");
3672 if ((rq2_entries
< EHEA_MIN_ENTRIES_QP
) ||
3673 (rq2_entries
> EHEA_MAX_ENTRIES_RQ2
)) {
3674 ehea_info("Bad parameter: rq2_entries");
3677 if ((rq3_entries
< EHEA_MIN_ENTRIES_QP
) ||
3678 (rq3_entries
> EHEA_MAX_ENTRIES_RQ3
)) {
3679 ehea_info("Bad parameter: rq3_entries");
3682 if ((sq_entries
< EHEA_MIN_ENTRIES_QP
) ||
3683 (sq_entries
> EHEA_MAX_ENTRIES_SQ
)) {
3684 ehea_info("Bad parameter: sq_entries");
3691 static ssize_t
ehea_show_capabilities(struct device_driver
*drv
,
3694 return sprintf(buf
, "%d", EHEA_CAPABILITIES
);
3697 static DRIVER_ATTR(capabilities
, S_IRUSR
| S_IRGRP
| S_IROTH
,
3698 ehea_show_capabilities
, NULL
);
3700 int __init
ehea_module_init(void)
3704 printk(KERN_INFO
"IBM eHEA ethernet device driver (Release %s)\n",
3708 INIT_WORK(&ehea_rereg_mr_task
, ehea_rereg_mrs
);
3709 memset(&ehea_fw_handles
, 0, sizeof(ehea_fw_handles
));
3710 memset(&ehea_bcmc_regs
, 0, sizeof(ehea_bcmc_regs
));
3712 mutex_init(&ehea_fw_handles
.lock
);
3713 spin_lock_init(&ehea_bcmc_regs
.lock
);
3715 ret
= check_module_parm();
3719 ret
= ehea_create_busmap();
3723 ret
= register_reboot_notifier(&ehea_reboot_nb
);
3725 ehea_info("failed registering reboot notifier");
3727 ret
= register_memory_notifier(&ehea_mem_nb
);
3729 ehea_info("failed registering memory remove notifier");
3731 ret
= crash_shutdown_register(ehea_crash_handler
);
3733 ehea_info("failed registering crash handler");
3735 ret
= ibmebus_register_driver(&ehea_driver
);
3737 ehea_error("failed registering eHEA device driver on ebus");
3741 ret
= driver_create_file(&ehea_driver
.driver
,
3742 &driver_attr_capabilities
);
3744 ehea_error("failed to register capabilities attribute, ret=%d",
3752 ibmebus_unregister_driver(&ehea_driver
);
3754 unregister_memory_notifier(&ehea_mem_nb
);
3755 unregister_reboot_notifier(&ehea_reboot_nb
);
3756 crash_shutdown_unregister(ehea_crash_handler
);
3761 static void __exit
ehea_module_exit(void)
3765 flush_scheduled_work();
3766 driver_remove_file(&ehea_driver
.driver
, &driver_attr_capabilities
);
3767 ibmebus_unregister_driver(&ehea_driver
);
3768 unregister_reboot_notifier(&ehea_reboot_nb
);
3769 ret
= crash_shutdown_unregister(ehea_crash_handler
);
3771 ehea_info("failed unregistering crash handler");
3772 unregister_memory_notifier(&ehea_mem_nb
);
3773 kfree(ehea_fw_handles
.arr
);
3774 kfree(ehea_bcmc_regs
.arr
);
3775 ehea_destroy_busmap();
3778 module_init(ehea_module_init
);
3779 module_exit(ehea_module_exit
);