Lines Matching full:adapter

61 static void qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding);
62 static int qlcnic_can_start_firmware(struct qlcnic_adapter *adapter);
73 static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter);
88 static u32 qlcnic_vlan_tx_check(struct qlcnic_adapter *adapter) in qlcnic_vlan_tx_check() argument
90 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_vlan_tx_check()
92 if (adapter->pdev->device == PCI_DEVICE_ID_QLOGIC_QLE824X) in qlcnic_vlan_tx_check()
160 "8400 series 10GbE Converged Network Adapter (TCP/IP Networking)" },
165 "8300 Series Dual Port 10GbE Converged Network Adapter "
171 "8300 Series Single Port 10GbE Converged Network Adapter "
177 "8300 Series Dual Port 10GbE Converged Network Adapter "
183 "8300 Series Dual Port 10GbE Converged Network Adapter "
189 "8300 Series Dual Port 10GbE Converged Network Adapter "
195 "8300 Series Dual Port 10GbE Converged Network Adapter "
201 "8300 Series Dual Port 10GbE Converged Network Adapter "
207 "8300 Series Single Port 10GbE Converged Network Adapter "
213 "8300 Series Dual Port 10GbE Converged Network Adapter "
219 "8300 Series Dual Port 10GbE Converged Network Adapter "
233 "8200 Series Single Port 10GbE Converged Network Adapter"
239 "8200 Series Dual Port 10GbE Converged Network Adapter"
245 "3200 Series Dual Port 10Gb Intelligent Ethernet Adapter" },
250 "3200 Series Quad Port 1Gb Intelligent Ethernet Adapter" },
255 "3200 Series Single Port 10Gb Intelligent Ethernet Adapter" },
259 "NC523SFP 10Gb 2-port Server Adapter" },
263 "CN1000Q Dual Port Converged Network Adapter" },
294 int qlcnic_read_mac_addr(struct qlcnic_adapter *adapter) in qlcnic_read_mac_addr() argument
296 struct net_device *netdev = adapter->netdev; in qlcnic_read_mac_addr()
297 struct pci_dev *pdev = adapter->pdev; in qlcnic_read_mac_addr()
301 ret = qlcnic_get_mac_address(adapter, mac_addr, in qlcnic_read_mac_addr()
302 adapter->ahw->pci_func); in qlcnic_read_mac_addr()
307 memcpy(adapter->mac_addr, netdev->dev_addr, netdev->addr_len); in qlcnic_read_mac_addr()
318 static void qlcnic_delete_adapter_mac(struct qlcnic_adapter *adapter) in qlcnic_delete_adapter_mac() argument
322 list_for_each_entry(cur, &adapter->mac_list, list) { in qlcnic_delete_adapter_mac()
323 if (ether_addr_equal_unaligned(adapter->mac_addr, cur->mac_addr)) { in qlcnic_delete_adapter_mac()
324 qlcnic_sre_macaddr_change(adapter, cur->mac_addr, in qlcnic_delete_adapter_mac()
335 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_set_mac() local
338 if (qlcnic_sriov_vf_check(adapter)) in qlcnic_set_mac()
341 if ((adapter->flags & QLCNIC_MAC_OVERRIDE_DISABLED)) in qlcnic_set_mac()
347 if (ether_addr_equal_unaligned(adapter->mac_addr, addr->sa_data) && in qlcnic_set_mac()
351 if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) { in qlcnic_set_mac()
353 qlcnic_napi_disable(adapter); in qlcnic_set_mac()
356 qlcnic_delete_adapter_mac(adapter); in qlcnic_set_mac()
357 memcpy(adapter->mac_addr, addr->sa_data, netdev->addr_len); in qlcnic_set_mac()
359 qlcnic_set_multi(adapter->netdev); in qlcnic_set_mac()
361 if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) { in qlcnic_set_mac()
363 qlcnic_napi_enable(adapter); in qlcnic_set_mac()
373 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_fdb_del() local
376 if (!adapter->fdb_mac_learn) in qlcnic_fdb_del()
379 if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) || in qlcnic_fdb_del()
380 qlcnic_sriov_check(adapter)) { in qlcnic_fdb_del()
384 err = qlcnic_nic_del_mac(adapter, addr); in qlcnic_fdb_del()
399 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_fdb_add() local
402 if (!adapter->fdb_mac_learn) in qlcnic_fdb_add()
405 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) && in qlcnic_fdb_add()
406 !qlcnic_sriov_check(adapter)) { in qlcnic_fdb_add()
411 if (ether_addr_equal(addr, adapter->mac_addr)) in qlcnic_fdb_add()
415 if (netdev_uc_count(netdev) < adapter->ahw->max_uc_count) in qlcnic_fdb_add()
432 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_fdb_dump() local
435 if (!adapter->fdb_mac_learn) in qlcnic_fdb_dump()
438 if ((adapter->flags & QLCNIC_ESWITCH_ENABLED) || in qlcnic_fdb_dump()
439 qlcnic_sriov_check(adapter)) in qlcnic_fdb_dump()
445 static void qlcnic_82xx_cancel_idc_work(struct qlcnic_adapter *adapter) in qlcnic_82xx_cancel_idc_work() argument
447 while (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) in qlcnic_82xx_cancel_idc_work()
450 if (!adapter->fw_work.work.func) in qlcnic_82xx_cancel_idc_work()
453 cancel_delayed_work_sync(&adapter->fw_work); in qlcnic_82xx_cancel_idc_work()
459 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_get_phys_port_id() local
460 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_get_phys_port_id()
462 if (!(adapter->flags & QLCNIC_HAS_PHYS_PORT_ID)) in qlcnic_get_phys_port_id()
473 struct qlcnic_adapter *adapter = netdev_priv(dev); in qlcnic_udp_tunnel_sync() local
479 err = qlcnic_set_vxlan_port(adapter, ntohs(ti.port)); in qlcnic_udp_tunnel_sync()
484 return qlcnic_set_vxlan_parsing(adapter, ntohs(ti.port)); in qlcnic_udp_tunnel_sync()
610 static int qlcnic_check_multi_tx_capability(struct qlcnic_adapter *adapter) in qlcnic_check_multi_tx_capability() argument
612 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_check_multi_tx_capability()
614 if (qlcnic_82xx_check(adapter) && in qlcnic_check_multi_tx_capability()
616 test_and_set_bit(__QLCNIC_MULTI_TX_UNIQUE, &adapter->state); in qlcnic_check_multi_tx_capability()
623 static int qlcnic_max_rings(struct qlcnic_adapter *adapter, u8 ring_cnt, in qlcnic_max_rings() argument
629 max_rings = adapter->max_sds_rings; in qlcnic_max_rings()
631 max_rings = adapter->max_tx_rings; in qlcnic_max_rings()
642 void qlcnic_set_tx_ring_count(struct qlcnic_adapter *adapter, u8 tx_cnt) in qlcnic_set_tx_ring_count() argument
644 /* 83xx adapter does not have max_tx_rings intialized in probe */ in qlcnic_set_tx_ring_count()
645 if (adapter->max_tx_rings) in qlcnic_set_tx_ring_count()
646 adapter->drv_tx_rings = qlcnic_max_rings(adapter, tx_cnt, in qlcnic_set_tx_ring_count()
649 adapter->drv_tx_rings = tx_cnt; in qlcnic_set_tx_ring_count()
652 void qlcnic_set_sds_ring_count(struct qlcnic_adapter *adapter, u8 rx_cnt) in qlcnic_set_sds_ring_count() argument
654 /* 83xx adapter does not have max_sds_rings intialized in probe */ in qlcnic_set_sds_ring_count()
655 if (adapter->max_sds_rings) in qlcnic_set_sds_ring_count()
656 adapter->drv_sds_rings = qlcnic_max_rings(adapter, rx_cnt, in qlcnic_set_sds_ring_count()
659 adapter->drv_sds_rings = rx_cnt; in qlcnic_set_sds_ring_count()
662 int qlcnic_setup_tss_rss_intr(struct qlcnic_adapter *adapter) in qlcnic_setup_tss_rss_intr() argument
664 struct pci_dev *pdev = adapter->pdev; in qlcnic_setup_tss_rss_intr()
667 adapter->flags &= ~QLCNIC_TSS_RSS; in qlcnic_setup_tss_rss_intr()
669 if (adapter->drv_tss_rings > 0) in qlcnic_setup_tss_rss_intr()
670 num_msix += adapter->drv_tss_rings; in qlcnic_setup_tss_rss_intr()
672 num_msix += adapter->drv_tx_rings; in qlcnic_setup_tss_rss_intr()
674 if (adapter->drv_rss_rings > 0) in qlcnic_setup_tss_rss_intr()
675 num_msix += adapter->drv_rss_rings; in qlcnic_setup_tss_rss_intr()
677 num_msix += adapter->drv_sds_rings; in qlcnic_setup_tss_rss_intr()
679 if (qlcnic_83xx_check(adapter)) in qlcnic_setup_tss_rss_intr()
682 if (!adapter->msix_entries) { in qlcnic_setup_tss_rss_intr()
683 adapter->msix_entries = kcalloc(num_msix, in qlcnic_setup_tss_rss_intr()
686 if (!adapter->msix_entries) in qlcnic_setup_tss_rss_intr()
691 adapter->msix_entries[vector].entry = vector; in qlcnic_setup_tss_rss_intr()
694 err = pci_enable_msix_exact(pdev, adapter->msix_entries, num_msix); in qlcnic_setup_tss_rss_intr()
696 if (!adapter->drv_tss_rings && !adapter->drv_rss_rings) in qlcnic_setup_tss_rss_intr()
699 netdev_info(adapter->netdev, in qlcnic_setup_tss_rss_intr()
703 num_msix = adapter->drv_tx_rings + adapter->drv_sds_rings; in qlcnic_setup_tss_rss_intr()
706 adapter->drv_tss_rings = 0; in qlcnic_setup_tss_rss_intr()
707 adapter->drv_rss_rings = 0; in qlcnic_setup_tss_rss_intr()
709 if (qlcnic_83xx_check(adapter)) in qlcnic_setup_tss_rss_intr()
712 netdev_info(adapter->netdev, in qlcnic_setup_tss_rss_intr()
714 adapter->drv_tx_rings, adapter->drv_sds_rings, in qlcnic_setup_tss_rss_intr()
722 adapter->ahw->num_msix = num_msix; in qlcnic_setup_tss_rss_intr()
723 if (adapter->drv_tss_rings > 0) in qlcnic_setup_tss_rss_intr()
724 adapter->drv_tx_rings = adapter->drv_tss_rings; in qlcnic_setup_tss_rss_intr()
726 if (adapter->drv_rss_rings > 0) in qlcnic_setup_tss_rss_intr()
727 adapter->drv_sds_rings = adapter->drv_rss_rings; in qlcnic_setup_tss_rss_intr()
732 int qlcnic_enable_msix(struct qlcnic_adapter *adapter, u32 num_msix) in qlcnic_enable_msix() argument
734 struct pci_dev *pdev = adapter->pdev; in qlcnic_enable_msix()
737 if (!adapter->msix_entries) { in qlcnic_enable_msix()
738 adapter->msix_entries = kcalloc(num_msix, in qlcnic_enable_msix()
741 if (!adapter->msix_entries) in qlcnic_enable_msix()
745 adapter->flags &= ~(QLCNIC_MSI_ENABLED | QLCNIC_MSIX_ENABLED); in qlcnic_enable_msix()
747 if (adapter->ahw->msix_supported) { in qlcnic_enable_msix()
750 adapter->msix_entries[vector].entry = vector; in qlcnic_enable_msix()
753 adapter->msix_entries, 1, num_msix); in qlcnic_enable_msix()
756 adapter->flags |= QLCNIC_MSIX_ENABLED; in qlcnic_enable_msix()
757 adapter->ahw->num_msix = num_msix; in qlcnic_enable_msix()
767 if (qlcnic_82xx_check(adapter)) { in qlcnic_enable_msix()
778 if (qlcnic_82xx_check(adapter) && in qlcnic_enable_msix()
779 !qlcnic_check_multi_tx(adapter)) { in qlcnic_enable_msix()
780 adapter->drv_sds_rings = num_msix; in qlcnic_enable_msix()
781 adapter->drv_tx_rings = QLCNIC_SINGLE_RING; in qlcnic_enable_msix()
784 adapter->drv_tx_rings = num_msix / 2; in qlcnic_enable_msix()
785 adapter->drv_sds_rings = adapter->drv_tx_rings; in qlcnic_enable_msix()
805 static int qlcnic_82xx_calculate_msix_vector(struct qlcnic_adapter *adapter) in qlcnic_82xx_calculate_msix_vector() argument
809 num_msix = adapter->drv_sds_rings; in qlcnic_82xx_calculate_msix_vector()
811 if (qlcnic_check_multi_tx(adapter)) in qlcnic_82xx_calculate_msix_vector()
812 num_msix += adapter->drv_tx_rings; in qlcnic_82xx_calculate_msix_vector()
819 static int qlcnic_enable_msi_legacy(struct qlcnic_adapter *adapter) in qlcnic_enable_msi_legacy() argument
824 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_enable_msi_legacy()
825 struct pci_dev *pdev = adapter->pdev; in qlcnic_enable_msi_legacy()
828 adapter->flags |= QLCNIC_MSI_ENABLED; in qlcnic_enable_msi_legacy()
829 offset = msi_tgt_status[adapter->ahw->pci_func]; in qlcnic_enable_msi_legacy()
830 adapter->tgt_status_reg = qlcnic_get_ioaddr(adapter->ahw, in qlcnic_enable_msi_legacy()
833 adapter->msix_entries[0].vector = pdev->irq; in qlcnic_enable_msi_legacy()
840 legacy_intrp = &legacy_intr[adapter->ahw->pci_func]; in qlcnic_enable_msi_legacy()
841 adapter->ahw->int_vec_bit = legacy_intrp->int_vec_bit; in qlcnic_enable_msi_legacy()
843 adapter->tgt_status_reg = qlcnic_get_ioaddr(ahw, offset); in qlcnic_enable_msi_legacy()
845 adapter->tgt_mask_reg = qlcnic_get_ioaddr(ahw, mask_reg); in qlcnic_enable_msi_legacy()
846 adapter->isr_int_vec = qlcnic_get_ioaddr(ahw, ISR_INT_VECTOR); in qlcnic_enable_msi_legacy()
847 adapter->crb_int_state_reg = qlcnic_get_ioaddr(ahw, ISR_INT_STATE_REG); in qlcnic_enable_msi_legacy()
849 adapter->msix_entries[0].vector = pdev->irq; in qlcnic_enable_msi_legacy()
853 static int qlcnic_82xx_setup_intr(struct qlcnic_adapter *adapter) in qlcnic_82xx_setup_intr() argument
857 if (adapter->flags & QLCNIC_TSS_RSS) { in qlcnic_82xx_setup_intr()
858 err = qlcnic_setup_tss_rss_intr(adapter); in qlcnic_82xx_setup_intr()
861 num_msix = adapter->ahw->num_msix; in qlcnic_82xx_setup_intr()
863 num_msix = qlcnic_82xx_calculate_msix_vector(adapter); in qlcnic_82xx_setup_intr()
865 err = qlcnic_enable_msix(adapter, num_msix); in qlcnic_82xx_setup_intr()
869 if (!(adapter->flags & QLCNIC_MSIX_ENABLED)) { in qlcnic_82xx_setup_intr()
870 qlcnic_disable_multi_tx(adapter); in qlcnic_82xx_setup_intr()
871 adapter->drv_sds_rings = QLCNIC_SINGLE_RING; in qlcnic_82xx_setup_intr()
873 err = qlcnic_enable_msi_legacy(adapter); in qlcnic_82xx_setup_intr()
882 int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *adapter, int op_type) in qlcnic_82xx_mq_intrpt() argument
884 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_82xx_mq_intrpt()
887 if (qlcnic_check_multi_tx(adapter) && in qlcnic_82xx_mq_intrpt()
889 (adapter->flags & QLCNIC_MSIX_ENABLED)) { in qlcnic_82xx_mq_intrpt()
902 err = qlcnic_82xx_config_intrpt(adapter, 1); in qlcnic_82xx_mq_intrpt()
904 dev_err(&adapter->pdev->dev, in qlcnic_82xx_mq_intrpt()
913 void qlcnic_teardown_intr(struct qlcnic_adapter *adapter) in qlcnic_teardown_intr() argument
915 if (adapter->flags & QLCNIC_MSIX_ENABLED) in qlcnic_teardown_intr()
916 pci_disable_msix(adapter->pdev); in qlcnic_teardown_intr()
917 if (adapter->flags & QLCNIC_MSI_ENABLED) in qlcnic_teardown_intr()
918 pci_disable_msi(adapter->pdev); in qlcnic_teardown_intr()
920 kfree(adapter->msix_entries); in qlcnic_teardown_intr()
921 adapter->msix_entries = NULL; in qlcnic_teardown_intr()
923 if (adapter->ahw->intr_tbl) { in qlcnic_teardown_intr()
924 vfree(adapter->ahw->intr_tbl); in qlcnic_teardown_intr()
925 adapter->ahw->intr_tbl = NULL; in qlcnic_teardown_intr()
935 static int qlcnic_get_act_pci_func(struct qlcnic_adapter *adapter) in qlcnic_get_act_pci_func() argument
937 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_get_act_pci_func()
941 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) { in qlcnic_get_act_pci_func()
960 ret = qlcnic_get_pci_info(adapter, pci_info); in qlcnic_get_act_pci_func()
965 static bool qlcnic_port_eswitch_cfg_capability(struct qlcnic_adapter *adapter) in qlcnic_port_eswitch_cfg_capability() argument
969 if (qlcnic_84xx_check(adapter)) { in qlcnic_port_eswitch_cfg_capability()
971 } else if (qlcnic_83xx_check(adapter)) { in qlcnic_port_eswitch_cfg_capability()
972 if (adapter->ahw->extra_capability[0] & in qlcnic_port_eswitch_cfg_capability()
982 int qlcnic_init_pci_info(struct qlcnic_adapter *adapter) in qlcnic_init_pci_info() argument
984 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_init_pci_info()
994 ret = qlcnic_get_pci_info(adapter, pci_info); in qlcnic_init_pci_info()
1000 adapter->npars = kcalloc(act_pci_func, in qlcnic_init_pci_info()
1003 if (!adapter->npars) { in qlcnic_init_pci_info()
1008 adapter->eswitch = kcalloc(QLCNIC_NIU_MAX_XG_PORTS, in qlcnic_init_pci_info()
1011 if (!adapter->eswitch) { in qlcnic_init_pci_info()
1021 dev_err(&adapter->pdev->dev, "%s: Invalid function 0x%x, max 0x%x\n", in qlcnic_init_pci_info()
1030 if (qlcnic_port_eswitch_cfg_capability(adapter)) { in qlcnic_init_pci_info()
1031 if (!qlcnic_83xx_set_port_eswitch_status(adapter, pfn, in qlcnic_init_pci_info()
1033 adapter->npars[j].eswitch_status = true; in qlcnic_init_pci_info()
1037 adapter->npars[j].eswitch_status = true; in qlcnic_init_pci_info()
1040 adapter->npars[j].pci_func = pfn; in qlcnic_init_pci_info()
1041 adapter->npars[j].active = (u8)pci_info[i].active; in qlcnic_init_pci_info()
1042 adapter->npars[j].type = (u8)pci_info[i].type; in qlcnic_init_pci_info()
1043 adapter->npars[j].phy_port = (u8)pci_info[i].default_port; in qlcnic_init_pci_info()
1044 adapter->npars[j].min_bw = pci_info[i].tx_min_bw; in qlcnic_init_pci_info()
1045 adapter->npars[j].max_bw = pci_info[i].tx_max_bw; in qlcnic_init_pci_info()
1047 memcpy(&adapter->npars[j].mac, &pci_info[i].mac, ETH_ALEN); in qlcnic_init_pci_info()
1054 if (!qlcnic_port_eswitch_cfg_capability(adapter)) { in qlcnic_init_pci_info()
1056 adapter->eswitch[i].flags |= QLCNIC_SWITCH_ENABLE; in qlcnic_init_pci_info()
1063 kfree(adapter->eswitch); in qlcnic_init_pci_info()
1064 adapter->eswitch = NULL; in qlcnic_init_pci_info()
1066 kfree(adapter->npars); in qlcnic_init_pci_info()
1067 adapter->npars = NULL; in qlcnic_init_pci_info()
1075 qlcnic_set_function_modes(struct qlcnic_adapter *adapter) in qlcnic_set_function_modes() argument
1080 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_set_function_modes()
1082 ret = qlcnic_api_lock(adapter); in qlcnic_set_function_modes()
1087 data = QLC_SHARED_REG_RD32(adapter, QLCNIC_DRV_OP_MODE); in qlcnic_set_function_modes()
1090 QLC_SHARED_REG_WR32(adapter, QLCNIC_DRV_OP_MODE, data); in qlcnic_set_function_modes()
1091 qlcnic_api_unlock(adapter); in qlcnic_set_function_modes()
1096 static void qlcnic_check_vf(struct qlcnic_adapter *adapter, in qlcnic_check_vf() argument
1102 adapter->ahw->fw_hal_version = QLC_SHARED_REG_RD32(adapter, in qlcnic_check_vf()
1106 qlcnic_get_func_no(adapter); in qlcnic_check_vf()
1109 op_mode = QLC_SHARED_REG_RD32(adapter, QLCNIC_DRV_OP_MODE); in qlcnic_check_vf()
1113 priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func); in qlcnic_check_vf()
1116 adapter->ahw->op_mode = QLCNIC_NON_PRIV_FUNC; in qlcnic_check_vf()
1117 dev_info(&adapter->pdev->dev, in qlcnic_check_vf()
1119 adapter->ahw->fw_hal_version); in qlcnic_check_vf()
1120 adapter->nic_ops = &qlcnic_vf_ops; in qlcnic_check_vf()
1122 adapter->nic_ops = &qlcnic_ops; in qlcnic_check_vf()
1179 static bool qlcnic_validate_subsystem_id(struct qlcnic_adapter *adapter, in qlcnic_validate_subsystem_id() argument
1182 struct pci_dev *pdev = adapter->pdev; in qlcnic_validate_subsystem_id()
1200 static void qlcnic_get_board_name(struct qlcnic_adapter *adapter, char *name) in qlcnic_get_board_name() argument
1202 struct pci_dev *pdev = adapter->pdev; in qlcnic_get_board_name()
1208 qlcnic_validate_subsystem_id(adapter, i)) { in qlcnic_get_board_name()
1215 sprintf(name, "%pM Gigabit Ethernet", adapter->mac_addr); in qlcnic_get_board_name()
1217 sprintf(name, "%pM: %s" , adapter->mac_addr, in qlcnic_get_board_name()
1222 qlcnic_check_options(struct qlcnic_adapter *adapter) in qlcnic_check_options() argument
1226 struct pci_dev *pdev = adapter->pdev; in qlcnic_check_options()
1227 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_check_options()
1230 prev_fw_version = adapter->fw_version; in qlcnic_check_options()
1232 fw_major = QLC_SHARED_REG_RD32(adapter, QLCNIC_FW_VERSION_MAJOR); in qlcnic_check_options()
1233 fw_minor = QLC_SHARED_REG_RD32(adapter, QLCNIC_FW_VERSION_MINOR); in qlcnic_check_options()
1234 fw_build = QLC_SHARED_REG_RD32(adapter, QLCNIC_FW_VERSION_SUB); in qlcnic_check_options()
1236 adapter->fw_version = QLCNIC_VERSION_CODE(fw_major, fw_minor, fw_build); in qlcnic_check_options()
1238 err = qlcnic_get_board_info(adapter); in qlcnic_check_options()
1245 adapter->fw_version > prev_fw_version) { in qlcnic_check_options()
1247 if (!qlcnic_fw_cmd_get_minidump_temp(adapter)) in qlcnic_check_options()
1256 if (adapter->ahw->port_type == QLCNIC_XGBE) { in qlcnic_check_options()
1257 if (adapter->flags & QLCNIC_ESWITCH_ENABLED) { in qlcnic_check_options()
1258 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_VF; in qlcnic_check_options()
1259 adapter->max_rxd = MAX_RCV_DESCRIPTORS_VF; in qlcnic_check_options()
1261 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_10G; in qlcnic_check_options()
1262 adapter->max_rxd = MAX_RCV_DESCRIPTORS_10G; in qlcnic_check_options()
1265 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; in qlcnic_check_options()
1266 adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_10G; in qlcnic_check_options()
1268 } else if (adapter->ahw->port_type == QLCNIC_GBE) { in qlcnic_check_options()
1269 adapter->num_rxd = DEFAULT_RCV_DESCRIPTORS_1G; in qlcnic_check_options()
1270 adapter->num_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; in qlcnic_check_options()
1271 adapter->max_jumbo_rxd = MAX_JUMBO_RCV_DESCRIPTORS_1G; in qlcnic_check_options()
1272 adapter->max_rxd = MAX_RCV_DESCRIPTORS_1G; in qlcnic_check_options()
1275 adapter->ahw->msix_supported = !!qlcnic_use_msi_x; in qlcnic_check_options()
1277 adapter->num_txd = MAX_CMD_DESCRIPTORS; in qlcnic_check_options()
1279 adapter->max_rds_rings = MAX_RDS_RINGS; in qlcnic_check_options()
1283 qlcnic_initialize_nic(struct qlcnic_adapter *adapter) in qlcnic_initialize_nic() argument
1289 err = qlcnic_get_nic_info(adapter, &nic_info, adapter->ahw->pci_func); in qlcnic_initialize_nic()
1293 adapter->ahw->physical_port = (u8)nic_info.phys_port; in qlcnic_initialize_nic()
1294 adapter->ahw->switch_mode = nic_info.switch_mode; in qlcnic_initialize_nic()
1295 adapter->ahw->max_tx_ques = nic_info.max_tx_ques; in qlcnic_initialize_nic()
1296 adapter->ahw->max_rx_ques = nic_info.max_rx_ques; in qlcnic_initialize_nic()
1297 adapter->ahw->capabilities = nic_info.capabilities; in qlcnic_initialize_nic()
1299 if (adapter->ahw->capabilities & QLCNIC_FW_CAPABILITY_MORE_CAPS) { in qlcnic_initialize_nic()
1301 temp = QLCRD32(adapter, CRB_FW_CAPABILITIES_2, &err); in qlcnic_initialize_nic()
1304 adapter->ahw->extra_capability[0] = temp; in qlcnic_initialize_nic()
1306 adapter->ahw->extra_capability[0] = 0; in qlcnic_initialize_nic()
1309 adapter->ahw->max_mac_filters = nic_info.max_mac_filters; in qlcnic_initialize_nic()
1310 adapter->ahw->max_mtu = nic_info.max_mtu; in qlcnic_initialize_nic()
1312 if (adapter->ahw->capabilities & BIT_6) { in qlcnic_initialize_nic()
1313 adapter->flags |= QLCNIC_ESWITCH_ENABLED; in qlcnic_initialize_nic()
1314 adapter->ahw->nic_mode = QLCNIC_VNIC_MODE; in qlcnic_initialize_nic()
1315 adapter->max_tx_rings = QLCNIC_MAX_HW_VNIC_TX_RINGS; in qlcnic_initialize_nic()
1316 adapter->max_sds_rings = QLCNIC_MAX_VNIC_SDS_RINGS; in qlcnic_initialize_nic()
1318 dev_info(&adapter->pdev->dev, "vNIC mode enabled.\n"); in qlcnic_initialize_nic()
1320 adapter->ahw->nic_mode = QLCNIC_DEFAULT_MODE; in qlcnic_initialize_nic()
1321 adapter->max_tx_rings = QLCNIC_MAX_HW_TX_RINGS; in qlcnic_initialize_nic()
1322 adapter->max_sds_rings = QLCNIC_MAX_SDS_RINGS; in qlcnic_initialize_nic()
1323 adapter->flags &= ~QLCNIC_ESWITCH_ENABLED; in qlcnic_initialize_nic()
1329 void qlcnic_set_vlan_config(struct qlcnic_adapter *adapter, in qlcnic_set_vlan_config() argument
1333 adapter->flags &= ~QLCNIC_TAGGING_ENABLED; in qlcnic_set_vlan_config()
1335 adapter->flags |= QLCNIC_TAGGING_ENABLED; in qlcnic_set_vlan_config()
1338 adapter->rx_pvid = esw_cfg->vlan_id; in qlcnic_set_vlan_config()
1339 adapter->tx_pvid = esw_cfg->vlan_id; in qlcnic_set_vlan_config()
1341 adapter->rx_pvid = 0; in qlcnic_set_vlan_config()
1342 adapter->tx_pvid = 0; in qlcnic_set_vlan_config()
1349 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_vlan_rx_add() local
1352 if (qlcnic_sriov_vf_check(adapter)) { in qlcnic_vlan_rx_add()
1353 err = qlcnic_sriov_cfg_vf_guest_vlan(adapter, vid, 1); in qlcnic_vlan_rx_add()
1362 set_bit(vid, adapter->vlans); in qlcnic_vlan_rx_add()
1369 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_vlan_rx_del() local
1372 if (qlcnic_sriov_vf_check(adapter)) { in qlcnic_vlan_rx_del()
1373 err = qlcnic_sriov_cfg_vf_guest_vlan(adapter, vid, 0); in qlcnic_vlan_rx_del()
1383 clear_bit(vid, adapter->vlans); in qlcnic_vlan_rx_del()
1387 void qlcnic_set_eswitch_port_features(struct qlcnic_adapter *adapter, in qlcnic_set_eswitch_port_features() argument
1390 adapter->flags &= ~(QLCNIC_MACSPOOF | QLCNIC_MAC_OVERRIDE_DISABLED | in qlcnic_set_eswitch_port_features()
1394 adapter->flags |= QLCNIC_MACSPOOF; in qlcnic_set_eswitch_port_features()
1397 adapter->flags |= QLCNIC_MAC_OVERRIDE_DISABLED; in qlcnic_set_eswitch_port_features()
1400 adapter->flags |= QLCNIC_PROMISC_DISABLED; in qlcnic_set_eswitch_port_features()
1403 int qlcnic_set_eswitch_port_config(struct qlcnic_adapter *adapter) in qlcnic_set_eswitch_port_config() argument
1407 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED)) in qlcnic_set_eswitch_port_config()
1410 esw_cfg.pci_func = adapter->ahw->pci_func; in qlcnic_set_eswitch_port_config()
1411 if (qlcnic_get_eswitch_port_config(adapter, &esw_cfg)) in qlcnic_set_eswitch_port_config()
1413 qlcnic_set_vlan_config(adapter, &esw_cfg); in qlcnic_set_eswitch_port_config()
1414 qlcnic_set_eswitch_port_features(adapter, &esw_cfg); in qlcnic_set_eswitch_port_config()
1415 qlcnic_set_netdev_features(adapter, &esw_cfg); in qlcnic_set_eswitch_port_config()
1420 void qlcnic_set_netdev_features(struct qlcnic_adapter *adapter, in qlcnic_set_netdev_features() argument
1423 struct net_device *netdev = adapter->netdev; in qlcnic_set_netdev_features()
1425 if (qlcnic_83xx_check(adapter)) in qlcnic_set_netdev_features()
1428 adapter->offload_flags = esw_cfg->offload_flags; in qlcnic_set_netdev_features()
1429 adapter->flags |= QLCNIC_APP_CHANGED_FLAGS; in qlcnic_set_netdev_features()
1431 adapter->flags &= ~QLCNIC_APP_CHANGED_FLAGS; in qlcnic_set_netdev_features()
1435 qlcnic_check_eswitch_mode(struct qlcnic_adapter *adapter) in qlcnic_check_eswitch_mode() argument
1440 err = qlcnic_initialize_nic(adapter); in qlcnic_check_eswitch_mode()
1444 if (adapter->flags & QLCNIC_ADAPTER_INITIALIZED) in qlcnic_check_eswitch_mode()
1447 op_mode = QLC_SHARED_REG_RD32(adapter, QLCNIC_DRV_OP_MODE); in qlcnic_check_eswitch_mode()
1448 priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func); in qlcnic_check_eswitch_mode()
1453 priv_level = QLC_DEV_GET_DRV(op_mode, adapter->ahw->pci_func); in qlcnic_check_eswitch_mode()
1455 if (adapter->flags & QLCNIC_ESWITCH_ENABLED) { in qlcnic_check_eswitch_mode()
1457 adapter->ahw->op_mode = QLCNIC_MGMT_FUNC; in qlcnic_check_eswitch_mode()
1458 err = qlcnic_init_pci_info(adapter); in qlcnic_check_eswitch_mode()
1462 qlcnic_set_function_modes(adapter); in qlcnic_check_eswitch_mode()
1463 dev_info(&adapter->pdev->dev, in qlcnic_check_eswitch_mode()
1465 adapter->ahw->fw_hal_version); in qlcnic_check_eswitch_mode()
1467 adapter->ahw->op_mode = QLCNIC_PRIV_FUNC; in qlcnic_check_eswitch_mode()
1468 dev_info(&adapter->pdev->dev, in qlcnic_check_eswitch_mode()
1470 adapter->ahw->fw_hal_version); in qlcnic_check_eswitch_mode()
1473 adapter->ahw->nic_mode = QLCNIC_DEFAULT_MODE; in qlcnic_check_eswitch_mode()
1476 adapter->flags |= QLCNIC_ADAPTER_INITIALIZED; in qlcnic_check_eswitch_mode()
1481 int qlcnic_set_default_offload_settings(struct qlcnic_adapter *adapter) in qlcnic_set_default_offload_settings() argument
1487 if (adapter->need_fw_reset) in qlcnic_set_default_offload_settings()
1490 for (i = 0; i < adapter->ahw->total_nic_func; i++) { in qlcnic_set_default_offload_settings()
1491 if (!adapter->npars[i].eswitch_status) in qlcnic_set_default_offload_settings()
1495 esw_cfg.pci_func = adapter->npars[i].pci_func; in qlcnic_set_default_offload_settings()
1498 if (qlcnic_82xx_check(adapter)) { in qlcnic_set_default_offload_settings()
1500 if (QLCNIC_IS_TSO_CAPABLE(adapter)) in qlcnic_set_default_offload_settings()
1503 if (qlcnic_config_switch_port(adapter, &esw_cfg)) in qlcnic_set_default_offload_settings()
1505 npar = &adapter->npars[i]; in qlcnic_set_default_offload_settings()
1519 qlcnic_reset_eswitch_config(struct qlcnic_adapter *adapter, in qlcnic_reset_eswitch_config() argument
1531 if (qlcnic_config_switch_port(adapter, &esw_cfg)) in qlcnic_reset_eswitch_config()
1535 if (qlcnic_config_switch_port(adapter, &esw_cfg)) in qlcnic_reset_eswitch_config()
1541 int qlcnic_reset_npar_config(struct qlcnic_adapter *adapter) in qlcnic_reset_npar_config() argument
1548 if (qlcnic_82xx_check(adapter)) in qlcnic_reset_npar_config()
1549 if (!adapter->need_fw_reset) in qlcnic_reset_npar_config()
1553 for (i = 0; i < adapter->ahw->total_nic_func; i++) { in qlcnic_reset_npar_config()
1554 npar = &adapter->npars[i]; in qlcnic_reset_npar_config()
1556 if (!adapter->npars[i].eswitch_status) in qlcnic_reset_npar_config()
1560 err = qlcnic_get_nic_info(adapter, &nic_info, pci_func); in qlcnic_reset_npar_config()
1565 err = qlcnic_set_nic_info(adapter, &nic_info); in qlcnic_reset_npar_config()
1570 err = qlcnic_config_port_mirroring(adapter, in qlcnic_reset_npar_config()
1576 err = qlcnic_reset_eswitch_config(adapter, npar, pci_func); in qlcnic_reset_npar_config()
1583 static int qlcnic_check_npar_opertional(struct qlcnic_adapter *adapter) in qlcnic_check_npar_opertional() argument
1588 if (adapter->ahw->op_mode == QLCNIC_MGMT_FUNC) in qlcnic_check_npar_opertional()
1591 npar_state = QLC_SHARED_REG_RD32(adapter, in qlcnic_check_npar_opertional()
1595 npar_state = QLC_SHARED_REG_RD32(adapter, in qlcnic_check_npar_opertional()
1599 dev_err(&adapter->pdev->dev, in qlcnic_check_npar_opertional()
1607 qlcnic_set_mgmt_operations(struct qlcnic_adapter *adapter) in qlcnic_set_mgmt_operations() argument
1611 if (!(adapter->flags & QLCNIC_ESWITCH_ENABLED) || in qlcnic_set_mgmt_operations()
1612 adapter->ahw->op_mode != QLCNIC_MGMT_FUNC) in qlcnic_set_mgmt_operations()
1615 err = qlcnic_set_default_offload_settings(adapter); in qlcnic_set_mgmt_operations()
1619 err = qlcnic_reset_npar_config(adapter); in qlcnic_set_mgmt_operations()
1623 qlcnic_dev_set_npar_ready(adapter); in qlcnic_set_mgmt_operations()
1628 static int qlcnic_82xx_start_firmware(struct qlcnic_adapter *adapter) in qlcnic_82xx_start_firmware() argument
1632 err = qlcnic_can_start_firmware(adapter); in qlcnic_82xx_start_firmware()
1639 qlcnic_request_firmware(adapter); in qlcnic_82xx_start_firmware()
1641 err = qlcnic_check_flash_fw_ver(adapter); in qlcnic_82xx_start_firmware()
1645 adapter->ahw->fw_type = QLCNIC_FLASH_ROMIMAGE; in qlcnic_82xx_start_firmware()
1648 err = qlcnic_need_fw_reset(adapter); in qlcnic_82xx_start_firmware()
1652 err = qlcnic_pinit_from_rom(adapter); in qlcnic_82xx_start_firmware()
1656 err = qlcnic_load_firmware(adapter); in qlcnic_82xx_start_firmware()
1660 qlcnic_release_firmware(adapter); in qlcnic_82xx_start_firmware()
1661 QLCWR32(adapter, CRB_DRIVER_VERSION, QLCNIC_DRIVER_VERSION); in qlcnic_82xx_start_firmware()
1664 err = qlcnic_check_fw_status(adapter); in qlcnic_82xx_start_firmware()
1668 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_READY); in qlcnic_82xx_start_firmware()
1669 qlcnic_idc_debug_info(adapter, 1); in qlcnic_82xx_start_firmware()
1670 err = qlcnic_check_eswitch_mode(adapter); in qlcnic_82xx_start_firmware()
1672 dev_err(&adapter->pdev->dev, in qlcnic_82xx_start_firmware()
1676 err = qlcnic_set_mgmt_operations(adapter); in qlcnic_82xx_start_firmware()
1680 qlcnic_check_options(adapter); in qlcnic_82xx_start_firmware()
1681 adapter->need_fw_reset = 0; in qlcnic_82xx_start_firmware()
1683 qlcnic_release_firmware(adapter); in qlcnic_82xx_start_firmware()
1687 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, QLCNIC_DEV_FAILED); in qlcnic_82xx_start_firmware()
1688 dev_err(&adapter->pdev->dev, "Device state set to failed\n"); in qlcnic_82xx_start_firmware()
1690 qlcnic_release_firmware(adapter); in qlcnic_82xx_start_firmware()
1695 qlcnic_request_irq(struct qlcnic_adapter *adapter) in qlcnic_request_irq() argument
1703 struct net_device *netdev = adapter->netdev; in qlcnic_request_irq()
1704 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; in qlcnic_request_irq()
1706 if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST) { in qlcnic_request_irq()
1707 if (qlcnic_82xx_check(adapter)) in qlcnic_request_irq()
1711 if (!QLCNIC_IS_MSI_FAMILY(adapter)) in qlcnic_request_irq()
1715 if (adapter->flags & QLCNIC_MSIX_ENABLED) in qlcnic_request_irq()
1717 else if (adapter->flags & QLCNIC_MSI_ENABLED) in qlcnic_request_irq()
1721 if (qlcnic_82xx_check(adapter)) in qlcnic_request_irq()
1727 adapter->irq = netdev->irq; in qlcnic_request_irq()
1729 if (adapter->ahw->diag_test != QLCNIC_LOOPBACK_TEST) { in qlcnic_request_irq()
1730 if (qlcnic_82xx_check(adapter) || in qlcnic_request_irq()
1731 (qlcnic_83xx_check(adapter) && in qlcnic_request_irq()
1732 (adapter->flags & QLCNIC_MSIX_ENABLED))) { in qlcnic_request_irq()
1733 num_sds_rings = adapter->drv_sds_rings; in qlcnic_request_irq()
1736 if (qlcnic_82xx_check(adapter) && in qlcnic_request_irq()
1737 !qlcnic_check_multi_tx(adapter) && in qlcnic_request_irq()
1739 if (!(adapter->flags & in qlcnic_request_irq()
1761 if ((qlcnic_82xx_check(adapter) && in qlcnic_request_irq()
1762 qlcnic_check_multi_tx(adapter)) || in qlcnic_request_irq()
1763 (qlcnic_83xx_check(adapter) && in qlcnic_request_irq()
1764 (adapter->flags & QLCNIC_MSIX_ENABLED) && in qlcnic_request_irq()
1765 !(adapter->flags & QLCNIC_TX_INTR_SHARED))) { in qlcnic_request_irq()
1767 for (ring = 0; ring < adapter->drv_tx_rings; in qlcnic_request_irq()
1769 tx_ring = &adapter->tx_ring[ring]; in qlcnic_request_irq()
1783 qlcnic_free_irq(struct qlcnic_adapter *adapter) in qlcnic_free_irq() argument
1789 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; in qlcnic_free_irq()
1791 if (adapter->ahw->diag_test != QLCNIC_LOOPBACK_TEST) { in qlcnic_free_irq()
1792 if (qlcnic_82xx_check(adapter) || in qlcnic_free_irq()
1793 (qlcnic_83xx_check(adapter) && in qlcnic_free_irq()
1794 (adapter->flags & QLCNIC_MSIX_ENABLED))) { in qlcnic_free_irq()
1795 for (ring = 0; ring < adapter->drv_sds_rings; ring++) { in qlcnic_free_irq()
1800 if ((qlcnic_83xx_check(adapter) && in qlcnic_free_irq()
1801 !(adapter->flags & QLCNIC_TX_INTR_SHARED)) || in qlcnic_free_irq()
1802 (qlcnic_82xx_check(adapter) && in qlcnic_free_irq()
1803 qlcnic_check_multi_tx(adapter))) { in qlcnic_free_irq()
1804 for (ring = 0; ring < adapter->drv_tx_rings; in qlcnic_free_irq()
1806 tx_ring = &adapter->tx_ring[ring]; in qlcnic_free_irq()
1814 static void qlcnic_get_lro_mss_capability(struct qlcnic_adapter *adapter) in qlcnic_get_lro_mss_capability() argument
1818 if (qlcnic_82xx_check(adapter)) { in qlcnic_get_lro_mss_capability()
1819 if (adapter->ahw->extra_capability[0] & in qlcnic_get_lro_mss_capability()
1821 adapter->flags |= QLCNIC_FW_LRO_MSS_CAP; in qlcnic_get_lro_mss_capability()
1823 capab = adapter->ahw->capabilities; in qlcnic_get_lro_mss_capability()
1825 adapter->flags |= QLCNIC_FW_LRO_MSS_CAP; in qlcnic_get_lro_mss_capability()
1829 static int qlcnic_config_def_intr_coalesce(struct qlcnic_adapter *adapter) in qlcnic_config_def_intr_coalesce() argument
1831 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_config_def_intr_coalesce()
1837 if (qlcnic_83xx_check(adapter)) { in qlcnic_config_def_intr_coalesce()
1844 err = qlcnic_83xx_set_rx_tx_intr_coal(adapter); in qlcnic_config_def_intr_coalesce()
1850 err = qlcnic_82xx_set_rx_coalesce(adapter); in qlcnic_config_def_intr_coalesce()
1856 int __qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev) in __qlcnic_up() argument
1861 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) in __qlcnic_up()
1864 if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) in __qlcnic_up()
1867 if (qlcnic_set_eswitch_port_config(adapter)) in __qlcnic_up()
1870 qlcnic_get_lro_mss_capability(adapter); in __qlcnic_up()
1872 if (qlcnic_fw_create_ctx(adapter)) in __qlcnic_up()
1875 for (ring = 0; ring < adapter->max_rds_rings; ring++) { in __qlcnic_up()
1876 rds_ring = &adapter->recv_ctx->rds_rings[ring]; in __qlcnic_up()
1877 qlcnic_post_rx_buffers(adapter, rds_ring, ring); in __qlcnic_up()
1881 qlcnic_fw_cmd_set_mtu(adapter, netdev->mtu); in __qlcnic_up()
1883 adapter->ahw->linkup = 0; in __qlcnic_up()
1885 if (adapter->drv_sds_rings > 1) in __qlcnic_up()
1886 qlcnic_config_rss(adapter, 1); in __qlcnic_up()
1888 qlcnic_config_def_intr_coalesce(adapter); in __qlcnic_up()
1891 qlcnic_config_hw_lro(adapter, QLCNIC_LRO_ENABLED); in __qlcnic_up()
1893 set_bit(__QLCNIC_DEV_UP, &adapter->state); in __qlcnic_up()
1894 qlcnic_napi_enable(adapter); in __qlcnic_up()
1896 qlcnic_linkevent_request(adapter, 1); in __qlcnic_up()
1898 adapter->ahw->reset_context = 0; in __qlcnic_up()
1903 int qlcnic_up(struct qlcnic_adapter *adapter, struct net_device *netdev) in qlcnic_up() argument
1909 err = __qlcnic_up(adapter, netdev); in qlcnic_up()
1915 void __qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev) in __qlcnic_down() argument
1919 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) in __qlcnic_down()
1922 if (!test_and_clear_bit(__QLCNIC_DEV_UP, &adapter->state)) in __qlcnic_down()
1927 adapter->ahw->linkup = 0; in __qlcnic_down()
1930 qlcnic_free_mac_list(adapter); in __qlcnic_down()
1932 if (adapter->fhash.fnum) in __qlcnic_down()
1933 qlcnic_delete_lb_filters(adapter); in __qlcnic_down()
1935 qlcnic_nic_set_promisc(adapter, QLCNIC_NIU_NON_PROMISC_MODE); in __qlcnic_down()
1936 if (qlcnic_sriov_vf_check(adapter)) in __qlcnic_down()
1937 qlcnic_sriov_cleanup_async_list(&adapter->ahw->sriov->bc); in __qlcnic_down()
1939 qlcnic_napi_disable(adapter); in __qlcnic_down()
1941 qlcnic_fw_destroy_ctx(adapter); in __qlcnic_down()
1942 adapter->flags &= ~QLCNIC_FW_LRO_MSS_CAP; in __qlcnic_down()
1944 qlcnic_reset_rx_buffers_list(adapter); in __qlcnic_down()
1946 for (ring = 0; ring < adapter->drv_tx_rings; ring++) in __qlcnic_down()
1947 qlcnic_release_tx_buffers(adapter, &adapter->tx_ring[ring]); in __qlcnic_down()
1952 void qlcnic_down(struct qlcnic_adapter *adapter, struct net_device *netdev) in qlcnic_down() argument
1956 __qlcnic_down(adapter, netdev); in qlcnic_down()
1962 qlcnic_attach(struct qlcnic_adapter *adapter) in qlcnic_attach() argument
1964 struct net_device *netdev = adapter->netdev; in qlcnic_attach()
1965 struct pci_dev *pdev = adapter->pdev; in qlcnic_attach()
1968 if (adapter->is_up == QLCNIC_ADAPTER_UP_MAGIC) in qlcnic_attach()
1971 err = qlcnic_napi_add(adapter, netdev); in qlcnic_attach()
1975 err = qlcnic_alloc_sw_resources(adapter); in qlcnic_attach()
1981 err = qlcnic_alloc_hw_resources(adapter); in qlcnic_attach()
1987 err = qlcnic_request_irq(adapter); in qlcnic_attach()
1993 qlcnic_create_sysfs_entries(adapter); in qlcnic_attach()
1995 if (qlcnic_encap_rx_offload(adapter)) in qlcnic_attach()
1998 adapter->is_up = QLCNIC_ADAPTER_UP_MAGIC; in qlcnic_attach()
2002 qlcnic_free_hw_resources(adapter); in qlcnic_attach()
2004 qlcnic_free_sw_resources(adapter); in qlcnic_attach()
2006 qlcnic_napi_del(adapter); in qlcnic_attach()
2010 void qlcnic_detach(struct qlcnic_adapter *adapter) in qlcnic_detach() argument
2012 if (adapter->is_up != QLCNIC_ADAPTER_UP_MAGIC) in qlcnic_detach()
2015 qlcnic_remove_sysfs_entries(adapter); in qlcnic_detach()
2017 qlcnic_free_hw_resources(adapter); in qlcnic_detach()
2018 qlcnic_release_rx_buffers(adapter); in qlcnic_detach()
2019 qlcnic_free_irq(adapter); in qlcnic_detach()
2020 qlcnic_napi_del(adapter); in qlcnic_detach()
2021 qlcnic_free_sw_resources(adapter); in qlcnic_detach()
2023 adapter->is_up = 0; in qlcnic_detach()
2028 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_diag_free_res() local
2030 int drv_tx_rings = adapter->drv_tx_rings; in qlcnic_diag_free_res()
2033 clear_bit(__QLCNIC_DEV_UP, &adapter->state); in qlcnic_diag_free_res()
2034 if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST) { in qlcnic_diag_free_res()
2035 for (ring = 0; ring < adapter->drv_sds_rings; ring++) { in qlcnic_diag_free_res()
2036 sds_ring = &adapter->recv_ctx->sds_rings[ring]; in qlcnic_diag_free_res()
2037 qlcnic_disable_sds_intr(adapter, sds_ring); in qlcnic_diag_free_res()
2041 qlcnic_fw_destroy_ctx(adapter); in qlcnic_diag_free_res()
2043 qlcnic_detach(adapter); in qlcnic_diag_free_res()
2045 adapter->ahw->diag_test = 0; in qlcnic_diag_free_res()
2046 adapter->drv_sds_rings = drv_sds_rings; in qlcnic_diag_free_res()
2047 adapter->drv_tx_rings = drv_tx_rings; in qlcnic_diag_free_res()
2049 if (qlcnic_attach(adapter)) in qlcnic_diag_free_res()
2053 __qlcnic_up(adapter, netdev); in qlcnic_diag_free_res()
2058 static int qlcnic_alloc_adapter_resources(struct qlcnic_adapter *adapter) in qlcnic_alloc_adapter_resources() argument
2060 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_alloc_adapter_resources()
2063 adapter->recv_ctx = kzalloc(sizeof(struct qlcnic_recv_context), in qlcnic_alloc_adapter_resources()
2065 if (!adapter->recv_ctx) { in qlcnic_alloc_adapter_resources()
2070 if (qlcnic_83xx_check(adapter)) { in qlcnic_alloc_adapter_resources()
2083 memset(&adapter->stats, 0, sizeof(adapter->stats)); in qlcnic_alloc_adapter_resources()
2088 static void qlcnic_free_adapter_resources(struct qlcnic_adapter *adapter) in qlcnic_free_adapter_resources() argument
2090 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump; in qlcnic_free_adapter_resources()
2092 kfree(adapter->recv_ctx); in qlcnic_free_adapter_resources()
2093 adapter->recv_ctx = NULL; in qlcnic_free_adapter_resources()
2101 dma_free_coherent(&adapter->pdev->dev, QLC_PEX_DMA_READ_SIZE, in qlcnic_free_adapter_resources()
2106 kfree(adapter->ahw->reset.buff); in qlcnic_free_adapter_resources()
2107 adapter->ahw->fw_dump.tmpl_hdr = NULL; in qlcnic_free_adapter_resources()
2112 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_diag_alloc_res() local
2121 __qlcnic_down(adapter, netdev); in qlcnic_diag_alloc_res()
2123 qlcnic_detach(adapter); in qlcnic_diag_alloc_res()
2125 adapter->drv_sds_rings = QLCNIC_SINGLE_RING; in qlcnic_diag_alloc_res()
2126 adapter->ahw->diag_test = test; in qlcnic_diag_alloc_res()
2127 adapter->ahw->linkup = 0; in qlcnic_diag_alloc_res()
2129 ret = qlcnic_attach(adapter); in qlcnic_diag_alloc_res()
2135 ret = qlcnic_fw_create_ctx(adapter); in qlcnic_diag_alloc_res()
2137 qlcnic_detach(adapter); in qlcnic_diag_alloc_res()
2142 for (ring = 0; ring < adapter->max_rds_rings; ring++) { in qlcnic_diag_alloc_res()
2143 rds_ring = &adapter->recv_ctx->rds_rings[ring]; in qlcnic_diag_alloc_res()
2144 qlcnic_post_rx_buffers(adapter, rds_ring, ring); in qlcnic_diag_alloc_res()
2147 if (adapter->ahw->diag_test == QLCNIC_INTERRUPT_TEST) { in qlcnic_diag_alloc_res()
2148 for (ring = 0; ring < adapter->drv_sds_rings; ring++) { in qlcnic_diag_alloc_res()
2149 sds_ring = &adapter->recv_ctx->sds_rings[ring]; in qlcnic_diag_alloc_res()
2150 qlcnic_enable_sds_intr(adapter, sds_ring); in qlcnic_diag_alloc_res()
2154 if (adapter->ahw->diag_test == QLCNIC_LOOPBACK_TEST) { in qlcnic_diag_alloc_res()
2155 adapter->ahw->loopback_state = 0; in qlcnic_diag_alloc_res()
2156 qlcnic_linkevent_request(adapter, 1); in qlcnic_diag_alloc_res()
2159 set_bit(__QLCNIC_DEV_UP, &adapter->state); in qlcnic_diag_alloc_res()
2166 qlcnic_reset_hw_context(struct qlcnic_adapter *adapter) in qlcnic_reset_hw_context() argument
2168 struct net_device *netdev = adapter->netdev; in qlcnic_reset_hw_context()
2170 if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) in qlcnic_reset_hw_context()
2175 qlcnic_down(adapter, netdev); in qlcnic_reset_hw_context()
2177 qlcnic_up(adapter, netdev); in qlcnic_reset_hw_context()
2181 clear_bit(__QLCNIC_RESETTING, &adapter->state); in qlcnic_reset_hw_context()
2182 netdev_info(adapter->netdev, "%s: soft reset complete\n", __func__); in qlcnic_reset_hw_context()
2187 qlcnic_reset_context(struct qlcnic_adapter *adapter) in qlcnic_reset_context() argument
2190 struct net_device *netdev = adapter->netdev; in qlcnic_reset_context()
2192 if (test_and_set_bit(__QLCNIC_RESETTING, &adapter->state)) in qlcnic_reset_context()
2195 if (adapter->is_up == QLCNIC_ADAPTER_UP_MAGIC) { in qlcnic_reset_context()
2200 __qlcnic_down(adapter, netdev); in qlcnic_reset_context()
2202 qlcnic_detach(adapter); in qlcnic_reset_context()
2205 err = qlcnic_attach(adapter); in qlcnic_reset_context()
2207 __qlcnic_up(adapter, netdev); in qlcnic_reset_context()
2215 clear_bit(__QLCNIC_RESETTING, &adapter->state); in qlcnic_reset_context()
2219 static void qlcnic_82xx_set_mac_filter_count(struct qlcnic_adapter *adapter) in qlcnic_82xx_set_mac_filter_count() argument
2221 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_82xx_set_mac_filter_count()
2235 static int qlcnic_set_real_num_queues(struct qlcnic_adapter *adapter, in qlcnic_set_real_num_queues() argument
2238 struct net_device *netdev = adapter->netdev; in qlcnic_set_real_num_queues()
2261 qlcnic_setup_netdev(struct qlcnic_adapter *adapter, struct net_device *netdev) in qlcnic_setup_netdev() argument
2264 struct pci_dev *pdev = adapter->pdev; in qlcnic_setup_netdev()
2266 adapter->rx_csum = 1; in qlcnic_setup_netdev()
2267 adapter->ahw->mc_enabled = 0; in qlcnic_setup_netdev()
2268 qlcnic_set_mac_filter_count(adapter); in qlcnic_setup_netdev()
2275 netdev->ethtool_ops = (qlcnic_sriov_vf_check(adapter)) ? in qlcnic_setup_netdev()
2284 if (QLCNIC_IS_TSO_CAPABLE(adapter)) { in qlcnic_setup_netdev()
2289 if (qlcnic_vlan_tx_check(adapter)) in qlcnic_setup_netdev()
2292 if (qlcnic_sriov_vf_check(adapter)) in qlcnic_setup_netdev()
2295 if (adapter->ahw->capabilities & QLCNIC_FW_CAPABILITY_HW_LRO) in qlcnic_setup_netdev()
2298 if (qlcnic_encap_tx_offload(adapter)) { in qlcnic_setup_netdev()
2301 /* encapsulation Tx offload supported by Adapter */ in qlcnic_setup_netdev()
2308 if (qlcnic_encap_rx_offload(adapter)) { in qlcnic_setup_netdev()
2316 netdev->irq = adapter->msix_entries[0].vector; in qlcnic_setup_netdev()
2322 err = qlcnic_set_real_num_queues(adapter, adapter->drv_tx_rings, in qlcnic_setup_netdev()
2323 adapter->drv_sds_rings); in qlcnic_setup_netdev()
2327 qlcnic_dcb_init_dcbnl_ops(adapter->dcb); in qlcnic_setup_netdev()
2338 void qlcnic_free_tx_rings(struct qlcnic_adapter *adapter) in qlcnic_free_tx_rings() argument
2343 for (ring = 0; ring < adapter->drv_tx_rings; ring++) { in qlcnic_free_tx_rings()
2344 tx_ring = &adapter->tx_ring[ring]; in qlcnic_free_tx_rings()
2350 kfree(adapter->tx_ring); in qlcnic_free_tx_rings()
2353 int qlcnic_alloc_tx_rings(struct qlcnic_adapter *adapter, in qlcnic_alloc_tx_rings() argument
2360 tx_ring = kcalloc(adapter->drv_tx_rings, in qlcnic_alloc_tx_rings()
2365 adapter->tx_ring = tx_ring; in qlcnic_alloc_tx_rings()
2367 for (ring = 0; ring < adapter->drv_tx_rings; ring++) { in qlcnic_alloc_tx_rings()
2368 tx_ring = &adapter->tx_ring[ring]; in qlcnic_alloc_tx_rings()
2369 tx_ring->num_desc = adapter->num_txd; in qlcnic_alloc_tx_rings()
2373 qlcnic_free_tx_rings(adapter); in qlcnic_alloc_tx_rings()
2380 if (qlcnic_83xx_check(adapter) || in qlcnic_alloc_tx_rings()
2381 (qlcnic_82xx_check(adapter) && qlcnic_check_multi_tx(adapter))) { in qlcnic_alloc_tx_rings()
2382 for (ring = 0; ring < adapter->drv_tx_rings; ring++) { in qlcnic_alloc_tx_rings()
2383 tx_ring = &adapter->tx_ring[ring]; in qlcnic_alloc_tx_rings()
2384 tx_ring->adapter = adapter; in qlcnic_alloc_tx_rings()
2385 if (adapter->flags & QLCNIC_MSIX_ENABLED) { in qlcnic_alloc_tx_rings()
2386 index = adapter->drv_sds_rings + ring; in qlcnic_alloc_tx_rings()
2387 vector = adapter->msix_entries[index].vector; in qlcnic_alloc_tx_rings()
2396 void qlcnic_set_drv_version(struct qlcnic_adapter *adapter) in qlcnic_set_drv_version() argument
2398 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_set_drv_version()
2401 if (qlcnic_82xx_check(adapter)) in qlcnic_set_drv_version()
2403 else if (qlcnic_83xx_check(adapter)) in qlcnic_set_drv_version()
2407 qlcnic_fw_cmd_set_drv_version(adapter, fw_cmd); in qlcnic_set_drv_version()
2411 static void qlcnic_reset_api_lock(struct qlcnic_adapter *adapter) in qlcnic_reset_api_lock() argument
2413 qlcnic_api_lock(adapter); in qlcnic_reset_api_lock()
2414 qlcnic_api_unlock(adapter); in qlcnic_reset_api_lock()
2422 struct qlcnic_adapter *adapter = NULL; in qlcnic_probe() local
2487 adapter = netdev_priv(netdev); in qlcnic_probe()
2488 adapter->netdev = netdev; in qlcnic_probe()
2489 adapter->pdev = pdev; in qlcnic_probe()
2490 adapter->ahw = ahw; in qlcnic_probe()
2492 adapter->qlcnic_wq = create_singlethread_workqueue("qlcnic"); in qlcnic_probe()
2493 if (adapter->qlcnic_wq == NULL) { in qlcnic_probe()
2499 err = qlcnic_alloc_adapter_resources(adapter); in qlcnic_probe()
2503 adapter->dev_rst_time = jiffies; in qlcnic_probe()
2505 ahw->max_vnic_func = qlcnic_get_vnic_func_count(adapter); in qlcnic_probe()
2507 adapter->fdb_mac_learn = true; in qlcnic_probe()
2509 adapter->drv_mac_learn = true; in qlcnic_probe()
2511 rwlock_init(&adapter->ahw->crb_lock); in qlcnic_probe()
2512 mutex_init(&adapter->ahw->mem_lock); in qlcnic_probe()
2514 INIT_LIST_HEAD(&adapter->mac_list); in qlcnic_probe()
2516 qlcnic_register_dcb(adapter); in qlcnic_probe()
2518 if (qlcnic_82xx_check(adapter)) { in qlcnic_probe()
2519 qlcnic_check_vf(adapter, ent); in qlcnic_probe()
2520 adapter->portnum = adapter->ahw->pci_func; in qlcnic_probe()
2521 qlcnic_reset_api_lock(adapter); in qlcnic_probe()
2522 err = qlcnic_start_firmware(adapter); in qlcnic_probe()
2530 if (adapter->ahw->msix_supported) { in qlcnic_probe()
2531 if (qlcnic_check_multi_tx_capability(adapter) == 1) in qlcnic_probe()
2532 qlcnic_set_tx_ring_count(adapter, in qlcnic_probe()
2535 qlcnic_set_tx_ring_count(adapter, in qlcnic_probe()
2537 qlcnic_set_sds_ring_count(adapter, in qlcnic_probe()
2540 qlcnic_set_tx_ring_count(adapter, QLCNIC_SINGLE_RING); in qlcnic_probe()
2541 qlcnic_set_sds_ring_count(adapter, QLCNIC_SINGLE_RING); in qlcnic_probe()
2544 err = qlcnic_setup_idc_param(adapter); in qlcnic_probe()
2548 adapter->flags |= QLCNIC_NEED_FLR; in qlcnic_probe()
2550 } else if (qlcnic_83xx_check(adapter)) { in qlcnic_probe()
2551 qlcnic_83xx_check_vf(adapter, ent); in qlcnic_probe()
2552 adapter->portnum = adapter->ahw->pci_func; in qlcnic_probe()
2553 err = qlcnic_83xx_init(adapter); in qlcnic_probe()
2557 dev_err(&pdev->dev, "Adapter initialization failed due to a faulty hardware\n"); in qlcnic_probe()
2558 …dev_err(&pdev->dev, "Please replace the adapter with new one and return the faulty adapter for rep… in qlcnic_probe()
2561 dev_err(&pdev->dev, "Adapter initialization failed. Please reboot\n"); in qlcnic_probe()
2564 dev_err(&pdev->dev, "Adapter initialization failed\n"); in qlcnic_probe()
2567 …dev_err(&pdev->dev, "Adapter initialization failed. Driver will load in maintenance mode to recove… in qlcnic_probe()
2572 if (qlcnic_sriov_vf_check(adapter)) in qlcnic_probe()
2581 if (qlcnic_read_mac_addr(adapter)) in qlcnic_probe()
2584 qlcnic_read_phys_port_id(adapter); in qlcnic_probe()
2586 if (adapter->portnum == 0) { in qlcnic_probe()
2587 qlcnic_get_board_name(adapter, board_name); in qlcnic_probe()
2591 board_name, adapter->ahw->revision_id); in qlcnic_probe()
2594 if (qlcnic_83xx_check(adapter) && !qlcnic_use_msi_x && in qlcnic_probe()
2599 if (qlcnic_82xx_check(adapter)) { in qlcnic_probe()
2600 err = qlcnic_dcb_enable(adapter->dcb); in qlcnic_probe()
2602 qlcnic_dcb_free(adapter->dcb); in qlcnic_probe()
2607 qlcnic_dcb_get_info(adapter->dcb); in qlcnic_probe()
2608 err = qlcnic_setup_intr(adapter); in qlcnic_probe()
2616 err = qlcnic_get_act_pci_func(adapter); in qlcnic_probe()
2620 if (adapter->portnum == 0) in qlcnic_probe()
2621 qlcnic_set_drv_version(adapter); in qlcnic_probe()
2623 err = qlcnic_setup_netdev(adapter, netdev); in qlcnic_probe()
2627 pci_set_drvdata(pdev, adapter); in qlcnic_probe()
2629 if (qlcnic_82xx_check(adapter)) in qlcnic_probe()
2630 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, in qlcnic_probe()
2633 switch (adapter->ahw->port_type) { in qlcnic_probe()
2635 dev_info(&adapter->pdev->dev, "%s: GbE port initialized\n", in qlcnic_probe()
2636 adapter->netdev->name); in qlcnic_probe()
2639 dev_info(&adapter->pdev->dev, "%s: XGbE port initialized\n", in qlcnic_probe()
2640 adapter->netdev->name); in qlcnic_probe()
2644 if (adapter->drv_mac_learn) in qlcnic_probe()
2645 qlcnic_alloc_lb_filters_mem(adapter); in qlcnic_probe()
2647 qlcnic_add_sysfs(adapter); in qlcnic_probe()
2648 qlcnic_register_hwmon_dev(adapter); in qlcnic_probe()
2652 if (qlcnic_83xx_check(adapter)) in qlcnic_probe()
2653 qlcnic_83xx_free_mbx_intr(adapter); in qlcnic_probe()
2656 qlcnic_teardown_intr(adapter); in qlcnic_probe()
2657 qlcnic_cancel_idc_work(adapter); in qlcnic_probe()
2658 qlcnic_clr_all_drv_state(adapter, 0); in qlcnic_probe()
2661 qlcnic_free_adapter_resources(adapter); in qlcnic_probe()
2664 destroy_workqueue(adapter->qlcnic_wq); in qlcnic_probe()
2683 set_bit(__QLCNIC_MAINTENANCE_MODE, &adapter->state); in qlcnic_probe()
2688 if (qlcnic_83xx_check(adapter)) in qlcnic_probe()
2689 adapter->tgt_status_reg = NULL; in qlcnic_probe()
2697 qlcnic_clr_all_drv_state(adapter, 0); in qlcnic_probe()
2701 pci_set_drvdata(pdev, adapter); in qlcnic_probe()
2702 qlcnic_add_sysfs(adapter); in qlcnic_probe()
2709 struct qlcnic_adapter *adapter; in qlcnic_remove() local
2713 adapter = pci_get_drvdata(pdev); in qlcnic_remove()
2714 if (adapter == NULL) in qlcnic_remove()
2717 netdev = adapter->netdev; in qlcnic_remove()
2719 qlcnic_cancel_idc_work(adapter); in qlcnic_remove()
2720 qlcnic_sriov_pf_disable(adapter); in qlcnic_remove()
2721 ahw = adapter->ahw; in qlcnic_remove()
2724 qlcnic_sriov_cleanup(adapter); in qlcnic_remove()
2726 if (qlcnic_83xx_check(adapter)) { in qlcnic_remove()
2727 qlcnic_83xx_initialize_nic(adapter, 0); in qlcnic_remove()
2728 cancel_delayed_work_sync(&adapter->idc_aen_work); in qlcnic_remove()
2729 qlcnic_83xx_free_mbx_intr(adapter); in qlcnic_remove()
2730 qlcnic_83xx_detach_mailbox_work(adapter); in qlcnic_remove()
2735 qlcnic_dcb_free(adapter->dcb); in qlcnic_remove()
2736 qlcnic_detach(adapter); in qlcnic_remove()
2737 kfree(adapter->npars); in qlcnic_remove()
2738 kfree(adapter->eswitch); in qlcnic_remove()
2740 if (qlcnic_82xx_check(adapter)) in qlcnic_remove()
2741 qlcnic_clr_all_drv_state(adapter, 0); in qlcnic_remove()
2743 clear_bit(__QLCNIC_RESETTING, &adapter->state); in qlcnic_remove()
2745 qlcnic_free_lb_filters_mem(adapter); in qlcnic_remove()
2747 qlcnic_teardown_intr(adapter); in qlcnic_remove()
2749 qlcnic_remove_sysfs(adapter); in qlcnic_remove()
2751 qlcnic_unregister_hwmon_dev(adapter); in qlcnic_remove()
2753 qlcnic_cleanup_pci_map(adapter->ahw); in qlcnic_remove()
2755 qlcnic_release_firmware(adapter); in qlcnic_remove()
2760 if (adapter->qlcnic_wq) { in qlcnic_remove()
2761 destroy_workqueue(adapter->qlcnic_wq); in qlcnic_remove()
2762 adapter->qlcnic_wq = NULL; in qlcnic_remove()
2765 qlcnic_free_adapter_resources(adapter); in qlcnic_remove()
2785 struct qlcnic_adapter *adapter = dev_get_drvdata(dev_d); in qlcnic_resume() local
2787 return __qlcnic_resume(adapter); in qlcnic_resume()
2792 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_open() local
2795 if (test_bit(__QLCNIC_MAINTENANCE_MODE, &adapter->state)) { in qlcnic_open()
2804 err = qlcnic_attach(adapter); in qlcnic_open()
2808 err = __qlcnic_up(adapter, netdev); in qlcnic_open()
2810 qlcnic_detach(adapter); in qlcnic_open()
2820 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_close() local
2822 __qlcnic_down(adapter, netdev); in qlcnic_close()
2829 void qlcnic_alloc_lb_filters_mem(struct qlcnic_adapter *adapter) in qlcnic_alloc_lb_filters_mem() argument
2833 struct net_device *netdev = adapter->netdev; in qlcnic_alloc_lb_filters_mem()
2837 if (adapter->fhash.fmax && adapter->fhash.fhead) in qlcnic_alloc_lb_filters_mem()
2840 act_pci_func = adapter->ahw->total_nic_func; in qlcnic_alloc_lb_filters_mem()
2841 spin_lock_init(&adapter->mac_learn_lock); in qlcnic_alloc_lb_filters_mem()
2842 spin_lock_init(&adapter->rx_mac_learn_lock); in qlcnic_alloc_lb_filters_mem()
2844 if (qlcnic_sriov_vf_check(adapter)) { in qlcnic_alloc_lb_filters_mem()
2846 adapter->fhash.fbucket_size = QLCNIC_VF_LB_BUCKET_SIZE; in qlcnic_alloc_lb_filters_mem()
2847 } else if (qlcnic_82xx_check(adapter)) { in qlcnic_alloc_lb_filters_mem()
2849 adapter->fhash.fbucket_size = QLCNIC_LB_BUCKET_SIZE; in qlcnic_alloc_lb_filters_mem()
2852 adapter->fhash.fbucket_size = QLC_83XX_LB_BUCKET_SIZE; in qlcnic_alloc_lb_filters_mem()
2855 head = kcalloc(adapter->fhash.fbucket_size, in qlcnic_alloc_lb_filters_mem()
2861 adapter->fhash.fmax = (filter_size / act_pci_func); in qlcnic_alloc_lb_filters_mem()
2862 adapter->fhash.fhead = head; in qlcnic_alloc_lb_filters_mem()
2865 act_pci_func, adapter->fhash.fmax); in qlcnic_alloc_lb_filters_mem()
2867 for (i = 0; i < adapter->fhash.fbucket_size; i++) in qlcnic_alloc_lb_filters_mem()
2868 INIT_HLIST_HEAD(&adapter->fhash.fhead[i]); in qlcnic_alloc_lb_filters_mem()
2870 adapter->rx_fhash.fbucket_size = adapter->fhash.fbucket_size; in qlcnic_alloc_lb_filters_mem()
2872 head = kcalloc(adapter->rx_fhash.fbucket_size, in qlcnic_alloc_lb_filters_mem()
2878 adapter->rx_fhash.fmax = (filter_size / act_pci_func); in qlcnic_alloc_lb_filters_mem()
2879 adapter->rx_fhash.fhead = head; in qlcnic_alloc_lb_filters_mem()
2881 for (i = 0; i < adapter->rx_fhash.fbucket_size; i++) in qlcnic_alloc_lb_filters_mem()
2882 INIT_HLIST_HEAD(&adapter->rx_fhash.fhead[i]); in qlcnic_alloc_lb_filters_mem()
2885 static void qlcnic_free_lb_filters_mem(struct qlcnic_adapter *adapter) in qlcnic_free_lb_filters_mem() argument
2887 if (adapter->fhash.fmax) in qlcnic_free_lb_filters_mem()
2888 kfree(adapter->fhash.fhead); in qlcnic_free_lb_filters_mem()
2890 adapter->fhash.fhead = NULL; in qlcnic_free_lb_filters_mem()
2891 adapter->fhash.fmax = 0; in qlcnic_free_lb_filters_mem()
2893 if (adapter->rx_fhash.fmax) in qlcnic_free_lb_filters_mem()
2894 kfree(adapter->rx_fhash.fhead); in qlcnic_free_lb_filters_mem()
2896 adapter->rx_fhash.fmax = 0; in qlcnic_free_lb_filters_mem()
2897 adapter->rx_fhash.fhead = NULL; in qlcnic_free_lb_filters_mem()
2900 int qlcnic_check_temp(struct qlcnic_adapter *adapter) in qlcnic_check_temp() argument
2902 struct net_device *netdev = adapter->netdev; in qlcnic_check_temp()
2906 if (qlcnic_83xx_check(adapter)) in qlcnic_check_temp()
2907 temp = QLCRDX(adapter->ahw, QLC_83XX_ASIC_TEMP); in qlcnic_check_temp()
2909 if (qlcnic_82xx_check(adapter)) in qlcnic_check_temp()
2910 temp = QLC_SHARED_REG_RD32(adapter, QLCNIC_ASIC_TEMP); in qlcnic_check_temp()
2922 if (adapter->ahw->temp == QLCNIC_TEMP_NORMAL) { in qlcnic_check_temp()
2930 if (adapter->ahw->temp == QLCNIC_TEMP_WARN) { in qlcnic_check_temp()
2936 adapter->ahw->temp = temp_state; in qlcnic_check_temp()
2952 static void qlcnic_dump_rings(struct qlcnic_adapter *adapter) in qlcnic_dump_rings() argument
2954 struct qlcnic_recv_context *recv_ctx = adapter->recv_ctx; in qlcnic_dump_rings()
2955 struct net_device *netdev = adapter->netdev; in qlcnic_dump_rings()
2964 for (ring = 0; ring < adapter->max_rds_rings; ring++) { in qlcnic_dump_rings()
2974 for (ring = 0; ring < adapter->drv_sds_rings; ring++) { in qlcnic_dump_rings()
2985 for (ring = 0; ring < adapter->drv_tx_rings; ring++) { in qlcnic_dump_rings()
2986 tx_ring = &adapter->tx_ring[ring]; in qlcnic_dump_rings()
3011 if (netif_msg_tx_err(adapter->ahw)) in qlcnic_dump_rings()
3019 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_tx_timeout() local
3021 if (test_bit(__QLCNIC_RESETTING, &adapter->state)) in qlcnic_tx_timeout()
3024 qlcnic_dump_rings(adapter); in qlcnic_tx_timeout()
3026 if (++adapter->tx_timeo_cnt >= QLCNIC_MAX_TX_TIMEOUTS || in qlcnic_tx_timeout()
3027 netif_msg_tx_err(adapter->ahw)) { in qlcnic_tx_timeout()
3028 netdev_err(netdev, "Tx timeout, reset the adapter.\n"); in qlcnic_tx_timeout()
3029 if (qlcnic_82xx_check(adapter)) in qlcnic_tx_timeout()
3030 adapter->need_fw_reset = 1; in qlcnic_tx_timeout()
3031 else if (qlcnic_83xx_check(adapter)) in qlcnic_tx_timeout()
3032 qlcnic_83xx_idc_request_reset(adapter, in qlcnic_tx_timeout()
3035 netdev_err(netdev, "Tx timeout, reset adapter context.\n"); in qlcnic_tx_timeout()
3036 adapter->ahw->reset_context = 1; in qlcnic_tx_timeout()
3042 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_get_stats() local
3045 if (test_bit(__QLCNIC_DEV_UP, &adapter->state)) in qlcnic_get_stats()
3046 qlcnic_update_stats(adapter); in qlcnic_get_stats()
3048 stats->rx_packets = adapter->stats.rx_pkts + adapter->stats.lro_pkts; in qlcnic_get_stats()
3049 stats->tx_packets = adapter->stats.xmitfinished; in qlcnic_get_stats()
3050 stats->rx_bytes = adapter->stats.rxbytes + adapter->stats.lrobytes; in qlcnic_get_stats()
3051 stats->tx_bytes = adapter->stats.txbytes; in qlcnic_get_stats()
3052 stats->rx_dropped = adapter->stats.rxdropped; in qlcnic_get_stats()
3053 stats->tx_dropped = adapter->stats.txdropped; in qlcnic_get_stats()
3058 static irqreturn_t qlcnic_82xx_clear_legacy_intr(struct qlcnic_adapter *adapter) in qlcnic_82xx_clear_legacy_intr() argument
3062 status = readl(adapter->isr_int_vec); in qlcnic_82xx_clear_legacy_intr()
3064 if (!(status & adapter->ahw->int_vec_bit)) in qlcnic_82xx_clear_legacy_intr()
3068 status = readl(adapter->crb_int_state_reg); in qlcnic_82xx_clear_legacy_intr()
3072 writel(0xffffffff, adapter->tgt_status_reg); in qlcnic_82xx_clear_legacy_intr()
3074 readl(adapter->isr_int_vec); in qlcnic_82xx_clear_legacy_intr()
3075 readl(adapter->isr_int_vec); in qlcnic_82xx_clear_legacy_intr()
3083 struct qlcnic_adapter *adapter = sds_ring->adapter; in qlcnic_tmp_intr() local
3085 if (adapter->flags & QLCNIC_MSIX_ENABLED) in qlcnic_tmp_intr()
3087 else if (adapter->flags & QLCNIC_MSI_ENABLED) { in qlcnic_tmp_intr()
3088 writel(0xffffffff, adapter->tgt_status_reg); in qlcnic_tmp_intr()
3092 if (qlcnic_clear_legacy_intr(adapter) == IRQ_NONE) in qlcnic_tmp_intr()
3096 adapter->ahw->diag_cnt++; in qlcnic_tmp_intr()
3097 qlcnic_enable_sds_intr(adapter, sds_ring); in qlcnic_tmp_intr()
3104 struct qlcnic_adapter *adapter = sds_ring->adapter; in qlcnic_intr() local
3106 if (qlcnic_clear_legacy_intr(adapter) == IRQ_NONE) in qlcnic_intr()
3117 struct qlcnic_adapter *adapter = sds_ring->adapter; in qlcnic_msi_intr() local
3120 writel(0xffffffff, adapter->tgt_status_reg); in qlcnic_msi_intr()
3143 qlcnic_idc_debug_info(struct qlcnic_adapter *adapter, u8 encoding) in qlcnic_idc_debug_info() argument
3147 val = adapter->portnum & 0xf; in qlcnic_idc_debug_info()
3149 val |= (jiffies - adapter->dev_rst_time) << 8; in qlcnic_idc_debug_info()
3151 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_SCRATCH, val); in qlcnic_idc_debug_info()
3152 adapter->dev_rst_time = jiffies; in qlcnic_idc_debug_info()
3156 qlcnic_set_drv_state(struct qlcnic_adapter *adapter, u8 state) in qlcnic_set_drv_state() argument
3163 if (qlcnic_api_lock(adapter)) in qlcnic_set_drv_state()
3166 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE); in qlcnic_set_drv_state()
3169 QLC_DEV_SET_RST_RDY(val, adapter->portnum); in qlcnic_set_drv_state()
3171 QLC_DEV_SET_QSCNT_RDY(val, adapter->portnum); in qlcnic_set_drv_state()
3173 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val); in qlcnic_set_drv_state()
3175 qlcnic_api_unlock(adapter); in qlcnic_set_drv_state()
3181 qlcnic_clr_drv_state(struct qlcnic_adapter *adapter) in qlcnic_clr_drv_state() argument
3185 if (qlcnic_api_lock(adapter)) in qlcnic_clr_drv_state()
3188 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE); in qlcnic_clr_drv_state()
3189 QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum); in qlcnic_clr_drv_state()
3190 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val); in qlcnic_clr_drv_state()
3192 qlcnic_api_unlock(adapter); in qlcnic_clr_drv_state()
3197 void qlcnic_clr_all_drv_state(struct qlcnic_adapter *adapter, u8 failed) in qlcnic_clr_all_drv_state() argument
3201 if (qlcnic_api_lock(adapter)) in qlcnic_clr_all_drv_state()
3204 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_ACTIVE); in qlcnic_clr_all_drv_state()
3205 QLC_DEV_CLR_REF_CNT(val, adapter->portnum); in qlcnic_clr_all_drv_state()
3206 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val); in qlcnic_clr_all_drv_state()
3209 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, in qlcnic_clr_all_drv_state()
3211 dev_info(&adapter->pdev->dev, in qlcnic_clr_all_drv_state()
3214 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, in qlcnic_clr_all_drv_state()
3217 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE); in qlcnic_clr_all_drv_state()
3218 QLC_DEV_CLR_RST_QSCNT(val, adapter->portnum); in qlcnic_clr_all_drv_state()
3219 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val); in qlcnic_clr_all_drv_state()
3221 qlcnic_api_unlock(adapter); in qlcnic_clr_all_drv_state()
3223 adapter->fw_fail_cnt = 0; in qlcnic_clr_all_drv_state()
3224 adapter->flags &= ~QLCNIC_FW_HANG; in qlcnic_clr_all_drv_state()
3225 clear_bit(__QLCNIC_START_FW, &adapter->state); in qlcnic_clr_all_drv_state()
3226 clear_bit(__QLCNIC_RESETTING, &adapter->state); in qlcnic_clr_all_drv_state()
3231 qlcnic_check_drv_state(struct qlcnic_adapter *adapter) in qlcnic_check_drv_state() argument
3234 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_check_drv_state()
3236 state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE); in qlcnic_check_drv_state()
3237 act = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_ACTIVE); in qlcnic_check_drv_state()
3239 if (adapter->flags & QLCNIC_FW_RESET_OWNER) { in qlcnic_check_drv_state()
3251 static int qlcnic_check_idc_ver(struct qlcnic_adapter *adapter) in qlcnic_check_idc_ver() argument
3253 u32 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_IDC_VER); in qlcnic_check_idc_ver()
3256 dev_warn(&adapter->pdev->dev, "IDC Version mismatch, driver's" in qlcnic_check_idc_ver()
3264 qlcnic_can_start_firmware(struct qlcnic_adapter *adapter) in qlcnic_can_start_firmware() argument
3267 u8 dev_init_timeo = adapter->dev_init_timeo; in qlcnic_can_start_firmware()
3268 u8 portnum = adapter->portnum; in qlcnic_can_start_firmware()
3271 if (test_and_clear_bit(__QLCNIC_START_FW, &adapter->state)) in qlcnic_can_start_firmware()
3274 if (qlcnic_api_lock(adapter)) in qlcnic_can_start_firmware()
3277 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_ACTIVE); in qlcnic_can_start_firmware()
3280 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_ACTIVE, val); in qlcnic_can_start_firmware()
3283 prev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE); in qlcnic_can_start_firmware()
3284 QLCDB(adapter, HW, "Device state = %u\n", prev_state); in qlcnic_can_start_firmware()
3288 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, in qlcnic_can_start_firmware()
3290 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_IDC_VER, in qlcnic_can_start_firmware()
3292 qlcnic_idc_debug_info(adapter, 0); in qlcnic_can_start_firmware()
3293 qlcnic_api_unlock(adapter); in qlcnic_can_start_firmware()
3297 ret = qlcnic_check_idc_ver(adapter); in qlcnic_can_start_firmware()
3298 qlcnic_api_unlock(adapter); in qlcnic_can_start_firmware()
3302 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE); in qlcnic_can_start_firmware()
3304 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val); in qlcnic_can_start_firmware()
3308 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE); in qlcnic_can_start_firmware()
3310 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val); in qlcnic_can_start_firmware()
3314 dev_err(&adapter->pdev->dev, "Device in failed state.\n"); in qlcnic_can_start_firmware()
3315 qlcnic_api_unlock(adapter); in qlcnic_can_start_firmware()
3323 qlcnic_api_unlock(adapter); in qlcnic_can_start_firmware()
3327 prev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE); in qlcnic_can_start_firmware()
3331 dev_err(&adapter->pdev->dev, in qlcnic_can_start_firmware()
3336 if (qlcnic_api_lock(adapter)) in qlcnic_can_start_firmware()
3339 val = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DRV_STATE); in qlcnic_can_start_firmware()
3341 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DRV_STATE, val); in qlcnic_can_start_firmware()
3343 ret = qlcnic_check_idc_ver(adapter); in qlcnic_can_start_firmware()
3344 qlcnic_api_unlock(adapter); in qlcnic_can_start_firmware()
3352 struct qlcnic_adapter *adapter = container_of(work, in qlcnic_fwinit_work() local
3357 if (qlcnic_api_lock(adapter)) in qlcnic_fwinit_work()
3360 dev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE); in qlcnic_fwinit_work()
3363 qlcnic_api_unlock(adapter); in qlcnic_fwinit_work()
3364 qlcnic_schedule_work(adapter, qlcnic_fwinit_work, in qlcnic_fwinit_work()
3369 if (adapter->ahw->op_mode == QLCNIC_NON_PRIV_FUNC) { in qlcnic_fwinit_work()
3370 qlcnic_api_unlock(adapter); in qlcnic_fwinit_work()
3376 dev_info(&adapter->pdev->dev, "Detected state change from " in qlcnic_fwinit_work()
3381 if (adapter->fw_wait_cnt++ > adapter->reset_ack_timeo) { in qlcnic_fwinit_work()
3382 dev_info(&adapter->pdev->dev, "Reset:Failed to get ack %d sec\n", in qlcnic_fwinit_work()
3383 adapter->reset_ack_timeo); in qlcnic_fwinit_work()
3387 if (!qlcnic_check_drv_state(adapter)) { in qlcnic_fwinit_work()
3389 dev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE); in qlcnic_fwinit_work()
3392 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, in qlcnic_fwinit_work()
3394 set_bit(__QLCNIC_START_FW, &adapter->state); in qlcnic_fwinit_work()
3395 QLCDB(adapter, DRV, "Restarting fw\n"); in qlcnic_fwinit_work()
3396 qlcnic_idc_debug_info(adapter, 0); in qlcnic_fwinit_work()
3397 val = QLC_SHARED_REG_RD32(adapter, in qlcnic_fwinit_work()
3399 QLC_DEV_SET_RST_RDY(val, adapter->portnum); in qlcnic_fwinit_work()
3400 QLC_SHARED_REG_WR32(adapter, in qlcnic_fwinit_work()
3404 qlcnic_api_unlock(adapter); in qlcnic_fwinit_work()
3407 if (qlcnic_check_fw_dump_state(adapter) && in qlcnic_fwinit_work()
3408 (adapter->flags & QLCNIC_FW_RESET_OWNER)) { in qlcnic_fwinit_work()
3409 QLCDB(adapter, DRV, "Take FW dump\n"); in qlcnic_fwinit_work()
3410 qlcnic_dump_fw(adapter); in qlcnic_fwinit_work()
3411 adapter->flags |= QLCNIC_FW_HANG; in qlcnic_fwinit_work()
3415 adapter->flags &= ~QLCNIC_FW_RESET_OWNER; in qlcnic_fwinit_work()
3416 if (!adapter->nic_ops->start_firmware(adapter)) { in qlcnic_fwinit_work()
3417 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); in qlcnic_fwinit_work()
3418 adapter->fw_wait_cnt = 0; in qlcnic_fwinit_work()
3424 qlcnic_api_unlock(adapter); in qlcnic_fwinit_work()
3427 dev_state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE); in qlcnic_fwinit_work()
3428 QLCDB(adapter, HW, "Func waiting: Device state=%u\n", dev_state); in qlcnic_fwinit_work()
3432 if (!qlcnic_start_firmware(adapter)) { in qlcnic_fwinit_work()
3433 qlcnic_schedule_work(adapter, qlcnic_attach_work, 0); in qlcnic_fwinit_work()
3434 adapter->fw_wait_cnt = 0; in qlcnic_fwinit_work()
3441 qlcnic_schedule_work(adapter, in qlcnic_fwinit_work()
3447 dev_err(&adapter->pdev->dev, "Fwinit work failed state=%u " in qlcnic_fwinit_work()
3448 "fw_wait_cnt=%u\n", dev_state, adapter->fw_wait_cnt); in qlcnic_fwinit_work()
3449 netif_device_attach(adapter->netdev); in qlcnic_fwinit_work()
3450 qlcnic_clr_all_drv_state(adapter, 0); in qlcnic_fwinit_work()
3456 struct qlcnic_adapter *adapter = container_of(work, in qlcnic_detach_work() local
3458 struct net_device *netdev = adapter->netdev; in qlcnic_detach_work()
3464 if (adapter->dev_state == QLCNIC_DEV_NEED_QUISCENT) { in qlcnic_detach_work()
3466 __qlcnic_down(adapter, netdev); in qlcnic_detach_work()
3468 qlcnic_down(adapter, netdev); in qlcnic_detach_work()
3470 status = QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_HALT_STATUS1); in qlcnic_detach_work()
3473 dev_err(&adapter->pdev->dev, in qlcnic_detach_work()
3478 dev_err(&adapter->pdev->dev, in qlcnic_detach_work()
3481 dev_err(&adapter->pdev->dev, in qlcnic_detach_work()
3482 "Replace the adapter.\n"); in qlcnic_detach_work()
3488 if (adapter->ahw->temp == QLCNIC_TEMP_PANIC) { in qlcnic_detach_work()
3489 dev_err(&adapter->pdev->dev, "Detaching the device: temp=%d\n", in qlcnic_detach_work()
3490 adapter->ahw->temp); in qlcnic_detach_work()
3495 if (!(adapter->flags & QLCNIC_FW_RESET_OWNER)) { in qlcnic_detach_work()
3496 if (qlcnic_set_drv_state(adapter, adapter->dev_state)) { in qlcnic_detach_work()
3497 dev_err(&adapter->pdev->dev, in qlcnic_detach_work()
3504 adapter->fw_wait_cnt = 0; in qlcnic_detach_work()
3506 qlcnic_schedule_work(adapter, qlcnic_fwinit_work, FW_POLL_DELAY); in qlcnic_detach_work()
3512 qlcnic_clr_all_drv_state(adapter, 1); in qlcnic_detach_work()
3517 qlcnic_set_npar_non_operational(struct qlcnic_adapter *adapter) in qlcnic_set_npar_non_operational() argument
3521 state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_NPAR_STATE); in qlcnic_set_npar_non_operational()
3525 if (qlcnic_api_lock(adapter)) in qlcnic_set_npar_non_operational()
3527 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, in qlcnic_set_npar_non_operational()
3529 qlcnic_api_unlock(adapter); in qlcnic_set_npar_non_operational()
3532 static void qlcnic_82xx_dev_request_reset(struct qlcnic_adapter *adapter, in qlcnic_82xx_dev_request_reset() argument
3539 QLCWR32(adapter, QLCNIC_NIU_XG_PAUSE_CTL, xg_val); in qlcnic_82xx_dev_request_reset()
3544 QLCWR32(adapter, QLCNIC_NIU_GB_PAUSE_CTL, gb_val); in qlcnic_82xx_dev_request_reset()
3545 dev_info(&adapter->pdev->dev, "Pause control frames disabled" in qlcnic_82xx_dev_request_reset()
3547 adapter->need_fw_reset = 1; in qlcnic_82xx_dev_request_reset()
3549 if (qlcnic_api_lock(adapter)) in qlcnic_82xx_dev_request_reset()
3552 state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE); in qlcnic_82xx_dev_request_reset()
3554 if (test_bit(__QLCNIC_MAINTENANCE_MODE, &adapter->state)) { in qlcnic_82xx_dev_request_reset()
3555 netdev_err(adapter->netdev, "%s: Device is in non-operational state\n", in qlcnic_82xx_dev_request_reset()
3557 qlcnic_api_unlock(adapter); in qlcnic_82xx_dev_request_reset()
3563 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, in qlcnic_82xx_dev_request_reset()
3565 adapter->flags |= QLCNIC_FW_RESET_OWNER; in qlcnic_82xx_dev_request_reset()
3566 QLCDB(adapter, DRV, "NEED_RESET state set\n"); in qlcnic_82xx_dev_request_reset()
3567 qlcnic_idc_debug_info(adapter, 0); in qlcnic_82xx_dev_request_reset()
3570 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, in qlcnic_82xx_dev_request_reset()
3572 qlcnic_api_unlock(adapter); in qlcnic_82xx_dev_request_reset()
3577 qlcnic_dev_set_npar_ready(struct qlcnic_adapter *adapter) in qlcnic_dev_set_npar_ready() argument
3579 if (qlcnic_api_lock(adapter)) in qlcnic_dev_set_npar_ready()
3582 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_NPAR_STATE, in qlcnic_dev_set_npar_ready()
3584 QLCDB(adapter, DRV, "NPAR operational state set\n"); in qlcnic_dev_set_npar_ready()
3586 qlcnic_api_unlock(adapter); in qlcnic_dev_set_npar_ready()
3589 void qlcnic_schedule_work(struct qlcnic_adapter *adapter, in qlcnic_schedule_work() argument
3592 if (test_bit(__QLCNIC_AER, &adapter->state)) in qlcnic_schedule_work()
3595 INIT_DELAYED_WORK(&adapter->fw_work, func); in qlcnic_schedule_work()
3596 queue_delayed_work(adapter->qlcnic_wq, &adapter->fw_work, in qlcnic_schedule_work()
3603 struct qlcnic_adapter *adapter = container_of(work, in qlcnic_attach_work() local
3605 struct net_device *netdev = adapter->netdev; in qlcnic_attach_work()
3608 if (adapter->ahw->op_mode != QLCNIC_MGMT_FUNC) { in qlcnic_attach_work()
3609 npar_state = QLC_SHARED_REG_RD32(adapter, in qlcnic_attach_work()
3611 if (adapter->fw_wait_cnt++ > QLCNIC_DEV_NPAR_OPER_TIMEO) in qlcnic_attach_work()
3612 qlcnic_clr_all_drv_state(adapter, 0); in qlcnic_attach_work()
3614 qlcnic_schedule_work(adapter, qlcnic_attach_work, in qlcnic_attach_work()
3618 QLCDB(adapter, DRV, "Waiting for NPAR state to operational\n"); in qlcnic_attach_work()
3622 qlcnic_dcb_get_info(adapter->dcb); in qlcnic_attach_work()
3625 if (qlcnic_up(adapter, netdev)) in qlcnic_attach_work()
3633 adapter->fw_fail_cnt = 0; in qlcnic_attach_work()
3634 adapter->flags &= ~QLCNIC_FW_HANG; in qlcnic_attach_work()
3635 clear_bit(__QLCNIC_RESETTING, &adapter->state); in qlcnic_attach_work()
3636 if (adapter->portnum == 0) in qlcnic_attach_work()
3637 qlcnic_set_drv_version(adapter); in qlcnic_attach_work()
3639 if (!qlcnic_clr_drv_state(adapter)) in qlcnic_attach_work()
3640 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, in qlcnic_attach_work()
3645 qlcnic_check_health(struct qlcnic_adapter *adapter) in qlcnic_check_health() argument
3647 struct qlcnic_hardware_context *ahw = adapter->ahw; in qlcnic_check_health()
3653 if (qlcnic_check_temp(adapter)) in qlcnic_check_health()
3656 if (adapter->need_fw_reset) in qlcnic_check_health()
3657 qlcnic_dev_request_reset(adapter, 0); in qlcnic_check_health()
3659 state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE); in qlcnic_check_health()
3661 qlcnic_set_npar_non_operational(adapter); in qlcnic_check_health()
3662 adapter->need_fw_reset = 1; in qlcnic_check_health()
3666 heartbeat = QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_ALIVE_COUNTER); in qlcnic_check_health()
3667 if (heartbeat != adapter->heartbeat) { in qlcnic_check_health()
3668 adapter->heartbeat = heartbeat; in qlcnic_check_health()
3669 adapter->fw_fail_cnt = 0; in qlcnic_check_health()
3670 if (adapter->need_fw_reset) in qlcnic_check_health()
3674 qlcnic_reset_hw_context(adapter); in qlcnic_check_health()
3679 if (++adapter->fw_fail_cnt < FW_FAIL_THRESH) in qlcnic_check_health()
3682 adapter->flags |= QLCNIC_FW_HANG; in qlcnic_check_health()
3684 qlcnic_dev_request_reset(adapter, 0); in qlcnic_check_health()
3687 clear_bit(__QLCNIC_FW_ATTACHED, &adapter->state); in qlcnic_check_health()
3689 dev_err(&adapter->pdev->dev, "firmware hang detected\n"); in qlcnic_check_health()
3690 peg_status = QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_HALT_STATUS1); in qlcnic_check_health()
3691 dev_err(&adapter->pdev->dev, "Dumping hw/fw registers\n" in qlcnic_check_health()
3697 QLC_SHARED_REG_RD32(adapter, QLCNIC_PEG_HALT_STATUS2), in qlcnic_check_health()
3698 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_0 + 0x3c, &err), in qlcnic_check_health()
3699 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_1 + 0x3c, &err), in qlcnic_check_health()
3700 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_2 + 0x3c, &err), in qlcnic_check_health()
3701 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_3 + 0x3c, &err), in qlcnic_check_health()
3702 QLCRD32(adapter, QLCNIC_CRB_PEG_NET_4 + 0x3c, &err)); in qlcnic_check_health()
3704 dev_err(&adapter->pdev->dev, in qlcnic_check_health()
3708 adapter->dev_state = (state == QLCNIC_DEV_NEED_QUISCENT) ? state : in qlcnic_check_health()
3712 &adapter->state)) { in qlcnic_check_health()
3714 qlcnic_schedule_work(adapter, qlcnic_detach_work, 0); in qlcnic_check_health()
3715 QLCDB(adapter, DRV, "fw recovery scheduled.\n"); in qlcnic_check_health()
3717 adapter->flags & QLCNIC_FW_RESET_OWNER) { in qlcnic_check_health()
3718 qlcnic_dump_fw(adapter); in qlcnic_check_health()
3726 struct qlcnic_adapter *adapter = container_of(work, in qlcnic_fw_poll_work() local
3729 if (test_bit(__QLCNIC_RESETTING, &adapter->state)) in qlcnic_fw_poll_work()
3733 if (qlcnic_check_health(adapter)) in qlcnic_fw_poll_work()
3736 if (adapter->fhash.fnum) in qlcnic_fw_poll_work()
3737 qlcnic_prune_lb_filters(adapter); in qlcnic_fw_poll_work()
3740 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, FW_POLL_DELAY); in qlcnic_fw_poll_work()
3767 struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); in qlcnic_attach_func() local
3768 struct net_device *netdev = adapter->netdev; in qlcnic_attach_func()
3781 if (qlcnic_api_lock(adapter)) in qlcnic_attach_func()
3784 if (adapter->ahw->op_mode != QLCNIC_NON_PRIV_FUNC && first_func) { in qlcnic_attach_func()
3785 adapter->need_fw_reset = 1; in qlcnic_attach_func()
3786 set_bit(__QLCNIC_START_FW, &adapter->state); in qlcnic_attach_func()
3787 QLC_SHARED_REG_WR32(adapter, QLCNIC_CRB_DEV_STATE, in qlcnic_attach_func()
3789 QLCDB(adapter, DRV, "Restarting fw\n"); in qlcnic_attach_func()
3791 qlcnic_api_unlock(adapter); in qlcnic_attach_func()
3793 err = qlcnic_start_firmware(adapter); in qlcnic_attach_func()
3797 qlcnic_clr_drv_state(adapter); in qlcnic_attach_func()
3798 kfree(adapter->msix_entries); in qlcnic_attach_func()
3799 adapter->msix_entries = NULL; in qlcnic_attach_func()
3800 err = qlcnic_setup_intr(adapter); in qlcnic_attach_func()
3803 kfree(adapter->msix_entries); in qlcnic_attach_func()
3809 err = qlcnic_attach(adapter); in qlcnic_attach_func()
3811 qlcnic_clr_all_drv_state(adapter, 1); in qlcnic_attach_func()
3812 clear_bit(__QLCNIC_AER, &adapter->state); in qlcnic_attach_func()
3817 err = qlcnic_up(adapter, netdev); in qlcnic_attach_func()
3831 struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); in qlcnic_82xx_io_error_detected() local
3832 struct net_device *netdev = adapter->netdev; in qlcnic_82xx_io_error_detected()
3840 set_bit(__QLCNIC_AER, &adapter->state); in qlcnic_82xx_io_error_detected()
3843 cancel_delayed_work_sync(&adapter->fw_work); in qlcnic_82xx_io_error_detected()
3846 qlcnic_down(adapter, netdev); in qlcnic_82xx_io_error_detected()
3848 qlcnic_detach(adapter); in qlcnic_82xx_io_error_detected()
3849 qlcnic_teardown_intr(adapter); in qlcnic_82xx_io_error_detected()
3851 clear_bit(__QLCNIC_RESETTING, &adapter->state); in qlcnic_82xx_io_error_detected()
3874 struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); in qlcnic_82xx_io_resume() local
3876 state = QLC_SHARED_REG_RD32(adapter, QLCNIC_CRB_DEV_STATE); in qlcnic_82xx_io_resume()
3878 &adapter->state)) in qlcnic_82xx_io_resume()
3879 qlcnic_schedule_work(adapter, qlcnic_fw_poll_work, in qlcnic_82xx_io_resume()
3886 struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); in qlcnic_io_error_detected() local
3887 struct qlcnic_hardware_ops *hw_ops = adapter->ahw->hw_ops; in qlcnic_io_error_detected()
3899 struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); in qlcnic_io_slot_reset() local
3900 struct qlcnic_hardware_ops *hw_ops = adapter->ahw->hw_ops; in qlcnic_io_slot_reset()
3912 struct qlcnic_adapter *adapter = pci_get_drvdata(pdev); in qlcnic_io_resume() local
3913 struct qlcnic_hardware_ops *hw_ops = adapter->ahw->hw_ops; in qlcnic_io_resume()
3923 qlcnicvf_start_firmware(struct qlcnic_adapter *adapter) in qlcnicvf_start_firmware() argument
3927 err = qlcnic_can_start_firmware(adapter); in qlcnicvf_start_firmware()
3931 err = qlcnic_check_npar_opertional(adapter); in qlcnicvf_start_firmware()
3935 err = qlcnic_initialize_nic(adapter); in qlcnicvf_start_firmware()
3939 qlcnic_check_options(adapter); in qlcnicvf_start_firmware()
3941 err = qlcnic_set_eswitch_port_config(adapter); in qlcnicvf_start_firmware()
3945 adapter->need_fw_reset = 0; in qlcnicvf_start_firmware()
3950 int qlcnic_validate_rings(struct qlcnic_adapter *adapter, __u32 ring_cnt, in qlcnic_validate_rings() argument
3953 struct net_device *netdev = adapter->netdev; in qlcnic_validate_rings()
3967 if (qlcnic_82xx_check(adapter) && (queue_type == QLCNIC_TX_QUEUE) && in qlcnic_validate_rings()
3968 !qlcnic_check_multi_tx(adapter)) { in qlcnic_validate_rings()
3983 int qlcnic_setup_rings(struct qlcnic_adapter *adapter) in qlcnic_setup_rings() argument
3985 struct net_device *netdev = adapter->netdev; in qlcnic_setup_rings()
3989 if (test_bit(__QLCNIC_RESETTING, &adapter->state)) in qlcnic_setup_rings()
3992 tx_rings = adapter->drv_tss_rings; in qlcnic_setup_rings()
3993 rx_rings = adapter->drv_rss_rings; in qlcnic_setup_rings()
3997 err = qlcnic_set_real_num_queues(adapter, tx_rings, rx_rings); in qlcnic_setup_rings()
4002 __qlcnic_down(adapter, netdev); in qlcnic_setup_rings()
4004 qlcnic_detach(adapter); in qlcnic_setup_rings()
4006 if (qlcnic_83xx_check(adapter)) { in qlcnic_setup_rings()
4007 qlcnic_83xx_free_mbx_intr(adapter); in qlcnic_setup_rings()
4008 qlcnic_83xx_enable_mbx_poll(adapter); in qlcnic_setup_rings()
4011 qlcnic_teardown_intr(adapter); in qlcnic_setup_rings()
4013 err = qlcnic_setup_intr(adapter); in qlcnic_setup_rings()
4015 kfree(adapter->msix_entries); in qlcnic_setup_rings()
4023 if ((tx_rings != adapter->drv_tx_rings) || in qlcnic_setup_rings()
4024 (rx_rings != adapter->drv_sds_rings)) { in qlcnic_setup_rings()
4025 err = qlcnic_set_real_num_queues(adapter, in qlcnic_setup_rings()
4026 adapter->drv_tx_rings, in qlcnic_setup_rings()
4027 adapter->drv_sds_rings); in qlcnic_setup_rings()
4032 if (qlcnic_83xx_check(adapter)) { in qlcnic_setup_rings()
4033 qlcnic_83xx_initialize_nic(adapter, 1); in qlcnic_setup_rings()
4034 err = qlcnic_83xx_setup_mbx_intr(adapter); in qlcnic_setup_rings()
4035 qlcnic_83xx_disable_mbx_poll(adapter); in qlcnic_setup_rings()
4037 dev_err(&adapter->pdev->dev, in qlcnic_setup_rings()
4044 err = qlcnic_attach(adapter); in qlcnic_setup_rings()
4047 err = __qlcnic_up(adapter, netdev); in qlcnic_setup_rings()
4054 clear_bit(__QLCNIC_RESETTING, &adapter->state); in qlcnic_setup_rings()
4063 qlcnic_config_indev_addr(struct qlcnic_adapter *adapter, in qlcnic_config_indev_addr() argument
4076 qlcnic_config_ipaddr(adapter, in qlcnic_config_indev_addr()
4080 qlcnic_config_ipaddr(adapter, in qlcnic_config_indev_addr()
4093 struct qlcnic_adapter *adapter = netdev_priv(netdev); in qlcnic_restore_indev_addr() local
4097 qlcnic_config_indev_addr(adapter, netdev, event); in qlcnic_restore_indev_addr()
4100 for_each_set_bit(vid, adapter->vlans, VLAN_N_VID) { in qlcnic_restore_indev_addr()
4104 qlcnic_config_indev_addr(adapter, dev, event); in qlcnic_restore_indev_addr()
4112 struct qlcnic_adapter *adapter; in qlcnic_netdev_event() local
4127 adapter = netdev_priv(dev); in qlcnic_netdev_event()
4129 if (!adapter) in qlcnic_netdev_event()
4132 if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) in qlcnic_netdev_event()
4135 qlcnic_config_indev_addr(adapter, dev, event); in qlcnic_netdev_event()
4144 struct qlcnic_adapter *adapter; in qlcnic_inetaddr_event() local
4163 adapter = netdev_priv(dev); in qlcnic_inetaddr_event()
4165 if (!adapter) in qlcnic_inetaddr_event()
4168 if (!test_bit(__QLCNIC_DEV_UP, &adapter->state)) in qlcnic_inetaddr_event()
4173 qlcnic_config_ipaddr(adapter, ifa->ifa_address, QLCNIC_IP_UP); in qlcnic_inetaddr_event()
4177 qlcnic_config_ipaddr(adapter, ifa->ifa_address, QLCNIC_IP_DOWN); in qlcnic_inetaddr_event()