aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorEmil Tantilov <emil.s.tantilov@intel.com>2017-01-20 17:11:45 -0500
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2017-04-18 16:11:54 -0400
commit2bc0972988c770dce093584ffd641856e3b18c5c (patch)
treea6e6af401ccbd59d87e8bcfb4dc02d5b21359028 /drivers
parent5b9d3cfb6b362a407d0c1ced588b962c5c934f24 (diff)
ixgbe: move num_vfs_macvlans allocation into separate function
Move the code allocating memory for list of MAC addresses that the VFs can use for MACVLAN into its own function. Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c48
1 files changed, 29 insertions, 19 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index 39e109da9bd9..d10b25fa0be4 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -46,42 +46,50 @@
46#include "ixgbe_sriov.h" 46#include "ixgbe_sriov.h"
47 47
48#ifdef CONFIG_PCI_IOV 48#ifdef CONFIG_PCI_IOV
49static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter) 49static inline void ixgbe_alloc_vf_macvlans(struct ixgbe_adapter *adapter)
50{ 50{
51 struct ixgbe_hw *hw = &adapter->hw; 51 struct ixgbe_hw *hw = &adapter->hw;
52 int num_vf_macvlans, i;
53 struct vf_macvlans *mv_list; 52 struct vf_macvlans *mv_list;
54 53 int num_vf_macvlans, i;
55 adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED;
56 e_info(probe, "SR-IOV enabled with %d VFs\n", adapter->num_vfs);
57
58 /* Enable VMDq flag so device will be set in VM mode */
59 adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED;
60 if (!adapter->ring_feature[RING_F_VMDQ].limit)
61 adapter->ring_feature[RING_F_VMDQ].limit = 1;
62 adapter->ring_feature[RING_F_VMDQ].offset = adapter->num_vfs;
63 54
64 num_vf_macvlans = hw->mac.num_rar_entries - 55 num_vf_macvlans = hw->mac.num_rar_entries -
65 (IXGBE_MAX_PF_MACVLANS + 1 + adapter->num_vfs); 56 (IXGBE_MAX_PF_MACVLANS + 1 + adapter->num_vfs);
57 if (!num_vf_macvlans)
58 return;
66 59
67 adapter->mv_list = mv_list = kcalloc(num_vf_macvlans, 60 mv_list = kcalloc(num_vf_macvlans, sizeof(struct vf_macvlans),
68 sizeof(struct vf_macvlans), 61 GFP_KERNEL);
69 GFP_KERNEL);
70 if (mv_list) { 62 if (mv_list) {
71 /* Initialize list of VF macvlans */ 63 /* Initialize list of VF macvlans */
72 INIT_LIST_HEAD(&adapter->vf_mvs.l); 64 INIT_LIST_HEAD(&adapter->vf_mvs.l);
73 for (i = 0; i < num_vf_macvlans; i++) { 65 for (i = 0; i < num_vf_macvlans; i++) {
74 mv_list->vf = -1; 66 mv_list[i].vf = -1;
75 mv_list->free = true; 67 mv_list[i].free = true;
76 list_add(&mv_list->l, &adapter->vf_mvs.l); 68 list_add(&mv_list[i].l, &adapter->vf_mvs.l);
77 mv_list++;
78 } 69 }
70 adapter->mv_list = mv_list;
79 } 71 }
72}
73
74static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
75{
76 struct ixgbe_hw *hw = &adapter->hw;
77
78 adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED;
79 e_info(probe, "SR-IOV enabled with %d VFs\n", adapter->num_vfs);
80
81 /* Enable VMDq flag so device will be set in VM mode */
82 adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED;
83 if (!adapter->ring_feature[RING_F_VMDQ].limit)
84 adapter->ring_feature[RING_F_VMDQ].limit = 1;
85 adapter->ring_feature[RING_F_VMDQ].offset = adapter->num_vfs;
80 86
81 /* Initialize default switching mode VEB */ 87 /* Initialize default switching mode VEB */
82 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN); 88 IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
83 adapter->bridge_mode = BRIDGE_MODE_VEB; 89 adapter->bridge_mode = BRIDGE_MODE_VEB;
84 90
91 ixgbe_alloc_vf_macvlans(adapter);
92
85 /* If call to enable VFs succeeded then allocate memory 93 /* If call to enable VFs succeeded then allocate memory
86 * for per VF control structures. 94 * for per VF control structures.
87 */ 95 */
@@ -89,6 +97,8 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
89 kcalloc(adapter->num_vfs, 97 kcalloc(adapter->num_vfs,
90 sizeof(struct vf_data_storage), GFP_KERNEL); 98 sizeof(struct vf_data_storage), GFP_KERNEL);
91 if (adapter->vfinfo) { 99 if (adapter->vfinfo) {
100 int i;
101
92 /* limit trafffic classes based on VFs enabled */ 102 /* limit trafffic classes based on VFs enabled */
93 if ((adapter->hw.mac.type == ixgbe_mac_82599EB) && 103 if ((adapter->hw.mac.type == ixgbe_mac_82599EB) &&
94 (adapter->num_vfs < 16)) { 104 (adapter->num_vfs < 16)) {