Lines Matching refs:hba
75 static int bnx2fc_em_config(struct fc_lport *lport, struct bnx2fc_hba *hba);
76 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba);
77 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba);
78 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba);
79 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba);
90 static int bnx2fc_fw_init(struct bnx2fc_hba *hba);
91 static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba);
172 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_cleanup() local
177 mutex_lock(&hba->hba_mutex); in bnx2fc_cleanup()
178 spin_lock_bh(&hba->hba_lock); in bnx2fc_cleanup()
180 tgt = hba->tgt_ofld_list[i]; in bnx2fc_cleanup()
184 spin_unlock_bh(&hba->hba_lock); in bnx2fc_cleanup()
187 spin_lock_bh(&hba->hba_lock); in bnx2fc_cleanup()
191 spin_unlock_bh(&hba->hba_lock); in bnx2fc_cleanup()
192 mutex_unlock(&hba->hba_mutex); in bnx2fc_cleanup()
251 struct bnx2fc_hba *hba; in bnx2fc_xmit() local
264 hba = interface->hba; in bnx2fc_xmit()
298 spin_lock_bh(&hba->hba_lock); in bnx2fc_xmit()
304 spin_unlock_bh(&hba->hba_lock); in bnx2fc_xmit()
311 spin_unlock_bh(&hba->hba_lock); in bnx2fc_xmit()
636 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_get_host_stats() local
640 fw_stats = (struct fcoe_statistics_params *)hba->stats_buffer; in bnx2fc_get_host_stats()
646 init_completion(&hba->stat_req_done); in bnx2fc_get_host_stats()
647 if (bnx2fc_send_stat_req(hba)) in bnx2fc_get_host_stats()
649 rc = wait_for_completion_timeout(&hba->stat_req_done, (2 * HZ)); in bnx2fc_get_host_stats()
654 BNX2FC_STATS(hba, rx_stat2, fc_crc_cnt); in bnx2fc_get_host_stats()
655 bnx2fc_stats->invalid_crc_count += hba->bfw_stats.fc_crc_cnt; in bnx2fc_get_host_stats()
656 BNX2FC_STATS(hba, tx_stat, fcoe_tx_pkt_cnt); in bnx2fc_get_host_stats()
657 bnx2fc_stats->tx_frames += hba->bfw_stats.fcoe_tx_pkt_cnt; in bnx2fc_get_host_stats()
658 BNX2FC_STATS(hba, tx_stat, fcoe_tx_byte_cnt); in bnx2fc_get_host_stats()
659 bnx2fc_stats->tx_words += ((hba->bfw_stats.fcoe_tx_byte_cnt) / 4); in bnx2fc_get_host_stats()
660 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_pkt_cnt); in bnx2fc_get_host_stats()
661 bnx2fc_stats->rx_frames += hba->bfw_stats.fcoe_rx_pkt_cnt; in bnx2fc_get_host_stats()
662 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_byte_cnt); in bnx2fc_get_host_stats()
663 bnx2fc_stats->rx_words += ((hba->bfw_stats.fcoe_rx_byte_cnt) / 4); in bnx2fc_get_host_stats()
672 memcpy(&hba->prev_stats, hba->stats_buffer, in bnx2fc_get_host_stats()
681 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_shost_config() local
704 BNX2FC_NAME, hba->chip_num, BNX2FC_VERSION, in bnx2fc_shost_config()
714 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_link_ok() local
715 struct net_device *dev = hba->phys_dev; in bnx2fc_link_ok()
719 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_link_ok()
721 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_link_ok()
734 void bnx2fc_get_link_state(struct bnx2fc_hba *hba) in bnx2fc_get_link_state() argument
736 if (test_bit(__LINK_STATE_NOCARRIER, &hba->phys_dev->state)) in bnx2fc_get_link_state()
737 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_get_link_state()
739 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_get_link_state()
744 struct bnx2fc_hba *hba; in bnx2fc_net_config() local
753 hba = interface->hba; in bnx2fc_net_config()
756 if (!hba->phys_dev->ethtool_ops || in bnx2fc_net_config()
757 !hba->phys_dev->ethtool_ops->get_pauseparam) in bnx2fc_net_config()
789 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)data; in bnx2fc_destroy_timer() local
793 set_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_destroy_timer()
794 wake_up_interruptible(&hba->destroy_wait); in bnx2fc_destroy_timer()
810 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; in bnx2fc_indicate_netevent() local
824 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) in bnx2fc_indicate_netevent()
830 clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2fc_indicate_netevent()
831 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_indicate_netevent()
836 set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2fc_indicate_netevent()
848 if (interface->hba == hba && in bnx2fc_indicate_netevent()
866 if (interface->hba != hba) in bnx2fc_indicate_netevent()
920 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_indicate_netevent()
921 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_indicate_netevent()
924 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
925 hba->wait_for_link_down = 1; in bnx2fc_indicate_netevent()
926 wait_event_interruptible(hba->shutdown_wait, in bnx2fc_indicate_netevent()
927 (hba->num_ofld_sess == 0)); in bnx2fc_indicate_netevent()
929 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
930 hba->wait_for_link_down = 0; in bnx2fc_indicate_netevent()
951 static int bnx2fc_em_config(struct fc_lport *lport, struct bnx2fc_hba *hba) in bnx2fc_em_config() argument
955 fcoe_min_xid = hba->max_xid + 1; in bnx2fc_em_config()
957 fcoe_max_xid = hba->max_xid + FCOE_XIDS_PER_CPU_OFFSET; in bnx2fc_em_config()
959 fcoe_max_xid = hba->max_xid + FCOE_MAX_XID_OFFSET; in bnx2fc_em_config()
1080 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_vport_create()
1108 static void bnx2fc_free_vport(struct bnx2fc_hba *hba, struct fc_lport *lport) in bnx2fc_free_vport() argument
1112 spin_lock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1113 list_for_each_entry_safe(blport, tmp, &hba->vports, list) { in bnx2fc_free_vport()
1119 spin_unlock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1145 bnx2fc_free_vport(interface->hba, port->lport); in bnx2fc_vport_destroy()
1171 struct net_device *physdev = interface->hba->phys_dev; in bnx2fc_interface_setup()
1273 static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba) in bnx2fc_hba_destroy() argument
1276 if (hba->cmd_mgr) { in bnx2fc_hba_destroy()
1277 bnx2fc_cmd_mgr_free(hba->cmd_mgr); in bnx2fc_hba_destroy()
1278 hba->cmd_mgr = NULL; in bnx2fc_hba_destroy()
1280 kfree(hba->tgt_ofld_list); in bnx2fc_hba_destroy()
1281 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_destroy()
1282 kfree(hba); in bnx2fc_hba_destroy()
1295 struct bnx2fc_hba *hba; in bnx2fc_hba_create() local
1299 hba = kzalloc(sizeof(*hba), GFP_KERNEL); in bnx2fc_hba_create()
1300 if (!hba) { in bnx2fc_hba_create()
1304 spin_lock_init(&hba->hba_lock); in bnx2fc_hba_create()
1305 mutex_init(&hba->hba_mutex); in bnx2fc_hba_create()
1307 hba->cnic = cnic; in bnx2fc_hba_create()
1309 hba->max_tasks = cnic->max_fcoe_exchanges; in bnx2fc_hba_create()
1310 hba->elstm_xids = (hba->max_tasks / 2); in bnx2fc_hba_create()
1311 hba->max_outstanding_cmds = hba->elstm_xids; in bnx2fc_hba_create()
1312 hba->max_xid = (hba->max_tasks - 1); in bnx2fc_hba_create()
1314 rc = bnx2fc_bind_pcidev(hba); in bnx2fc_hba_create()
1319 hba->phys_dev = cnic->netdev; in bnx2fc_hba_create()
1320 hba->next_conn_id = 0; in bnx2fc_hba_create()
1322 hba->tgt_ofld_list = in bnx2fc_hba_create()
1325 if (!hba->tgt_ofld_list) { in bnx2fc_hba_create()
1330 hba->num_ofld_sess = 0; in bnx2fc_hba_create()
1332 hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba); in bnx2fc_hba_create()
1333 if (!hba->cmd_mgr) { in bnx2fc_hba_create()
1337 fcoe_cap = &hba->fcoe_cap; in bnx2fc_hba_create()
1343 fcoe_cap->capability2 = hba->max_outstanding_cmds << in bnx2fc_hba_create()
1349 fcoe_cap->capability3 |= hba->max_outstanding_cmds << in bnx2fc_hba_create()
1353 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_hba_create()
1354 init_waitqueue_head(&hba->destroy_wait); in bnx2fc_hba_create()
1355 INIT_LIST_HEAD(&hba->vports); in bnx2fc_hba_create()
1357 return hba; in bnx2fc_hba_create()
1360 kfree(hba->tgt_ofld_list); in bnx2fc_hba_create()
1362 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_create()
1364 kfree(hba); in bnx2fc_hba_create()
1368 struct bnx2fc_interface *bnx2fc_interface_create(struct bnx2fc_hba *hba, in bnx2fc_interface_create() argument
1390 interface->hba = hba; in bnx2fc_interface_create()
1430 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_if_create() local
1440 bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds; in bnx2fc_if_create()
1492 rc = bnx2fc_em_config(lport, hba); in bnx2fc_if_create()
1506 spin_lock_bh(&hba->hba_lock); in bnx2fc_if_create()
1508 list_add_tail(&blport->list, &hba->vports); in bnx2fc_if_create()
1509 spin_unlock_bh(&hba->hba_lock); in bnx2fc_if_create()
1535 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_interface_cleanup() local
1545 bnx2fc_free_vport(hba, lport); in bnx2fc_interface_cleanup()
1635 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_unbind_adapter_devices() argument
1637 bnx2fc_free_fw_resc(hba); in bnx2fc_unbind_adapter_devices()
1638 bnx2fc_free_task_ctx(hba); in bnx2fc_unbind_adapter_devices()
1647 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_bind_adapter_devices() argument
1649 if (bnx2fc_setup_task_ctx(hba)) in bnx2fc_bind_adapter_devices()
1652 if (bnx2fc_setup_fw_resc(hba)) in bnx2fc_bind_adapter_devices()
1657 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_bind_adapter_devices()
1661 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_bind_pcidev() argument
1666 if (!hba->cnic) { in bnx2fc_bind_pcidev()
1670 cnic = hba->cnic; in bnx2fc_bind_pcidev()
1671 pdev = hba->pcidev = cnic->pcidev; in bnx2fc_bind_pcidev()
1672 if (!hba->pcidev) in bnx2fc_bind_pcidev()
1677 strncpy(hba->chip_num, "BCM57710", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1680 strncpy(hba->chip_num, "BCM57711", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1685 strncpy(hba->chip_num, "BCM57712", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1690 strncpy(hba->chip_num, "BCM57800", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1695 strncpy(hba->chip_num, "BCM57810", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1702 strncpy(hba->chip_num, "BCM57840", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1708 pci_dev_get(hba->pcidev); in bnx2fc_bind_pcidev()
1712 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_unbind_pcidev() argument
1714 if (hba->pcidev) { in bnx2fc_unbind_pcidev()
1715 hba->chip_num[0] = '\0'; in bnx2fc_unbind_pcidev()
1716 pci_dev_put(hba->pcidev); in bnx2fc_unbind_pcidev()
1718 hba->pcidev = NULL; in bnx2fc_unbind_pcidev()
1728 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_get_stats() local
1732 if (!hba) in bnx2fc_ulp_get_stats()
1735 cnic = hba->cnic; in bnx2fc_ulp_get_stats()
1764 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_start() local
1771 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_start()
1772 bnx2fc_fw_init(hba); in bnx2fc_ulp_start()
1777 if (interface->hba == hba) { in bnx2fc_ulp_start()
1803 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) in bnx2fc_stop()
1819 static int bnx2fc_fw_init(struct bnx2fc_hba *hba) in bnx2fc_fw_init() argument
1825 rc = bnx2fc_bind_adapter_devices(hba); in bnx2fc_fw_init()
1832 rc = bnx2fc_send_fw_fcoe_init_msg(hba); in bnx2fc_fw_init()
1843 while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--) in bnx2fc_fw_init()
1846 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) { in bnx2fc_fw_init()
1849 hba->cnic->netdev->name); in bnx2fc_fw_init()
1855 set_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags); in bnx2fc_fw_init()
1859 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_init()
1864 static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) in bnx2fc_fw_destroy() argument
1866 if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) { in bnx2fc_fw_destroy()
1867 if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) { in bnx2fc_fw_destroy()
1868 init_timer(&hba->destroy_timer); in bnx2fc_fw_destroy()
1869 hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT + in bnx2fc_fw_destroy()
1871 hba->destroy_timer.function = bnx2fc_destroy_timer; in bnx2fc_fw_destroy()
1872 hba->destroy_timer.data = (unsigned long)hba; in bnx2fc_fw_destroy()
1873 add_timer(&hba->destroy_timer); in bnx2fc_fw_destroy()
1874 wait_event_interruptible(hba->destroy_wait, in bnx2fc_fw_destroy()
1876 &hba->flags)); in bnx2fc_fw_destroy()
1877 clear_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_fw_destroy()
1882 del_timer_sync(&hba->destroy_timer); in bnx2fc_fw_destroy()
1884 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_destroy()
1898 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_stop() local
1904 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_stop()
1907 if (interface->hba == hba) in bnx2fc_ulp_stop()
1910 BUG_ON(hba->num_ofld_sess != 0); in bnx2fc_ulp_stop()
1912 mutex_lock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1913 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_ulp_stop()
1915 &hba->adapter_state); in bnx2fc_ulp_stop()
1917 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_ulp_stop()
1918 mutex_unlock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1920 bnx2fc_fw_destroy(hba); in bnx2fc_ulp_stop()
1933 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_start_disc()
1945 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in bnx2fc_start_disc()
1975 struct bnx2fc_hba *hba; in bnx2fc_ulp_init() local
1988 hba = bnx2fc_hba_create(dev); in bnx2fc_ulp_init()
1989 if (!hba) { in bnx2fc_ulp_init()
1996 list_add_tail(&hba->list, &adapter_list); in bnx2fc_ulp_init()
2000 dev->fcoe_cap = &hba->fcoe_cap; in bnx2fc_ulp_init()
2001 clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2003 (void *) hba); in bnx2fc_ulp_init()
2007 set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2148 struct bnx2fc_hba *hba; in _bnx2fc_create() local
2190 hba = bnx2fc_hba_lookup(phys_dev); in _bnx2fc_create()
2191 if (!hba) { in _bnx2fc_create()
2202 interface = bnx2fc_interface_create(hba, netdev, fip_mode); in _bnx2fc_create()
2251 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in _bnx2fc_create()
2323 struct bnx2fc_hba *hba; in bnx2fc_find_hba_for_cnic() local
2326 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_find_hba_for_cnic()
2327 if (hba->cnic == cnic) in bnx2fc_find_hba_for_cnic()
2328 return hba; in bnx2fc_find_hba_for_cnic()
2349 struct bnx2fc_hba *hba; in bnx2fc_hba_lookup() local
2352 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_hba_lookup()
2353 if (hba->phys_dev == phys_dev) in bnx2fc_hba_lookup()
2354 return hba; in bnx2fc_hba_lookup()
2367 struct bnx2fc_hba *hba; in bnx2fc_ulp_exit() local
2379 hba = bnx2fc_find_hba_for_cnic(dev); in bnx2fc_ulp_exit()
2380 if (!hba) { in bnx2fc_ulp_exit()
2387 list_del_init(&hba->list); in bnx2fc_ulp_exit()
2392 if (interface->hba == hba) in bnx2fc_ulp_exit()
2399 bnx2fc_ulp_stop(hba); in bnx2fc_ulp_exit()
2401 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) in bnx2fc_ulp_exit()
2402 hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); in bnx2fc_ulp_exit()
2403 bnx2fc_hba_destroy(hba); in bnx2fc_ulp_exit()
2624 struct bnx2fc_hba *hba, *next; in bnx2fc_mod_exit() local
2643 list_for_each_entry_safe(hba, next, &to_be_deleted, list) { in bnx2fc_mod_exit()
2644 list_del_init(&hba->list); in bnx2fc_mod_exit()
2646 hba); in bnx2fc_mod_exit()
2647 bnx2fc_ulp_stop(hba); in bnx2fc_mod_exit()
2650 &hba->reg_with_cnic)) in bnx2fc_mod_exit()
2651 hba->cnic->unregister_device(hba->cnic, in bnx2fc_mod_exit()
2653 bnx2fc_hba_destroy(hba); in bnx2fc_mod_exit()