diff options
author | Bhanu Prakash Gollapudi <bprakash@broadcom.com> | 2011-07-26 17:51:39 -0400 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2011-07-27 07:37:31 -0400 |
commit | aea71a024914e8b5b8bed31256dae42195a0a207 (patch) | |
tree | d3d155d7323966a56425ad68837b924816719c89 /drivers/scsi/bnx2fc/bnx2fc_fcoe.c | |
parent | f6e76055ba778c56716ba79e106db28297775e87 (diff) |
[SCSI] bnx2fc: Introduce interface structure for each vlan interface
Currently, bnx2fc has a hba structure that can work with only a single vlan
interface. When there is a change in vlan id, it does not have the capability
to switch to different vlan interface. To solve this problem, a new structure
called 'interface' has been introduced, and each hba can now have multiple
interfaces, one per vlan id.
Most of the patch is a moving the interface specific fields from hba to the
interface structure, and appropriately modifying the dereferences. A list of
interfaces (if_list) is maintained along with adapter list. During a create
call, the interface structure is allocated and added to if_list and deleted &
freed on a destroy call. Link events are propagated to all interfaces
belonging to the hba.
Signed-off-by: Bhanu Prakash Gollapudi <bprakash@broadcom.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi/bnx2fc/bnx2fc_fcoe.c')
-rw-r--r-- | drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 716 |
1 files changed, 337 insertions, 379 deletions
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index e70452174f20..65561fcaad03 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include "bnx2fc.h" | 15 | #include "bnx2fc.h" |
16 | 16 | ||
17 | static struct list_head adapter_list; | 17 | static struct list_head adapter_list; |
18 | static struct list_head if_list; | ||
18 | static u32 adapter_count; | 19 | static u32 adapter_count; |
19 | static DEFINE_MUTEX(bnx2fc_dev_lock); | 20 | static DEFINE_MUTEX(bnx2fc_dev_lock); |
20 | DEFINE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu); | 21 | DEFINE_PER_CPU(struct bnx2fc_percpu_s, bnx2fc_percpu); |
@@ -61,7 +62,7 @@ static int bnx2fc_disable(struct net_device *netdev); | |||
61 | 62 | ||
62 | static void bnx2fc_recv_frame(struct sk_buff *skb); | 63 | static void bnx2fc_recv_frame(struct sk_buff *skb); |
63 | 64 | ||
64 | static void bnx2fc_start_disc(struct bnx2fc_hba *hba); | 65 | static void bnx2fc_start_disc(struct bnx2fc_interface *interface); |
65 | static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev); | 66 | static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev); |
66 | static int bnx2fc_net_config(struct fc_lport *lp); | 67 | static int bnx2fc_net_config(struct fc_lport *lp); |
67 | static int bnx2fc_lport_config(struct fc_lport *lport); | 68 | static int bnx2fc_lport_config(struct fc_lport *lport); |
@@ -70,18 +71,20 @@ static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba); | |||
70 | static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba); | 71 | static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba); |
71 | static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba); | 72 | static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba); |
72 | static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba); | 73 | static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba); |
73 | static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba, | 74 | static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface, |
74 | struct device *parent, int npiv); | 75 | struct device *parent, int npiv); |
75 | static void bnx2fc_destroy_work(struct work_struct *work); | 76 | static void bnx2fc_destroy_work(struct work_struct *work); |
76 | 77 | ||
77 | static struct bnx2fc_hba *bnx2fc_hba_lookup(struct net_device *phys_dev); | 78 | static struct bnx2fc_hba *bnx2fc_hba_lookup(struct net_device *phys_dev); |
79 | static struct bnx2fc_interface *bnx2fc_interface_lookup(struct net_device | ||
80 | *phys_dev); | ||
78 | static struct bnx2fc_hba *bnx2fc_find_hba_for_cnic(struct cnic_dev *cnic); | 81 | static struct bnx2fc_hba *bnx2fc_find_hba_for_cnic(struct cnic_dev *cnic); |
79 | 82 | ||
80 | static int bnx2fc_fw_init(struct bnx2fc_hba *hba); | 83 | static int bnx2fc_fw_init(struct bnx2fc_hba *hba); |
81 | static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba); | 84 | static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba); |
82 | 85 | ||
83 | static void bnx2fc_port_shutdown(struct fc_lport *lport); | 86 | static void bnx2fc_port_shutdown(struct fc_lport *lport); |
84 | static void bnx2fc_stop(struct bnx2fc_hba *hba); | 87 | static void bnx2fc_stop(struct bnx2fc_interface *interface); |
85 | static int __init bnx2fc_mod_init(void); | 88 | static int __init bnx2fc_mod_init(void); |
86 | static void __exit bnx2fc_mod_exit(void); | 89 | static void __exit bnx2fc_mod_exit(void); |
87 | 90 | ||
@@ -142,7 +145,8 @@ static void bnx2fc_abort_io(struct fc_lport *lport) | |||
142 | static void bnx2fc_cleanup(struct fc_lport *lport) | 145 | static void bnx2fc_cleanup(struct fc_lport *lport) |
143 | { | 146 | { |
144 | struct fcoe_port *port = lport_priv(lport); | 147 | struct fcoe_port *port = lport_priv(lport); |
145 | struct bnx2fc_hba *hba = port->priv; | 148 | struct bnx2fc_interface *interface = port->priv; |
149 | struct bnx2fc_hba *hba = interface->hba; | ||
146 | struct bnx2fc_rport *tgt; | 150 | struct bnx2fc_rport *tgt; |
147 | int i; | 151 | int i; |
148 | 152 | ||
@@ -219,7 +223,8 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) | |||
219 | struct fcoe_crc_eof *cp; | 223 | struct fcoe_crc_eof *cp; |
220 | struct sk_buff *skb; | 224 | struct sk_buff *skb; |
221 | struct fc_frame_header *fh; | 225 | struct fc_frame_header *fh; |
222 | struct bnx2fc_hba *hba; | 226 | struct bnx2fc_interface *interface; |
227 | struct bnx2fc_hba *hba; | ||
223 | struct fcoe_port *port; | 228 | struct fcoe_port *port; |
224 | struct fcoe_hdr *hp; | 229 | struct fcoe_hdr *hp; |
225 | struct bnx2fc_rport *tgt; | 230 | struct bnx2fc_rport *tgt; |
@@ -230,7 +235,8 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) | |||
230 | int wlen, rc = 0; | 235 | int wlen, rc = 0; |
231 | 236 | ||
232 | port = (struct fcoe_port *)lport_priv(lport); | 237 | port = (struct fcoe_port *)lport_priv(lport); |
233 | hba = port->priv; | 238 | interface = port->priv; |
239 | hba = interface->hba; | ||
234 | 240 | ||
235 | fh = fc_frame_header_get(fp); | 241 | fh = fc_frame_header_get(fp); |
236 | 242 | ||
@@ -242,12 +248,12 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) | |||
242 | } | 248 | } |
243 | 249 | ||
244 | if (unlikely(fh->fh_r_ctl == FC_RCTL_ELS_REQ)) { | 250 | if (unlikely(fh->fh_r_ctl == FC_RCTL_ELS_REQ)) { |
245 | if (!hba->ctlr.sel_fcf) { | 251 | if (!interface->ctlr.sel_fcf) { |
246 | BNX2FC_HBA_DBG(lport, "FCF not selected yet!\n"); | 252 | BNX2FC_HBA_DBG(lport, "FCF not selected yet!\n"); |
247 | kfree_skb(skb); | 253 | kfree_skb(skb); |
248 | return -EINVAL; | 254 | return -EINVAL; |
249 | } | 255 | } |
250 | if (fcoe_ctlr_els_send(&hba->ctlr, lport, skb)) | 256 | if (fcoe_ctlr_els_send(&interface->ctlr, lport, skb)) |
251 | return 0; | 257 | return 0; |
252 | } | 258 | } |
253 | 259 | ||
@@ -316,19 +322,19 @@ static int bnx2fc_xmit(struct fc_lport *lport, struct fc_frame *fp) | |||
316 | skb_reset_network_header(skb); | 322 | skb_reset_network_header(skb); |
317 | skb->mac_len = elen; | 323 | skb->mac_len = elen; |
318 | skb->protocol = htons(ETH_P_FCOE); | 324 | skb->protocol = htons(ETH_P_FCOE); |
319 | skb->dev = hba->netdev; | 325 | skb->dev = interface->netdev; |
320 | 326 | ||
321 | /* fill up mac and fcoe headers */ | 327 | /* fill up mac and fcoe headers */ |
322 | eh = eth_hdr(skb); | 328 | eh = eth_hdr(skb); |
323 | eh->h_proto = htons(ETH_P_FCOE); | 329 | eh->h_proto = htons(ETH_P_FCOE); |
324 | if (hba->ctlr.map_dest) | 330 | if (interface->ctlr.map_dest) |
325 | fc_fcoe_set_mac(eh->h_dest, fh->fh_d_id); | 331 | fc_fcoe_set_mac(eh->h_dest, fh->fh_d_id); |
326 | else | 332 | else |
327 | /* insert GW address */ | 333 | /* insert GW address */ |
328 | memcpy(eh->h_dest, hba->ctlr.dest_addr, ETH_ALEN); | 334 | memcpy(eh->h_dest, interface->ctlr.dest_addr, ETH_ALEN); |
329 | 335 | ||
330 | if (unlikely(hba->ctlr.flogi_oxid != FC_XID_UNKNOWN)) | 336 | if (unlikely(interface->ctlr.flogi_oxid != FC_XID_UNKNOWN)) |
331 | memcpy(eh->h_source, hba->ctlr.ctl_src_addr, ETH_ALEN); | 337 | memcpy(eh->h_source, interface->ctlr.ctl_src_addr, ETH_ALEN); |
332 | else | 338 | else |
333 | memcpy(eh->h_source, port->data_src_addr, ETH_ALEN); | 339 | memcpy(eh->h_source, port->data_src_addr, ETH_ALEN); |
334 | 340 | ||
@@ -377,14 +383,15 @@ static int bnx2fc_rcv(struct sk_buff *skb, struct net_device *dev, | |||
377 | struct packet_type *ptype, struct net_device *olddev) | 383 | struct packet_type *ptype, struct net_device *olddev) |
378 | { | 384 | { |
379 | struct fc_lport *lport; | 385 | struct fc_lport *lport; |
380 | struct bnx2fc_hba *hba; | 386 | struct bnx2fc_interface *interface; |
381 | struct fc_frame_header *fh; | 387 | struct fc_frame_header *fh; |
382 | struct fcoe_rcv_info *fr; | 388 | struct fcoe_rcv_info *fr; |
383 | struct fcoe_percpu_s *bg; | 389 | struct fcoe_percpu_s *bg; |
384 | unsigned short oxid; | 390 | unsigned short oxid; |
385 | 391 | ||
386 | hba = container_of(ptype, struct bnx2fc_hba, fcoe_packet_type); | 392 | interface = container_of(ptype, struct bnx2fc_interface, |
387 | lport = hba->ctlr.lp; | 393 | fcoe_packet_type); |
394 | lport = interface->ctlr.lp; | ||
388 | 395 | ||
389 | if (unlikely(lport == NULL)) { | 396 | if (unlikely(lport == NULL)) { |
390 | printk(KERN_ERR PFX "bnx2fc_rcv: lport is NULL\n"); | 397 | printk(KERN_ERR PFX "bnx2fc_rcv: lport is NULL\n"); |
@@ -594,7 +601,8 @@ static struct fc_host_statistics *bnx2fc_get_host_stats(struct Scsi_Host *shost) | |||
594 | struct fc_host_statistics *bnx2fc_stats; | 601 | struct fc_host_statistics *bnx2fc_stats; |
595 | struct fc_lport *lport = shost_priv(shost); | 602 | struct fc_lport *lport = shost_priv(shost); |
596 | struct fcoe_port *port = lport_priv(lport); | 603 | struct fcoe_port *port = lport_priv(lport); |
597 | struct bnx2fc_hba *hba = port->priv; | 604 | struct bnx2fc_interface *interface = port->priv; |
605 | struct bnx2fc_hba *hba = interface->hba; | ||
598 | struct fcoe_statistics_params *fw_stats; | 606 | struct fcoe_statistics_params *fw_stats; |
599 | int rc = 0; | 607 | int rc = 0; |
600 | 608 | ||
@@ -631,7 +639,7 @@ static struct fc_host_statistics *bnx2fc_get_host_stats(struct Scsi_Host *shost) | |||
631 | static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev) | 639 | static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev) |
632 | { | 640 | { |
633 | struct fcoe_port *port = lport_priv(lport); | 641 | struct fcoe_port *port = lport_priv(lport); |
634 | struct bnx2fc_hba *hba = port->priv; | 642 | struct bnx2fc_interface *interface = port->priv; |
635 | struct Scsi_Host *shost = lport->host; | 643 | struct Scsi_Host *shost = lport->host; |
636 | int rc = 0; | 644 | int rc = 0; |
637 | 645 | ||
@@ -654,7 +662,7 @@ static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev) | |||
654 | fc_host_max_npiv_vports(lport->host) = USHRT_MAX; | 662 | fc_host_max_npiv_vports(lport->host) = USHRT_MAX; |
655 | sprintf(fc_host_symbolic_name(lport->host), "%s v%s over %s", | 663 | sprintf(fc_host_symbolic_name(lport->host), "%s v%s over %s", |
656 | BNX2FC_NAME, BNX2FC_VERSION, | 664 | BNX2FC_NAME, BNX2FC_VERSION, |
657 | hba->netdev->name); | 665 | interface->netdev->name); |
658 | 666 | ||
659 | return 0; | 667 | return 0; |
660 | } | 668 | } |
@@ -662,8 +670,8 @@ static int bnx2fc_shost_config(struct fc_lport *lport, struct device *dev) | |||
662 | static void bnx2fc_link_speed_update(struct fc_lport *lport) | 670 | static void bnx2fc_link_speed_update(struct fc_lport *lport) |
663 | { | 671 | { |
664 | struct fcoe_port *port = lport_priv(lport); | 672 | struct fcoe_port *port = lport_priv(lport); |
665 | struct bnx2fc_hba *hba = port->priv; | 673 | struct bnx2fc_interface *interface = port->priv; |
666 | struct net_device *netdev = hba->netdev; | 674 | struct net_device *netdev = interface->netdev; |
667 | struct ethtool_cmd ecmd; | 675 | struct ethtool_cmd ecmd; |
668 | 676 | ||
669 | if (!dev_ethtool_get_settings(netdev, &ecmd)) { | 677 | if (!dev_ethtool_get_settings(netdev, &ecmd)) { |
@@ -691,7 +699,8 @@ static void bnx2fc_link_speed_update(struct fc_lport *lport) | |||
691 | static int bnx2fc_link_ok(struct fc_lport *lport) | 699 | static int bnx2fc_link_ok(struct fc_lport *lport) |
692 | { | 700 | { |
693 | struct fcoe_port *port = lport_priv(lport); | 701 | struct fcoe_port *port = lport_priv(lport); |
694 | struct bnx2fc_hba *hba = port->priv; | 702 | struct bnx2fc_interface *interface = port->priv; |
703 | struct bnx2fc_hba *hba = interface->hba; | ||
695 | struct net_device *dev = hba->phys_dev; | 704 | struct net_device *dev = hba->phys_dev; |
696 | int rc = 0; | 705 | int rc = 0; |
697 | 706 | ||
@@ -713,7 +722,7 @@ static int bnx2fc_link_ok(struct fc_lport *lport) | |||
713 | */ | 722 | */ |
714 | void bnx2fc_get_link_state(struct bnx2fc_hba *hba) | 723 | void bnx2fc_get_link_state(struct bnx2fc_hba *hba) |
715 | { | 724 | { |
716 | if (test_bit(__LINK_STATE_NOCARRIER, &hba->netdev->state)) | 725 | if (test_bit(__LINK_STATE_NOCARRIER, &hba->phys_dev->state)) |
717 | set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); | 726 | set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); |
718 | else | 727 | else |
719 | clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); | 728 | clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); |
@@ -722,11 +731,13 @@ void bnx2fc_get_link_state(struct bnx2fc_hba *hba) | |||
722 | static int bnx2fc_net_config(struct fc_lport *lport) | 731 | static int bnx2fc_net_config(struct fc_lport *lport) |
723 | { | 732 | { |
724 | struct bnx2fc_hba *hba; | 733 | struct bnx2fc_hba *hba; |
734 | struct bnx2fc_interface *interface; | ||
725 | struct fcoe_port *port; | 735 | struct fcoe_port *port; |
726 | u64 wwnn, wwpn; | 736 | u64 wwnn, wwpn; |
727 | 737 | ||
728 | port = lport_priv(lport); | 738 | port = lport_priv(lport); |
729 | hba = port->priv; | 739 | interface = port->priv; |
740 | hba = interface->hba; | ||
730 | 741 | ||
731 | /* require support for get_pauseparam ethtool op. */ | 742 | /* require support for get_pauseparam ethtool op. */ |
732 | if (!hba->phys_dev->ethtool_ops || | 743 | if (!hba->phys_dev->ethtool_ops || |
@@ -743,11 +754,11 @@ static int bnx2fc_net_config(struct fc_lport *lport) | |||
743 | bnx2fc_link_speed_update(lport); | 754 | bnx2fc_link_speed_update(lport); |
744 | 755 | ||
745 | if (!lport->vport) { | 756 | if (!lport->vport) { |
746 | wwnn = fcoe_wwn_from_mac(hba->ctlr.ctl_src_addr, 1, 0); | 757 | wwnn = fcoe_wwn_from_mac(interface->ctlr.ctl_src_addr, 1, 0); |
747 | BNX2FC_HBA_DBG(lport, "WWNN = 0x%llx\n", wwnn); | 758 | BNX2FC_HBA_DBG(lport, "WWNN = 0x%llx\n", wwnn); |
748 | fc_set_wwnn(lport, wwnn); | 759 | fc_set_wwnn(lport, wwnn); |
749 | 760 | ||
750 | wwpn = fcoe_wwn_from_mac(hba->ctlr.ctl_src_addr, 2, 0); | 761 | wwpn = fcoe_wwn_from_mac(interface->ctlr.ctl_src_addr, 2, 0); |
751 | BNX2FC_HBA_DBG(lport, "WWPN = 0x%llx\n", wwpn); | 762 | BNX2FC_HBA_DBG(lport, "WWPN = 0x%llx\n", wwpn); |
752 | fc_set_wwpn(lport, wwpn); | 763 | fc_set_wwpn(lport, wwpn); |
753 | } | 764 | } |
@@ -759,9 +770,9 @@ static void bnx2fc_destroy_timer(unsigned long data) | |||
759 | { | 770 | { |
760 | struct bnx2fc_hba *hba = (struct bnx2fc_hba *)data; | 771 | struct bnx2fc_hba *hba = (struct bnx2fc_hba *)data; |
761 | 772 | ||
762 | BNX2FC_HBA_DBG(hba->ctlr.lp, "ERROR:bnx2fc_destroy_timer - " | 773 | BNX2FC_MISC_DBG("ERROR:bnx2fc_destroy_timer - " |
763 | "Destroy compl not received!!\n"); | 774 | "Destroy compl not received!!\n"); |
764 | hba->flags |= BNX2FC_FLAG_DESTROY_CMPL; | 775 | set_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); |
765 | wake_up_interruptible(&hba->destroy_wait); | 776 | wake_up_interruptible(&hba->destroy_wait); |
766 | } | 777 | } |
767 | 778 | ||
@@ -779,54 +790,35 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event, | |||
779 | u16 vlan_id) | 790 | u16 vlan_id) |
780 | { | 791 | { |
781 | struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; | 792 | struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; |
782 | struct fc_lport *lport = hba->ctlr.lp; | 793 | struct fc_lport *lport; |
783 | struct fc_lport *vport; | 794 | struct fc_lport *vport; |
795 | struct bnx2fc_interface *interface; | ||
796 | int wait_for_upload = 0; | ||
784 | u32 link_possible = 1; | 797 | u32 link_possible = 1; |
785 | 798 | ||
786 | /* Ignore vlans for now */ | 799 | /* Ignore vlans for now */ |
787 | if (vlan_id != 0) | 800 | if (vlan_id != 0) |
788 | return; | 801 | return; |
789 | 802 | ||
790 | if (!test_bit(BNX2FC_CREATE_DONE, &hba->init_done)) { | ||
791 | BNX2FC_MISC_DBG("driver not ready. event=%s %ld\n", | ||
792 | hba->netdev->name, event); | ||
793 | return; | ||
794 | } | ||
795 | |||
796 | /* | ||
797 | * ASSUMPTION: | ||
798 | * indicate_netevent cannot be called from cnic unless bnx2fc | ||
799 | * does register_device | ||
800 | */ | ||
801 | BUG_ON(!lport); | ||
802 | |||
803 | BNX2FC_HBA_DBG(lport, "enter netevent handler - event=%s %ld\n", | ||
804 | hba->netdev->name, event); | ||
805 | |||
806 | switch (event) { | 803 | switch (event) { |
807 | case NETDEV_UP: | 804 | case NETDEV_UP: |
808 | BNX2FC_HBA_DBG(lport, "Port up, adapter_state = %ld\n", | ||
809 | hba->adapter_state); | ||
810 | if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) | 805 | if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) |
811 | printk(KERN_ERR "indicate_netevent: "\ | 806 | printk(KERN_ERR "indicate_netevent: "\ |
812 | "adapter is not UP!!\n"); | 807 | "hba is not UP!!\n"); |
813 | break; | 808 | break; |
814 | 809 | ||
815 | case NETDEV_DOWN: | 810 | case NETDEV_DOWN: |
816 | BNX2FC_HBA_DBG(lport, "Port down\n"); | ||
817 | clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); | 811 | clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); |
818 | clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); | 812 | clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); |
819 | link_possible = 0; | 813 | link_possible = 0; |
820 | break; | 814 | break; |
821 | 815 | ||
822 | case NETDEV_GOING_DOWN: | 816 | case NETDEV_GOING_DOWN: |
823 | BNX2FC_HBA_DBG(lport, "Port going down\n"); | ||
824 | set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); | 817 | set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); |
825 | link_possible = 0; | 818 | link_possible = 0; |
826 | break; | 819 | break; |
827 | 820 | ||
828 | case NETDEV_CHANGE: | 821 | case NETDEV_CHANGE: |
829 | BNX2FC_HBA_DBG(lport, "NETDEV_CHANGE\n"); | ||
830 | break; | 822 | break; |
831 | 823 | ||
832 | default: | 824 | default: |
@@ -834,15 +826,22 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event, | |||
834 | return; | 826 | return; |
835 | } | 827 | } |
836 | 828 | ||
837 | bnx2fc_link_speed_update(lport); | 829 | mutex_lock(&bnx2fc_dev_lock); |
830 | list_for_each_entry(interface, &if_list, list) { | ||
838 | 831 | ||
839 | if (link_possible && !bnx2fc_link_ok(lport)) { | 832 | if (interface->hba != hba) |
840 | printk(KERN_ERR "indicate_netevent: call ctlr_link_up\n"); | 833 | continue; |
841 | fcoe_ctlr_link_up(&hba->ctlr); | 834 | |
842 | } else { | 835 | lport = interface->ctlr.lp; |
843 | printk(KERN_ERR "indicate_netevent: call ctlr_link_down\n"); | 836 | BNX2FC_HBA_DBG(lport, "netevent handler - event=%s %ld\n", |
844 | if (fcoe_ctlr_link_down(&hba->ctlr)) { | 837 | interface->netdev->name, event); |
845 | clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); | 838 | |
839 | bnx2fc_link_speed_update(lport); | ||
840 | |||
841 | if (link_possible && !bnx2fc_link_ok(lport)) { | ||
842 | printk(KERN_ERR "indicate_netevent: ctlr_link_up\n"); | ||
843 | fcoe_ctlr_link_up(&interface->ctlr); | ||
844 | } else if (fcoe_ctlr_link_down(&interface->ctlr)) { | ||
846 | mutex_lock(&lport->lp_mutex); | 845 | mutex_lock(&lport->lp_mutex); |
847 | list_for_each_entry(vport, &lport->vports, list) | 846 | list_for_each_entry(vport, &lport->vports, list) |
848 | fc_host_port_type(vport->host) = | 847 | fc_host_port_type(vport->host) = |
@@ -853,24 +852,26 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event, | |||
853 | get_cpu())->LinkFailureCount++; | 852 | get_cpu())->LinkFailureCount++; |
854 | put_cpu(); | 853 | put_cpu(); |
855 | fcoe_clean_pending_queue(lport); | 854 | fcoe_clean_pending_queue(lport); |
855 | wait_for_upload = 1; | ||
856 | } | ||
857 | } | ||
858 | mutex_unlock(&bnx2fc_dev_lock); | ||
856 | 859 | ||
857 | init_waitqueue_head(&hba->shutdown_wait); | 860 | if (wait_for_upload) { |
858 | BNX2FC_HBA_DBG(lport, "indicate_netevent " | 861 | clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); |
859 | "num_ofld_sess = %d\n", | 862 | init_waitqueue_head(&hba->shutdown_wait); |
860 | hba->num_ofld_sess); | 863 | BNX2FC_MISC_DBG("indicate_netevent " |
861 | hba->wait_for_link_down = 1; | 864 | "num_ofld_sess = %d\n", |
862 | BNX2FC_HBA_DBG(lport, "waiting for uploads to " | 865 | hba->num_ofld_sess); |
863 | "compl proc = %s\n", | 866 | hba->wait_for_link_down = 1; |
864 | current->comm); | 867 | wait_event_interruptible(hba->shutdown_wait, |
865 | wait_event_interruptible(hba->shutdown_wait, | 868 | (hba->num_ofld_sess == 0)); |
866 | (hba->num_ofld_sess == 0)); | 869 | BNX2FC_MISC_DBG("wakeup - num_ofld_sess = %d\n", |
867 | BNX2FC_HBA_DBG(lport, "wakeup - num_ofld_sess = %d\n", | ||
868 | hba->num_ofld_sess); | 870 | hba->num_ofld_sess); |
869 | hba->wait_for_link_down = 0; | 871 | hba->wait_for_link_down = 0; |
870 | 872 | ||
871 | if (signal_pending(current)) | 873 | if (signal_pending(current)) |
872 | flush_signals(current); | 874 | flush_signals(current); |
873 | } | ||
874 | } | 875 | } |
875 | } | 876 | } |
876 | 877 | ||
@@ -889,23 +890,12 @@ static int bnx2fc_libfc_config(struct fc_lport *lport) | |||
889 | 890 | ||
890 | static int bnx2fc_em_config(struct fc_lport *lport) | 891 | static int bnx2fc_em_config(struct fc_lport *lport) |
891 | { | 892 | { |
892 | struct fcoe_port *port = lport_priv(lport); | ||
893 | struct bnx2fc_hba *hba = port->priv; | ||
894 | |||
895 | if (!fc_exch_mgr_alloc(lport, FC_CLASS_3, FCOE_MIN_XID, | 893 | if (!fc_exch_mgr_alloc(lport, FC_CLASS_3, FCOE_MIN_XID, |
896 | FCOE_MAX_XID, NULL)) { | 894 | FCOE_MAX_XID, NULL)) { |
897 | printk(KERN_ERR PFX "em_config:fc_exch_mgr_alloc failed\n"); | 895 | printk(KERN_ERR PFX "em_config:fc_exch_mgr_alloc failed\n"); |
898 | return -ENOMEM; | 896 | return -ENOMEM; |
899 | } | 897 | } |
900 | 898 | ||
901 | hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba, BNX2FC_MIN_XID, | ||
902 | BNX2FC_MAX_XID); | ||
903 | |||
904 | if (!hba->cmd_mgr) { | ||
905 | printk(KERN_ERR PFX "em_config:bnx2fc_cmd_mgr_alloc failed\n"); | ||
906 | fc_exch_mgr_free(lport); | ||
907 | return -ENOMEM; | ||
908 | } | ||
909 | return 0; | 899 | return 0; |
910 | } | 900 | } |
911 | 901 | ||
@@ -952,9 +942,10 @@ static int bnx2fc_fip_recv(struct sk_buff *skb, struct net_device *dev, | |||
952 | struct packet_type *ptype, | 942 | struct packet_type *ptype, |
953 | struct net_device *orig_dev) | 943 | struct net_device *orig_dev) |
954 | { | 944 | { |
955 | struct bnx2fc_hba *hba; | 945 | struct bnx2fc_interface *interface; |
956 | hba = container_of(ptype, struct bnx2fc_hba, fip_packet_type); | 946 | interface = container_of(ptype, struct bnx2fc_interface, |
957 | fcoe_ctlr_recv(&hba->ctlr, skb); | 947 | fip_packet_type); |
948 | fcoe_ctlr_recv(&interface->ctlr, skb); | ||
958 | return 0; | 949 | return 0; |
959 | } | 950 | } |
960 | 951 | ||
@@ -1005,17 +996,17 @@ static int bnx2fc_vport_create(struct fc_vport *vport, bool disabled) | |||
1005 | struct Scsi_Host *shost = vport_to_shost(vport); | 996 | struct Scsi_Host *shost = vport_to_shost(vport); |
1006 | struct fc_lport *n_port = shost_priv(shost); | 997 | struct fc_lport *n_port = shost_priv(shost); |
1007 | struct fcoe_port *port = lport_priv(n_port); | 998 | struct fcoe_port *port = lport_priv(n_port); |
1008 | struct bnx2fc_hba *hba = port->priv; | 999 | struct bnx2fc_interface *interface = port->priv; |
1009 | struct net_device *netdev = hba->netdev; | 1000 | struct net_device *netdev = interface->netdev; |
1010 | struct fc_lport *vn_port; | 1001 | struct fc_lport *vn_port; |
1011 | 1002 | ||
1012 | if (!test_bit(BNX2FC_FW_INIT_DONE, &hba->init_done)) { | 1003 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { |
1013 | printk(KERN_ERR PFX "vn ports cannot be created on" | 1004 | printk(KERN_ERR PFX "vn ports cannot be created on" |
1014 | "this hba\n"); | 1005 | "this interface\n"); |
1015 | return -EIO; | 1006 | return -EIO; |
1016 | } | 1007 | } |
1017 | mutex_lock(&bnx2fc_dev_lock); | 1008 | mutex_lock(&bnx2fc_dev_lock); |
1018 | vn_port = bnx2fc_if_create(hba, &vport->dev, 1); | 1009 | vn_port = bnx2fc_if_create(interface, &vport->dev, 1); |
1019 | mutex_unlock(&bnx2fc_dev_lock); | 1010 | mutex_unlock(&bnx2fc_dev_lock); |
1020 | 1011 | ||
1021 | if (IS_ERR(vn_port)) { | 1012 | if (IS_ERR(vn_port)) { |
@@ -1065,10 +1056,10 @@ static int bnx2fc_vport_disable(struct fc_vport *vport, bool disable) | |||
1065 | } | 1056 | } |
1066 | 1057 | ||
1067 | 1058 | ||
1068 | static int bnx2fc_netdev_setup(struct bnx2fc_hba *hba) | 1059 | static int bnx2fc_netdev_setup(struct bnx2fc_interface *interface) |
1069 | { | 1060 | { |
1070 | struct net_device *netdev = hba->netdev; | 1061 | struct net_device *netdev = interface->netdev; |
1071 | struct net_device *physdev = hba->phys_dev; | 1062 | struct net_device *physdev = interface->hba->phys_dev; |
1072 | struct netdev_hw_addr *ha; | 1063 | struct netdev_hw_addr *ha; |
1073 | int sel_san_mac = 0; | 1064 | int sel_san_mac = 0; |
1074 | 1065 | ||
@@ -1083,7 +1074,8 @@ static int bnx2fc_netdev_setup(struct bnx2fc_hba *hba) | |||
1083 | 1074 | ||
1084 | if ((ha->type == NETDEV_HW_ADDR_T_SAN) && | 1075 | if ((ha->type == NETDEV_HW_ADDR_T_SAN) && |
1085 | (is_valid_ether_addr(ha->addr))) { | 1076 | (is_valid_ether_addr(ha->addr))) { |
1086 | memcpy(hba->ctlr.ctl_src_addr, ha->addr, ETH_ALEN); | 1077 | memcpy(interface->ctlr.ctl_src_addr, ha->addr, |
1078 | ETH_ALEN); | ||
1087 | sel_san_mac = 1; | 1079 | sel_san_mac = 1; |
1088 | BNX2FC_MISC_DBG("Found SAN MAC\n"); | 1080 | BNX2FC_MISC_DBG("Found SAN MAC\n"); |
1089 | } | 1081 | } |
@@ -1093,15 +1085,15 @@ static int bnx2fc_netdev_setup(struct bnx2fc_hba *hba) | |||
1093 | if (!sel_san_mac) | 1085 | if (!sel_san_mac) |
1094 | return -ENODEV; | 1086 | return -ENODEV; |
1095 | 1087 | ||
1096 | hba->fip_packet_type.func = bnx2fc_fip_recv; | 1088 | interface->fip_packet_type.func = bnx2fc_fip_recv; |
1097 | hba->fip_packet_type.type = htons(ETH_P_FIP); | 1089 | interface->fip_packet_type.type = htons(ETH_P_FIP); |
1098 | hba->fip_packet_type.dev = netdev; | 1090 | interface->fip_packet_type.dev = netdev; |
1099 | dev_add_pack(&hba->fip_packet_type); | 1091 | dev_add_pack(&interface->fip_packet_type); |
1100 | 1092 | ||
1101 | hba->fcoe_packet_type.func = bnx2fc_rcv; | 1093 | interface->fcoe_packet_type.func = bnx2fc_rcv; |
1102 | hba->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE); | 1094 | interface->fcoe_packet_type.type = __constant_htons(ETH_P_FCOE); |
1103 | hba->fcoe_packet_type.dev = netdev; | 1095 | interface->fcoe_packet_type.dev = netdev; |
1104 | dev_add_pack(&hba->fcoe_packet_type); | 1096 | dev_add_pack(&interface->fcoe_packet_type); |
1105 | 1097 | ||
1106 | return 0; | 1098 | return 0; |
1107 | } | 1099 | } |
@@ -1137,53 +1129,54 @@ static void bnx2fc_release_transport(void) | |||
1137 | 1129 | ||
1138 | static void bnx2fc_interface_release(struct kref *kref) | 1130 | static void bnx2fc_interface_release(struct kref *kref) |
1139 | { | 1131 | { |
1140 | struct bnx2fc_hba *hba; | 1132 | struct bnx2fc_interface *interface; |
1141 | struct net_device *netdev; | 1133 | struct net_device *netdev; |
1142 | struct net_device *phys_dev; | ||
1143 | 1134 | ||
1144 | hba = container_of(kref, struct bnx2fc_hba, kref); | 1135 | interface = container_of(kref, struct bnx2fc_interface, kref); |
1145 | BNX2FC_MISC_DBG("Interface is being released\n"); | 1136 | BNX2FC_MISC_DBG("Interface is being released\n"); |
1146 | 1137 | ||
1147 | netdev = hba->netdev; | 1138 | netdev = interface->netdev; |
1148 | phys_dev = hba->phys_dev; | ||
1149 | 1139 | ||
1150 | /* tear-down FIP controller */ | 1140 | /* tear-down FIP controller */ |
1151 | if (test_and_clear_bit(BNX2FC_CTLR_INIT_DONE, &hba->init_done)) | 1141 | if (test_and_clear_bit(BNX2FC_CTLR_INIT_DONE, &interface->if_flags)) |
1152 | fcoe_ctlr_destroy(&hba->ctlr); | 1142 | fcoe_ctlr_destroy(&interface->ctlr); |
1143 | |||
1144 | kfree(interface); | ||
1153 | 1145 | ||
1154 | /* Free the command manager */ | ||
1155 | if (hba->cmd_mgr) { | ||
1156 | bnx2fc_cmd_mgr_free(hba->cmd_mgr); | ||
1157 | hba->cmd_mgr = NULL; | ||
1158 | } | ||
1159 | dev_put(netdev); | 1146 | dev_put(netdev); |
1160 | module_put(THIS_MODULE); | 1147 | module_put(THIS_MODULE); |
1161 | } | 1148 | } |
1162 | 1149 | ||
1163 | static inline void bnx2fc_interface_get(struct bnx2fc_hba *hba) | 1150 | static inline void bnx2fc_interface_get(struct bnx2fc_interface *interface) |
1164 | { | 1151 | { |
1165 | kref_get(&hba->kref); | 1152 | kref_get(&interface->kref); |
1166 | } | 1153 | } |
1167 | 1154 | ||
1168 | static inline void bnx2fc_interface_put(struct bnx2fc_hba *hba) | 1155 | static inline void bnx2fc_interface_put(struct bnx2fc_interface *interface) |
1169 | { | 1156 | { |
1170 | kref_put(&hba->kref, bnx2fc_interface_release); | 1157 | kref_put(&interface->kref, bnx2fc_interface_release); |
1171 | } | 1158 | } |
1172 | static void bnx2fc_interface_destroy(struct bnx2fc_hba *hba) | 1159 | static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba) |
1173 | { | 1160 | { |
1161 | /* Free the command manager */ | ||
1162 | if (hba->cmd_mgr) { | ||
1163 | bnx2fc_cmd_mgr_free(hba->cmd_mgr); | ||
1164 | hba->cmd_mgr = NULL; | ||
1165 | } | ||
1166 | kfree(hba->tgt_ofld_list); | ||
1174 | bnx2fc_unbind_pcidev(hba); | 1167 | bnx2fc_unbind_pcidev(hba); |
1175 | kfree(hba); | 1168 | kfree(hba); |
1176 | } | 1169 | } |
1177 | 1170 | ||
1178 | /** | 1171 | /** |
1179 | * bnx2fc_interface_create - create a new fcoe instance | 1172 | * bnx2fc_hba_create - create a new bnx2fc hba |
1180 | * | 1173 | * |
1181 | * @cnic: pointer to cnic device | 1174 | * @cnic: pointer to cnic device |
1182 | * | 1175 | * |
1183 | * Creates a new FCoE instance on the given device which include allocating | 1176 | * Creates a new FCoE hba on the given device. |
1184 | * hba structure, scsi_host and lport structures. | 1177 | * |
1185 | */ | 1178 | */ |
1186 | static struct bnx2fc_hba *bnx2fc_interface_create(struct cnic_dev *cnic) | 1179 | static struct bnx2fc_hba *bnx2fc_hba_create(struct cnic_dev *cnic) |
1187 | { | 1180 | { |
1188 | struct bnx2fc_hba *hba; | 1181 | struct bnx2fc_hba *hba; |
1189 | int rc; | 1182 | int rc; |
@@ -1198,65 +1191,83 @@ static struct bnx2fc_hba *bnx2fc_interface_create(struct cnic_dev *cnic) | |||
1198 | 1191 | ||
1199 | hba->cnic = cnic; | 1192 | hba->cnic = cnic; |
1200 | rc = bnx2fc_bind_pcidev(hba); | 1193 | rc = bnx2fc_bind_pcidev(hba); |
1201 | if (rc) | 1194 | if (rc) { |
1195 | printk(KERN_ERR PFX "create_adapter: bind error\n"); | ||
1202 | goto bind_err; | 1196 | goto bind_err; |
1197 | } | ||
1203 | hba->phys_dev = cnic->netdev; | 1198 | hba->phys_dev = cnic->netdev; |
1204 | /* will get overwritten after we do vlan discovery */ | 1199 | hba->next_conn_id = 0; |
1205 | hba->netdev = hba->phys_dev; | 1200 | |
1201 | hba->tgt_ofld_list = | ||
1202 | kzalloc(sizeof(struct bnx2fc_rport *) * BNX2FC_NUM_MAX_SESS, | ||
1203 | GFP_KERNEL); | ||
1204 | if (!hba->tgt_ofld_list) { | ||
1205 | printk(KERN_ERR PFX "Unable to allocate tgt offload list\n"); | ||
1206 | goto tgtofld_err; | ||
1207 | } | ||
1208 | |||
1209 | hba->num_ofld_sess = 0; | ||
1210 | |||
1211 | hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba, BNX2FC_MIN_XID, | ||
1212 | BNX2FC_MAX_XID); | ||
1213 | if (!hba->cmd_mgr) { | ||
1214 | printk(KERN_ERR PFX "em_config:bnx2fc_cmd_mgr_alloc failed\n"); | ||
1215 | goto cmgr_err; | ||
1216 | } | ||
1206 | 1217 | ||
1207 | init_waitqueue_head(&hba->shutdown_wait); | 1218 | init_waitqueue_head(&hba->shutdown_wait); |
1208 | init_waitqueue_head(&hba->destroy_wait); | 1219 | init_waitqueue_head(&hba->destroy_wait); |
1220 | INIT_LIST_HEAD(&hba->vports); | ||
1209 | 1221 | ||
1210 | return hba; | 1222 | return hba; |
1223 | |||
1224 | cmgr_err: | ||
1225 | kfree(hba->tgt_ofld_list); | ||
1226 | tgtofld_err: | ||
1227 | bnx2fc_unbind_pcidev(hba); | ||
1211 | bind_err: | 1228 | bind_err: |
1212 | printk(KERN_ERR PFX "create_interface: bind error\n"); | ||
1213 | kfree(hba); | 1229 | kfree(hba); |
1214 | return NULL; | 1230 | return NULL; |
1215 | } | 1231 | } |
1216 | 1232 | ||
1217 | static int bnx2fc_interface_setup(struct bnx2fc_hba *hba, | 1233 | struct bnx2fc_interface *bnx2fc_interface_create(struct bnx2fc_hba *hba, |
1218 | enum fip_state fip_mode) | 1234 | struct net_device *netdev, |
1235 | enum fip_state fip_mode) | ||
1219 | { | 1236 | { |
1237 | struct bnx2fc_interface *interface; | ||
1220 | int rc = 0; | 1238 | int rc = 0; |
1221 | struct net_device *netdev = hba->netdev; | ||
1222 | struct fcoe_ctlr *fip = &hba->ctlr; | ||
1223 | 1239 | ||
1240 | interface = kzalloc(sizeof(*interface), GFP_KERNEL); | ||
1241 | if (!interface) { | ||
1242 | printk(KERN_ERR PFX "Unable to allocate interface structure\n"); | ||
1243 | return NULL; | ||
1244 | } | ||
1224 | dev_hold(netdev); | 1245 | dev_hold(netdev); |
1225 | kref_init(&hba->kref); | 1246 | kref_init(&interface->kref); |
1226 | 1247 | interface->hba = hba; | |
1227 | hba->flags = 0; | 1248 | interface->netdev = netdev; |
1228 | 1249 | ||
1229 | /* Initialize FIP */ | 1250 | /* Initialize FIP */ |
1230 | memset(fip, 0, sizeof(*fip)); | 1251 | fcoe_ctlr_init(&interface->ctlr, fip_mode); |
1231 | fcoe_ctlr_init(fip, fip_mode); | 1252 | interface->ctlr.send = bnx2fc_fip_send; |
1232 | hba->ctlr.send = bnx2fc_fip_send; | 1253 | interface->ctlr.update_mac = bnx2fc_update_src_mac; |
1233 | hba->ctlr.update_mac = bnx2fc_update_src_mac; | 1254 | interface->ctlr.get_src_addr = bnx2fc_get_src_mac; |
1234 | hba->ctlr.get_src_addr = bnx2fc_get_src_mac; | 1255 | set_bit(BNX2FC_CTLR_INIT_DONE, &interface->if_flags); |
1235 | set_bit(BNX2FC_CTLR_INIT_DONE, &hba->init_done); | ||
1236 | |||
1237 | INIT_LIST_HEAD(&hba->vports); | ||
1238 | rc = bnx2fc_netdev_setup(hba); | ||
1239 | if (rc) | ||
1240 | goto setup_err; | ||
1241 | 1256 | ||
1242 | hba->next_conn_id = 0; | 1257 | rc = bnx2fc_netdev_setup(interface); |
1258 | if (!rc) | ||
1259 | return interface; | ||
1243 | 1260 | ||
1244 | memset(hba->tgt_ofld_list, 0, sizeof(hba->tgt_ofld_list)); | 1261 | fcoe_ctlr_destroy(&interface->ctlr); |
1245 | hba->num_ofld_sess = 0; | ||
1246 | |||
1247 | return 0; | ||
1248 | |||
1249 | setup_err: | ||
1250 | fcoe_ctlr_destroy(&hba->ctlr); | ||
1251 | dev_put(netdev); | 1262 | dev_put(netdev); |
1252 | bnx2fc_interface_put(hba); | 1263 | kfree(interface); |
1253 | return rc; | 1264 | return NULL; |
1254 | } | 1265 | } |
1255 | 1266 | ||
1256 | /** | 1267 | /** |
1257 | * bnx2fc_if_create - Create FCoE instance on a given interface | 1268 | * bnx2fc_if_create - Create FCoE instance on a given interface |
1258 | * | 1269 | * |
1259 | * @hba: FCoE interface to create a local port on | 1270 | * @interface: FCoE interface to create a local port on |
1260 | * @parent: Device pointer to be the parent in sysfs for the SCSI host | 1271 | * @parent: Device pointer to be the parent in sysfs for the SCSI host |
1261 | * @npiv: Indicates if the port is vport or not | 1272 | * @npiv: Indicates if the port is vport or not |
1262 | * | 1273 | * |
@@ -1264,7 +1275,7 @@ setup_err: | |||
1264 | * | 1275 | * |
1265 | * Returns: Allocated fc_lport or an error pointer | 1276 | * Returns: Allocated fc_lport or an error pointer |
1266 | */ | 1277 | */ |
1267 | static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba, | 1278 | static struct fc_lport *bnx2fc_if_create(struct bnx2fc_interface *interface, |
1268 | struct device *parent, int npiv) | 1279 | struct device *parent, int npiv) |
1269 | { | 1280 | { |
1270 | struct fc_lport *lport, *n_port; | 1281 | struct fc_lport *lport, *n_port; |
@@ -1272,11 +1283,12 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba, | |||
1272 | struct Scsi_Host *shost; | 1283 | struct Scsi_Host *shost; |
1273 | struct fc_vport *vport = dev_to_vport(parent); | 1284 | struct fc_vport *vport = dev_to_vport(parent); |
1274 | struct bnx2fc_lport *blport; | 1285 | struct bnx2fc_lport *blport; |
1286 | struct bnx2fc_hba *hba; | ||
1275 | int rc = 0; | 1287 | int rc = 0; |
1276 | 1288 | ||
1277 | blport = kzalloc(sizeof(struct bnx2fc_lport), GFP_KERNEL); | 1289 | blport = kzalloc(sizeof(struct bnx2fc_lport), GFP_KERNEL); |
1278 | if (!blport) { | 1290 | if (!blport) { |
1279 | BNX2FC_HBA_DBG(hba->ctlr.lp, "Unable to alloc bnx2fc_lport\n"); | 1291 | BNX2FC_HBA_DBG(interface->ctlr.lp, "Unable to alloc blport\n"); |
1280 | return NULL; | 1292 | return NULL; |
1281 | } | 1293 | } |
1282 | 1294 | ||
@@ -1293,7 +1305,7 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba, | |||
1293 | shost = lport->host; | 1305 | shost = lport->host; |
1294 | port = lport_priv(lport); | 1306 | port = lport_priv(lport); |
1295 | port->lport = lport; | 1307 | port->lport = lport; |
1296 | port->priv = hba; | 1308 | port->priv = interface; |
1297 | INIT_WORK(&port->destroy_work, bnx2fc_destroy_work); | 1309 | INIT_WORK(&port->destroy_work, bnx2fc_destroy_work); |
1298 | 1310 | ||
1299 | /* Configure fcoe_port */ | 1311 | /* Configure fcoe_port */ |
@@ -1317,7 +1329,7 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba, | |||
1317 | rc = bnx2fc_shost_config(lport, parent); | 1329 | rc = bnx2fc_shost_config(lport, parent); |
1318 | if (rc) { | 1330 | if (rc) { |
1319 | printk(KERN_ERR PFX "Couldnt configure shost for %s\n", | 1331 | printk(KERN_ERR PFX "Couldnt configure shost for %s\n", |
1320 | hba->netdev->name); | 1332 | interface->netdev->name); |
1321 | goto lp_config_err; | 1333 | goto lp_config_err; |
1322 | } | 1334 | } |
1323 | 1335 | ||
@@ -1343,8 +1355,9 @@ static struct fc_lport *bnx2fc_if_create(struct bnx2fc_hba *hba, | |||
1343 | goto shost_err; | 1355 | goto shost_err; |
1344 | } | 1356 | } |
1345 | 1357 | ||
1346 | bnx2fc_interface_get(hba); | 1358 | bnx2fc_interface_get(interface); |
1347 | 1359 | ||
1360 | hba = interface->hba; | ||
1348 | spin_lock_bh(&hba->hba_lock); | 1361 | spin_lock_bh(&hba->hba_lock); |
1349 | blport->lport = lport; | 1362 | blport->lport = lport; |
1350 | list_add_tail(&blport->list, &hba->vports); | 1363 | list_add_tail(&blport->list, &hba->vports); |
@@ -1361,21 +1374,19 @@ free_blport: | |||
1361 | return NULL; | 1374 | return NULL; |
1362 | } | 1375 | } |
1363 | 1376 | ||
1364 | static void bnx2fc_netdev_cleanup(struct bnx2fc_hba *hba) | 1377 | static void bnx2fc_netdev_cleanup(struct bnx2fc_interface *interface) |
1365 | { | 1378 | { |
1366 | /* Dont listen for Ethernet packets anymore */ | 1379 | /* Dont listen for Ethernet packets anymore */ |
1367 | __dev_remove_pack(&hba->fcoe_packet_type); | 1380 | __dev_remove_pack(&interface->fcoe_packet_type); |
1368 | __dev_remove_pack(&hba->fip_packet_type); | 1381 | __dev_remove_pack(&interface->fip_packet_type); |
1369 | synchronize_net(); | 1382 | synchronize_net(); |
1370 | } | 1383 | } |
1371 | 1384 | ||
1372 | static void bnx2fc_if_destroy(struct fc_lport *lport) | 1385 | static void bnx2fc_if_destroy(struct fc_lport *lport, struct bnx2fc_hba *hba) |
1373 | { | 1386 | { |
1374 | struct fcoe_port *port = lport_priv(lport); | 1387 | struct fcoe_port *port = lport_priv(lport); |
1375 | struct bnx2fc_hba *hba = port->priv; | ||
1376 | struct bnx2fc_lport *blport, *tmp; | 1388 | struct bnx2fc_lport *blport, *tmp; |
1377 | 1389 | ||
1378 | BNX2FC_HBA_DBG(hba->ctlr.lp, "ENTERED bnx2fc_if_destroy\n"); | ||
1379 | /* Stop the transmit retry timer */ | 1390 | /* Stop the transmit retry timer */ |
1380 | del_timer_sync(&port->timer); | 1391 | del_timer_sync(&port->timer); |
1381 | 1392 | ||
@@ -1409,8 +1420,6 @@ static void bnx2fc_if_destroy(struct fc_lport *lport) | |||
1409 | 1420 | ||
1410 | /* Release Scsi_Host */ | 1421 | /* Release Scsi_Host */ |
1411 | scsi_host_put(lport->host); | 1422 | scsi_host_put(lport->host); |
1412 | |||
1413 | bnx2fc_interface_put(hba); | ||
1414 | } | 1423 | } |
1415 | 1424 | ||
1416 | /** | 1425 | /** |
@@ -1425,46 +1434,31 @@ static void bnx2fc_if_destroy(struct fc_lport *lport) | |||
1425 | */ | 1434 | */ |
1426 | static int bnx2fc_destroy(struct net_device *netdev) | 1435 | static int bnx2fc_destroy(struct net_device *netdev) |
1427 | { | 1436 | { |
1428 | struct bnx2fc_hba *hba = NULL; | 1437 | struct bnx2fc_interface *interface = NULL; |
1429 | struct net_device *phys_dev; | 1438 | struct bnx2fc_hba *hba; |
1439 | struct fc_lport *lport; | ||
1430 | int rc = 0; | 1440 | int rc = 0; |
1431 | 1441 | ||
1432 | rtnl_lock(); | 1442 | rtnl_lock(); |
1433 | |||
1434 | mutex_lock(&bnx2fc_dev_lock); | 1443 | mutex_lock(&bnx2fc_dev_lock); |
1435 | /* obtain physical netdev */ | ||
1436 | if (netdev->priv_flags & IFF_802_1Q_VLAN) | ||
1437 | phys_dev = vlan_dev_real_dev(netdev); | ||
1438 | else { | ||
1439 | printk(KERN_ERR PFX "Not a vlan device\n"); | ||
1440 | rc = -ENODEV; | ||
1441 | goto netdev_err; | ||
1442 | } | ||
1443 | 1444 | ||
1444 | hba = bnx2fc_hba_lookup(phys_dev); | 1445 | interface = bnx2fc_interface_lookup(netdev); |
1445 | if (!hba || !hba->ctlr.lp) { | 1446 | if (!interface || !interface->ctlr.lp) { |
1446 | rc = -ENODEV; | 1447 | rc = -ENODEV; |
1447 | printk(KERN_ERR PFX "bnx2fc_destroy: hba or lport not found\n"); | 1448 | printk(KERN_ERR PFX "bnx2fc_destroy: interface or lport not found\n"); |
1448 | goto netdev_err; | ||
1449 | } | ||
1450 | |||
1451 | if (!test_bit(BNX2FC_CREATE_DONE, &hba->init_done)) { | ||
1452 | printk(KERN_ERR PFX "bnx2fc_destroy: Create not called\n"); | ||
1453 | goto netdev_err; | 1449 | goto netdev_err; |
1454 | } | 1450 | } |
1455 | 1451 | ||
1456 | bnx2fc_netdev_cleanup(hba); | 1452 | hba = interface->hba; |
1457 | |||
1458 | bnx2fc_stop(hba); | ||
1459 | |||
1460 | bnx2fc_if_destroy(hba->ctlr.lp); | ||
1461 | 1453 | ||
1462 | destroy_workqueue(hba->timer_work_queue); | 1454 | bnx2fc_netdev_cleanup(interface); |
1455 | lport = interface->ctlr.lp; | ||
1456 | bnx2fc_stop(interface); | ||
1457 | list_del(&interface->list); | ||
1458 | destroy_workqueue(interface->timer_work_queue); | ||
1459 | bnx2fc_interface_put(interface); | ||
1460 | bnx2fc_if_destroy(lport, hba); | ||
1463 | 1461 | ||
1464 | if (test_bit(BNX2FC_FW_INIT_DONE, &hba->init_done)) | ||
1465 | bnx2fc_fw_destroy(hba); | ||
1466 | |||
1467 | clear_bit(BNX2FC_CREATE_DONE, &hba->init_done); | ||
1468 | netdev_err: | 1462 | netdev_err: |
1469 | mutex_unlock(&bnx2fc_dev_lock); | 1463 | mutex_unlock(&bnx2fc_dev_lock); |
1470 | rtnl_unlock(); | 1464 | rtnl_unlock(); |
@@ -1475,16 +1469,20 @@ static void bnx2fc_destroy_work(struct work_struct *work) | |||
1475 | { | 1469 | { |
1476 | struct fcoe_port *port; | 1470 | struct fcoe_port *port; |
1477 | struct fc_lport *lport; | 1471 | struct fc_lport *lport; |
1472 | struct bnx2fc_interface *interface; | ||
1473 | struct bnx2fc_hba *hba; | ||
1478 | 1474 | ||
1479 | port = container_of(work, struct fcoe_port, destroy_work); | 1475 | port = container_of(work, struct fcoe_port, destroy_work); |
1480 | lport = port->lport; | 1476 | lport = port->lport; |
1477 | interface = port->priv; | ||
1478 | hba = interface->hba; | ||
1481 | 1479 | ||
1482 | BNX2FC_HBA_DBG(lport, "Entered bnx2fc_destroy_work\n"); | 1480 | BNX2FC_HBA_DBG(lport, "Entered bnx2fc_destroy_work\n"); |
1483 | 1481 | ||
1484 | bnx2fc_port_shutdown(lport); | 1482 | bnx2fc_port_shutdown(lport); |
1485 | rtnl_lock(); | 1483 | rtnl_lock(); |
1486 | mutex_lock(&bnx2fc_dev_lock); | 1484 | mutex_lock(&bnx2fc_dev_lock); |
1487 | bnx2fc_if_destroy(lport); | 1485 | bnx2fc_if_destroy(lport, hba); |
1488 | mutex_unlock(&bnx2fc_dev_lock); | 1486 | mutex_unlock(&bnx2fc_dev_lock); |
1489 | rtnl_unlock(); | 1487 | rtnl_unlock(); |
1490 | } | 1488 | } |
@@ -1556,28 +1554,27 @@ static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba) | |||
1556 | static void bnx2fc_ulp_start(void *handle) | 1554 | static void bnx2fc_ulp_start(void *handle) |
1557 | { | 1555 | { |
1558 | struct bnx2fc_hba *hba = handle; | 1556 | struct bnx2fc_hba *hba = handle; |
1559 | struct fc_lport *lport = hba->ctlr.lp; | 1557 | struct bnx2fc_interface *interface; |
1558 | struct fc_lport *lport; | ||
1560 | 1559 | ||
1561 | BNX2FC_MISC_DBG("Entered %s\n", __func__); | ||
1562 | mutex_lock(&bnx2fc_dev_lock); | 1560 | mutex_lock(&bnx2fc_dev_lock); |
1563 | 1561 | ||
1564 | if (test_bit(BNX2FC_FW_INIT_DONE, &hba->init_done)) | 1562 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) |
1565 | goto start_disc; | ||
1566 | |||
1567 | if (test_bit(BNX2FC_CREATE_DONE, &hba->init_done)) | ||
1568 | bnx2fc_fw_init(hba); | 1563 | bnx2fc_fw_init(hba); |
1569 | 1564 | ||
1570 | start_disc: | ||
1571 | mutex_unlock(&bnx2fc_dev_lock); | ||
1572 | |||
1573 | BNX2FC_MISC_DBG("bnx2fc started.\n"); | 1565 | BNX2FC_MISC_DBG("bnx2fc started.\n"); |
1574 | 1566 | ||
1575 | /* Kick off Fabric discovery*/ | 1567 | list_for_each_entry(interface, &if_list, list) { |
1576 | if (test_bit(BNX2FC_CREATE_DONE, &hba->init_done)) { | 1568 | if (interface->hba == hba) { |
1577 | printk(KERN_ERR PFX "ulp_init: start discovery\n"); | 1569 | lport = interface->ctlr.lp; |
1578 | lport->tt.frame_send = bnx2fc_xmit; | 1570 | /* Kick off Fabric discovery*/ |
1579 | bnx2fc_start_disc(hba); | 1571 | printk(KERN_ERR PFX "ulp_init: start discovery\n"); |
1572 | lport->tt.frame_send = bnx2fc_xmit; | ||
1573 | bnx2fc_start_disc(interface); | ||
1574 | } | ||
1580 | } | 1575 | } |
1576 | |||
1577 | mutex_unlock(&bnx2fc_dev_lock); | ||
1581 | } | 1578 | } |
1582 | 1579 | ||
1583 | static void bnx2fc_port_shutdown(struct fc_lport *lport) | 1580 | static void bnx2fc_port_shutdown(struct fc_lport *lport) |
@@ -1587,37 +1584,25 @@ static void bnx2fc_port_shutdown(struct fc_lport *lport) | |||
1587 | fc_lport_destroy(lport); | 1584 | fc_lport_destroy(lport); |
1588 | } | 1585 | } |
1589 | 1586 | ||
1590 | static void bnx2fc_stop(struct bnx2fc_hba *hba) | 1587 | static void bnx2fc_stop(struct bnx2fc_interface *interface) |
1591 | { | 1588 | { |
1592 | struct fc_lport *lport; | 1589 | struct fc_lport *lport; |
1593 | struct fc_lport *vport; | 1590 | struct fc_lport *vport; |
1594 | 1591 | ||
1595 | BNX2FC_MISC_DBG("ENTERED %s - init_done = %ld\n", __func__, | 1592 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) |
1596 | hba->init_done); | 1593 | return; |
1597 | if (test_bit(BNX2FC_FW_INIT_DONE, &hba->init_done) && | ||
1598 | test_bit(BNX2FC_CREATE_DONE, &hba->init_done)) { | ||
1599 | lport = hba->ctlr.lp; | ||
1600 | bnx2fc_port_shutdown(lport); | ||
1601 | BNX2FC_HBA_DBG(lport, "bnx2fc_stop: waiting for %d " | ||
1602 | "offloaded sessions\n", | ||
1603 | hba->num_ofld_sess); | ||
1604 | wait_event_interruptible(hba->shutdown_wait, | ||
1605 | (hba->num_ofld_sess == 0)); | ||
1606 | mutex_lock(&lport->lp_mutex); | ||
1607 | list_for_each_entry(vport, &lport->vports, list) | ||
1608 | fc_host_port_type(vport->host) = FC_PORTTYPE_UNKNOWN; | ||
1609 | mutex_unlock(&lport->lp_mutex); | ||
1610 | fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN; | ||
1611 | fcoe_ctlr_link_down(&hba->ctlr); | ||
1612 | fcoe_clean_pending_queue(lport); | ||
1613 | |||
1614 | mutex_lock(&hba->hba_mutex); | ||
1615 | clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); | ||
1616 | clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); | ||
1617 | 1594 | ||
1618 | clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); | 1595 | lport = interface->ctlr.lp; |
1619 | mutex_unlock(&hba->hba_mutex); | 1596 | bnx2fc_port_shutdown(lport); |
1620 | } | 1597 | |
1598 | mutex_lock(&lport->lp_mutex); | ||
1599 | list_for_each_entry(vport, &lport->vports, list) | ||
1600 | fc_host_port_type(vport->host) = | ||
1601 | FC_PORTTYPE_UNKNOWN; | ||
1602 | mutex_unlock(&lport->lp_mutex); | ||
1603 | fc_host_port_type(lport->host) = FC_PORTTYPE_UNKNOWN; | ||
1604 | fcoe_ctlr_link_down(&interface->ctlr); | ||
1605 | fcoe_clean_pending_queue(lport); | ||
1621 | } | 1606 | } |
1622 | 1607 | ||
1623 | static int bnx2fc_fw_init(struct bnx2fc_hba *hba) | 1608 | static int bnx2fc_fw_init(struct bnx2fc_hba *hba) |
@@ -1656,8 +1641,7 @@ static int bnx2fc_fw_init(struct bnx2fc_hba *hba) | |||
1656 | } | 1641 | } |
1657 | 1642 | ||
1658 | 1643 | ||
1659 | /* Mark HBA to indicate that the FW INIT is done */ | 1644 | set_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags); |
1660 | set_bit(BNX2FC_FW_INIT_DONE, &hba->init_done); | ||
1661 | return 0; | 1645 | return 0; |
1662 | 1646 | ||
1663 | err_unbind: | 1647 | err_unbind: |
@@ -1668,7 +1652,7 @@ err_out: | |||
1668 | 1652 | ||
1669 | static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) | 1653 | static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) |
1670 | { | 1654 | { |
1671 | if (test_and_clear_bit(BNX2FC_FW_INIT_DONE, &hba->init_done)) { | 1655 | if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) { |
1672 | if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) { | 1656 | if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) { |
1673 | init_timer(&hba->destroy_timer); | 1657 | init_timer(&hba->destroy_timer); |
1674 | hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT + | 1658 | hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT + |
@@ -1677,8 +1661,8 @@ static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) | |||
1677 | hba->destroy_timer.data = (unsigned long)hba; | 1661 | hba->destroy_timer.data = (unsigned long)hba; |
1678 | add_timer(&hba->destroy_timer); | 1662 | add_timer(&hba->destroy_timer); |
1679 | wait_event_interruptible(hba->destroy_wait, | 1663 | wait_event_interruptible(hba->destroy_wait, |
1680 | (hba->flags & | 1664 | test_bit(BNX2FC_FLAG_DESTROY_CMPL, |
1681 | BNX2FC_FLAG_DESTROY_CMPL)); | 1665 | &hba->flags)); |
1682 | /* This should never happen */ | 1666 | /* This should never happen */ |
1683 | if (signal_pending(current)) | 1667 | if (signal_pending(current)) |
1684 | flush_signals(current); | 1668 | flush_signals(current); |
@@ -1699,40 +1683,57 @@ static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) | |||
1699 | */ | 1683 | */ |
1700 | static void bnx2fc_ulp_stop(void *handle) | 1684 | static void bnx2fc_ulp_stop(void *handle) |
1701 | { | 1685 | { |
1702 | struct bnx2fc_hba *hba = (struct bnx2fc_hba *)handle; | 1686 | struct bnx2fc_hba *hba = handle; |
1687 | struct bnx2fc_interface *interface; | ||
1703 | 1688 | ||
1704 | printk(KERN_ERR "ULP_STOP\n"); | 1689 | printk(KERN_ERR "ULP_STOP\n"); |
1705 | 1690 | ||
1706 | mutex_lock(&bnx2fc_dev_lock); | 1691 | mutex_lock(&bnx2fc_dev_lock); |
1707 | bnx2fc_stop(hba); | 1692 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) |
1693 | goto exit; | ||
1694 | list_for_each_entry(interface, &if_list, list) { | ||
1695 | if (interface->hba == hba) | ||
1696 | bnx2fc_stop(interface); | ||
1697 | } | ||
1698 | BUG_ON(hba->num_ofld_sess != 0); | ||
1699 | |||
1700 | mutex_lock(&hba->hba_mutex); | ||
1701 | clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); | ||
1702 | clear_bit(ADAPTER_STATE_GOING_DOWN, | ||
1703 | &hba->adapter_state); | ||
1704 | |||
1705 | clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); | ||
1706 | mutex_unlock(&hba->hba_mutex); | ||
1707 | |||
1708 | bnx2fc_fw_destroy(hba); | 1708 | bnx2fc_fw_destroy(hba); |
1709 | exit: | ||
1709 | mutex_unlock(&bnx2fc_dev_lock); | 1710 | mutex_unlock(&bnx2fc_dev_lock); |
1710 | } | 1711 | } |
1711 | 1712 | ||
1712 | static void bnx2fc_start_disc(struct bnx2fc_hba *hba) | 1713 | static void bnx2fc_start_disc(struct bnx2fc_interface *interface) |
1713 | { | 1714 | { |
1714 | struct fc_lport *lport; | 1715 | struct fc_lport *lport; |
1715 | int wait_cnt = 0; | 1716 | int wait_cnt = 0; |
1716 | 1717 | ||
1717 | BNX2FC_MISC_DBG("Entered %s\n", __func__); | 1718 | BNX2FC_MISC_DBG("Entered %s\n", __func__); |
1718 | /* Kick off FIP/FLOGI */ | 1719 | /* Kick off FIP/FLOGI */ |
1719 | if (!test_bit(BNX2FC_FW_INIT_DONE, &hba->init_done)) { | 1720 | if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { |
1720 | printk(KERN_ERR PFX "Init not done yet\n"); | 1721 | printk(KERN_ERR PFX "Init not done yet\n"); |
1721 | return; | 1722 | return; |
1722 | } | 1723 | } |
1723 | 1724 | ||
1724 | lport = hba->ctlr.lp; | 1725 | lport = interface->ctlr.lp; |
1725 | BNX2FC_HBA_DBG(lport, "calling fc_fabric_login\n"); | 1726 | BNX2FC_HBA_DBG(lport, "calling fc_fabric_login\n"); |
1726 | 1727 | ||
1727 | if (!bnx2fc_link_ok(lport)) { | 1728 | if (!bnx2fc_link_ok(lport)) { |
1728 | BNX2FC_HBA_DBG(lport, "ctlr_link_up\n"); | 1729 | BNX2FC_HBA_DBG(lport, "ctlr_link_up\n"); |
1729 | fcoe_ctlr_link_up(&hba->ctlr); | 1730 | fcoe_ctlr_link_up(&interface->ctlr); |
1730 | fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; | 1731 | fc_host_port_type(lport->host) = FC_PORTTYPE_NPORT; |
1731 | set_bit(ADAPTER_STATE_READY, &hba->adapter_state); | 1732 | set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); |
1732 | } | 1733 | } |
1733 | 1734 | ||
1734 | /* wait for the FCF to be selected before issuing FLOGI */ | 1735 | /* wait for the FCF to be selected before issuing FLOGI */ |
1735 | while (!hba->ctlr.sel_fcf) { | 1736 | while (!interface->ctlr.sel_fcf) { |
1736 | msleep(250); | 1737 | msleep(250); |
1737 | /* give up after 3 secs */ | 1738 | /* give up after 3 secs */ |
1738 | if (++wait_cnt > 12) | 1739 | if (++wait_cnt > 12) |
@@ -1758,15 +1759,15 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev) | |||
1758 | 1759 | ||
1759 | BNX2FC_MISC_DBG("Entered %s\n", __func__); | 1760 | BNX2FC_MISC_DBG("Entered %s\n", __func__); |
1760 | /* bnx2fc works only when bnx2x is loaded */ | 1761 | /* bnx2fc works only when bnx2x is loaded */ |
1761 | if (!test_bit(CNIC_F_BNX2X_CLASS, &dev->flags)) { | 1762 | if (!test_bit(CNIC_F_BNX2X_CLASS, &dev->flags) || |
1763 | (dev->max_fcoe_conn == 0)) { | ||
1762 | printk(KERN_ERR PFX "bnx2fc FCoE not supported on %s," | 1764 | printk(KERN_ERR PFX "bnx2fc FCoE not supported on %s," |
1763 | " flags: %lx\n", | 1765 | " flags: %lx fcoe_conn: %d\n", |
1764 | dev->netdev->name, dev->flags); | 1766 | dev->netdev->name, dev->flags, dev->max_fcoe_conn); |
1765 | return; | 1767 | return; |
1766 | } | 1768 | } |
1767 | 1769 | ||
1768 | /* Configure FCoE interface */ | 1770 | hba = bnx2fc_hba_create(dev); |
1769 | hba = bnx2fc_interface_create(dev); | ||
1770 | if (!hba) { | 1771 | if (!hba) { |
1771 | printk(KERN_ERR PFX "hba initialization failed\n"); | 1772 | printk(KERN_ERR PFX "hba initialization failed\n"); |
1772 | return; | 1773 | return; |
@@ -1774,7 +1775,7 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev) | |||
1774 | 1775 | ||
1775 | /* Add HBA to the adapter list */ | 1776 | /* Add HBA to the adapter list */ |
1776 | mutex_lock(&bnx2fc_dev_lock); | 1777 | mutex_lock(&bnx2fc_dev_lock); |
1777 | list_add_tail(&hba->link, &adapter_list); | 1778 | list_add_tail(&hba->list, &adapter_list); |
1778 | adapter_count++; | 1779 | adapter_count++; |
1779 | mutex_unlock(&bnx2fc_dev_lock); | 1780 | mutex_unlock(&bnx2fc_dev_lock); |
1780 | 1781 | ||
@@ -1790,52 +1791,21 @@ static void bnx2fc_ulp_init(struct cnic_dev *dev) | |||
1790 | 1791 | ||
1791 | static int bnx2fc_disable(struct net_device *netdev) | 1792 | static int bnx2fc_disable(struct net_device *netdev) |
1792 | { | 1793 | { |
1793 | struct bnx2fc_hba *hba; | 1794 | struct bnx2fc_interface *interface; |
1794 | struct net_device *phys_dev; | ||
1795 | struct ethtool_drvinfo drvinfo; | ||
1796 | int rc = 0; | 1795 | int rc = 0; |
1797 | 1796 | ||
1798 | rtnl_lock(); | 1797 | rtnl_lock(); |
1799 | |||
1800 | mutex_lock(&bnx2fc_dev_lock); | 1798 | mutex_lock(&bnx2fc_dev_lock); |
1801 | 1799 | ||
1802 | /* obtain physical netdev */ | 1800 | interface = bnx2fc_interface_lookup(netdev); |
1803 | if (netdev->priv_flags & IFF_802_1Q_VLAN) | 1801 | if (!interface || !interface->ctlr.lp) { |
1804 | phys_dev = vlan_dev_real_dev(netdev); | ||
1805 | else { | ||
1806 | printk(KERN_ERR PFX "Not a vlan device\n"); | ||
1807 | rc = -ENODEV; | ||
1808 | goto nodev; | ||
1809 | } | ||
1810 | |||
1811 | /* verify if the physical device is a netxtreme2 device */ | ||
1812 | if (phys_dev->ethtool_ops && phys_dev->ethtool_ops->get_drvinfo) { | ||
1813 | memset(&drvinfo, 0, sizeof(drvinfo)); | ||
1814 | phys_dev->ethtool_ops->get_drvinfo(phys_dev, &drvinfo); | ||
1815 | if (strcmp(drvinfo.driver, "bnx2x")) { | ||
1816 | printk(KERN_ERR PFX "Not a netxtreme2 device\n"); | ||
1817 | rc = -ENODEV; | ||
1818 | goto nodev; | ||
1819 | } | ||
1820 | } else { | ||
1821 | printk(KERN_ERR PFX "unable to obtain drv_info\n"); | ||
1822 | rc = -ENODEV; | ||
1823 | goto nodev; | ||
1824 | } | ||
1825 | |||
1826 | printk(KERN_ERR PFX "phys_dev is netxtreme2 device\n"); | ||
1827 | |||
1828 | /* obtain hba and initialize rest of the structure */ | ||
1829 | hba = bnx2fc_hba_lookup(phys_dev); | ||
1830 | if (!hba || !hba->ctlr.lp) { | ||
1831 | rc = -ENODEV; | 1802 | rc = -ENODEV; |
1832 | printk(KERN_ERR PFX "bnx2fc_disable: hba or lport not found\n"); | 1803 | printk(KERN_ERR PFX "bnx2fc_disable: interface or lport not found\n"); |
1833 | } else { | 1804 | } else { |
1834 | fcoe_ctlr_link_down(&hba->ctlr); | 1805 | fcoe_ctlr_link_down(&interface->ctlr); |
1835 | fcoe_clean_pending_queue(hba->ctlr.lp); | 1806 | fcoe_clean_pending_queue(interface->ctlr.lp); |
1836 | } | 1807 | } |
1837 | 1808 | ||
1838 | nodev: | ||
1839 | mutex_unlock(&bnx2fc_dev_lock); | 1809 | mutex_unlock(&bnx2fc_dev_lock); |
1840 | rtnl_unlock(); | 1810 | rtnl_unlock(); |
1841 | return rc; | 1811 | return rc; |
@@ -1844,48 +1814,19 @@ nodev: | |||
1844 | 1814 | ||
1845 | static int bnx2fc_enable(struct net_device *netdev) | 1815 | static int bnx2fc_enable(struct net_device *netdev) |
1846 | { | 1816 | { |
1847 | struct bnx2fc_hba *hba; | 1817 | struct bnx2fc_interface *interface; |
1848 | struct net_device *phys_dev; | ||
1849 | struct ethtool_drvinfo drvinfo; | ||
1850 | int rc = 0; | 1818 | int rc = 0; |
1851 | 1819 | ||
1852 | rtnl_lock(); | 1820 | rtnl_lock(); |
1853 | |||
1854 | BNX2FC_MISC_DBG("Entered %s\n", __func__); | ||
1855 | mutex_lock(&bnx2fc_dev_lock); | 1821 | mutex_lock(&bnx2fc_dev_lock); |
1856 | 1822 | ||
1857 | /* obtain physical netdev */ | 1823 | interface = bnx2fc_interface_lookup(netdev); |
1858 | if (netdev->priv_flags & IFF_802_1Q_VLAN) | 1824 | if (!interface || !interface->ctlr.lp) { |
1859 | phys_dev = vlan_dev_real_dev(netdev); | ||
1860 | else { | ||
1861 | printk(KERN_ERR PFX "Not a vlan device\n"); | ||
1862 | rc = -ENODEV; | ||
1863 | goto nodev; | ||
1864 | } | ||
1865 | /* verify if the physical device is a netxtreme2 device */ | ||
1866 | if (phys_dev->ethtool_ops && phys_dev->ethtool_ops->get_drvinfo) { | ||
1867 | memset(&drvinfo, 0, sizeof(drvinfo)); | ||
1868 | phys_dev->ethtool_ops->get_drvinfo(phys_dev, &drvinfo); | ||
1869 | if (strcmp(drvinfo.driver, "bnx2x")) { | ||
1870 | printk(KERN_ERR PFX "Not a netxtreme2 device\n"); | ||
1871 | rc = -ENODEV; | ||
1872 | goto nodev; | ||
1873 | } | ||
1874 | } else { | ||
1875 | printk(KERN_ERR PFX "unable to obtain drv_info\n"); | ||
1876 | rc = -ENODEV; | 1825 | rc = -ENODEV; |
1877 | goto nodev; | 1826 | printk(KERN_ERR PFX "bnx2fc_enable: interface or lport not found\n"); |
1878 | } | 1827 | } else if (!bnx2fc_link_ok(interface->ctlr.lp)) |
1879 | 1828 | fcoe_ctlr_link_up(&interface->ctlr); | |
1880 | /* obtain hba and initialize rest of the structure */ | ||
1881 | hba = bnx2fc_hba_lookup(phys_dev); | ||
1882 | if (!hba || !hba->ctlr.lp) { | ||
1883 | rc = -ENODEV; | ||
1884 | printk(KERN_ERR PFX "bnx2fc_enable: hba or lport not found\n"); | ||
1885 | } else if (!bnx2fc_link_ok(hba->ctlr.lp)) | ||
1886 | fcoe_ctlr_link_up(&hba->ctlr); | ||
1887 | 1829 | ||
1888 | nodev: | ||
1889 | mutex_unlock(&bnx2fc_dev_lock); | 1830 | mutex_unlock(&bnx2fc_dev_lock); |
1890 | rtnl_unlock(); | 1831 | rtnl_unlock(); |
1891 | return rc; | 1832 | return rc; |
@@ -1903,6 +1844,7 @@ nodev: | |||
1903 | */ | 1844 | */ |
1904 | static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) | 1845 | static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) |
1905 | { | 1846 | { |
1847 | struct bnx2fc_interface *interface; | ||
1906 | struct bnx2fc_hba *hba; | 1848 | struct bnx2fc_hba *hba; |
1907 | struct net_device *phys_dev; | 1849 | struct net_device *phys_dev; |
1908 | struct fc_lport *lport; | 1850 | struct fc_lport *lport; |
@@ -1938,7 +1880,7 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) | |||
1938 | if (phys_dev->ethtool_ops && phys_dev->ethtool_ops->get_drvinfo) { | 1880 | if (phys_dev->ethtool_ops && phys_dev->ethtool_ops->get_drvinfo) { |
1939 | memset(&drvinfo, 0, sizeof(drvinfo)); | 1881 | memset(&drvinfo, 0, sizeof(drvinfo)); |
1940 | phys_dev->ethtool_ops->get_drvinfo(phys_dev, &drvinfo); | 1882 | phys_dev->ethtool_ops->get_drvinfo(phys_dev, &drvinfo); |
1941 | if (strcmp(drvinfo.driver, "bnx2x")) { | 1883 | if (strncmp(drvinfo.driver, "bnx2x", strlen("bnx2x"))) { |
1942 | printk(KERN_ERR PFX "Not a netxtreme2 device\n"); | 1884 | printk(KERN_ERR PFX "Not a netxtreme2 device\n"); |
1943 | rc = -EINVAL; | 1885 | rc = -EINVAL; |
1944 | goto netdev_err; | 1886 | goto netdev_err; |
@@ -1949,7 +1891,7 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) | |||
1949 | goto netdev_err; | 1891 | goto netdev_err; |
1950 | } | 1892 | } |
1951 | 1893 | ||
1952 | /* obtain hba and initialize rest of the structure */ | 1894 | /* obtain interface and initialize rest of the structure */ |
1953 | hba = bnx2fc_hba_lookup(phys_dev); | 1895 | hba = bnx2fc_hba_lookup(phys_dev); |
1954 | if (!hba) { | 1896 | if (!hba) { |
1955 | rc = -ENODEV; | 1897 | rc = -ENODEV; |
@@ -1957,67 +1899,61 @@ static int bnx2fc_create(struct net_device *netdev, enum fip_state fip_mode) | |||
1957 | goto netdev_err; | 1899 | goto netdev_err; |
1958 | } | 1900 | } |
1959 | 1901 | ||
1960 | if (!test_bit(BNX2FC_FW_INIT_DONE, &hba->init_done)) { | 1902 | if (bnx2fc_interface_lookup(netdev)) { |
1961 | rc = bnx2fc_fw_init(hba); | ||
1962 | if (rc) | ||
1963 | goto netdev_err; | ||
1964 | } | ||
1965 | |||
1966 | if (test_bit(BNX2FC_CREATE_DONE, &hba->init_done)) { | ||
1967 | rc = -EEXIST; | 1903 | rc = -EEXIST; |
1968 | goto netdev_err; | 1904 | goto netdev_err; |
1969 | } | 1905 | } |
1970 | 1906 | ||
1971 | /* update netdev with vlan netdev */ | 1907 | interface = bnx2fc_interface_create(hba, netdev, fip_mode); |
1972 | hba->netdev = netdev; | 1908 | if (!interface) { |
1973 | hba->vlan_id = vlan_id; | 1909 | printk(KERN_ERR PFX "bnx2fc_interface_create failed\n"); |
1974 | hba->vlan_enabled = 1; | ||
1975 | |||
1976 | rc = bnx2fc_interface_setup(hba, fip_mode); | ||
1977 | if (rc) { | ||
1978 | printk(KERN_ERR PFX "bnx2fc_interface_setup failed\n"); | ||
1979 | goto ifput_err; | 1910 | goto ifput_err; |
1980 | } | 1911 | } |
1981 | 1912 | ||
1982 | hba->timer_work_queue = | 1913 | interface->vlan_id = vlan_id; |
1914 | interface->vlan_enabled = 1; | ||
1915 | |||
1916 | interface->timer_work_queue = | ||
1983 | create_singlethread_workqueue("bnx2fc_timer_wq"); | 1917 | create_singlethread_workqueue("bnx2fc_timer_wq"); |
1984 | if (!hba->timer_work_queue) { | 1918 | if (!interface->timer_work_queue) { |
1985 | printk(KERN_ERR PFX "ulp_init could not create timer_wq\n"); | 1919 | printk(KERN_ERR PFX "ulp_init could not create timer_wq\n"); |
1986 | rc = -EINVAL; | 1920 | rc = -EINVAL; |
1987 | goto ifput_err; | 1921 | goto ifput_err; |
1988 | } | 1922 | } |
1989 | 1923 | ||
1990 | lport = bnx2fc_if_create(hba, &hba->pcidev->dev, 0); | 1924 | lport = bnx2fc_if_create(interface, &interface->hba->pcidev->dev, 0); |
1991 | if (!lport) { | 1925 | if (!lport) { |
1992 | printk(KERN_ERR PFX "Failed to create interface (%s)\n", | 1926 | printk(KERN_ERR PFX "Failed to create interface (%s)\n", |
1993 | netdev->name); | 1927 | netdev->name); |
1994 | bnx2fc_netdev_cleanup(hba); | 1928 | bnx2fc_netdev_cleanup(interface); |
1995 | rc = -EINVAL; | 1929 | rc = -EINVAL; |
1996 | goto if_create_err; | 1930 | goto if_create_err; |
1997 | } | 1931 | } |
1998 | 1932 | ||
1933 | /* Add interface to if_list */ | ||
1934 | list_add_tail(&interface->list, &if_list); | ||
1935 | |||
1999 | lport->boot_time = jiffies; | 1936 | lport->boot_time = jiffies; |
2000 | 1937 | ||
2001 | /* Make this master N_port */ | 1938 | /* Make this master N_port */ |
2002 | hba->ctlr.lp = lport; | 1939 | interface->ctlr.lp = lport; |
2003 | 1940 | ||
2004 | set_bit(BNX2FC_CREATE_DONE, &hba->init_done); | 1941 | BNX2FC_HBA_DBG(lport, "create: START DISC\n"); |
2005 | printk(KERN_ERR PFX "create: START DISC\n"); | 1942 | bnx2fc_start_disc(interface); |
2006 | bnx2fc_start_disc(hba); | ||
2007 | /* | 1943 | /* |
2008 | * Release from kref_init in bnx2fc_interface_setup, on success | 1944 | * Release from kref_init in bnx2fc_interface_setup, on success |
2009 | * lport should be holding a reference taken in bnx2fc_if_create | 1945 | * lport should be holding a reference taken in bnx2fc_if_create |
2010 | */ | 1946 | */ |
2011 | bnx2fc_interface_put(hba); | 1947 | bnx2fc_interface_put(interface); |
2012 | /* put netdev that was held while calling dev_get_by_name */ | 1948 | /* put netdev that was held while calling dev_get_by_name */ |
2013 | mutex_unlock(&bnx2fc_dev_lock); | 1949 | mutex_unlock(&bnx2fc_dev_lock); |
2014 | rtnl_unlock(); | 1950 | rtnl_unlock(); |
2015 | return 0; | 1951 | return 0; |
2016 | 1952 | ||
2017 | if_create_err: | 1953 | if_create_err: |
2018 | destroy_workqueue(hba->timer_work_queue); | 1954 | destroy_workqueue(interface->timer_work_queue); |
2019 | ifput_err: | 1955 | ifput_err: |
2020 | bnx2fc_interface_put(hba); | 1956 | bnx2fc_interface_put(interface); |
2021 | netdev_err: | 1957 | netdev_err: |
2022 | module_put(THIS_MODULE); | 1958 | module_put(THIS_MODULE); |
2023 | mod_err: | 1959 | mod_err: |
@@ -2027,7 +1963,7 @@ mod_err: | |||
2027 | } | 1963 | } |
2028 | 1964 | ||
2029 | /** | 1965 | /** |
2030 | * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc adapter instance | 1966 | * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance |
2031 | * | 1967 | * |
2032 | * @cnic: Pointer to cnic device instance | 1968 | * @cnic: Pointer to cnic device instance |
2033 | * | 1969 | * |
@@ -2047,19 +1983,30 @@ static struct bnx2fc_hba *bnx2fc_find_hba_for_cnic(struct cnic_dev *cnic) | |||
2047 | return NULL; | 1983 | return NULL; |
2048 | } | 1984 | } |
2049 | 1985 | ||
2050 | static struct bnx2fc_hba *bnx2fc_hba_lookup(struct net_device *phys_dev) | 1986 | static struct bnx2fc_interface *bnx2fc_interface_lookup(struct net_device |
1987 | *netdev) | ||
1988 | { | ||
1989 | struct bnx2fc_interface *interface; | ||
1990 | |||
1991 | /* Called with bnx2fc_dev_lock held */ | ||
1992 | list_for_each_entry(interface, &if_list, list) { | ||
1993 | if (interface->netdev == netdev) | ||
1994 | return interface; | ||
1995 | } | ||
1996 | return NULL; | ||
1997 | } | ||
1998 | |||
1999 | static struct bnx2fc_hba *bnx2fc_hba_lookup(struct net_device | ||
2000 | *phys_dev) | ||
2051 | { | 2001 | { |
2052 | struct list_head *list; | ||
2053 | struct list_head *temp; | ||
2054 | struct bnx2fc_hba *hba; | 2002 | struct bnx2fc_hba *hba; |
2055 | 2003 | ||
2056 | /* Called with bnx2fc_dev_lock held */ | 2004 | /* Called with bnx2fc_dev_lock held */ |
2057 | list_for_each_safe(list, temp, &adapter_list) { | 2005 | list_for_each_entry(hba, &adapter_list, list) { |
2058 | hba = (struct bnx2fc_hba *)list; | ||
2059 | if (hba->phys_dev == phys_dev) | 2006 | if (hba->phys_dev == phys_dev) |
2060 | return hba; | 2007 | return hba; |
2061 | } | 2008 | } |
2062 | printk(KERN_ERR PFX "hba_lookup: hba NULL\n"); | 2009 | printk(KERN_ERR PFX "adapter_lookup: hba NULL\n"); |
2063 | return NULL; | 2010 | return NULL; |
2064 | } | 2011 | } |
2065 | 2012 | ||
@@ -2071,6 +2018,8 @@ static struct bnx2fc_hba *bnx2fc_hba_lookup(struct net_device *phys_dev) | |||
2071 | static void bnx2fc_ulp_exit(struct cnic_dev *dev) | 2018 | static void bnx2fc_ulp_exit(struct cnic_dev *dev) |
2072 | { | 2019 | { |
2073 | struct bnx2fc_hba *hba; | 2020 | struct bnx2fc_hba *hba; |
2021 | struct bnx2fc_interface *interface, *tmp; | ||
2022 | struct fc_lport *lport; | ||
2074 | 2023 | ||
2075 | BNX2FC_MISC_DBG("Entered bnx2fc_ulp_exit\n"); | 2024 | BNX2FC_MISC_DBG("Entered bnx2fc_ulp_exit\n"); |
2076 | 2025 | ||
@@ -2089,13 +2038,20 @@ static void bnx2fc_ulp_exit(struct cnic_dev *dev) | |||
2089 | return; | 2038 | return; |
2090 | } | 2039 | } |
2091 | 2040 | ||
2092 | list_del_init(&hba->link); | 2041 | list_del_init(&hba->list); |
2093 | adapter_count--; | 2042 | adapter_count--; |
2094 | 2043 | ||
2095 | if (test_bit(BNX2FC_CREATE_DONE, &hba->init_done)) { | 2044 | list_for_each_entry_safe(interface, tmp, &if_list, list) { |
2096 | /* destroy not called yet, move to quiesced list */ | 2045 | /* destroy not called yet, move to quiesced list */ |
2097 | bnx2fc_netdev_cleanup(hba); | 2046 | if (interface->hba == hba) { |
2098 | bnx2fc_if_destroy(hba->ctlr.lp); | 2047 | bnx2fc_netdev_cleanup(interface); |
2048 | bnx2fc_stop(interface); | ||
2049 | |||
2050 | list_del(&interface->list); | ||
2051 | lport = interface->ctlr.lp; | ||
2052 | bnx2fc_interface_put(interface); | ||
2053 | bnx2fc_if_destroy(lport, hba); | ||
2054 | } | ||
2099 | } | 2055 | } |
2100 | mutex_unlock(&bnx2fc_dev_lock); | 2056 | mutex_unlock(&bnx2fc_dev_lock); |
2101 | 2057 | ||
@@ -2103,7 +2059,7 @@ static void bnx2fc_ulp_exit(struct cnic_dev *dev) | |||
2103 | /* unregister cnic device */ | 2059 | /* unregister cnic device */ |
2104 | if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) | 2060 | if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) |
2105 | hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); | 2061 | hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); |
2106 | bnx2fc_interface_destroy(hba); | 2062 | bnx2fc_hba_destroy(hba); |
2107 | } | 2063 | } |
2108 | 2064 | ||
2109 | /** | 2065 | /** |
@@ -2259,6 +2215,7 @@ static int __init bnx2fc_mod_init(void) | |||
2259 | } | 2215 | } |
2260 | 2216 | ||
2261 | INIT_LIST_HEAD(&adapter_list); | 2217 | INIT_LIST_HEAD(&adapter_list); |
2218 | INIT_LIST_HEAD(&if_list); | ||
2262 | mutex_init(&bnx2fc_dev_lock); | 2219 | mutex_init(&bnx2fc_dev_lock); |
2263 | adapter_count = 0; | 2220 | adapter_count = 0; |
2264 | 2221 | ||
@@ -2336,16 +2293,17 @@ static void __exit bnx2fc_mod_exit(void) | |||
2336 | mutex_unlock(&bnx2fc_dev_lock); | 2293 | mutex_unlock(&bnx2fc_dev_lock); |
2337 | 2294 | ||
2338 | /* Unregister with cnic */ | 2295 | /* Unregister with cnic */ |
2339 | list_for_each_entry_safe(hba, next, &to_be_deleted, link) { | 2296 | list_for_each_entry_safe(hba, next, &to_be_deleted, list) { |
2340 | list_del_init(&hba->link); | 2297 | list_del_init(&hba->list); |
2341 | printk(KERN_ERR PFX "MOD_EXIT:destroy hba = 0x%p, kref = %d\n", | 2298 | printk(KERN_ERR PFX "MOD_EXIT:destroy hba = 0x%p\n", |
2342 | hba, atomic_read(&hba->kref.refcount)); | 2299 | hba); |
2343 | bnx2fc_ulp_stop(hba); | 2300 | bnx2fc_ulp_stop(hba); |
2344 | /* unregister cnic device */ | 2301 | /* unregister cnic device */ |
2345 | if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, | 2302 | if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, |
2346 | &hba->reg_with_cnic)) | 2303 | &hba->reg_with_cnic)) |
2347 | hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); | 2304 | hba->cnic->unregister_device(hba->cnic, |
2348 | bnx2fc_interface_destroy(hba); | 2305 | CNIC_ULP_FCOE); |
2306 | bnx2fc_hba_destroy(hba); | ||
2349 | } | 2307 | } |
2350 | cnic_unregister_driver(CNIC_ULP_FCOE); | 2308 | cnic_unregister_driver(CNIC_ULP_FCOE); |
2351 | 2309 | ||