blob: 47b2ce740ec140fe665251851eb3aa9253f069d0 [file] [log] [blame]
Greg Rose17367272010-01-09 02:25:48 +00001/*******************************************************************************
2
3 Intel 10 Gigabit PCI Express Linux driver
Don Skidmore94971822012-01-06 03:24:16 +00004 Copyright(c) 1999 - 2012 Intel Corporation.
Greg Rose17367272010-01-09 02:25:48 +00005
6 This program is free software; you can redistribute it and/or modify it
7 under the terms and conditions of the GNU General Public License,
8 version 2, as published by the Free Software Foundation.
9
10 This program is distributed in the hope it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along with
16 this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
18
19 The full GNU General Public License is included in this distribution in
20 the file called "COPYING".
21
22 Contact Information:
23 e1000-devel Mailing List <e1000-devel@lists.sourceforge.net>
24 Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
25
26*******************************************************************************/
27
Greg Rose17367272010-01-09 02:25:48 +000028#include <linux/types.h>
29#include <linux/module.h>
30#include <linux/pci.h>
31#include <linux/netdevice.h>
32#include <linux/vmalloc.h>
33#include <linux/string.h>
34#include <linux/in.h>
35#include <linux/ip.h>
36#include <linux/tcp.h>
37#include <linux/ipv6.h>
38#ifdef NETIF_F_HW_VLAN_TX
39#include <linux/if_vlan.h>
40#endif
41
42#include "ixgbe.h"
Greg Rosec6bda302011-08-24 02:37:55 +000043#include "ixgbe_type.h"
Greg Rose17367272010-01-09 02:25:48 +000044#include "ixgbe_sriov.h"
45
Greg Rosec6bda302011-08-24 02:37:55 +000046#ifdef CONFIG_PCI_IOV
Greg Rosec6bda302011-08-24 02:37:55 +000047void ixgbe_enable_sriov(struct ixgbe_adapter *adapter,
48 const struct ixgbe_info *ii)
49{
50 struct ixgbe_hw *hw = &adapter->hw;
Greg Rosec6bda302011-08-24 02:37:55 +000051 int num_vf_macvlans, i;
52 struct vf_macvlans *mv_list;
53 int pre_existing_vfs = 0;
54
Alexander Duyck92971272012-05-23 02:58:40 +000055 pre_existing_vfs = pci_num_vf(adapter->pdev);
Greg Rosec6bda302011-08-24 02:37:55 +000056 if (!pre_existing_vfs && !adapter->num_vfs)
57 return;
58
59 /* If there are pre-existing VFs then we have to force
60 * use of that many because they were not deleted the last
61 * time someone removed the PF driver. That would have
62 * been because they were allocated to guest VMs and can't
63 * be removed. Go ahead and just re-enable the old amount.
64 * If the user wants to change the number of VFs they can
65 * use ethtool while making sure no VFs are allocated to
66 * guest VMs... i.e. the right way.
67 */
68 if (pre_existing_vfs) {
69 adapter->num_vfs = pre_existing_vfs;
70 dev_warn(&adapter->pdev->dev, "Virtual Functions already "
71 "enabled for this device - Please reload all "
72 "VF drivers to avoid spoofed packet errors\n");
73 } else {
Alexander Duyck99d74482012-05-09 08:09:25 +000074 int err;
75 /*
76 * The 82599 supports up to 64 VFs per physical function
77 * but this implementation limits allocation to 63 so that
78 * basic networking resources are still available to the
79 * physical function. If the user requests greater thn
80 * 63 VFs then it is an error - reset to default of zero.
81 */
82 adapter->num_vfs = min_t(unsigned int, adapter->num_vfs, 63);
83
Greg Rosec6bda302011-08-24 02:37:55 +000084 err = pci_enable_sriov(adapter->pdev, adapter->num_vfs);
Alexander Duyck73079ea2012-07-14 06:48:49 +000085 if (err) {
86 e_err(probe, "Failed to enable PCI sriov: %d\n", err);
Alexander Duyck99d74482012-05-09 08:09:25 +000087 adapter->num_vfs = 0;
88 return;
Alexander Duyck73079ea2012-07-14 06:48:49 +000089 }
Greg Rosec6bda302011-08-24 02:37:55 +000090 }
Greg Rosec6bda302011-08-24 02:37:55 +000091
Alexander Duyck73079ea2012-07-14 06:48:49 +000092 adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED;
Greg Rosec6bda302011-08-24 02:37:55 +000093 e_info(probe, "SR-IOV enabled with %d VFs\n", adapter->num_vfs);
94
Alexander Duyck73079ea2012-07-14 06:48:49 +000095 /* Enable VMDq flag so device will be set in VM mode */
96 adapter->flags |= IXGBE_FLAG_VMDQ_ENABLED;
97 if (!adapter->ring_feature[RING_F_VMDQ].limit)
98 adapter->ring_feature[RING_F_VMDQ].limit = 1;
99 adapter->ring_feature[RING_F_VMDQ].offset = adapter->num_vfs;
100
Greg Rosec6bda302011-08-24 02:37:55 +0000101 num_vf_macvlans = hw->mac.num_rar_entries -
102 (IXGBE_MAX_PF_MACVLANS + 1 + adapter->num_vfs);
103
104 adapter->mv_list = mv_list = kcalloc(num_vf_macvlans,
105 sizeof(struct vf_macvlans),
106 GFP_KERNEL);
107 if (mv_list) {
108 /* Initialize list of VF macvlans */
109 INIT_LIST_HEAD(&adapter->vf_mvs.l);
110 for (i = 0; i < num_vf_macvlans; i++) {
111 mv_list->vf = -1;
112 mv_list->free = true;
113 mv_list->rar_entry = hw->mac.num_rar_entries -
114 (i + adapter->num_vfs + 1);
115 list_add(&mv_list->l, &adapter->vf_mvs.l);
116 mv_list++;
117 }
118 }
119
120 /* If call to enable VFs succeeded then allocate memory
121 * for per VF control structures.
122 */
123 adapter->vfinfo =
124 kcalloc(adapter->num_vfs,
125 sizeof(struct vf_data_storage), GFP_KERNEL);
126 if (adapter->vfinfo) {
127 /* Now that we're sure SR-IOV is enabled
128 * and memory allocated set up the mailbox parameters
129 */
130 ixgbe_init_mbx_params_pf(hw);
Alexander Duyck73079ea2012-07-14 06:48:49 +0000131 memcpy(&hw->mbx.ops, ii->mbx_ops, sizeof(hw->mbx.ops));
132
133 /* limit trafffic classes based on VFs enabled */
134 if ((adapter->hw.mac.type == ixgbe_mac_82599EB) &&
135 (adapter->num_vfs < 16)) {
136 adapter->dcb_cfg.num_tcs.pg_tcs = MAX_TRAFFIC_CLASS;
137 adapter->dcb_cfg.num_tcs.pfc_tcs = MAX_TRAFFIC_CLASS;
138 } else if (adapter->num_vfs < 32) {
139 adapter->dcb_cfg.num_tcs.pg_tcs = 4;
140 adapter->dcb_cfg.num_tcs.pfc_tcs = 4;
141 } else {
142 adapter->dcb_cfg.num_tcs.pg_tcs = 1;
143 adapter->dcb_cfg.num_tcs.pfc_tcs = 1;
144 }
145
146 /* We do not support RSS w/ SR-IOV */
147 adapter->ring_feature[RING_F_RSS].limit = 1;
Greg Rosec6bda302011-08-24 02:37:55 +0000148
149 /* Disable RSC when in SR-IOV mode */
150 adapter->flags2 &= ~(IXGBE_FLAG2_RSC_CAPABLE |
151 IXGBE_FLAG2_RSC_ENABLED);
Alexander Duyck73079ea2012-07-14 06:48:49 +0000152
153#ifdef IXGBE_FCOE
154 /*
155 * When SR-IOV is enabled 82599 cannot support jumbo frames
156 * so we must disable FCoE because we cannot support FCoE MTU.
157 */
158 if (adapter->hw.mac.type == ixgbe_mac_82599EB)
159 adapter->flags &= ~(IXGBE_FLAG_FCOE_ENABLED |
160 IXGBE_FLAG_FCOE_CAPABLE);
161#endif
162
163 /* enable spoof checking for all VFs */
Greg Rosede4c7f62011-09-29 05:57:33 +0000164 for (i = 0; i < adapter->num_vfs; i++)
165 adapter->vfinfo[i].spoofchk_enabled = true;
Greg Rosec6bda302011-08-24 02:37:55 +0000166 return;
167 }
168
169 /* Oh oh */
170 e_err(probe, "Unable to allocate memory for VF Data Storage - "
171 "SRIOV disabled\n");
Alexander Duyck99d74482012-05-09 08:09:25 +0000172 ixgbe_disable_sriov(adapter);
Greg Rosec6bda302011-08-24 02:37:55 +0000173}
Greg Rosec6bda302011-08-24 02:37:55 +0000174
Alexander Duyck92971272012-05-23 02:58:40 +0000175static bool ixgbe_vfs_are_assigned(struct ixgbe_adapter *adapter)
176{
177 struct pci_dev *pdev = adapter->pdev;
178 struct pci_dev *vfdev;
179 int dev_id;
180
181 switch (adapter->hw.mac.type) {
182 case ixgbe_mac_82599EB:
183 dev_id = IXGBE_DEV_ID_82599_VF;
184 break;
185 case ixgbe_mac_X540:
186 dev_id = IXGBE_DEV_ID_X540_VF;
187 break;
188 default:
189 return false;
190 }
191
192 /* loop through all the VFs to see if we own any that are assigned */
193 vfdev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, NULL);
194 while (vfdev) {
195 /* if we don't own it we don't care */
196 if (vfdev->is_virtfn && vfdev->physfn == pdev) {
197 /* if it is assigned we cannot release it */
198 if (vfdev->dev_flags & PCI_DEV_FLAGS_ASSIGNED)
199 return true;
200 }
201
202 vfdev = pci_get_device(PCI_VENDOR_ID_INTEL, dev_id, vfdev);
203 }
204
205 return false;
206}
207
208#endif /* #ifdef CONFIG_PCI_IOV */
Greg Rosec6bda302011-08-24 02:37:55 +0000209void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)
210{
211 struct ixgbe_hw *hw = &adapter->hw;
Greg Rosec6bda302011-08-24 02:37:55 +0000212 u32 gpie;
213 u32 vmdctl;
Greg Rosec6bda302011-08-24 02:37:55 +0000214
Alexander Duyckd773d132012-05-05 05:32:26 +0000215 /* set num VFs to 0 to prevent access to vfinfo */
216 adapter->num_vfs = 0;
217
218 /* free VF control structures */
219 kfree(adapter->vfinfo);
220 adapter->vfinfo = NULL;
221
222 /* free macvlan list */
223 kfree(adapter->mv_list);
224 adapter->mv_list = NULL;
225
Alexander Duyck99d74482012-05-09 08:09:25 +0000226 /* if SR-IOV is already disabled then there is nothing to do */
227 if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED))
228 return;
229
Greg Rosec6bda302011-08-24 02:37:55 +0000230#ifdef CONFIG_PCI_IOV
Alexander Duyck92971272012-05-23 02:58:40 +0000231 /*
232 * If our VFs are assigned we cannot shut down SR-IOV
233 * without causing issues, so just leave the hardware
234 * available but disabled
235 */
236 if (ixgbe_vfs_are_assigned(adapter)) {
237 e_dev_warn("Unloading driver while VFs are assigned - VFs will not be deallocated\n");
238 return;
239
Greg Rosec6bda302011-08-24 02:37:55 +0000240 /* disable iov and allow time for transactions to clear */
241 pci_disable_sriov(adapter->pdev);
242#endif
243
244 /* turn off device IOV mode */
Alexander Duyck73079ea2012-07-14 06:48:49 +0000245 IXGBE_WRITE_REG(hw, IXGBE_GCR_EXT, 0);
Greg Rosec6bda302011-08-24 02:37:55 +0000246 gpie = IXGBE_READ_REG(hw, IXGBE_GPIE);
247 gpie &= ~IXGBE_GPIE_VTMODE_MASK;
248 IXGBE_WRITE_REG(hw, IXGBE_GPIE, gpie);
249
250 /* set default pool back to 0 */
251 vmdctl = IXGBE_READ_REG(hw, IXGBE_VT_CTL);
252 vmdctl &= ~IXGBE_VT_CTL_POOL_MASK;
253 IXGBE_WRITE_REG(hw, IXGBE_VT_CTL, vmdctl);
254 IXGBE_WRITE_FLUSH(hw);
255
Alexander Duyck1d9c0bf2012-05-05 05:32:21 +0000256 /* Disable VMDq flag so device will be set in VM mode */
257 if (adapter->ring_feature[RING_F_VMDQ].limit == 1)
258 adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED;
259 adapter->ring_feature[RING_F_VMDQ].offset = 0;
260
Greg Rosec6bda302011-08-24 02:37:55 +0000261 /* take a breather then clean up driver data */
262 msleep(100);
263
Greg Rosec6bda302011-08-24 02:37:55 +0000264 adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED;
265}
266
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000267static int ixgbe_set_vf_multicasts(struct ixgbe_adapter *adapter,
268 int entries, u16 *hash_list, u32 vf)
Greg Rose17367272010-01-09 02:25:48 +0000269{
270 struct vf_data_storage *vfinfo = &adapter->vfinfo[vf];
Greg Rose8a07a222010-05-05 19:57:30 +0000271 struct ixgbe_hw *hw = &adapter->hw;
Greg Rose17367272010-01-09 02:25:48 +0000272 int i;
Greg Rose8a07a222010-05-05 19:57:30 +0000273 u32 vector_bit;
274 u32 vector_reg;
275 u32 mta_reg;
Greg Rose17367272010-01-09 02:25:48 +0000276
277 /* only so many hash values supported */
278 entries = min(entries, IXGBE_MAX_VF_MC_ENTRIES);
279
280 /*
281 * salt away the number of multi cast addresses assigned
282 * to this VF for later use to restore when the PF multi cast
283 * list changes
284 */
285 vfinfo->num_vf_mc_hashes = entries;
286
287 /*
288 * VFs are limited to using the MTA hash table for their multicast
289 * addresses
290 */
291 for (i = 0; i < entries; i++) {
Joe Perchese81a1ba2010-11-14 17:04:33 +0000292 vfinfo->vf_mc_hashes[i] = hash_list[i];
Greg Rose17367272010-01-09 02:25:48 +0000293 }
294
Greg Rose8a07a222010-05-05 19:57:30 +0000295 for (i = 0; i < vfinfo->num_vf_mc_hashes; i++) {
296 vector_reg = (vfinfo->vf_mc_hashes[i] >> 5) & 0x7F;
297 vector_bit = vfinfo->vf_mc_hashes[i] & 0x1F;
298 mta_reg = IXGBE_READ_REG(hw, IXGBE_MTA(vector_reg));
299 mta_reg |= (1 << vector_bit);
300 IXGBE_WRITE_REG(hw, IXGBE_MTA(vector_reg), mta_reg);
301 }
Greg Rose17367272010-01-09 02:25:48 +0000302
303 return 0;
304}
305
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000306static void ixgbe_restore_vf_macvlans(struct ixgbe_adapter *adapter)
307{
308 struct ixgbe_hw *hw = &adapter->hw;
309 struct list_head *pos;
310 struct vf_macvlans *entry;
311
312 list_for_each(pos, &adapter->vf_mvs.l) {
313 entry = list_entry(pos, struct vf_macvlans, l);
Joe Perches23677ce2012-02-09 11:17:23 +0000314 if (!entry->free)
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000315 hw->mac.ops.set_rar(hw, entry->rar_entry,
316 entry->vf_macvlan,
317 entry->vf, IXGBE_RAH_AV);
318 }
319}
320
Greg Rose17367272010-01-09 02:25:48 +0000321void ixgbe_restore_vf_multicasts(struct ixgbe_adapter *adapter)
322{
323 struct ixgbe_hw *hw = &adapter->hw;
324 struct vf_data_storage *vfinfo;
325 int i, j;
326 u32 vector_bit;
327 u32 vector_reg;
328 u32 mta_reg;
329
330 for (i = 0; i < adapter->num_vfs; i++) {
331 vfinfo = &adapter->vfinfo[i];
332 for (j = 0; j < vfinfo->num_vf_mc_hashes; j++) {
333 hw->addr_ctrl.mta_in_use++;
334 vector_reg = (vfinfo->vf_mc_hashes[j] >> 5) & 0x7F;
335 vector_bit = vfinfo->vf_mc_hashes[j] & 0x1F;
336 mta_reg = IXGBE_READ_REG(hw, IXGBE_MTA(vector_reg));
337 mta_reg |= (1 << vector_bit);
338 IXGBE_WRITE_REG(hw, IXGBE_MTA(vector_reg), mta_reg);
339 }
340 }
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000341
342 /* Restore any VF macvlans */
343 ixgbe_restore_vf_macvlans(adapter);
Greg Rose17367272010-01-09 02:25:48 +0000344}
345
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000346static int ixgbe_set_vf_vlan(struct ixgbe_adapter *adapter, int add, int vid,
347 u32 vf)
Greg Rose17367272010-01-09 02:25:48 +0000348{
Greg Rose17367272010-01-09 02:25:48 +0000349 return adapter->hw.mac.ops.set_vfta(&adapter->hw, vid, vf, (bool)add);
350}
351
John Fastabendb32c8dc2011-04-12 02:44:55 +0000352static void ixgbe_set_vf_lpe(struct ixgbe_adapter *adapter, u32 *msgbuf)
Greg Rosee9f98072011-01-26 01:06:07 +0000353{
354 struct ixgbe_hw *hw = &adapter->hw;
355 int new_mtu = msgbuf[1];
356 u32 max_frs;
357 int max_frame = new_mtu + ETH_HLEN + ETH_FCS_LEN;
358
359 /* Only X540 supports jumbo frames in IOV mode */
360 if (adapter->hw.mac.type != ixgbe_mac_X540)
361 return;
362
363 /* MTU < 68 is an error and causes problems on some kernels */
364 if ((new_mtu < 68) || (max_frame > IXGBE_MAX_JUMBO_FRAME_SIZE)) {
365 e_err(drv, "VF mtu %d out of range\n", new_mtu);
366 return;
367 }
368
369 max_frs = (IXGBE_READ_REG(hw, IXGBE_MAXFRS) &
370 IXGBE_MHADD_MFS_MASK) >> IXGBE_MHADD_MFS_SHIFT;
371 if (max_frs < new_mtu) {
372 max_frs = new_mtu << IXGBE_MHADD_MFS_SHIFT;
373 IXGBE_WRITE_REG(hw, IXGBE_MAXFRS, max_frs);
374 }
375
376 e_info(hw, "VF requests change max MTU to %d\n", new_mtu);
377}
378
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000379static void ixgbe_set_vmolr(struct ixgbe_hw *hw, u32 vf, bool aupe)
Greg Rose17367272010-01-09 02:25:48 +0000380{
381 u32 vmolr = IXGBE_READ_REG(hw, IXGBE_VMOLR(vf));
Greg Rosef0412772010-05-04 22:11:46 +0000382 vmolr |= (IXGBE_VMOLR_ROMPE |
Greg Rose17367272010-01-09 02:25:48 +0000383 IXGBE_VMOLR_BAM);
Greg Rosef0412772010-05-04 22:11:46 +0000384 if (aupe)
385 vmolr |= IXGBE_VMOLR_AUPE;
386 else
387 vmolr &= ~IXGBE_VMOLR_AUPE;
Greg Rose17367272010-01-09 02:25:48 +0000388 IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);
389}
390
Greg Rose7f016482010-05-04 22:12:06 +0000391static void ixgbe_set_vmvir(struct ixgbe_adapter *adapter, u32 vid, u32 vf)
392{
393 struct ixgbe_hw *hw = &adapter->hw;
394
395 if (vid)
396 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf),
397 (vid | IXGBE_VMVIR_VLANA_DEFAULT));
398 else
399 IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), 0);
400}
401
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000402static inline void ixgbe_vf_reset_event(struct ixgbe_adapter *adapter, u32 vf)
Greg Rose17367272010-01-09 02:25:48 +0000403{
404 struct ixgbe_hw *hw = &adapter->hw;
Alexander Duyck28500622010-06-15 09:25:48 +0000405 int rar_entry = hw->mac.num_rar_entries - (vf + 1);
Greg Rose17367272010-01-09 02:25:48 +0000406
407 /* reset offloads to defaults */
Greg Rose7f016482010-05-04 22:12:06 +0000408 if (adapter->vfinfo[vf].pf_vlan) {
409 ixgbe_set_vf_vlan(adapter, true,
410 adapter->vfinfo[vf].pf_vlan, vf);
411 ixgbe_set_vmvir(adapter,
412 (adapter->vfinfo[vf].pf_vlan |
413 (adapter->vfinfo[vf].pf_qos <<
414 VLAN_PRIO_SHIFT)), vf);
415 ixgbe_set_vmolr(hw, vf, false);
416 } else {
417 ixgbe_set_vmvir(adapter, 0, vf);
418 ixgbe_set_vmolr(hw, vf, true);
419 }
Greg Rose17367272010-01-09 02:25:48 +0000420
421 /* reset multicast table array for vf */
422 adapter->vfinfo[vf].num_vf_mc_hashes = 0;
423
424 /* Flush and reset the mta with the new values */
425 ixgbe_set_rx_mode(adapter->netdev);
426
Alexander Duyck28500622010-06-15 09:25:48 +0000427 hw->mac.ops.clear_rar(hw, rar_entry);
Greg Rose17367272010-01-09 02:25:48 +0000428}
429
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000430static int ixgbe_set_vf_mac(struct ixgbe_adapter *adapter,
431 int vf, unsigned char *mac_addr)
Greg Rose17367272010-01-09 02:25:48 +0000432{
433 struct ixgbe_hw *hw = &adapter->hw;
Alexander Duyck28500622010-06-15 09:25:48 +0000434 int rar_entry = hw->mac.num_rar_entries - (vf + 1);
Greg Rose17367272010-01-09 02:25:48 +0000435
436 memcpy(adapter->vfinfo[vf].vf_mac_addresses, mac_addr, 6);
Alexander Duyck28500622010-06-15 09:25:48 +0000437 hw->mac.ops.set_rar(hw, rar_entry, mac_addr, vf, IXGBE_RAH_AV);
Greg Rose17367272010-01-09 02:25:48 +0000438
439 return 0;
440}
441
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000442static int ixgbe_set_vf_macvlan(struct ixgbe_adapter *adapter,
443 int vf, int index, unsigned char *mac_addr)
444{
445 struct ixgbe_hw *hw = &adapter->hw;
446 struct list_head *pos;
447 struct vf_macvlans *entry;
448
449 if (index <= 1) {
450 list_for_each(pos, &adapter->vf_mvs.l) {
451 entry = list_entry(pos, struct vf_macvlans, l);
452 if (entry->vf == vf) {
453 entry->vf = -1;
454 entry->free = true;
455 entry->is_macvlan = false;
456 hw->mac.ops.clear_rar(hw, entry->rar_entry);
457 }
458 }
459 }
460
461 /*
462 * If index was zero then we were asked to clear the uc list
463 * for the VF. We're done.
464 */
465 if (!index)
466 return 0;
467
468 entry = NULL;
469
470 list_for_each(pos, &adapter->vf_mvs.l) {
471 entry = list_entry(pos, struct vf_macvlans, l);
472 if (entry->free)
473 break;
474 }
475
476 /*
477 * If we traversed the entire list and didn't find a free entry
478 * then we're out of space on the RAR table. Also entry may
479 * be NULL because the original memory allocation for the list
480 * failed, which is not fatal but does mean we can't support
481 * VF requests for MACVLAN because we couldn't allocate
482 * memory for the list management required.
483 */
484 if (!entry || !entry->free)
485 return -ENOSPC;
486
487 entry->free = false;
488 entry->is_macvlan = true;
489 entry->vf = vf;
490 memcpy(entry->vf_macvlan, mac_addr, ETH_ALEN);
491
492 hw->mac.ops.set_rar(hw, entry->rar_entry, mac_addr, vf, IXGBE_RAH_AV);
493
494 return 0;
495}
496
Greg Rose17367272010-01-09 02:25:48 +0000497int ixgbe_vf_configuration(struct pci_dev *pdev, unsigned int event_mask)
498{
499 unsigned char vf_mac_addr[6];
Alexander Duyckc60fbb02010-11-16 19:26:54 -0800500 struct ixgbe_adapter *adapter = pci_get_drvdata(pdev);
Greg Rose17367272010-01-09 02:25:48 +0000501 unsigned int vfn = (event_mask & 0x3f);
502
503 bool enable = ((event_mask & 0x10000000U) != 0);
504
505 if (enable) {
Joe Perches7efd26d2012-07-12 19:33:06 +0000506 eth_random_addr(vf_mac_addr);
Emil Tantilov396e7992010-07-01 20:05:12 +0000507 e_info(probe, "IOV: VF %d is enabled MAC %pM\n",
508 vfn, vf_mac_addr);
Greg Rose17367272010-01-09 02:25:48 +0000509 /*
510 * Store away the VF "permananet" MAC address, it will ask
511 * for it later.
512 */
513 memcpy(adapter->vfinfo[vfn].vf_mac_addresses, vf_mac_addr, 6);
514 }
515
516 return 0;
517}
518
Emil Tantilov5d5b7c32010-10-12 22:20:59 +0000519static inline void ixgbe_vf_reset_msg(struct ixgbe_adapter *adapter, u32 vf)
Greg Rose17367272010-01-09 02:25:48 +0000520{
521 struct ixgbe_hw *hw = &adapter->hw;
522 u32 reg;
523 u32 reg_offset, vf_shift;
524
525 vf_shift = vf % 32;
526 reg_offset = vf / 32;
527
528 /* enable transmit and receive for vf */
529 reg = IXGBE_READ_REG(hw, IXGBE_VFTE(reg_offset));
530 reg |= (reg | (1 << vf_shift));
531 IXGBE_WRITE_REG(hw, IXGBE_VFTE(reg_offset), reg);
532
533 reg = IXGBE_READ_REG(hw, IXGBE_VFRE(reg_offset));
534 reg |= (reg | (1 << vf_shift));
535 IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset), reg);
536
Greg Rosea985b6c32010-11-18 03:02:52 +0000537 /* Enable counting of spoofed packets in the SSVPC register */
538 reg = IXGBE_READ_REG(hw, IXGBE_VMECM(reg_offset));
539 reg |= (1 << vf_shift);
540 IXGBE_WRITE_REG(hw, IXGBE_VMECM(reg_offset), reg);
541
Greg Rose17367272010-01-09 02:25:48 +0000542 ixgbe_vf_reset_event(adapter, vf);
543}
544
545static int ixgbe_rcv_msg_from_vf(struct ixgbe_adapter *adapter, u32 vf)
546{
547 u32 mbx_size = IXGBE_VFMAILBOX_SIZE;
Emil Tantilovc0509992011-05-07 06:49:18 +0000548 u32 msgbuf[IXGBE_VFMAILBOX_SIZE];
Greg Rose17367272010-01-09 02:25:48 +0000549 struct ixgbe_hw *hw = &adapter->hw;
550 s32 retval;
551 int entries;
552 u16 *hash_list;
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000553 int add, vid, index;
Greg Rosed3306c22010-11-18 03:03:23 +0000554 u8 *new_mac;
Greg Rose17367272010-01-09 02:25:48 +0000555
556 retval = ixgbe_read_mbx(hw, msgbuf, mbx_size, vf);
557
Alexander Duyckdcaccc82012-03-28 08:03:38 +0000558 if (retval) {
Emil Tantilov849c4542010-06-03 16:53:41 +0000559 pr_err("Error receiving message from VF\n");
Alexander Duyckdcaccc82012-03-28 08:03:38 +0000560 return retval;
561 }
Greg Rose17367272010-01-09 02:25:48 +0000562
563 /* this is a message we already processed, do nothing */
564 if (msgbuf[0] & (IXGBE_VT_MSGTYPE_ACK | IXGBE_VT_MSGTYPE_NACK))
565 return retval;
566
Alexander Duyckdcaccc82012-03-28 08:03:38 +0000567 /* flush the ack before we write any messages back */
568 IXGBE_WRITE_FLUSH(hw);
569
Greg Rose17367272010-01-09 02:25:48 +0000570 /*
571 * until the vf completes a virtual function reset it should not be
572 * allowed to start any configuration.
573 */
574
575 if (msgbuf[0] == IXGBE_VF_RESET) {
576 unsigned char *vf_mac = adapter->vfinfo[vf].vf_mac_addresses;
Greg Rosed3306c22010-11-18 03:03:23 +0000577 new_mac = (u8 *)(&msgbuf[1]);
Emil Tantilov396e7992010-07-01 20:05:12 +0000578 e_info(probe, "VF Reset msg received from vf %d\n", vf);
Greg Rose17367272010-01-09 02:25:48 +0000579 adapter->vfinfo[vf].clear_to_send = false;
580 ixgbe_vf_reset_msg(adapter, vf);
581 adapter->vfinfo[vf].clear_to_send = true;
582
Greg Rosed3306c22010-11-18 03:03:23 +0000583 if (is_valid_ether_addr(new_mac) &&
584 !adapter->vfinfo[vf].pf_set_mac)
585 ixgbe_set_vf_mac(adapter, vf, vf_mac);
586 else
587 ixgbe_set_vf_mac(adapter,
588 vf, adapter->vfinfo[vf].vf_mac_addresses);
589
Greg Rose17367272010-01-09 02:25:48 +0000590 /* reply to reset with ack and vf mac address */
591 msgbuf[0] = IXGBE_VF_RESET | IXGBE_VT_MSGTYPE_ACK;
Joe Perchesea99d832011-09-20 15:32:52 +0000592 memcpy(new_mac, vf_mac, ETH_ALEN);
Greg Rose17367272010-01-09 02:25:48 +0000593 /*
594 * Piggyback the multicast filter type so VF can compute the
595 * correct vectors
596 */
597 msgbuf[3] = hw->mac.mc_filter_type;
598 ixgbe_write_mbx(hw, msgbuf, IXGBE_VF_PERMADDR_MSG_LEN, vf);
599
600 return retval;
601 }
602
603 if (!adapter->vfinfo[vf].clear_to_send) {
604 msgbuf[0] |= IXGBE_VT_MSGTYPE_NACK;
605 ixgbe_write_mbx(hw, msgbuf, 1, vf);
606 return retval;
607 }
608
609 switch ((msgbuf[0] & 0xFFFF)) {
610 case IXGBE_VF_SET_MAC_ADDR:
Greg Rosed3306c22010-11-18 03:03:23 +0000611 new_mac = ((u8 *)(&msgbuf[1]));
612 if (is_valid_ether_addr(new_mac) &&
613 !adapter->vfinfo[vf].pf_set_mac) {
614 ixgbe_set_vf_mac(adapter, vf, new_mac);
615 } else if (memcmp(adapter->vfinfo[vf].vf_mac_addresses,
616 new_mac, ETH_ALEN)) {
617 e_warn(drv, "VF %d attempted to override "
618 "administratively set MAC address\nReload "
619 "the VF driver to resume operations\n", vf);
620 retval = -1;
Greg Rose17367272010-01-09 02:25:48 +0000621 }
622 break;
623 case IXGBE_VF_SET_MULTICAST:
624 entries = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK)
625 >> IXGBE_VT_MSGINFO_SHIFT;
626 hash_list = (u16 *)&msgbuf[1];
627 retval = ixgbe_set_vf_multicasts(adapter, entries,
628 hash_list, vf);
629 break;
630 case IXGBE_VF_SET_LPE:
Greg Rosee9f98072011-01-26 01:06:07 +0000631 ixgbe_set_vf_lpe(adapter, msgbuf);
Greg Rose17367272010-01-09 02:25:48 +0000632 break;
633 case IXGBE_VF_SET_VLAN:
634 add = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK)
635 >> IXGBE_VT_MSGINFO_SHIFT;
636 vid = (msgbuf[1] & IXGBE_VLVF_VLANID_MASK);
Greg Rosed3306c22010-11-18 03:03:23 +0000637 if (adapter->vfinfo[vf].pf_vlan) {
638 e_warn(drv, "VF %d attempted to override "
639 "administratively set VLAN configuration\n"
640 "Reload the VF driver to resume operations\n",
641 vf);
642 retval = -1;
643 } else {
Greg Rosede4c7f62011-09-29 05:57:33 +0000644 if (add)
645 adapter->vfinfo[vf].vlan_count++;
646 else if (adapter->vfinfo[vf].vlan_count)
647 adapter->vfinfo[vf].vlan_count--;
Greg Rosed3306c22010-11-18 03:03:23 +0000648 retval = ixgbe_set_vf_vlan(adapter, add, vid, vf);
Greg Rosede4c7f62011-09-29 05:57:33 +0000649 if (!retval && adapter->vfinfo[vf].spoofchk_enabled)
650 hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf);
Greg Rosed3306c22010-11-18 03:03:23 +0000651 }
Greg Rose17367272010-01-09 02:25:48 +0000652 break;
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000653 case IXGBE_VF_SET_MACVLAN:
Greg Rose44b82dd2012-04-21 00:54:28 +0000654 index = (msgbuf[0] & IXGBE_VT_MSGINFO_MASK) >>
655 IXGBE_VT_MSGINFO_SHIFT;
656 if (adapter->vfinfo[vf].pf_set_mac && index > 0) {
Greg Rose2ee70652012-03-24 00:26:44 +0000657 e_warn(drv, "VF %d requested MACVLAN filter but is "
658 "administratively denied\n", vf);
659 retval = -1;
660 break;
661 }
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000662 /*
663 * If the VF is allowed to set MAC filters then turn off
664 * anti-spoofing to avoid false positives. An index
665 * greater than 0 will indicate the VF is setting a
666 * macvlan MAC filter.
667 */
Greg Rosede4c7f62011-09-29 05:57:33 +0000668 if (index > 0 && adapter->vfinfo[vf].spoofchk_enabled)
669 ixgbe_ndo_set_vf_spoofchk(adapter->netdev, vf, false);
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000670 retval = ixgbe_set_vf_macvlan(adapter, vf, index,
671 (unsigned char *)(&msgbuf[1]));
Greg Rose68d6d4a2012-01-05 07:58:11 +0000672 if (retval == -ENOSPC)
673 e_warn(drv, "VF %d has requested a MACVLAN filter "
674 "but there is no space for it\n", vf);
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000675 break;
Greg Rose17367272010-01-09 02:25:48 +0000676 default:
Emil Tantilov396e7992010-07-01 20:05:12 +0000677 e_err(drv, "Unhandled Msg %8.8x\n", msgbuf[0]);
Greg Rose17367272010-01-09 02:25:48 +0000678 retval = IXGBE_ERR_MBX;
679 break;
680 }
681
682 /* notify the VF of the results of what it sent us */
683 if (retval)
684 msgbuf[0] |= IXGBE_VT_MSGTYPE_NACK;
685 else
686 msgbuf[0] |= IXGBE_VT_MSGTYPE_ACK;
687
688 msgbuf[0] |= IXGBE_VT_MSGTYPE_CTS;
689
690 ixgbe_write_mbx(hw, msgbuf, 1, vf);
691
692 return retval;
693}
694
695static void ixgbe_rcv_ack_from_vf(struct ixgbe_adapter *adapter, u32 vf)
696{
697 struct ixgbe_hw *hw = &adapter->hw;
698 u32 msg = IXGBE_VT_MSGTYPE_NACK;
699
700 /* if device isn't clear to send it shouldn't be reading either */
701 if (!adapter->vfinfo[vf].clear_to_send)
702 ixgbe_write_mbx(hw, &msg, 1, vf);
703}
704
705void ixgbe_msg_task(struct ixgbe_adapter *adapter)
706{
707 struct ixgbe_hw *hw = &adapter->hw;
708 u32 vf;
709
710 for (vf = 0; vf < adapter->num_vfs; vf++) {
711 /* process any reset requests */
712 if (!ixgbe_check_for_rst(hw, vf))
713 ixgbe_vf_reset_event(adapter, vf);
714
715 /* process any messages pending */
716 if (!ixgbe_check_for_msg(hw, vf))
717 ixgbe_rcv_msg_from_vf(adapter, vf);
718
719 /* process any acks */
720 if (!ixgbe_check_for_ack(hw, vf))
721 ixgbe_rcv_ack_from_vf(adapter, vf);
722 }
723}
724
Greg Rose767081a2010-01-22 22:46:40 +0000725void ixgbe_disable_tx_rx(struct ixgbe_adapter *adapter)
726{
727 struct ixgbe_hw *hw = &adapter->hw;
728
729 /* disable transmit and receive for all vfs */
730 IXGBE_WRITE_REG(hw, IXGBE_VFTE(0), 0);
731 IXGBE_WRITE_REG(hw, IXGBE_VFTE(1), 0);
732
733 IXGBE_WRITE_REG(hw, IXGBE_VFRE(0), 0);
734 IXGBE_WRITE_REG(hw, IXGBE_VFRE(1), 0);
735}
736
737void ixgbe_ping_all_vfs(struct ixgbe_adapter *adapter)
738{
739 struct ixgbe_hw *hw = &adapter->hw;
740 u32 ping;
741 int i;
742
743 for (i = 0 ; i < adapter->num_vfs; i++) {
744 ping = IXGBE_PF_CONTROL_MSG;
745 if (adapter->vfinfo[i].clear_to_send)
746 ping |= IXGBE_VT_MSGTYPE_CTS;
747 ixgbe_write_mbx(hw, &ping, 1, i);
748 }
749}
750
Greg Rose7f016482010-05-04 22:12:06 +0000751int ixgbe_ndo_set_vf_mac(struct net_device *netdev, int vf, u8 *mac)
752{
753 struct ixgbe_adapter *adapter = netdev_priv(netdev);
754 if (!is_valid_ether_addr(mac) || (vf >= adapter->num_vfs))
755 return -EINVAL;
756 adapter->vfinfo[vf].pf_set_mac = true;
757 dev_info(&adapter->pdev->dev, "setting MAC %pM on VF %d\n", mac, vf);
758 dev_info(&adapter->pdev->dev, "Reload the VF driver to make this"
759 " change effective.");
760 if (test_bit(__IXGBE_DOWN, &adapter->state)) {
761 dev_warn(&adapter->pdev->dev, "The VF MAC address has been set,"
762 " but the PF device is not up.\n");
763 dev_warn(&adapter->pdev->dev, "Bring the PF device up before"
764 " attempting to use the VF device.\n");
765 }
766 return ixgbe_set_vf_mac(adapter, vf, mac);
767}
768
769int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos)
770{
771 int err = 0;
772 struct ixgbe_adapter *adapter = netdev_priv(netdev);
Greg Rosea985b6c32010-11-18 03:02:52 +0000773 struct ixgbe_hw *hw = &adapter->hw;
Greg Rose7f016482010-05-04 22:12:06 +0000774
775 if ((vf >= adapter->num_vfs) || (vlan > 4095) || (qos > 7))
776 return -EINVAL;
777 if (vlan || qos) {
778 err = ixgbe_set_vf_vlan(adapter, true, vlan, vf);
779 if (err)
780 goto out;
781 ixgbe_set_vmvir(adapter, vlan | (qos << VLAN_PRIO_SHIFT), vf);
Greg Rosea985b6c32010-11-18 03:02:52 +0000782 ixgbe_set_vmolr(hw, vf, false);
Greg Rosede4c7f62011-09-29 05:57:33 +0000783 if (adapter->vfinfo[vf].spoofchk_enabled)
Greg Rosea1cbb15c2011-05-13 01:33:48 +0000784 hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf);
Greg Rosede4c7f62011-09-29 05:57:33 +0000785 adapter->vfinfo[vf].vlan_count++;
Greg Rose7f016482010-05-04 22:12:06 +0000786 adapter->vfinfo[vf].pf_vlan = vlan;
787 adapter->vfinfo[vf].pf_qos = qos;
788 dev_info(&adapter->pdev->dev,
789 "Setting VLAN %d, QOS 0x%x on VF %d\n", vlan, qos, vf);
790 if (test_bit(__IXGBE_DOWN, &adapter->state)) {
791 dev_warn(&adapter->pdev->dev,
792 "The VF VLAN has been set,"
793 " but the PF device is not up.\n");
794 dev_warn(&adapter->pdev->dev,
795 "Bring the PF device up before"
796 " attempting to use the VF device.\n");
797 }
798 } else {
799 err = ixgbe_set_vf_vlan(adapter, false,
800 adapter->vfinfo[vf].pf_vlan, vf);
801 ixgbe_set_vmvir(adapter, vlan, vf);
Greg Rosea985b6c32010-11-18 03:02:52 +0000802 ixgbe_set_vmolr(hw, vf, true);
803 hw->mac.ops.set_vlan_anti_spoofing(hw, false, vf);
Greg Rosede4c7f62011-09-29 05:57:33 +0000804 if (adapter->vfinfo[vf].vlan_count)
805 adapter->vfinfo[vf].vlan_count--;
Greg Rose7f016482010-05-04 22:12:06 +0000806 adapter->vfinfo[vf].pf_vlan = 0;
807 adapter->vfinfo[vf].pf_qos = 0;
808 }
809out:
810 return err;
811}
812
Lior Levyff4ab202011-03-11 02:03:07 +0000813static int ixgbe_link_mbps(int internal_link_speed)
814{
815 switch (internal_link_speed) {
816 case IXGBE_LINK_SPEED_100_FULL:
817 return 100;
818 case IXGBE_LINK_SPEED_1GB_FULL:
819 return 1000;
820 case IXGBE_LINK_SPEED_10GB_FULL:
821 return 10000;
822 default:
823 return 0;
824 }
825}
826
827static void ixgbe_set_vf_rate_limit(struct ixgbe_hw *hw, int vf, int tx_rate,
828 int link_speed)
829{
830 int rf_dec, rf_int;
831 u32 bcnrc_val;
832
833 if (tx_rate != 0) {
834 /* Calculate the rate factor values to set */
835 rf_int = link_speed / tx_rate;
836 rf_dec = (link_speed - (rf_int * tx_rate));
837 rf_dec = (rf_dec * (1<<IXGBE_RTTBCNRC_RF_INT_SHIFT)) / tx_rate;
838
839 bcnrc_val = IXGBE_RTTBCNRC_RS_ENA;
840 bcnrc_val |= ((rf_int<<IXGBE_RTTBCNRC_RF_INT_SHIFT) &
841 IXGBE_RTTBCNRC_RF_INT_MASK);
842 bcnrc_val |= (rf_dec & IXGBE_RTTBCNRC_RF_DEC_MASK);
843 } else {
844 bcnrc_val = 0;
845 }
846
847 IXGBE_WRITE_REG(hw, IXGBE_RTTDQSEL, 2*vf); /* vf Y uses queue 2*Y */
Lior Levy7555e832011-06-25 00:09:08 -0700848 /*
849 * Set global transmit compensation time to the MMW_SIZE in RTTBCNRM
850 * register. Typically MMW_SIZE=0x014 if 9728-byte jumbo is supported
851 * and 0x004 otherwise.
852 */
853 switch (hw->mac.type) {
854 case ixgbe_mac_82599EB:
855 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM, 0x4);
856 break;
857 case ixgbe_mac_X540:
858 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRM, 0x14);
859 break;
860 default:
861 break;
862 }
863
Lior Levyff4ab202011-03-11 02:03:07 +0000864 IXGBE_WRITE_REG(hw, IXGBE_RTTBCNRC, bcnrc_val);
865}
866
867void ixgbe_check_vf_rate_limit(struct ixgbe_adapter *adapter)
868{
869 int actual_link_speed, i;
870 bool reset_rate = false;
871
872 /* VF Tx rate limit was not set */
873 if (adapter->vf_rate_link_speed == 0)
874 return;
875
876 actual_link_speed = ixgbe_link_mbps(adapter->link_speed);
877 if (actual_link_speed != adapter->vf_rate_link_speed) {
878 reset_rate = true;
879 adapter->vf_rate_link_speed = 0;
880 dev_info(&adapter->pdev->dev,
881 "Link speed has been changed. VF Transmit rate "
882 "is disabled\n");
883 }
884
885 for (i = 0; i < adapter->num_vfs; i++) {
886 if (reset_rate)
887 adapter->vfinfo[i].tx_rate = 0;
888
889 ixgbe_set_vf_rate_limit(&adapter->hw, i,
890 adapter->vfinfo[i].tx_rate,
891 actual_link_speed);
892 }
893}
894
Greg Rose7f016482010-05-04 22:12:06 +0000895int ixgbe_ndo_set_vf_bw(struct net_device *netdev, int vf, int tx_rate)
896{
Lior Levyff4ab202011-03-11 02:03:07 +0000897 struct ixgbe_adapter *adapter = netdev_priv(netdev);
898 struct ixgbe_hw *hw = &adapter->hw;
899 int actual_link_speed;
900
901 actual_link_speed = ixgbe_link_mbps(adapter->link_speed);
902 if ((vf >= adapter->num_vfs) || (!adapter->link_up) ||
903 (tx_rate > actual_link_speed) || (actual_link_speed != 10000) ||
904 ((tx_rate != 0) && (tx_rate <= 10)))
905 /* rate limit cannot be set to 10Mb or less in 10Gb adapters */
906 return -EINVAL;
907
908 adapter->vf_rate_link_speed = actual_link_speed;
909 adapter->vfinfo[vf].tx_rate = (u16)tx_rate;
910 ixgbe_set_vf_rate_limit(hw, vf, tx_rate, actual_link_speed);
911
912 return 0;
Greg Rose7f016482010-05-04 22:12:06 +0000913}
914
Greg Rosede4c7f62011-09-29 05:57:33 +0000915int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting)
916{
917 struct ixgbe_adapter *adapter = netdev_priv(netdev);
918 int vf_target_reg = vf >> 3;
919 int vf_target_shift = vf % 8;
920 struct ixgbe_hw *hw = &adapter->hw;
921 u32 regval;
922
923 adapter->vfinfo[vf].spoofchk_enabled = setting;
924
925 regval = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
926 regval &= ~(1 << vf_target_shift);
927 regval |= (setting << vf_target_shift);
928 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), regval);
929
930 if (adapter->vfinfo[vf].vlan_count) {
931 vf_target_shift += IXGBE_SPOOF_VLANAS_SHIFT;
932 regval = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg));
933 regval &= ~(1 << vf_target_shift);
934 regval |= (setting << vf_target_shift);
935 IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), regval);
936 }
937
938 return 0;
939}
940
Greg Rose7f016482010-05-04 22:12:06 +0000941int ixgbe_ndo_get_vf_config(struct net_device *netdev,
942 int vf, struct ifla_vf_info *ivi)
943{
944 struct ixgbe_adapter *adapter = netdev_priv(netdev);
945 if (vf >= adapter->num_vfs)
946 return -EINVAL;
947 ivi->vf = vf;
948 memcpy(&ivi->mac, adapter->vfinfo[vf].vf_mac_addresses, ETH_ALEN);
Lior Levyff4ab202011-03-11 02:03:07 +0000949 ivi->tx_rate = adapter->vfinfo[vf].tx_rate;
Greg Rose7f016482010-05-04 22:12:06 +0000950 ivi->vlan = adapter->vfinfo[vf].pf_vlan;
951 ivi->qos = adapter->vfinfo[vf].pf_qos;
Greg Rosede4c7f62011-09-29 05:57:33 +0000952 ivi->spoofchk = adapter->vfinfo[vf].spoofchk_enabled;
Greg Rose7f016482010-05-04 22:12:06 +0000953 return 0;
954}