Lines Matching refs:hba
78 static int bnx2fc_em_config(struct fc_lport *lport, struct bnx2fc_hba *hba);
79 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba);
80 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba);
81 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba);
82 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba);
93 static int bnx2fc_fw_init(struct bnx2fc_hba *hba);
94 static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba);
193 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_cleanup() local
198 mutex_lock(&hba->hba_mutex); in bnx2fc_cleanup()
199 spin_lock_bh(&hba->hba_lock); in bnx2fc_cleanup()
201 tgt = hba->tgt_ofld_list[i]; in bnx2fc_cleanup()
205 spin_unlock_bh(&hba->hba_lock); in bnx2fc_cleanup()
208 spin_lock_bh(&hba->hba_lock); in bnx2fc_cleanup()
212 spin_unlock_bh(&hba->hba_lock); in bnx2fc_cleanup()
213 mutex_unlock(&hba->hba_mutex); in bnx2fc_cleanup()
272 struct bnx2fc_hba *hba; in bnx2fc_xmit() local
285 hba = interface->hba; in bnx2fc_xmit()
319 spin_lock_bh(&hba->hba_lock); in bnx2fc_xmit()
325 spin_unlock_bh(&hba->hba_lock); in bnx2fc_xmit()
332 spin_unlock_bh(&hba->hba_lock); in bnx2fc_xmit()
688 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_get_host_stats() local
692 fw_stats = (struct fcoe_statistics_params *)hba->stats_buffer; in bnx2fc_get_host_stats()
696 mutex_lock(&hba->hba_stats_mutex); in bnx2fc_get_host_stats()
700 init_completion(&hba->stat_req_done); in bnx2fc_get_host_stats()
701 if (bnx2fc_send_stat_req(hba)) in bnx2fc_get_host_stats()
703 rc = wait_for_completion_timeout(&hba->stat_req_done, (2 * HZ)); in bnx2fc_get_host_stats()
708 BNX2FC_STATS(hba, rx_stat2, fc_crc_cnt); in bnx2fc_get_host_stats()
709 bnx2fc_stats->invalid_crc_count += hba->bfw_stats.fc_crc_cnt; in bnx2fc_get_host_stats()
710 BNX2FC_STATS(hba, tx_stat, fcoe_tx_pkt_cnt); in bnx2fc_get_host_stats()
711 bnx2fc_stats->tx_frames += hba->bfw_stats.fcoe_tx_pkt_cnt; in bnx2fc_get_host_stats()
712 BNX2FC_STATS(hba, tx_stat, fcoe_tx_byte_cnt); in bnx2fc_get_host_stats()
713 bnx2fc_stats->tx_words += ((hba->bfw_stats.fcoe_tx_byte_cnt) / 4); in bnx2fc_get_host_stats()
714 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_pkt_cnt); in bnx2fc_get_host_stats()
715 bnx2fc_stats->rx_frames += hba->bfw_stats.fcoe_rx_pkt_cnt; in bnx2fc_get_host_stats()
716 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_byte_cnt); in bnx2fc_get_host_stats()
717 bnx2fc_stats->rx_words += ((hba->bfw_stats.fcoe_rx_byte_cnt) / 4); in bnx2fc_get_host_stats()
726 memcpy(&hba->prev_stats, hba->stats_buffer, in bnx2fc_get_host_stats()
730 mutex_unlock(&hba->hba_stats_mutex); in bnx2fc_get_host_stats()
738 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_shost_config() local
761 BNX2FC_NAME, hba->chip_num, BNX2FC_VERSION, in bnx2fc_shost_config()
771 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_link_ok() local
772 struct net_device *dev = hba->phys_dev; in bnx2fc_link_ok()
776 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_link_ok()
778 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_link_ok()
791 void bnx2fc_get_link_state(struct bnx2fc_hba *hba) in bnx2fc_get_link_state() argument
793 if (test_bit(__LINK_STATE_NOCARRIER, &hba->phys_dev->state)) in bnx2fc_get_link_state()
794 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_get_link_state()
796 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_get_link_state()
801 struct bnx2fc_hba *hba; in bnx2fc_net_config() local
810 hba = interface->hba; in bnx2fc_net_config()
813 if (!hba->phys_dev->ethtool_ops || in bnx2fc_net_config()
814 !hba->phys_dev->ethtool_ops->get_pauseparam) in bnx2fc_net_config()
846 struct bnx2fc_hba *hba = from_timer(hba, t, destroy_timer); in bnx2fc_destroy_timer() local
850 set_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_destroy_timer()
851 wake_up_interruptible(&hba->destroy_wait); in bnx2fc_destroy_timer()
867 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; in bnx2fc_indicate_netevent() local
881 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) in bnx2fc_indicate_netevent()
887 clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2fc_indicate_netevent()
888 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_indicate_netevent()
893 set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2fc_indicate_netevent()
905 if (interface->hba == hba && in bnx2fc_indicate_netevent()
922 if (interface->hba != hba) in bnx2fc_indicate_netevent()
976 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_indicate_netevent()
977 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_indicate_netevent()
980 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
981 hba->wait_for_link_down = 1; in bnx2fc_indicate_netevent()
982 wait_event_interruptible(hba->shutdown_wait, in bnx2fc_indicate_netevent()
983 (hba->num_ofld_sess == 0)); in bnx2fc_indicate_netevent()
985 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
986 hba->wait_for_link_down = 0; in bnx2fc_indicate_netevent()
1006 static int bnx2fc_em_config(struct fc_lport *lport, struct bnx2fc_hba *hba) in bnx2fc_em_config() argument
1010 fcoe_min_xid = hba->max_xid + 1; in bnx2fc_em_config()
1012 fcoe_max_xid = hba->max_xid + FCOE_XIDS_PER_CPU_OFFSET; in bnx2fc_em_config()
1014 fcoe_max_xid = hba->max_xid + FCOE_MAX_XID_OFFSET; in bnx2fc_em_config()
1148 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_vport_create()
1179 static void bnx2fc_free_vport(struct bnx2fc_hba *hba, struct fc_lport *lport) in bnx2fc_free_vport() argument
1183 spin_lock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1184 list_for_each_entry_safe(blport, tmp, &hba->vports, list) { in bnx2fc_free_vport()
1190 spin_unlock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1216 bnx2fc_free_vport(interface->hba, port->lport); in bnx2fc_vport_destroy()
1242 struct net_device *physdev = interface->hba->phys_dev; in bnx2fc_interface_setup()
1344 static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba) in bnx2fc_hba_destroy() argument
1347 if (hba->cmd_mgr) { in bnx2fc_hba_destroy()
1348 bnx2fc_cmd_mgr_free(hba->cmd_mgr); in bnx2fc_hba_destroy()
1349 hba->cmd_mgr = NULL; in bnx2fc_hba_destroy()
1351 kfree(hba->tgt_ofld_list); in bnx2fc_hba_destroy()
1352 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_destroy()
1353 kfree(hba); in bnx2fc_hba_destroy()
1366 struct bnx2fc_hba *hba; in bnx2fc_hba_create() local
1370 hba = kzalloc(sizeof(*hba), GFP_KERNEL); in bnx2fc_hba_create()
1371 if (!hba) { in bnx2fc_hba_create()
1375 spin_lock_init(&hba->hba_lock); in bnx2fc_hba_create()
1376 mutex_init(&hba->hba_mutex); in bnx2fc_hba_create()
1377 mutex_init(&hba->hba_stats_mutex); in bnx2fc_hba_create()
1379 hba->cnic = cnic; in bnx2fc_hba_create()
1381 hba->max_tasks = cnic->max_fcoe_exchanges; in bnx2fc_hba_create()
1382 hba->elstm_xids = (hba->max_tasks / 2); in bnx2fc_hba_create()
1383 hba->max_outstanding_cmds = hba->elstm_xids; in bnx2fc_hba_create()
1384 hba->max_xid = (hba->max_tasks - 1); in bnx2fc_hba_create()
1386 rc = bnx2fc_bind_pcidev(hba); in bnx2fc_hba_create()
1391 hba->phys_dev = cnic->netdev; in bnx2fc_hba_create()
1392 hba->next_conn_id = 0; in bnx2fc_hba_create()
1394 hba->tgt_ofld_list = in bnx2fc_hba_create()
1397 if (!hba->tgt_ofld_list) { in bnx2fc_hba_create()
1402 hba->num_ofld_sess = 0; in bnx2fc_hba_create()
1404 hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba); in bnx2fc_hba_create()
1405 if (!hba->cmd_mgr) { in bnx2fc_hba_create()
1409 fcoe_cap = &hba->fcoe_cap; in bnx2fc_hba_create()
1415 fcoe_cap->capability2 = hba->max_outstanding_cmds << in bnx2fc_hba_create()
1421 fcoe_cap->capability3 |= hba->max_outstanding_cmds << in bnx2fc_hba_create()
1425 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_hba_create()
1426 init_waitqueue_head(&hba->destroy_wait); in bnx2fc_hba_create()
1427 INIT_LIST_HEAD(&hba->vports); in bnx2fc_hba_create()
1429 return hba; in bnx2fc_hba_create()
1432 kfree(hba->tgt_ofld_list); in bnx2fc_hba_create()
1434 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_create()
1436 kfree(hba); in bnx2fc_hba_create()
1441 bnx2fc_interface_create(struct bnx2fc_hba *hba, in bnx2fc_interface_create() argument
1463 interface->hba = hba; in bnx2fc_interface_create()
1503 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_if_create() local
1513 bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds; in bnx2fc_if_create()
1568 rc = bnx2fc_em_config(lport, hba); in bnx2fc_if_create()
1582 spin_lock_bh(&hba->hba_lock); in bnx2fc_if_create()
1584 list_add_tail(&blport->list, &hba->vports); in bnx2fc_if_create()
1585 spin_unlock_bh(&hba->hba_lock); in bnx2fc_if_create()
1611 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_interface_cleanup() local
1621 bnx2fc_free_vport(hba, lport); in bnx2fc_interface_cleanup()
1710 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_unbind_adapter_devices() argument
1712 bnx2fc_free_fw_resc(hba); in bnx2fc_unbind_adapter_devices()
1713 bnx2fc_free_task_ctx(hba); in bnx2fc_unbind_adapter_devices()
1722 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_bind_adapter_devices() argument
1724 if (bnx2fc_setup_task_ctx(hba)) in bnx2fc_bind_adapter_devices()
1727 if (bnx2fc_setup_fw_resc(hba)) in bnx2fc_bind_adapter_devices()
1732 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_bind_adapter_devices()
1736 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_bind_pcidev() argument
1741 if (!hba->cnic) { in bnx2fc_bind_pcidev()
1745 cnic = hba->cnic; in bnx2fc_bind_pcidev()
1746 pdev = hba->pcidev = cnic->pcidev; in bnx2fc_bind_pcidev()
1747 if (!hba->pcidev) in bnx2fc_bind_pcidev()
1752 strncpy(hba->chip_num, "BCM57710", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1755 strncpy(hba->chip_num, "BCM57711", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1760 strncpy(hba->chip_num, "BCM57712", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1765 strncpy(hba->chip_num, "BCM57800", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1770 strncpy(hba->chip_num, "BCM57810", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1777 strncpy(hba->chip_num, "BCM57840", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1783 pci_dev_get(hba->pcidev); in bnx2fc_bind_pcidev()
1787 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_unbind_pcidev() argument
1789 if (hba->pcidev) { in bnx2fc_unbind_pcidev()
1790 hba->chip_num[0] = '\0'; in bnx2fc_unbind_pcidev()
1791 pci_dev_put(hba->pcidev); in bnx2fc_unbind_pcidev()
1793 hba->pcidev = NULL; in bnx2fc_unbind_pcidev()
1803 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_get_stats() local
1807 if (!hba) in bnx2fc_ulp_get_stats()
1810 cnic = hba->cnic; in bnx2fc_ulp_get_stats()
1839 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_start() local
1846 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_start()
1847 bnx2fc_fw_init(hba); in bnx2fc_ulp_start()
1852 if (interface->hba == hba) { in bnx2fc_ulp_start()
1878 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) in bnx2fc_stop()
1894 static int bnx2fc_fw_init(struct bnx2fc_hba *hba) in bnx2fc_fw_init() argument
1900 rc = bnx2fc_bind_adapter_devices(hba); in bnx2fc_fw_init()
1907 rc = bnx2fc_send_fw_fcoe_init_msg(hba); in bnx2fc_fw_init()
1918 while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--) in bnx2fc_fw_init()
1921 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) { in bnx2fc_fw_init()
1924 hba->cnic->netdev->name); in bnx2fc_fw_init()
1930 set_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags); in bnx2fc_fw_init()
1934 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_init()
1939 static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) in bnx2fc_fw_destroy() argument
1941 if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) { in bnx2fc_fw_destroy()
1942 if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) { in bnx2fc_fw_destroy()
1943 timer_setup(&hba->destroy_timer, bnx2fc_destroy_timer, in bnx2fc_fw_destroy()
1945 hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT + in bnx2fc_fw_destroy()
1947 add_timer(&hba->destroy_timer); in bnx2fc_fw_destroy()
1948 wait_event_interruptible(hba->destroy_wait, in bnx2fc_fw_destroy()
1950 &hba->flags)); in bnx2fc_fw_destroy()
1951 clear_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_fw_destroy()
1956 del_timer_sync(&hba->destroy_timer); in bnx2fc_fw_destroy()
1958 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_destroy()
1972 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_stop() local
1978 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_stop()
1981 if (interface->hba == hba) in bnx2fc_ulp_stop()
1984 BUG_ON(hba->num_ofld_sess != 0); in bnx2fc_ulp_stop()
1986 mutex_lock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1987 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_ulp_stop()
1989 &hba->adapter_state); in bnx2fc_ulp_stop()
1991 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_ulp_stop()
1992 mutex_unlock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1994 bnx2fc_fw_destroy(hba); in bnx2fc_ulp_stop()
2007 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_start_disc()
2019 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in bnx2fc_start_disc()
2049 struct bnx2fc_hba *hba; in bnx2fc_ulp_init() local
2062 hba = bnx2fc_hba_create(dev); in bnx2fc_ulp_init()
2063 if (!hba) { in bnx2fc_ulp_init()
2072 list_add_tail(&hba->list, &adapter_list); in bnx2fc_ulp_init()
2076 dev->fcoe_cap = &hba->fcoe_cap; in bnx2fc_ulp_init()
2077 clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2079 (void *) hba); in bnx2fc_ulp_init()
2083 set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2185 struct bnx2fc_hba *hba; in __bnx2fc_enable() local
2200 hba = interface->hba; in __bnx2fc_enable()
2203 if (!hba) in __bnx2fc_enable()
2206 if (!hba->cnic) in __bnx2fc_enable()
2215 if (!hba->cnic->get_fc_npiv_tbl) in __bnx2fc_enable()
2222 if (hba->cnic->get_fc_npiv_tbl(hba->cnic, npiv_tbl)) in __bnx2fc_enable()
2310 struct bnx2fc_hba *hba; in _bnx2fc_create() local
2352 hba = bnx2fc_hba_lookup(phys_dev); in _bnx2fc_create()
2353 if (!hba) { in _bnx2fc_create()
2364 interface = bnx2fc_interface_create(hba, netdev, fip_mode); in _bnx2fc_create()
2414 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in _bnx2fc_create()
2486 struct bnx2fc_hba *hba; in bnx2fc_find_hba_for_cnic() local
2489 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_find_hba_for_cnic()
2490 if (hba->cnic == cnic) in bnx2fc_find_hba_for_cnic()
2491 return hba; in bnx2fc_find_hba_for_cnic()
2512 struct bnx2fc_hba *hba; in bnx2fc_hba_lookup() local
2515 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_hba_lookup()
2516 if (hba->phys_dev == phys_dev) in bnx2fc_hba_lookup()
2517 return hba; in bnx2fc_hba_lookup()
2530 struct bnx2fc_hba *hba; in bnx2fc_ulp_exit() local
2542 hba = bnx2fc_find_hba_for_cnic(dev); in bnx2fc_ulp_exit()
2543 if (!hba) { in bnx2fc_ulp_exit()
2550 list_del_init(&hba->list); in bnx2fc_ulp_exit()
2555 if (interface->hba == hba) in bnx2fc_ulp_exit()
2562 bnx2fc_ulp_stop(hba); in bnx2fc_ulp_exit()
2564 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) in bnx2fc_ulp_exit()
2565 hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); in bnx2fc_ulp_exit()
2566 bnx2fc_hba_destroy(hba); in bnx2fc_ulp_exit()
2768 struct bnx2fc_hba *hba, *next; in bnx2fc_mod_exit() local
2785 list_for_each_entry_safe(hba, next, &to_be_deleted, list) { in bnx2fc_mod_exit()
2786 list_del_init(&hba->list); in bnx2fc_mod_exit()
2788 hba); in bnx2fc_mod_exit()
2789 bnx2fc_ulp_stop(hba); in bnx2fc_mod_exit()
2792 &hba->reg_with_cnic)) in bnx2fc_mod_exit()
2793 hba->cnic->unregister_device(hba->cnic, in bnx2fc_mod_exit()
2795 bnx2fc_hba_destroy(hba); in bnx2fc_mod_exit()