diff options
Diffstat (limited to 'drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c')
-rw-r--r-- | drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c index c5cfbaa832a8..58f094ca052e 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_ctx.c | |||
@@ -7,6 +7,18 @@ | |||
7 | 7 | ||
8 | #include "qlcnic.h" | 8 | #include "qlcnic.h" |
9 | 9 | ||
10 | static int qlcnic_is_valid_nic_func(struct qlcnic_adapter *adapter, u8 pci_func) | ||
11 | { | ||
12 | int i; | ||
13 | |||
14 | for (i = 0; i < adapter->ahw->act_pci_func; i++) { | ||
15 | if (adapter->npars[i].pci_func == pci_func) | ||
16 | return i; | ||
17 | } | ||
18 | |||
19 | return -1; | ||
20 | } | ||
21 | |||
10 | static u32 | 22 | static u32 |
11 | qlcnic_poll_rsp(struct qlcnic_adapter *adapter) | 23 | qlcnic_poll_rsp(struct qlcnic_adapter *adapter) |
12 | { | 24 | { |
@@ -817,11 +829,14 @@ int qlcnic_get_pci_info(struct qlcnic_adapter *adapter, | |||
817 | qlcnic_issue_cmd(adapter, &cmd); | 829 | qlcnic_issue_cmd(adapter, &cmd); |
818 | err = cmd.rsp.cmd; | 830 | err = cmd.rsp.cmd; |
819 | 831 | ||
832 | adapter->ahw->act_pci_func = 0; | ||
820 | if (err == QLCNIC_RCODE_SUCCESS) { | 833 | if (err == QLCNIC_RCODE_SUCCESS) { |
821 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++, npar++, pci_info++) { | 834 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++, npar++, pci_info++) { |
822 | pci_info->id = le16_to_cpu(npar->id); | 835 | pci_info->id = le16_to_cpu(npar->id); |
823 | pci_info->active = le16_to_cpu(npar->active); | 836 | pci_info->active = le16_to_cpu(npar->active); |
824 | pci_info->type = le16_to_cpu(npar->type); | 837 | pci_info->type = le16_to_cpu(npar->type); |
838 | if (pci_info->type == QLCNIC_TYPE_NIC) | ||
839 | adapter->ahw->act_pci_func++; | ||
825 | pci_info->default_port = | 840 | pci_info->default_port = |
826 | le16_to_cpu(npar->default_port); | 841 | le16_to_cpu(npar->default_port); |
827 | pci_info->tx_min_bw = | 842 | pci_info->tx_min_bw = |
@@ -1016,12 +1031,13 @@ int qlcnic_get_eswitch_stats(struct qlcnic_adapter *adapter, const u8 eswitch, | |||
1016 | esw_stats->numbytes = QLCNIC_STATS_NOT_AVAIL; | 1031 | esw_stats->numbytes = QLCNIC_STATS_NOT_AVAIL; |
1017 | esw_stats->context_id = eswitch; | 1032 | esw_stats->context_id = eswitch; |
1018 | 1033 | ||
1019 | for (i = 0; i < QLCNIC_MAX_PCI_FUNC; i++) { | 1034 | for (i = 0; i < adapter->ahw->act_pci_func; i++) { |
1020 | if (adapter->npars[i].phy_port != eswitch) | 1035 | if (adapter->npars[i].phy_port != eswitch) |
1021 | continue; | 1036 | continue; |
1022 | 1037 | ||
1023 | memset(&port_stats, 0, sizeof(struct __qlcnic_esw_statistics)); | 1038 | memset(&port_stats, 0, sizeof(struct __qlcnic_esw_statistics)); |
1024 | if (qlcnic_get_port_stats(adapter, i, rx_tx, &port_stats)) | 1039 | if (qlcnic_get_port_stats(adapter, adapter->npars[i].pci_func, |
1040 | rx_tx, &port_stats)) | ||
1025 | continue; | 1041 | continue; |
1026 | 1042 | ||
1027 | esw_stats->size = port_stats.size; | 1043 | esw_stats->size = port_stats.size; |
@@ -1120,7 +1136,7 @@ op_type = 1 for port vlan_id | |||
1120 | int qlcnic_config_switch_port(struct qlcnic_adapter *adapter, | 1136 | int qlcnic_config_switch_port(struct qlcnic_adapter *adapter, |
1121 | struct qlcnic_esw_func_cfg *esw_cfg) | 1137 | struct qlcnic_esw_func_cfg *esw_cfg) |
1122 | { | 1138 | { |
1123 | int err = -EIO; | 1139 | int err = -EIO, index; |
1124 | u32 arg1, arg2 = 0; | 1140 | u32 arg1, arg2 = 0; |
1125 | struct qlcnic_cmd_args cmd; | 1141 | struct qlcnic_cmd_args cmd; |
1126 | u8 pci_func; | 1142 | u8 pci_func; |
@@ -1128,7 +1144,10 @@ int qlcnic_config_switch_port(struct qlcnic_adapter *adapter, | |||
1128 | if (adapter->ahw->op_mode != QLCNIC_MGMT_FUNC) | 1144 | if (adapter->ahw->op_mode != QLCNIC_MGMT_FUNC) |
1129 | return err; | 1145 | return err; |
1130 | pci_func = esw_cfg->pci_func; | 1146 | pci_func = esw_cfg->pci_func; |
1131 | arg1 = (adapter->npars[pci_func].phy_port & BIT_0); | 1147 | index = qlcnic_is_valid_nic_func(adapter, pci_func); |
1148 | if (index < 0) | ||
1149 | return err; | ||
1150 | arg1 = (adapter->npars[index].phy_port & BIT_0); | ||
1132 | arg1 |= (pci_func << 8); | 1151 | arg1 |= (pci_func << 8); |
1133 | 1152 | ||
1134 | if (__qlcnic_get_eswitch_port_config(adapter, &arg1, &arg2)) | 1153 | if (__qlcnic_get_eswitch_port_config(adapter, &arg1, &arg2)) |
@@ -1192,11 +1211,17 @@ qlcnic_get_eswitch_port_config(struct qlcnic_adapter *adapter, | |||
1192 | struct qlcnic_esw_func_cfg *esw_cfg) | 1211 | struct qlcnic_esw_func_cfg *esw_cfg) |
1193 | { | 1212 | { |
1194 | u32 arg1, arg2; | 1213 | u32 arg1, arg2; |
1214 | int index; | ||
1195 | u8 phy_port; | 1215 | u8 phy_port; |
1196 | if (adapter->ahw->op_mode == QLCNIC_MGMT_FUNC) | 1216 | |
1197 | phy_port = adapter->npars[esw_cfg->pci_func].phy_port; | 1217 | if (adapter->ahw->op_mode == QLCNIC_MGMT_FUNC) { |
1198 | else | 1218 | index = qlcnic_is_valid_nic_func(adapter, esw_cfg->pci_func); |
1219 | if (index < 0) | ||
1220 | return -EIO; | ||
1221 | phy_port = adapter->npars[index].phy_port; | ||
1222 | } else { | ||
1199 | phy_port = adapter->ahw->physical_port; | 1223 | phy_port = adapter->ahw->physical_port; |
1224 | } | ||
1200 | arg1 = phy_port; | 1225 | arg1 = phy_port; |
1201 | arg1 |= (esw_cfg->pci_func << 8); | 1226 | arg1 |= (esw_cfg->pci_func << 8); |
1202 | if (__qlcnic_get_eswitch_port_config(adapter, &arg1, &arg2)) | 1227 | if (__qlcnic_get_eswitch_port_config(adapter, &arg1, &arg2)) |