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;
177 mutex_lock(&hba->hba_mutex);
178 spin_lock_bh(&hba->hba_lock);
180 tgt = hba->tgt_ofld_list[i];
184 spin_unlock_bh(&hba->hba_lock);
187 spin_lock_bh(&hba->hba_lock);
191 spin_unlock_bh(&hba->hba_lock);
192 mutex_unlock(&hba->hba_mutex);
251 struct bnx2fc_hba *hba;
264 hba = interface->hba;
294 * both hba mutex and hba lock. Atleast hba mutex or
295 * hba lock needs to be held for read access.
298 spin_lock_bh(&hba->hba_lock);
304 spin_unlock_bh(&hba->hba_lock);
311 spin_unlock_bh(&hba->hba_lock);
636 struct bnx2fc_hba *hba = interface->hba;
640 fw_stats = (struct fcoe_statistics_params *)hba->stats_buffer;
646 init_completion(&hba->stat_req_done);
647 if (bnx2fc_send_stat_req(hba))
649 rc = wait_for_completion_timeout(&hba->stat_req_done, (2 * HZ));
654 BNX2FC_STATS(hba, rx_stat2, fc_crc_cnt);
655 bnx2fc_stats->invalid_crc_count += hba->bfw_stats.fc_crc_cnt;
656 BNX2FC_STATS(hba, tx_stat, fcoe_tx_pkt_cnt);
657 bnx2fc_stats->tx_frames += hba->bfw_stats.fcoe_tx_pkt_cnt;
658 BNX2FC_STATS(hba, tx_stat, fcoe_tx_byte_cnt);
659 bnx2fc_stats->tx_words += ((hba->bfw_stats.fcoe_tx_byte_cnt) / 4);
660 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_pkt_cnt);
661 bnx2fc_stats->rx_frames += hba->bfw_stats.fcoe_rx_pkt_cnt;
662 BNX2FC_STATS(hba, rx_stat0, fcoe_rx_byte_cnt);
663 bnx2fc_stats->rx_words += ((hba->bfw_stats.fcoe_rx_byte_cnt) / 4);
672 memcpy(&hba->prev_stats, hba->stats_buffer,
681 struct bnx2fc_hba *hba = interface->hba;
704 BNX2FC_NAME, hba->chip_num, BNX2FC_VERSION,
714 struct bnx2fc_hba *hba = interface->hba;
715 struct net_device *dev = hba->phys_dev;
719 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state);
721 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state);
730 * @hba: adapter instance pointer
734 void bnx2fc_get_link_state(struct bnx2fc_hba *hba)
736 if (test_bit(__LINK_STATE_NOCARRIER, &hba->phys_dev->state))
737 set_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state);
739 clear_bit(ADAPTER_STATE_LINK_DOWN, &hba->adapter_state);
744 struct bnx2fc_hba *hba;
753 hba = interface->hba;
756 if (!hba->phys_dev->ethtool_ops ||
757 !hba->phys_dev->ethtool_ops->get_pauseparam)
789 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)data;
793 set_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags);
794 wake_up_interruptible(&hba->destroy_wait);
810 struct bnx2fc_hba *hba = (struct bnx2fc_hba *)context;
824 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state))
826 "hba is not UP!!\n");
830 clear_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
831 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
836 set_bit(ADAPTER_STATE_GOING_DOWN, &hba->adapter_state);
848 if (interface->hba == hba &&
866 if (interface->hba != hba)
920 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state);
921 init_waitqueue_head(&hba->shutdown_wait);
924 hba->num_ofld_sess);
925 hba->wait_for_link_down = 1;
926 wait_event_interruptible(hba->shutdown_wait,
927 (hba->num_ofld_sess == 0));
929 hba->num_ofld_sess);
930 hba->wait_for_link_down = 0;
951 static int bnx2fc_em_config(struct fc_lport *lport, struct bnx2fc_hba *hba)
955 fcoe_min_xid = hba->max_xid + 1;
957 fcoe_max_xid = hba->max_xid + FCOE_XIDS_PER_CPU_OFFSET;
959 fcoe_max_xid = hba->max_xid + FCOE_MAX_XID_OFFSET;
1080 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) {
1108 static void bnx2fc_free_vport(struct bnx2fc_hba *hba, struct fc_lport *lport)
1112 spin_lock_bh(&hba->hba_lock);
1113 list_for_each_entry_safe(blport, tmp, &hba->vports, list) {
1119 spin_unlock_bh(&hba->hba_lock);
1145 bnx2fc_free_vport(interface->hba, port->lport);
1171 struct net_device *physdev = interface->hba->phys_dev;
1273 static void bnx2fc_hba_destroy(struct bnx2fc_hba *hba)
1276 if (hba->cmd_mgr) {
1277 bnx2fc_cmd_mgr_free(hba->cmd_mgr);
1278 hba->cmd_mgr = NULL;
1280 kfree(hba->tgt_ofld_list);
1281 bnx2fc_unbind_pcidev(hba);
1282 kfree(hba);
1286 * bnx2fc_hba_create - create a new bnx2fc hba
1290 * Creates a new FCoE hba on the given device.
1295 struct bnx2fc_hba *hba;
1299 hba = kzalloc(sizeof(*hba), GFP_KERNEL);
1300 if (!hba) {
1301 printk(KERN_ERR PFX "Unable to allocate hba structure\n");
1304 spin_lock_init(&hba->hba_lock);
1305 mutex_init(&hba->hba_mutex);
1307 hba->cnic = cnic;
1309 hba->max_tasks = cnic->max_fcoe_exchanges;
1310 hba->elstm_xids = (hba->max_tasks / 2);
1311 hba->max_outstanding_cmds = hba->elstm_xids;
1312 hba->max_xid = (hba->max_tasks - 1);
1314 rc = bnx2fc_bind_pcidev(hba);
1319 hba->phys_dev = cnic->netdev;
1320 hba->next_conn_id = 0;
1322 hba->tgt_ofld_list =
1325 if (!hba->tgt_ofld_list) {
1330 hba->num_ofld_sess = 0;
1332 hba->cmd_mgr = bnx2fc_cmd_mgr_alloc(hba);
1333 if (!hba->cmd_mgr) {
1337 fcoe_cap = &hba->fcoe_cap;
1343 fcoe_cap->capability2 = hba->max_outstanding_cmds <<
1349 fcoe_cap->capability3 |= hba->max_outstanding_cmds <<
1353 init_waitqueue_head(&hba->shutdown_wait);
1354 init_waitqueue_head(&hba->destroy_wait);
1355 INIT_LIST_HEAD(&hba->vports);
1357 return hba;
1360 kfree(hba->tgt_ofld_list);
1362 bnx2fc_unbind_pcidev(hba);
1364 kfree(hba);
1368 struct bnx2fc_interface *bnx2fc_interface_create(struct bnx2fc_hba *hba,
1390 interface->hba = hba;
1430 struct bnx2fc_hba *hba = interface->hba;
1440 bnx2fc_shost_template.can_queue = hba->max_outstanding_cmds;
1492 rc = bnx2fc_em_config(lport, hba);
1506 spin_lock_bh(&hba->hba_lock);
1508 list_add_tail(&blport->list, &hba->vports);
1509 spin_unlock_bh(&hba->hba_lock);
1535 struct bnx2fc_hba *hba = interface->hba;
1545 bnx2fc_free_vport(hba, lport);
1635 static void bnx2fc_unbind_adapter_devices(struct bnx2fc_hba *hba)
1637 bnx2fc_free_fw_resc(hba);
1638 bnx2fc_free_task_ctx(hba);
1645 * @hba: Adapter instance
1647 static int bnx2fc_bind_adapter_devices(struct bnx2fc_hba *hba)
1649 if (bnx2fc_setup_task_ctx(hba))
1652 if (bnx2fc_setup_fw_resc(hba))
1657 bnx2fc_unbind_adapter_devices(hba);
1661 static int bnx2fc_bind_pcidev(struct bnx2fc_hba *hba)
1666 if (!hba->cnic) {
1670 cnic = hba->cnic;
1671 pdev = hba->pcidev = cnic->pcidev;
1672 if (!hba->pcidev)
1677 strncpy(hba->chip_num, "BCM57710", BCM_CHIP_LEN);
1680 strncpy(hba->chip_num, "BCM57711", BCM_CHIP_LEN);
1685 strncpy(hba->chip_num, "BCM57712", BCM_CHIP_LEN);
1690 strncpy(hba->chip_num, "BCM57800", BCM_CHIP_LEN);
1695 strncpy(hba->chip_num, "BCM57810", BCM_CHIP_LEN);
1702 strncpy(hba->chip_num, "BCM57840", BCM_CHIP_LEN);
1708 pci_dev_get(hba->pcidev);
1712 static void bnx2fc_unbind_pcidev(struct bnx2fc_hba *hba)
1714 if (hba->pcidev) {
1715 hba->chip_num[0] = '\0';
1716 pci_dev_put(hba->pcidev);
1718 hba->pcidev = NULL;
1728 struct bnx2fc_hba *hba = handle;
1732 if (!hba)
1735 cnic = hba->cnic;
1764 struct bnx2fc_hba *hba = handle;
1771 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags))
1772 bnx2fc_fw_init(hba);
1777 if (interface->hba == hba) {
1803 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags))
1819 static int bnx2fc_fw_init(struct bnx2fc_hba *hba)
1825 rc = bnx2fc_bind_adapter_devices(hba);
1832 rc = bnx2fc_send_fw_fcoe_init_msg(hba);
1843 while (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state) && i--)
1846 if (!test_bit(ADAPTER_STATE_UP, &hba->adapter_state)) {
1849 hba->cnic->netdev->name);
1855 set_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags);
1859 bnx2fc_unbind_adapter_devices(hba);
1864 static void bnx2fc_fw_destroy(struct bnx2fc_hba *hba)
1866 if (test_and_clear_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags)) {
1867 if (bnx2fc_send_fw_fcoe_destroy_msg(hba) == 0) {
1868 init_timer(&hba->destroy_timer);
1869 hba->destroy_timer.expires = BNX2FC_FW_TIMEOUT +
1871 hba->destroy_timer.function = bnx2fc_destroy_timer;
1872 hba->destroy_timer.data = (unsigned long)hba;
1873 add_timer(&hba->destroy_timer);
1874 wait_event_interruptible(hba->destroy_wait,
1876 &hba->flags));
1877 clear_bit(BNX2FC_FLAG_DESTROY_CMPL, &hba->flags);
1882 del_timer_sync(&hba->destroy_timer);
1884 bnx2fc_unbind_adapter_devices(hba);
1898 struct bnx2fc_hba *hba = handle;
1904 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &hba->flags))
1907 if (interface->hba == hba)
1910 BUG_ON(hba->num_ofld_sess != 0);
1912 mutex_lock(&hba->hba_mutex);
1913 clear_bit(ADAPTER_STATE_UP, &hba->adapter_state);
1915 &hba->adapter_state);
1917 clear_bit(ADAPTER_STATE_READY, &hba->adapter_state);
1918 mutex_unlock(&hba->hba_mutex);
1920 bnx2fc_fw_destroy(hba);
1933 if (!test_bit(BNX2FC_FLAG_FW_INIT_DONE, &interface->hba->flags)) {
1945 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state);
1975 struct bnx2fc_hba *hba;
1988 hba = bnx2fc_hba_create(dev);
1989 if (!hba) {
1990 printk(KERN_ERR PFX "hba initialization failed\n");
1996 list_add_tail(&hba->list, &adapter_list);
2000 dev->fcoe_cap = &hba->fcoe_cap;
2001 clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic);
2003 (void *) hba);
2007 set_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic);
2148 struct bnx2fc_hba *hba;
2190 hba = bnx2fc_hba_lookup(phys_dev);
2191 if (!hba) {
2193 printk(KERN_ERR PFX "bnx2fc_create: hba not found\n");
2202 interface = bnx2fc_interface_create(hba, netdev, fip_mode);
2250 set_bit(ADAPTER_STATE_READY, &interface->hba->adapter_state);
2315 * bnx2fc_find_hba_for_cnic - maps cnic instance to bnx2fc hba instance
2322 struct bnx2fc_hba *hba;
2325 list_for_each_entry(hba, &adapter_list, list) {
2326 if (hba->cnic == cnic)
2327 return hba;
2348 struct bnx2fc_hba *hba;
2351 list_for_each_entry(hba, &adapter_list, list) {
2352 if (hba->phys_dev == phys_dev)
2353 return hba;
2355 printk(KERN_ERR PFX "adapter_lookup: hba NULL\n");
2366 struct bnx2fc_hba *hba;
2378 hba = bnx2fc_find_hba_for_cnic(dev);
2379 if (!hba) {
2380 printk(KERN_ERR PFX "bnx2fc_ulp_exit: hba not found, dev 0%p\n",
2386 list_del_init(&hba->list);
2391 if (interface->hba == hba)
2398 bnx2fc_ulp_stop(hba);
2400 if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic))
2401 hba->cnic->unregister_device(hba->cnic, CNIC_ULP_FCOE);
2402 bnx2fc_hba_destroy(hba);
2623 struct bnx2fc_hba *hba, *next;
2642 list_for_each_entry_safe(hba, next, &to_be_deleted, list) {
2643 list_del_init(&hba->list);
2644 printk(KERN_ERR PFX "MOD_EXIT:destroy hba = 0x%p\n",
2645 hba);
2646 bnx2fc_ulp_stop(hba);
2649 &hba->reg_with_cnic))
2650 hba->cnic->unregister_device(hba->cnic,
2652 bnx2fc_hba_destroy(hba);