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
;
414 struct sk_buff
*tmp_skb
;
417 interface
= container_of(ptype
, struct bnx2fc_interface
,
419 ctlr
= bnx2fc_to_ctlr(interface
);
422 if (unlikely(lport
== NULL
)) {
423 printk(KERN_ERR PFX
"bnx2fc_rcv: lport is NULL\n");
427 tmp_skb
= skb_share_check(skb
, GFP_ATOMIC
);
433 if (unlikely(eth_hdr(skb
)->h_proto
!= htons(ETH_P_FCOE
))) {
434 printk(KERN_ERR PFX
"bnx2fc_rcv: Wrong FC type frame\n");
439 * Check for minimum frame length, and make sure required FCoE
440 * and FC headers are pulled into the linear data area.
442 if (unlikely((skb
->len
< FCOE_MIN_FRAME
) ||
443 !pskb_may_pull(skb
, FCOE_HEADER_LEN
)))
446 skb_set_transport_header(skb
, sizeof(struct fcoe_hdr
));
447 fh
= (struct fc_frame_header
*) skb_transport_header(skb
);
449 oxid
= ntohs(fh
->fh_ox_id
);
451 fr
= fcoe_dev_from_skb(skb
);
455 spin_lock(&bg
->fcoe_rx_list
.lock
);
457 __skb_queue_tail(&bg
->fcoe_rx_list
, skb
);
458 if (bg
->fcoe_rx_list
.qlen
== 1)
459 wake_up_process(bg
->thread
);
461 spin_unlock(&bg
->fcoe_rx_list
.lock
);
469 static int bnx2fc_l2_rcv_thread(void *arg
)
471 struct fcoe_percpu_s
*bg
= arg
;
474 set_user_nice(current
, -20);
475 set_current_state(TASK_INTERRUPTIBLE
);
476 while (!kthread_should_stop()) {
478 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
479 while ((skb
= __skb_dequeue(&bg
->fcoe_rx_list
)) != NULL
) {
480 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
481 bnx2fc_recv_frame(skb
);
482 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
484 __set_current_state(TASK_INTERRUPTIBLE
);
485 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
487 __set_current_state(TASK_RUNNING
);
492 static void bnx2fc_recv_frame(struct sk_buff
*skb
)
495 struct fc_lport
*lport
;
496 struct fcoe_rcv_info
*fr
;
497 struct fc_stats
*stats
;
498 struct fc_frame_header
*fh
;
499 struct fcoe_crc_eof crc_eof
;
501 struct fc_lport
*vn_port
;
502 struct fcoe_port
*port
;
507 fr
= fcoe_dev_from_skb(skb
);
509 if (unlikely(lport
== NULL
)) {
510 printk(KERN_ERR PFX
"Invalid lport struct\n");
515 if (skb_is_nonlinear(skb
))
517 mac
= eth_hdr(skb
)->h_source
;
518 dest_mac
= eth_hdr(skb
)->h_dest
;
520 /* Pull the header */
521 hp
= (struct fcoe_hdr
*) skb_network_header(skb
);
522 fh
= (struct fc_frame_header
*) skb_transport_header(skb
);
523 skb_pull(skb
, sizeof(struct fcoe_hdr
));
524 fr_len
= skb
->len
- sizeof(struct fcoe_crc_eof
);
526 stats
= per_cpu_ptr(lport
->stats
, get_cpu());
528 stats
->RxWords
+= fr_len
/ FCOE_WORD_TO_BYTE
;
530 fp
= (struct fc_frame
*)skb
;
533 fr_sof(fp
) = hp
->fcoe_sof
;
534 if (skb_copy_bits(skb
, fr_len
, &crc_eof
, sizeof(crc_eof
))) {
539 fr_eof(fp
) = crc_eof
.fcoe_eof
;
540 fr_crc(fp
) = crc_eof
.fcoe_crc32
;
541 if (pskb_trim(skb
, fr_len
)) {
547 fh
= fc_frame_header_get(fp
);
549 vn_port
= fc_vport_id_lookup(lport
, ntoh24(fh
->fh_d_id
));
551 port
= lport_priv(vn_port
);
552 if (!ether_addr_equal(port
->data_src_addr
, dest_mac
)) {
553 BNX2FC_HBA_DBG(lport
, "fpma mismatch\n");
559 if (fh
->fh_r_ctl
== FC_RCTL_DD_SOL_DATA
&&
560 fh
->fh_type
== FC_TYPE_FCP
) {
561 /* Drop FCP data. We dont this in L2 path */
566 if (fh
->fh_r_ctl
== FC_RCTL_ELS_REQ
&&
567 fh
->fh_type
== FC_TYPE_ELS
) {
568 switch (fc_frame_payload_op(fp
)) {
570 if (ntoh24(fh
->fh_s_id
) == FC_FID_FLOGI
) {
571 /* drop non-FIP LOGO */
580 if (fh
->fh_r_ctl
== FC_RCTL_BA_ABTS
) {
581 /* Drop incoming ABTS */
587 if (le32_to_cpu(fr_crc(fp
)) !=
588 ~crc32(~0, skb
->data
, fr_len
)) {
589 if (stats
->InvalidCRCCount
< 5)
590 printk(KERN_WARNING PFX
"dropping frame with "
592 stats
->InvalidCRCCount
++;
598 fc_exch_recv(lport
, fp
);
602 * bnx2fc_percpu_io_thread - thread per cpu for ios
604 * @arg: ptr to bnx2fc_percpu_info structure
606 int bnx2fc_percpu_io_thread(void *arg
)
608 struct bnx2fc_percpu_s
*p
= arg
;
609 struct bnx2fc_work
*work
, *tmp
;
610 LIST_HEAD(work_list
);
612 set_user_nice(current
, -20);
613 set_current_state(TASK_INTERRUPTIBLE
);
614 while (!kthread_should_stop()) {
616 spin_lock_bh(&p
->fp_work_lock
);
617 while (!list_empty(&p
->work_list
)) {
618 list_splice_init(&p
->work_list
, &work_list
);
619 spin_unlock_bh(&p
->fp_work_lock
);
621 list_for_each_entry_safe(work
, tmp
, &work_list
, list
) {
622 list_del_init(&work
->list
);
623 bnx2fc_process_cq_compl(work
->tgt
, work
->wqe
);
627 spin_lock_bh(&p
->fp_work_lock
);
629 __set_current_state(TASK_INTERRUPTIBLE
);
630 spin_unlock_bh(&p
->fp_work_lock
);
632 __set_current_state(TASK_RUNNING
);
637 static struct fc_host_statistics
*bnx2fc_get_host_stats(struct Scsi_Host
*shost
)
639 struct fc_host_statistics
*bnx2fc_stats
;
640 struct fc_lport
*lport
= shost_priv(shost
);
641 struct fcoe_port
*port
= lport_priv(lport
);
642 struct bnx2fc_interface
*interface
= port
->priv
;
643 struct bnx2fc_hba
*hba
= interface
->hba
;
644 struct fcoe_statistics_params
*fw_stats
;
647 fw_stats
= (struct fcoe_statistics_params
*)hba
->stats_buffer
;
651 bnx2fc_stats
= fc_get_host_stats(shost
);
653 init_completion(&hba
->stat_req_done
);
654 if (bnx2fc_send_stat_req(hba
))
656 rc
= wait_for_completion_timeout(&hba
->stat_req_done
, (2 * HZ
));
658 BNX2FC_HBA_DBG(lport
, "FW stat req timed out\n");
661 BNX2FC_STATS(hba
, rx_stat2
, fc_crc_cnt
);
662 bnx2fc_stats
->invalid_crc_count
+= hba
->bfw_stats
.fc_crc_cnt
;
663 BNX2FC_STATS(hba
, tx_stat
, fcoe_tx_pkt_cnt
);
664 bnx2fc_stats
->tx_frames
+= hba
->bfw_stats
.fcoe_tx_pkt_cnt
;
665 BNX2FC_STATS(hba
, tx_stat
, fcoe_tx_byte_cnt
);
666 bnx2fc_stats
->tx_words
+= ((hba
->bfw_stats
.fcoe_tx_byte_cnt
) / 4);
667 BNX2FC_STATS(hba
, rx_stat0
, fcoe_rx_pkt_cnt
);
668 bnx2fc_stats
->rx_frames
+= hba
->bfw_stats
.fcoe_rx_pkt_cnt
;
669 BNX2FC_STATS(hba
, rx_stat0
, fcoe_rx_byte_cnt
);
670 bnx2fc_stats
->rx_words
+= ((hba
->bfw_stats
.fcoe_rx_byte_cnt
) / 4);
672 bnx2fc_stats
->dumped_frames
= 0;
673 bnx2fc_stats
->lip_count
= 0;
674 bnx2fc_stats
->nos_count
= 0;
675 bnx2fc_stats
->loss_of_sync_count
= 0;
676 bnx2fc_stats
->loss_of_signal_count
= 0;
677 bnx2fc_stats
->prim_seq_protocol_err_count
= 0;
679 memcpy(&hba
->prev_stats
, hba
->stats_buffer
,
680 sizeof(struct fcoe_statistics_params
));
684 static int bnx2fc_shost_config(struct fc_lport
*lport
, struct device
*dev
)
686 struct fcoe_port
*port
= lport_priv(lport
);
687 struct bnx2fc_interface
*interface
= port
->priv
;
688 struct bnx2fc_hba
*hba
= interface
->hba
;
689 struct Scsi_Host
*shost
= lport
->host
;
692 shost
->max_cmd_len
= BNX2FC_MAX_CMD_LEN
;
693 shost
->max_lun
= BNX2FC_MAX_LUN
;
694 shost
->max_id
= BNX2FC_MAX_FCP_TGT
;
695 shost
->max_channel
= 0;
697 shost
->transportt
= bnx2fc_vport_xport_template
;
699 shost
->transportt
= bnx2fc_transport_template
;
701 /* Add the new host to SCSI-ml */
702 rc
= scsi_add_host(lport
->host
, dev
);
704 printk(KERN_ERR PFX
"Error on scsi_add_host\n");
708 fc_host_max_npiv_vports(lport
->host
) = USHRT_MAX
;
709 snprintf(fc_host_symbolic_name(lport
->host
), 256,
710 "%s (Broadcom %s) v%s over %s",
711 BNX2FC_NAME
, hba
->chip_num
, BNX2FC_VERSION
,
712 interface
->netdev
->name
);
717 static int bnx2fc_link_ok(struct fc_lport
*lport
)
719 struct fcoe_port
*port
= lport_priv(lport
);
720 struct bnx2fc_interface
*interface
= port
->priv
;
721 struct bnx2fc_hba
*hba
= interface
->hba
;
722 struct net_device
*dev
= hba
->phys_dev
;
725 if ((dev
->flags
& IFF_UP
) && netif_carrier_ok(dev
))
726 clear_bit(ADAPTER_STATE_LINK_DOWN
, &hba
->adapter_state
);
728 set_bit(ADAPTER_STATE_LINK_DOWN
, &hba
->adapter_state
);
735 * bnx2fc_get_link_state - get network link state
737 * @hba: adapter instance pointer
739 * updates adapter structure flag based on netdev state
741 void bnx2fc_get_link_state(struct bnx2fc_hba
*hba
)
743 if (test_bit(__LINK_STATE_NOCARRIER
, &hba
->phys_dev
->state
))
744 set_bit(ADAPTER_STATE_LINK_DOWN
, &hba
->adapter_state
);
746 clear_bit(ADAPTER_STATE_LINK_DOWN
, &hba
->adapter_state
);
749 static int bnx2fc_net_config(struct fc_lport
*lport
, struct net_device
*netdev
)
751 struct bnx2fc_hba
*hba
;
752 struct bnx2fc_interface
*interface
;
753 struct fcoe_ctlr
*ctlr
;
754 struct fcoe_port
*port
;
757 port
= lport_priv(lport
);
758 interface
= port
->priv
;
759 ctlr
= bnx2fc_to_ctlr(interface
);
760 hba
= interface
->hba
;
762 /* require support for get_pauseparam ethtool op. */
763 if (!hba
->phys_dev
->ethtool_ops
||
764 !hba
->phys_dev
->ethtool_ops
->get_pauseparam
)
767 if (fc_set_mfs(lport
, BNX2FC_MFS
))
770 skb_queue_head_init(&port
->fcoe_pending_queue
);
771 port
->fcoe_pending_queue_active
= 0;
772 setup_timer(&port
->timer
, fcoe_queue_timer
, (unsigned long) lport
);
774 fcoe_link_speed_update(lport
);
777 if (fcoe_get_wwn(netdev
, &wwnn
, NETDEV_FCOE_WWNN
))
778 wwnn
= fcoe_wwn_from_mac(ctlr
->ctl_src_addr
,
780 BNX2FC_HBA_DBG(lport
, "WWNN = 0x%llx\n", wwnn
);
781 fc_set_wwnn(lport
, wwnn
);
783 if (fcoe_get_wwn(netdev
, &wwpn
, NETDEV_FCOE_WWPN
))
784 wwpn
= fcoe_wwn_from_mac(ctlr
->ctl_src_addr
,
787 BNX2FC_HBA_DBG(lport
, "WWPN = 0x%llx\n", wwpn
);
788 fc_set_wwpn(lport
, wwpn
);
794 static void bnx2fc_destroy_timer(unsigned long data
)
796 struct bnx2fc_hba
*hba
= (struct bnx2fc_hba
*)data
;
798 printk(KERN_ERR PFX
"ERROR:bnx2fc_destroy_timer - "
799 "Destroy compl not received!!\n");
800 set_bit(BNX2FC_FLAG_DESTROY_CMPL
, &hba
->flags
);
801 wake_up_interruptible(&hba
->destroy_wait
);
805 * bnx2fc_indicate_netevent - Generic netdev event handler
807 * @context: adapter structure pointer
809 * @vlan_id: vlan id - associated vlan id with this event
811 * Handles NETDEV_UP, NETDEV_DOWN, NETDEV_GOING_DOWN,NETDEV_CHANGE and
812 * NETDEV_CHANGE_MTU events. Handle NETDEV_UNREGISTER only for vlans.
814 static void bnx2fc_indicate_netevent(void *context
, unsigned long event
,
817 struct bnx2fc_hba
*hba
= (struct bnx2fc_hba
*)context
;
818 struct fcoe_ctlr_device
*cdev
;
819 struct fc_lport
*lport
;
820 struct fc_lport
*vport
;
821 struct bnx2fc_interface
*interface
, *tmp
;
822 struct fcoe_ctlr
*ctlr
;
823 int wait_for_upload
= 0;
824 u32 link_possible
= 1;
826 if (vlan_id
!= 0 && event
!= NETDEV_UNREGISTER
)
831 if (!test_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
))
832 printk(KERN_ERR
"indicate_netevent: "\
833 "hba is not UP!!\n");
837 clear_bit(ADAPTER_STATE_GOING_DOWN
, &hba
->adapter_state
);
838 clear_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
);
842 case NETDEV_GOING_DOWN
:
843 set_bit(ADAPTER_STATE_GOING_DOWN
, &hba
->adapter_state
);
850 case NETDEV_UNREGISTER
:
853 mutex_lock(&bnx2fc_dev_lock
);
854 list_for_each_entry_safe(interface
, tmp
, &if_list
, list
) {
855 if (interface
->hba
== hba
&&
856 interface
->vlan_id
== (vlan_id
& VLAN_VID_MASK
))
857 __bnx2fc_destroy(interface
);
859 mutex_unlock(&bnx2fc_dev_lock
);
863 printk(KERN_ERR PFX
"Unknown netevent %ld", event
);
867 mutex_lock(&bnx2fc_dev_lock
);
868 list_for_each_entry(interface
, &if_list
, list
) {
870 if (interface
->hba
!= hba
)
873 ctlr
= bnx2fc_to_ctlr(interface
);
875 BNX2FC_HBA_DBG(lport
, "netevent handler - event=%s %ld\n",
876 interface
->netdev
->name
, event
);
878 fcoe_link_speed_update(lport
);
880 cdev
= fcoe_ctlr_to_ctlr_dev(ctlr
);
882 if (link_possible
&& !bnx2fc_link_ok(lport
)) {
883 switch (cdev
->enabled
) {
884 case FCOE_CTLR_DISABLED
:
885 pr_info("Link up while interface is disabled.\n");
887 case FCOE_CTLR_ENABLED
:
888 case FCOE_CTLR_UNUSED
:
889 /* Reset max recv frame size to default */
890 fc_set_mfs(lport
, BNX2FC_MFS
);
892 * ctlr link up will only be handled during
893 * enable to avoid sending discovery
894 * solicitation on a stale vlan
896 if (interface
->enabled
)
897 fcoe_ctlr_link_up(ctlr
);
899 } else if (fcoe_ctlr_link_down(ctlr
)) {
900 switch (cdev
->enabled
) {
901 case FCOE_CTLR_DISABLED
:
902 pr_info("Link down while interface is disabled.\n");
904 case FCOE_CTLR_ENABLED
:
905 case FCOE_CTLR_UNUSED
:
906 mutex_lock(&lport
->lp_mutex
);
907 list_for_each_entry(vport
, &lport
->vports
, list
)
908 fc_host_port_type(vport
->host
) =
910 mutex_unlock(&lport
->lp_mutex
);
911 fc_host_port_type(lport
->host
) =
913 per_cpu_ptr(lport
->stats
,
914 get_cpu())->LinkFailureCount
++;
916 fcoe_clean_pending_queue(lport
);
921 mutex_unlock(&bnx2fc_dev_lock
);
923 if (wait_for_upload
) {
924 clear_bit(ADAPTER_STATE_READY
, &hba
->adapter_state
);
925 init_waitqueue_head(&hba
->shutdown_wait
);
926 BNX2FC_MISC_DBG("indicate_netevent "
927 "num_ofld_sess = %d\n",
929 hba
->wait_for_link_down
= 1;
930 wait_event_interruptible(hba
->shutdown_wait
,
931 (hba
->num_ofld_sess
== 0));
932 BNX2FC_MISC_DBG("wakeup - num_ofld_sess = %d\n",
934 hba
->wait_for_link_down
= 0;
936 if (signal_pending(current
))
937 flush_signals(current
);
941 static int bnx2fc_libfc_config(struct fc_lport
*lport
)
944 /* Set the function pointers set by bnx2fc driver */
945 memcpy(&lport
->tt
, &bnx2fc_libfc_fcn_templ
,
946 sizeof(struct libfc_function_template
));
947 fc_elsct_init(lport
);
949 fc_rport_init(lport
);
951 fc_disc_config(lport
, lport
);
955 static int bnx2fc_em_config(struct fc_lport
*lport
, struct bnx2fc_hba
*hba
)
957 int fcoe_min_xid
, fcoe_max_xid
;
959 fcoe_min_xid
= hba
->max_xid
+ 1;
961 fcoe_max_xid
= hba
->max_xid
+ FCOE_XIDS_PER_CPU_OFFSET
;
963 fcoe_max_xid
= hba
->max_xid
+ FCOE_MAX_XID_OFFSET
;
964 if (!fc_exch_mgr_alloc(lport
, FC_CLASS_3
, fcoe_min_xid
,
965 fcoe_max_xid
, NULL
)) {
966 printk(KERN_ERR PFX
"em_config:fc_exch_mgr_alloc failed\n");
973 static int bnx2fc_lport_config(struct fc_lport
*lport
)
977 lport
->max_retry_count
= BNX2FC_MAX_RETRY_CNT
;
978 lport
->max_rport_retry_count
= BNX2FC_MAX_RPORT_RETRY_CNT
;
979 lport
->e_d_tov
= 2 * 1000;
980 lport
->r_a_tov
= 10 * 1000;
982 lport
->service_params
= (FCP_SPPF_INIT_FCN
| FCP_SPPF_RD_XRDY_DIS
|
983 FCP_SPPF_RETRY
| FCP_SPPF_CONF_COMPL
);
984 lport
->does_npiv
= 1;
986 memset(&lport
->rnid_gen
, 0, sizeof(struct fc_els_rnid_gen
));
987 lport
->rnid_gen
.rnid_atype
= BNX2FC_RNID_HBA
;
989 /* alloc stats structure */
990 if (fc_lport_init_stats(lport
))
993 /* Finish fc_lport configuration */
994 fc_lport_config(lport
);
1000 * bnx2fc_fip_recv - handle a received FIP frame.
1002 * @skb: the received skb
1003 * @dev: associated &net_device
1004 * @ptype: the &packet_type structure which was used to register this handler.
1005 * @orig_dev: original receive &net_device, in case @ dev is a bond.
1007 * Returns: 0 for success
1009 static int bnx2fc_fip_recv(struct sk_buff
*skb
, struct net_device
*dev
,
1010 struct packet_type
*ptype
,
1011 struct net_device
*orig_dev
)
1013 struct bnx2fc_interface
*interface
;
1014 struct fcoe_ctlr
*ctlr
;
1015 interface
= container_of(ptype
, struct bnx2fc_interface
,
1017 ctlr
= bnx2fc_to_ctlr(interface
);
1018 fcoe_ctlr_recv(ctlr
, skb
);
1023 * bnx2fc_update_src_mac - Update Ethernet MAC filters.
1025 * @fip: FCoE controller.
1026 * @old: Unicast MAC address to delete if the MAC is non-zero.
1027 * @new: Unicast MAC address to add.
1029 * Remove any previously-set unicast MAC filter.
1030 * Add secondary FCoE MAC address filter for our OUI.
1032 static void bnx2fc_update_src_mac(struct fc_lport
*lport
, u8
*addr
)
1034 struct fcoe_port
*port
= lport_priv(lport
);
1036 memcpy(port
->data_src_addr
, addr
, ETH_ALEN
);
1040 * bnx2fc_get_src_mac - return the ethernet source address for an lport
1042 * @lport: libfc port
1044 static u8
*bnx2fc_get_src_mac(struct fc_lport
*lport
)
1046 struct fcoe_port
*port
;
1048 port
= (struct fcoe_port
*)lport_priv(lport
);
1049 return port
->data_src_addr
;
1053 * bnx2fc_fip_send - send an Ethernet-encapsulated FIP frame.
1055 * @fip: FCoE controller.
1058 static void bnx2fc_fip_send(struct fcoe_ctlr
*fip
, struct sk_buff
*skb
)
1060 skb
->dev
= bnx2fc_from_ctlr(fip
)->netdev
;
1061 dev_queue_xmit(skb
);
1064 static int bnx2fc_vport_create(struct fc_vport
*vport
, bool disabled
)
1066 struct Scsi_Host
*shost
= vport_to_shost(vport
);
1067 struct fc_lport
*n_port
= shost_priv(shost
);
1068 struct fcoe_port
*port
= lport_priv(n_port
);
1069 struct bnx2fc_interface
*interface
= port
->priv
;
1070 struct net_device
*netdev
= interface
->netdev
;
1071 struct fc_lport
*vn_port
;
1075 rc
= fcoe_validate_vport_create(vport
);
1077 fcoe_wwn_to_str(vport
->port_name
, buf
, sizeof(buf
));
1078 printk(KERN_ERR PFX
"Failed to create vport, "
1079 "WWPN (0x%s) already exists\n",
1084 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &interface
->hba
->flags
)) {
1085 printk(KERN_ERR PFX
"vn ports cannot be created on"
1086 "this interface\n");
1090 mutex_lock(&bnx2fc_dev_lock
);
1091 vn_port
= bnx2fc_if_create(interface
, &vport
->dev
, 1);
1092 mutex_unlock(&bnx2fc_dev_lock
);
1095 if (IS_ERR(vn_port
)) {
1096 printk(KERN_ERR PFX
"bnx2fc_vport_create (%s) failed\n",
1102 fc_vport_set_state(vport
, FC_VPORT_DISABLED
);
1104 vn_port
->boot_time
= jiffies
;
1105 fc_lport_init(vn_port
);
1106 fc_fabric_login(vn_port
);
1107 fc_vport_setlink(vn_port
);
1112 static void bnx2fc_free_vport(struct bnx2fc_hba
*hba
, struct fc_lport
*lport
)
1114 struct bnx2fc_lport
*blport
, *tmp
;
1116 spin_lock_bh(&hba
->hba_lock
);
1117 list_for_each_entry_safe(blport
, tmp
, &hba
->vports
, list
) {
1118 if (blport
->lport
== lport
) {
1119 list_del(&blport
->list
);
1123 spin_unlock_bh(&hba
->hba_lock
);
1126 static int bnx2fc_vport_destroy(struct fc_vport
*vport
)
1128 struct Scsi_Host
*shost
= vport_to_shost(vport
);
1129 struct fc_lport
*n_port
= shost_priv(shost
);
1130 struct fc_lport
*vn_port
= vport
->dd_data
;
1131 struct fcoe_port
*port
= lport_priv(vn_port
);
1132 struct bnx2fc_interface
*interface
= port
->priv
;
1133 struct fc_lport
*v_port
;
1136 mutex_lock(&n_port
->lp_mutex
);
1137 list_for_each_entry(v_port
, &n_port
->vports
, list
)
1138 if (v_port
->vport
== vport
) {
1144 mutex_unlock(&n_port
->lp_mutex
);
1147 list_del(&vn_port
->list
);
1148 mutex_unlock(&n_port
->lp_mutex
);
1149 bnx2fc_free_vport(interface
->hba
, port
->lport
);
1150 bnx2fc_port_shutdown(port
->lport
);
1151 bnx2fc_interface_put(interface
);
1152 queue_work(bnx2fc_wq
, &port
->destroy_work
);
1156 static int bnx2fc_vport_disable(struct fc_vport
*vport
, bool disable
)
1158 struct fc_lport
*lport
= vport
->dd_data
;
1161 fc_vport_set_state(vport
, FC_VPORT_DISABLED
);
1162 fc_fabric_logoff(lport
);
1164 lport
->boot_time
= jiffies
;
1165 fc_fabric_login(lport
);
1166 fc_vport_setlink(lport
);
1172 static int bnx2fc_interface_setup(struct bnx2fc_interface
*interface
)
1174 struct net_device
*netdev
= interface
->netdev
;
1175 struct net_device
*physdev
= interface
->hba
->phys_dev
;
1176 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1177 struct netdev_hw_addr
*ha
;
1178 int sel_san_mac
= 0;
1180 /* setup Source MAC Address */
1182 for_each_dev_addr(physdev
, ha
) {
1183 BNX2FC_MISC_DBG("net_config: ha->type = %d, fip_mac = ",
1185 printk(KERN_INFO
"%2x:%2x:%2x:%2x:%2x:%2x\n", ha
->addr
[0],
1186 ha
->addr
[1], ha
->addr
[2], ha
->addr
[3],
1187 ha
->addr
[4], ha
->addr
[5]);
1189 if ((ha
->type
== NETDEV_HW_ADDR_T_SAN
) &&
1190 (is_valid_ether_addr(ha
->addr
))) {
1191 memcpy(ctlr
->ctl_src_addr
, ha
->addr
,
1194 BNX2FC_MISC_DBG("Found SAN MAC\n");
1202 interface
->fip_packet_type
.func
= bnx2fc_fip_recv
;
1203 interface
->fip_packet_type
.type
= htons(ETH_P_FIP
);
1204 interface
->fip_packet_type
.dev
= netdev
;
1205 dev_add_pack(&interface
->fip_packet_type
);
1207 interface
->fcoe_packet_type
.func
= bnx2fc_rcv
;
1208 interface
->fcoe_packet_type
.type
= __constant_htons(ETH_P_FCOE
);
1209 interface
->fcoe_packet_type
.dev
= netdev
;
1210 dev_add_pack(&interface
->fcoe_packet_type
);
1215 static int bnx2fc_attach_transport(void)
1217 bnx2fc_transport_template
=
1218 fc_attach_transport(&bnx2fc_transport_function
);
1220 if (bnx2fc_transport_template
== NULL
) {
1221 printk(KERN_ERR PFX
"Failed to attach FC transport\n");
1225 bnx2fc_vport_xport_template
=
1226 fc_attach_transport(&bnx2fc_vport_xport_function
);
1227 if (bnx2fc_vport_xport_template
== NULL
) {
1229 "Failed to attach FC transport for vport\n");
1230 fc_release_transport(bnx2fc_transport_template
);
1231 bnx2fc_transport_template
= NULL
;
1236 static void bnx2fc_release_transport(void)
1238 fc_release_transport(bnx2fc_transport_template
);
1239 fc_release_transport(bnx2fc_vport_xport_template
);
1240 bnx2fc_transport_template
= NULL
;
1241 bnx2fc_vport_xport_template
= NULL
;
1244 static void bnx2fc_interface_release(struct kref
*kref
)
1246 struct fcoe_ctlr_device
*ctlr_dev
;
1247 struct bnx2fc_interface
*interface
;
1248 struct fcoe_ctlr
*ctlr
;
1249 struct net_device
*netdev
;
1251 interface
= container_of(kref
, struct bnx2fc_interface
, kref
);
1252 BNX2FC_MISC_DBG("Interface is being released\n");
1254 ctlr
= bnx2fc_to_ctlr(interface
);
1255 ctlr_dev
= fcoe_ctlr_to_ctlr_dev(ctlr
);
1256 netdev
= interface
->netdev
;
1258 /* tear-down FIP controller */
1259 if (test_and_clear_bit(BNX2FC_CTLR_INIT_DONE
, &interface
->if_flags
))
1260 fcoe_ctlr_destroy(ctlr
);
1262 fcoe_ctlr_device_delete(ctlr_dev
);
1265 module_put(THIS_MODULE
);
1268 static inline void bnx2fc_interface_get(struct bnx2fc_interface
*interface
)
1270 kref_get(&interface
->kref
);
1273 static inline void bnx2fc_interface_put(struct bnx2fc_interface
*interface
)
1275 kref_put(&interface
->kref
, bnx2fc_interface_release
);
1277 static void bnx2fc_hba_destroy(struct bnx2fc_hba
*hba
)
1279 /* Free the command manager */
1281 bnx2fc_cmd_mgr_free(hba
->cmd_mgr
);
1282 hba
->cmd_mgr
= NULL
;
1284 kfree(hba
->tgt_ofld_list
);
1285 bnx2fc_unbind_pcidev(hba
);
1290 * bnx2fc_hba_create - create a new bnx2fc hba
1292 * @cnic: pointer to cnic device
1294 * Creates a new FCoE hba on the given device.
1297 static struct bnx2fc_hba
*bnx2fc_hba_create(struct cnic_dev
*cnic
)
1299 struct bnx2fc_hba
*hba
;
1300 struct fcoe_capabilities
*fcoe_cap
;
1303 hba
= kzalloc(sizeof(*hba
), GFP_KERNEL
);
1305 printk(KERN_ERR PFX
"Unable to allocate hba structure\n");
1308 spin_lock_init(&hba
->hba_lock
);
1309 mutex_init(&hba
->hba_mutex
);
1313 hba
->max_tasks
= cnic
->max_fcoe_exchanges
;
1314 hba
->elstm_xids
= (hba
->max_tasks
/ 2);
1315 hba
->max_outstanding_cmds
= hba
->elstm_xids
;
1316 hba
->max_xid
= (hba
->max_tasks
- 1);
1318 rc
= bnx2fc_bind_pcidev(hba
);
1320 printk(KERN_ERR PFX
"create_adapter: bind error\n");
1323 hba
->phys_dev
= cnic
->netdev
;
1324 hba
->next_conn_id
= 0;
1326 hba
->tgt_ofld_list
=
1327 kzalloc(sizeof(struct bnx2fc_rport
*) * BNX2FC_NUM_MAX_SESS
,
1329 if (!hba
->tgt_ofld_list
) {
1330 printk(KERN_ERR PFX
"Unable to allocate tgt offload list\n");
1334 hba
->num_ofld_sess
= 0;
1336 hba
->cmd_mgr
= bnx2fc_cmd_mgr_alloc(hba
);
1337 if (!hba
->cmd_mgr
) {
1338 printk(KERN_ERR PFX
"em_config:bnx2fc_cmd_mgr_alloc failed\n");
1341 fcoe_cap
= &hba
->fcoe_cap
;
1343 fcoe_cap
->capability1
= BNX2FC_TM_MAX_SQES
<<
1344 FCOE_IOS_PER_CONNECTION_SHIFT
;
1345 fcoe_cap
->capability1
|= BNX2FC_NUM_MAX_SESS
<<
1346 FCOE_LOGINS_PER_PORT_SHIFT
;
1347 fcoe_cap
->capability2
= hba
->max_outstanding_cmds
<<
1348 FCOE_NUMBER_OF_EXCHANGES_SHIFT
;
1349 fcoe_cap
->capability2
|= BNX2FC_MAX_NPIV
<<
1350 FCOE_NPIV_WWN_PER_PORT_SHIFT
;
1351 fcoe_cap
->capability3
= BNX2FC_NUM_MAX_SESS
<<
1352 FCOE_TARGETS_SUPPORTED_SHIFT
;
1353 fcoe_cap
->capability3
|= hba
->max_outstanding_cmds
<<
1354 FCOE_OUTSTANDING_COMMANDS_SHIFT
;
1355 fcoe_cap
->capability4
= FCOE_CAPABILITY4_STATEFUL
;
1357 init_waitqueue_head(&hba
->shutdown_wait
);
1358 init_waitqueue_head(&hba
->destroy_wait
);
1359 INIT_LIST_HEAD(&hba
->vports
);
1364 kfree(hba
->tgt_ofld_list
);
1366 bnx2fc_unbind_pcidev(hba
);
1372 struct bnx2fc_interface
*bnx2fc_interface_create(struct bnx2fc_hba
*hba
,
1373 struct net_device
*netdev
,
1374 enum fip_state fip_mode
)
1376 struct fcoe_ctlr_device
*ctlr_dev
;
1377 struct bnx2fc_interface
*interface
;
1378 struct fcoe_ctlr
*ctlr
;
1382 size
= (sizeof(*interface
) + sizeof(struct fcoe_ctlr
));
1383 ctlr_dev
= fcoe_ctlr_device_add(&netdev
->dev
, &bnx2fc_fcoe_sysfs_templ
,
1386 printk(KERN_ERR PFX
"Unable to allocate interface structure\n");
1389 ctlr
= fcoe_ctlr_device_priv(ctlr_dev
);
1390 ctlr
->cdev
= ctlr_dev
;
1391 interface
= fcoe_ctlr_priv(ctlr
);
1393 kref_init(&interface
->kref
);
1394 interface
->hba
= hba
;
1395 interface
->netdev
= netdev
;
1397 /* Initialize FIP */
1398 fcoe_ctlr_init(ctlr
, fip_mode
);
1399 ctlr
->send
= bnx2fc_fip_send
;
1400 ctlr
->update_mac
= bnx2fc_update_src_mac
;
1401 ctlr
->get_src_addr
= bnx2fc_get_src_mac
;
1402 set_bit(BNX2FC_CTLR_INIT_DONE
, &interface
->if_flags
);
1404 rc
= bnx2fc_interface_setup(interface
);
1408 fcoe_ctlr_destroy(ctlr
);
1410 fcoe_ctlr_device_delete(ctlr_dev
);
1415 * bnx2fc_if_create - Create FCoE instance on a given interface
1417 * @interface: FCoE interface to create a local port on
1418 * @parent: Device pointer to be the parent in sysfs for the SCSI host
1419 * @npiv: Indicates if the port is vport or not
1421 * Creates a fc_lport instance and a Scsi_Host instance and configure them.
1423 * Returns: Allocated fc_lport or an error pointer
1425 static struct fc_lport
*bnx2fc_if_create(struct bnx2fc_interface
*interface
,
1426 struct device
*parent
, int npiv
)
1428 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1429 struct fc_lport
*lport
, *n_port
;
1430 struct fcoe_port
*port
;
1431 struct Scsi_Host
*shost
;
1432 struct fc_vport
*vport
= dev_to_vport(parent
);
1433 struct bnx2fc_lport
*blport
;
1434 struct bnx2fc_hba
*hba
= interface
->hba
;
1437 blport
= kzalloc(sizeof(struct bnx2fc_lport
), GFP_KERNEL
);
1439 BNX2FC_HBA_DBG(ctlr
->lp
, "Unable to alloc blport\n");
1443 /* Allocate Scsi_Host structure */
1444 bnx2fc_shost_template
.can_queue
= hba
->max_outstanding_cmds
;
1446 lport
= libfc_host_alloc(&bnx2fc_shost_template
, sizeof(*port
));
1448 lport
= libfc_vport_create(vport
, sizeof(*port
));
1451 printk(KERN_ERR PFX
"could not allocate scsi host structure\n");
1454 shost
= lport
->host
;
1455 port
= lport_priv(lport
);
1456 port
->lport
= lport
;
1457 port
->priv
= interface
;
1458 port
->get_netdev
= bnx2fc_netdev
;
1459 INIT_WORK(&port
->destroy_work
, bnx2fc_destroy_work
);
1461 /* Configure fcoe_port */
1462 rc
= bnx2fc_lport_config(lport
);
1467 printk(KERN_ERR PFX
"Setting vport names, 0x%llX 0x%llX\n",
1468 vport
->node_name
, vport
->port_name
);
1469 fc_set_wwnn(lport
, vport
->node_name
);
1470 fc_set_wwpn(lport
, vport
->port_name
);
1472 /* Configure netdev and networking properties of the lport */
1473 rc
= bnx2fc_net_config(lport
, interface
->netdev
);
1475 printk(KERN_ERR PFX
"Error on bnx2fc_net_config\n");
1479 rc
= bnx2fc_shost_config(lport
, parent
);
1481 printk(KERN_ERR PFX
"Couldnt configure shost for %s\n",
1482 interface
->netdev
->name
);
1486 /* Initialize the libfc library */
1487 rc
= bnx2fc_libfc_config(lport
);
1489 printk(KERN_ERR PFX
"Couldnt configure libfc\n");
1492 fc_host_port_type(lport
->host
) = FC_PORTTYPE_UNKNOWN
;
1494 /* Allocate exchange manager */
1496 rc
= bnx2fc_em_config(lport
, hba
);
1498 shost
= vport_to_shost(vport
);
1499 n_port
= shost_priv(shost
);
1500 rc
= fc_exch_mgr_list_clone(n_port
, lport
);
1504 printk(KERN_ERR PFX
"Error on bnx2fc_em_config\n");
1508 bnx2fc_interface_get(interface
);
1510 spin_lock_bh(&hba
->hba_lock
);
1511 blport
->lport
= lport
;
1512 list_add_tail(&blport
->list
, &hba
->vports
);
1513 spin_unlock_bh(&hba
->hba_lock
);
1518 scsi_remove_host(shost
);
1520 scsi_host_put(lport
->host
);
1526 static void bnx2fc_net_cleanup(struct bnx2fc_interface
*interface
)
1528 /* Dont listen for Ethernet packets anymore */
1529 __dev_remove_pack(&interface
->fcoe_packet_type
);
1530 __dev_remove_pack(&interface
->fip_packet_type
);
1534 static void bnx2fc_interface_cleanup(struct bnx2fc_interface
*interface
)
1536 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1537 struct fc_lport
*lport
= ctlr
->lp
;
1538 struct fcoe_port
*port
= lport_priv(lport
);
1539 struct bnx2fc_hba
*hba
= interface
->hba
;
1541 /* Stop the transmit retry timer */
1542 del_timer_sync(&port
->timer
);
1544 /* Free existing transmit skbs */
1545 fcoe_clean_pending_queue(lport
);
1547 bnx2fc_net_cleanup(interface
);
1549 bnx2fc_free_vport(hba
, lport
);
1552 static void bnx2fc_if_destroy(struct fc_lport
*lport
)
1555 /* Free queued packets for the receive thread */
1556 bnx2fc_clean_rx_queue(lport
);
1558 /* Detach from scsi-ml */
1559 fc_remove_host(lport
->host
);
1560 scsi_remove_host(lport
->host
);
1563 * Note that only the physical lport will have the exchange manager.
1564 * for vports, this function is NOP
1566 fc_exch_mgr_free(lport
);
1568 /* Free memory used by statistical counters */
1569 fc_lport_free_stats(lport
);
1571 /* Release Scsi_Host */
1572 scsi_host_put(lport
->host
);
1575 static void __bnx2fc_destroy(struct bnx2fc_interface
*interface
)
1577 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1578 struct fc_lport
*lport
= ctlr
->lp
;
1579 struct fcoe_port
*port
= lport_priv(lport
);
1581 bnx2fc_interface_cleanup(interface
);
1582 bnx2fc_stop(interface
);
1583 list_del(&interface
->list
);
1584 bnx2fc_interface_put(interface
);
1585 queue_work(bnx2fc_wq
, &port
->destroy_work
);
1589 * bnx2fc_destroy - Destroy a bnx2fc FCoE interface
1591 * @buffer: The name of the Ethernet interface to be destroyed
1592 * @kp: The associated kernel parameter
1594 * Called from sysfs.
1596 * Returns: 0 for success
1598 static int bnx2fc_destroy(struct net_device
*netdev
)
1600 struct bnx2fc_interface
*interface
= NULL
;
1601 struct workqueue_struct
*timer_work_queue
;
1602 struct fcoe_ctlr
*ctlr
;
1606 mutex_lock(&bnx2fc_dev_lock
);
1608 interface
= bnx2fc_interface_lookup(netdev
);
1609 ctlr
= bnx2fc_to_ctlr(interface
);
1610 if (!interface
|| !ctlr
->lp
) {
1612 printk(KERN_ERR PFX
"bnx2fc_destroy: interface or lport not found\n");
1616 timer_work_queue
= interface
->timer_work_queue
;
1617 __bnx2fc_destroy(interface
);
1618 destroy_workqueue(timer_work_queue
);
1621 mutex_unlock(&bnx2fc_dev_lock
);
1626 static void bnx2fc_destroy_work(struct work_struct
*work
)
1628 struct fcoe_port
*port
;
1629 struct fc_lport
*lport
;
1631 port
= container_of(work
, struct fcoe_port
, destroy_work
);
1632 lport
= port
->lport
;
1634 BNX2FC_HBA_DBG(lport
, "Entered bnx2fc_destroy_work\n");
1636 bnx2fc_if_destroy(lport
);
1639 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba
*hba
)
1641 bnx2fc_free_fw_resc(hba
);
1642 bnx2fc_free_task_ctx(hba
);
1646 * bnx2fc_bind_adapter_devices - binds bnx2fc adapter with the associated
1649 * @hba: Adapter instance
1651 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba
*hba
)
1653 if (bnx2fc_setup_task_ctx(hba
))
1656 if (bnx2fc_setup_fw_resc(hba
))
1661 bnx2fc_unbind_adapter_devices(hba
);
1665 static int bnx2fc_bind_pcidev(struct bnx2fc_hba
*hba
)
1667 struct cnic_dev
*cnic
;
1668 struct pci_dev
*pdev
;
1671 printk(KERN_ERR PFX
"cnic is NULL\n");
1675 pdev
= hba
->pcidev
= cnic
->pcidev
;
1679 switch (pdev
->device
) {
1680 case PCI_DEVICE_ID_NX2_57710
:
1681 strncpy(hba
->chip_num
, "BCM57710", BCM_CHIP_LEN
);
1683 case PCI_DEVICE_ID_NX2_57711
:
1684 strncpy(hba
->chip_num
, "BCM57711", BCM_CHIP_LEN
);
1686 case PCI_DEVICE_ID_NX2_57712
:
1687 case PCI_DEVICE_ID_NX2_57712_MF
:
1688 case PCI_DEVICE_ID_NX2_57712_VF
:
1689 strncpy(hba
->chip_num
, "BCM57712", BCM_CHIP_LEN
);
1691 case PCI_DEVICE_ID_NX2_57800
:
1692 case PCI_DEVICE_ID_NX2_57800_MF
:
1693 case PCI_DEVICE_ID_NX2_57800_VF
:
1694 strncpy(hba
->chip_num
, "BCM57800", BCM_CHIP_LEN
);
1696 case PCI_DEVICE_ID_NX2_57810
:
1697 case PCI_DEVICE_ID_NX2_57810_MF
:
1698 case PCI_DEVICE_ID_NX2_57810_VF
:
1699 strncpy(hba
->chip_num
, "BCM57810", BCM_CHIP_LEN
);
1701 case PCI_DEVICE_ID_NX2_57840
:
1702 case PCI_DEVICE_ID_NX2_57840_MF
:
1703 case PCI_DEVICE_ID_NX2_57840_VF
:
1704 case PCI_DEVICE_ID_NX2_57840_2_20
:
1705 case PCI_DEVICE_ID_NX2_57840_4_10
:
1706 strncpy(hba
->chip_num
, "BCM57840", BCM_CHIP_LEN
);
1709 pr_err(PFX
"Unknown device id 0x%x\n", pdev
->device
);
1712 pci_dev_get(hba
->pcidev
);
1716 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba
*hba
)
1719 hba
->chip_num
[0] = '\0';
1720 pci_dev_put(hba
->pcidev
);
1726 * bnx2fc_ulp_get_stats - cnic callback to populate FCoE stats
1728 * @handle: transport handle pointing to adapter struture
1730 static int bnx2fc_ulp_get_stats(void *handle
)
1732 struct bnx2fc_hba
*hba
= handle
;
1733 struct cnic_dev
*cnic
;
1734 struct fcoe_stats_info
*stats_addr
;
1740 stats_addr
= &cnic
->stats_addr
->fcoe_stat
;
1744 strncpy(stats_addr
->version
, BNX2FC_VERSION
,
1745 sizeof(stats_addr
->version
));
1746 stats_addr
->txq_size
= BNX2FC_SQ_WQES_MAX
;
1747 stats_addr
->rxq_size
= BNX2FC_CQ_WQES_MAX
;
1754 * bnx2fc_ulp_start - cnic callback to initialize & start adapter instance
1756 * @handle: transport handle pointing to adapter structure
1758 * This function maps adapter structure to pcidev structure and initiates
1759 * firmware handshake to enable/initialize on-chip FCoE components.
1760 * This bnx2fc - cnic interface api callback is used after following
1761 * conditions are met -
1762 * a) underlying network interface is up (marked by event NETDEV_UP
1764 * b) bnx2fc adatper structure is registered.
1766 static void bnx2fc_ulp_start(void *handle
)
1768 struct bnx2fc_hba
*hba
= handle
;
1769 struct bnx2fc_interface
*interface
;
1770 struct fcoe_ctlr
*ctlr
;
1771 struct fc_lport
*lport
;
1773 mutex_lock(&bnx2fc_dev_lock
);
1775 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &hba
->flags
))
1776 bnx2fc_fw_init(hba
);
1778 BNX2FC_MISC_DBG("bnx2fc started.\n");
1780 list_for_each_entry(interface
, &if_list
, list
) {
1781 if (interface
->hba
== hba
) {
1782 ctlr
= bnx2fc_to_ctlr(interface
);
1784 /* Kick off Fabric discovery*/
1785 printk(KERN_ERR PFX
"ulp_init: start discovery\n");
1786 lport
->tt
.frame_send
= bnx2fc_xmit
;
1787 bnx2fc_start_disc(interface
);
1791 mutex_unlock(&bnx2fc_dev_lock
);
1794 static void bnx2fc_port_shutdown(struct fc_lport
*lport
)
1796 BNX2FC_MISC_DBG("Entered %s\n", __func__
);
1797 fc_fabric_logoff(lport
);
1798 fc_lport_destroy(lport
);
1801 static void bnx2fc_stop(struct bnx2fc_interface
*interface
)
1803 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1804 struct fc_lport
*lport
;
1805 struct fc_lport
*vport
;
1807 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &interface
->hba
->flags
))
1811 bnx2fc_port_shutdown(lport
);
1813 mutex_lock(&lport
->lp_mutex
);
1814 list_for_each_entry(vport
, &lport
->vports
, list
)
1815 fc_host_port_type(vport
->host
) =
1816 FC_PORTTYPE_UNKNOWN
;
1817 mutex_unlock(&lport
->lp_mutex
);
1818 fc_host_port_type(lport
->host
) = FC_PORTTYPE_UNKNOWN
;
1819 fcoe_ctlr_link_down(ctlr
);
1820 fcoe_clean_pending_queue(lport
);
1823 static int bnx2fc_fw_init(struct bnx2fc_hba
*hba
)
1825 #define BNX2FC_INIT_POLL_TIME (1000 / HZ)
1829 rc
= bnx2fc_bind_adapter_devices(hba
);
1831 printk(KERN_ALERT PFX
1832 "bnx2fc_bind_adapter_devices failed - rc = %d\n", rc
);
1836 rc
= bnx2fc_send_fw_fcoe_init_msg(hba
);
1838 printk(KERN_ALERT PFX
1839 "bnx2fc_send_fw_fcoe_init_msg failed - rc = %d\n", rc
);
1844 * Wait until the adapter init message is complete, and adapter
1847 while (!test_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
) && i
--)
1848 msleep(BNX2FC_INIT_POLL_TIME
);
1850 if (!test_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
)) {
1851 printk(KERN_ERR PFX
"bnx2fc_start: %s failed to initialize. "
1853 hba
->cnic
->netdev
->name
);
1859 set_bit(BNX2FC_FLAG_FW_INIT_DONE
, &hba
->flags
);
1863 bnx2fc_unbind_adapter_devices(hba
);
1868 static void bnx2fc_fw_destroy(struct bnx2fc_hba
*hba
)
1870 if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE
, &hba
->flags
)) {
1871 if (bnx2fc_send_fw_fcoe_destroy_msg(hba
) == 0) {
1872 init_timer(&hba
->destroy_timer
);
1873 hba
->destroy_timer
.expires
= BNX2FC_FW_TIMEOUT
+
1875 hba
->destroy_timer
.function
= bnx2fc_destroy_timer
;
1876 hba
->destroy_timer
.data
= (unsigned long)hba
;
1877 add_timer(&hba
->destroy_timer
);
1878 wait_event_interruptible(hba
->destroy_wait
,
1879 test_bit(BNX2FC_FLAG_DESTROY_CMPL
,
1881 clear_bit(BNX2FC_FLAG_DESTROY_CMPL
, &hba
->flags
);
1882 /* This should never happen */
1883 if (signal_pending(current
))
1884 flush_signals(current
);
1886 del_timer_sync(&hba
->destroy_timer
);
1888 bnx2fc_unbind_adapter_devices(hba
);
1893 * bnx2fc_ulp_stop - cnic callback to shutdown adapter instance
1895 * @handle: transport handle pointing to adapter structure
1897 * Driver checks if adapter is already in shutdown mode, if not start
1898 * the shutdown process.
1900 static void bnx2fc_ulp_stop(void *handle
)
1902 struct bnx2fc_hba
*hba
= handle
;
1903 struct bnx2fc_interface
*interface
;
1905 printk(KERN_ERR
"ULP_STOP\n");
1907 mutex_lock(&bnx2fc_dev_lock
);
1908 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &hba
->flags
))
1910 list_for_each_entry(interface
, &if_list
, list
) {
1911 if (interface
->hba
== hba
)
1912 bnx2fc_stop(interface
);
1914 BUG_ON(hba
->num_ofld_sess
!= 0);
1916 mutex_lock(&hba
->hba_mutex
);
1917 clear_bit(ADAPTER_STATE_UP
, &hba
->adapter_state
);
1918 clear_bit(ADAPTER_STATE_GOING_DOWN
,
1919 &hba
->adapter_state
);
1921 clear_bit(ADAPTER_STATE_READY
, &hba
->adapter_state
);
1922 mutex_unlock(&hba
->hba_mutex
);
1924 bnx2fc_fw_destroy(hba
);
1926 mutex_unlock(&bnx2fc_dev_lock
);
1929 static void bnx2fc_start_disc(struct bnx2fc_interface
*interface
)
1931 struct fcoe_ctlr
*ctlr
= bnx2fc_to_ctlr(interface
);
1932 struct fc_lport
*lport
;
1935 BNX2FC_MISC_DBG("Entered %s\n", __func__
);
1936 /* Kick off FIP/FLOGI */
1937 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE
, &interface
->hba
->flags
)) {
1938 printk(KERN_ERR PFX
"Init not done yet\n");
1943 BNX2FC_HBA_DBG(lport
, "calling fc_fabric_login\n");
1945 if (!bnx2fc_link_ok(lport
) && interface
->enabled
) {
1946 BNX2FC_HBA_DBG(lport
, "ctlr_link_up\n");
1947 fcoe_ctlr_link_up(ctlr
);
1948 fc_host_port_type(lport
->host
) = FC_PORTTYPE_NPORT
;
1949 set_bit(ADAPTER_STATE_READY
, &interface
->hba
->adapter_state
);
1952 /* wait for the FCF to be selected before issuing FLOGI */
1953 while (!ctlr
->sel_fcf
) {
1955 /* give up after 3 secs */
1956 if (++wait_cnt
> 12)
1960 /* Reset max receive frame size to default */
1961 if (fc_set_mfs(lport
, BNX2FC_MFS
))
1964 fc_lport_init(lport
);
1965 fc_fabric_login(lport
);
1970 * bnx2fc_ulp_init - Initialize an adapter instance
1972 * @dev : cnic device handle
1973 * Called from cnic_register_driver() context to initialize all
1974 * enumerated cnic devices. This routine allocates adapter structure
1975 * and other device specific resources.
1977 static void bnx2fc_ulp_init(struct cnic_dev
*dev
)
1979 struct bnx2fc_hba
*hba
;
1982 BNX2FC_MISC_DBG("Entered %s\n", __func__
);
1983 /* bnx2fc works only when bnx2x is loaded */
1984 if (!test_bit(CNIC_F_BNX2X_CLASS
, &dev
->flags
) ||
1985 (dev
->max_fcoe_conn
== 0)) {
1986 printk(KERN_ERR PFX
"bnx2fc FCoE not supported on %s,"
1987 " flags: %lx fcoe_conn: %d\n",
1988 dev
->netdev
->name
, dev
->flags
, dev
->max_fcoe_conn
);
1992 hba
= bnx2fc_hba_create(dev
);
1994 printk(KERN_ERR PFX
"hba initialization failed\n");
1998 /* Add HBA to the adapter list */
1999 mutex_lock(&bnx2fc_dev_lock
);
2000 list_add_tail(&hba
->list
, &adapter_list
);
2002 mutex_unlock(&bnx2fc_dev_lock
);
2004 dev
->fcoe_cap
= &hba
->fcoe_cap
;
2005 clear_bit(BNX2FC_CNIC_REGISTERED
, &hba
->reg_with_cnic
);
2006 rc
= dev
->register_device(dev
, CNIC_ULP_FCOE
,
2009 printk(KERN_ERR PFX
"register_device failed, rc = %d\n", rc
);
2011 set_bit(BNX2FC_CNIC_REGISTERED
, &hba
->reg_with_cnic
);
2014 /* Assumes rtnl_lock and the bnx2fc_dev_lock are already taken */
2015 static int __bnx2fc_disable(struct fcoe_ctlr
*ctlr
)
2017 struct bnx2fc_interface
*interface
= fcoe_ctlr_priv(ctlr
);
2019 if (interface
->enabled
== true) {
2021 pr_err(PFX
"__bnx2fc_disable: lport not found\n");
2024 interface
->enabled
= false;
2025 fcoe_ctlr_link_down(ctlr
);
2026 fcoe_clean_pending_queue(ctlr
->lp
);
2033 * Deperecated: Use bnx2fc_enabled()
2035 static int bnx2fc_disable(struct net_device
*netdev
)
2037 struct bnx2fc_interface
*interface
;
2038 struct fcoe_ctlr
*ctlr
;
2042 mutex_lock(&bnx2fc_dev_lock
);
2044 interface
= bnx2fc_interface_lookup(netdev
);
2045 ctlr
= bnx2fc_to_ctlr(interface
);
2049 pr_err(PFX
"bnx2fc_disable: interface not found\n");
2051 rc
= __bnx2fc_disable(ctlr
);
2053 mutex_unlock(&bnx2fc_dev_lock
);
2058 static int __bnx2fc_enable(struct fcoe_ctlr
*ctlr
)
2060 struct bnx2fc_interface
*interface
= fcoe_ctlr_priv(ctlr
);
2062 if (interface
->enabled
== false) {
2064 pr_err(PFX
"__bnx2fc_enable: lport not found\n");
2066 } else if (!bnx2fc_link_ok(ctlr
->lp
)) {
2067 fcoe_ctlr_link_up(ctlr
);
2068 interface
->enabled
= true;
2075 * Deprecated: Use bnx2fc_enabled()
2077 static int bnx2fc_enable(struct net_device
*netdev
)
2079 struct bnx2fc_interface
*interface
;
2080 struct fcoe_ctlr
*ctlr
;
2084 mutex_lock(&bnx2fc_dev_lock
);
2086 interface
= bnx2fc_interface_lookup(netdev
);
2087 ctlr
= bnx2fc_to_ctlr(interface
);
2090 pr_err(PFX
"bnx2fc_enable: interface not found\n");
2092 rc
= __bnx2fc_enable(ctlr
);
2095 mutex_unlock(&bnx2fc_dev_lock
);
2101 * bnx2fc_ctlr_enabled() - Enable or disable an FCoE Controller
2102 * @cdev: The FCoE Controller that is being enabled or disabled
2104 * fcoe_sysfs will ensure that the state of 'enabled' has
2105 * changed, so no checking is necessary here. This routine simply
2106 * calls fcoe_enable or fcoe_disable, both of which are deprecated.
2107 * When those routines are removed the functionality can be merged
2110 static int bnx2fc_ctlr_enabled(struct fcoe_ctlr_device
*cdev
)
2112 struct fcoe_ctlr
*ctlr
= fcoe_ctlr_device_priv(cdev
);
2114 switch (cdev
->enabled
) {
2115 case FCOE_CTLR_ENABLED
:
2116 return __bnx2fc_enable(ctlr
);
2117 case FCOE_CTLR_DISABLED
:
2118 return __bnx2fc_disable(ctlr
);
2119 case FCOE_CTLR_UNUSED
:
2125 enum bnx2fc_create_link_state
{
2126 BNX2FC_CREATE_LINK_DOWN
,
2127 BNX2FC_CREATE_LINK_UP
,
2131 * _bnx2fc_create() - Create bnx2fc FCoE interface
2132 * @netdev : The net_device object the Ethernet interface to create on
2133 * @fip_mode: The FIP mode for this creation
2134 * @link_state: The ctlr link state on creation
2136 * Called from either the libfcoe 'create' module parameter
2137 * via fcoe_create or from fcoe_syfs's ctlr_create file.
2139 * libfcoe's 'create' module parameter is deprecated so some
2140 * consolidation of code can be done when that interface is
2143 * Returns: 0 for success
2145 static int _bnx2fc_create(struct net_device
*netdev
,
2146 enum fip_state fip_mode
,
2147 enum bnx2fc_create_link_state link_state
)
2149 struct fcoe_ctlr_device
*cdev
;
2150 struct fcoe_ctlr
*ctlr
;
2151 struct bnx2fc_interface
*interface
;
2152 struct bnx2fc_hba
*hba
;
2153 struct net_device
*phys_dev
= netdev
;
2154 struct fc_lport
*lport
;
2155 struct ethtool_drvinfo drvinfo
;
2159 BNX2FC_MISC_DBG("Entered bnx2fc_create\n");
2160 if (fip_mode
!= FIP_MODE_FABRIC
) {
2161 printk(KERN_ERR
"fip mode not FABRIC\n");
2167 mutex_lock(&bnx2fc_dev_lock
);
2169 if (!try_module_get(THIS_MODULE
)) {
2174 /* obtain physical netdev */
2175 if (netdev
->priv_flags
& IFF_802_1Q_VLAN
)
2176 phys_dev
= vlan_dev_real_dev(netdev
);
2178 /* verify if the physical device is a netxtreme2 device */
2179 if (phys_dev
->ethtool_ops
&& phys_dev
->ethtool_ops
->get_drvinfo
) {
2180 memset(&drvinfo
, 0, sizeof(drvinfo
));
2181 phys_dev
->ethtool_ops
->get_drvinfo(phys_dev
, &drvinfo
);
2182 if (strncmp(drvinfo
.driver
, "bnx2x", strlen("bnx2x"))) {
2183 printk(KERN_ERR PFX
"Not a netxtreme2 device\n");
2188 printk(KERN_ERR PFX
"unable to obtain drv_info\n");
2193 /* obtain interface and initialize rest of the structure */
2194 hba
= bnx2fc_hba_lookup(phys_dev
);
2197 printk(KERN_ERR PFX
"bnx2fc_create: hba not found\n");
2201 if (bnx2fc_interface_lookup(netdev
)) {
2206 interface
= bnx2fc_interface_create(hba
, netdev
, fip_mode
);
2208 printk(KERN_ERR PFX
"bnx2fc_interface_create failed\n");
2212 if (netdev
->priv_flags
& IFF_802_1Q_VLAN
) {
2213 vlan_id
= vlan_dev_vlan_id(netdev
);
2214 interface
->vlan_enabled
= 1;
2217 ctlr
= bnx2fc_to_ctlr(interface
);
2218 cdev
= fcoe_ctlr_to_ctlr_dev(ctlr
);
2219 interface
->vlan_id
= vlan_id
;
2221 interface
->timer_work_queue
=
2222 create_singlethread_workqueue("bnx2fc_timer_wq");
2223 if (!interface
->timer_work_queue
) {
2224 printk(KERN_ERR PFX
"ulp_init could not create timer_wq\n");
2229 lport
= bnx2fc_if_create(interface
, &cdev
->dev
, 0);
2231 printk(KERN_ERR PFX
"Failed to create interface (%s)\n",
2237 /* Add interface to if_list */
2238 list_add_tail(&interface
->list
, &if_list
);
2240 lport
->boot_time
= jiffies
;
2242 /* Make this master N_port */
2245 if (link_state
== BNX2FC_CREATE_LINK_UP
)
2246 cdev
->enabled
= FCOE_CTLR_ENABLED
;
2248 cdev
->enabled
= FCOE_CTLR_DISABLED
;
2250 if (link_state
== BNX2FC_CREATE_LINK_UP
&&
2251 !bnx2fc_link_ok(lport
)) {
2252 fcoe_ctlr_link_up(ctlr
);
2253 fc_host_port_type(lport
->host
) = FC_PORTTYPE_NPORT
;
2254 set_bit(ADAPTER_STATE_READY
, &interface
->hba
->adapter_state
);
2257 BNX2FC_HBA_DBG(lport
, "create: START DISC\n");
2258 bnx2fc_start_disc(interface
);
2260 if (link_state
== BNX2FC_CREATE_LINK_UP
)
2261 interface
->enabled
= true;
2264 * Release from kref_init in bnx2fc_interface_setup, on success
2265 * lport should be holding a reference taken in bnx2fc_if_create
2267 bnx2fc_interface_put(interface
);
2268 /* put netdev that was held while calling dev_get_by_name */
2269 mutex_unlock(&bnx2fc_dev_lock
);
2274 destroy_workqueue(interface
->timer_work_queue
);
2276 bnx2fc_net_cleanup(interface
);
2277 bnx2fc_interface_put(interface
);
2280 module_put(THIS_MODULE
);
2282 mutex_unlock(&bnx2fc_dev_lock
);
2288 * bnx2fc_create() - Create a bnx2fc interface
2289 * @netdev : The net_device object the Ethernet interface to create on
2290 * @fip_mode: The FIP mode for this creation
2292 * Called from fcoe transport
2294 * Returns: 0 for success
2296 static int bnx2fc_create(struct net_device
*netdev
, enum fip_state fip_mode
)
2298 return _bnx2fc_create(netdev
, fip_mode
, BNX2FC_CREATE_LINK_UP
);
2302 * bnx2fc_ctlr_alloc() - Allocate a bnx2fc interface from fcoe_sysfs
2303 * @netdev: The net_device to be used by the allocated FCoE Controller
2305 * This routine is called from fcoe_sysfs. It will start the fcoe_ctlr
2306 * in a link_down state. The allows the user an opportunity to configure
2307 * the FCoE Controller from sysfs before enabling the FCoE Controller.
2309 * Creating in with this routine starts the FCoE Controller in Fabric
2310 * mode. The user can change to VN2VN or another mode before enabling.
2312 static int bnx2fc_ctlr_alloc(struct net_device
*netdev
)
2314 return _bnx2fc_create(netdev
, FIP_MODE_FABRIC
,
2315 BNX2FC_CREATE_LINK_DOWN
);
2319 * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
2321 * @cnic: Pointer to cnic device instance
2324 static struct bnx2fc_hba
*bnx2fc_find_hba_for_cnic(struct cnic_dev
*cnic
)
2326 struct bnx2fc_hba
*hba
;
2328 /* Called with bnx2fc_dev_lock held */
2329 list_for_each_entry(hba
, &adapter_list
, list
) {
2330 if (hba
->cnic
== cnic
)
2336 static struct bnx2fc_interface
*bnx2fc_interface_lookup(struct net_device
2339 struct bnx2fc_interface
*interface
;
2341 /* Called with bnx2fc_dev_lock held */
2342 list_for_each_entry(interface
, &if_list
, list
) {
2343 if (interface
->netdev
== netdev
)
2349 static struct bnx2fc_hba
*bnx2fc_hba_lookup(struct net_device
2352 struct bnx2fc_hba
*hba
;
2354 /* Called with bnx2fc_dev_lock held */
2355 list_for_each_entry(hba
, &adapter_list
, list
) {
2356 if (hba
->phys_dev
== phys_dev
)
2359 printk(KERN_ERR PFX
"adapter_lookup: hba NULL\n");
2364 * bnx2fc_ulp_exit - shuts down adapter instance and frees all resources
2366 * @dev cnic device handle
2368 static void bnx2fc_ulp_exit(struct cnic_dev
*dev
)
2370 struct bnx2fc_hba
*hba
;
2371 struct bnx2fc_interface
*interface
, *tmp
;
2373 BNX2FC_MISC_DBG("Entered bnx2fc_ulp_exit\n");
2375 if (!test_bit(CNIC_F_BNX2X_CLASS
, &dev
->flags
)) {
2376 printk(KERN_ERR PFX
"bnx2fc port check: %s, flags: %lx\n",
2377 dev
->netdev
->name
, dev
->flags
);
2381 mutex_lock(&bnx2fc_dev_lock
);
2382 hba
= bnx2fc_find_hba_for_cnic(dev
);
2384 printk(KERN_ERR PFX
"bnx2fc_ulp_exit: hba not found, dev 0%p\n",
2386 mutex_unlock(&bnx2fc_dev_lock
);
2390 list_del_init(&hba
->list
);
2393 list_for_each_entry_safe(interface
, tmp
, &if_list
, list
)
2394 /* destroy not called yet, move to quiesced list */
2395 if (interface
->hba
== hba
)
2396 __bnx2fc_destroy(interface
);
2397 mutex_unlock(&bnx2fc_dev_lock
);
2399 bnx2fc_ulp_stop(hba
);
2400 /* unregister cnic device */
2401 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED
, &hba
->reg_with_cnic
))
2402 hba
->cnic
->unregister_device(hba
->cnic
, CNIC_ULP_FCOE
);
2403 bnx2fc_hba_destroy(hba
);
2407 * bnx2fc_fcoe_reset - Resets the fcoe
2409 * @shost: shost the reset is from
2413 static int bnx2fc_fcoe_reset(struct Scsi_Host
*shost
)
2415 struct fc_lport
*lport
= shost_priv(shost
);
2416 fc_lport_reset(lport
);
2421 static bool bnx2fc_match(struct net_device
*netdev
)
2423 struct net_device
*phys_dev
= netdev
;
2425 mutex_lock(&bnx2fc_dev_lock
);
2426 if (netdev
->priv_flags
& IFF_802_1Q_VLAN
)
2427 phys_dev
= vlan_dev_real_dev(netdev
);
2429 if (bnx2fc_hba_lookup(phys_dev
)) {
2430 mutex_unlock(&bnx2fc_dev_lock
);
2434 mutex_unlock(&bnx2fc_dev_lock
);
2439 static struct fcoe_transport bnx2fc_transport
= {
2442 .list
= LIST_HEAD_INIT(bnx2fc_transport
.list
),
2443 .alloc
= bnx2fc_ctlr_alloc
,
2444 .match
= bnx2fc_match
,
2445 .create
= bnx2fc_create
,
2446 .destroy
= bnx2fc_destroy
,
2447 .enable
= bnx2fc_enable
,
2448 .disable
= bnx2fc_disable
,
2452 * bnx2fc_percpu_thread_create - Create a receive thread for an
2455 * @cpu: cpu index for the online cpu
2457 static void bnx2fc_percpu_thread_create(unsigned int cpu
)
2459 struct bnx2fc_percpu_s
*p
;
2460 struct task_struct
*thread
;
2462 p
= &per_cpu(bnx2fc_percpu
, cpu
);
2464 thread
= kthread_create_on_node(bnx2fc_percpu_io_thread
,
2465 (void *)p
, cpu_to_node(cpu
),
2466 "bnx2fc_thread/%d", cpu
);
2467 /* bind thread to the cpu */
2468 if (likely(!IS_ERR(thread
))) {
2469 kthread_bind(thread
, cpu
);
2470 p
->iothread
= thread
;
2471 wake_up_process(thread
);
2475 static void bnx2fc_percpu_thread_destroy(unsigned int cpu
)
2477 struct bnx2fc_percpu_s
*p
;
2478 struct task_struct
*thread
;
2479 struct bnx2fc_work
*work
, *tmp
;
2481 BNX2FC_MISC_DBG("destroying io thread for CPU %d\n", cpu
);
2483 /* Prevent any new work from being queued for this CPU */
2484 p
= &per_cpu(bnx2fc_percpu
, cpu
);
2485 spin_lock_bh(&p
->fp_work_lock
);
2486 thread
= p
->iothread
;
2490 /* Free all work in the list */
2491 list_for_each_entry_safe(work
, tmp
, &p
->work_list
, list
) {
2492 list_del_init(&work
->list
);
2493 bnx2fc_process_cq_compl(work
->tgt
, work
->wqe
);
2497 spin_unlock_bh(&p
->fp_work_lock
);
2500 kthread_stop(thread
);
2504 * bnx2fc_cpu_callback - Handler for CPU hotplug events
2506 * @nfb: The callback data block
2507 * @action: The event triggering the callback
2508 * @hcpu: The index of the CPU that the event is for
2510 * This creates or destroys per-CPU data for fcoe
2512 * Returns NOTIFY_OK always.
2514 static int bnx2fc_cpu_callback(struct notifier_block
*nfb
,
2515 unsigned long action
, void *hcpu
)
2517 unsigned cpu
= (unsigned long)hcpu
;
2521 case CPU_ONLINE_FROZEN
:
2522 printk(PFX
"CPU %x online: Create Rx thread\n", cpu
);
2523 bnx2fc_percpu_thread_create(cpu
);
2526 case CPU_DEAD_FROZEN
:
2527 printk(PFX
"CPU %x offline: Remove Rx thread\n", cpu
);
2528 bnx2fc_percpu_thread_destroy(cpu
);
2537 * bnx2fc_mod_init - module init entry point
2539 * Initialize driver wide global data structures, and register
2542 static int __init
bnx2fc_mod_init(void)
2544 struct fcoe_percpu_s
*bg
;
2545 struct task_struct
*l2_thread
;
2547 unsigned int cpu
= 0;
2548 struct bnx2fc_percpu_s
*p
;
2550 printk(KERN_INFO PFX
"%s", version
);
2552 /* register as a fcoe transport */
2553 rc
= fcoe_transport_attach(&bnx2fc_transport
);
2555 printk(KERN_ERR
"failed to register an fcoe transport, check "
2556 "if libfcoe is loaded\n");
2560 INIT_LIST_HEAD(&adapter_list
);
2561 INIT_LIST_HEAD(&if_list
);
2562 mutex_init(&bnx2fc_dev_lock
);
2565 /* Attach FC transport template */
2566 rc
= bnx2fc_attach_transport();
2570 bnx2fc_wq
= alloc_workqueue("bnx2fc", 0, 0);
2576 bg
= &bnx2fc_global
;
2577 skb_queue_head_init(&bg
->fcoe_rx_list
);
2578 l2_thread
= kthread_create(bnx2fc_l2_rcv_thread
,
2580 "bnx2fc_l2_thread");
2581 if (IS_ERR(l2_thread
)) {
2582 rc
= PTR_ERR(l2_thread
);
2585 wake_up_process(l2_thread
);
2586 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
2587 bg
->thread
= l2_thread
;
2588 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
2590 for_each_possible_cpu(cpu
) {
2591 p
= &per_cpu(bnx2fc_percpu
, cpu
);
2592 INIT_LIST_HEAD(&p
->work_list
);
2593 spin_lock_init(&p
->fp_work_lock
);
2596 for_each_online_cpu(cpu
) {
2597 bnx2fc_percpu_thread_create(cpu
);
2600 /* Initialize per CPU interrupt thread */
2601 register_hotcpu_notifier(&bnx2fc_cpu_notifier
);
2603 cnic_register_driver(CNIC_ULP_FCOE
, &bnx2fc_cnic_cb
);
2608 destroy_workqueue(bnx2fc_wq
);
2610 bnx2fc_release_transport();
2612 fcoe_transport_detach(&bnx2fc_transport
);
2617 static void __exit
bnx2fc_mod_exit(void)
2619 LIST_HEAD(to_be_deleted
);
2620 struct bnx2fc_hba
*hba
, *next
;
2621 struct fcoe_percpu_s
*bg
;
2622 struct task_struct
*l2_thread
;
2623 struct sk_buff
*skb
;
2624 unsigned int cpu
= 0;
2627 * NOTE: Since cnic calls register_driver routine rtnl_lock,
2628 * it will have higher precedence than bnx2fc_dev_lock.
2629 * unregister_device() cannot be called with bnx2fc_dev_lock
2632 mutex_lock(&bnx2fc_dev_lock
);
2633 list_splice(&adapter_list
, &to_be_deleted
);
2634 INIT_LIST_HEAD(&adapter_list
);
2636 mutex_unlock(&bnx2fc_dev_lock
);
2638 /* Unregister with cnic */
2639 list_for_each_entry_safe(hba
, next
, &to_be_deleted
, list
) {
2640 list_del_init(&hba
->list
);
2641 printk(KERN_ERR PFX
"MOD_EXIT:destroy hba = 0x%p\n",
2643 bnx2fc_ulp_stop(hba
);
2644 /* unregister cnic device */
2645 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED
,
2646 &hba
->reg_with_cnic
))
2647 hba
->cnic
->unregister_device(hba
->cnic
,
2649 bnx2fc_hba_destroy(hba
);
2651 cnic_unregister_driver(CNIC_ULP_FCOE
);
2653 /* Destroy global thread */
2654 bg
= &bnx2fc_global
;
2655 spin_lock_bh(&bg
->fcoe_rx_list
.lock
);
2656 l2_thread
= bg
->thread
;
2658 while ((skb
= __skb_dequeue(&bg
->fcoe_rx_list
)) != NULL
)
2661 spin_unlock_bh(&bg
->fcoe_rx_list
.lock
);
2664 kthread_stop(l2_thread
);
2666 unregister_hotcpu_notifier(&bnx2fc_cpu_notifier
);
2668 /* Destroy per cpu threads */
2669 for_each_online_cpu(cpu
) {
2670 bnx2fc_percpu_thread_destroy(cpu
);
2673 destroy_workqueue(bnx2fc_wq
);
2675 * detach from scsi transport
2676 * must happen after all destroys are done
2678 bnx2fc_release_transport();
2680 /* detach from fcoe transport */
2681 fcoe_transport_detach(&bnx2fc_transport
);
2684 module_init(bnx2fc_mod_init
);
2685 module_exit(bnx2fc_mod_exit
);
2687 static struct fcoe_sysfs_function_template bnx2fc_fcoe_sysfs_templ
= {
2688 .set_fcoe_ctlr_enabled
= bnx2fc_ctlr_enabled
,
2689 .get_fcoe_ctlr_link_fail
= fcoe_ctlr_get_lesb
,
2690 .get_fcoe_ctlr_vlink_fail
= fcoe_ctlr_get_lesb
,
2691 .get_fcoe_ctlr_miss_fka
= fcoe_ctlr_get_lesb
,
2692 .get_fcoe_ctlr_symb_err
= fcoe_ctlr_get_lesb
,
2693 .get_fcoe_ctlr_err_block
= fcoe_ctlr_get_lesb
,
2694 .get_fcoe_ctlr_fcs_error
= fcoe_ctlr_get_lesb
,
2696 .get_fcoe_fcf_selected
= fcoe_fcf_get_selected
,
2697 .get_fcoe_fcf_vlan_id
= bnx2fc_fcf_get_vlan_id
,
2700 static struct fc_function_template bnx2fc_transport_function
= {
2701 .show_host_node_name
= 1,
2702 .show_host_port_name
= 1,
2703 .show_host_supported_classes
= 1,
2704 .show_host_supported_fc4s
= 1,
2705 .show_host_active_fc4s
= 1,
2706 .show_host_maxframe_size
= 1,
2708 .show_host_port_id
= 1,
2709 .show_host_supported_speeds
= 1,
2710 .get_host_speed
= fc_get_host_speed
,
2711 .show_host_speed
= 1,
2712 .show_host_port_type
= 1,
2713 .get_host_port_state
= fc_get_host_port_state
,
2714 .show_host_port_state
= 1,
2715 .show_host_symbolic_name
= 1,
2717 .dd_fcrport_size
= (sizeof(struct fc_rport_libfc_priv
) +
2718 sizeof(struct bnx2fc_rport
)),
2719 .show_rport_maxframe_size
= 1,
2720 .show_rport_supported_classes
= 1,
2722 .show_host_fabric_name
= 1,
2723 .show_starget_node_name
= 1,
2724 .show_starget_port_name
= 1,
2725 .show_starget_port_id
= 1,
2726 .set_rport_dev_loss_tmo
= fc_set_rport_loss_tmo
,
2727 .show_rport_dev_loss_tmo
= 1,
2728 .get_fc_host_stats
= bnx2fc_get_host_stats
,
2730 .issue_fc_host_lip
= bnx2fc_fcoe_reset
,
2732 .terminate_rport_io
= fc_rport_terminate_io
,
2734 .vport_create
= bnx2fc_vport_create
,
2735 .vport_delete
= bnx2fc_vport_destroy
,
2736 .vport_disable
= bnx2fc_vport_disable
,
2737 .bsg_request
= fc_lport_bsg_request
,
2740 static struct fc_function_template bnx2fc_vport_xport_function
= {
2741 .show_host_node_name
= 1,
2742 .show_host_port_name
= 1,
2743 .show_host_supported_classes
= 1,
2744 .show_host_supported_fc4s
= 1,
2745 .show_host_active_fc4s
= 1,
2746 .show_host_maxframe_size
= 1,
2748 .show_host_port_id
= 1,
2749 .show_host_supported_speeds
= 1,
2750 .get_host_speed
= fc_get_host_speed
,
2751 .show_host_speed
= 1,
2752 .show_host_port_type
= 1,
2753 .get_host_port_state
= fc_get_host_port_state
,
2754 .show_host_port_state
= 1,
2755 .show_host_symbolic_name
= 1,
2757 .dd_fcrport_size
= (sizeof(struct fc_rport_libfc_priv
) +
2758 sizeof(struct bnx2fc_rport
)),
2759 .show_rport_maxframe_size
= 1,
2760 .show_rport_supported_classes
= 1,
2762 .show_host_fabric_name
= 1,
2763 .show_starget_node_name
= 1,
2764 .show_starget_port_name
= 1,
2765 .show_starget_port_id
= 1,
2766 .set_rport_dev_loss_tmo
= fc_set_rport_loss_tmo
,
2767 .show_rport_dev_loss_tmo
= 1,
2768 .get_fc_host_stats
= fc_get_host_stats
,
2769 .issue_fc_host_lip
= bnx2fc_fcoe_reset
,
2770 .terminate_rport_io
= fc_rport_terminate_io
,
2771 .bsg_request
= fc_lport_bsg_request
,
2775 * scsi_host_template structure used while registering with SCSI-ml
2777 static struct scsi_host_template bnx2fc_shost_template
= {
2778 .module
= THIS_MODULE
,
2779 .name
= "Broadcom Offload FCoE Initiator",
2780 .queuecommand
= bnx2fc_queuecommand
,
2781 .eh_abort_handler
= bnx2fc_eh_abort
, /* abts */
2782 .eh_device_reset_handler
= bnx2fc_eh_device_reset
, /* lun reset */
2783 .eh_target_reset_handler
= bnx2fc_eh_target_reset
, /* tgt reset */
2784 .eh_host_reset_handler
= fc_eh_host_reset
,
2785 .slave_alloc
= fc_slave_alloc
,
2786 .change_queue_depth
= fc_change_queue_depth
,
2787 .change_queue_type
= fc_change_queue_type
,
2790 .use_clustering
= ENABLE_CLUSTERING
,
2791 .sg_tablesize
= BNX2FC_MAX_BDS_PER_CMD
,
2792 .max_sectors
= 1024,
2795 static struct libfc_function_template bnx2fc_libfc_fcn_templ
= {
2796 .frame_send
= bnx2fc_xmit
,
2797 .elsct_send
= bnx2fc_elsct_send
,
2798 .fcp_abort_io
= bnx2fc_abort_io
,
2799 .fcp_cleanup
= bnx2fc_cleanup
,
2800 .get_lesb
= fcoe_get_lesb
,
2801 .rport_event_callback
= bnx2fc_rport_event_handler
,
2805 * bnx2fc_cnic_cb - global template of bnx2fc - cnic driver interface
2806 * structure carrying callback function pointers
2808 static struct cnic_ulp_ops bnx2fc_cnic_cb
= {
2809 .owner
= THIS_MODULE
,
2810 .cnic_init
= bnx2fc_ulp_init
,
2811 .cnic_exit
= bnx2fc_ulp_exit
,
2812 .cnic_start
= bnx2fc_ulp_start
,
2813 .cnic_stop
= bnx2fc_ulp_stop
,
2814 .indicate_kcqes
= bnx2fc_indicate_kcqe
,
2815 .indicate_netevent
= bnx2fc_indicate_netevent
,
2816 .cnic_get_stats
= bnx2fc_ulp_get_stats
,