Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2015-2020 Beijing WangXun Technology Co., Ltd.
3 : : * Copyright(c) 2010-2017 Intel Corporation
4 : : */
5 : :
6 : : #include <sys/queue.h>
7 : : #include <stdio.h>
8 : : #include <errno.h>
9 : : #include <stdint.h>
10 : : #include <string.h>
11 : : #include <rte_log.h>
12 : : #include <ethdev_pci.h>
13 : : #include <rte_alarm.h>
14 : :
15 : : #include "txgbe_logs.h"
16 : : #include "base/txgbe.h"
17 : : #include "txgbe_ethdev.h"
18 : : #include "txgbe_rxtx.h"
19 : : #include "txgbe_regs_group.h"
20 : :
21 : : static const struct reg_info txgbevf_regs_general[] = {
22 : : {TXGBE_VFRST, 1, 1, "TXGBE_VFRST"},
23 : : {TXGBE_VFSTATUS, 1, 1, "TXGBE_VFSTATUS"},
24 : : {TXGBE_VFMBCTL, 1, 1, "TXGBE_VFMAILBOX"},
25 : : {TXGBE_VFMBX, 16, 4, "TXGBE_VFMBX"},
26 : : {TXGBE_VFPBWRAP, 1, 1, "TXGBE_VFPBWRAP"},
27 : : {0, 0, 0, ""}
28 : : };
29 : :
30 : : static const struct reg_info txgbevf_regs_interrupt[] = {
31 : : {0, 0, 0, ""}
32 : : };
33 : :
34 : : static const struct reg_info txgbevf_regs_rxdma[] = {
35 : : {0, 0, 0, ""}
36 : : };
37 : :
38 : : static const struct reg_info txgbevf_regs_tx[] = {
39 : : {0, 0, 0, ""}
40 : : };
41 : :
42 : : /* VF registers */
43 : : static const struct reg_info *txgbevf_regs[] = {
44 : : txgbevf_regs_general,
45 : : txgbevf_regs_interrupt,
46 : : txgbevf_regs_rxdma,
47 : : txgbevf_regs_tx,
48 : : NULL};
49 : :
50 : : static int txgbevf_dev_xstats_get(struct rte_eth_dev *dev,
51 : : struct rte_eth_xstat *xstats, unsigned int n);
52 : : static int txgbevf_dev_info_get(struct rte_eth_dev *dev,
53 : : struct rte_eth_dev_info *dev_info);
54 : : static int txgbevf_dev_configure(struct rte_eth_dev *dev);
55 : : static int txgbevf_dev_start(struct rte_eth_dev *dev);
56 : : static int txgbevf_dev_link_update(struct rte_eth_dev *dev,
57 : : int wait_to_complete);
58 : : static int txgbevf_dev_stop(struct rte_eth_dev *dev);
59 : : static int txgbevf_dev_close(struct rte_eth_dev *dev);
60 : : static void txgbevf_intr_disable(struct rte_eth_dev *dev);
61 : : static void txgbevf_intr_enable(struct rte_eth_dev *dev);
62 : : static int txgbevf_dev_stats_reset(struct rte_eth_dev *dev);
63 : : static int txgbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask);
64 : : static void txgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on);
65 : : static void txgbevf_configure_msix(struct rte_eth_dev *dev);
66 : : static int txgbevf_dev_promiscuous_enable(struct rte_eth_dev *dev);
67 : : static int txgbevf_dev_promiscuous_disable(struct rte_eth_dev *dev);
68 : : static void txgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index);
69 : : static void txgbevf_dev_interrupt_handler(void *param);
70 : :
71 : : /*
72 : : * The set of PCI devices this driver supports (for VF)
73 : : */
74 : : static const struct rte_pci_id pci_id_txgbevf_map[] = {
75 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_SP1000_VF) },
76 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_WX1820_VF) },
77 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_AML_VF) },
78 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_AML5024_VF) },
79 : : { RTE_PCI_DEVICE(PCI_VENDOR_ID_WANGXUN, TXGBE_DEV_ID_AML5124_VF) },
80 : : { .vendor_id = 0, /* sentinel */ },
81 : : };
82 : :
83 : : static const struct rte_eth_desc_lim rx_desc_lim = {
84 : : .nb_max = TXGBE_RING_DESC_MAX,
85 : : .nb_min = TXGBE_RING_DESC_MIN,
86 : : .nb_align = TXGBE_RXD_ALIGN,
87 : : };
88 : :
89 : : static const struct rte_eth_desc_lim tx_desc_lim = {
90 : : .nb_max = TXGBE_RING_DESC_MAX,
91 : : .nb_min = TXGBE_RING_DESC_MIN,
92 : : .nb_align = TXGBE_TXD_ALIGN,
93 : : .nb_seg_max = TXGBE_TX_MAX_SEG,
94 : : .nb_mtu_seg_max = TXGBE_TX_MAX_SEG,
95 : : };
96 : :
97 : : static const struct eth_dev_ops txgbevf_eth_dev_ops;
98 : :
99 : : static const struct rte_txgbe_xstats_name_off rte_txgbevf_stats_strings[] = {
100 : : {"rx_multicast_packets_0",
101 : : offsetof(struct txgbevf_hw_stats, qp[0].vfmprc)},
102 : : {"rx_multicast_packets_1",
103 : : offsetof(struct txgbevf_hw_stats, qp[1].vfmprc)},
104 : : {"rx_multicast_packets_2",
105 : : offsetof(struct txgbevf_hw_stats, qp[2].vfmprc)},
106 : : {"rx_multicast_packets_3",
107 : : offsetof(struct txgbevf_hw_stats, qp[3].vfmprc)},
108 : : {"rx_multicast_packets_4",
109 : : offsetof(struct txgbevf_hw_stats, qp[4].vfmprc)},
110 : : {"rx_multicast_packets_5",
111 : : offsetof(struct txgbevf_hw_stats, qp[5].vfmprc)},
112 : : {"rx_multicast_packets_6",
113 : : offsetof(struct txgbevf_hw_stats, qp[6].vfmprc)},
114 : : {"rx_multicast_packets_7",
115 : : offsetof(struct txgbevf_hw_stats, qp[7].vfmprc)}
116 : : };
117 : :
118 : : #define TXGBEVF_NB_XSTATS (sizeof(rte_txgbevf_stats_strings) / \
119 : : sizeof(rte_txgbevf_stats_strings[0]))
120 : :
121 : : /*
122 : : * Negotiate mailbox API version with the PF.
123 : : * After reset API version is always set to the basic one (txgbe_mbox_api_10).
124 : : * Then we try to negotiate starting with the most recent one.
125 : : * If all negotiation attempts fail, then we will proceed with
126 : : * the default one (txgbe_mbox_api_10).
127 : : */
128 : : static void
129 : 0 : txgbevf_negotiate_api(struct txgbe_hw *hw)
130 : : {
131 : : int32_t i;
132 : :
133 : : /* start with highest supported, proceed down */
134 : : static const int sup_ver[] = {
135 : : txgbe_mbox_api_23,
136 : : txgbe_mbox_api_21,
137 : : txgbe_mbox_api_13,
138 : : txgbe_mbox_api_12,
139 : : txgbe_mbox_api_11,
140 : : txgbe_mbox_api_10,
141 : : };
142 : :
143 [ # # ]: 0 : for (i = 0; i < ARRAY_SIZE(sup_ver); i++) {
144 [ # # ]: 0 : if (txgbevf_negotiate_api_version(hw, sup_ver[i]) == 0)
145 : : break;
146 : : }
147 : 0 : }
148 : :
149 : : static void
150 : 0 : generate_random_mac_addr(struct rte_ether_addr *mac_addr)
151 : : {
152 : : uint64_t random;
153 : :
154 : : /* Set Organizationally Unique Identifier (OUI) prefix. */
155 : : mac_addr->addr_bytes[0] = 0x00;
156 : 0 : mac_addr->addr_bytes[1] = 0x09;
157 : 0 : mac_addr->addr_bytes[2] = 0xC0;
158 : : /* Force indication of locally assigned MAC address. */
159 : 0 : mac_addr->addr_bytes[0] |= RTE_ETHER_LOCAL_ADMIN_ADDR;
160 : : /* Generate the last 3 bytes of the MAC address with a random number. */
161 : 0 : random = rte_rand();
162 : 0 : memcpy(&mac_addr->addr_bytes[3], &random, 3);
163 : 0 : }
164 : :
165 : : int
166 : 0 : txgbevf_inject_5tuple_filter(struct rte_eth_dev *dev,
167 : : struct txgbe_5tuple_filter *filter)
168 : : {
169 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(dev);
170 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
171 : : uint32_t mask = TXGBE_5TFCTL0_MASK;
172 [ # # ]: 0 : uint16_t index = filter->index;
173 : : uint32_t msg[TXGBEVF_5T_MAX];
174 : : int err;
175 : :
176 : : memset(msg, 0, sizeof(msg));
177 : :
178 : : /* 0 means compare */
179 : : mask &= ~TXGBE_5TFCTL0_MPOOL;
180 [ # # ]: 0 : if (filter->filter_info.src_ip_mask == 0)
181 : : mask &= ~TXGBE_5TFCTL0_MSADDR;
182 [ # # ]: 0 : if (filter->filter_info.dst_ip_mask == 0)
183 : 0 : mask &= ~TXGBE_5TFCTL0_MDADDR;
184 [ # # ]: 0 : if (filter->filter_info.src_port_mask == 0)
185 : 0 : mask &= ~TXGBE_5TFCTL0_MSPORT;
186 [ # # ]: 0 : if (filter->filter_info.dst_port_mask == 0)
187 : 0 : mask &= ~TXGBE_5TFCTL0_MDPORT;
188 [ # # ]: 0 : if (filter->filter_info.proto_mask == 0)
189 : 0 : mask &= ~TXGBE_5TFCTL0_MPROTO;
190 : :
191 : : msg[TXGBEVF_5T_CTRL0] = mask;
192 : 0 : msg[TXGBEVF_5T_CTRL0] |= TXGBE_5TFCTL0_ENA;
193 : 0 : msg[TXGBEVF_5T_CTRL0] |= TXGBE_5TFCTL0_PROTO(filter->filter_info.proto);
194 : 0 : msg[TXGBEVF_5T_CTRL0] |= TXGBE_5TFCTL0_PRI(filter->filter_info.priority);
195 : 0 : msg[TXGBEVF_5T_CTRL1] = TXGBE_5TFCTL1_QP(filter->queue);
196 [ # # ]: 0 : msg[TXGBEVF_5T_PORT] = TXGBE_5TFPORT_DST(be_to_le16(filter->filter_info.dst_port));
197 [ # # ]: 0 : msg[TXGBEVF_5T_PORT] |= TXGBE_5TFPORT_SRC(be_to_le16(filter->filter_info.src_port));
198 [ # # ]: 0 : msg[TXGBEVF_5T_DA] = be_to_le32(filter->filter_info.dst_ip);
199 [ # # ]: 0 : msg[TXGBEVF_5T_SA] = be_to_le32(filter->filter_info.src_ip);
200 : :
201 : 0 : err = txgbevf_add_5tuple_filter(hw, msg, index);
202 [ # # ]: 0 : if (!err)
203 : : return 0;
204 : :
205 [ # # ]: 0 : if (msg[TXGBEVF_5T_REQ] & TXGBE_VT_MSGTYPE_SPEC) {
206 : 0 : PMD_DRV_LOG(INFO, "5tuple filters are full, switch to FDIR");
207 : 0 : filter_info->ntuple_is_full = true;
208 : 0 : return -ENOSYS;
209 : : }
210 : :
211 : 0 : PMD_DRV_LOG(ERR, "VF request PF to add 5tuple filters failed.");
212 : 0 : return err;
213 : : }
214 : :
215 : : void
216 : 0 : txgbevf_remove_5tuple_filter(struct rte_eth_dev *dev, u16 index)
217 : : {
218 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
219 : : int err;
220 : :
221 : 0 : err = txgbevf_del_5tuple_filter(hw, index);
222 [ # # ]: 0 : if (err)
223 : 0 : PMD_DRV_LOG(ERR, "VF request PF to delete 5tuple filters failed.");
224 : 0 : }
225 : :
226 : : /*
227 : : * Virtual Function device init
228 : : */
229 : : static int
230 : 0 : eth_txgbevf_dev_init(struct rte_eth_dev *eth_dev)
231 : : {
232 : : int err;
233 : : uint32_t tc, tcs;
234 : 0 : struct txgbe_adapter *ad = eth_dev->data->dev_private;
235 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(eth_dev);
236 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
237 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(eth_dev);
238 : 0 : struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(eth_dev);
239 : 0 : struct txgbe_hwstrip *hwstrip = TXGBE_DEV_HWSTRIP(eth_dev);
240 : 0 : struct rte_ether_addr *perm_addr =
241 : : (struct rte_ether_addr *)hw->mac.perm_addr;
242 : 0 : struct txgbe_filter_info *filter_info = TXGBE_DEV_FILTER(eth_dev);
243 : :
244 : 0 : PMD_INIT_FUNC_TRACE();
245 : :
246 : 0 : eth_dev->dev_ops = &txgbevf_eth_dev_ops;
247 : 0 : eth_dev->rx_descriptor_status = txgbe_dev_rx_descriptor_status;
248 : 0 : eth_dev->tx_descriptor_status = txgbe_dev_tx_descriptor_status;
249 : 0 : eth_dev->rx_pkt_burst = &txgbe_recv_pkts;
250 : 0 : eth_dev->tx_pkt_burst = &txgbe_xmit_pkts;
251 : :
252 : : /* for secondary processes, we don't initialise any further as primary
253 : : * has already done this work. Only check we don't need a different
254 : : * RX function
255 : : */
256 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
257 : : struct txgbe_tx_queue *txq;
258 : 0 : uint16_t nb_tx_queues = eth_dev->data->nb_tx_queues;
259 : : /* TX queue function in primary, set by last queue initialized
260 : : * Tx queue may not initialized by primary process
261 : : */
262 [ # # ]: 0 : if (eth_dev->data->tx_queues) {
263 : 0 : txq = eth_dev->data->tx_queues[nb_tx_queues - 1];
264 : 0 : txgbe_set_tx_function(eth_dev, txq);
265 : : } else {
266 : : /* Use default TX function if we get here */
267 : 0 : PMD_INIT_LOG(NOTICE,
268 : : "No TX queues configured yet. Using default TX function.");
269 : : }
270 : :
271 : 0 : txgbe_set_rx_function(eth_dev);
272 : :
273 : 0 : return 0;
274 : : }
275 : :
276 : 0 : rte_atomic_store_explicit(&ad->link_thread_running, 0, rte_memory_order_seq_cst);
277 : 0 : rte_eth_copy_pci_info(eth_dev, pci_dev);
278 : :
279 : 0 : hw->device_id = pci_dev->id.device_id;
280 : 0 : hw->vendor_id = pci_dev->id.vendor_id;
281 : 0 : hw->subsystem_device_id = pci_dev->id.subsystem_device_id;
282 : 0 : hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
283 : 0 : hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
284 : :
285 : : /* initialize the vfta */
286 : : memset(shadow_vfta, 0, sizeof(*shadow_vfta));
287 : :
288 : : /* initialize the hw strip bitmap*/
289 : : memset(hwstrip, 0, sizeof(*hwstrip));
290 : :
291 : : /* Initialize the shared code (base driver) */
292 : 0 : err = txgbe_init_shared_code(hw);
293 [ # # ]: 0 : if (err != 0) {
294 : 0 : PMD_INIT_LOG(ERR,
295 : : "Shared code init failed for txgbevf: %d", err);
296 : 0 : return -EIO;
297 : : }
298 : :
299 : : /* init_mailbox_params */
300 : 0 : hw->mbx.init_params(hw);
301 : :
302 : : /* Reset the hw statistics */
303 : 0 : txgbevf_dev_stats_reset(eth_dev);
304 : :
305 : : /* Disable the interrupts for VF */
306 : 0 : txgbevf_intr_disable(eth_dev);
307 : :
308 : 0 : hw->mac.num_rar_entries = 128; /* The MAX of the underlying PF */
309 : 0 : err = hw->mac.reset_hw(hw);
310 : :
311 : : /*
312 : : * The VF reset operation returns the TXGBE_ERR_INVALID_MAC_ADDR when
313 : : * the underlying PF driver has not assigned a MAC address to the VF.
314 : : * In this case, assign a random MAC address.
315 : : */
316 [ # # ]: 0 : if (err != 0 && err != TXGBE_ERR_INVALID_MAC_ADDR) {
317 : 0 : PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", err);
318 : : /*
319 : : * This error code will be propagated to the app by
320 : : * rte_eth_dev_reset, so use a public error code rather than
321 : : * the internal-only TXGBE_ERR_RESET_FAILED
322 : : */
323 : 0 : return -EAGAIN;
324 : : }
325 : :
326 : : /* negotiate mailbox API version to use with the PF. */
327 : 0 : txgbevf_negotiate_api(hw);
328 : :
329 : : /* Get Rx/Tx queue count via mailbox, which is ready after reset_hw */
330 : 0 : txgbevf_get_queues(hw, &tcs, &tc);
331 : :
332 : : /* Allocate memory for storing MAC addresses */
333 : 0 : eth_dev->data->mac_addrs = rte_zmalloc("txgbevf", RTE_ETHER_ADDR_LEN *
334 : 0 : hw->mac.num_rar_entries, 0);
335 [ # # ]: 0 : if (eth_dev->data->mac_addrs == NULL) {
336 : 0 : PMD_INIT_LOG(ERR,
337 : : "Failed to allocate %u bytes needed to store "
338 : : "MAC addresses",
339 : : RTE_ETHER_ADDR_LEN * hw->mac.num_rar_entries);
340 : 0 : return -ENOMEM;
341 : : }
342 : :
343 : : /* Generate a random MAC address, if none was assigned by PF. */
344 [ # # ]: 0 : if (rte_is_zero_ether_addr(perm_addr)) {
345 : 0 : generate_random_mac_addr(perm_addr);
346 : 0 : err = txgbe_set_rar_vf(hw, 1, perm_addr->addr_bytes, 0, 1);
347 [ # # ]: 0 : if (err) {
348 : 0 : rte_free(eth_dev->data->mac_addrs);
349 : 0 : eth_dev->data->mac_addrs = NULL;
350 : 0 : return err;
351 : : }
352 : 0 : PMD_INIT_LOG(INFO, "\tVF MAC address not assigned by Host PF");
353 : 0 : PMD_INIT_LOG(INFO, "\tAssign randomly generated MAC address "
354 : : RTE_ETHER_ADDR_PRT_FMT,
355 : : RTE_ETHER_ADDR_BYTES(perm_addr));
356 : : }
357 : :
358 : : /* Copy the permanent MAC address */
359 : 0 : rte_ether_addr_copy(perm_addr, ð_dev->data->mac_addrs[0]);
360 : :
361 : : /* reset the hardware with the new settings */
362 : 0 : err = hw->mac.start_hw(hw);
363 [ # # ]: 0 : if (err) {
364 : 0 : PMD_INIT_LOG(ERR, "VF Initialization Failure: %d", err);
365 : 0 : rte_free(eth_dev->data->mac_addrs);
366 : 0 : eth_dev->data->mac_addrs = NULL;
367 : 0 : return -EIO;
368 : : }
369 : :
370 : : /* enter promiscuous mode */
371 : : txgbevf_dev_promiscuous_enable(eth_dev);
372 : :
373 : 0 : rte_intr_callback_register(intr_handle,
374 : : txgbevf_dev_interrupt_handler, eth_dev);
375 : 0 : rte_intr_enable(intr_handle);
376 : 0 : txgbevf_intr_enable(eth_dev);
377 : :
378 : : /* initialize filter info */
379 : : memset(filter_info, 0,
380 : : sizeof(struct txgbe_filter_info));
381 : :
382 : : /* initialize flow director filter list & hash */
383 : 0 : txgbe_fdir_filter_init(eth_dev);
384 : :
385 : : /* initialize 5tuple filter list */
386 : 0 : TAILQ_INIT(&filter_info->fivetuple_list);
387 : :
388 : : /* initialize flow filter lists */
389 : 0 : txgbe_filterlist_init();
390 : :
391 : 0 : PMD_INIT_LOG(DEBUG, "port %d vendorID=0x%x deviceID=0x%x mac.type=%s",
392 : : eth_dev->data->port_id, pci_dev->id.vendor_id,
393 : : pci_dev->id.device_id, "txgbe_mac_sp_vf");
394 : :
395 : 0 : return 0;
396 : : }
397 : :
398 : : /* Virtual Function device uninit */
399 : : static int
400 : 0 : eth_txgbevf_dev_uninit(struct rte_eth_dev *eth_dev)
401 : : {
402 : 0 : PMD_INIT_FUNC_TRACE();
403 : :
404 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
405 : : return 0;
406 : :
407 : 0 : txgbevf_dev_close(eth_dev);
408 : :
409 : 0 : return 0;
410 : : }
411 : :
412 : 0 : static int eth_txgbevf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
413 : : struct rte_pci_device *pci_dev)
414 : : {
415 : 0 : return rte_eth_dev_pci_generic_probe(pci_dev,
416 : : sizeof(struct txgbe_adapter), eth_txgbevf_dev_init);
417 : : }
418 : :
419 : 0 : static int eth_txgbevf_pci_remove(struct rte_pci_device *pci_dev)
420 : : {
421 : 0 : return rte_eth_dev_pci_generic_remove(pci_dev, eth_txgbevf_dev_uninit);
422 : : }
423 : :
424 : : /*
425 : : * virtual function driver struct
426 : : */
427 : : static struct rte_pci_driver rte_txgbevf_pmd = {
428 : : .id_table = pci_id_txgbevf_map,
429 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING,
430 : : .probe = eth_txgbevf_pci_probe,
431 : : .remove = eth_txgbevf_pci_remove,
432 : : };
433 : :
434 : 0 : static int txgbevf_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
435 : : struct rte_eth_xstat_name *xstats_names, unsigned int limit)
436 : : {
437 : : unsigned int i;
438 : :
439 [ # # ]: 0 : if (limit < TXGBEVF_NB_XSTATS && xstats_names != NULL)
440 : : return -ENOMEM;
441 : :
442 [ # # ]: 0 : if (xstats_names != NULL)
443 [ # # ]: 0 : for (i = 0; i < TXGBEVF_NB_XSTATS; i++)
444 : 0 : snprintf(xstats_names[i].name,
445 : : sizeof(xstats_names[i].name),
446 : 0 : "%s", rte_txgbevf_stats_strings[i].name);
447 : : return TXGBEVF_NB_XSTATS;
448 : : }
449 : :
450 : : static void
451 : 0 : txgbevf_update_stats(struct rte_eth_dev *dev)
452 : : {
453 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
454 : : struct txgbevf_hw_stats *hw_stats = (struct txgbevf_hw_stats *)
455 : : TXGBE_DEV_STATS(dev);
456 : : unsigned int i;
457 : :
458 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
459 : : /* Good Rx packet, include VF loopback */
460 [ # # ]: 0 : TXGBE_UPDCNT32(TXGBE_QPRXPKT(i),
461 : : hw_stats->qp[i].last_vfgprc, hw_stats->qp[i].vfgprc);
462 : :
463 : : /* Good Rx octets, include VF loopback */
464 [ # # ]: 0 : TXGBE_UPDCNT36(TXGBE_QPRXOCTL(i),
465 : : hw_stats->qp[i].last_vfgorc, hw_stats->qp[i].vfgorc);
466 : :
467 : : /* Rx Multicst Packet */
468 [ # # ]: 0 : TXGBE_UPDCNT32(TXGBE_QPRXMPKT(i),
469 : : hw_stats->qp[i].last_vfmprc, hw_stats->qp[i].vfmprc);
470 : : }
471 : 0 : hw->rx_loaded = 0;
472 : :
473 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
474 : : /* Good Tx packet, include VF loopback */
475 [ # # ]: 0 : TXGBE_UPDCNT32(TXGBE_QPTXPKT(i),
476 : : hw_stats->qp[i].last_vfgptc, hw_stats->qp[i].vfgptc);
477 : :
478 : : /* Good Tx octets, include VF loopback */
479 [ # # ]: 0 : TXGBE_UPDCNT36(TXGBE_QPTXOCTL(i),
480 : : hw_stats->qp[i].last_vfgotc, hw_stats->qp[i].vfgotc);
481 : : }
482 : 0 : hw->offset_loaded = 0;
483 : 0 : }
484 : :
485 : : static int
486 : 0 : txgbevf_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
487 : : unsigned int n)
488 : : {
489 : 0 : struct txgbevf_hw_stats *hw_stats = (struct txgbevf_hw_stats *)
490 : 0 : TXGBE_DEV_STATS(dev);
491 : : unsigned int i;
492 : :
493 [ # # ]: 0 : if (n < TXGBEVF_NB_XSTATS)
494 : : return TXGBEVF_NB_XSTATS;
495 : :
496 : 0 : txgbevf_update_stats(dev);
497 : :
498 [ # # ]: 0 : if (!xstats)
499 : : return 0;
500 : :
501 : : /* Extended stats */
502 [ # # ]: 0 : for (i = 0; i < TXGBEVF_NB_XSTATS; i++) {
503 : 0 : xstats[i].id = i;
504 : 0 : xstats[i].value = *(uint64_t *)(((char *)hw_stats) +
505 : 0 : rte_txgbevf_stats_strings[i].offset);
506 : : }
507 : :
508 : : return TXGBEVF_NB_XSTATS;
509 : : }
510 : :
511 : : static int
512 : 0 : txgbevf_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
513 : : struct eth_queue_stats *qstats __rte_unused)
514 : : {
515 : : struct txgbevf_hw_stats *hw_stats = (struct txgbevf_hw_stats *)
516 : 0 : TXGBE_DEV_STATS(dev);
517 : : uint32_t i;
518 : :
519 : 0 : txgbevf_update_stats(dev);
520 : :
521 [ # # ]: 0 : if (stats == NULL)
522 : : return -EINVAL;
523 : :
524 : 0 : stats->ipackets = 0;
525 : 0 : stats->ibytes = 0;
526 : 0 : stats->opackets = 0;
527 : 0 : stats->obytes = 0;
528 : :
529 [ # # ]: 0 : for (i = 0; i < 8; i++) {
530 : 0 : stats->ipackets += hw_stats->qp[i].vfgprc;
531 : 0 : stats->ibytes += hw_stats->qp[i].vfgorc;
532 : 0 : stats->opackets += hw_stats->qp[i].vfgptc;
533 : 0 : stats->obytes += hw_stats->qp[i].vfgotc;
534 : : }
535 : :
536 : : return 0;
537 : : }
538 : :
539 : : static int
540 : 0 : txgbevf_dev_stats_reset(struct rte_eth_dev *dev)
541 : : {
542 : : struct txgbevf_hw_stats *hw_stats = (struct txgbevf_hw_stats *)
543 : 0 : TXGBE_DEV_STATS(dev);
544 : : uint32_t i;
545 : :
546 : : /* Sync HW register to the last stats */
547 : : txgbevf_dev_stats_get(dev, NULL, NULL);
548 : :
549 : : /* reset HW current stats*/
550 [ # # ]: 0 : for (i = 0; i < 8; i++) {
551 : 0 : hw_stats->qp[i].vfgprc = 0;
552 : 0 : hw_stats->qp[i].vfgorc = 0;
553 : 0 : hw_stats->qp[i].vfgptc = 0;
554 : 0 : hw_stats->qp[i].vfgotc = 0;
555 : : }
556 : :
557 : 0 : return 0;
558 : : }
559 : :
560 : : static int
561 : 0 : txgbevf_dev_info_get(struct rte_eth_dev *dev,
562 : : struct rte_eth_dev_info *dev_info)
563 : : {
564 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
565 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
566 : :
567 : 0 : dev_info->max_rx_queues = (uint16_t)hw->mac.max_rx_queues;
568 : 0 : dev_info->max_tx_queues = (uint16_t)hw->mac.max_tx_queues;
569 : 0 : dev_info->min_rx_bufsize = 1024;
570 : 0 : dev_info->max_rx_pktlen = TXGBE_FRAME_SIZE_MAX;
571 : 0 : dev_info->max_mac_addrs = hw->mac.num_rar_entries;
572 : 0 : dev_info->max_hash_mac_addrs = TXGBE_VMDQ_NUM_UC_MAC;
573 : 0 : dev_info->max_vfs = pci_dev->max_vfs;
574 : 0 : dev_info->max_vmdq_pools = RTE_ETH_64_POOLS;
575 : 0 : dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
576 : 0 : dev_info->rx_queue_offload_capa = txgbe_get_rx_queue_offloads(dev);
577 : 0 : dev_info->rx_offload_capa = (txgbe_get_rx_port_offloads(dev) |
578 : 0 : dev_info->rx_queue_offload_capa);
579 : 0 : dev_info->tx_queue_offload_capa = txgbe_get_tx_queue_offloads(dev);
580 : 0 : dev_info->tx_offload_capa = txgbe_get_tx_port_offloads(dev);
581 : 0 : dev_info->hash_key_size = TXGBE_HKEY_MAX_INDEX * sizeof(uint32_t);
582 : 0 : dev_info->reta_size = RTE_ETH_RSS_RETA_SIZE_128;
583 : 0 : dev_info->flow_type_rss_offloads = TXGBE_RSS_OFFLOAD_ALL;
584 : :
585 : 0 : dev_info->default_rxconf = (struct rte_eth_rxconf) {
586 : : .rx_thresh = {
587 : : .pthresh = TXGBE_DEFAULT_RX_PTHRESH,
588 : : .hthresh = TXGBE_DEFAULT_RX_HTHRESH,
589 : : .wthresh = TXGBE_DEFAULT_RX_WTHRESH,
590 : : },
591 : : .rx_free_thresh = TXGBE_DEFAULT_RX_FREE_THRESH,
592 : : .rx_drop_en = 0,
593 : : .offloads = 0,
594 : : };
595 : :
596 : 0 : dev_info->default_txconf = (struct rte_eth_txconf) {
597 : : .tx_thresh = {
598 : : .pthresh = TXGBE_DEFAULT_TX_PTHRESH,
599 : : .hthresh = TXGBE_DEFAULT_TX_HTHRESH,
600 : : .wthresh = TXGBE_DEFAULT_TX_WTHRESH,
601 : : },
602 : : .tx_free_thresh = TXGBE_DEFAULT_TX_FREE_THRESH,
603 : : .offloads = 0,
604 : : };
605 : :
606 : 0 : dev_info->rx_desc_lim = rx_desc_lim;
607 : 0 : dev_info->tx_desc_lim = tx_desc_lim;
608 : :
609 : 0 : dev_info->err_handle_mode = RTE_ETH_ERROR_HANDLE_MODE_PASSIVE;
610 : :
611 : 0 : return 0;
612 : : }
613 : :
614 : : static int
615 : 0 : txgbevf_dev_link_update(struct rte_eth_dev *dev, int wait_to_complete)
616 : : {
617 : 0 : return txgbe_dev_link_update_share(dev, wait_to_complete);
618 : : }
619 : :
620 : : /*
621 : : * Virtual Function operations
622 : : */
623 : : static void
624 : 0 : txgbevf_intr_disable(struct rte_eth_dev *dev)
625 : : {
626 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
627 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
628 : :
629 : 0 : PMD_INIT_FUNC_TRACE();
630 : :
631 : : /* Clear interrupt mask to stop from interrupts being generated */
632 : : wr32(hw, TXGBE_VFIMS, TXGBE_VFIMS_MASK);
633 : :
634 : : txgbe_flush(hw);
635 : :
636 : : /* Clear mask value. */
637 : 0 : intr->mask_misc = TXGBE_VFIMS_MASK;
638 : 0 : }
639 : :
640 : : static void
641 : 0 : txgbevf_intr_enable(struct rte_eth_dev *dev)
642 : : {
643 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
644 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
645 : :
646 : 0 : PMD_INIT_FUNC_TRACE();
647 : :
648 : : /* VF enable interrupt autoclean */
649 : : wr32(hw, TXGBE_VFIMC, TXGBE_VFIMC_MASK);
650 : :
651 : : txgbe_flush(hw);
652 : :
653 : 0 : intr->mask_misc = 0;
654 : 0 : }
655 : :
656 : : static int
657 : 0 : txgbevf_dev_configure(struct rte_eth_dev *dev)
658 : : {
659 : 0 : struct rte_eth_conf *conf = &dev->data->dev_conf;
660 : 0 : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
661 : :
662 : 0 : PMD_INIT_LOG(DEBUG, "Configured Virtual Function port id: %d",
663 : : dev->data->port_id);
664 : :
665 [ # # ]: 0 : if (dev->data->dev_conf.rxmode.mq_mode & RTE_ETH_MQ_RX_RSS_FLAG)
666 : 0 : dev->data->dev_conf.rxmode.offloads |= RTE_ETH_RX_OFFLOAD_RSS_HASH;
667 : :
668 : : /*
669 : : * VF has no ability to enable/disable HW CRC
670 : : * Keep the persistent behavior the same as Host PF
671 : : */
672 : : #ifndef RTE_LIBRTE_TXGBE_PF_DISABLE_STRIP_CRC
673 [ # # ]: 0 : if (conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC) {
674 : 0 : PMD_INIT_LOG(NOTICE, "VF can't disable HW CRC Strip");
675 : 0 : conf->rxmode.offloads &= ~RTE_ETH_RX_OFFLOAD_KEEP_CRC;
676 : : }
677 : : #else
678 : : if (!(conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_KEEP_CRC)) {
679 : : PMD_INIT_LOG(NOTICE, "VF can't enable HW CRC Strip");
680 : : conf->rxmode.offloads |= RTE_ETH_RX_OFFLOAD_KEEP_CRC;
681 : : }
682 : : #endif
683 : :
684 : : /*
685 : : * Initialize to TRUE. If any of Rx queues doesn't meet the bulk
686 : : * allocation or vector Rx preconditions we will reset it.
687 : : */
688 : 0 : adapter->rx_bulk_alloc_allowed = true;
689 : 0 : adapter->rx_vec_allowed = true;
690 : :
691 : 0 : return 0;
692 : : }
693 : :
694 : : static int
695 : 0 : txgbevf_dev_start(struct rte_eth_dev *dev)
696 : : {
697 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
698 : : uint32_t intr_vector = 0;
699 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
700 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
701 : :
702 : : int err, mask = 0;
703 : :
704 : 0 : PMD_INIT_FUNC_TRACE();
705 : :
706 : : /* Stop the link setup handler before resetting the HW. */
707 : 0 : txgbe_dev_wait_setup_link_complete(dev, 0);
708 : :
709 : 0 : err = hw->mac.reset_hw(hw);
710 [ # # ]: 0 : if (err) {
711 : 0 : PMD_INIT_LOG(ERR, "Unable to reset vf hardware (%d)", err);
712 : 0 : return err;
713 : : }
714 : 0 : hw->mac.get_link_status = true;
715 : 0 : hw->dev_start = true;
716 : :
717 : : /* negotiate mailbox API version to use with the PF. */
718 : 0 : txgbevf_negotiate_api(hw);
719 : :
720 : 0 : txgbevf_dev_tx_init(dev);
721 : :
722 : : /* This can fail when allocating mbufs for descriptor rings */
723 : 0 : err = txgbevf_dev_rx_init(dev);
724 : :
725 : : /**
726 : : * In this case, reuses the MAC address assigned by VF
727 : : * initialization.
728 : : */
729 [ # # ]: 0 : if (err != 0 && err != TXGBE_ERR_INVALID_MAC_ADDR) {
730 : 0 : PMD_INIT_LOG(ERR, "Unable to initialize RX hardware (%d)", err);
731 : 0 : txgbe_dev_clear_queues(dev);
732 : 0 : return err;
733 : : }
734 : :
735 : : /* Set vfta */
736 : 0 : txgbevf_set_vfta_all(dev, 1);
737 : :
738 : : /* Set HW strip */
739 : : mask = RTE_ETH_VLAN_STRIP_MASK | RTE_ETH_VLAN_FILTER_MASK |
740 : : RTE_ETH_VLAN_EXTEND_MASK;
741 : 0 : err = txgbevf_vlan_offload_config(dev, mask);
742 [ # # ]: 0 : if (err) {
743 : 0 : PMD_INIT_LOG(ERR, "Unable to set VLAN offload (%d)", err);
744 : 0 : txgbe_dev_clear_queues(dev);
745 : 0 : return err;
746 : : }
747 : :
748 : 0 : txgbevf_dev_rxtx_start(dev);
749 : :
750 : : /* check and configure queue intr-vector mapping */
751 [ # # ]: 0 : if (rte_intr_cap_multiple(intr_handle) &&
752 [ # # ]: 0 : dev->data->dev_conf.intr_conf.rxq) {
753 : : /* According to datasheet, only vector 0/1/2 can be used,
754 : : * now only one vector is used for Rx queue
755 : : */
756 : : intr_vector = 1;
757 [ # # ]: 0 : if (rte_intr_efd_enable(intr_handle, intr_vector)) {
758 : 0 : txgbe_dev_clear_queues(dev);
759 : 0 : return -1;
760 : : }
761 : : }
762 : :
763 [ # # ]: 0 : if (rte_intr_dp_is_en(intr_handle)) {
764 [ # # ]: 0 : if (rte_intr_vec_list_alloc(intr_handle, "intr_vec",
765 : 0 : dev->data->nb_rx_queues)) {
766 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate %d rx_queues"
767 : : " intr_vec", dev->data->nb_rx_queues);
768 : 0 : txgbe_dev_clear_queues(dev);
769 : 0 : return -ENOMEM;
770 : : }
771 : : }
772 : 0 : txgbevf_configure_msix(dev);
773 : :
774 : : /* When a VF port is bound to VFIO-PCI, only miscellaneous interrupt
775 : : * is mapped to VFIO vector 0 in eth_txgbevf_dev_init( ).
776 : : * If previous VFIO interrupt mapping setting in eth_txgbevf_dev_init( )
777 : : * is not cleared, it will fail when following rte_intr_enable( ) tries
778 : : * to map Rx queue interrupt to other VFIO vectors.
779 : : * So clear uio/vfio intr/evevnfd first to avoid failure.
780 : : */
781 : 0 : rte_intr_disable(intr_handle);
782 : :
783 : 0 : rte_intr_enable(intr_handle);
784 : :
785 : : /* Re-enable interrupt for VF */
786 : 0 : txgbevf_intr_enable(dev);
787 : :
788 : : /*
789 : : * Update link status right before return, because it may
790 : : * start link configuration process in a separate thread.
791 : : */
792 : : txgbevf_dev_link_update(dev, 0);
793 : :
794 : 0 : hw->adapter_stopped = false;
795 : :
796 : 0 : return 0;
797 : : }
798 : :
799 : : static int
800 : 0 : txgbevf_dev_stop(struct rte_eth_dev *dev)
801 : : {
802 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
803 : : struct txgbe_adapter *adapter = TXGBE_DEV_ADAPTER(dev);
804 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
805 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
806 : :
807 [ # # ]: 0 : if (hw->adapter_stopped)
808 : : return 0;
809 : :
810 : 0 : PMD_INIT_FUNC_TRACE();
811 : :
812 : 0 : txgbe_dev_wait_setup_link_complete(dev, 0);
813 : :
814 : 0 : txgbevf_intr_disable(dev);
815 : :
816 : 0 : hw->adapter_stopped = 1;
817 : 0 : hw->mac.stop_hw(hw);
818 : :
819 : : /*
820 : : * Clear what we set, but we still keep shadow_vfta to
821 : : * restore after device starts
822 : : */
823 : 0 : txgbevf_set_vfta_all(dev, 0);
824 : :
825 : : /* Clear stored conf */
826 : 0 : dev->data->scattered_rx = 0;
827 : :
828 : 0 : txgbe_dev_clear_queues(dev);
829 : :
830 : : /* Clean datapath event and queue/vec mapping */
831 : 0 : rte_intr_efd_disable(intr_handle);
832 : 0 : rte_intr_vec_list_free(intr_handle);
833 : :
834 : 0 : adapter->rss_reta_updated = 0;
835 : 0 : hw->dev_start = false;
836 : :
837 : 0 : return 0;
838 : : }
839 : :
840 : : static int
841 : 0 : txgbevf_dev_close(struct rte_eth_dev *dev)
842 : : {
843 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
844 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
845 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
846 : : int ret;
847 : :
848 : 0 : PMD_INIT_FUNC_TRACE();
849 [ # # ]: 0 : if (rte_eal_process_type() != RTE_PROC_PRIMARY)
850 : : return 0;
851 : :
852 : 0 : hw->mac.reset_hw(hw);
853 : :
854 : 0 : ret = txgbevf_dev_stop(dev);
855 : :
856 : 0 : txgbe_dev_free_queues(dev);
857 : :
858 : : /**
859 : : * Remove the VF MAC address ro ensure
860 : : * that the VF traffic goes to the PF
861 : : * after stop, close and detach of the VF
862 : : **/
863 : 0 : txgbevf_remove_mac_addr(dev, 0);
864 : :
865 : 0 : dev->rx_pkt_burst = NULL;
866 : 0 : dev->tx_pkt_burst = NULL;
867 : :
868 : : /* Disable the interrupts for VF */
869 : 0 : txgbevf_intr_disable(dev);
870 : :
871 : 0 : rte_free(dev->data->mac_addrs);
872 : 0 : dev->data->mac_addrs = NULL;
873 : :
874 : 0 : rte_intr_disable(intr_handle);
875 : 0 : rte_intr_callback_unregister(intr_handle,
876 : : txgbevf_dev_interrupt_handler, dev);
877 : :
878 : : /* remove all the fdir filters & hash */
879 : 0 : txgbe_fdir_filter_uninit(dev);
880 : :
881 : : /* Remove all ntuple filters of the device */
882 : 0 : txgbe_ntuple_filter_uninit(dev);
883 : :
884 : : /* clear all the filters list */
885 : 0 : txgbe_filterlist_flush();
886 : :
887 : 0 : return ret;
888 : : }
889 : :
890 : : /*
891 : : * Reset VF device
892 : : */
893 : : static int
894 : 0 : txgbevf_dev_reset(struct rte_eth_dev *dev)
895 : : {
896 : : int ret;
897 : :
898 : 0 : ret = eth_txgbevf_dev_uninit(dev);
899 [ # # ]: 0 : if (ret)
900 : : return ret;
901 : :
902 : 0 : ret = eth_txgbevf_dev_init(dev);
903 : :
904 : 0 : return ret;
905 : : }
906 : :
907 : 0 : static void txgbevf_set_vfta_all(struct rte_eth_dev *dev, bool on)
908 : : {
909 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
910 : : struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(dev);
911 : : int i = 0, j = 0, vfta = 0, mask = 1;
912 : :
913 [ # # ]: 0 : for (i = 0; i < TXGBE_VFTA_SIZE; i++) {
914 : 0 : vfta = shadow_vfta->vfta[i];
915 [ # # ]: 0 : if (vfta) {
916 : : mask = 1;
917 [ # # ]: 0 : for (j = 0; j < 32; j++) {
918 [ # # ]: 0 : if (vfta & mask)
919 : 0 : hw->mac.set_vfta(hw, (i << 5) + j, 0,
920 : : on, false);
921 : 0 : mask <<= 1;
922 : : }
923 : : }
924 : : }
925 : 0 : }
926 : :
927 : : static int
928 : 0 : txgbevf_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
929 : : {
930 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
931 : : struct txgbe_vfta *shadow_vfta = TXGBE_DEV_VFTA(dev);
932 : : uint32_t vid_idx = 0;
933 : : uint32_t vid_bit = 0;
934 : : int ret = 0;
935 : :
936 : 0 : PMD_INIT_FUNC_TRACE();
937 : :
938 : : /* vind is not used in VF driver, set to 0, check txgbe_set_vfta_vf */
939 : 0 : ret = hw->mac.set_vfta(hw, vlan_id, 0, !!on, false);
940 [ # # ]: 0 : if (ret) {
941 : 0 : PMD_INIT_LOG(ERR, "Unable to set VF vlan");
942 : 0 : return ret;
943 : : }
944 : 0 : vid_idx = (uint32_t)((vlan_id >> 5) & 0x7F);
945 : 0 : vid_bit = (uint32_t)(1 << (vlan_id & 0x1F));
946 : :
947 : : /* Save what we set and restore it after device reset */
948 [ # # ]: 0 : if (on)
949 : 0 : shadow_vfta->vfta[vid_idx] |= vid_bit;
950 : : else
951 : 0 : shadow_vfta->vfta[vid_idx] &= ~vid_bit;
952 : :
953 : : return 0;
954 : : }
955 : :
956 : : static void
957 : 0 : txgbevf_vlan_strip_q_set(struct rte_eth_dev *dev, uint16_t queue, int on)
958 : : {
959 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
960 : : uint32_t ctrl;
961 : :
962 : 0 : PMD_INIT_FUNC_TRACE();
963 : :
964 [ # # ]: 0 : if (queue >= hw->mac.max_rx_queues)
965 : : return;
966 : :
967 : 0 : ctrl = rd32(hw, TXGBE_RXCFG(queue));
968 [ # # ]: 0 : if (on)
969 : 0 : ctrl |= TXGBE_RXCFG_VLAN;
970 : : else
971 : 0 : ctrl &= ~TXGBE_RXCFG_VLAN;
972 : : wr32(hw, TXGBE_RXCFG(queue), ctrl);
973 : :
974 : 0 : txgbe_vlan_hw_strip_bitmap_set(dev, queue, on);
975 : : }
976 : :
977 : : static void
978 : 0 : txgbevf_vlan_strip_queue_set(struct rte_eth_dev *dev, uint16_t queue, int on)
979 : : {
980 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
981 : :
982 [ # # ]: 0 : if (!hw->adapter_stopped) {
983 : 0 : PMD_DRV_LOG(ERR, "Please stop port first");
984 : 0 : return;
985 : : }
986 : :
987 : 0 : txgbevf_vlan_strip_q_set(dev, queue, on);
988 : : }
989 : :
990 : : static int
991 : 0 : txgbevf_vlan_offload_config(struct rte_eth_dev *dev, int mask)
992 : : {
993 : : struct txgbe_rx_queue *rxq;
994 : : uint16_t i;
995 : : int on = 0;
996 : :
997 : : /* VF function only support hw strip feature, others are not support */
998 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK) {
999 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
1000 : 0 : rxq = dev->data->rx_queues[i];
1001 : 0 : on = !!(rxq->offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP);
1002 : 0 : txgbevf_vlan_strip_q_set(dev, i, on);
1003 : : }
1004 : : }
1005 : :
1006 : 0 : return 0;
1007 : : }
1008 : :
1009 : : static int
1010 : 0 : txgbevf_vlan_offload_set(struct rte_eth_dev *dev, int mask)
1011 : : {
1012 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1013 : :
1014 [ # # # # ]: 0 : if (!hw->adapter_stopped && (mask & RTE_ETH_VLAN_STRIP_MASK)) {
1015 : 0 : PMD_DRV_LOG(ERR, "Please stop port first");
1016 : 0 : return -EPERM;
1017 : : }
1018 : :
1019 : 0 : txgbe_config_vlan_strip_on_all_queues(dev, mask);
1020 : :
1021 : 0 : txgbevf_vlan_offload_config(dev, mask);
1022 : :
1023 : 0 : return 0;
1024 : : }
1025 : :
1026 : : static int
1027 : 0 : txgbevf_dev_rx_queue_intr_enable(struct rte_eth_dev *dev, uint16_t queue_id)
1028 : : {
1029 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
1030 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
1031 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1032 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1033 : : uint32_t vec = TXGBE_MISC_VEC_ID;
1034 : :
1035 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle))
1036 : : vec = TXGBE_RX_VEC_START;
1037 : 0 : intr->mask_misc &= ~(1 << vec);
1038 : : RTE_SET_USED(queue_id);
1039 : 0 : wr32(hw, TXGBE_VFIMC, ~intr->mask_misc);
1040 : :
1041 : 0 : rte_intr_enable(intr_handle);
1042 : :
1043 : 0 : return 0;
1044 : : }
1045 : :
1046 : : static int
1047 : 0 : txgbevf_dev_rx_queue_intr_disable(struct rte_eth_dev *dev, uint16_t queue_id)
1048 : : {
1049 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1050 : : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1051 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
1052 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
1053 : : uint32_t vec = TXGBE_MISC_VEC_ID;
1054 : :
1055 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle))
1056 : : vec = TXGBE_RX_VEC_START;
1057 : 0 : intr->mask_misc |= (1 << vec);
1058 : : RTE_SET_USED(queue_id);
1059 : : wr32(hw, TXGBE_VFIMS, intr->mask_misc);
1060 : :
1061 : 0 : return 0;
1062 : : }
1063 : :
1064 : : static void
1065 : 0 : txgbevf_set_ivar_map(struct txgbe_hw *hw, int8_t direction,
1066 : : uint8_t queue, uint8_t msix_vector)
1067 : : {
1068 : : uint32_t tmp, idx;
1069 : :
1070 [ # # ]: 0 : if (direction == -1) {
1071 : : /* other causes */
1072 : 0 : msix_vector |= TXGBE_VFIVAR_VLD;
1073 : : tmp = rd32(hw, TXGBE_VFIVARMISC);
1074 : 0 : tmp &= ~0xFF;
1075 : 0 : tmp |= msix_vector;
1076 : : wr32(hw, TXGBE_VFIVARMISC, tmp);
1077 : : } else {
1078 : : /* rx or tx cause */
1079 : 0 : msix_vector |= TXGBE_VFIVAR_VLD; /* Workaround for ICR lost */
1080 : 0 : idx = ((16 * (queue & 1)) + (8 * direction));
1081 : 0 : tmp = rd32(hw, TXGBE_VFIVAR(queue >> 1));
1082 : 0 : tmp &= ~(0xFF << idx);
1083 : 0 : tmp |= (msix_vector << idx);
1084 : : wr32(hw, TXGBE_VFIVAR(queue >> 1), tmp);
1085 : : }
1086 : 0 : }
1087 : :
1088 : : static void
1089 : 0 : txgbevf_configure_msix(struct rte_eth_dev *dev)
1090 : : {
1091 : 0 : struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
1092 : 0 : struct rte_intr_handle *intr_handle = pci_dev->intr_handle;
1093 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1094 : : uint32_t q_idx;
1095 : : uint32_t vector_idx = TXGBE_MISC_VEC_ID;
1096 : : uint32_t base = TXGBE_MISC_VEC_ID;
1097 : :
1098 : : /* Configure VF other cause ivar */
1099 : : txgbevf_set_ivar_map(hw, -1, 1, vector_idx);
1100 : :
1101 : : /* won't configure msix register if no mapping is done
1102 : : * between intr vector and event fd.
1103 : : */
1104 [ # # ]: 0 : if (!rte_intr_dp_is_en(intr_handle))
1105 : : return;
1106 : :
1107 [ # # ]: 0 : if (rte_intr_allow_others(intr_handle)) {
1108 : : base = TXGBE_RX_VEC_START;
1109 : : vector_idx = TXGBE_RX_VEC_START;
1110 : : }
1111 : :
1112 : : /* Configure all RX queues of VF */
1113 [ # # ]: 0 : for (q_idx = 0; q_idx < dev->data->nb_rx_queues; q_idx++) {
1114 : : /* Force all queue use vector 0,
1115 : : * as TXGBE_VF_MAXMSIVECTOR = 1
1116 : : */
1117 : 0 : txgbevf_set_ivar_map(hw, 0, q_idx, vector_idx);
1118 : 0 : rte_intr_vec_list_index_set(intr_handle, q_idx,
1119 : : vector_idx);
1120 : 0 : if (vector_idx < base + rte_intr_nb_efd_get(intr_handle)
1121 [ # # ]: 0 : - 1)
1122 : 0 : vector_idx++;
1123 : : }
1124 : :
1125 : : /* As RX queue setting above show, all queues use the vector 0.
1126 : : * Set only the ITR value of TXGBE_MISC_VEC_ID.
1127 : : */
1128 : : wr32(hw, TXGBE_ITR(TXGBE_MISC_VEC_ID),
1129 : : TXGBE_ITR_IVAL(TXGBE_QUEUE_ITR_INTERVAL_DEFAULT)
1130 : : | TXGBE_ITR_WRDSA);
1131 : : }
1132 : :
1133 : : static int
1134 : 0 : txgbevf_add_mac_addr(struct rte_eth_dev *dev, struct rte_ether_addr *mac_addr,
1135 : : __rte_unused uint32_t index,
1136 : : __rte_unused uint32_t pool)
1137 : : {
1138 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1139 : : int err;
1140 : :
1141 : : /*
1142 : : * On a VF, adding again the same MAC addr is not an idempotent
1143 : : * operation. Trap this case to avoid exhausting the [very limited]
1144 : : * set of PF resources used to store VF MAC addresses.
1145 : : */
1146 [ # # ]: 0 : if (memcmp(hw->mac.perm_addr, mac_addr,
1147 : : sizeof(struct rte_ether_addr)) == 0)
1148 : : return -1;
1149 : 0 : err = txgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
1150 [ # # ]: 0 : if (err != 0)
1151 : 0 : PMD_DRV_LOG(ERR, "Unable to add MAC address "
1152 : : RTE_ETHER_ADDR_PRT_FMT " - err=%d",
1153 : : RTE_ETHER_ADDR_BYTES(mac_addr), err);
1154 : : return err;
1155 : : }
1156 : :
1157 : : static void
1158 : 0 : txgbevf_remove_mac_addr(struct rte_eth_dev *dev, uint32_t index)
1159 : : {
1160 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1161 : 0 : struct rte_ether_addr *perm_addr =
1162 : : (struct rte_ether_addr *)hw->mac.perm_addr;
1163 : : struct rte_ether_addr *mac_addr;
1164 : : uint32_t i;
1165 : : int err;
1166 : :
1167 : : /*
1168 : : * The TXGBE_VF_SET_MACVLAN command of the txgbe-pf driver does
1169 : : * not support the deletion of a given MAC address.
1170 : : * Instead, it imposes to delete all MAC addresses, then to add again
1171 : : * all MAC addresses with the exception of the one to be deleted.
1172 : : */
1173 : 0 : (void)txgbevf_set_uc_addr_vf(hw, 0, NULL);
1174 : :
1175 : : /*
1176 : : * Add again all MAC addresses, with the exception of the deleted one
1177 : : * and of the permanent MAC address.
1178 : : */
1179 : 0 : for (i = 0, mac_addr = dev->data->mac_addrs;
1180 [ # # ]: 0 : i < hw->mac.num_rar_entries; i++, mac_addr++) {
1181 : : /* Skip the deleted MAC address */
1182 [ # # ]: 0 : if (i == index)
1183 : 0 : continue;
1184 : : /* Skip NULL MAC addresses */
1185 [ # # ]: 0 : if (rte_is_zero_ether_addr(mac_addr))
1186 : 0 : continue;
1187 : : /* Skip the permanent MAC address */
1188 [ # # ]: 0 : if (memcmp(perm_addr, mac_addr,
1189 : : sizeof(struct rte_ether_addr)) == 0)
1190 : 0 : continue;
1191 : 0 : err = txgbevf_set_uc_addr_vf(hw, 2, mac_addr->addr_bytes);
1192 [ # # ]: 0 : if (err != 0)
1193 : 0 : PMD_DRV_LOG(ERR,
1194 : : "Adding again MAC address "
1195 : : RTE_ETHER_ADDR_PRT_FMT " failed "
1196 : : "err=%d",
1197 : : RTE_ETHER_ADDR_BYTES(mac_addr), err);
1198 : : }
1199 : 0 : }
1200 : :
1201 : : static int
1202 : 0 : txgbevf_set_default_mac_addr(struct rte_eth_dev *dev,
1203 : : struct rte_ether_addr *addr)
1204 : : {
1205 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1206 : :
1207 : 0 : hw->mac.set_rar(hw, 0, (void *)addr, 0, 0);
1208 : :
1209 : 0 : return 0;
1210 : : }
1211 : :
1212 : : static int
1213 : 0 : txgbevf_dev_set_mtu(struct rte_eth_dev *dev, uint16_t mtu)
1214 : : {
1215 : : struct txgbe_hw *hw;
1216 : 0 : uint32_t max_frame = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN;
1217 : 0 : struct rte_eth_dev_data *dev_data = dev->data;
1218 : :
1219 : 0 : hw = TXGBE_DEV_HW(dev);
1220 : :
1221 : 0 : if (mtu < RTE_ETHER_MIN_MTU ||
1222 [ # # ]: 0 : max_frame > RTE_ETHER_MAX_JUMBO_FRAME_LEN)
1223 : : return -EINVAL;
1224 : :
1225 : : /* If device is started, refuse mtu that requires the support of
1226 : : * scattered packets when this feature has not been enabled before.
1227 : : */
1228 [ # # ]: 0 : if (dev_data->dev_started && !dev_data->scattered_rx &&
1229 : 0 : (max_frame + 2 * RTE_VLAN_HLEN >
1230 [ # # ]: 0 : dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM)) {
1231 : 0 : PMD_INIT_LOG(ERR, "Stop port first.");
1232 : 0 : return -EINVAL;
1233 : : }
1234 : :
1235 : : /*
1236 : : * When supported by the underlying PF driver, use the TXGBE_VF_SET_MTU
1237 : : * request of the version 2.0 of the mailbox API.
1238 : : * For now, use the TXGBE_VF_SET_LPE request of the version 1.0
1239 : : * of the mailbox API.
1240 : : */
1241 [ # # ]: 0 : if (txgbevf_rlpml_set_vf(hw, max_frame))
1242 : 0 : return -EINVAL;
1243 : :
1244 : : return 0;
1245 : : }
1246 : :
1247 : : static int
1248 : : txgbevf_get_reg_length(struct rte_eth_dev *dev __rte_unused)
1249 : : {
1250 : : int count = 0;
1251 : : int g_ind = 0;
1252 : : const struct reg_info *reg_group;
1253 : :
1254 [ # # # # ]: 0 : while ((reg_group = txgbevf_regs[g_ind++]))
1255 : 0 : count += txgbe_regs_group_count(reg_group);
1256 : :
1257 : : return count;
1258 : : }
1259 : :
1260 : : static int
1261 : 0 : txgbevf_get_regs(struct rte_eth_dev *dev,
1262 : : struct rte_dev_reg_info *regs)
1263 : : {
1264 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1265 : 0 : uint32_t *data = regs->data;
1266 : : int g_ind = 0;
1267 : : int count = 0;
1268 : : const struct reg_info *reg_group;
1269 : :
1270 [ # # ]: 0 : if (data == NULL) {
1271 : 0 : regs->length = txgbevf_get_reg_length(dev);
1272 : 0 : regs->width = sizeof(uint32_t);
1273 : 0 : return 0;
1274 : : }
1275 : :
1276 : : /* Support only full register dump */
1277 [ # # ]: 0 : if (regs->length == 0 ||
1278 [ # # ]: 0 : regs->length == (uint32_t)txgbevf_get_reg_length(dev)) {
1279 : 0 : regs->version = hw->mac.type << 24 | hw->revision_id << 16 |
1280 : 0 : hw->device_id;
1281 [ # # ]: 0 : while ((reg_group = txgbevf_regs[g_ind++]))
1282 : 0 : count += txgbe_read_regs_group(dev, &data[count],
1283 : : reg_group);
1284 : : return 0;
1285 : : }
1286 : :
1287 : : return -ENOTSUP;
1288 : : }
1289 : :
1290 : : static int
1291 : 0 : txgbevf_dev_promiscuous_enable(struct rte_eth_dev *dev)
1292 : : {
1293 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1294 : : int ret;
1295 : :
1296 [ # # # ]: 0 : switch (hw->mac.update_xcast_mode(hw, TXGBEVF_XCAST_MODE_PROMISC)) {
1297 : : case 0:
1298 : : ret = 0;
1299 : : break;
1300 : 0 : case TXGBE_ERR_FEATURE_NOT_SUPPORTED:
1301 : : ret = -ENOTSUP;
1302 : 0 : break;
1303 : 0 : default:
1304 : : ret = -EAGAIN;
1305 : 0 : break;
1306 : : }
1307 : :
1308 : 0 : return ret;
1309 : : }
1310 : :
1311 : : static int
1312 : 0 : txgbevf_dev_promiscuous_disable(struct rte_eth_dev *dev)
1313 : : {
1314 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1315 : : int mode = TXGBEVF_XCAST_MODE_NONE;
1316 : : int ret;
1317 : :
1318 [ # # ]: 0 : if (dev->data->all_multicast)
1319 : : mode = TXGBEVF_XCAST_MODE_ALLMULTI;
1320 : :
1321 [ # # # ]: 0 : switch (hw->mac.update_xcast_mode(hw, mode)) {
1322 : : case 0:
1323 : : ret = 0;
1324 : : break;
1325 : 0 : case TXGBE_ERR_FEATURE_NOT_SUPPORTED:
1326 : : ret = -ENOTSUP;
1327 : 0 : break;
1328 : 0 : default:
1329 : : ret = -EAGAIN;
1330 : 0 : break;
1331 : : }
1332 : :
1333 : 0 : return ret;
1334 : : }
1335 : :
1336 : : static int
1337 : 0 : txgbevf_dev_allmulticast_enable(struct rte_eth_dev *dev)
1338 : : {
1339 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1340 : : int ret;
1341 : :
1342 [ # # ]: 0 : if (dev->data->promiscuous)
1343 : : return 0;
1344 : :
1345 [ # # # ]: 0 : switch (hw->mac.update_xcast_mode(hw, TXGBEVF_XCAST_MODE_ALLMULTI)) {
1346 : : case 0:
1347 : : ret = 0;
1348 : : break;
1349 : 0 : case TXGBE_ERR_FEATURE_NOT_SUPPORTED:
1350 : : ret = -ENOTSUP;
1351 : 0 : break;
1352 : 0 : default:
1353 : : ret = -EAGAIN;
1354 : 0 : break;
1355 : : }
1356 : :
1357 : : return ret;
1358 : : }
1359 : :
1360 : : static int
1361 : 0 : txgbevf_dev_allmulticast_disable(struct rte_eth_dev *dev)
1362 : : {
1363 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1364 : : int ret;
1365 : :
1366 [ # # ]: 0 : if (dev->data->promiscuous)
1367 : : return 0;
1368 : :
1369 [ # # # ]: 0 : switch (hw->mac.update_xcast_mode(hw, TXGBEVF_XCAST_MODE_MULTI)) {
1370 : : case 0:
1371 : : ret = 0;
1372 : : break;
1373 : 0 : case TXGBE_ERR_FEATURE_NOT_SUPPORTED:
1374 : : ret = -ENOTSUP;
1375 : 0 : break;
1376 : 0 : default:
1377 : : ret = -EAGAIN;
1378 : 0 : break;
1379 : : }
1380 : :
1381 : : return ret;
1382 : : }
1383 : :
1384 : : /**
1385 : : * txgbevf_get_pf_link_status - Get pf link/speed status
1386 : : * @hw: pointer to hardware structure
1387 : : *
1388 : : * - PF notifies status via mailbox on change
1389 : : * - VF sets its link state synchronously upon mailbox interrupt,
1390 : : * skipping hardware link detection.
1391 : : **/
1392 : 0 : static s32 txgbevf_get_pf_link_status(struct rte_eth_dev *dev)
1393 : : {
1394 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1395 : : struct txgbe_mbx_info *mbx = &hw->mbx;
1396 : : struct rte_eth_link link;
1397 : : u32 link_speed = TXGBE_LINK_SPEED_UNKNOWN;
1398 : : bool link_up = false;
1399 : : u32 msgbuf[2];
1400 : : s32 retval;
1401 : :
1402 : 0 : retval = mbx->read(hw, msgbuf, 2, 0);
1403 : :
1404 : : /*
1405 : : *if the read failed it could just be a mailbox collision, best wait
1406 : : * until we are called again and don't report an error
1407 : : */
1408 [ # # ]: 0 : if (retval)
1409 : : return 0;
1410 : :
1411 : 0 : rte_eth_linkstatus_get(dev, &link);
1412 : :
1413 : 0 : link_up = msgbuf[1] & TXGBE_VFSTATUS_UP;
1414 : 0 : link_speed = (msgbuf[1] & 0xFFF0) >> 1;
1415 : :
1416 [ # # # # ]: 0 : if (link_up == link.link_status && link_speed == link.link_speed)
1417 : : return 0;
1418 : :
1419 : 0 : link.link_speed = link_speed;
1420 : 0 : link.link_status = link_up;
1421 : :
1422 [ # # ]: 0 : if (link_up)
1423 : 0 : link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
1424 : : else
1425 : 0 : link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
1426 : : /*
1427 : : * Invoke the LSC interrupt callback to notify the upper app of a link
1428 : : * status change, even though the change is detected via a mailbox interrupt
1429 : : * instead of an LSC interrupt. This is because VF link status changes do
1430 : : * not trigger LSC interrupts — they rely on PF notifications.
1431 : : */
1432 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
1433 : : NULL);
1434 : : return rte_eth_linkstatus_set(dev, &link);
1435 : : }
1436 : :
1437 : 0 : static void txgbevf_check_link_for_intr(struct rte_eth_dev *dev)
1438 : : {
1439 : : struct rte_eth_link orig_link, new_link;
1440 : :
1441 : 0 : rte_eth_linkstatus_get(dev, &orig_link);
1442 : : txgbevf_dev_link_update(dev, 0);
1443 : 0 : rte_eth_linkstatus_get(dev, &new_link);
1444 : :
1445 : 0 : PMD_DRV_LOG(INFO, "orig_link: %d, new_link: %d",
1446 : : orig_link.link_status, new_link.link_status);
1447 : :
1448 [ # # ]: 0 : if (new_link.link_status != orig_link.link_status)
1449 : 0 : rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC,
1450 : : NULL);
1451 : 0 : }
1452 : :
1453 : 0 : static void txgbevf_mbx_process(struct rte_eth_dev *dev)
1454 : : {
1455 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1456 : 0 : u32 in_msg = 0;
1457 : :
1458 : : /* peek the message first */
1459 : 0 : in_msg = rd32(hw, TXGBE_VFMBX);
1460 : :
1461 : : /* PF reset VF event */
1462 [ # # ]: 0 : if (in_msg & TXGBE_PF_CONTROL_MSG) {
1463 [ # # ]: 0 : if (in_msg & TXGBE_NOFITY_VF_LINK_STATUS) {
1464 : 0 : txgbevf_get_pf_link_status(dev);
1465 : : } else {
1466 : : /* dummy mbx read to ack pf */
1467 : 0 : txgbe_read_mbx(hw, &in_msg, 1, 0);
1468 : : /* check link status if pf ping vf */
1469 : 0 : txgbevf_check_link_for_intr(dev);
1470 : : }
1471 : : }
1472 : 0 : }
1473 : :
1474 : : static int
1475 : 0 : txgbevf_dev_interrupt_get_status(struct rte_eth_dev *dev)
1476 : : {
1477 : : uint32_t eicr;
1478 : 0 : struct txgbe_hw *hw = TXGBE_DEV_HW(dev);
1479 : : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1480 : 0 : txgbevf_intr_disable(dev);
1481 : :
1482 : : /* read-on-clear nic registers here */
1483 : : eicr = rd32(hw, TXGBE_VFICR);
1484 : : intr->flags = 0;
1485 : :
1486 : : /* only one misc vector supported - mailbox */
1487 : : eicr &= TXGBE_VFICR_MASK;
1488 : : /* Workaround for ICR lost */
1489 : 0 : intr->flags |= TXGBE_FLAG_MAILBOX;
1490 : :
1491 : : /* To avoid compiler warnings set eicr to used. */
1492 : : RTE_SET_USED(eicr);
1493 : :
1494 : 0 : return 0;
1495 : : }
1496 : :
1497 : : static int
1498 : 0 : txgbevf_dev_interrupt_action(struct rte_eth_dev *dev)
1499 : : {
1500 : 0 : struct txgbe_interrupt *intr = TXGBE_DEV_INTR(dev);
1501 : :
1502 [ # # ]: 0 : if (intr->flags & TXGBE_FLAG_MAILBOX) {
1503 : 0 : txgbevf_mbx_process(dev);
1504 : 0 : intr->flags &= ~TXGBE_FLAG_MAILBOX;
1505 : : }
1506 : :
1507 : 0 : txgbevf_intr_enable(dev);
1508 : :
1509 : 0 : return 0;
1510 : : }
1511 : :
1512 : : static void
1513 : 0 : txgbevf_dev_interrupt_handler(void *param)
1514 : : {
1515 : : struct rte_eth_dev *dev = (struct rte_eth_dev *)param;
1516 : :
1517 : 0 : txgbevf_dev_interrupt_get_status(dev);
1518 : 0 : txgbevf_dev_interrupt_action(dev);
1519 : 0 : }
1520 : :
1521 : : static int
1522 : 0 : txgbevf_dev_flow_ops_get(__rte_unused struct rte_eth_dev *dev,
1523 : : const struct rte_flow_ops **ops)
1524 : : {
1525 : 0 : *ops = &txgbe_flow_ops;
1526 : 0 : return 0;
1527 : : }
1528 : :
1529 : : /*
1530 : : * dev_ops for virtual function, bare necessities for basic vf
1531 : : * operation have been implemented
1532 : : */
1533 : : static const struct eth_dev_ops txgbevf_eth_dev_ops = {
1534 : : .dev_configure = txgbevf_dev_configure,
1535 : : .dev_start = txgbevf_dev_start,
1536 : : .dev_stop = txgbevf_dev_stop,
1537 : : .link_update = txgbevf_dev_link_update,
1538 : : .stats_get = txgbevf_dev_stats_get,
1539 : : .xstats_get = txgbevf_dev_xstats_get,
1540 : : .stats_reset = txgbevf_dev_stats_reset,
1541 : : .xstats_reset = txgbevf_dev_stats_reset,
1542 : : .xstats_get_names = txgbevf_dev_xstats_get_names,
1543 : : .dev_close = txgbevf_dev_close,
1544 : : .dev_reset = txgbevf_dev_reset,
1545 : : .promiscuous_enable = txgbevf_dev_promiscuous_enable,
1546 : : .promiscuous_disable = txgbevf_dev_promiscuous_disable,
1547 : : .allmulticast_enable = txgbevf_dev_allmulticast_enable,
1548 : : .allmulticast_disable = txgbevf_dev_allmulticast_disable,
1549 : : .dev_infos_get = txgbevf_dev_info_get,
1550 : : .dev_supported_ptypes_get = txgbe_dev_supported_ptypes_get,
1551 : : .mtu_set = txgbevf_dev_set_mtu,
1552 : : .vlan_filter_set = txgbevf_vlan_filter_set,
1553 : : .vlan_strip_queue_set = txgbevf_vlan_strip_queue_set,
1554 : : .vlan_offload_set = txgbevf_vlan_offload_set,
1555 : : .rx_queue_setup = txgbe_dev_rx_queue_setup,
1556 : : .rx_queue_release = txgbe_dev_rx_queue_release,
1557 : : .tx_queue_setup = txgbe_dev_tx_queue_setup,
1558 : : .tx_queue_release = txgbe_dev_tx_queue_release,
1559 : : .rx_queue_intr_enable = txgbevf_dev_rx_queue_intr_enable,
1560 : : .rx_queue_intr_disable = txgbevf_dev_rx_queue_intr_disable,
1561 : : .mac_addr_add = txgbevf_add_mac_addr,
1562 : : .mac_addr_remove = txgbevf_remove_mac_addr,
1563 : : .set_mc_addr_list = txgbe_dev_set_mc_addr_list,
1564 : : .rxq_info_get = txgbe_rxq_info_get,
1565 : : .txq_info_get = txgbe_txq_info_get,
1566 : : .mac_addr_set = txgbevf_set_default_mac_addr,
1567 : : .get_reg = txgbevf_get_regs,
1568 : : .reta_update = txgbe_dev_rss_reta_update,
1569 : : .reta_query = txgbe_dev_rss_reta_query,
1570 : : .rss_hash_update = txgbe_dev_rss_hash_update,
1571 : : .rss_hash_conf_get = txgbe_dev_rss_hash_conf_get,
1572 : : .tx_done_cleanup = txgbe_dev_tx_done_cleanup,
1573 : : .flow_ops_get = txgbevf_dev_flow_ops_get,
1574 : : };
1575 : :
1576 : 254 : RTE_PMD_REGISTER_PCI(net_txgbe_vf, rte_txgbevf_pmd);
1577 : : RTE_PMD_REGISTER_PCI_TABLE(net_txgbe_vf, pci_id_txgbevf_map);
1578 : : RTE_PMD_REGISTER_KMOD_DEP(net_txgbe_vf, "* igb_uio | vfio-pci");
|