aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c94
1 files changed, 54 insertions, 40 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
index 029c863cac81..8a284ac4b400 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c
@@ -44,49 +44,11 @@
44#include "ixgbe_sriov.h" 44#include "ixgbe_sriov.h"
45 45
46#ifdef CONFIG_PCI_IOV 46#ifdef CONFIG_PCI_IOV
47void ixgbe_enable_sriov(struct ixgbe_adapter *adapter) 47static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
48{ 48{
49 struct ixgbe_hw *hw = &adapter->hw; 49 struct ixgbe_hw *hw = &adapter->hw;
50 int num_vf_macvlans, i; 50 int num_vf_macvlans, i;
51 struct vf_macvlans *mv_list; 51 struct vf_macvlans *mv_list;
52 int pre_existing_vfs = 0;
53
54 pre_existing_vfs = pci_num_vf(adapter->pdev);
55 if (!pre_existing_vfs && !adapter->num_vfs)
56 return;
57
58 /* If there are pre-existing VFs then we have to force
59 * use of that many because they were not deleted the last
60 * time someone removed the PF driver. That would have
61 * been because they were allocated to guest VMs and can't
62 * be removed. Go ahead and just re-enable the old amount.
63 * If the user wants to change the number of VFs they can
64 * use ethtool while making sure no VFs are allocated to
65 * guest VMs... i.e. the right way.
66 */
67 if (pre_existing_vfs) {
68 adapter->num_vfs = pre_existing_vfs;
69 dev_warn(&adapter->pdev->dev, "Virtual Functions already "
70 "enabled for this device - Please reload all "
71 "VF drivers to avoid spoofed packet errors\n");
72 } else {
73 int err;
74 /*
75 * The 82599 supports up to 64 VFs per physical function
76 * but this implementation limits allocation to 63 so that
77 * basic networking resources are still available to the
78 * physical function. If the user requests greater thn
79 * 63 VFs then it is an error - reset to default of zero.
80 */
81 adapter->num_vfs = min_t(unsigned int, adapter->num_vfs, 63);
82
83 err = pci_enable_sriov(adapter->pdev, adapter->num_vfs);
84 if (err) {
85 e_err(probe, "Failed to enable PCI sriov: %d\n", err);
86 adapter->num_vfs = 0;
87 return;
88 }
89 }
90 52
91 adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED; 53 adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED;
92 e_info(probe, "SR-IOV enabled with %d VFs\n", adapter->num_vfs); 54 e_info(probe, "SR-IOV enabled with %d VFs\n", adapter->num_vfs);
@@ -150,10 +112,62 @@ void ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
150 /* enable spoof checking for all VFs */ 112 /* enable spoof checking for all VFs */
151 for (i = 0; i < adapter->num_vfs; i++) 113 for (i = 0; i < adapter->num_vfs; i++)
152 adapter->vfinfo[i].spoofchk_enabled = true; 114 adapter->vfinfo[i].spoofchk_enabled = true;
115 return 0;
116 }
117
118 return -ENOMEM;
119}
120
121/* Note this function is called when the user wants to enable SR-IOV
122 * VFs using the now deprecated module parameter
123 */
124void ixgbe_enable_sriov(struct ixgbe_adapter *adapter)
125{
126 int pre_existing_vfs = 0;
127
128 pre_existing_vfs = pci_num_vf(adapter->pdev);
129 if (!pre_existing_vfs && !adapter->num_vfs)
153 return; 130 return;
131
132 if (!pre_existing_vfs)
133 dev_warn(&adapter->pdev->dev,
134 "Enabling SR-IOV VFs using the module parameter is deprecated - please use the pci sysfs interface.\n");
135
136 /* If there are pre-existing VFs then we have to force
137 * use of that many - over ride any module parameter value.
138 * This may result from the user unloading the PF driver
139 * while VFs were assigned to guest VMs or because the VFs
140 * have been created via the new PCI SR-IOV sysfs interface.
141 */
142 if (pre_existing_vfs) {
143 adapter->num_vfs = pre_existing_vfs;
144 dev_warn(&adapter->pdev->dev,
145 "Virtual Functions already enabled for this device - Please reload all VF drivers to avoid spoofed packet errors\n");
146 } else {
147 int err;
148 /*
149 * The 82599 supports up to 64 VFs per physical function
150 * but this implementation limits allocation to 63 so that
151 * basic networking resources are still available to the
152 * physical function. If the user requests greater thn
153 * 63 VFs then it is an error - reset to default of zero.
154 */
155 adapter->num_vfs = min_t(unsigned int, adapter->num_vfs, 63);
156
157 err = pci_enable_sriov(adapter->pdev, adapter->num_vfs);
158 if (err) {
159 e_err(probe, "Failed to enable PCI sriov: %d\n", err);
160 adapter->num_vfs = 0;
161 return;
162 }
154 } 163 }
155 164
156 /* Oh oh */ 165 if (!__ixgbe_enable_sriov(adapter))
166 return;
167
168 /* If we have gotten to this point then there is no memory available
169 * to manage the VF devices - print message and bail.
170 */
157 e_err(probe, "Unable to allocate memory for VF Data Storage - " 171 e_err(probe, "Unable to allocate memory for VF Data Storage - "
158 "SRIOV disabled\n"); 172 "SRIOV disabled\n");
159 ixgbe_disable_sriov(adapter); 173 ixgbe_disable_sriov(adapter);