Lines Matching full: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
284 hba = interface->hba; in bnx2fc_xmit()
314 * both hba mutex and hba lock. Atleast hba mutex or in bnx2fc_xmit()
315 * hba lock needs to be held for read access. in bnx2fc_xmit()
318 spin_lock_bh(&hba->hba_lock); in bnx2fc_xmit()
324 spin_unlock_bh(&hba->hba_lock); in bnx2fc_xmit()
331 spin_unlock_bh(&hba->hba_lock); in bnx2fc_xmit()
682 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_get_host_stats() local
686 fw_stats = (struct fcoe_statistics_params *)hba->stats_buffer; in bnx2fc_get_host_stats()
690 mutex_lock(&hba->hba_stats_mutex); in bnx2fc_get_host_stats()
694 init_completion(&hba->stat_req_done); in bnx2fc_get_host_stats()
695 if (bnx2fc_send_stat_req(hba)) in bnx2fc_get_host_stats()
697 rc = wait_for_completion_timeout(&hba->stat_req_done, (2 * HZ)); in bnx2fc_get_host_stats()
702 BNX2FC_STATS(hba, rx_stat2, fc_crc_cnt); in bnx2fc_get_host_stats()
703 bnx2fc_stats->invalid_crc_count += hba->bfw_stats.fc_crc_cnt; in bnx2fc_get_host_stats()
704 BNX2FC_STATS(hba, tx_stat, fcoe_tx_pkt_cnt); in bnx2fc_get_host_stats()
705 bnx2fc_stats->tx_frames += hba->bfw_stats.fcoe_tx_pkt_cnt; in bnx2fc_get_host_stats()
706 BNX2FC_STATS(hba, tx_stat, fcoe_tx_byte_cnt); in bnx2fc_get_host_stats()
707 bnx2fc_stats->tx_words += ((hba->bfw_stats.fcoe_tx_byte_cnt) / 4); in bnx2fc_get_host_stats()
708 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_pkt_cnt); in bnx2fc_get_host_stats()
709 bnx2fc_stats->rx_frames += hba->bfw_stats.fcoe_rx_pkt_cnt; in bnx2fc_get_host_stats()
710 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_byte_cnt); in bnx2fc_get_host_stats()
711 bnx2fc_stats->rx_words += ((hba->bfw_stats.fcoe_rx_byte_cnt) / 4); in bnx2fc_get_host_stats()
720 memcpy(&hba->prev_stats, hba->stats_buffer, in bnx2fc_get_host_stats()
724 mutex_unlock(&hba->hba_stats_mutex); in bnx2fc_get_host_stats()
732 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_shost_config() local
755 BNX2FC_NAME, hba->chip_num, BNX2FC_VERSION, in bnx2fc_shost_config()
765 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_link_ok() local
766 struct net_device *dev = hba->phys_dev; in bnx2fc_link_ok()
770 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_link_ok()
772 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_link_ok()
781 * @hba: adapter instance pointer
785 void bnx2fc_get_link_state(struct bnx2fc_hba *hba) in bnx2fc_get_link_state() argument
787 if (test_bit(__LINK_STATE_NOCARRIER, &hba->phys_dev->state)) in bnx2fc_get_link_state()
788 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_get_link_state()
790 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_get_link_state()
795 struct bnx2fc_hba *hba; in bnx2fc_net_config() local
804 hba = interface->hba; in bnx2fc_net_config()
807 if (!hba->phys_dev->ethtool_ops || in bnx2fc_net_config()
808 !hba->phys_dev->ethtool_ops->get_pauseparam) in bnx2fc_net_config()
840 struct bnx2fc_hba *hba = from_timer(hba, t, destroy_timer); in bnx2fc_destroy_timer() local
844 set_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_destroy_timer()
845 wake_up_interruptible(&hba->destroy_wait); in bnx2fc_destroy_timer()
861 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; in bnx2fc_indicate_netevent() local
875 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) in bnx2fc_indicate_netevent()
877 "hba is not UP!!\n"); in bnx2fc_indicate_netevent()
881 clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2fc_indicate_netevent()
882 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_indicate_netevent()
887 set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2fc_indicate_netevent()
899 if (interface->hba == hba && in bnx2fc_indicate_netevent()
913 if (interface->hba != hba) in bnx2fc_indicate_netevent()
965 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_indicate_netevent()
966 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_indicate_netevent()
969 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
970 hba->wait_for_link_down = 1; in bnx2fc_indicate_netevent()
971 wait_event_interruptible(hba->shutdown_wait, in bnx2fc_indicate_netevent()
972 (hba->num_ofld_sess == 0)); in bnx2fc_indicate_netevent()
974 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
975 hba->wait_for_link_down = 0; in bnx2fc_indicate_netevent()
995 static int bnx2fc_em_config(struct fc_lport *lport, struct bnx2fc_hba *hba) in bnx2fc_em_config() argument
999 fcoe_min_xid = hba->max_xid + 1; in bnx2fc_em_config()
1001 fcoe_max_xid = hba->max_xid + FCOE_XIDS_PER_CPU_OFFSET; in bnx2fc_em_config()
1003 fcoe_max_xid = hba->max_xid + FCOE_MAX_XID_OFFSET; in bnx2fc_em_config()
1137 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_vport_create()
1168 static void bnx2fc_free_vport(struct bnx2fc_hba *hba, struct fc_lport *lport) in bnx2fc_free_vport() argument
1172 spin_lock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1173 list_for_each_entry_safe(blport, tmp, &hba->vports, list) { in bnx2fc_free_vport()
1179 spin_unlock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1205 bnx2fc_free_vport(interface->hba, port->lport); in bnx2fc_vport_destroy()
1231 struct net_device *physdev = interface->hba->phys_dev; in bnx2fc_interface_setup()
1333 static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba) in bnx2fc_hba_destroy() argument
1336 if (hba->cmd_mgr) { in bnx2fc_hba_destroy()
1337 bnx2fc_cmd_mgr_free(hba->cmd_mgr); in bnx2fc_hba_destroy()
1338 hba->cmd_mgr = NULL; in bnx2fc_hba_destroy()
1340 kfree(hba->tgt_ofld_list); in bnx2fc_hba_destroy()
1341 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_destroy()
1342 kfree(hba); in bnx2fc_hba_destroy()
1346 * bnx2fc_hba_create - create a new bnx2fc hba
1350 * Creates a new FCoE hba on the given device.
1355 struct bnx2fc_hba *hba; in bnx2fc_hba_create() local
1359 hba = kzalloc(sizeof(*hba), GFP_KERNEL); in bnx2fc_hba_create()
1360 if (!hba) { in bnx2fc_hba_create()
1361 printk(KERN_ERR PFX "Unable to allocate hba structure\n"); in bnx2fc_hba_create()
1364 spin_lock_init(&hba->hba_lock); in bnx2fc_hba_create()
1365 mutex_init(&hba->hba_mutex); in bnx2fc_hba_create()
1366 mutex_init(&hba->hba_stats_mutex); in bnx2fc_hba_create()
1368 hba->cnic = cnic; in bnx2fc_hba_create()
1370 hba->max_tasks = cnic->max_fcoe_exchanges; in bnx2fc_hba_create()
1371 hba->elstm_xids = (hba->max_tasks / 2); in bnx2fc_hba_create()
1372 hba->max_outstanding_cmds = hba->elstm_xids; in bnx2fc_hba_create()
1373 hba->max_xid = (hba->max_tasks - 1); in bnx2fc_hba_create()
1375 rc = bnx2fc_bind_pcidev(hba); in bnx2fc_hba_create()
1380 hba->phys_dev = cnic->netdev; in bnx2fc_hba_create()
1381 hba->next_conn_id = 0; in bnx2fc_hba_create()
1383 hba->tgt_ofld_list = in bnx2fc_hba_create()
1386 if (!hba->tgt_ofld_list) { in bnx2fc_hba_create()
1391 hba->num_ofld_sess = 0; in bnx2fc_hba_create()
1393 hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba); in bnx2fc_hba_create()
1394 if (!hba->cmd_mgr) { in bnx2fc_hba_create()
1398 fcoe_cap = &hba->fcoe_cap; in bnx2fc_hba_create()
1404 fcoe_cap->capability2 = hba->max_outstanding_cmds << in bnx2fc_hba_create()
1410 fcoe_cap->capability3 |= hba->max_outstanding_cmds << in bnx2fc_hba_create()
1414 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_hba_create()
1415 init_waitqueue_head(&hba->destroy_wait); in bnx2fc_hba_create()
1416 INIT_LIST_HEAD(&hba->vports); in bnx2fc_hba_create()
1418 return hba; in bnx2fc_hba_create()
1421 kfree(hba->tgt_ofld_list); in bnx2fc_hba_create()
1423 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_create()
1425 kfree(hba); in bnx2fc_hba_create()
1430 bnx2fc_interface_create(struct bnx2fc_hba *hba, in bnx2fc_interface_create() argument
1452 interface->hba = hba; in bnx2fc_interface_create()
1492 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_if_create() local
1502 bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds; in bnx2fc_if_create()
1556 rc = bnx2fc_em_config(lport, hba); in bnx2fc_if_create()
1570 spin_lock_bh(&hba->hba_lock); in bnx2fc_if_create()
1572 list_add_tail(&blport->list, &hba->vports); in bnx2fc_if_create()
1573 spin_unlock_bh(&hba->hba_lock); in bnx2fc_if_create()
1599 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_interface_cleanup() local
1609 bnx2fc_free_vport(hba, lport); in bnx2fc_interface_cleanup()
1695 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_unbind_adapter_devices() argument
1697 bnx2fc_free_fw_resc(hba); in bnx2fc_unbind_adapter_devices()
1698 bnx2fc_free_task_ctx(hba); in bnx2fc_unbind_adapter_devices()
1705 * @hba: Adapter instance
1707 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_bind_adapter_devices() argument
1709 if (bnx2fc_setup_task_ctx(hba)) in bnx2fc_bind_adapter_devices()
1712 if (bnx2fc_setup_fw_resc(hba)) in bnx2fc_bind_adapter_devices()
1717 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_bind_adapter_devices()
1721 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_bind_pcidev() argument
1726 if (!hba->cnic) { in bnx2fc_bind_pcidev()
1730 cnic = hba->cnic; in bnx2fc_bind_pcidev()
1731 pdev = hba->pcidev = cnic->pcidev; in bnx2fc_bind_pcidev()
1732 if (!hba->pcidev) in bnx2fc_bind_pcidev()
1737 strscpy(hba->chip_num, "BCM57710", sizeof(hba->chip_num)); in bnx2fc_bind_pcidev()
1740 strscpy(hba->chip_num, "BCM57711", sizeof(hba->chip_num)); in bnx2fc_bind_pcidev()
1745 strscpy(hba->chip_num, "BCM57712", sizeof(hba->chip_num)); in bnx2fc_bind_pcidev()
1750 strscpy(hba->chip_num, "BCM57800", sizeof(hba->chip_num)); in bnx2fc_bind_pcidev()
1755 strscpy(hba->chip_num, "BCM57810", sizeof(hba->chip_num)); in bnx2fc_bind_pcidev()
1762 strscpy(hba->chip_num, "BCM57840", sizeof(hba->chip_num)); in bnx2fc_bind_pcidev()
1768 pci_dev_get(hba->pcidev); in bnx2fc_bind_pcidev()
1772 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_unbind_pcidev() argument
1774 if (hba->pcidev) { in bnx2fc_unbind_pcidev()
1775 hba->chip_num[0] = '\0'; in bnx2fc_unbind_pcidev()
1776 pci_dev_put(hba->pcidev); in bnx2fc_unbind_pcidev()
1778 hba->pcidev = NULL; in bnx2fc_unbind_pcidev()
1788 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_get_stats() local
1792 if (!hba) in bnx2fc_ulp_get_stats()
1795 cnic = hba->cnic; in bnx2fc_ulp_get_stats()
1824 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_start() local
1831 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_start()
1832 bnx2fc_fw_init(hba); in bnx2fc_ulp_start()
1837 if (interface->hba == hba) { in bnx2fc_ulp_start()
1863 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) in bnx2fc_stop()
1879 static int bnx2fc_fw_init(struct bnx2fc_hba *hba) in bnx2fc_fw_init() argument
1885 rc = bnx2fc_bind_adapter_devices(hba); in bnx2fc_fw_init()
1892 rc = bnx2fc_send_fw_fcoe_init_msg(hba); in bnx2fc_fw_init()
1903 while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--) in bnx2fc_fw_init()
1906 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) { in bnx2fc_fw_init()
1909 hba->cnic->netdev->name); in bnx2fc_fw_init()
1915 set_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags); in bnx2fc_fw_init()
1919 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_init()
1924 static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) in bnx2fc_fw_destroy() argument
1926 if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) { in bnx2fc_fw_destroy()
1927 if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) { in bnx2fc_fw_destroy()
1928 timer_setup(&hba->destroy_timer, bnx2fc_destroy_timer, in bnx2fc_fw_destroy()
1930 hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT + in bnx2fc_fw_destroy()
1932 add_timer(&hba->destroy_timer); in bnx2fc_fw_destroy()
1933 wait_event_interruptible(hba->destroy_wait, in bnx2fc_fw_destroy()
1935 &hba->flags)); in bnx2fc_fw_destroy()
1936 clear_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_fw_destroy()
1941 del_timer_sync(&hba->destroy_timer); in bnx2fc_fw_destroy()
1943 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_destroy()
1957 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_stop() local
1963 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_stop()
1966 if (interface->hba == hba) in bnx2fc_ulp_stop()
1969 BUG_ON(hba->num_ofld_sess != 0); in bnx2fc_ulp_stop()
1971 mutex_lock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1972 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_ulp_stop()
1974 &hba->adapter_state); in bnx2fc_ulp_stop()
1976 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_ulp_stop()
1977 mutex_unlock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1979 bnx2fc_fw_destroy(hba); in bnx2fc_ulp_stop()
1992 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_start_disc()
2004 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in bnx2fc_start_disc()
2034 struct bnx2fc_hba *hba; in bnx2fc_ulp_init() local
2047 hba = bnx2fc_hba_create(dev); in bnx2fc_ulp_init()
2048 if (!hba) { in bnx2fc_ulp_init()
2049 printk(KERN_ERR PFX "hba initialization failed\n"); in bnx2fc_ulp_init()
2055 /* Add HBA to the adapter list */ in bnx2fc_ulp_init()
2057 list_add_tail(&hba->list, &adapter_list); in bnx2fc_ulp_init()
2061 dev->fcoe_cap = &hba->fcoe_cap; in bnx2fc_ulp_init()
2062 clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2064 (void *) hba); in bnx2fc_ulp_init()
2068 set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2170 struct bnx2fc_hba *hba; in __bnx2fc_enable() local
2185 hba = interface->hba; in __bnx2fc_enable()
2188 if (!hba) in __bnx2fc_enable()
2191 if (!hba->cnic) in __bnx2fc_enable()
2200 if (!hba->cnic->get_fc_npiv_tbl) in __bnx2fc_enable()
2207 if (hba->cnic->get_fc_npiv_tbl(hba->cnic, npiv_tbl)) in __bnx2fc_enable()
2295 struct bnx2fc_hba *hba; in _bnx2fc_create() local
2337 hba = bnx2fc_hba_lookup(phys_dev); in _bnx2fc_create()
2338 if (!hba) { in _bnx2fc_create()
2340 printk(KERN_ERR PFX "bnx2fc_create: hba not found\n"); in _bnx2fc_create()
2349 interface = bnx2fc_interface_create(hba, netdev, fip_mode); in _bnx2fc_create()
2399 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in _bnx2fc_create()
2464 * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
2471 struct bnx2fc_hba *hba; in bnx2fc_find_hba_for_cnic() local
2474 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_find_hba_for_cnic()
2475 if (hba->cnic == cnic) in bnx2fc_find_hba_for_cnic()
2476 return hba; in bnx2fc_find_hba_for_cnic()
2497 struct bnx2fc_hba *hba; in bnx2fc_hba_lookup() local
2500 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_hba_lookup()
2501 if (hba->phys_dev == phys_dev) in bnx2fc_hba_lookup()
2502 return hba; in bnx2fc_hba_lookup()
2504 printk(KERN_ERR PFX "adapter_lookup: hba NULL\n"); in bnx2fc_hba_lookup()
2515 struct bnx2fc_hba *hba; in bnx2fc_ulp_exit() local
2527 hba = bnx2fc_find_hba_for_cnic(dev); in bnx2fc_ulp_exit()
2528 if (!hba) { in bnx2fc_ulp_exit()
2529 printk(KERN_ERR PFX "bnx2fc_ulp_exit: hba not found, dev 0%p\n", in bnx2fc_ulp_exit()
2535 list_del_init(&hba->list); in bnx2fc_ulp_exit()
2540 if (interface->hba == hba) in bnx2fc_ulp_exit()
2544 bnx2fc_ulp_stop(hba); in bnx2fc_ulp_exit()
2546 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) in bnx2fc_ulp_exit()
2547 hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); in bnx2fc_ulp_exit()
2548 bnx2fc_hba_destroy(hba); in bnx2fc_ulp_exit()
2747 struct bnx2fc_hba *hba, *next; in bnx2fc_mod_exit() local
2764 list_for_each_entry_safe(hba, next, &to_be_deleted, list) { in bnx2fc_mod_exit()
2765 list_del_init(&hba->list); in bnx2fc_mod_exit()
2766 printk(KERN_ERR PFX "MOD_EXIT:destroy hba = 0x%p\n", in bnx2fc_mod_exit()
2767 hba); in bnx2fc_mod_exit()
2768 bnx2fc_ulp_stop(hba); in bnx2fc_mod_exit()
2771 &hba->reg_with_cnic)) in bnx2fc_mod_exit()
2772 hba->cnic->unregister_device(hba->cnic, in bnx2fc_mod_exit()
2774 bnx2fc_hba_destroy(hba); in bnx2fc_mod_exit()