net/txgbe: support VF register dump
[dpdk.git] / drivers / net / txgbe / txgbe_ethdev_vf.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020
3  */
4
5 #include <sys/queue.h>
6 #include <stdio.h>
7 #include <errno.h>
8 #include <stdint.h>
9 #include <string.h>
10 #include <rte_log.h>
11 #include <ethdev_pci.h>
12
13 #include "txgbe_logs.h"
14 #include "base/txgbe.h"
15 #include "txgbe_ethdev.h"
16 #include "txgbe_rxtx.h"
17 #include "txgbe_regs_group.h"
18
19 static const struct reg_info txgbevf_regs_general[] = {
20         {TXGBE_VFRST, 1, 1, "TXGBE_VFRST"},
21         {TXGBE_VFSTATUS, 1, 1, "TXGBE_VFSTATUS"},
22         {TXGBE_VFMBCTL, 1, 1, "TXGBE_VFMAILBOX"},
23         {TXGBE_VFMBX, 16, 4, "TXGBE_VFMBX"},
24         {TXGBE_VFPBWRAP, 1, 1, "TXGBE_VFPBWRAP"},
25         {0, 0, 0, ""}
26 };
27
28 static const struct reg_info txgbevf_regs_interrupt[] = {
29         {0, 0, 0, ""}
30 };
31
32 static const struct reg_info txgbevf_regs_rxdma[] = {
33         {0, 0, 0, ""}
34 };
35
36 static const struct reg_info txgbevf_regs_tx[] = {
37         {0, 0, 0, ""}
38 };
39
40 /* VF registers */
41 static const struct reg_info *txgbevf_regs[] = {
42                                 txgbevf_regs_general,
43                                 txgbevf_regs_interrupt,
44                                 txgbevf_regs_rxdma,
45                                 txgbevf_regs_tx,
46                                 NULL};
47
48 static int txgbevf_dev_xstats_get(struct rte_eth_dev *dev,
49                                   struct rte_eth_xstat *xstats, unsigned int n);
50 static int txgbevf_dev_info_get(struct rte_eth_dev *dev,
51                                  struct rte_eth_dev_info *dev_info);
52 static int  txgbevf_dev_configure(struct rte_eth_dev *dev);
53 static int txgbevf_dev_link_update(struct rte_eth_dev *dev,
54                                    int wait_to_complete);
55 static int txgbevf_dev_close(struct rte_eth_dev *dev);
56 static void txgbevf_intr_disable(struct rte_eth_dev *dev);
57 static void txgbevf_intr_enable(struct rte_eth_dev *dev);
58 static int txgbevf_dev_stats_reset(struct rte_eth_dev *dev);
59 static int txgbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
60 static void txgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
61 static void txgbevf_configure_msix(struct rte_eth_dev *dev);
62 static int txgbevf_dev_promiscuous_enable(struct rte_eth_dev *dev);
63 static int txgbevf_dev_promiscuous_disable(struct rte_eth_dev *dev);
64 static void txgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
65 static void txgbevf_dev_interrupt_handler(void *param);
66
67 /*
68  * The set of PCI devices this driver supports (for VF)
69  */
70 static const struct rte_pci_id pci_id_txgbevf_map[] = {
71         { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_RAPTOR_VF) },
72         { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_RAPTOR_VF_HV) },
73         { .vendor_id = 0, /* sentinel */ },
74 };
75
76 static const struct rte_eth_desc_lim rx_desc_lim = {
77         .nb_max = TXGBE_RING_DESC_MAX,
78         .nb_min = TXGBE_RING_DESC_MIN,
79         .nb_align = TXGBE_RXD_ALIGN,
80 };
81
82 static const struct rte_eth_desc_lim tx_desc_lim = {
83         .nb_max = TXGBE_RING_DESC_MAX,
84         .nb_min = TXGBE_RING_DESC_MIN,
85         .nb_align = TXGBE_TXD_ALIGN,
86         .nb_seg_max = TXGBE_TX_MAX_SEG,
87         .nb_mtu_seg_max = TXGBE_TX_MAX_SEG,
88 };
89
90 static const struct eth_dev_ops txgbevf_eth_dev_ops;
91
92 static const struct rte_txgbe_xstats_name_off rte_txgbevf_stats_strings[] = {
93         {"rx_multicast_packets_0",
94                         offsetof(struct txgbevf_hw_stats, qp[0].vfmprc)},
95         {"rx_multicast_packets_1",
96                         offsetof(struct txgbevf_hw_stats, qp[1].vfmprc)},
97         {"rx_multicast_packets_2",
98                         offsetof(struct txgbevf_hw_stats, qp[2].vfmprc)},
99         {"rx_multicast_packets_3",
100                         offsetof(struct txgbevf_hw_stats, qp[3].vfmprc)},
101         {"rx_multicast_packets_4",
102                         offsetof(struct txgbevf_hw_stats, qp[4].vfmprc)},
103         {"rx_multicast_packets_5",
104                         offsetof(struct txgbevf_hw_stats, qp[5].vfmprc)},
105         {"rx_multicast_packets_6",
106                         offsetof(struct txgbevf_hw_stats, qp[6].vfmprc)},
107         {"rx_multicast_packets_7",
108                         offsetof(struct txgbevf_hw_stats, qp[7].vfmprc)}
109 };
110
111 #define TXGBEVF_NB_XSTATS (sizeof(rte_txgbevf_stats_strings) /  \
112                 sizeof(rte_txgbevf_stats_strings[0]))
113
114 /*
115  * Negotiate mailbox API version with the PF.
116  * After reset API version is always set to the basic one (txgbe_mbox_api_10).
117  * Then we try to negotiate starting with the most recent one.
118  * If all negotiation attempts fail, then we will proceed with
119  * the default one (txgbe_mbox_api_10).
120  */
121 static void
122 txgbevf_negotiate_api(struct txgbe_hw *hw)
123 {
124         int32_t i;
125
126         /* start with highest supported, proceed down */
127         static const int sup_ver[] = {
128                 txgbe_mbox_api_13,
129                 txgbe_mbox_api_12,
130                 txgbe_mbox_api_11,
131                 txgbe_mbox_api_10,
132         };
133
134         for (i = 0; i < ARRAY_SIZE(sup_ver); i++) {
135                 if (txgbevf_negotiate_api_version(hw, sup_ver[i]) == 0)
136                         break;
137         }
138 }
139
140 static void
141 generate_random_mac_addr(struct rte_ether_addr *mac_addr)
142 {
143         uint64_t random;
144
145         /* Set Organizationally Unique Identifier (OUI) prefix. */
146         mac_addr->addr_bytes[0] = 0x00;
147         mac_addr->addr_bytes[1] = 0x09;
148         mac_addr->addr_bytes[2] = 0xC0;
149         /* Force indication of locally assigned MAC address. */
150         mac_addr->addr_bytes[0] |= RTE_ETHER_LOCAL_ADMIN_ADDR;
151         /* Generate the last 3 bytes of the MAC address with a random number. */
152         random = rte_rand();
153         memcpy(&mac_addr->addr_bytes[3], &random, 3);
154 }
155
156 /*
157  * Virtual Function device init
158  */
159 static int
160 eth_txgbevf_dev_init(struct rte_eth_dev *eth_dev)
161 {
162         int err;
163         uint32_t tc, tcs;
164         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
165         struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
166         struct txgbe_hw *hw = TXGBE_DEV_HW(eth_dev);
167         struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(eth_dev);
168         struct txgbe_hwstrip *hwstrip = TXGBE_DEV_HWSTRIP(eth_dev);
169         struct rte_ether_addr *perm_addr =
170                         (struct rte_ether_addr *)hw->mac.perm_addr;
171
172         PMD_INIT_FUNC_TRACE();
173
174         eth_dev->dev_ops = &txgbevf_eth_dev_ops;
175         eth_dev->rx_descriptor_status = txgbe_dev_rx_descriptor_status;
176         eth_dev->tx_descriptor_status = txgbe_dev_tx_descriptor_status;
177         eth_dev->rx_pkt_burst = &txgbe_recv_pkts;
178         eth_dev->tx_pkt_burst = &txgbe_xmit_pkts;
179
180         /* for secondary processes, we don't initialise any further as primary
181          * has already done this work. Only check we don't need a different
182          * RX function
183          */
184         if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
185                 struct txgbe_tx_queue *txq;
186                 uint16_t nb_tx_queues = eth_dev->data->nb_tx_queues;
187                 /* TX queue function in primary, set by last queue initialized
188                  * Tx queue may not initialized by primary process
189                  */
190                 if (eth_dev->data->tx_queues) {
191                         txq = eth_dev->data->tx_queues[nb_tx_queues - 1];
192                         txgbe_set_tx_function(eth_dev, txq);
193                 } else {
194                         /* Use default TX function if we get here */
195                         PMD_INIT_LOG(NOTICE,
196                                      "No TX queues configured yet. Using default TX function.");
197                 }
198
199                 txgbe_set_rx_function(eth_dev);
200
201                 return 0;
202         }
203
204         rte_eth_copy_pci_info(eth_dev, pci_dev);
205
206         hw->device_id = pci_dev->id.device_id;
207         hw->vendor_id = pci_dev->id.vendor_id;
208         hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
209         hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
210         hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
211
212         /* initialize the vfta */
213         memset(shadow_vfta, 0, sizeof(*shadow_vfta));
214
215         /* initialize the hw strip bitmap*/
216         memset(hwstrip, 0, sizeof(*hwstrip));
217
218         /* Initialize the shared code (base driver) */
219         err = txgbe_init_shared_code(hw);
220         if (err != 0) {
221                 PMD_INIT_LOG(ERR,
222                         "Shared code init failed for txgbevf: %d", err);
223                 return -EIO;
224         }
225
226         /* init_mailbox_params */
227         hw->mbx.init_params(hw);
228
229         /* Reset the hw statistics */
230         txgbevf_dev_stats_reset(eth_dev);
231
232         /* Disable the interrupts for VF */
233         txgbevf_intr_disable(eth_dev);
234
235         hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
236         err = hw->mac.reset_hw(hw);
237
238         /*
239          * The VF reset operation returns the TXGBE_ERR_INVALID_MAC_ADDR when
240          * the underlying PF driver has not assigned a MAC address to the VF.
241          * In this case, assign a random MAC address.
242          */
243         if (err != 0 && err != TXGBE_ERR_INVALID_MAC_ADDR) {
244                 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", err);
245                 /*
246                  * This error code will be propagated to the app by
247                  * rte_eth_dev_reset, so use a public error code rather than
248                  * the internal-only TXGBE_ERR_RESET_FAILED
249                  */
250                 return -EAGAIN;
251         }
252
253         /* negotiate mailbox API version to use with the PF. */
254         txgbevf_negotiate_api(hw);
255
256         /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
257         txgbevf_get_queues(hw, &tcs, &tc);
258
259         /* Allocate memory for storing MAC addresses */
260         eth_dev->data->mac_addrs = rte_zmalloc("txgbevf", RTE_ETHER_ADDR_LEN *
261                                                hw->mac.num_rar_entries, 0);
262         if (eth_dev->data->mac_addrs == NULL) {
263                 PMD_INIT_LOG(ERR,
264                              "Failed to allocate %u bytes needed to store "
265                              "MAC addresses",
266                              RTE_ETHER_ADDR_LEN * hw->mac.num_rar_entries);
267                 return -ENOMEM;
268         }
269
270         /* Generate a random MAC address, if none was assigned by PF. */
271         if (rte_is_zero_ether_addr(perm_addr)) {
272                 generate_random_mac_addr(perm_addr);
273                 err = txgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
274                 if (err) {
275                         rte_free(eth_dev->data->mac_addrs);
276                         eth_dev->data->mac_addrs = NULL;
277                         return err;
278                 }
279                 PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
280                 PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
281                              "%02x:%02x:%02x:%02x:%02x:%02x",
282                              perm_addr->addr_bytes[0],
283                              perm_addr->addr_bytes[1],
284                              perm_addr->addr_bytes[2],
285                              perm_addr->addr_bytes[3],
286                              perm_addr->addr_bytes[4],
287                              perm_addr->addr_bytes[5]);
288         }
289
290         /* Copy the permanent MAC address */
291         rte_ether_addr_copy(perm_addr, &eth_dev->data->mac_addrs[0]);
292
293         /* reset the hardware with the new settings */
294         err = hw->mac.start_hw(hw);
295         if (err) {
296                 PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", err);
297                 return -EIO;
298         }
299
300         /* enter promiscuous mode */
301         txgbevf_dev_promiscuous_enable(eth_dev);
302
303         rte_intr_callback_register(intr_handle,
304                                    txgbevf_dev_interrupt_handler, eth_dev);
305         rte_intr_enable(intr_handle);
306         txgbevf_intr_enable(eth_dev);
307
308         PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
309                      eth_dev->data->port_id, pci_dev->id.vendor_id,
310                      pci_dev->id.device_id, "txgbe_mac_raptor_vf");
311
312         return 0;
313 }
314
315 /* Virtual Function device uninit */
316 static int
317 eth_txgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
318 {
319         PMD_INIT_FUNC_TRACE();
320
321         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
322                 return 0;
323
324         txgbevf_dev_close(eth_dev);
325
326         return 0;
327 }
328
329 static int eth_txgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
330         struct rte_pci_device *pci_dev)
331 {
332         return rte_eth_dev_pci_generic_probe(pci_dev,
333                 sizeof(struct txgbe_adapter), eth_txgbevf_dev_init);
334 }
335
336 static int eth_txgbevf_pci_remove(struct rte_pci_device *pci_dev)
337 {
338         return rte_eth_dev_pci_generic_remove(pci_dev, eth_txgbevf_dev_uninit);
339 }
340
341 /*
342  * virtual function driver struct
343  */
344 static struct rte_pci_driver rte_txgbevf_pmd = {
345         .id_table = pci_id_txgbevf_map,
346         .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
347         .probe = eth_txgbevf_pci_probe,
348         .remove = eth_txgbevf_pci_remove,
349 };
350
351 static int txgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
352         struct rte_eth_xstat_name *xstats_names, unsigned int limit)
353 {
354         unsigned int i;
355
356         if (limit < TXGBEVF_NB_XSTATS && xstats_names != NULL)
357                 return -ENOMEM;
358
359         if (xstats_names != NULL)
360                 for (i = 0; i < TXGBEVF_NB_XSTATS; i++)
361                         snprintf(xstats_names[i].name,
362                                 sizeof(xstats_names[i].name),
363                                 "%s", rte_txgbevf_stats_strings[i].name);
364         return TXGBEVF_NB_XSTATS;
365 }
366
367 static void
368 txgbevf_update_stats(struct rte_eth_dev *dev)
369 {
370         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
371         struct txgbevf_hw_stats *hw_stats = (struct txgbevf_hw_stats *)
372                           TXGBE_DEV_STATS(dev);
373         unsigned int i;
374
375         for (i = 0; i < dev->data->nb_rx_queues; i++) {
376                 /* Good Rx packet, include VF loopback */
377                 TXGBE_UPDCNT32(TXGBE_QPRXPKT(i),
378                 hw_stats->qp[i].last_vfgprc, hw_stats->qp[i].vfgprc);
379
380                 /* Good Rx octets, include VF loopback */
381                 TXGBE_UPDCNT36(TXGBE_QPRXOCTL(i),
382                 hw_stats->qp[i].last_vfgorc, hw_stats->qp[i].vfgorc);
383
384                 /* Rx Multicst Packet */
385                 TXGBE_UPDCNT32(TXGBE_QPRXMPKT(i),
386                 hw_stats->qp[i].last_vfmprc, hw_stats->qp[i].vfmprc);
387         }
388         hw->rx_loaded = 0;
389
390         for (i = 0; i < dev->data->nb_tx_queues; i++) {
391                 /* Good Tx packet, include VF loopback */
392                 TXGBE_UPDCNT32(TXGBE_QPTXPKT(i),
393                 hw_stats->qp[i].last_vfgptc, hw_stats->qp[i].vfgptc);
394
395                 /* Good Tx octets, include VF loopback */
396                 TXGBE_UPDCNT36(TXGBE_QPTXOCTL(i),
397                 hw_stats->qp[i].last_vfgotc, hw_stats->qp[i].vfgotc);
398         }
399         hw->offset_loaded = 0;
400 }
401
402 static int
403 txgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
404                        unsigned int n)
405 {
406         struct txgbevf_hw_stats *hw_stats = (struct txgbevf_hw_stats *)
407                         TXGBE_DEV_STATS(dev);
408         unsigned int i;
409
410         if (n < TXGBEVF_NB_XSTATS)
411                 return TXGBEVF_NB_XSTATS;
412
413         txgbevf_update_stats(dev);
414
415         if (!xstats)
416                 return 0;
417
418         /* Extended stats */
419         for (i = 0; i < TXGBEVF_NB_XSTATS; i++) {
420                 xstats[i].id = i;
421                 xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
422                         rte_txgbevf_stats_strings[i].offset);
423         }
424
425         return TXGBEVF_NB_XSTATS;
426 }
427
428 static int
429 txgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats)
430 {
431         struct txgbevf_hw_stats *hw_stats = (struct txgbevf_hw_stats *)
432                           TXGBE_DEV_STATS(dev);
433         uint32_t i;
434
435         txgbevf_update_stats(dev);
436
437         if (stats == NULL)
438                 return -EINVAL;
439
440         stats->ipackets = 0;
441         stats->ibytes = 0;
442         stats->opackets = 0;
443         stats->obytes = 0;
444
445         for (i = 0; i < 8; i++) {
446                 stats->ipackets += hw_stats->qp[i].vfgprc;
447                 stats->ibytes += hw_stats->qp[i].vfgorc;
448                 stats->opackets += hw_stats->qp[i].vfgptc;
449                 stats->obytes += hw_stats->qp[i].vfgotc;
450         }
451
452         return 0;
453 }
454
455 static int
456 txgbevf_dev_stats_reset(struct rte_eth_dev *dev)
457 {
458         struct txgbevf_hw_stats *hw_stats = (struct txgbevf_hw_stats *)
459                         TXGBE_DEV_STATS(dev);
460         uint32_t i;
461
462         /* Sync HW register to the last stats */
463         txgbevf_dev_stats_get(dev, NULL);
464
465         /* reset HW current stats*/
466         for (i = 0; i < 8; i++) {
467                 hw_stats->qp[i].vfgprc = 0;
468                 hw_stats->qp[i].vfgorc = 0;
469                 hw_stats->qp[i].vfgptc = 0;
470                 hw_stats->qp[i].vfgotc = 0;
471         }
472
473         return 0;
474 }
475
476 static int
477 txgbevf_dev_info_get(struct rte_eth_dev *dev,
478                      struct rte_eth_dev_info *dev_info)
479 {
480         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
481         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
482
483         dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
484         dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
485         dev_info->min_rx_bufsize = 1024;
486         dev_info->max_rx_pktlen = TXGBE_FRAME_SIZE_MAX;
487         dev_info->max_mac_addrs = hw->mac.num_rar_entries;
488         dev_info->max_hash_mac_addrs = TXGBE_VMDQ_NUM_UC_MAC;
489         dev_info->max_vfs = pci_dev->max_vfs;
490         dev_info->max_vmdq_pools = ETH_64_POOLS;
491         dev_info->rx_queue_offload_capa = txgbe_get_rx_queue_offloads(dev);
492         dev_info->rx_offload_capa = (txgbe_get_rx_port_offloads(dev) |
493                                      dev_info->rx_queue_offload_capa);
494         dev_info->tx_queue_offload_capa = txgbe_get_tx_queue_offloads(dev);
495         dev_info->tx_offload_capa = txgbe_get_tx_port_offloads(dev);
496         dev_info->hash_key_size = TXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
497         dev_info->reta_size = ETH_RSS_RETA_SIZE_128;
498         dev_info->flow_type_rss_offloads = TXGBE_RSS_OFFLOAD_ALL;
499
500         dev_info->default_rxconf = (struct rte_eth_rxconf) {
501                 .rx_thresh = {
502                         .pthresh = TXGBE_DEFAULT_RX_PTHRESH,
503                         .hthresh = TXGBE_DEFAULT_RX_HTHRESH,
504                         .wthresh = TXGBE_DEFAULT_RX_WTHRESH,
505                 },
506                 .rx_free_thresh = TXGBE_DEFAULT_RX_FREE_THRESH,
507                 .rx_drop_en = 0,
508                 .offloads = 0,
509         };
510
511         dev_info->default_txconf = (struct rte_eth_txconf) {
512                 .tx_thresh = {
513                         .pthresh = TXGBE_DEFAULT_TX_PTHRESH,
514                         .hthresh = TXGBE_DEFAULT_TX_HTHRESH,
515                         .wthresh = TXGBE_DEFAULT_TX_WTHRESH,
516                 },
517                 .tx_free_thresh = TXGBE_DEFAULT_TX_FREE_THRESH,
518                 .offloads = 0,
519         };
520
521         dev_info->rx_desc_lim = rx_desc_lim;
522         dev_info->tx_desc_lim = tx_desc_lim;
523
524         return 0;
525 }
526
527 static int
528 txgbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
529 {
530         return txgbe_dev_link_update_share(dev, wait_to_complete);
531 }
532
533 /*
534  * Virtual Function operations
535  */
536 static void
537 txgbevf_intr_disable(struct rte_eth_dev *dev)
538 {
539         struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
540         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
541
542         PMD_INIT_FUNC_TRACE();
543
544         /* Clear interrupt mask to stop from interrupts being generated */
545         wr32(hw, TXGBE_VFIMS, TXGBE_VFIMS_MASK);
546
547         txgbe_flush(hw);
548
549         /* Clear mask value. */
550         intr->mask_misc = TXGBE_VFIMS_MASK;
551 }
552
553 static void
554 txgbevf_intr_enable(struct rte_eth_dev *dev)
555 {
556         struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
557         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
558
559         PMD_INIT_FUNC_TRACE();
560
561         /* VF enable interrupt autoclean */
562         wr32(hw, TXGBE_VFIMC, TXGBE_VFIMC_MASK);
563
564         txgbe_flush(hw);
565
566         intr->mask_misc = 0;
567 }
568
569 static int
570 txgbevf_dev_configure(struct rte_eth_dev *dev)
571 {
572         struct rte_eth_conf *conf = &dev->data->dev_conf;
573         struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
574
575         PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
576                      dev->data->port_id);
577
578         if (dev->data->dev_conf.rxmode.mq_mode & ETH_MQ_RX_RSS_FLAG)
579                 dev->data->dev_conf.rxmode.offloads |= DEV_RX_OFFLOAD_RSS_HASH;
580
581         /*
582          * VF has no ability to enable/disable HW CRC
583          * Keep the persistent behavior the same as Host PF
584          */
585 #ifndef RTE_LIBRTE_TXGBE_PF_DISABLE_STRIP_CRC
586         if (conf->rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC) {
587                 PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
588                 conf->rxmode.offloads &= ~DEV_RX_OFFLOAD_KEEP_CRC;
589         }
590 #else
591         if (!(conf->rxmode.offloads & DEV_RX_OFFLOAD_KEEP_CRC)) {
592                 PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
593                 conf->rxmode.offloads |= DEV_RX_OFFLOAD_KEEP_CRC;
594         }
595 #endif
596
597         /*
598          * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
599          * allocation or vector Rx preconditions we will reset it.
600          */
601         adapter->rx_bulk_alloc_allowed = true;
602
603         return 0;
604 }
605
606 static int
607 txgbevf_dev_close(struct rte_eth_dev *dev)
608 {
609         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
610         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
611         struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
612         PMD_INIT_FUNC_TRACE();
613         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
614                 return 0;
615
616         hw->mac.reset_hw(hw);
617
618         txgbe_dev_free_queues(dev);
619
620         /**
621          * Remove the VF MAC address ro ensure
622          * that the VF traffic goes to the PF
623          * after stop, close and detach of the VF
624          **/
625         txgbevf_remove_mac_addr(dev, 0);
626
627         dev->rx_pkt_burst = NULL;
628         dev->tx_pkt_burst = NULL;
629
630         /* Disable the interrupts for VF */
631         txgbevf_intr_disable(dev);
632
633         rte_free(dev->data->mac_addrs);
634         dev->data->mac_addrs = NULL;
635
636         rte_intr_disable(intr_handle);
637         rte_intr_callback_unregister(intr_handle,
638                                      txgbevf_dev_interrupt_handler, dev);
639
640         return 0;
641 }
642
643 static void txgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
644 {
645         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
646         struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(dev);
647         int i = 0, j = 0, vfta = 0, mask = 1;
648
649         for (i = 0; i < TXGBE_VFTA_SIZE; i++) {
650                 vfta = shadow_vfta->vfta[i];
651                 if (vfta) {
652                         mask = 1;
653                         for (j = 0; j < 32; j++) {
654                                 if (vfta & mask)
655                                         txgbe_set_vfta(hw, (i << 5) + j, 0,
656                                                        on, false);
657                                 mask <<= 1;
658                         }
659                 }
660         }
661 }
662
663 static int
664 txgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
665 {
666         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
667         struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(dev);
668         uint32_t vid_idx = 0;
669         uint32_t vid_bit = 0;
670         int ret = 0;
671
672         PMD_INIT_FUNC_TRACE();
673
674         /* vind is not used in VF driver, set to 0, check txgbe_set_vfta_vf */
675         ret = hw->mac.set_vfta(hw, vlan_id, 0, !!on, false);
676         if (ret) {
677                 PMD_INIT_LOG(ERR, "Unable to set VF vlan");
678                 return ret;
679         }
680         vid_idx = (uint32_t)((vlan_id >> 5) & 0x7F);
681         vid_bit = (uint32_t)(1 << (vlan_id & 0x1F));
682
683         /* Save what we set and restore it after device reset */
684         if (on)
685                 shadow_vfta->vfta[vid_idx] |= vid_bit;
686         else
687                 shadow_vfta->vfta[vid_idx] &= ~vid_bit;
688
689         return 0;
690 }
691
692 static void
693 txgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
694 {
695         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
696         uint32_t ctrl;
697
698         PMD_INIT_FUNC_TRACE();
699
700         if (queue >= hw->mac.max_rx_queues)
701                 return;
702
703         ctrl = rd32(hw, TXGBE_RXCFG(queue));
704         txgbe_dev_save_rx_queue(hw, queue);
705         if (on)
706                 ctrl |= TXGBE_RXCFG_VLAN;
707         else
708                 ctrl &= ~TXGBE_RXCFG_VLAN;
709         wr32(hw, TXGBE_RXCFG(queue), 0);
710         msec_delay(100);
711         txgbe_dev_store_rx_queue(hw, queue);
712         wr32m(hw, TXGBE_RXCFG(queue),
713                 TXGBE_RXCFG_VLAN | TXGBE_RXCFG_ENA, ctrl);
714
715         txgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
716 }
717
718 static int
719 txgbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask)
720 {
721         struct txgbe_rx_queue *rxq;
722         uint16_t i;
723         int on = 0;
724
725         /* VF function only support hw strip feature, others are not support */
726         if (mask & ETH_VLAN_STRIP_MASK) {
727                 for (i = 0; i < dev->data->nb_rx_queues; i++) {
728                         rxq = dev->data->rx_queues[i];
729                         on = !!(rxq->offloads & DEV_RX_OFFLOAD_VLAN_STRIP);
730                         txgbevf_vlan_strip_queue_set(dev, i, on);
731                 }
732         }
733
734         return 0;
735 }
736
737 static int
738 txgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
739 {
740         txgbe_config_vlan_strip_on_all_queues(dev, mask);
741
742         txgbevf_vlan_offload_config(dev, mask);
743
744         return 0;
745 }
746
747 static int
748 txgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
749 {
750         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
751         struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
752         struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
753         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
754         uint32_t vec = TXGBE_MISC_VEC_ID;
755
756         if (rte_intr_allow_others(intr_handle))
757                 vec = TXGBE_RX_VEC_START;
758         intr->mask_misc &= ~(1 << vec);
759         RTE_SET_USED(queue_id);
760         wr32(hw, TXGBE_VFIMC, ~intr->mask_misc);
761
762         rte_intr_enable(intr_handle);
763
764         return 0;
765 }
766
767 static int
768 txgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
769 {
770         struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
771         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
772         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
773         struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
774         uint32_t vec = TXGBE_MISC_VEC_ID;
775
776         if (rte_intr_allow_others(intr_handle))
777                 vec = TXGBE_RX_VEC_START;
778         intr->mask_misc |= (1 << vec);
779         RTE_SET_USED(queue_id);
780         wr32(hw, TXGBE_VFIMS, intr->mask_misc);
781
782         return 0;
783 }
784
785 static void
786 txgbevf_set_ivar_map(struct txgbe_hw *hw, int8_t direction,
787                      uint8_t queue, uint8_t msix_vector)
788 {
789         uint32_t tmp, idx;
790
791         if (direction == -1) {
792                 /* other causes */
793                 msix_vector |= TXGBE_VFIVAR_VLD;
794                 tmp = rd32(hw, TXGBE_VFIVARMISC);
795                 tmp &= ~0xFF;
796                 tmp |= msix_vector;
797                 wr32(hw, TXGBE_VFIVARMISC, tmp);
798         } else {
799                 /* rx or tx cause */
800                 /* Workround for ICR lost */
801                 idx = ((16 * (queue & 1)) + (8 * direction));
802                 tmp = rd32(hw, TXGBE_VFIVAR(queue >> 1));
803                 tmp &= ~(0xFF << idx);
804                 tmp |= (msix_vector << idx);
805                 wr32(hw, TXGBE_VFIVAR(queue >> 1), tmp);
806         }
807 }
808
809 static void
810 txgbevf_configure_msix(struct rte_eth_dev *dev)
811 {
812         struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
813         struct rte_intr_handle *intr_handle = &pci_dev->intr_handle;
814         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
815         uint32_t q_idx;
816         uint32_t vector_idx = TXGBE_MISC_VEC_ID;
817         uint32_t base = TXGBE_MISC_VEC_ID;
818
819         /* Configure VF other cause ivar */
820         txgbevf_set_ivar_map(hw, -1, 1, vector_idx);
821
822         /* won't configure msix register if no mapping is done
823          * between intr vector and event fd.
824          */
825         if (!rte_intr_dp_is_en(intr_handle))
826                 return;
827
828         if (rte_intr_allow_others(intr_handle)) {
829                 base = TXGBE_RX_VEC_START;
830                 vector_idx = TXGBE_RX_VEC_START;
831         }
832
833         /* Configure all RX queues of VF */
834         for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
835                 /* Force all queue use vector 0,
836                  * as TXGBE_VF_MAXMSIVECOTR = 1
837                  */
838                 txgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
839                 intr_handle->intr_vec[q_idx] = vector_idx;
840                 if (vector_idx < base + intr_handle->nb_efd - 1)
841                         vector_idx++;
842         }
843
844         /* As RX queue setting above show, all queues use the vector 0.
845          * Set only the ITR value of TXGBE_MISC_VEC_ID.
846          */
847         wr32(hw, TXGBE_ITR(TXGBE_MISC_VEC_ID),
848                 TXGBE_ITR_IVAL(TXGBE_QUEUE_ITR_INTERVAL_DEFAULT)
849                 | TXGBE_ITR_WRDSA);
850 }
851
852 static int
853 txgbevf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
854                      __rte_unused uint32_t index,
855                      __rte_unused uint32_t pool)
856 {
857         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
858         int err;
859
860         /*
861          * On a VF, adding again the same MAC addr is not an idempotent
862          * operation. Trap this case to avoid exhausting the [very limited]
863          * set of PF resources used to store VF MAC addresses.
864          */
865         if (memcmp(hw->mac.perm_addr, mac_addr,
866                         sizeof(struct rte_ether_addr)) == 0)
867                 return -1;
868         err = txgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
869         if (err != 0)
870                 PMD_DRV_LOG(ERR, "Unable to add MAC address "
871                             "%02x:%02x:%02x:%02x:%02x:%02x - err=%d",
872                             mac_addr->addr_bytes[0],
873                             mac_addr->addr_bytes[1],
874                             mac_addr->addr_bytes[2],
875                             mac_addr->addr_bytes[3],
876                             mac_addr->addr_bytes[4],
877                             mac_addr->addr_bytes[5],
878                             err);
879         return err;
880 }
881
882 static void
883 txgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
884 {
885         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
886         struct rte_ether_addr *perm_addr =
887                         (struct rte_ether_addr *)hw->mac.perm_addr;
888         struct rte_ether_addr *mac_addr;
889         uint32_t i;
890         int err;
891
892         /*
893          * The TXGBE_VF_SET_MACVLAN command of the txgbe-pf driver does
894          * not support the deletion of a given MAC address.
895          * Instead, it imposes to delete all MAC addresses, then to add again
896          * all MAC addresses with the exception of the one to be deleted.
897          */
898         (void)txgbevf_set_uc_addr_vf(hw, 0, NULL);
899
900         /*
901          * Add again all MAC addresses, with the exception of the deleted one
902          * and of the permanent MAC address.
903          */
904         for (i = 0, mac_addr = dev->data->mac_addrs;
905              i < hw->mac.num_rar_entries; i++, mac_addr++) {
906                 /* Skip the deleted MAC address */
907                 if (i == index)
908                         continue;
909                 /* Skip NULL MAC addresses */
910                 if (rte_is_zero_ether_addr(mac_addr))
911                         continue;
912                 /* Skip the permanent MAC address */
913                 if (memcmp(perm_addr, mac_addr,
914                                 sizeof(struct rte_ether_addr)) == 0)
915                         continue;
916                 err = txgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
917                 if (err != 0)
918                         PMD_DRV_LOG(ERR,
919                                     "Adding again MAC address "
920                                     "%02x:%02x:%02x:%02x:%02x:%02x failed "
921                                     "err=%d",
922                                     mac_addr->addr_bytes[0],
923                                     mac_addr->addr_bytes[1],
924                                     mac_addr->addr_bytes[2],
925                                     mac_addr->addr_bytes[3],
926                                     mac_addr->addr_bytes[4],
927                                     mac_addr->addr_bytes[5],
928                                     err);
929         }
930 }
931
932 static int
933 txgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
934                 struct rte_ether_addr *addr)
935 {
936         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
937
938         hw->mac.set_rar(hw, 0, (void *)addr, 0, 0);
939
940         return 0;
941 }
942
943 static int
944 txgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
945 {
946         struct txgbe_hw *hw;
947         uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
948         struct rte_eth_rxmode *rx_conf = &dev->data->dev_conf.rxmode;
949
950         hw = TXGBE_DEV_HW(dev);
951
952         if (mtu < RTE_ETHER_MIN_MTU ||
953                         max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
954                 return -EINVAL;
955
956         /* refuse mtu that requires the support of scattered packets when this
957          * feature has not been enabled before.
958          */
959         if (!(rx_conf->offloads & DEV_RX_OFFLOAD_SCATTER) &&
960             (max_frame + 2 * TXGBE_VLAN_TAG_SIZE >
961              dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM))
962                 return -EINVAL;
963
964         /*
965          * When supported by the underlying PF driver, use the TXGBE_VF_SET_MTU
966          * request of the version 2.0 of the mailbox API.
967          * For now, use the TXGBE_VF_SET_LPE request of the version 1.0
968          * of the mailbox API.
969          */
970         if (txgbevf_rlpml_set_vf(hw, max_frame))
971                 return -EINVAL;
972
973         /* update max frame size */
974         dev->data->dev_conf.rxmode.max_rx_pkt_len = max_frame;
975         return 0;
976 }
977
978 static int
979 txgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
980 {
981         int count = 0;
982         int g_ind = 0;
983         const struct reg_info *reg_group;
984
985         while ((reg_group = txgbevf_regs[g_ind++]))
986                 count += txgbe_regs_group_count(reg_group);
987
988         return count;
989 }
990
991 static int
992 txgbevf_get_regs(struct rte_eth_dev *dev,
993                 struct rte_dev_reg_info *regs)
994 {
995         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
996         uint32_t *data = regs->data;
997         int g_ind = 0;
998         int count = 0;
999         const struct reg_info *reg_group;
1000
1001         if (data == NULL) {
1002                 regs->length = txgbevf_get_reg_length(dev);
1003                 regs->width = sizeof(uint32_t);
1004                 return 0;
1005         }
1006
1007         /* Support only full register dump */
1008         if (regs->length == 0 ||
1009             regs->length == (uint32_t)txgbevf_get_reg_length(dev)) {
1010                 regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
1011                         hw->device_id;
1012                 while ((reg_group = txgbevf_regs[g_ind++]))
1013                         count += txgbe_read_regs_group(dev, &data[count],
1014                                                       reg_group);
1015                 return 0;
1016         }
1017
1018         return -ENOTSUP;
1019 }
1020
1021 static int
1022 txgbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
1023 {
1024         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1025         int ret;
1026
1027         switch (hw->mac.update_xcast_mode(hw, TXGBEVF_XCAST_MODE_PROMISC)) {
1028         case 0:
1029                 ret = 0;
1030                 break;
1031         case TXGBE_ERR_FEATURE_NOT_SUPPORTED:
1032                 ret = -ENOTSUP;
1033                 break;
1034         default:
1035                 ret = -EAGAIN;
1036                 break;
1037         }
1038
1039         return ret;
1040 }
1041
1042 static int
1043 txgbevf_dev_promiscuous_disable(struct rte_eth_dev *dev)
1044 {
1045         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1046         int ret;
1047
1048         switch (hw->mac.update_xcast_mode(hw, TXGBEVF_XCAST_MODE_NONE)) {
1049         case 0:
1050                 ret = 0;
1051                 break;
1052         case TXGBE_ERR_FEATURE_NOT_SUPPORTED:
1053                 ret = -ENOTSUP;
1054                 break;
1055         default:
1056                 ret = -EAGAIN;
1057                 break;
1058         }
1059
1060         return ret;
1061 }
1062
1063 static int
1064 txgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
1065 {
1066         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1067         int ret;
1068
1069         switch (hw->mac.update_xcast_mode(hw, TXGBEVF_XCAST_MODE_ALLMULTI)) {
1070         case 0:
1071                 ret = 0;
1072                 break;
1073         case TXGBE_ERR_FEATURE_NOT_SUPPORTED:
1074                 ret = -ENOTSUP;
1075                 break;
1076         default:
1077                 ret = -EAGAIN;
1078                 break;
1079         }
1080
1081         return ret;
1082 }
1083
1084 static int
1085 txgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
1086 {
1087         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1088         int ret;
1089
1090         switch (hw->mac.update_xcast_mode(hw, TXGBEVF_XCAST_MODE_MULTI)) {
1091         case 0:
1092                 ret = 0;
1093                 break;
1094         case TXGBE_ERR_FEATURE_NOT_SUPPORTED:
1095                 ret = -ENOTSUP;
1096                 break;
1097         default:
1098                 ret = -EAGAIN;
1099                 break;
1100         }
1101
1102         return ret;
1103 }
1104
1105 static void txgbevf_mbx_process(struct rte_eth_dev *dev)
1106 {
1107         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1108         u32 in_msg = 0;
1109
1110         /* peek the message first */
1111         in_msg = rd32(hw, TXGBE_VFMBX);
1112
1113         /* PF reset VF event */
1114         if (in_msg == TXGBE_PF_CONTROL_MSG) {
1115                 /* dummy mbx read to ack pf */
1116                 if (txgbe_read_mbx(hw, &in_msg, 1, 0))
1117                         return;
1118                 rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_RESET,
1119                                               NULL);
1120         }
1121 }
1122
1123 static int
1124 txgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
1125 {
1126         uint32_t eicr;
1127         struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1128         struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1129         txgbevf_intr_disable(dev);
1130
1131         /* read-on-clear nic registers here */
1132         eicr = rd32(hw, TXGBE_VFICR);
1133         intr->flags = 0;
1134
1135         /* only one misc vector supported - mailbox */
1136         eicr &= TXGBE_VFICR_MASK;
1137         /* Workround for ICR lost */
1138         intr->flags |= TXGBE_FLAG_MAILBOX;
1139
1140         return 0;
1141 }
1142
1143 static int
1144 txgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
1145 {
1146         struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1147
1148         if (intr->flags & TXGBE_FLAG_MAILBOX) {
1149                 txgbevf_mbx_process(dev);
1150                 intr->flags &= ~TXGBE_FLAG_MAILBOX;
1151         }
1152
1153         txgbevf_intr_enable(dev);
1154
1155         return 0;
1156 }
1157
1158 static void
1159 txgbevf_dev_interrupt_handler(void *param)
1160 {
1161         struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
1162
1163         txgbevf_dev_interrupt_get_status(dev);
1164         txgbevf_dev_interrupt_action(dev);
1165 }
1166
1167 /*
1168  * dev_ops for virtual function, bare necessities for basic vf
1169  * operation have been implemented
1170  */
1171 static const struct eth_dev_ops txgbevf_eth_dev_ops = {
1172         .dev_configure        = txgbevf_dev_configure,
1173         .link_update          = txgbevf_dev_link_update,
1174         .stats_get            = txgbevf_dev_stats_get,
1175         .xstats_get           = txgbevf_dev_xstats_get,
1176         .stats_reset          = txgbevf_dev_stats_reset,
1177         .xstats_reset         = txgbevf_dev_stats_reset,
1178         .xstats_get_names     = txgbevf_dev_xstats_get_names,
1179         .promiscuous_enable   = txgbevf_dev_promiscuous_enable,
1180         .promiscuous_disable  = txgbevf_dev_promiscuous_disable,
1181         .allmulticast_enable  = txgbevf_dev_allmulticast_enable,
1182         .allmulticast_disable = txgbevf_dev_allmulticast_disable,
1183         .dev_infos_get        = txgbevf_dev_info_get,
1184         .mtu_set              = txgbevf_dev_set_mtu,
1185         .vlan_filter_set      = txgbevf_vlan_filter_set,
1186         .vlan_strip_queue_set = txgbevf_vlan_strip_queue_set,
1187         .vlan_offload_set     = txgbevf_vlan_offload_set,
1188         .rx_queue_intr_enable = txgbevf_dev_rx_queue_intr_enable,
1189         .rx_queue_intr_disable = txgbevf_dev_rx_queue_intr_disable,
1190         .mac_addr_add         = txgbevf_add_mac_addr,
1191         .mac_addr_remove      = txgbevf_remove_mac_addr,
1192         .set_mc_addr_list     = txgbe_dev_set_mc_addr_list,
1193         .rxq_info_get         = txgbe_rxq_info_get,
1194         .txq_info_get         = txgbe_txq_info_get,
1195         .mac_addr_set         = txgbevf_set_default_mac_addr,
1196         .get_reg              = txgbevf_get_regs,
1197         .reta_update          = txgbe_dev_rss_reta_update,
1198         .reta_query           = txgbe_dev_rss_reta_query,
1199         .rss_hash_update      = txgbe_dev_rss_hash_update,
1200         .rss_hash_conf_get    = txgbe_dev_rss_hash_conf_get,
1201 };
1202
1203 RTE_PMD_REGISTER_PCI(net_txgbe_vf, rte_txgbevf_pmd);
1204 RTE_PMD_REGISTER_PCI_TABLE(net_txgbe_vf, pci_id_txgbevf_map);
1205 RTE_PMD_REGISTER_KMOD_DEP(net_txgbe_vf, "* igb_uio | vfio-pci");