diff options
author | Sathya Perla <sathya.perla@emulex.com> | 2011-12-12 19:58:50 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2011-12-13 13:34:26 -0500 |
commit | 11ac75ed1eb9d8f5ff067fa9a82ebf5075989281 (patch) | |
tree | ead18a44d5fa3fba328c2be772cf1568b7adbcc5 /drivers/net/ethernet/emulex | |
parent | 110b82bc6265a48c1a0bf198109bed325ed055e2 (diff) |
be2net: refactor/cleanup vf configuration code
- use adapter->num_vfs (and not the module param) to store the actual
number of vfs created. Use the same variable to reflect SRIOV
enable/disable state. So, drop the adapter->sriov_enabled field.
- use for_all_vfs() macro in VF configuration code
- drop the "vf_" prefix for the fields of be_vf_cfg; the prefix is
redundant and removing it helps reduce line wrap
Signed-off-by: Sathya Perla <sathya.perla@emulex.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/emulex')
-rw-r--r-- | drivers/net/ethernet/emulex/benet/be.h | 20 | ||||
-rw-r--r-- | drivers/net/ethernet/emulex/benet/be_main.c | 137 |
2 files changed, 80 insertions, 77 deletions
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h index 34f162db9f2e..a3588fb8d6a9 100644 --- a/drivers/net/ethernet/emulex/benet/be.h +++ b/drivers/net/ethernet/emulex/benet/be.h | |||
@@ -288,11 +288,11 @@ struct be_drv_stats { | |||
288 | }; | 288 | }; |
289 | 289 | ||
290 | struct be_vf_cfg { | 290 | struct be_vf_cfg { |
291 | unsigned char vf_mac_addr[ETH_ALEN]; | 291 | unsigned char mac_addr[ETH_ALEN]; |
292 | int vf_if_handle; | 292 | int if_handle; |
293 | int vf_pmac_id; | 293 | int pmac_id; |
294 | u16 vf_vlan_tag; | 294 | u16 vlan_tag; |
295 | u32 vf_tx_rate; | 295 | u32 tx_rate; |
296 | }; | 296 | }; |
297 | 297 | ||
298 | struct be_adapter { | 298 | struct be_adapter { |
@@ -368,16 +368,20 @@ struct be_adapter { | |||
368 | u32 flash_status; | 368 | u32 flash_status; |
369 | struct completion flash_compl; | 369 | struct completion flash_compl; |
370 | 370 | ||
371 | bool be3_native; | 371 | u32 num_vfs; |
372 | bool sriov_enabled; | ||
373 | struct be_vf_cfg *vf_cfg; | ||
374 | u8 is_virtfn; | 372 | u8 is_virtfn; |
373 | struct be_vf_cfg *vf_cfg; | ||
374 | bool be3_native; | ||
375 | u32 sli_family; | 375 | u32 sli_family; |
376 | u8 hba_port_num; | 376 | u8 hba_port_num; |
377 | u16 pvid; | 377 | u16 pvid; |
378 | }; | 378 | }; |
379 | 379 | ||
380 | #define be_physfn(adapter) (!adapter->is_virtfn) | 380 | #define be_physfn(adapter) (!adapter->is_virtfn) |
381 | #define sriov_enabled(adapter) (adapter->num_vfs > 0) | ||
382 | #define for_all_vfs(adapter, vf_cfg, i) \ | ||
383 | for (i = 0, vf_cfg = &adapter->vf_cfg[i]; i < adapter->num_vfs; \ | ||
384 | i++, vf_cfg++) | ||
381 | 385 | ||
382 | /* BladeEngine Generation numbers */ | 386 | /* BladeEngine Generation numbers */ |
383 | #define BE_GEN2 2 | 387 | #define BE_GEN2 2 |
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c index 62f55145fa44..9b5304a653f3 100644 --- a/drivers/net/ethernet/emulex/benet/be_main.c +++ b/drivers/net/ethernet/emulex/benet/be_main.c | |||
@@ -27,13 +27,14 @@ MODULE_DESCRIPTION(DRV_DESC " " DRV_VER); | |||
27 | MODULE_AUTHOR("ServerEngines Corporation"); | 27 | MODULE_AUTHOR("ServerEngines Corporation"); |
28 | MODULE_LICENSE("GPL"); | 28 | MODULE_LICENSE("GPL"); |
29 | 29 | ||
30 | static ushort rx_frag_size = 2048; | ||
31 | static unsigned int num_vfs; | 30 | static unsigned int num_vfs; |
32 | module_param(rx_frag_size, ushort, S_IRUGO); | ||
33 | module_param(num_vfs, uint, S_IRUGO); | 31 | module_param(num_vfs, uint, S_IRUGO); |
34 | MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data."); | ||
35 | MODULE_PARM_DESC(num_vfs, "Number of PCI VFs to initialize"); | 32 | MODULE_PARM_DESC(num_vfs, "Number of PCI VFs to initialize"); |
36 | 33 | ||
34 | static ushort rx_frag_size = 2048; | ||
35 | module_param(rx_frag_size, ushort, S_IRUGO); | ||
36 | MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data."); | ||
37 | |||
37 | static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = { | 38 | static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = { |
38 | { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, | 39 | { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, |
39 | { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) }, | 40 | { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) }, |
@@ -779,15 +780,15 @@ static int be_change_mtu(struct net_device *netdev, int new_mtu) | |||
779 | */ | 780 | */ |
780 | static int be_vid_config(struct be_adapter *adapter, bool vf, u32 vf_num) | 781 | static int be_vid_config(struct be_adapter *adapter, bool vf, u32 vf_num) |
781 | { | 782 | { |
783 | struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf_num]; | ||
782 | u16 vtag[BE_NUM_VLANS_SUPPORTED]; | 784 | u16 vtag[BE_NUM_VLANS_SUPPORTED]; |
783 | u16 ntags = 0, i; | 785 | u16 ntags = 0, i; |
784 | int status = 0; | 786 | int status = 0; |
785 | u32 if_handle; | ||
786 | 787 | ||
787 | if (vf) { | 788 | if (vf) { |
788 | if_handle = adapter->vf_cfg[vf_num].vf_if_handle; | 789 | vtag[0] = cpu_to_le16(vf_cfg->vlan_tag); |
789 | vtag[0] = cpu_to_le16(adapter->vf_cfg[vf_num].vf_vlan_tag); | 790 | status = be_cmd_vlan_config(adapter, vf_cfg->if_handle, vtag, |
790 | status = be_cmd_vlan_config(adapter, if_handle, vtag, 1, 1, 0); | 791 | 1, 1, 0); |
791 | } | 792 | } |
792 | 793 | ||
793 | /* No need to further configure vids if in promiscuous mode */ | 794 | /* No need to further configure vids if in promiscuous mode */ |
@@ -877,31 +878,30 @@ done: | |||
877 | static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) | 878 | static int be_set_vf_mac(struct net_device *netdev, int vf, u8 *mac) |
878 | { | 879 | { |
879 | struct be_adapter *adapter = netdev_priv(netdev); | 880 | struct be_adapter *adapter = netdev_priv(netdev); |
881 | struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; | ||
880 | int status; | 882 | int status; |
881 | 883 | ||
882 | if (!adapter->sriov_enabled) | 884 | if (!sriov_enabled(adapter)) |
883 | return -EPERM; | 885 | return -EPERM; |
884 | 886 | ||
885 | if (!is_valid_ether_addr(mac) || (vf >= num_vfs)) | 887 | if (!is_valid_ether_addr(mac) || vf >= adapter->num_vfs) |
886 | return -EINVAL; | 888 | return -EINVAL; |
887 | 889 | ||
888 | if (lancer_chip(adapter)) { | 890 | if (lancer_chip(adapter)) { |
889 | status = be_cmd_set_mac_list(adapter, mac, 1, vf + 1); | 891 | status = be_cmd_set_mac_list(adapter, mac, 1, vf + 1); |
890 | } else { | 892 | } else { |
891 | status = be_cmd_pmac_del(adapter, | 893 | status = be_cmd_pmac_del(adapter, vf_cfg->if_handle, |
892 | adapter->vf_cfg[vf].vf_if_handle, | 894 | vf_cfg->pmac_id, vf + 1); |
893 | adapter->vf_cfg[vf].vf_pmac_id, vf + 1); | ||
894 | 895 | ||
895 | status = be_cmd_pmac_add(adapter, mac, | 896 | status = be_cmd_pmac_add(adapter, mac, vf_cfg->if_handle, |
896 | adapter->vf_cfg[vf].vf_if_handle, | 897 | &vf_cfg->pmac_id, vf + 1); |
897 | &adapter->vf_cfg[vf].vf_pmac_id, vf + 1); | ||
898 | } | 898 | } |
899 | 899 | ||
900 | if (status) | 900 | if (status) |
901 | dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", | 901 | dev_err(&adapter->pdev->dev, "MAC %pM set on VF %d Failed\n", |
902 | mac, vf); | 902 | mac, vf); |
903 | else | 903 | else |
904 | memcpy(adapter->vf_cfg[vf].vf_mac_addr, mac, ETH_ALEN); | 904 | memcpy(vf_cfg->mac_addr, mac, ETH_ALEN); |
905 | 905 | ||
906 | return status; | 906 | return status; |
907 | } | 907 | } |
@@ -910,18 +910,19 @@ static int be_get_vf_config(struct net_device *netdev, int vf, | |||
910 | struct ifla_vf_info *vi) | 910 | struct ifla_vf_info *vi) |
911 | { | 911 | { |
912 | struct be_adapter *adapter = netdev_priv(netdev); | 912 | struct be_adapter *adapter = netdev_priv(netdev); |
913 | struct be_vf_cfg *vf_cfg = &adapter->vf_cfg[vf]; | ||
913 | 914 | ||
914 | if (!adapter->sriov_enabled) | 915 | if (!sriov_enabled(adapter)) |
915 | return -EPERM; | 916 | return -EPERM; |
916 | 917 | ||
917 | if (vf >= num_vfs) | 918 | if (vf >= adapter->num_vfs) |
918 | return -EINVAL; | 919 | return -EINVAL; |
919 | 920 | ||
920 | vi->vf = vf; | 921 | vi->vf = vf; |
921 | vi->tx_rate = adapter->vf_cfg[vf].vf_tx_rate; | 922 | vi->tx_rate = vf_cfg->tx_rate; |
922 | vi->vlan = adapter->vf_cfg[vf].vf_vlan_tag; | 923 | vi->vlan = vf_cfg->vlan_tag; |
923 | vi->qos = 0; | 924 | vi->qos = 0; |
924 | memcpy(&vi->mac, adapter->vf_cfg[vf].vf_mac_addr, ETH_ALEN); | 925 | memcpy(&vi->mac, vf_cfg->mac_addr, ETH_ALEN); |
925 | 926 | ||
926 | return 0; | 927 | return 0; |
927 | } | 928 | } |
@@ -932,17 +933,17 @@ static int be_set_vf_vlan(struct net_device *netdev, | |||
932 | struct be_adapter *adapter = netdev_priv(netdev); | 933 | struct be_adapter *adapter = netdev_priv(netdev); |
933 | int status = 0; | 934 | int status = 0; |
934 | 935 | ||
935 | if (!adapter->sriov_enabled) | 936 | if (!sriov_enabled(adapter)) |
936 | return -EPERM; | 937 | return -EPERM; |
937 | 938 | ||
938 | if ((vf >= num_vfs) || (vlan > 4095)) | 939 | if (vf >= adapter->num_vfs || vlan > 4095) |
939 | return -EINVAL; | 940 | return -EINVAL; |
940 | 941 | ||
941 | if (vlan) { | 942 | if (vlan) { |
942 | adapter->vf_cfg[vf].vf_vlan_tag = vlan; | 943 | adapter->vf_cfg[vf].vlan_tag = vlan; |
943 | adapter->vlans_added++; | 944 | adapter->vlans_added++; |
944 | } else { | 945 | } else { |
945 | adapter->vf_cfg[vf].vf_vlan_tag = 0; | 946 | adapter->vf_cfg[vf].vlan_tag = 0; |
946 | adapter->vlans_added--; | 947 | adapter->vlans_added--; |
947 | } | 948 | } |
948 | 949 | ||
@@ -960,16 +961,16 @@ static int be_set_vf_tx_rate(struct net_device *netdev, | |||
960 | struct be_adapter *adapter = netdev_priv(netdev); | 961 | struct be_adapter *adapter = netdev_priv(netdev); |
961 | int status = 0; | 962 | int status = 0; |
962 | 963 | ||
963 | if (!adapter->sriov_enabled) | 964 | if (!sriov_enabled(adapter)) |
964 | return -EPERM; | 965 | return -EPERM; |
965 | 966 | ||
966 | if ((vf >= num_vfs) || (rate < 0)) | 967 | if (vf >= adapter->num_vfs || rate < 0) |
967 | return -EINVAL; | 968 | return -EINVAL; |
968 | 969 | ||
969 | if (rate > 10000) | 970 | if (rate > 10000) |
970 | rate = 10000; | 971 | rate = 10000; |
971 | 972 | ||
972 | adapter->vf_cfg[vf].vf_tx_rate = rate; | 973 | adapter->vf_cfg[vf].tx_rate = rate; |
973 | status = be_cmd_set_qos(adapter, rate / 10, vf + 1); | 974 | status = be_cmd_set_qos(adapter, rate / 10, vf + 1); |
974 | 975 | ||
975 | if (status) | 976 | if (status) |
@@ -1685,8 +1686,7 @@ static void be_tx_queues_destroy(struct be_adapter *adapter) | |||
1685 | 1686 | ||
1686 | static int be_num_txqs_want(struct be_adapter *adapter) | 1687 | static int be_num_txqs_want(struct be_adapter *adapter) |
1687 | { | 1688 | { |
1688 | if ((num_vfs && adapter->sriov_enabled) || | 1689 | if (sriov_enabled(adapter) || be_is_mc(adapter) || |
1689 | be_is_mc(adapter) || | ||
1690 | lancer_chip(adapter) || !be_physfn(adapter) || | 1690 | lancer_chip(adapter) || !be_physfn(adapter) || |
1691 | adapter->generation == BE_GEN2) | 1691 | adapter->generation == BE_GEN2) |
1692 | return 1; | 1692 | return 1; |
@@ -1768,8 +1768,8 @@ static void be_rx_queues_destroy(struct be_adapter *adapter) | |||
1768 | static u32 be_num_rxqs_want(struct be_adapter *adapter) | 1768 | static u32 be_num_rxqs_want(struct be_adapter *adapter) |
1769 | { | 1769 | { |
1770 | if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && | 1770 | if ((adapter->function_caps & BE_FUNCTION_CAPS_RSS) && |
1771 | !adapter->sriov_enabled && be_physfn(adapter) && | 1771 | !sriov_enabled(adapter) && be_physfn(adapter) && |
1772 | !be_is_mc(adapter)) { | 1772 | !be_is_mc(adapter)) { |
1773 | return 1 + MAX_RSS_QS; /* one default non-RSS queue */ | 1773 | return 1 + MAX_RSS_QS; /* one default non-RSS queue */ |
1774 | } else { | 1774 | } else { |
1775 | dev_warn(&adapter->pdev->dev, | 1775 | dev_warn(&adapter->pdev->dev, |
@@ -2116,27 +2116,28 @@ done: | |||
2116 | static int be_sriov_enable(struct be_adapter *adapter) | 2116 | static int be_sriov_enable(struct be_adapter *adapter) |
2117 | { | 2117 | { |
2118 | be_check_sriov_fn_type(adapter); | 2118 | be_check_sriov_fn_type(adapter); |
2119 | |||
2119 | #ifdef CONFIG_PCI_IOV | 2120 | #ifdef CONFIG_PCI_IOV |
2120 | if (be_physfn(adapter) && num_vfs) { | 2121 | if (be_physfn(adapter) && num_vfs) { |
2121 | int status, pos; | 2122 | int status, pos; |
2122 | u16 nvfs; | 2123 | u16 dev_vfs; |
2123 | 2124 | ||
2124 | pos = pci_find_ext_capability(adapter->pdev, | 2125 | pos = pci_find_ext_capability(adapter->pdev, |
2125 | PCI_EXT_CAP_ID_SRIOV); | 2126 | PCI_EXT_CAP_ID_SRIOV); |
2126 | pci_read_config_word(adapter->pdev, | 2127 | pci_read_config_word(adapter->pdev, |
2127 | pos + PCI_SRIOV_TOTAL_VF, &nvfs); | 2128 | pos + PCI_SRIOV_TOTAL_VF, &dev_vfs); |
2128 | 2129 | ||
2129 | if (num_vfs > nvfs) { | 2130 | adapter->num_vfs = min_t(u16, num_vfs, dev_vfs); |
2131 | if (adapter->num_vfs != num_vfs) | ||
2130 | dev_info(&adapter->pdev->dev, | 2132 | dev_info(&adapter->pdev->dev, |
2131 | "Device supports %d VFs and not %d\n", | 2133 | "Device supports %d VFs and not %d\n", |
2132 | nvfs, num_vfs); | 2134 | adapter->num_vfs, num_vfs); |
2133 | num_vfs = nvfs; | ||
2134 | } | ||
2135 | 2135 | ||
2136 | status = pci_enable_sriov(adapter->pdev, num_vfs); | 2136 | status = pci_enable_sriov(adapter->pdev, adapter->num_vfs); |
2137 | adapter->sriov_enabled = status ? false : true; | 2137 | if (status) |
2138 | adapter->num_vfs = 0; | ||
2138 | 2139 | ||
2139 | if (adapter->sriov_enabled) { | 2140 | if (adapter->num_vfs) { |
2140 | adapter->vf_cfg = kcalloc(num_vfs, | 2141 | adapter->vf_cfg = kcalloc(num_vfs, |
2141 | sizeof(struct be_vf_cfg), | 2142 | sizeof(struct be_vf_cfg), |
2142 | GFP_KERNEL); | 2143 | GFP_KERNEL); |
@@ -2151,10 +2152,10 @@ static int be_sriov_enable(struct be_adapter *adapter) | |||
2151 | static void be_sriov_disable(struct be_adapter *adapter) | 2152 | static void be_sriov_disable(struct be_adapter *adapter) |
2152 | { | 2153 | { |
2153 | #ifdef CONFIG_PCI_IOV | 2154 | #ifdef CONFIG_PCI_IOV |
2154 | if (adapter->sriov_enabled) { | 2155 | if (sriov_enabled(adapter)) { |
2155 | pci_disable_sriov(adapter->pdev); | 2156 | pci_disable_sriov(adapter->pdev); |
2156 | kfree(adapter->vf_cfg); | 2157 | kfree(adapter->vf_cfg); |
2157 | adapter->sriov_enabled = false; | 2158 | adapter->num_vfs = 0; |
2158 | } | 2159 | } |
2159 | #endif | 2160 | #endif |
2160 | } | 2161 | } |
@@ -2466,24 +2467,24 @@ static inline int be_vf_eth_addr_config(struct be_adapter *adapter) | |||
2466 | u32 vf; | 2467 | u32 vf; |
2467 | int status = 0; | 2468 | int status = 0; |
2468 | u8 mac[ETH_ALEN]; | 2469 | u8 mac[ETH_ALEN]; |
2470 | struct be_vf_cfg *vf_cfg; | ||
2469 | 2471 | ||
2470 | be_vf_eth_addr_generate(adapter, mac); | 2472 | be_vf_eth_addr_generate(adapter, mac); |
2471 | 2473 | ||
2472 | for (vf = 0; vf < num_vfs; vf++) { | 2474 | for_all_vfs(adapter, vf_cfg, vf) { |
2473 | if (lancer_chip(adapter)) { | 2475 | if (lancer_chip(adapter)) { |
2474 | status = be_cmd_set_mac_list(adapter, mac, 1, vf + 1); | 2476 | status = be_cmd_set_mac_list(adapter, mac, 1, vf + 1); |
2475 | } else { | 2477 | } else { |
2476 | status = be_cmd_pmac_add(adapter, mac, | 2478 | status = be_cmd_pmac_add(adapter, mac, |
2477 | adapter->vf_cfg[vf].vf_if_handle, | 2479 | vf_cfg->if_handle, |
2478 | &adapter->vf_cfg[vf].vf_pmac_id, | 2480 | &vf_cfg->pmac_id, vf + 1); |
2479 | vf + 1); | ||
2480 | } | 2481 | } |
2481 | 2482 | ||
2482 | if (status) | 2483 | if (status) |
2483 | dev_err(&adapter->pdev->dev, | 2484 | dev_err(&adapter->pdev->dev, |
2484 | "Mac address assignment failed for VF %d\n", vf); | 2485 | "Mac address assignment failed for VF %d\n", vf); |
2485 | else | 2486 | else |
2486 | memcpy(adapter->vf_cfg[vf].vf_mac_addr, mac, ETH_ALEN); | 2487 | memcpy(vf_cfg->mac_addr, mac, ETH_ALEN); |
2487 | 2488 | ||
2488 | mac[5] += 1; | 2489 | mac[5] += 1; |
2489 | } | 2490 | } |
@@ -2492,25 +2493,23 @@ static inline int be_vf_eth_addr_config(struct be_adapter *adapter) | |||
2492 | 2493 | ||
2493 | static void be_vf_clear(struct be_adapter *adapter) | 2494 | static void be_vf_clear(struct be_adapter *adapter) |
2494 | { | 2495 | { |
2496 | struct be_vf_cfg *vf_cfg; | ||
2495 | u32 vf; | 2497 | u32 vf; |
2496 | 2498 | ||
2497 | for (vf = 0; vf < num_vfs; vf++) { | 2499 | for_all_vfs(adapter, vf_cfg, vf) { |
2498 | if (lancer_chip(adapter)) | 2500 | if (lancer_chip(adapter)) |
2499 | be_cmd_set_mac_list(adapter, NULL, 0, vf + 1); | 2501 | be_cmd_set_mac_list(adapter, NULL, 0, vf + 1); |
2500 | else | 2502 | else |
2501 | be_cmd_pmac_del(adapter, | 2503 | be_cmd_pmac_del(adapter, vf_cfg->if_handle, |
2502 | adapter->vf_cfg[vf].vf_if_handle, | 2504 | vf_cfg->pmac_id, vf + 1); |
2503 | adapter->vf_cfg[vf].vf_pmac_id, vf + 1); | ||
2504 | } | ||
2505 | 2505 | ||
2506 | for (vf = 0; vf < num_vfs; vf++) | 2506 | be_cmd_if_destroy(adapter, vf_cfg->if_handle, vf + 1); |
2507 | be_cmd_if_destroy(adapter, adapter->vf_cfg[vf].vf_if_handle, | 2507 | } |
2508 | vf + 1); | ||
2509 | } | 2508 | } |
2510 | 2509 | ||
2511 | static int be_clear(struct be_adapter *adapter) | 2510 | static int be_clear(struct be_adapter *adapter) |
2512 | { | 2511 | { |
2513 | if (be_physfn(adapter) && adapter->sriov_enabled) | 2512 | if (sriov_enabled(adapter)) |
2514 | be_vf_clear(adapter); | 2513 | be_vf_clear(adapter); |
2515 | 2514 | ||
2516 | be_cmd_if_destroy(adapter, adapter->if_handle, 0); | 2515 | be_cmd_if_destroy(adapter, adapter->if_handle, 0); |
@@ -2526,16 +2525,18 @@ static int be_clear(struct be_adapter *adapter) | |||
2526 | 2525 | ||
2527 | static void be_vf_setup_init(struct be_adapter *adapter) | 2526 | static void be_vf_setup_init(struct be_adapter *adapter) |
2528 | { | 2527 | { |
2528 | struct be_vf_cfg *vf_cfg; | ||
2529 | int vf; | 2529 | int vf; |
2530 | 2530 | ||
2531 | for (vf = 0; vf < num_vfs; vf++) { | 2531 | for_all_vfs(adapter, vf_cfg, vf) { |
2532 | adapter->vf_cfg[vf].vf_if_handle = -1; | 2532 | vf_cfg->if_handle = -1; |
2533 | adapter->vf_cfg[vf].vf_pmac_id = -1; | 2533 | vf_cfg->pmac_id = -1; |
2534 | } | 2534 | } |
2535 | } | 2535 | } |
2536 | 2536 | ||
2537 | static int be_vf_setup(struct be_adapter *adapter) | 2537 | static int be_vf_setup(struct be_adapter *adapter) |
2538 | { | 2538 | { |
2539 | struct be_vf_cfg *vf_cfg; | ||
2539 | u32 cap_flags, en_flags, vf; | 2540 | u32 cap_flags, en_flags, vf; |
2540 | u16 lnk_speed; | 2541 | u16 lnk_speed; |
2541 | int status; | 2542 | int status; |
@@ -2544,11 +2545,9 @@ static int be_vf_setup(struct be_adapter *adapter) | |||
2544 | 2545 | ||
2545 | cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | | 2546 | cap_flags = en_flags = BE_IF_FLAGS_UNTAGGED | BE_IF_FLAGS_BROADCAST | |
2546 | BE_IF_FLAGS_MULTICAST; | 2547 | BE_IF_FLAGS_MULTICAST; |
2547 | 2548 | for_all_vfs(adapter, vf_cfg, vf) { | |
2548 | for (vf = 0; vf < num_vfs; vf++) { | ||
2549 | status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, | 2549 | status = be_cmd_if_create(adapter, cap_flags, en_flags, NULL, |
2550 | &adapter->vf_cfg[vf].vf_if_handle, | 2550 | &vf_cfg->if_handle, NULL, vf + 1); |
2551 | NULL, vf+1); | ||
2552 | if (status) | 2551 | if (status) |
2553 | goto err; | 2552 | goto err; |
2554 | } | 2553 | } |
@@ -2557,12 +2556,12 @@ static int be_vf_setup(struct be_adapter *adapter) | |||
2557 | if (status) | 2556 | if (status) |
2558 | goto err; | 2557 | goto err; |
2559 | 2558 | ||
2560 | for (vf = 0; vf < num_vfs; vf++) { | 2559 | for_all_vfs(adapter, vf_cfg, vf) { |
2561 | status = be_cmd_link_status_query(adapter, NULL, &lnk_speed, | 2560 | status = be_cmd_link_status_query(adapter, NULL, &lnk_speed, |
2562 | vf + 1); | 2561 | vf + 1); |
2563 | if (status) | 2562 | if (status) |
2564 | goto err; | 2563 | goto err; |
2565 | adapter->vf_cfg[vf].vf_tx_rate = lnk_speed * 10; | 2564 | vf_cfg->tx_rate = lnk_speed * 10; |
2566 | } | 2565 | } |
2567 | return 0; | 2566 | return 0; |
2568 | err: | 2567 | err: |
@@ -2690,7 +2689,7 @@ static int be_setup(struct be_adapter *adapter) | |||
2690 | 2689 | ||
2691 | pcie_set_readrq(adapter->pdev, 4096); | 2690 | pcie_set_readrq(adapter->pdev, 4096); |
2692 | 2691 | ||
2693 | if (be_physfn(adapter) && adapter->sriov_enabled) { | 2692 | if (sriov_enabled(adapter)) { |
2694 | status = be_vf_setup(adapter); | 2693 | status = be_vf_setup(adapter); |
2695 | if (status) | 2694 | if (status) |
2696 | goto err; | 2695 | goto err; |