1 /* bnx2fc_fcoe.c: Broadcom NetXtreme II Linux FCoE offload driver.
2 * This file contains the code that interacts with libfc, libfcoe,
3 * cnic modules to create FCoE instances, send/receive non-offloaded
4 * FIP/FCoE packets, listen to link events etc.
6 * Copyright (c) 2008 - 2013 Broadcom Corporation
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation.
12 * Written by: Bhanu Prakash Gollapudi (bprakash@broadcom.com)
17 static struct list_head adapter_list
;
18 static struct list_head if_list
;
19 static u32 adapter_count
;
20 static DEFINE_MUTEX(bnx2fc_dev_lock
);
21 DEFINE_PER_CPU(struct bnx2fc_percpu_s
, bnx2fc_percpu
);
23 #define DRV_MODULE_NAME "bnx2fc"
24 #define DRV_MODULE_VERSION BNX2FC_VERSION
25 #define DRV_MODULE_RELDATE "Sep 17, 2013"
28 static char version
[] =
29 "Broadcom NetXtreme II FCoE Driver " DRV_MODULE_NAME \
30 " v" DRV_MODULE_VERSION
" (" DRV_MODULE_RELDATE
")\n";
33 MODULE_AUTHOR("Bhanu Prakash Gollapudi <bprakash@broadcom.com>");
34 MODULE_DESCRIPTION("Broadcom NetXtreme II BCM57710 FCoE Driver");
35 MODULE_LICENSE("GPL");
36 MODULE_VERSION(DRV_MODULE_VERSION
);
38 #define BNX2FC_MAX_QUEUE_DEPTH 256
39 #define BNX2FC_MIN_QUEUE_DEPTH 32
40 #define FCOE_WORD_TO_BYTE 4
42 static struct scsi_transport_template
*bnx2fc_transport_template
;
43 static struct scsi_transport_template
*bnx2fc_vport_xport_template
;
45 struct workqueue_struct
*bnx2fc_wq
;
47 /* bnx2fc structure needs only one instance of the fcoe_percpu_s structure.
48 * Here the io threads are per cpu but the l2 thread is just one
50 struct fcoe_percpu_s bnx2fc_global
;
51 DEFINE_SPINLOCK(bnx2fc_global_lock
);
53 static struct cnic_ulp_ops bnx2fc_cnic_cb
;
54 static struct libfc_function_template bnx2fc_libfc_fcn_templ
;
55 static struct scsi_host_template bnx2fc_shost_template
;
56 static struct fc_function_template bnx2fc_transport_function
;
57 static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ
;
58 static struct fc_function_template bnx2fc_vport_xport_function
;
59 static int bnx2fc_create(struct net_device
*netdev
, enum fip_state fip_mode
);
60 static void __bnx2fc_destroy(struct bnx2fc_interface
*interface
);
61 static int bnx2fc_destroy(struct net_device
*net_device
);
62 static int bnx2fc_enable(struct net_device
*netdev
);
63 static int bnx2fc_disable(struct net_device
*netdev
);
65 /* fcoe_syfs control interface handlers */
66 static int bnx2fc_ctlr_alloc(struct net_device
*netdev
);
67 static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device
*cdev
);
69 static void bnx2fc_recv_frame(struct sk_buff
*skb
);
71 static void bnx2fc_start_disc(struct bnx2fc_interface
*interface
);
72 static int bnx2fc_shost_config(struct fc_lport
*lport
, struct device
*dev
);
73 static int bnx2fc_lport_config(struct fc_lport
*lport
);
74 static int bnx2fc_em_config(struct fc_lport
*lport
, struct bnx2fc_hba
*hba
);
75 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba
*hba
);
76 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba
*hba
);
77 static int bnx2fc_bind_pcidev(struct bnx2fc_hba
*hba
);
78 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba
*hba
);
79 static struct fc_lport
*bnx2fc_if_create(struct bnx2fc_interface
*interface
,
80 struct device
*parent
, int npiv
);
81 static void bnx2fc_destroy_work(struct work_struct
*work
);
83 static struct bnx2fc_hba
*bnx2fc_hba_lookup(struct net_device
*phys_dev
);
84 static struct bnx2fc_interface
*bnx2fc_interface_lookup(struct net_device
86 static inline void bnx2fc_interface_put(struct bnx2fc_interface
*interface
);
87 static struct bnx2fc_hba
*bnx2fc_find_hba_for_cnic(struct cnic_dev
*cnic
);
89 static int bnx2fc_fw_init(struct bnx2fc_hba
*hba
);
90 static void bnx2fc_fw_destroy(struct bnx2fc_hba
*hba
);
92 static void bnx2fc_port_shutdown(struct fc_lport
*lport
);
93 static void bnx2fc_stop(struct bnx2fc_interface
*interface
);
94 static int __init
bnx2fc_mod_init(void);
95 static void __exit
bnx2fc_mod_exit(void);
97 unsigned int bnx2fc_debug_level
;
98 module_param_named(debug_logging
, bnx2fc_debug_level
, int, S_IRUGO
|S_IWUSR
);
100 static int bnx2fc_cpu_callback(struct notifier_block
*nfb
,
101 unsigned long action
, void *hcpu
);
102 /* notification function for CPU hotplug events */
103 static struct notifier_block bnx2fc_cpu_notifier
= {
104 .notifier_call
= bnx2fc_cpu_callback
,
107 static inline struct net_device
*bnx2fc_netdev(const struct fc_lport
*lport
)
109 return ((struct bnx2fc_interface
*)
110 ((struct fcoe_port
*)lport_priv(lport
))->priv
)->netdev
;
113 static void bnx2fc_fcf_get_vlan_id(struct fcoe_fcf_device
*fcf_dev
)
115 struct fcoe_ctlr_device
*ctlr_dev
=
116 fcoe_fcf_dev_to_ctlr_dev(fcf_dev
);
117 struct fcoe_ctlr
*ctlr
= fcoe_ctlr_device_priv(ctlr_dev
);
118 struct bnx2fc_interface
*fcoe
= fcoe_ctlr_priv(ctlr
);
120 fcf_dev
->vlan_id
= fcoe
->vlan_id
;
123 static void bnx2fc_clean_rx_queue(struct fc_lport
*lp
)
125 struct fcoe_percpu_s
*bg
;
126 struct fcoe_rcv_info
*fr
;
127 struct sk_buff_head
*list
;
128 struct sk_buff
*skb
, *next
;
129 struct sk_buff
*head
;
132 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
133 list
= &bg
->fcoe_rx_list
;
135 for (skb
= head
; skb
!= (struct sk_buff
*)list
;
138 fr
= fcoe_dev_from_skb(skb
);
139 if (fr
->fr_dev
== lp
) {
140 __skb_unlink(skb
, list
);
144 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
147 int bnx2fc_get_paged_crc_eof(struct sk_buff
*skb
, int tlen
)
150 spin_lock(&bnx2fc_global_lock
);
151 rc
= fcoe_get_paged_crc_eof(skb
, tlen
, &bnx2fc_global
);
152 spin_unlock(&bnx2fc_global_lock
);
157 static void bnx2fc_abort_io(struct fc_lport
*lport
)
160 * This function is no-op for bnx2fc, but we do
161 * not want to leave it as NULL either, as libfc
162 * can call the default function which is
167 static void bnx2fc_cleanup(struct fc_lport
*lport
)
169 struct fcoe_port
*port
= lport_priv(lport
);
170 struct bnx2fc_interface
*interface
= port
->priv
;
171 struct bnx2fc_hba
*hba
= interface
->hba
;
172 struct bnx2fc_rport
*tgt
;
175 BNX2FC_MISC_DBG("Entered %s\n", __func__
);
176 mutex_lock(&hba
->hba_mutex
);
177 spin_lock_bh(&hba
->hba_lock
);
178 for (i
= 0; i
< BNX2FC_NUM_MAX_SESS
; i
++) {
179 tgt
= hba
->tgt_ofld_list
[i
];
181 /* Cleanup IOs belonging to requested vport */
182 if (tgt
->port
== port
) {
183 spin_unlock_bh(&hba
->hba_lock
);
184 BNX2FC_TGT_DBG(tgt
, "flush/cleanup\n");
185 bnx2fc_flush_active_ios(tgt
);
186 spin_lock_bh(&hba
->hba_lock
);
190 spin_unlock_bh(&hba
->hba_lock
);
191 mutex_unlock(&hba
->hba_mutex
);
194 static int bnx2fc_xmit_l2_frame(struct bnx2fc_rport
*tgt
,
197 struct fc_rport_priv
*rdata
= tgt
->rdata
;
198 struct fc_frame_header
*fh
;
201 fh
= fc_frame_header_get(fp
);
202 BNX2FC_TGT_DBG(tgt
, "Xmit L2 frame rport = 0x%x, oxid = 0x%x, "
203 "r_ctl = 0x%x\n", rdata
->ids
.port_id
,
204 ntohs(fh
->fh_ox_id
), fh
->fh_r_ctl
);
205 if ((fh
->fh_type
== FC_TYPE_ELS
) &&
206 (fh
->fh_r_ctl
== FC_RCTL_ELS_REQ
)) {
208 switch (fc_frame_payload_op(fp
)) {
210 rc
= bnx2fc_send_adisc(tgt
, fp
);
213 rc
= bnx2fc_send_logo(tgt
, fp
);
216 rc
= bnx2fc_send_rls(tgt
, fp
);
221 } else if ((fh
->fh_type
== FC_TYPE_BLS
) &&
222 (fh
->fh_r_ctl
== FC_RCTL_BA_ABTS
))
223 BNX2FC_TGT_DBG(tgt
, "ABTS frame\n");
225 BNX2FC_TGT_DBG(tgt
, "Send L2 frame type 0x%x "
226 "rctl 0x%x thru non-offload path\n",
227 fh
->fh_type
, fh
->fh_r_ctl
);
237 * bnx2fc_xmit - bnx2fc's FCoE frame transmit function
239 * @lport: the associated local port
240 * @fp: the fc_frame to be transmitted
242 static int bnx2fc_xmit(struct fc_lport
*lport
, struct fc_frame
*fp
)
245 struct fcoe_crc_eof
*cp
;
247 struct fc_frame_header
*fh
;
248 struct bnx2fc_interface
*interface
;
249 struct fcoe_ctlr
*ctlr
;
250 struct bnx2fc_hba
*hba
;
251 struct fcoe_port
*port
;
253 struct bnx2fc_rport
*tgt
;
254 struct fc_stats
*stats
;
257 unsigned int hlen
, tlen
, elen
;
260 port
= (struct fcoe_port
*)lport_priv(lport
);
261 interface
= port
->priv
;
262 ctlr
= bnx2fc_to_ctlr(interface
);
263 hba
= interface
->hba
;
265 fh
= fc_frame_header_get(fp
);
268 if (!lport
->link_up
) {
269 BNX2FC_HBA_DBG(lport
, "bnx2fc_xmit link down\n");
274 if (unlikely(fh
->fh_r_ctl
== FC_RCTL_ELS_REQ
)) {
275 if (!ctlr
->sel_fcf
) {
276 BNX2FC_HBA_DBG(lport
, "FCF not selected yet!\n");
280 if (fcoe_ctlr_els_send(ctlr
, lport
, skb
))
288 * Snoop the frame header to check if the frame is for
289 * an offloaded session
292 * tgt_ofld_list access is synchronized using
293 * both hba mutex and hba lock. Atleast hba mutex or
294 * hba lock needs to be held for read access.
297 spin_lock_bh(&hba
->hba_lock
);
298 tgt
= bnx2fc_tgt_lookup(port
, ntoh24(fh
->fh_d_id
));
299 if (tgt
&& (test_bit(BNX2FC_FLAG_SESSION_READY
, &tgt
->flags
))) {
300 /* This frame is for offloaded session */
301 BNX2FC_HBA_DBG(lport
, "xmit: Frame is for offloaded session "
302 "port_id = 0x%x\n", ntoh24(fh
->fh_d_id
));
303 spin_unlock_bh(&hba
->hba_lock
);
304 rc
= bnx2fc_xmit_l2_frame(tgt
, fp
);
310 spin_unlock_bh(&hba
->hba_lock
);
313 elen
= sizeof(struct ethhdr
);
314 hlen
= sizeof(struct fcoe_hdr
);
315 tlen
= sizeof(struct fcoe_crc_eof
);
316 wlen
= (skb
->len
- tlen
+ sizeof(crc
)) / FCOE_WORD_TO_BYTE
;
318 skb
->ip_summed
= CHECKSUM_NONE
;
319 crc
= fcoe_fc_crc(fp
);
321 /* copy port crc and eof to the skb buff */
322 if (skb_is_nonlinear(skb
)) {
324 if (bnx2fc_get_paged_crc_eof(skb
, tlen
)) {
328 frag
= &skb_shinfo(skb
)->frags
[skb_shinfo(skb
)->nr_frags
- 1];
329 cp
= kmap_atomic(skb_frag_page(frag
)) + frag
->page_offset
;
331 cp
= (struct fcoe_crc_eof
*)skb_put(skb
, tlen
);
334 memset(cp
, 0, sizeof(*cp
));
336 cp
->fcoe_crc32
= cpu_to_le32(~crc
);
337 if (skb_is_nonlinear(skb
)) {
342 /* adjust skb network/transport offsets to match mac/fcoe/port */
343 skb_push(skb
, elen
+ hlen
);
344 skb_reset_mac_header(skb
);
345 skb_reset_network_header(skb
);
347 skb
->protocol
= htons(ETH_P_FCOE
);
348 skb
->dev
= interface
->netdev
;
350 /* fill up mac and fcoe headers */
352 eh
->h_proto
= htons(ETH_P_FCOE
);
354 fc_fcoe_set_mac(eh
->h_dest
, fh
->fh_d_id
);
356 /* insert GW address */
357 memcpy(eh
->h_dest
, ctlr
->dest_addr
, ETH_ALEN
);
359 if (unlikely(ctlr
->flogi_oxid
!= FC_XID_UNKNOWN
))
360 memcpy(eh
->h_source
, ctlr
->ctl_src_addr
, ETH_ALEN
);
362 memcpy(eh
->h_source
, port
->data_src_addr
, ETH_ALEN
);
364 hp
= (struct fcoe_hdr
*)(eh
+ 1);
365 memset(hp
, 0, sizeof(*hp
));
367 FC_FCOE_ENCAPS_VER(hp
, FC_FCOE_VER
);
370 /* fcoe lso, mss is in max_payload which is non-zero for FCP data */
371 if (lport
->seq_offload
&& fr_max_payload(fp
)) {
372 skb_shinfo(skb
)->gso_type
= SKB_GSO_FCOE
;
373 skb_shinfo(skb
)->gso_size
= fr_max_payload(fp
);
375 skb_shinfo(skb
)->gso_type
= 0;
376 skb_shinfo(skb
)->gso_size
= 0;
380 stats
= per_cpu_ptr(lport
->stats
, get_cpu());
382 stats
->TxWords
+= wlen
;
385 /* send down to lld */
387 if (port
->fcoe_pending_queue
.qlen
)
388 fcoe_check_wait_queue(lport
, skb
);
389 else if (fcoe_start_io(skb
))
390 fcoe_check_wait_queue(lport
, skb
);
396 * bnx2fc_rcv - This is bnx2fc's receive function called by NET_RX_SOFTIRQ
398 * @skb: the receive socket buffer
399 * @dev: associated net device
401 * @olddev: last device
403 * This function receives the packet and builds FC frame and passes it up
405 static int bnx2fc_rcv(struct sk_buff
*skb
, struct net_device
*dev
,
406 struct packet_type
*ptype
, struct net_device
*olddev
)
408 struct fc_lport
*lport
;
409 struct bnx2fc_interface
*interface
;
410 struct fcoe_ctlr
*ctlr
;
411 struct fc_frame_header
*fh
;
412 struct fcoe_rcv_info
*fr
;
413 struct fcoe_percpu_s
*bg
;
416 interface
= container_of(ptype
, struct bnx2fc_interface
,
418 ctlr
= bnx2fc_to_ctlr(interface
);
421 if (unlikely(lport
== NULL
)) {
422 printk(KERN_ERR PFX
"bnx2fc_rcv: lport is NULL\n");
426 if (unlikely(eth_hdr(skb
)->h_proto
!= htons(ETH_P_FCOE
))) {
427 printk(KERN_ERR PFX
"bnx2fc_rcv: Wrong FC type frame\n");
432 * Check for minimum frame length, and make sure required FCoE
433 * and FC headers are pulled into the linear data area.
435 if (unlikely((skb
->len
< FCOE_MIN_FRAME
) ||
436 !pskb_may_pull(skb
, FCOE_HEADER_LEN
)))
439 skb_set_transport_header(skb
, sizeof(struct fcoe_hdr
));
440 fh
= (struct fc_frame_header
*) skb_transport_header(skb
);
442 oxid
= ntohs(fh
->fh_ox_id
);
444 fr
= fcoe_dev_from_skb(skb
);
448 spin_lock(&bg
->fcoe_rx_list
.lock
);
450 __skb_queue_tail(&bg
->fcoe_rx_list
, skb
);
451 if (bg
->fcoe_rx_list
.qlen
== 1)
452 wake_up_process(bg
->thread
);
454 spin_unlock(&bg
->fcoe_rx_list
.lock
);
462 static int bnx2fc_l2_rcv_thread(void *arg
)
464 struct fcoe_percpu_s
*bg
= arg
;
467 set_user_nice(current
, -20);
468 set_current_state(TASK_INTERRUPTIBLE
);
469 while (!kthread_should_stop()) {
471 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
472 while ((skb
= __skb_dequeue(&bg
->fcoe_rx_list
)) != NULL
) {
473 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
474 bnx2fc_recv_frame(skb
);
475 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
477 __set_current_state(TASK_INTERRUPTIBLE
);
478 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
480 __set_current_state(TASK_RUNNING
);
485 static void bnx2fc_recv_frame(struct sk_buff
*skb
)
488 struct fc_lport
*lport
;
489 struct fcoe_rcv_info
*fr
;
490 struct fc_stats
*stats
;
491 struct fc_frame_header
*fh
;
492 struct fcoe_crc_eof crc_eof
;
494 struct fc_lport
*vn_port
;
495 struct fcoe_port
*port
;
500 fr
= fcoe_dev_from_skb(skb
);
502 if (unlikely(lport
== NULL
)) {
503 printk(KERN_ERR PFX
"Invalid lport struct\n");
508 if (skb_is_nonlinear(skb
))
510 mac
= eth_hdr(skb
)->h_source
;
511 dest_mac
= eth_hdr(skb
)->h_dest
;
513 /* Pull the header */
514 hp
= (struct fcoe_hdr
*) skb_network_header(skb
);
515 fh
= (struct fc_frame_header
*) skb_transport_header(skb
);
516 skb_pull(skb
, sizeof(struct fcoe_hdr
));
517 fr_len
= skb
->len
- sizeof(struct fcoe_crc_eof
);
519 stats
= per_cpu_ptr(lport
->stats
, get_cpu());
521 stats
->RxWords
+= fr_len
/ FCOE_WORD_TO_BYTE
;
523 fp
= (struct fc_frame
*)skb
;
526 fr_sof(fp
) = hp
->fcoe_sof
;
527 if (skb_copy_bits(skb
, fr_len
, &crc_eof
, sizeof(crc_eof
))) {
532 fr_eof(fp
) = crc_eof
.fcoe_eof
;
533 fr_crc(fp
) = crc_eof
.fcoe_crc32
;
534 if (pskb_trim(skb
, fr_len
)) {
540 fh
= fc_frame_header_get(fp
);
542 vn_port
= fc_vport_id_lookup(lport
, ntoh24(fh
->fh_d_id
));
544 port
= lport_priv(vn_port
);
545 if (!ether_addr_equal(port
->data_src_addr
, dest_mac
)) {
546 BNX2FC_HBA_DBG(lport
, "fpma mismatch\n");
552 if (fh
->fh_r_ctl
== FC_RCTL_DD_SOL_DATA
&&
553 fh
->fh_type
== FC_TYPE_FCP
) {
554 /* Drop FCP data. We dont this in L2 path */
559 if (fh
->fh_r_ctl
== FC_RCTL_ELS_REQ
&&
560 fh
->fh_type
== FC_TYPE_ELS
) {
561 switch (fc_frame_payload_op(fp
)) {
563 if (ntoh24(fh
->fh_s_id
) == FC_FID_FLOGI
) {
564 /* drop non-FIP LOGO */
573 if (fh
->fh_r_ctl
== FC_RCTL_BA_ABTS
) {
574 /* Drop incoming ABTS */
580 if (le32_to_cpu(fr_crc(fp
)) !=
581 ~crc32(~0, skb
->data
, fr_len
)) {
582 if (stats
->InvalidCRCCount
< 5)
583 printk(KERN_WARNING PFX
"dropping frame with "
585 stats
->InvalidCRCCount
++;
591 fc_exch_recv(lport
, fp
);
595 * bnx2fc_percpu_io_thread - thread per cpu for ios
597 * @arg: ptr to bnx2fc_percpu_info structure
599 int bnx2fc_percpu_io_thread(void *arg
)
601 struct bnx2fc_percpu_s
*p
= arg
;
602 struct bnx2fc_work
*work
, *tmp
;
603 LIST_HEAD(work_list
);
605 set_user_nice(current
, -20);
606 set_current_state(TASK_INTERRUPTIBLE
);
607 while (!kthread_should_stop()) {
609 spin_lock_bh(&p
->fp_work_lock
);
610 while (!list_empty(&p
->work_list
)) {
611 list_splice_init(&p
->work_list
, &work_list
);
612 spin_unlock_bh(&p
->fp_work_lock
);
614 list_for_each_entry_safe(work
, tmp
, &work_list
, list
) {
615 list_del_init(&work
->list
);
616 bnx2fc_process_cq_compl(work
->tgt
, work
->wqe
);
620 spin_lock_bh(&p
->fp_work_lock
);
622 __set_current_state(TASK_INTERRUPTIBLE
);
623 spin_unlock_bh(&p
->fp_work_lock
);
625 __set_current_state(TASK_RUNNING
);
630 static struct fc_host_statistics
*bnx2fc_get_host_stats(struct Scsi_Host
*shost
)
632 struct fc_host_statistics
*bnx2fc_stats
;
633 struct fc_lport
*lport
= shost_priv(shost
);
634 struct fcoe_port
*port
= lport_priv(lport
);
635 struct bnx2fc_interface
*interface
= port
->priv
;
636 struct bnx2fc_hba
*hba
= interface
->hba
;
637 struct fcoe_statistics_params
*fw_stats
;
640 fw_stats
= (struct fcoe_statistics_params
*)hba
->stats_buffer
;
644 bnx2fc_stats
= fc_get_host_stats(shost
);
646 init_completion(&hba
->stat_req_done
);
647 if (bnx2fc_send_stat_req(hba
))
649 rc
= wait_for_completion_timeout(&hba
->stat_req_done
, (2 * HZ
));
651 BNX2FC_HBA_DBG(lport
, "FW stat req timed out\n");
654 BNX2FC_STATS(hba
, rx_stat2
, fc_crc_cnt
);
655 bnx2fc_stats
->invalid_crc_count
+= hba
->bfw_stats
.fc_crc_cnt
;
656 BNX2FC_STATS(hba
, tx_stat
, fcoe_tx_pkt_cnt
);
657 bnx2fc_stats
->tx_frames
+= hba
->bfw_stats
.fcoe_tx_pkt_cnt
;
658 BNX2FC_STATS(hba
, tx_stat
, fcoe_tx_byte_cnt
);
659 bnx2fc_stats
->tx_words
+= ((hba
->bfw_stats
.fcoe_tx_byte_cnt
) / 4);
660 BNX2FC_STATS(hba
, rx_stat0
, fcoe_rx_pkt_cnt
);
661 bnx2fc_stats
->rx_frames
+= hba
->bfw_stats
.fcoe_rx_pkt_cnt
;
662 BNX2FC_STATS(hba
, rx_stat0
, fcoe_rx_byte_cnt
);
663 bnx2fc_stats
->rx_words
+= ((hba
->bfw_stats
.fcoe_rx_byte_cnt
) / 4);
665 bnx2fc_stats
->dumped_frames
= 0;
666 bnx2fc_stats
->lip_count
= 0;
667 bnx2fc_stats
->nos_count
= 0;
668 bnx2fc_stats
->loss_of_sync_count
= 0;
669 bnx2fc_stats
->loss_of_signal_count
= 0;
670 bnx2fc_stats
->prim_seq_protocol_err_count
= 0;
672 memcpy(&hba
->prev_stats
, hba
->stats_buffer
,
673 sizeof(struct fcoe_statistics_params
));
677 static int bnx2fc_shost_config(struct fc_lport
*lport
, struct device
*dev
)
679 struct fcoe_port
*port
= lport_priv(lport
);
680 struct bnx2fc_interface
*interface
= port
->priv
;
681 struct bnx2fc_hba
*hba
= interface
->hba
;
682 struct Scsi_Host
*shost
= lport
->host
;
685 shost
->max_cmd_len
= BNX2FC_MAX_CMD_LEN
;
686 shost
->max_lun
= BNX2FC_MAX_LUN
;
687 shost
->max_id
= BNX2FC_MAX_FCP_TGT
;
688 shost
->max_channel
= 0;
690 shost
->transportt
= bnx2fc_vport_xport_template
;
692 shost
->transportt
= bnx2fc_transport_template
;
694 /* Add the new host to SCSI-ml */
695 rc
= scsi_add_host(lport
->host
, dev
);
697 printk(KERN_ERR PFX
"Error on scsi_add_host\n");
701 fc_host_max_npiv_vports(lport
->host
) = USHRT_MAX
;
702 snprintf(fc_host_symbolic_name(lport
->host
), 256,
703 "%s (Broadcom %s) v%s over %s",
704 BNX2FC_NAME
, hba
->chip_num
, BNX2FC_VERSION
,
705 interface
->netdev
->name
);
710 static int bnx2fc_link_ok(struct fc_lport
*lport
)
712 struct fcoe_port
*port
= lport_priv(lport
);
713 struct bnx2fc_interface
*interface
= port
->priv
;
714 struct bnx2fc_hba
*hba
= interface
->hba
;
715 struct net_device
*dev
= hba
->phys_dev
;
718 if ((dev
->flags
& IFF_UP
) && netif_carrier_ok(dev
))
719 clear_bit(ADAPTER_STATE_LINK_DOWN
, &hba
->adapter_state
);
721 set_bit(ADAPTER_STATE_LINK_DOWN
, &hba
->adapter_state
);
728 * bnx2fc_get_link_state - get network link state
730 * @hba: adapter instance pointer
732 * updates adapter structure flag based on netdev state
734 void bnx2fc_get_link_state(struct bnx2fc_hba
*hba
)
736 if (test_bit(__LINK_STATE_NOCARRIER
, &hba
->phys_dev
->state
))
737 set_bit(ADAPTER_STATE_LINK_DOWN
, &hba
->adapter_state
);
739 clear_bit(ADAPTER_STATE_LINK_DOWN
, &hba
->adapter_state
);
742 static int bnx2fc_net_config(struct fc_lport
*lport
, struct net_device
*netdev
)
744 struct bnx2fc_hba
*hba
;
745 struct bnx2fc_interface
*interface
;
746 struct fcoe_ctlr
*ctlr
;
747 struct fcoe_port
*port
;
750 port
= lport_priv(lport
);
751 interface
= port
->priv
;
752 ctlr
= bnx2fc_to_ctlr(interface
);
753 hba
= interface
->hba
;
755 /* require support for get_pauseparam ethtool op. */
756 if (!hba
->phys_dev
->ethtool_ops
||
757 !hba
->phys_dev
->ethtool_ops
->get_pauseparam
)
760 if (fc_set_mfs(lport
, BNX2FC_MFS
))
763 skb_queue_head_init(&port
->fcoe_pending_queue
);
764 port
->fcoe_pending_queue_active
= 0;
765 setup_timer(&port
->timer
, fcoe_queue_timer
, (unsigned long) lport
);
767 fcoe_link_speed_update(lport
);
770 if (fcoe_get_wwn(netdev
, &wwnn
, NETDEV_FCOE_WWNN
))
771 wwnn
= fcoe_wwn_from_mac(ctlr
->ctl_src_addr
,
773 BNX2FC_HBA_DBG(lport
, "WWNN = 0x%llx\n", wwnn
);
774 fc_set_wwnn(lport
, wwnn
);
776 if (fcoe_get_wwn(netdev
, &wwpn
, NETDEV_FCOE_WWPN
))
777 wwpn
= fcoe_wwn_from_mac(ctlr
->ctl_src_addr
,
780 BNX2FC_HBA_DBG(lport
, "WWPN = 0x%llx\n", wwpn
);
781 fc_set_wwpn(lport
, wwpn
);
787 static void bnx2fc_destroy_timer(unsigned long data
)
789 struct bnx2fc_hba
*hba
= (struct bnx2fc_hba
*)data
;
791 printk(KERN_ERR PFX
"ERROR:bnx2fc_destroy_timer - "
792 "Destroy compl not received!!\n");
793 set_bit(BNX2FC_FLAG_DESTROY_CMPL
, &hba
->flags
);
794 wake_up_interruptible(&hba
->destroy_wait
);
798 * bnx2fc_indicate_netevent - Generic netdev event handler
800 * @context: adapter structure pointer
802 * @vlan_id: vlan id - associated vlan id with this event
804 * Handles NETDEV_UP, NETDEV_DOWN, NETDEV_GOING_DOWN,NETDEV_CHANGE and
805 * NETDEV_CHANGE_MTU events. Handle NETDEV_UNREGISTER only for vlans.
807 static void bnx2fc_indicate_netevent(void *context
, unsigned long event
,
810 struct bnx2fc_hba
*hba
= (struct bnx2fc_hba
*)context
;
811 struct fcoe_ctlr_device
*cdev
;
812 struct fc_lport
*lport
;
813 struct fc_lport
*vport
;
814 struct bnx2fc_interface
*interface
, *tmp
;
815 struct fcoe_ctlr
*ctlr
;
816 int wait_for_upload
= 0;
817 u32 link_possible
= 1;
819 if (vlan_id
!= 0 && event
!= NETDEV_UNREGISTER
)
824 if (!test_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
))
825 printk(KERN_ERR
"indicate_netevent: "\
826 "hba is not UP!!\n");
830 clear_bit(ADAPTER_STATE_GOING_DOWN
, &hba
->adapter_state
);
831 clear_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
);
835 case NETDEV_GOING_DOWN
:
836 set_bit(ADAPTER_STATE_GOING_DOWN
, &hba
->adapter_state
);
843 case NETDEV_UNREGISTER
:
846 mutex_lock(&bnx2fc_dev_lock
);
847 list_for_each_entry_safe(interface
, tmp
, &if_list
, list
) {
848 if (interface
->hba
== hba
&&
849 interface
->vlan_id
== (vlan_id
& VLAN_VID_MASK
))
850 __bnx2fc_destroy(interface
);
852 mutex_unlock(&bnx2fc_dev_lock
);
856 printk(KERN_ERR PFX
"Unknown netevent %ld", event
);
860 mutex_lock(&bnx2fc_dev_lock
);
861 list_for_each_entry(interface
, &if_list
, list
) {
863 if (interface
->hba
!= hba
)
866 ctlr
= bnx2fc_to_ctlr(interface
);
868 BNX2FC_HBA_DBG(lport
, "netevent handler - event=%s %ld\n",
869 interface
->netdev
->name
, event
);
871 fcoe_link_speed_update(lport
);
873 cdev
= fcoe_ctlr_to_ctlr_dev(ctlr
);
875 if (link_possible
&& !bnx2fc_link_ok(lport
)) {
876 switch (cdev
->enabled
) {
877 case FCOE_CTLR_DISABLED
:
878 pr_info("Link up while interface is disabled.\n");
880 case FCOE_CTLR_ENABLED
:
881 case FCOE_CTLR_UNUSED
:
882 /* Reset max recv frame size to default */
883 fc_set_mfs(lport
, BNX2FC_MFS
);
885 * ctlr link up will only be handled during
886 * enable to avoid sending discovery
887 * solicitation on a stale vlan
889 if (interface
->enabled
)
890 fcoe_ctlr_link_up(ctlr
);
892 } else if (fcoe_ctlr_link_down(ctlr
)) {
893 switch (cdev
->enabled
) {
894 case FCOE_CTLR_DISABLED
:
895 pr_info("Link down while interface is disabled.\n");
897 case FCOE_CTLR_ENABLED
:
898 case FCOE_CTLR_UNUSED
:
899 mutex_lock(&lport
->lp_mutex
);
900 list_for_each_entry(vport
, &lport
->vports
, list
)
901 fc_host_port_type(vport
->host
) =
903 mutex_unlock(&lport
->lp_mutex
);
904 fc_host_port_type(lport
->host
) =
906 per_cpu_ptr(lport
->stats
,
907 get_cpu())->LinkFailureCount
++;
909 fcoe_clean_pending_queue(lport
);
914 mutex_unlock(&bnx2fc_dev_lock
);
916 if (wait_for_upload
) {
917 clear_bit(ADAPTER_STATE_READY
, &hba
->adapter_state
);
918 init_waitqueue_head(&hba
->shutdown_wait
);
919 BNX2FC_MISC_DBG("indicate_netevent "
920 "num_ofld_sess = %d\n",
922 hba
->wait_for_link_down
= 1;
923 wait_event_interruptible(hba
->shutdown_wait
,
924 (hba
->num_ofld_sess
== 0));
925 BNX2FC_MISC_DBG("wakeup - num_ofld_sess = %d\n",
927 hba
->wait_for_link_down
= 0;
929 if (signal_pending(current
))
930 flush_signals(current
);
934 static int bnx2fc_libfc_config(struct fc_lport
*lport
)
937 /* Set the function pointers set by bnx2fc driver */
938 memcpy(&lport
->tt
, &bnx2fc_libfc_fcn_templ
,
939 sizeof(struct libfc_function_template
));
940 fc_elsct_init(lport
);
942 fc_rport_init(lport
);
944 fc_disc_config(lport
, lport
);
948 static int bnx2fc_em_config(struct fc_lport
*lport
, struct bnx2fc_hba
*hba
)
950 int fcoe_min_xid
, fcoe_max_xid
;
952 fcoe_min_xid
= hba
->max_xid
+ 1;
954 fcoe_max_xid
= hba
->max_xid
+ FCOE_XIDS_PER_CPU_OFFSET
;
956 fcoe_max_xid
= hba
->max_xid
+ FCOE_MAX_XID_OFFSET
;
957 if (!fc_exch_mgr_alloc(lport
, FC_CLASS_3
, fcoe_min_xid
,
958 fcoe_max_xid
, NULL
)) {
959 printk(KERN_ERR PFX
"em_config:fc_exch_mgr_alloc failed\n");
966 static int bnx2fc_lport_config(struct fc_lport
*lport
)
970 lport
->max_retry_count
= BNX2FC_MAX_RETRY_CNT
;
971 lport
->max_rport_retry_count
= BNX2FC_MAX_RPORT_RETRY_CNT
;
972 lport
->e_d_tov
= 2 * 1000;
973 lport
->r_a_tov
= 10 * 1000;
975 lport
->service_params
= (FCP_SPPF_INIT_FCN
| FCP_SPPF_RD_XRDY_DIS
|
976 FCP_SPPF_RETRY
| FCP_SPPF_CONF_COMPL
);
977 lport
->does_npiv
= 1;
979 memset(&lport
->rnid_gen
, 0, sizeof(struct fc_els_rnid_gen
));
980 lport
->rnid_gen
.rnid_atype
= BNX2FC_RNID_HBA
;
982 /* alloc stats structure */
983 if (fc_lport_init_stats(lport
))
986 /* Finish fc_lport configuration */
987 fc_lport_config(lport
);
993 * bnx2fc_fip_recv - handle a received FIP frame.
995 * @skb: the received skb
996 * @dev: associated &net_device
997 * @ptype: the &packet_type structure which was used to register this handler.
998 * @orig_dev: original receive &net_device, in case @ dev is a bond.
1000 * Returns: 0 for success
1002 static int bnx2fc_fip_recv(struct sk_buff
*skb
, struct net_device
*dev
,
1003 struct packet_type
*ptype
,
1004 struct net_device
*orig_dev
)
1006 struct bnx2fc_interface
*interface
;
1007 struct fcoe_ctlr
*ctlr
;
1008 interface
= container_of(ptype
, struct bnx2fc_interface
,
1010 ctlr
= bnx2fc_to_ctlr(interface
);
1011 fcoe_ctlr_recv(ctlr
, skb
);
1016 * bnx2fc_update_src_mac - Update Ethernet MAC filters.
1018 * @fip: FCoE controller.
1019 * @old: Unicast MAC address to delete if the MAC is non-zero.
1020 * @new: Unicast MAC address to add.
1022 * Remove any previously-set unicast MAC filter.
1023 * Add secondary FCoE MAC address filter for our OUI.
1025 static void bnx2fc_update_src_mac(struct fc_lport
*lport
, u8
*addr
)
1027 struct fcoe_port
*port
= lport_priv(lport
);
1029 memcpy(port
->data_src_addr
, addr
, ETH_ALEN
);
1033 * bnx2fc_get_src_mac - return the ethernet source address for an lport
1035 * @lport: libfc port
1037 static u8
*bnx2fc_get_src_mac(struct fc_lport
*lport
)
1039 struct fcoe_port
*port
;
1041 port
= (struct fcoe_port
*)lport_priv(lport
);
1042 return port
->data_src_addr
;
1046 * bnx2fc_fip_send - send an Ethernet-encapsulated FIP frame.
1048 * @fip: FCoE controller.
1051 static void bnx2fc_fip_send(struct fcoe_ctlr
*fip
, struct sk_buff
*skb
)
1053 skb
->dev
= bnx2fc_from_ctlr(fip
)->netdev
;
1054 dev_queue_xmit(skb
);
1057 static int bnx2fc_vport_create(struct fc_vport
*vport
, bool disabled
)
1059 struct Scsi_Host
*shost
= vport_to_shost(vport
);
1060 struct fc_lport
*n_port
= shost_priv(shost
);
1061 struct fcoe_port
*port
= lport_priv(n_port
);
1062 struct bnx2fc_interface
*interface
= port
->priv
;
1063 struct net_device
*netdev
= interface
->netdev
;
1064 struct fc_lport
*vn_port
;
1068 rc
= fcoe_validate_vport_create(vport
);
1070 fcoe_wwn_to_str(vport
->port_name
, buf
, sizeof(buf
));
1071 printk(KERN_ERR PFX
"Failed to create vport, "
1072 "WWPN (0x%s) already exists\n",
1077 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &interface
->hba
->flags
)) {
1078 printk(KERN_ERR PFX
"vn ports cannot be created on"
1079 "this interface\n");
1083 mutex_lock(&bnx2fc_dev_lock
);
1084 vn_port
= bnx2fc_if_create(interface
, &vport
->dev
, 1);
1085 mutex_unlock(&bnx2fc_dev_lock
);
1088 if (IS_ERR(vn_port
)) {
1089 printk(KERN_ERR PFX
"bnx2fc_vport_create (%s) failed\n",
1095 fc_vport_set_state(vport
, FC_VPORT_DISABLED
);
1097 vn_port
->boot_time
= jiffies
;
1098 fc_lport_init(vn_port
);
1099 fc_fabric_login(vn_port
);
1100 fc_vport_setlink(vn_port
);
1105 static void bnx2fc_free_vport(struct bnx2fc_hba
*hba
, struct fc_lport
*lport
)
1107 struct bnx2fc_lport
*blport
, *tmp
;
1109 spin_lock_bh(&hba
->hba_lock
);
1110 list_for_each_entry_safe(blport
, tmp
, &hba
->vports
, list
) {
1111 if (blport
->lport
== lport
) {
1112 list_del(&blport
->list
);
1116 spin_unlock_bh(&hba
->hba_lock
);
1119 static int bnx2fc_vport_destroy(struct fc_vport
*vport
)
1121 struct Scsi_Host
*shost
= vport_to_shost(vport
);
1122 struct fc_lport
*n_port
= shost_priv(shost
);
1123 struct fc_lport
*vn_port
= vport
->dd_data
;
1124 struct fcoe_port
*port
= lport_priv(vn_port
);
1125 struct bnx2fc_interface
*interface
= port
->priv
;
1126 struct fc_lport
*v_port
;
1129 mutex_lock(&n_port
->lp_mutex
);
1130 list_for_each_entry(v_port
, &n_port
->vports
, list
)
1131 if (v_port
->vport
== vport
) {
1137 mutex_unlock(&n_port
->lp_mutex
);
1140 list_del(&vn_port
->list
);
1141 mutex_unlock(&n_port
->lp_mutex
);
1142 bnx2fc_free_vport(interface
->hba
, port
->lport
);
1143 bnx2fc_port_shutdown(port
->lport
);
1144 bnx2fc_interface_put(interface
);
1145 queue_work(bnx2fc_wq
, &port
->destroy_work
);
1149 static int bnx2fc_vport_disable(struct fc_vport
*vport
, bool disable
)
1151 struct fc_lport
*lport
= vport
->dd_data
;
1154 fc_vport_set_state(vport
, FC_VPORT_DISABLED
);
1155 fc_fabric_logoff(lport
);
1157 lport
->boot_time
= jiffies
;
1158 fc_fabric_login(lport
);
1159 fc_vport_setlink(lport
);
1165 static int bnx2fc_interface_setup(struct bnx2fc_interface
*interface
)
1167 struct net_device
*netdev
= interface
->netdev
;
1168 struct net_device
*physdev
= interface
->hba
->phys_dev
;
1169 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1170 struct netdev_hw_addr
*ha
;
1171 int sel_san_mac
= 0;
1173 /* setup Source MAC Address */
1175 for_each_dev_addr(physdev
, ha
) {
1176 BNX2FC_MISC_DBG("net_config: ha->type = %d, fip_mac = ",
1178 printk(KERN_INFO
"%2x:%2x:%2x:%2x:%2x:%2x\n", ha
->addr
[0],
1179 ha
->addr
[1], ha
->addr
[2], ha
->addr
[3],
1180 ha
->addr
[4], ha
->addr
[5]);
1182 if ((ha
->type
== NETDEV_HW_ADDR_T_SAN
) &&
1183 (is_valid_ether_addr(ha
->addr
))) {
1184 memcpy(ctlr
->ctl_src_addr
, ha
->addr
,
1187 BNX2FC_MISC_DBG("Found SAN MAC\n");
1195 interface
->fip_packet_type
.func
= bnx2fc_fip_recv
;
1196 interface
->fip_packet_type
.type
= htons(ETH_P_FIP
);
1197 interface
->fip_packet_type
.dev
= netdev
;
1198 dev_add_pack(&interface
->fip_packet_type
);
1200 interface
->fcoe_packet_type
.func
= bnx2fc_rcv
;
1201 interface
->fcoe_packet_type
.type
= __constant_htons(ETH_P_FCOE
);
1202 interface
->fcoe_packet_type
.dev
= netdev
;
1203 dev_add_pack(&interface
->fcoe_packet_type
);
1208 static int bnx2fc_attach_transport(void)
1210 bnx2fc_transport_template
=
1211 fc_attach_transport(&bnx2fc_transport_function
);
1213 if (bnx2fc_transport_template
== NULL
) {
1214 printk(KERN_ERR PFX
"Failed to attach FC transport\n");
1218 bnx2fc_vport_xport_template
=
1219 fc_attach_transport(&bnx2fc_vport_xport_function
);
1220 if (bnx2fc_vport_xport_template
== NULL
) {
1222 "Failed to attach FC transport for vport\n");
1223 fc_release_transport(bnx2fc_transport_template
);
1224 bnx2fc_transport_template
= NULL
;
1229 static void bnx2fc_release_transport(void)
1231 fc_release_transport(bnx2fc_transport_template
);
1232 fc_release_transport(bnx2fc_vport_xport_template
);
1233 bnx2fc_transport_template
= NULL
;
1234 bnx2fc_vport_xport_template
= NULL
;
1237 static void bnx2fc_interface_release(struct kref
*kref
)
1239 struct fcoe_ctlr_device
*ctlr_dev
;
1240 struct bnx2fc_interface
*interface
;
1241 struct fcoe_ctlr
*ctlr
;
1242 struct net_device
*netdev
;
1244 interface
= container_of(kref
, struct bnx2fc_interface
, kref
);
1245 BNX2FC_MISC_DBG("Interface is being released\n");
1247 ctlr
= bnx2fc_to_ctlr(interface
);
1248 ctlr_dev
= fcoe_ctlr_to_ctlr_dev(ctlr
);
1249 netdev
= interface
->netdev
;
1251 /* tear-down FIP controller */
1252 if (test_and_clear_bit(BNX2FC_CTLR_INIT_DONE
, &interface
->if_flags
))
1253 fcoe_ctlr_destroy(ctlr
);
1255 fcoe_ctlr_device_delete(ctlr_dev
);
1258 module_put(THIS_MODULE
);
1261 static inline void bnx2fc_interface_get(struct bnx2fc_interface
*interface
)
1263 kref_get(&interface
->kref
);
1266 static inline void bnx2fc_interface_put(struct bnx2fc_interface
*interface
)
1268 kref_put(&interface
->kref
, bnx2fc_interface_release
);
1270 static void bnx2fc_hba_destroy(struct bnx2fc_hba
*hba
)
1272 /* Free the command manager */
1274 bnx2fc_cmd_mgr_free(hba
->cmd_mgr
);
1275 hba
->cmd_mgr
= NULL
;
1277 kfree(hba
->tgt_ofld_list
);
1278 bnx2fc_unbind_pcidev(hba
);
1283 * bnx2fc_hba_create - create a new bnx2fc hba
1285 * @cnic: pointer to cnic device
1287 * Creates a new FCoE hba on the given device.
1290 static struct bnx2fc_hba
*bnx2fc_hba_create(struct cnic_dev
*cnic
)
1292 struct bnx2fc_hba
*hba
;
1293 struct fcoe_capabilities
*fcoe_cap
;
1296 hba
= kzalloc(sizeof(*hba
), GFP_KERNEL
);
1298 printk(KERN_ERR PFX
"Unable to allocate hba structure\n");
1301 spin_lock_init(&hba
->hba_lock
);
1302 mutex_init(&hba
->hba_mutex
);
1306 hba
->max_tasks
= cnic
->max_fcoe_exchanges
;
1307 hba
->elstm_xids
= (hba
->max_tasks
/ 2);
1308 hba
->max_outstanding_cmds
= hba
->elstm_xids
;
1309 hba
->max_xid
= (hba
->max_tasks
- 1);
1311 rc
= bnx2fc_bind_pcidev(hba
);
1313 printk(KERN_ERR PFX
"create_adapter: bind error\n");
1316 hba
->phys_dev
= cnic
->netdev
;
1317 hba
->next_conn_id
= 0;
1319 hba
->tgt_ofld_list
=
1320 kzalloc(sizeof(struct bnx2fc_rport
*) * BNX2FC_NUM_MAX_SESS
,
1322 if (!hba
->tgt_ofld_list
) {
1323 printk(KERN_ERR PFX
"Unable to allocate tgt offload list\n");
1327 hba
->num_ofld_sess
= 0;
1329 hba
->cmd_mgr
= bnx2fc_cmd_mgr_alloc(hba
);
1330 if (!hba
->cmd_mgr
) {
1331 printk(KERN_ERR PFX
"em_config:bnx2fc_cmd_mgr_alloc failed\n");
1334 fcoe_cap
= &hba
->fcoe_cap
;
1336 fcoe_cap
->capability1
= BNX2FC_TM_MAX_SQES
<<
1337 FCOE_IOS_PER_CONNECTION_SHIFT
;
1338 fcoe_cap
->capability1
|= BNX2FC_NUM_MAX_SESS
<<
1339 FCOE_LOGINS_PER_PORT_SHIFT
;
1340 fcoe_cap
->capability2
= hba
->max_outstanding_cmds
<<
1341 FCOE_NUMBER_OF_EXCHANGES_SHIFT
;
1342 fcoe_cap
->capability2
|= BNX2FC_MAX_NPIV
<<
1343 FCOE_NPIV_WWN_PER_PORT_SHIFT
;
1344 fcoe_cap
->capability3
= BNX2FC_NUM_MAX_SESS
<<
1345 FCOE_TARGETS_SUPPORTED_SHIFT
;
1346 fcoe_cap
->capability3
|= hba
->max_outstanding_cmds
<<
1347 FCOE_OUTSTANDING_COMMANDS_SHIFT
;
1348 fcoe_cap
->capability4
= FCOE_CAPABILITY4_STATEFUL
;
1350 init_waitqueue_head(&hba
->shutdown_wait
);
1351 init_waitqueue_head(&hba
->destroy_wait
);
1352 INIT_LIST_HEAD(&hba
->vports
);
1357 kfree(hba
->tgt_ofld_list
);
1359 bnx2fc_unbind_pcidev(hba
);
1365 struct bnx2fc_interface
*bnx2fc_interface_create(struct bnx2fc_hba
*hba
,
1366 struct net_device
*netdev
,
1367 enum fip_state fip_mode
)
1369 struct fcoe_ctlr_device
*ctlr_dev
;
1370 struct bnx2fc_interface
*interface
;
1371 struct fcoe_ctlr
*ctlr
;
1375 size
= (sizeof(*interface
) + sizeof(struct fcoe_ctlr
));
1376 ctlr_dev
= fcoe_ctlr_device_add(&netdev
->dev
, &bnx2fc_fcoe_sysfs_templ
,
1379 printk(KERN_ERR PFX
"Unable to allocate interface structure\n");
1382 ctlr
= fcoe_ctlr_device_priv(ctlr_dev
);
1383 ctlr
->cdev
= ctlr_dev
;
1384 interface
= fcoe_ctlr_priv(ctlr
);
1386 kref_init(&interface
->kref
);
1387 interface
->hba
= hba
;
1388 interface
->netdev
= netdev
;
1390 /* Initialize FIP */
1391 fcoe_ctlr_init(ctlr
, fip_mode
);
1392 ctlr
->send
= bnx2fc_fip_send
;
1393 ctlr
->update_mac
= bnx2fc_update_src_mac
;
1394 ctlr
->get_src_addr
= bnx2fc_get_src_mac
;
1395 set_bit(BNX2FC_CTLR_INIT_DONE
, &interface
->if_flags
);
1397 rc
= bnx2fc_interface_setup(interface
);
1401 fcoe_ctlr_destroy(ctlr
);
1403 fcoe_ctlr_device_delete(ctlr_dev
);
1408 * bnx2fc_if_create - Create FCoE instance on a given interface
1410 * @interface: FCoE interface to create a local port on
1411 * @parent: Device pointer to be the parent in sysfs for the SCSI host
1412 * @npiv: Indicates if the port is vport or not
1414 * Creates a fc_lport instance and a Scsi_Host instance and configure them.
1416 * Returns: Allocated fc_lport or an error pointer
1418 static struct fc_lport
*bnx2fc_if_create(struct bnx2fc_interface
*interface
,
1419 struct device
*parent
, int npiv
)
1421 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1422 struct fc_lport
*lport
, *n_port
;
1423 struct fcoe_port
*port
;
1424 struct Scsi_Host
*shost
;
1425 struct fc_vport
*vport
= dev_to_vport(parent
);
1426 struct bnx2fc_lport
*blport
;
1427 struct bnx2fc_hba
*hba
= interface
->hba
;
1430 blport
= kzalloc(sizeof(struct bnx2fc_lport
), GFP_KERNEL
);
1432 BNX2FC_HBA_DBG(ctlr
->lp
, "Unable to alloc blport\n");
1436 /* Allocate Scsi_Host structure */
1437 bnx2fc_shost_template
.can_queue
= hba
->max_outstanding_cmds
;
1439 lport
= libfc_host_alloc(&bnx2fc_shost_template
, sizeof(*port
));
1441 lport
= libfc_vport_create(vport
, sizeof(*port
));
1444 printk(KERN_ERR PFX
"could not allocate scsi host structure\n");
1447 shost
= lport
->host
;
1448 port
= lport_priv(lport
);
1449 port
->lport
= lport
;
1450 port
->priv
= interface
;
1451 port
->get_netdev
= bnx2fc_netdev
;
1452 INIT_WORK(&port
->destroy_work
, bnx2fc_destroy_work
);
1454 /* Configure fcoe_port */
1455 rc
= bnx2fc_lport_config(lport
);
1460 printk(KERN_ERR PFX
"Setting vport names, 0x%llX 0x%llX\n",
1461 vport
->node_name
, vport
->port_name
);
1462 fc_set_wwnn(lport
, vport
->node_name
);
1463 fc_set_wwpn(lport
, vport
->port_name
);
1465 /* Configure netdev and networking properties of the lport */
1466 rc
= bnx2fc_net_config(lport
, interface
->netdev
);
1468 printk(KERN_ERR PFX
"Error on bnx2fc_net_config\n");
1472 rc
= bnx2fc_shost_config(lport
, parent
);
1474 printk(KERN_ERR PFX
"Couldnt configure shost for %s\n",
1475 interface
->netdev
->name
);
1479 /* Initialize the libfc library */
1480 rc
= bnx2fc_libfc_config(lport
);
1482 printk(KERN_ERR PFX
"Couldnt configure libfc\n");
1485 fc_host_port_type(lport
->host
) = FC_PORTTYPE_UNKNOWN
;
1487 /* Allocate exchange manager */
1489 rc
= bnx2fc_em_config(lport
, hba
);
1491 shost
= vport_to_shost(vport
);
1492 n_port
= shost_priv(shost
);
1493 rc
= fc_exch_mgr_list_clone(n_port
, lport
);
1497 printk(KERN_ERR PFX
"Error on bnx2fc_em_config\n");
1501 bnx2fc_interface_get(interface
);
1503 spin_lock_bh(&hba
->hba_lock
);
1504 blport
->lport
= lport
;
1505 list_add_tail(&blport
->list
, &hba
->vports
);
1506 spin_unlock_bh(&hba
->hba_lock
);
1511 scsi_remove_host(shost
);
1513 scsi_host_put(lport
->host
);
1519 static void bnx2fc_net_cleanup(struct bnx2fc_interface
*interface
)
1521 /* Dont listen for Ethernet packets anymore */
1522 __dev_remove_pack(&interface
->fcoe_packet_type
);
1523 __dev_remove_pack(&interface
->fip_packet_type
);
1527 static void bnx2fc_interface_cleanup(struct bnx2fc_interface
*interface
)
1529 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1530 struct fc_lport
*lport
= ctlr
->lp
;
1531 struct fcoe_port
*port
= lport_priv(lport
);
1532 struct bnx2fc_hba
*hba
= interface
->hba
;
1534 /* Stop the transmit retry timer */
1535 del_timer_sync(&port
->timer
);
1537 /* Free existing transmit skbs */
1538 fcoe_clean_pending_queue(lport
);
1540 bnx2fc_net_cleanup(interface
);
1542 bnx2fc_free_vport(hba
, lport
);
1545 static void bnx2fc_if_destroy(struct fc_lport
*lport
)
1548 /* Free queued packets for the receive thread */
1549 bnx2fc_clean_rx_queue(lport
);
1551 /* Detach from scsi-ml */
1552 fc_remove_host(lport
->host
);
1553 scsi_remove_host(lport
->host
);
1556 * Note that only the physical lport will have the exchange manager.
1557 * for vports, this function is NOP
1559 fc_exch_mgr_free(lport
);
1561 /* Free memory used by statistical counters */
1562 fc_lport_free_stats(lport
);
1564 /* Release Scsi_Host */
1565 scsi_host_put(lport
->host
);
1568 static void __bnx2fc_destroy(struct bnx2fc_interface
*interface
)
1570 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1571 struct fc_lport
*lport
= ctlr
->lp
;
1572 struct fcoe_port
*port
= lport_priv(lport
);
1574 bnx2fc_interface_cleanup(interface
);
1575 bnx2fc_stop(interface
);
1576 list_del(&interface
->list
);
1577 bnx2fc_interface_put(interface
);
1578 queue_work(bnx2fc_wq
, &port
->destroy_work
);
1582 * bnx2fc_destroy - Destroy a bnx2fc FCoE interface
1584 * @buffer: The name of the Ethernet interface to be destroyed
1585 * @kp: The associated kernel parameter
1587 * Called from sysfs.
1589 * Returns: 0 for success
1591 static int bnx2fc_destroy(struct net_device
*netdev
)
1593 struct bnx2fc_interface
*interface
= NULL
;
1594 struct workqueue_struct
*timer_work_queue
;
1595 struct fcoe_ctlr
*ctlr
;
1599 mutex_lock(&bnx2fc_dev_lock
);
1601 interface
= bnx2fc_interface_lookup(netdev
);
1602 ctlr
= bnx2fc_to_ctlr(interface
);
1603 if (!interface
|| !ctlr
->lp
) {
1605 printk(KERN_ERR PFX
"bnx2fc_destroy: interface or lport not found\n");
1609 timer_work_queue
= interface
->timer_work_queue
;
1610 __bnx2fc_destroy(interface
);
1611 destroy_workqueue(timer_work_queue
);
1614 mutex_unlock(&bnx2fc_dev_lock
);
1619 static void bnx2fc_destroy_work(struct work_struct
*work
)
1621 struct fcoe_port
*port
;
1622 struct fc_lport
*lport
;
1624 port
= container_of(work
, struct fcoe_port
, destroy_work
);
1625 lport
= port
->lport
;
1627 BNX2FC_HBA_DBG(lport
, "Entered bnx2fc_destroy_work\n");
1629 bnx2fc_if_destroy(lport
);
1632 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba
*hba
)
1634 bnx2fc_free_fw_resc(hba
);
1635 bnx2fc_free_task_ctx(hba
);
1639 * bnx2fc_bind_adapter_devices - binds bnx2fc adapter with the associated
1642 * @hba: Adapter instance
1644 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba
*hba
)
1646 if (bnx2fc_setup_task_ctx(hba
))
1649 if (bnx2fc_setup_fw_resc(hba
))
1654 bnx2fc_unbind_adapter_devices(hba
);
1658 static int bnx2fc_bind_pcidev(struct bnx2fc_hba
*hba
)
1660 struct cnic_dev
*cnic
;
1661 struct pci_dev
*pdev
;
1664 printk(KERN_ERR PFX
"cnic is NULL\n");
1668 pdev
= hba
->pcidev
= cnic
->pcidev
;
1672 switch (pdev
->device
) {
1673 case PCI_DEVICE_ID_NX2_57710
:
1674 strncpy(hba
->chip_num
, "BCM57710", BCM_CHIP_LEN
);
1676 case PCI_DEVICE_ID_NX2_57711
:
1677 strncpy(hba
->chip_num
, "BCM57711", BCM_CHIP_LEN
);
1679 case PCI_DEVICE_ID_NX2_57712
:
1680 case PCI_DEVICE_ID_NX2_57712_MF
:
1681 case PCI_DEVICE_ID_NX2_57712_VF
:
1682 strncpy(hba
->chip_num
, "BCM57712", BCM_CHIP_LEN
);
1684 case PCI_DEVICE_ID_NX2_57800
:
1685 case PCI_DEVICE_ID_NX2_57800_MF
:
1686 case PCI_DEVICE_ID_NX2_57800_VF
:
1687 strncpy(hba
->chip_num
, "BCM57800", BCM_CHIP_LEN
);
1689 case PCI_DEVICE_ID_NX2_57810
:
1690 case PCI_DEVICE_ID_NX2_57810_MF
:
1691 case PCI_DEVICE_ID_NX2_57810_VF
:
1692 strncpy(hba
->chip_num
, "BCM57810", BCM_CHIP_LEN
);
1694 case PCI_DEVICE_ID_NX2_57840
:
1695 case PCI_DEVICE_ID_NX2_57840_MF
:
1696 case PCI_DEVICE_ID_NX2_57840_VF
:
1697 case PCI_DEVICE_ID_NX2_57840_2_20
:
1698 case PCI_DEVICE_ID_NX2_57840_4_10
:
1699 strncpy(hba
->chip_num
, "BCM57840", BCM_CHIP_LEN
);
1702 pr_err(PFX
"Unknown device id 0x%x\n", pdev
->device
);
1705 pci_dev_get(hba
->pcidev
);
1709 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba
*hba
)
1712 hba
->chip_num
[0] = '\0';
1713 pci_dev_put(hba
->pcidev
);
1719 * bnx2fc_ulp_get_stats - cnic callback to populate FCoE stats
1721 * @handle: transport handle pointing to adapter struture
1723 static int bnx2fc_ulp_get_stats(void *handle
)
1725 struct bnx2fc_hba
*hba
= handle
;
1726 struct cnic_dev
*cnic
;
1727 struct fcoe_stats_info
*stats_addr
;
1733 stats_addr
= &cnic
->stats_addr
->fcoe_stat
;
1737 strncpy(stats_addr
->version
, BNX2FC_VERSION
,
1738 sizeof(stats_addr
->version
));
1739 stats_addr
->txq_size
= BNX2FC_SQ_WQES_MAX
;
1740 stats_addr
->rxq_size
= BNX2FC_CQ_WQES_MAX
;
1747 * bnx2fc_ulp_start - cnic callback to initialize & start adapter instance
1749 * @handle: transport handle pointing to adapter structure
1751 * This function maps adapter structure to pcidev structure and initiates
1752 * firmware handshake to enable/initialize on-chip FCoE components.
1753 * This bnx2fc - cnic interface api callback is used after following
1754 * conditions are met -
1755 * a) underlying network interface is up (marked by event NETDEV_UP
1757 * b) bnx2fc adatper structure is registered.
1759 static void bnx2fc_ulp_start(void *handle
)
1761 struct bnx2fc_hba
*hba
= handle
;
1762 struct bnx2fc_interface
*interface
;
1763 struct fcoe_ctlr
*ctlr
;
1764 struct fc_lport
*lport
;
1766 mutex_lock(&bnx2fc_dev_lock
);
1768 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &hba
->flags
))
1769 bnx2fc_fw_init(hba
);
1771 BNX2FC_MISC_DBG("bnx2fc started.\n");
1773 list_for_each_entry(interface
, &if_list
, list
) {
1774 if (interface
->hba
== hba
) {
1775 ctlr
= bnx2fc_to_ctlr(interface
);
1777 /* Kick off Fabric discovery*/
1778 printk(KERN_ERR PFX
"ulp_init: start discovery\n");
1779 lport
->tt
.frame_send
= bnx2fc_xmit
;
1780 bnx2fc_start_disc(interface
);
1784 mutex_unlock(&bnx2fc_dev_lock
);
1787 static void bnx2fc_port_shutdown(struct fc_lport
*lport
)
1789 BNX2FC_MISC_DBG("Entered %s\n", __func__
);
1790 fc_fabric_logoff(lport
);
1791 fc_lport_destroy(lport
);
1794 static void bnx2fc_stop(struct bnx2fc_interface
*interface
)
1796 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1797 struct fc_lport
*lport
;
1798 struct fc_lport
*vport
;
1800 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &interface
->hba
->flags
))
1804 bnx2fc_port_shutdown(lport
);
1806 mutex_lock(&lport
->lp_mutex
);
1807 list_for_each_entry(vport
, &lport
->vports
, list
)
1808 fc_host_port_type(vport
->host
) =
1809 FC_PORTTYPE_UNKNOWN
;
1810 mutex_unlock(&lport
->lp_mutex
);
1811 fc_host_port_type(lport
->host
) = FC_PORTTYPE_UNKNOWN
;
1812 fcoe_ctlr_link_down(ctlr
);
1813 fcoe_clean_pending_queue(lport
);
1816 static int bnx2fc_fw_init(struct bnx2fc_hba
*hba
)
1818 #define BNX2FC_INIT_POLL_TIME (1000 / HZ)
1822 rc
= bnx2fc_bind_adapter_devices(hba
);
1824 printk(KERN_ALERT PFX
1825 "bnx2fc_bind_adapter_devices failed - rc = %d\n", rc
);
1829 rc
= bnx2fc_send_fw_fcoe_init_msg(hba
);
1831 printk(KERN_ALERT PFX
1832 "bnx2fc_send_fw_fcoe_init_msg failed - rc = %d\n", rc
);
1837 * Wait until the adapter init message is complete, and adapter
1840 while (!test_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
) && i
--)
1841 msleep(BNX2FC_INIT_POLL_TIME
);
1843 if (!test_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
)) {
1844 printk(KERN_ERR PFX
"bnx2fc_start: %s failed to initialize. "
1846 hba
->cnic
->netdev
->name
);
1852 set_bit(BNX2FC_FLAG_FW_INIT_DONE
, &hba
->flags
);
1856 bnx2fc_unbind_adapter_devices(hba
);
1861 static void bnx2fc_fw_destroy(struct bnx2fc_hba
*hba
)
1863 if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE
, &hba
->flags
)) {
1864 if (bnx2fc_send_fw_fcoe_destroy_msg(hba
) == 0) {
1865 init_timer(&hba
->destroy_timer
);
1866 hba
->destroy_timer
.expires
= BNX2FC_FW_TIMEOUT
+
1868 hba
->destroy_timer
.function
= bnx2fc_destroy_timer
;
1869 hba
->destroy_timer
.data
= (unsigned long)hba
;
1870 add_timer(&hba
->destroy_timer
);
1871 wait_event_interruptible(hba
->destroy_wait
,
1872 test_bit(BNX2FC_FLAG_DESTROY_CMPL
,
1874 clear_bit(BNX2FC_FLAG_DESTROY_CMPL
, &hba
->flags
);
1875 /* This should never happen */
1876 if (signal_pending(current
))
1877 flush_signals(current
);
1879 del_timer_sync(&hba
->destroy_timer
);
1881 bnx2fc_unbind_adapter_devices(hba
);
1886 * bnx2fc_ulp_stop - cnic callback to shutdown adapter instance
1888 * @handle: transport handle pointing to adapter structure
1890 * Driver checks if adapter is already in shutdown mode, if not start
1891 * the shutdown process.
1893 static void bnx2fc_ulp_stop(void *handle
)
1895 struct bnx2fc_hba
*hba
= handle
;
1896 struct bnx2fc_interface
*interface
;
1898 printk(KERN_ERR
"ULP_STOP\n");
1900 mutex_lock(&bnx2fc_dev_lock
);
1901 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &hba
->flags
))
1903 list_for_each_entry(interface
, &if_list
, list
) {
1904 if (interface
->hba
== hba
)
1905 bnx2fc_stop(interface
);
1907 BUG_ON(hba
->num_ofld_sess
!= 0);
1909 mutex_lock(&hba
->hba_mutex
);
1910 clear_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
);
1911 clear_bit(ADAPTER_STATE_GOING_DOWN
,
1912 &hba
->adapter_state
);
1914 clear_bit(ADAPTER_STATE_READY
, &hba
->adapter_state
);
1915 mutex_unlock(&hba
->hba_mutex
);
1917 bnx2fc_fw_destroy(hba
);
1919 mutex_unlock(&bnx2fc_dev_lock
);
1922 static void bnx2fc_start_disc(struct bnx2fc_interface
*interface
)
1924 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1925 struct fc_lport
*lport
;
1928 BNX2FC_MISC_DBG("Entered %s\n", __func__
);
1929 /* Kick off FIP/FLOGI */
1930 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &interface
->hba
->flags
)) {
1931 printk(KERN_ERR PFX
"Init not done yet\n");
1936 BNX2FC_HBA_DBG(lport
, "calling fc_fabric_login\n");
1938 if (!bnx2fc_link_ok(lport
) && interface
->enabled
) {
1939 BNX2FC_HBA_DBG(lport
, "ctlr_link_up\n");
1940 fcoe_ctlr_link_up(ctlr
);
1941 fc_host_port_type(lport
->host
) = FC_PORTTYPE_NPORT
;
1942 set_bit(ADAPTER_STATE_READY
, &interface
->hba
->adapter_state
);
1945 /* wait for the FCF to be selected before issuing FLOGI */
1946 while (!ctlr
->sel_fcf
) {
1948 /* give up after 3 secs */
1949 if (++wait_cnt
> 12)
1953 /* Reset max receive frame size to default */
1954 if (fc_set_mfs(lport
, BNX2FC_MFS
))
1957 fc_lport_init(lport
);
1958 fc_fabric_login(lport
);
1963 * bnx2fc_ulp_init - Initialize an adapter instance
1965 * @dev : cnic device handle
1966 * Called from cnic_register_driver() context to initialize all
1967 * enumerated cnic devices. This routine allocates adapter structure
1968 * and other device specific resources.
1970 static void bnx2fc_ulp_init(struct cnic_dev
*dev
)
1972 struct bnx2fc_hba
*hba
;
1975 BNX2FC_MISC_DBG("Entered %s\n", __func__
);
1976 /* bnx2fc works only when bnx2x is loaded */
1977 if (!test_bit(CNIC_F_BNX2X_CLASS
, &dev
->flags
) ||
1978 (dev
->max_fcoe_conn
== 0)) {
1979 printk(KERN_ERR PFX
"bnx2fc FCoE not supported on %s,"
1980 " flags: %lx fcoe_conn: %d\n",
1981 dev
->netdev
->name
, dev
->flags
, dev
->max_fcoe_conn
);
1985 hba
= bnx2fc_hba_create(dev
);
1987 printk(KERN_ERR PFX
"hba initialization failed\n");
1991 /* Add HBA to the adapter list */
1992 mutex_lock(&bnx2fc_dev_lock
);
1993 list_add_tail(&hba
->list
, &adapter_list
);
1995 mutex_unlock(&bnx2fc_dev_lock
);
1997 dev
->fcoe_cap
= &hba
->fcoe_cap
;
1998 clear_bit(BNX2FC_CNIC_REGISTERED
, &hba
->reg_with_cnic
);
1999 rc
= dev
->register_device(dev
, CNIC_ULP_FCOE
,
2002 printk(KERN_ERR PFX
"register_device failed, rc = %d\n", rc
);
2004 set_bit(BNX2FC_CNIC_REGISTERED
, &hba
->reg_with_cnic
);
2007 /* Assumes rtnl_lock and the bnx2fc_dev_lock are already taken */
2008 static int __bnx2fc_disable(struct fcoe_ctlr
*ctlr
)
2010 struct bnx2fc_interface
*interface
= fcoe_ctlr_priv(ctlr
);
2012 if (interface
->enabled
== true) {
2014 pr_err(PFX
"__bnx2fc_disable: lport not found\n");
2017 interface
->enabled
= false;
2018 fcoe_ctlr_link_down(ctlr
);
2019 fcoe_clean_pending_queue(ctlr
->lp
);
2026 * Deperecated: Use bnx2fc_enabled()
2028 static int bnx2fc_disable(struct net_device
*netdev
)
2030 struct bnx2fc_interface
*interface
;
2031 struct fcoe_ctlr
*ctlr
;
2035 mutex_lock(&bnx2fc_dev_lock
);
2037 interface
= bnx2fc_interface_lookup(netdev
);
2038 ctlr
= bnx2fc_to_ctlr(interface
);
2042 pr_err(PFX
"bnx2fc_disable: interface not found\n");
2044 rc
= __bnx2fc_disable(ctlr
);
2046 mutex_unlock(&bnx2fc_dev_lock
);
2051 static int __bnx2fc_enable(struct fcoe_ctlr
*ctlr
)
2053 struct bnx2fc_interface
*interface
= fcoe_ctlr_priv(ctlr
);
2055 if (interface
->enabled
== false) {
2057 pr_err(PFX
"__bnx2fc_enable: lport not found\n");
2059 } else if (!bnx2fc_link_ok(ctlr
->lp
)) {
2060 fcoe_ctlr_link_up(ctlr
);
2061 interface
->enabled
= true;
2068 * Deprecated: Use bnx2fc_enabled()
2070 static int bnx2fc_enable(struct net_device
*netdev
)
2072 struct bnx2fc_interface
*interface
;
2073 struct fcoe_ctlr
*ctlr
;
2077 mutex_lock(&bnx2fc_dev_lock
);
2079 interface
= bnx2fc_interface_lookup(netdev
);
2080 ctlr
= bnx2fc_to_ctlr(interface
);
2083 pr_err(PFX
"bnx2fc_enable: interface not found\n");
2085 rc
= __bnx2fc_enable(ctlr
);
2088 mutex_unlock(&bnx2fc_dev_lock
);
2094 * bnx2fc_ctlr_enabled() - Enable or disable an FCoE Controller
2095 * @cdev: The FCoE Controller that is being enabled or disabled
2097 * fcoe_sysfs will ensure that the state of 'enabled' has
2098 * changed, so no checking is necessary here. This routine simply
2099 * calls fcoe_enable or fcoe_disable, both of which are deprecated.
2100 * When those routines are removed the functionality can be merged
2103 static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device
*cdev
)
2105 struct fcoe_ctlr
*ctlr
= fcoe_ctlr_device_priv(cdev
);
2107 switch (cdev
->enabled
) {
2108 case FCOE_CTLR_ENABLED
:
2109 return __bnx2fc_enable(ctlr
);
2110 case FCOE_CTLR_DISABLED
:
2111 return __bnx2fc_disable(ctlr
);
2112 case FCOE_CTLR_UNUSED
:
2118 enum bnx2fc_create_link_state
{
2119 BNX2FC_CREATE_LINK_DOWN
,
2120 BNX2FC_CREATE_LINK_UP
,
2124 * _bnx2fc_create() - Create bnx2fc FCoE interface
2125 * @netdev : The net_device object the Ethernet interface to create on
2126 * @fip_mode: The FIP mode for this creation
2127 * @link_state: The ctlr link state on creation
2129 * Called from either the libfcoe 'create' module parameter
2130 * via fcoe_create or from fcoe_syfs's ctlr_create file.
2132 * libfcoe's 'create' module parameter is deprecated so some
2133 * consolidation of code can be done when that interface is
2136 * Returns: 0 for success
2138 static int _bnx2fc_create(struct net_device
*netdev
,
2139 enum fip_state fip_mode
,
2140 enum bnx2fc_create_link_state link_state
)
2142 struct fcoe_ctlr_device
*cdev
;
2143 struct fcoe_ctlr
*ctlr
;
2144 struct bnx2fc_interface
*interface
;
2145 struct bnx2fc_hba
*hba
;
2146 struct net_device
*phys_dev
= netdev
;
2147 struct fc_lport
*lport
;
2148 struct ethtool_drvinfo drvinfo
;
2152 BNX2FC_MISC_DBG("Entered bnx2fc_create\n");
2153 if (fip_mode
!= FIP_MODE_FABRIC
) {
2154 printk(KERN_ERR
"fip mode not FABRIC\n");
2160 mutex_lock(&bnx2fc_dev_lock
);
2162 if (!try_module_get(THIS_MODULE
)) {
2167 /* obtain physical netdev */
2168 if (netdev
->priv_flags
& IFF_802_1Q_VLAN
)
2169 phys_dev
= vlan_dev_real_dev(netdev
);
2171 /* verify if the physical device is a netxtreme2 device */
2172 if (phys_dev
->ethtool_ops
&& phys_dev
->ethtool_ops
->get_drvinfo
) {
2173 memset(&drvinfo
, 0, sizeof(drvinfo
));
2174 phys_dev
->ethtool_ops
->get_drvinfo(phys_dev
, &drvinfo
);
2175 if (strncmp(drvinfo
.driver
, "bnx2x", strlen("bnx2x"))) {
2176 printk(KERN_ERR PFX
"Not a netxtreme2 device\n");
2181 printk(KERN_ERR PFX
"unable to obtain drv_info\n");
2186 /* obtain interface and initialize rest of the structure */
2187 hba
= bnx2fc_hba_lookup(phys_dev
);
2190 printk(KERN_ERR PFX
"bnx2fc_create: hba not found\n");
2194 if (bnx2fc_interface_lookup(netdev
)) {
2199 interface
= bnx2fc_interface_create(hba
, netdev
, fip_mode
);
2201 printk(KERN_ERR PFX
"bnx2fc_interface_create failed\n");
2205 if (netdev
->priv_flags
& IFF_802_1Q_VLAN
) {
2206 vlan_id
= vlan_dev_vlan_id(netdev
);
2207 interface
->vlan_enabled
= 1;
2210 ctlr
= bnx2fc_to_ctlr(interface
);
2211 cdev
= fcoe_ctlr_to_ctlr_dev(ctlr
);
2212 interface
->vlan_id
= vlan_id
;
2214 interface
->timer_work_queue
=
2215 create_singlethread_workqueue("bnx2fc_timer_wq");
2216 if (!interface
->timer_work_queue
) {
2217 printk(KERN_ERR PFX
"ulp_init could not create timer_wq\n");
2222 lport
= bnx2fc_if_create(interface
, &cdev
->dev
, 0);
2224 printk(KERN_ERR PFX
"Failed to create interface (%s)\n",
2230 /* Add interface to if_list */
2231 list_add_tail(&interface
->list
, &if_list
);
2233 lport
->boot_time
= jiffies
;
2235 /* Make this master N_port */
2238 if (link_state
== BNX2FC_CREATE_LINK_UP
)
2239 cdev
->enabled
= FCOE_CTLR_ENABLED
;
2241 cdev
->enabled
= FCOE_CTLR_DISABLED
;
2243 if (link_state
== BNX2FC_CREATE_LINK_UP
&&
2244 !bnx2fc_link_ok(lport
)) {
2245 fcoe_ctlr_link_up(ctlr
);
2246 fc_host_port_type(lport
->host
) = FC_PORTTYPE_NPORT
;
2247 set_bit(ADAPTER_STATE_READY
, &interface
->hba
->adapter_state
);
2250 BNX2FC_HBA_DBG(lport
, "create: START DISC\n");
2251 bnx2fc_start_disc(interface
);
2253 if (link_state
== BNX2FC_CREATE_LINK_UP
)
2254 interface
->enabled
= true;
2257 * Release from kref_init in bnx2fc_interface_setup, on success
2258 * lport should be holding a reference taken in bnx2fc_if_create
2260 bnx2fc_interface_put(interface
);
2261 /* put netdev that was held while calling dev_get_by_name */
2262 mutex_unlock(&bnx2fc_dev_lock
);
2267 destroy_workqueue(interface
->timer_work_queue
);
2269 bnx2fc_net_cleanup(interface
);
2270 bnx2fc_interface_put(interface
);
2273 module_put(THIS_MODULE
);
2275 mutex_unlock(&bnx2fc_dev_lock
);
2281 * bnx2fc_create() - Create a bnx2fc interface
2282 * @netdev : The net_device object the Ethernet interface to create on
2283 * @fip_mode: The FIP mode for this creation
2285 * Called from fcoe transport
2287 * Returns: 0 for success
2289 static int bnx2fc_create(struct net_device
*netdev
, enum fip_state fip_mode
)
2291 return _bnx2fc_create(netdev
, fip_mode
, BNX2FC_CREATE_LINK_UP
);
2295 * bnx2fc_ctlr_alloc() - Allocate a bnx2fc interface from fcoe_sysfs
2296 * @netdev: The net_device to be used by the allocated FCoE Controller
2298 * This routine is called from fcoe_sysfs. It will start the fcoe_ctlr
2299 * in a link_down state. The allows the user an opportunity to configure
2300 * the FCoE Controller from sysfs before enabling the FCoE Controller.
2302 * Creating in with this routine starts the FCoE Controller in Fabric
2303 * mode. The user can change to VN2VN or another mode before enabling.
2305 static int bnx2fc_ctlr_alloc(struct net_device
*netdev
)
2307 return _bnx2fc_create(netdev
, FIP_MODE_FABRIC
,
2308 BNX2FC_CREATE_LINK_DOWN
);
2312 * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
2314 * @cnic: Pointer to cnic device instance
2317 static struct bnx2fc_hba
*bnx2fc_find_hba_for_cnic(struct cnic_dev
*cnic
)
2319 struct bnx2fc_hba
*hba
;
2321 /* Called with bnx2fc_dev_lock held */
2322 list_for_each_entry(hba
, &adapter_list
, list
) {
2323 if (hba
->cnic
== cnic
)
2329 static struct bnx2fc_interface
*bnx2fc_interface_lookup(struct net_device
2332 struct bnx2fc_interface
*interface
;
2334 /* Called with bnx2fc_dev_lock held */
2335 list_for_each_entry(interface
, &if_list
, list
) {
2336 if (interface
->netdev
== netdev
)
2342 static struct bnx2fc_hba
*bnx2fc_hba_lookup(struct net_device
2345 struct bnx2fc_hba
*hba
;
2347 /* Called with bnx2fc_dev_lock held */
2348 list_for_each_entry(hba
, &adapter_list
, list
) {
2349 if (hba
->phys_dev
== phys_dev
)
2352 printk(KERN_ERR PFX
"adapter_lookup: hba NULL\n");
2357 * bnx2fc_ulp_exit - shuts down adapter instance and frees all resources
2359 * @dev cnic device handle
2361 static void bnx2fc_ulp_exit(struct cnic_dev
*dev
)
2363 struct bnx2fc_hba
*hba
;
2364 struct bnx2fc_interface
*interface
, *tmp
;
2366 BNX2FC_MISC_DBG("Entered bnx2fc_ulp_exit\n");
2368 if (!test_bit(CNIC_F_BNX2X_CLASS
, &dev
->flags
)) {
2369 printk(KERN_ERR PFX
"bnx2fc port check: %s, flags: %lx\n",
2370 dev
->netdev
->name
, dev
->flags
);
2374 mutex_lock(&bnx2fc_dev_lock
);
2375 hba
= bnx2fc_find_hba_for_cnic(dev
);
2377 printk(KERN_ERR PFX
"bnx2fc_ulp_exit: hba not found, dev 0%p\n",
2379 mutex_unlock(&bnx2fc_dev_lock
);
2383 list_del_init(&hba
->list
);
2386 list_for_each_entry_safe(interface
, tmp
, &if_list
, list
)
2387 /* destroy not called yet, move to quiesced list */
2388 if (interface
->hba
== hba
)
2389 __bnx2fc_destroy(interface
);
2390 mutex_unlock(&bnx2fc_dev_lock
);
2392 bnx2fc_ulp_stop(hba
);
2393 /* unregister cnic device */
2394 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED
, &hba
->reg_with_cnic
))
2395 hba
->cnic
->unregister_device(hba
->cnic
, CNIC_ULP_FCOE
);
2396 bnx2fc_hba_destroy(hba
);
2400 * bnx2fc_fcoe_reset - Resets the fcoe
2402 * @shost: shost the reset is from
2406 static int bnx2fc_fcoe_reset(struct Scsi_Host
*shost
)
2408 struct fc_lport
*lport
= shost_priv(shost
);
2409 fc_lport_reset(lport
);
2414 static bool bnx2fc_match(struct net_device
*netdev
)
2416 struct net_device
*phys_dev
= netdev
;
2418 mutex_lock(&bnx2fc_dev_lock
);
2419 if (netdev
->priv_flags
& IFF_802_1Q_VLAN
)
2420 phys_dev
= vlan_dev_real_dev(netdev
);
2422 if (bnx2fc_hba_lookup(phys_dev
)) {
2423 mutex_unlock(&bnx2fc_dev_lock
);
2427 mutex_unlock(&bnx2fc_dev_lock
);
2432 static struct fcoe_transport bnx2fc_transport
= {
2435 .list
= LIST_HEAD_INIT(bnx2fc_transport
.list
),
2436 .alloc
= bnx2fc_ctlr_alloc
,
2437 .match
= bnx2fc_match
,
2438 .create
= bnx2fc_create
,
2439 .destroy
= bnx2fc_destroy
,
2440 .enable
= bnx2fc_enable
,
2441 .disable
= bnx2fc_disable
,
2445 * bnx2fc_percpu_thread_create - Create a receive thread for an
2448 * @cpu: cpu index for the online cpu
2450 static void bnx2fc_percpu_thread_create(unsigned int cpu
)
2452 struct bnx2fc_percpu_s
*p
;
2453 struct task_struct
*thread
;
2455 p
= &per_cpu(bnx2fc_percpu
, cpu
);
2457 thread
= kthread_create_on_node(bnx2fc_percpu_io_thread
,
2458 (void *)p
, cpu_to_node(cpu
),
2459 "bnx2fc_thread/%d", cpu
);
2460 /* bind thread to the cpu */
2461 if (likely(!IS_ERR(thread
))) {
2462 kthread_bind(thread
, cpu
);
2463 p
->iothread
= thread
;
2464 wake_up_process(thread
);
2468 static void bnx2fc_percpu_thread_destroy(unsigned int cpu
)
2470 struct bnx2fc_percpu_s
*p
;
2471 struct task_struct
*thread
;
2472 struct bnx2fc_work
*work
, *tmp
;
2474 BNX2FC_MISC_DBG("destroying io thread for CPU %d\n", cpu
);
2476 /* Prevent any new work from being queued for this CPU */
2477 p
= &per_cpu(bnx2fc_percpu
, cpu
);
2478 spin_lock_bh(&p
->fp_work_lock
);
2479 thread
= p
->iothread
;
2483 /* Free all work in the list */
2484 list_for_each_entry_safe(work
, tmp
, &p
->work_list
, list
) {
2485 list_del_init(&work
->list
);
2486 bnx2fc_process_cq_compl(work
->tgt
, work
->wqe
);
2490 spin_unlock_bh(&p
->fp_work_lock
);
2493 kthread_stop(thread
);
2497 * bnx2fc_cpu_callback - Handler for CPU hotplug events
2499 * @nfb: The callback data block
2500 * @action: The event triggering the callback
2501 * @hcpu: The index of the CPU that the event is for
2503 * This creates or destroys per-CPU data for fcoe
2505 * Returns NOTIFY_OK always.
2507 static int bnx2fc_cpu_callback(struct notifier_block
*nfb
,
2508 unsigned long action
, void *hcpu
)
2510 unsigned cpu
= (unsigned long)hcpu
;
2514 case CPU_ONLINE_FROZEN
:
2515 printk(PFX
"CPU %x online: Create Rx thread\n", cpu
);
2516 bnx2fc_percpu_thread_create(cpu
);
2519 case CPU_DEAD_FROZEN
:
2520 printk(PFX
"CPU %x offline: Remove Rx thread\n", cpu
);
2521 bnx2fc_percpu_thread_destroy(cpu
);
2530 * bnx2fc_mod_init - module init entry point
2532 * Initialize driver wide global data structures, and register
2535 static int __init
bnx2fc_mod_init(void)
2537 struct fcoe_percpu_s
*bg
;
2538 struct task_struct
*l2_thread
;
2540 unsigned int cpu
= 0;
2541 struct bnx2fc_percpu_s
*p
;
2543 printk(KERN_INFO PFX
"%s", version
);
2545 /* register as a fcoe transport */
2546 rc
= fcoe_transport_attach(&bnx2fc_transport
);
2548 printk(KERN_ERR
"failed to register an fcoe transport, check "
2549 "if libfcoe is loaded\n");
2553 INIT_LIST_HEAD(&adapter_list
);
2554 INIT_LIST_HEAD(&if_list
);
2555 mutex_init(&bnx2fc_dev_lock
);
2558 /* Attach FC transport template */
2559 rc
= bnx2fc_attach_transport();
2563 bnx2fc_wq
= alloc_workqueue("bnx2fc", 0, 0);
2569 bg
= &bnx2fc_global
;
2570 skb_queue_head_init(&bg
->fcoe_rx_list
);
2571 l2_thread
= kthread_create(bnx2fc_l2_rcv_thread
,
2573 "bnx2fc_l2_thread");
2574 if (IS_ERR(l2_thread
)) {
2575 rc
= PTR_ERR(l2_thread
);
2578 wake_up_process(l2_thread
);
2579 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
2580 bg
->thread
= l2_thread
;
2581 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
2583 for_each_possible_cpu(cpu
) {
2584 p
= &per_cpu(bnx2fc_percpu
, cpu
);
2585 INIT_LIST_HEAD(&p
->work_list
);
2586 spin_lock_init(&p
->fp_work_lock
);
2589 for_each_online_cpu(cpu
) {
2590 bnx2fc_percpu_thread_create(cpu
);
2593 /* Initialize per CPU interrupt thread */
2594 register_hotcpu_notifier(&bnx2fc_cpu_notifier
);
2596 cnic_register_driver(CNIC_ULP_FCOE
, &bnx2fc_cnic_cb
);
2601 destroy_workqueue(bnx2fc_wq
);
2603 bnx2fc_release_transport();
2605 fcoe_transport_detach(&bnx2fc_transport
);
2610 static void __exit
bnx2fc_mod_exit(void)
2612 LIST_HEAD(to_be_deleted
);
2613 struct bnx2fc_hba
*hba
, *next
;
2614 struct fcoe_percpu_s
*bg
;
2615 struct task_struct
*l2_thread
;
2616 struct sk_buff
*skb
;
2617 unsigned int cpu
= 0;
2620 * NOTE: Since cnic calls register_driver routine rtnl_lock,
2621 * it will have higher precedence than bnx2fc_dev_lock.
2622 * unregister_device() cannot be called with bnx2fc_dev_lock
2625 mutex_lock(&bnx2fc_dev_lock
);
2626 list_splice(&adapter_list
, &to_be_deleted
);
2627 INIT_LIST_HEAD(&adapter_list
);
2629 mutex_unlock(&bnx2fc_dev_lock
);
2631 /* Unregister with cnic */
2632 list_for_each_entry_safe(hba
, next
, &to_be_deleted
, list
) {
2633 list_del_init(&hba
->list
);
2634 printk(KERN_ERR PFX
"MOD_EXIT:destroy hba = 0x%p\n",
2636 bnx2fc_ulp_stop(hba
);
2637 /* unregister cnic device */
2638 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED
,
2639 &hba
->reg_with_cnic
))
2640 hba
->cnic
->unregister_device(hba
->cnic
,
2642 bnx2fc_hba_destroy(hba
);
2644 cnic_unregister_driver(CNIC_ULP_FCOE
);
2646 /* Destroy global thread */
2647 bg
= &bnx2fc_global
;
2648 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
2649 l2_thread
= bg
->thread
;
2651 while ((skb
= __skb_dequeue(&bg
->fcoe_rx_list
)) != NULL
)
2654 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
2657 kthread_stop(l2_thread
);
2659 unregister_hotcpu_notifier(&bnx2fc_cpu_notifier
);
2661 /* Destroy per cpu threads */
2662 for_each_online_cpu(cpu
) {
2663 bnx2fc_percpu_thread_destroy(cpu
);
2666 destroy_workqueue(bnx2fc_wq
);
2668 * detach from scsi transport
2669 * must happen after all destroys are done
2671 bnx2fc_release_transport();
2673 /* detach from fcoe transport */
2674 fcoe_transport_detach(&bnx2fc_transport
);
2677 module_init(bnx2fc_mod_init
);
2678 module_exit(bnx2fc_mod_exit
);
2680 static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ
= {
2681 .set_fcoe_ctlr_enabled
= bnx2fc_ctlr_enabled
,
2682 .get_fcoe_ctlr_link_fail
= fcoe_ctlr_get_lesb
,
2683 .get_fcoe_ctlr_vlink_fail
= fcoe_ctlr_get_lesb
,
2684 .get_fcoe_ctlr_miss_fka
= fcoe_ctlr_get_lesb
,
2685 .get_fcoe_ctlr_symb_err
= fcoe_ctlr_get_lesb
,
2686 .get_fcoe_ctlr_err_block
= fcoe_ctlr_get_lesb
,
2687 .get_fcoe_ctlr_fcs_error
= fcoe_ctlr_get_lesb
,
2689 .get_fcoe_fcf_selected
= fcoe_fcf_get_selected
,
2690 .get_fcoe_fcf_vlan_id
= bnx2fc_fcf_get_vlan_id
,
2693 static struct fc_function_template bnx2fc_transport_function
= {
2694 .show_host_node_name
= 1,
2695 .show_host_port_name
= 1,
2696 .show_host_supported_classes
= 1,
2697 .show_host_supported_fc4s
= 1,
2698 .show_host_active_fc4s
= 1,
2699 .show_host_maxframe_size
= 1,
2701 .show_host_port_id
= 1,
2702 .show_host_supported_speeds
= 1,
2703 .get_host_speed
= fc_get_host_speed
,
2704 .show_host_speed
= 1,
2705 .show_host_port_type
= 1,
2706 .get_host_port_state
= fc_get_host_port_state
,
2707 .show_host_port_state
= 1,
2708 .show_host_symbolic_name
= 1,
2710 .dd_fcrport_size
= (sizeof(struct fc_rport_libfc_priv
) +
2711 sizeof(struct bnx2fc_rport
)),
2712 .show_rport_maxframe_size
= 1,
2713 .show_rport_supported_classes
= 1,
2715 .show_host_fabric_name
= 1,
2716 .show_starget_node_name
= 1,
2717 .show_starget_port_name
= 1,
2718 .show_starget_port_id
= 1,
2719 .set_rport_dev_loss_tmo
= fc_set_rport_loss_tmo
,
2720 .show_rport_dev_loss_tmo
= 1,
2721 .get_fc_host_stats
= bnx2fc_get_host_stats
,
2723 .issue_fc_host_lip
= bnx2fc_fcoe_reset
,
2725 .terminate_rport_io
= fc_rport_terminate_io
,
2727 .vport_create
= bnx2fc_vport_create
,
2728 .vport_delete
= bnx2fc_vport_destroy
,
2729 .vport_disable
= bnx2fc_vport_disable
,
2730 .bsg_request
= fc_lport_bsg_request
,
2733 static struct fc_function_template bnx2fc_vport_xport_function
= {
2734 .show_host_node_name
= 1,
2735 .show_host_port_name
= 1,
2736 .show_host_supported_classes
= 1,
2737 .show_host_supported_fc4s
= 1,
2738 .show_host_active_fc4s
= 1,
2739 .show_host_maxframe_size
= 1,
2741 .show_host_port_id
= 1,
2742 .show_host_supported_speeds
= 1,
2743 .get_host_speed
= fc_get_host_speed
,
2744 .show_host_speed
= 1,
2745 .show_host_port_type
= 1,
2746 .get_host_port_state
= fc_get_host_port_state
,
2747 .show_host_port_state
= 1,
2748 .show_host_symbolic_name
= 1,
2750 .dd_fcrport_size
= (sizeof(struct fc_rport_libfc_priv
) +
2751 sizeof(struct bnx2fc_rport
)),
2752 .show_rport_maxframe_size
= 1,
2753 .show_rport_supported_classes
= 1,
2755 .show_host_fabric_name
= 1,
2756 .show_starget_node_name
= 1,
2757 .show_starget_port_name
= 1,
2758 .show_starget_port_id
= 1,
2759 .set_rport_dev_loss_tmo
= fc_set_rport_loss_tmo
,
2760 .show_rport_dev_loss_tmo
= 1,
2761 .get_fc_host_stats
= fc_get_host_stats
,
2762 .issue_fc_host_lip
= bnx2fc_fcoe_reset
,
2763 .terminate_rport_io
= fc_rport_terminate_io
,
2764 .bsg_request
= fc_lport_bsg_request
,
2768 * scsi_host_template structure used while registering with SCSI-ml
2770 static struct scsi_host_template bnx2fc_shost_template
= {
2771 .module
= THIS_MODULE
,
2772 .name
= "Broadcom Offload FCoE Initiator",
2773 .queuecommand
= bnx2fc_queuecommand
,
2774 .eh_abort_handler
= bnx2fc_eh_abort
, /* abts */
2775 .eh_device_reset_handler
= bnx2fc_eh_device_reset
, /* lun reset */
2776 .eh_target_reset_handler
= bnx2fc_eh_target_reset
, /* tgt reset */
2777 .eh_host_reset_handler
= fc_eh_host_reset
,
2778 .slave_alloc
= fc_slave_alloc
,
2779 .change_queue_depth
= fc_change_queue_depth
,
2780 .change_queue_type
= fc_change_queue_type
,
2783 .use_clustering
= ENABLE_CLUSTERING
,
2784 .sg_tablesize
= BNX2FC_MAX_BDS_PER_CMD
,
2785 .max_sectors
= 1024,
2788 static struct libfc_function_template bnx2fc_libfc_fcn_templ
= {
2789 .frame_send
= bnx2fc_xmit
,
2790 .elsct_send
= bnx2fc_elsct_send
,
2791 .fcp_abort_io
= bnx2fc_abort_io
,
2792 .fcp_cleanup
= bnx2fc_cleanup
,
2793 .get_lesb
= fcoe_get_lesb
,
2794 .rport_event_callback
= bnx2fc_rport_event_handler
,
2798 * bnx2fc_cnic_cb - global template of bnx2fc - cnic driver interface
2799 * structure carrying callback function pointers
2801 static struct cnic_ulp_ops bnx2fc_cnic_cb
= {
2802 .owner
= THIS_MODULE
,
2803 .cnic_init
= bnx2fc_ulp_init
,
2804 .cnic_exit
= bnx2fc_ulp_exit
,
2805 .cnic_start
= bnx2fc_ulp_start
,
2806 .cnic_stop
= bnx2fc_ulp_stop
,
2807 .indicate_kcqes
= bnx2fc_indicate_kcqe
,
2808 .indicate_netevent
= bnx2fc_indicate_netevent
,
2809 .cnic_get_stats
= bnx2fc_ulp_get_stats
,