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()
685 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_get_host_stats() local
689 fw_stats = (struct fcoe_statistics_params *)hba->stats_buffer; in bnx2fc_get_host_stats()
693 mutex_lock(&hba->hba_stats_mutex); in bnx2fc_get_host_stats()
697 init_completion(&hba->stat_req_done); in bnx2fc_get_host_stats()
698 if (bnx2fc_send_stat_req(hba)) in bnx2fc_get_host_stats()
700 rc = wait_for_completion_timeout(&hba->stat_req_done, (2 * HZ)); in bnx2fc_get_host_stats()
705 BNX2FC_STATS(hba, rx_stat2, fc_crc_cnt); in bnx2fc_get_host_stats()
706 bnx2fc_stats->invalid_crc_count += hba->bfw_stats.fc_crc_cnt; in bnx2fc_get_host_stats()
707 BNX2FC_STATS(hba, tx_stat, fcoe_tx_pkt_cnt); in bnx2fc_get_host_stats()
708 bnx2fc_stats->tx_frames += hba->bfw_stats.fcoe_tx_pkt_cnt; in bnx2fc_get_host_stats()
709 BNX2FC_STATS(hba, tx_stat, fcoe_tx_byte_cnt); in bnx2fc_get_host_stats()
710 bnx2fc_stats->tx_words += ((hba->bfw_stats.fcoe_tx_byte_cnt) / 4); in bnx2fc_get_host_stats()
711 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_pkt_cnt); in bnx2fc_get_host_stats()
712 bnx2fc_stats->rx_frames += hba->bfw_stats.fcoe_rx_pkt_cnt; in bnx2fc_get_host_stats()
713 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_byte_cnt); in bnx2fc_get_host_stats()
714 bnx2fc_stats->rx_words += ((hba->bfw_stats.fcoe_rx_byte_cnt) / 4); in bnx2fc_get_host_stats()
723 memcpy(&hba->prev_stats, hba->stats_buffer, in bnx2fc_get_host_stats()
727 mutex_unlock(&hba->hba_stats_mutex); in bnx2fc_get_host_stats()
735 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_shost_config() local
758 BNX2FC_NAME, hba->chip_num, BNX2FC_VERSION, in bnx2fc_shost_config()
768 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_link_ok() local
769 struct net_device *dev = hba->phys_dev; in bnx2fc_link_ok()
773 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_link_ok()
775 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_link_ok()
784 * @hba: adapter instance pointer
788 void bnx2fc_get_link_state(struct bnx2fc_hba *hba) in bnx2fc_get_link_state() argument
790 if (test_bit(__LINK_STATE_NOCARRIER, &hba->phys_dev->state)) in bnx2fc_get_link_state()
791 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_get_link_state()
793 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state); in bnx2fc_get_link_state()
798 struct bnx2fc_hba *hba; in bnx2fc_net_config() local
807 hba = interface->hba; in bnx2fc_net_config()
810 if (!hba->phys_dev->ethtool_ops || in bnx2fc_net_config()
811 !hba->phys_dev->ethtool_ops->get_pauseparam) in bnx2fc_net_config()
843 struct bnx2fc_hba *hba = from_timer(hba, t, destroy_timer); in bnx2fc_destroy_timer() local
847 set_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_destroy_timer()
848 wake_up_interruptible(&hba->destroy_wait); in bnx2fc_destroy_timer()
864 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context; in bnx2fc_indicate_netevent() local
878 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) in bnx2fc_indicate_netevent()
880 "hba is not UP!!\n"); in bnx2fc_indicate_netevent()
884 clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2fc_indicate_netevent()
885 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_indicate_netevent()
890 set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state); in bnx2fc_indicate_netevent()
902 if (interface->hba == hba && in bnx2fc_indicate_netevent()
916 if (interface->hba != hba) in bnx2fc_indicate_netevent()
968 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_indicate_netevent()
969 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_indicate_netevent()
972 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
973 hba->wait_for_link_down = 1; in bnx2fc_indicate_netevent()
974 wait_event_interruptible(hba->shutdown_wait, in bnx2fc_indicate_netevent()
975 (hba->num_ofld_sess == 0)); in bnx2fc_indicate_netevent()
977 hba->num_ofld_sess); in bnx2fc_indicate_netevent()
978 hba->wait_for_link_down = 0; in bnx2fc_indicate_netevent()
998 static int bnx2fc_em_config(struct fc_lport *lport, struct bnx2fc_hba *hba) in bnx2fc_em_config() argument
1002 fcoe_min_xid = hba->max_xid + 1; in bnx2fc_em_config()
1004 fcoe_max_xid = hba->max_xid + FCOE_XIDS_PER_CPU_OFFSET; in bnx2fc_em_config()
1006 fcoe_max_xid = hba->max_xid + FCOE_MAX_XID_OFFSET; in bnx2fc_em_config()
1140 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_vport_create()
1171 static void bnx2fc_free_vport(struct bnx2fc_hba *hba, struct fc_lport *lport) in bnx2fc_free_vport() argument
1175 spin_lock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1176 list_for_each_entry_safe(blport, tmp, &hba->vports, list) { in bnx2fc_free_vport()
1182 spin_unlock_bh(&hba->hba_lock); in bnx2fc_free_vport()
1208 bnx2fc_free_vport(interface->hba, port->lport); in bnx2fc_vport_destroy()
1234 struct net_device *physdev = interface->hba->phys_dev; in bnx2fc_interface_setup()
1336 static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba) in bnx2fc_hba_destroy() argument
1339 if (hba->cmd_mgr) { in bnx2fc_hba_destroy()
1340 bnx2fc_cmd_mgr_free(hba->cmd_mgr); in bnx2fc_hba_destroy()
1341 hba->cmd_mgr = NULL; in bnx2fc_hba_destroy()
1343 kfree(hba->tgt_ofld_list); in bnx2fc_hba_destroy()
1344 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_destroy()
1345 kfree(hba); in bnx2fc_hba_destroy()
1349 * bnx2fc_hba_create - create a new bnx2fc hba
1353 * Creates a new FCoE hba on the given device.
1358 struct bnx2fc_hba *hba; in bnx2fc_hba_create() local
1362 hba = kzalloc(sizeof(*hba), GFP_KERNEL); in bnx2fc_hba_create()
1363 if (!hba) { in bnx2fc_hba_create()
1364 printk(KERN_ERR PFX "Unable to allocate hba structure\n"); in bnx2fc_hba_create()
1367 spin_lock_init(&hba->hba_lock); in bnx2fc_hba_create()
1368 mutex_init(&hba->hba_mutex); in bnx2fc_hba_create()
1369 mutex_init(&hba->hba_stats_mutex); in bnx2fc_hba_create()
1371 hba->cnic = cnic; in bnx2fc_hba_create()
1373 hba->max_tasks = cnic->max_fcoe_exchanges; in bnx2fc_hba_create()
1374 hba->elstm_xids = (hba->max_tasks / 2); in bnx2fc_hba_create()
1375 hba->max_outstanding_cmds = hba->elstm_xids; in bnx2fc_hba_create()
1376 hba->max_xid = (hba->max_tasks - 1); in bnx2fc_hba_create()
1378 rc = bnx2fc_bind_pcidev(hba); in bnx2fc_hba_create()
1383 hba->phys_dev = cnic->netdev; in bnx2fc_hba_create()
1384 hba->next_conn_id = 0; in bnx2fc_hba_create()
1386 hba->tgt_ofld_list = in bnx2fc_hba_create()
1389 if (!hba->tgt_ofld_list) { in bnx2fc_hba_create()
1394 hba->num_ofld_sess = 0; in bnx2fc_hba_create()
1396 hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba); in bnx2fc_hba_create()
1397 if (!hba->cmd_mgr) { in bnx2fc_hba_create()
1401 fcoe_cap = &hba->fcoe_cap; in bnx2fc_hba_create()
1407 fcoe_cap->capability2 = hba->max_outstanding_cmds << in bnx2fc_hba_create()
1413 fcoe_cap->capability3 |= hba->max_outstanding_cmds << in bnx2fc_hba_create()
1417 init_waitqueue_head(&hba->shutdown_wait); in bnx2fc_hba_create()
1418 init_waitqueue_head(&hba->destroy_wait); in bnx2fc_hba_create()
1419 INIT_LIST_HEAD(&hba->vports); in bnx2fc_hba_create()
1421 return hba; in bnx2fc_hba_create()
1424 kfree(hba->tgt_ofld_list); in bnx2fc_hba_create()
1426 bnx2fc_unbind_pcidev(hba); in bnx2fc_hba_create()
1428 kfree(hba); in bnx2fc_hba_create()
1433 bnx2fc_interface_create(struct bnx2fc_hba *hba, in bnx2fc_interface_create() argument
1455 interface->hba = hba; in bnx2fc_interface_create()
1495 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_if_create() local
1505 bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds; in bnx2fc_if_create()
1559 rc = bnx2fc_em_config(lport, hba); in bnx2fc_if_create()
1573 spin_lock_bh(&hba->hba_lock); in bnx2fc_if_create()
1575 list_add_tail(&blport->list, &hba->vports); in bnx2fc_if_create()
1576 spin_unlock_bh(&hba->hba_lock); in bnx2fc_if_create()
1602 struct bnx2fc_hba *hba = interface->hba; in bnx2fc_interface_cleanup() local
1612 bnx2fc_free_vport(hba, lport); in bnx2fc_interface_cleanup()
1698 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_unbind_adapter_devices() argument
1700 bnx2fc_free_fw_resc(hba); in bnx2fc_unbind_adapter_devices()
1701 bnx2fc_free_task_ctx(hba); in bnx2fc_unbind_adapter_devices()
1708 * @hba: Adapter instance
1710 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba) in bnx2fc_bind_adapter_devices() argument
1712 if (bnx2fc_setup_task_ctx(hba)) in bnx2fc_bind_adapter_devices()
1715 if (bnx2fc_setup_fw_resc(hba)) in bnx2fc_bind_adapter_devices()
1720 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_bind_adapter_devices()
1724 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_bind_pcidev() argument
1729 if (!hba->cnic) { in bnx2fc_bind_pcidev()
1733 cnic = hba->cnic; in bnx2fc_bind_pcidev()
1734 pdev = hba->pcidev = cnic->pcidev; in bnx2fc_bind_pcidev()
1735 if (!hba->pcidev) in bnx2fc_bind_pcidev()
1740 strncpy(hba->chip_num, "BCM57710", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1743 strncpy(hba->chip_num, "BCM57711", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1748 strncpy(hba->chip_num, "BCM57712", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1753 strncpy(hba->chip_num, "BCM57800", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1758 strncpy(hba->chip_num, "BCM57810", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1765 strncpy(hba->chip_num, "BCM57840", BCM_CHIP_LEN); in bnx2fc_bind_pcidev()
1771 pci_dev_get(hba->pcidev); in bnx2fc_bind_pcidev()
1775 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba) in bnx2fc_unbind_pcidev() argument
1777 if (hba->pcidev) { in bnx2fc_unbind_pcidev()
1778 hba->chip_num[0] = '\0'; in bnx2fc_unbind_pcidev()
1779 pci_dev_put(hba->pcidev); in bnx2fc_unbind_pcidev()
1781 hba->pcidev = NULL; in bnx2fc_unbind_pcidev()
1791 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_get_stats() local
1795 if (!hba) in bnx2fc_ulp_get_stats()
1798 cnic = hba->cnic; in bnx2fc_ulp_get_stats()
1827 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_start() local
1834 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_start()
1835 bnx2fc_fw_init(hba); in bnx2fc_ulp_start()
1840 if (interface->hba == hba) { in bnx2fc_ulp_start()
1866 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) in bnx2fc_stop()
1882 static int bnx2fc_fw_init(struct bnx2fc_hba *hba) in bnx2fc_fw_init() argument
1888 rc = bnx2fc_bind_adapter_devices(hba); in bnx2fc_fw_init()
1895 rc = bnx2fc_send_fw_fcoe_init_msg(hba); in bnx2fc_fw_init()
1906 while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--) in bnx2fc_fw_init()
1909 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) { in bnx2fc_fw_init()
1912 hba->cnic->netdev->name); in bnx2fc_fw_init()
1918 set_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags); in bnx2fc_fw_init()
1922 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_init()
1927 static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba) in bnx2fc_fw_destroy() argument
1929 if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) { in bnx2fc_fw_destroy()
1930 if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) { in bnx2fc_fw_destroy()
1931 timer_setup(&hba->destroy_timer, bnx2fc_destroy_timer, in bnx2fc_fw_destroy()
1933 hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT + in bnx2fc_fw_destroy()
1935 add_timer(&hba->destroy_timer); in bnx2fc_fw_destroy()
1936 wait_event_interruptible(hba->destroy_wait, in bnx2fc_fw_destroy()
1938 &hba->flags)); in bnx2fc_fw_destroy()
1939 clear_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags); in bnx2fc_fw_destroy()
1944 del_timer_sync(&hba->destroy_timer); in bnx2fc_fw_destroy()
1946 bnx2fc_unbind_adapter_devices(hba); in bnx2fc_fw_destroy()
1960 struct bnx2fc_hba *hba = handle; in bnx2fc_ulp_stop() local
1966 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) in bnx2fc_ulp_stop()
1969 if (interface->hba == hba) in bnx2fc_ulp_stop()
1972 BUG_ON(hba->num_ofld_sess != 0); in bnx2fc_ulp_stop()
1974 mutex_lock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1975 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state); in bnx2fc_ulp_stop()
1977 &hba->adapter_state); in bnx2fc_ulp_stop()
1979 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state); in bnx2fc_ulp_stop()
1980 mutex_unlock(&hba->hba_mutex); in bnx2fc_ulp_stop()
1982 bnx2fc_fw_destroy(hba); in bnx2fc_ulp_stop()
1995 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) { in bnx2fc_start_disc()
2007 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in bnx2fc_start_disc()
2037 struct bnx2fc_hba *hba; in bnx2fc_ulp_init() local
2050 hba = bnx2fc_hba_create(dev); in bnx2fc_ulp_init()
2051 if (!hba) { in bnx2fc_ulp_init()
2052 printk(KERN_ERR PFX "hba initialization failed\n"); in bnx2fc_ulp_init()
2058 /* Add HBA to the adapter list */ in bnx2fc_ulp_init()
2060 list_add_tail(&hba->list, &adapter_list); in bnx2fc_ulp_init()
2064 dev->fcoe_cap = &hba->fcoe_cap; in bnx2fc_ulp_init()
2065 clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2067 (void *) hba); in bnx2fc_ulp_init()
2071 set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic); in bnx2fc_ulp_init()
2173 struct bnx2fc_hba *hba; in __bnx2fc_enable() local
2188 hba = interface->hba; in __bnx2fc_enable()
2191 if (!hba) in __bnx2fc_enable()
2194 if (!hba->cnic) in __bnx2fc_enable()
2203 if (!hba->cnic->get_fc_npiv_tbl) in __bnx2fc_enable()
2210 if (hba->cnic->get_fc_npiv_tbl(hba->cnic, npiv_tbl)) in __bnx2fc_enable()
2298 struct bnx2fc_hba *hba; in _bnx2fc_create() local
2340 hba = bnx2fc_hba_lookup(phys_dev); in _bnx2fc_create()
2341 if (!hba) { in _bnx2fc_create()
2343 printk(KERN_ERR PFX "bnx2fc_create: hba not found\n"); in _bnx2fc_create()
2352 interface = bnx2fc_interface_create(hba, netdev, fip_mode); in _bnx2fc_create()
2402 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state); in _bnx2fc_create()
2467 * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
2474 struct bnx2fc_hba *hba; in bnx2fc_find_hba_for_cnic() local
2477 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_find_hba_for_cnic()
2478 if (hba->cnic == cnic) in bnx2fc_find_hba_for_cnic()
2479 return hba; in bnx2fc_find_hba_for_cnic()
2500 struct bnx2fc_hba *hba; in bnx2fc_hba_lookup() local
2503 list_for_each_entry(hba, &adapter_list, list) { in bnx2fc_hba_lookup()
2504 if (hba->phys_dev == phys_dev) in bnx2fc_hba_lookup()
2505 return hba; in bnx2fc_hba_lookup()
2507 printk(KERN_ERR PFX "adapter_lookup: hba NULL\n"); in bnx2fc_hba_lookup()
2518 struct bnx2fc_hba *hba; in bnx2fc_ulp_exit() local
2530 hba = bnx2fc_find_hba_for_cnic(dev); in bnx2fc_ulp_exit()
2531 if (!hba) { in bnx2fc_ulp_exit()
2532 printk(KERN_ERR PFX "bnx2fc_ulp_exit: hba not found, dev 0%p\n", in bnx2fc_ulp_exit()
2538 list_del_init(&hba->list); in bnx2fc_ulp_exit()
2543 if (interface->hba == hba) in bnx2fc_ulp_exit()
2547 bnx2fc_ulp_stop(hba); in bnx2fc_ulp_exit()
2549 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) in bnx2fc_ulp_exit()
2550 hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE); in bnx2fc_ulp_exit()
2551 bnx2fc_hba_destroy(hba); in bnx2fc_ulp_exit()
2752 struct bnx2fc_hba *hba, *next; in bnx2fc_mod_exit() local
2769 list_for_each_entry_safe(hba, next, &to_be_deleted, list) { in bnx2fc_mod_exit()
2770 list_del_init(&hba->list); in bnx2fc_mod_exit()
2771 printk(KERN_ERR PFX "MOD_EXIT:destroy hba = 0x%p\n", in bnx2fc_mod_exit()
2772 hba); in bnx2fc_mod_exit()
2773 bnx2fc_ulp_stop(hba); in bnx2fc_mod_exit()
2776 &hba->reg_with_cnic)) in bnx2fc_mod_exit()
2777 hba->cnic->unregister_device(hba->cnic, in bnx2fc_mod_exit()
2779 bnx2fc_hba_destroy(hba); in bnx2fc_mod_exit()