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>
This commit is contained in:
parent
5b9d3cfb6b
commit
2bc0972988
@ -46,11 +46,34 @@
|
|||||||
#include "ixgbe_sriov.h"
|
#include "ixgbe_sriov.h"
|
||||||
|
|
||||||
#ifdef CONFIG_PCI_IOV
|
#ifdef CONFIG_PCI_IOV
|
||||||
|
static inline void ixgbe_alloc_vf_macvlans(struct ixgbe_adapter *adapter)
|
||||||
|
{
|
||||||
|
struct ixgbe_hw *hw = &adapter->hw;
|
||||||
|
struct vf_macvlans *mv_list;
|
||||||
|
int num_vf_macvlans, i;
|
||||||
|
|
||||||
|
num_vf_macvlans = hw->mac.num_rar_entries -
|
||||||
|
(IXGBE_MAX_PF_MACVLANS + 1 + adapter->num_vfs);
|
||||||
|
if (!num_vf_macvlans)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mv_list = kcalloc(num_vf_macvlans, sizeof(struct vf_macvlans),
|
||||||
|
GFP_KERNEL);
|
||||||
|
if (mv_list) {
|
||||||
|
/* Initialize list of VF macvlans */
|
||||||
|
INIT_LIST_HEAD(&adapter->vf_mvs.l);
|
||||||
|
for (i = 0; i < num_vf_macvlans; i++) {
|
||||||
|
mv_list[i].vf = -1;
|
||||||
|
mv_list[i].free = true;
|
||||||
|
list_add(&mv_list[i].l, &adapter->vf_mvs.l);
|
||||||
|
}
|
||||||
|
adapter->mv_list = mv_list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
|
static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
|
||||||
{
|
{
|
||||||
struct ixgbe_hw *hw = &adapter->hw;
|
struct ixgbe_hw *hw = &adapter->hw;
|
||||||
int num_vf_macvlans, i;
|
|
||||||
struct vf_macvlans *mv_list;
|
|
||||||
|
|
||||||
adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED;
|
adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED;
|
||||||
e_info(probe, "SR-IOV enabled with %d VFs\n", adapter->num_vfs);
|
e_info(probe, "SR-IOV enabled with %d VFs\n", adapter->num_vfs);
|
||||||
@ -61,27 +84,12 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
|
|||||||
adapter->ring_feature[RING_F_VMDQ].limit = 1;
|
adapter->ring_feature[RING_F_VMDQ].limit = 1;
|
||||||
adapter->ring_feature[RING_F_VMDQ].offset = adapter->num_vfs;
|
adapter->ring_feature[RING_F_VMDQ].offset = adapter->num_vfs;
|
||||||
|
|
||||||
num_vf_macvlans = hw->mac.num_rar_entries -
|
|
||||||
(IXGBE_MAX_PF_MACVLANS + 1 + adapter->num_vfs);
|
|
||||||
|
|
||||||
adapter->mv_list = mv_list = kcalloc(num_vf_macvlans,
|
|
||||||
sizeof(struct vf_macvlans),
|
|
||||||
GFP_KERNEL);
|
|
||||||
if (mv_list) {
|
|
||||||
/* Initialize list of VF macvlans */
|
|
||||||
INIT_LIST_HEAD(&adapter->vf_mvs.l);
|
|
||||||
for (i = 0; i < num_vf_macvlans; i++) {
|
|
||||||
mv_list->vf = -1;
|
|
||||||
mv_list->free = true;
|
|
||||||
list_add(&mv_list->l, &adapter->vf_mvs.l);
|
|
||||||
mv_list++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Initialize default switching mode VEB */
|
/* Initialize default switching mode VEB */
|
||||||
IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
|
IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN);
|
||||||
adapter->bridge_mode = BRIDGE_MODE_VEB;
|
adapter->bridge_mode = BRIDGE_MODE_VEB;
|
||||||
|
|
||||||
|
ixgbe_alloc_vf_macvlans(adapter);
|
||||||
|
|
||||||
/* If call to enable VFs succeeded then allocate memory
|
/* If call to enable VFs succeeded then allocate memory
|
||||||
* for per VF control structures.
|
* for per VF control structures.
|
||||||
*/
|
*/
|
||||||
@ -89,6 +97,8 @@ static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
|
|||||||
kcalloc(adapter->num_vfs,
|
kcalloc(adapter->num_vfs,
|
||||||
sizeof(struct vf_data_storage), GFP_KERNEL);
|
sizeof(struct vf_data_storage), GFP_KERNEL);
|
||||||
if (adapter->vfinfo) {
|
if (adapter->vfinfo) {
|
||||||
|
int i;
|
||||||
|
|
||||||
/* limit trafffic classes based on VFs enabled */
|
/* limit trafffic classes based on VFs enabled */
|
||||||
if ((adapter->hw.mac.type == ixgbe_mac_82599EB) &&
|
if ((adapter->hw.mac.type == ixgbe_mac_82599EB) &&
|
||||||
(adapter->num_vfs < 16)) {
|
(adapter->num_vfs < 16)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user