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()
865 if (interface->hba != hba) in bnx2fc_indicate_netevent()
919 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_indicate_netevent()
920 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_indicate_netevent()
923 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
924 hba->wait_for_link_down = 1; in bnx2fc_indicate_netevent()
925 wait_event_interruptible(hba->shutdown_wait, in bnx2fc_indicate_netevent()
926 (hba->num_ofld_sess == 0)); in bnx2fc_indicate_netevent()
928 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
929 hba->wait_for_link_down = 0; in bnx2fc_indicate_netevent()
950 static int bnx2fc_em_config(struct fc_lport *lport, struct bnx2fc_hba *hba) in bnx2fc_em_config() argument
954 fcoe_min_xid = hba->max_xid + 1; in bnx2fc_em_config()
956 fcoe_max_xid = hba->max_xid + FCOE_XIDS_PER_CPU_OFFSET; in bnx2fc_em_config()
958 fcoe_max_xid = hba->max_xid + FCOE_MAX_XID_OFFSET; in bnx2fc_em_config()
1079 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_vport_create()
1107 static void bnx2fc_free_vport(struct bnx2fc_hba *hba, struct fc_lport *lport) in bnx2fc_free_vport() argument
1111 spin_lock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1112 list_for_each_entry_safe(blport, tmp, &hba->vports, list) { in bnx2fc_free_vport()
1118 spin_unlock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1144 bnx2fc_free_vport(interface->hba, port->lport); in bnx2fc_vport_destroy()
1170 struct net_device *physdev = interface->hba->phys_dev; in bnx2fc_interface_setup()
1272 static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba) in bnx2fc_hba_destroy() argument
1275 if (hba->cmd_mgr) { in bnx2fc_hba_destroy()
1276 bnx2fc_cmd_mgr_free(hba->cmd_mgr); in bnx2fc_hba_destroy()
1277 hba->cmd_mgr = NULL; in bnx2fc_hba_destroy()
1279 kfree(hba->tgt_ofld_list); in bnx2fc_hba_destroy()
1280 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_destroy()
1281 kfree(hba); in bnx2fc_hba_destroy()
1294 struct bnx2fc_hba *hba; in bnx2fc_hba_create() local
1298 hba = kzalloc(sizeof(*hba), GFP_KERNEL); in bnx2fc_hba_create()
1299 if (!hba) { in bnx2fc_hba_create()
1303 spin_lock_init(&hba->hba_lock); in bnx2fc_hba_create()
1304 mutex_init(&hba->hba_mutex); in bnx2fc_hba_create()
1306 hba->cnic = cnic; in bnx2fc_hba_create()
1308 hba->max_tasks = cnic->max_fcoe_exchanges; in bnx2fc_hba_create()
1309 hba->elstm_xids = (hba->max_tasks / 2); in bnx2fc_hba_create()
1310 hba->max_outstanding_cmds = hba->elstm_xids; in bnx2fc_hba_create()
1311 hba->max_xid = (hba->max_tasks - 1); in bnx2fc_hba_create()
1313 rc = bnx2fc_bind_pcidev(hba); in bnx2fc_hba_create()
1318 hba->phys_dev = cnic->netdev; in bnx2fc_hba_create()
1319 hba->next_conn_id = 0; in bnx2fc_hba_create()
1321 hba->tgt_ofld_list = in bnx2fc_hba_create()
1324 if (!hba->tgt_ofld_list) { in bnx2fc_hba_create()
1329 hba->num_ofld_sess = 0; in bnx2fc_hba_create()
1331 hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba); in bnx2fc_hba_create()
1332 if (!hba->cmd_mgr) { in bnx2fc_hba_create()
1336 fcoe_cap = &hba->fcoe_cap; in bnx2fc_hba_create()
1342 fcoe_cap->capability2 = hba->max_outstanding_cmds << in bnx2fc_hba_create()
1348 fcoe_cap->capability3 |= hba->max_outstanding_cmds << in bnx2fc_hba_create()
1352 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_hba_create()
1353 init_waitqueue_head(&hba->destroy_wait); in bnx2fc_hba_create()
1354 INIT_LIST_HEAD(&hba->vports); in bnx2fc_hba_create()
1356 return hba; in bnx2fc_hba_create()
1359 kfree(hba->tgt_ofld_list); in bnx2fc_hba_create()
1361 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_create()
1363 kfree(hba); in bnx2fc_hba_create()
1367 struct bnx2fc_interface *bnx2fc_interface_create(struct bnx2fc_hba *hba, in bnx2fc_interface_create() argument
1389 interface->hba = hba; in bnx2fc_interface_create()
1429 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_if_create() local
1439 bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds; in bnx2fc_if_create()
1491 rc = bnx2fc_em_config(lport, hba); in bnx2fc_if_create()
1505 spin_lock_bh(&hba->hba_lock); in bnx2fc_if_create()
1507 list_add_tail(&blport->list, &hba->vports); in bnx2fc_if_create()
1508 spin_unlock_bh(&hba->hba_lock); in bnx2fc_if_create()
1534 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_interface_cleanup() local
1544 bnx2fc_free_vport(hba, lport); in bnx2fc_interface_cleanup()
1634 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_unbind_adapter_devices() argument
1636 bnx2fc_free_fw_resc(hba); in bnx2fc_unbind_adapter_devices()
1637 bnx2fc_free_task_ctx(hba); in bnx2fc_unbind_adapter_devices()
1646 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_bind_adapter_devices() argument
1648 if (bnx2fc_setup_task_ctx(hba)) in bnx2fc_bind_adapter_devices()
1651 if (bnx2fc_setup_fw_resc(hba)) in bnx2fc_bind_adapter_devices()
1656 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_bind_adapter_devices()
1660 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_bind_pcidev() argument
1665 if (!hba->cnic) { in bnx2fc_bind_pcidev()
1669 cnic = hba->cnic; in bnx2fc_bind_pcidev()
1670 pdev = hba->pcidev = cnic->pcidev; in bnx2fc_bind_pcidev()
1671 if (!hba->pcidev) in bnx2fc_bind_pcidev()
1676 strncpy(hba->chip_num, "BCM57710", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1679 strncpy(hba->chip_num, "BCM57711", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1684 strncpy(hba->chip_num, "BCM57712", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1689 strncpy(hba->chip_num, "BCM57800", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1694 strncpy(hba->chip_num, "BCM57810", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1701 strncpy(hba->chip_num, "BCM57840", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1707 pci_dev_get(hba->pcidev); in bnx2fc_bind_pcidev()
1711 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_unbind_pcidev() argument
1713 if (hba->pcidev) { in bnx2fc_unbind_pcidev()
1714 hba->chip_num[0] = '\0'; in bnx2fc_unbind_pcidev()
1715 pci_dev_put(hba->pcidev); in bnx2fc_unbind_pcidev()
1717 hba->pcidev = NULL; in bnx2fc_unbind_pcidev()
1727 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_get_stats() local
1731 if (!hba) in bnx2fc_ulp_get_stats()
1734 cnic = hba->cnic; in bnx2fc_ulp_get_stats()
1763 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_start() local
1770 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_start()
1771 bnx2fc_fw_init(hba); in bnx2fc_ulp_start()
1776 if (interface->hba == hba) { in bnx2fc_ulp_start()
1802 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) in bnx2fc_stop()
1818 static int bnx2fc_fw_init(struct bnx2fc_hba *hba) in bnx2fc_fw_init() argument
1824 rc = bnx2fc_bind_adapter_devices(hba); in bnx2fc_fw_init()
1831 rc = bnx2fc_send_fw_fcoe_init_msg(hba); in bnx2fc_fw_init()
1842 while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--) in bnx2fc_fw_init()
1845 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) { in bnx2fc_fw_init()
1848 hba->cnic->netdev->name); in bnx2fc_fw_init()
1854 set_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags); in bnx2fc_fw_init()
1858 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_init()
1863 static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) in bnx2fc_fw_destroy() argument
1865 if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) { in bnx2fc_fw_destroy()
1866 if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) { in bnx2fc_fw_destroy()
1867 init_timer(&hba->destroy_timer); in bnx2fc_fw_destroy()
1868 hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT + in bnx2fc_fw_destroy()
1870 hba->destroy_timer.function = bnx2fc_destroy_timer; in bnx2fc_fw_destroy()
1871 hba->destroy_timer.data = (unsigned long)hba; in bnx2fc_fw_destroy()
1872 add_timer(&hba->destroy_timer); in bnx2fc_fw_destroy()
1873 wait_event_interruptible(hba->destroy_wait, in bnx2fc_fw_destroy()
1875 &hba->flags)); in bnx2fc_fw_destroy()
1876 clear_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_fw_destroy()
1881 del_timer_sync(&hba->destroy_timer); in bnx2fc_fw_destroy()
1883 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_destroy()
1897 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_stop() local
1903 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_stop()
1906 if (interface->hba == hba) in bnx2fc_ulp_stop()
1909 BUG_ON(hba->num_ofld_sess != 0); in bnx2fc_ulp_stop()
1911 mutex_lock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1912 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_ulp_stop()
1914 &hba->adapter_state); in bnx2fc_ulp_stop()
1916 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_ulp_stop()
1917 mutex_unlock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1919 bnx2fc_fw_destroy(hba); in bnx2fc_ulp_stop()
1932 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_start_disc()
1944 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in bnx2fc_start_disc()
1974 struct bnx2fc_hba *hba; in bnx2fc_ulp_init() local
1987 hba = bnx2fc_hba_create(dev); in bnx2fc_ulp_init()
1988 if (!hba) { in bnx2fc_ulp_init()
1995 list_add_tail(&hba->list, &adapter_list); in bnx2fc_ulp_init()
1999 dev->fcoe_cap = &hba->fcoe_cap; in bnx2fc_ulp_init()
2000 clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2002 (void *) hba); in bnx2fc_ulp_init()
2006 set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2093 struct bnx2fc_hba *hba; in __bnx2fc_enable() local
2108 hba = interface->hba; in __bnx2fc_enable()
2111 if (!hba) in __bnx2fc_enable()
2114 if (!hba->cnic) in __bnx2fc_enable()
2123 if (!hba->cnic->get_fc_npiv_tbl) in __bnx2fc_enable()
2130 if (hba->cnic->get_fc_npiv_tbl(hba->cnic, npiv_tbl)) in __bnx2fc_enable()
2218 struct bnx2fc_hba *hba; in _bnx2fc_create() local
2260 hba = bnx2fc_hba_lookup(phys_dev); in _bnx2fc_create()
2261 if (!hba) { in _bnx2fc_create()
2272 interface = bnx2fc_interface_create(hba, netdev, fip_mode); in _bnx2fc_create()
2321 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in _bnx2fc_create()
2393 struct bnx2fc_hba *hba; in bnx2fc_find_hba_for_cnic() local
2396 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_find_hba_for_cnic()
2397 if (hba->cnic == cnic) in bnx2fc_find_hba_for_cnic()
2398 return hba; in bnx2fc_find_hba_for_cnic()
2419 struct bnx2fc_hba *hba; in bnx2fc_hba_lookup() local
2422 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_hba_lookup()
2423 if (hba->phys_dev == phys_dev) in bnx2fc_hba_lookup()
2424 return hba; in bnx2fc_hba_lookup()
2437 struct bnx2fc_hba *hba; in bnx2fc_ulp_exit() local
2449 hba = bnx2fc_find_hba_for_cnic(dev); in bnx2fc_ulp_exit()
2450 if (!hba) { in bnx2fc_ulp_exit()
2457 list_del_init(&hba->list); in bnx2fc_ulp_exit()
2462 if (interface->hba == hba) in bnx2fc_ulp_exit()
2469 bnx2fc_ulp_stop(hba); in bnx2fc_ulp_exit()
2471 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) in bnx2fc_ulp_exit()
2472 hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); in bnx2fc_ulp_exit()
2473 bnx2fc_hba_destroy(hba); in bnx2fc_ulp_exit()
2694 struct bnx2fc_hba *hba, *next; in bnx2fc_mod_exit() local
2713 list_for_each_entry_safe(hba, next, &to_be_deleted, list) { in bnx2fc_mod_exit()
2714 list_del_init(&hba->list); in bnx2fc_mod_exit()
2716 hba); in bnx2fc_mod_exit()
2717 bnx2fc_ulp_stop(hba); in bnx2fc_mod_exit()
2720 &hba->reg_with_cnic)) in bnx2fc_mod_exit()
2721 hba->cnic->unregister_device(hba->cnic, in bnx2fc_mod_exit()
2723 bnx2fc_hba_destroy(hba); in bnx2fc_mod_exit()