Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2018 Intel Corporation.
3 : : */
4 : :
5 : : #include <bus_pci_driver.h>
6 : : #include <rte_ethdev.h>
7 : : #include <rte_pci.h>
8 : : #include <rte_malloc.h>
9 : :
10 : : #include "ethdev_driver.h"
11 : : #include "base/i40e_type.h"
12 : : #include "base/virtchnl.h"
13 : : #include "i40e_ethdev.h"
14 : : #include "i40e_rxtx.h"
15 : : #include "rte_pmd_i40e.h"
16 : :
17 : : static int
18 : 0 : i40e_vf_representor_link_update(struct rte_eth_dev *ethdev,
19 : : int wait_to_complete)
20 : : {
21 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
22 : 0 : struct rte_eth_dev *dev =
23 : 0 : &rte_eth_devices[representor->adapter->pf.dev_data->port_id];
24 : :
25 : 0 : return i40e_dev_link_update(dev, wait_to_complete);
26 : : }
27 : : static int
28 : 0 : i40e_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
29 : : struct rte_eth_dev_info *dev_info)
30 : : {
31 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
32 : :
33 : : /* get dev info for the vdev */
34 : 0 : dev_info->device = ethdev->device;
35 : :
36 : 0 : dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
37 : :
38 : 0 : dev_info->max_rx_queues = ethdev->data->nb_rx_queues;
39 : 0 : dev_info->max_tx_queues = ethdev->data->nb_tx_queues;
40 : :
41 : 0 : dev_info->min_rx_bufsize = I40E_BUF_SIZE_MIN;
42 : 0 : dev_info->max_rx_pktlen = I40E_FRAME_SIZE_MAX;
43 : 0 : dev_info->hash_key_size = (I40E_VFQF_HKEY_MAX_INDEX + 1) *
44 : : sizeof(uint32_t);
45 : 0 : dev_info->reta_size = RTE_ETH_RSS_RETA_SIZE_64;
46 : 0 : dev_info->flow_type_rss_offloads = I40E_RSS_OFFLOAD_ALL;
47 : 0 : dev_info->max_mac_addrs = I40E_NUM_MACADDR_MAX;
48 : 0 : dev_info->rx_offload_capa =
49 : : RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
50 : : RTE_ETH_RX_OFFLOAD_QINQ_STRIP |
51 : : RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
52 : : RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
53 : : RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
54 : : RTE_ETH_RX_OFFLOAD_VLAN_FILTER;
55 : 0 : dev_info->tx_offload_capa =
56 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS |
57 : : RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
58 : : RTE_ETH_TX_OFFLOAD_QINQ_INSERT |
59 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
60 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
61 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
62 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
63 : : RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
64 : : RTE_ETH_TX_OFFLOAD_TCP_TSO |
65 : : RTE_ETH_TX_OFFLOAD_VXLAN_TNL_TSO |
66 : : RTE_ETH_TX_OFFLOAD_GRE_TNL_TSO |
67 : : RTE_ETH_TX_OFFLOAD_IPIP_TNL_TSO |
68 : : RTE_ETH_TX_OFFLOAD_GENEVE_TNL_TSO;
69 : :
70 : 0 : dev_info->default_rxconf = (struct rte_eth_rxconf) {
71 : : .rx_thresh = {
72 : : .pthresh = I40E_DEFAULT_RX_PTHRESH,
73 : : .hthresh = I40E_DEFAULT_RX_HTHRESH,
74 : : .wthresh = I40E_DEFAULT_RX_WTHRESH,
75 : : },
76 : : .rx_free_thresh = I40E_DEFAULT_RX_FREE_THRESH,
77 : : .rx_drop_en = 0,
78 : : .offloads = 0,
79 : : };
80 : :
81 : 0 : dev_info->default_txconf = (struct rte_eth_txconf) {
82 : : .tx_thresh = {
83 : : .pthresh = I40E_DEFAULT_TX_PTHRESH,
84 : : .hthresh = I40E_DEFAULT_TX_HTHRESH,
85 : : .wthresh = I40E_DEFAULT_TX_WTHRESH,
86 : : },
87 : : .tx_free_thresh = I40E_DEFAULT_TX_FREE_THRESH,
88 : : .tx_rs_thresh = I40E_DEFAULT_TX_RSBIT_THRESH,
89 : : .offloads = 0,
90 : : };
91 : :
92 : 0 : dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
93 : : .nb_max = I40E_MAX_RING_DESC,
94 : : .nb_min = I40E_MIN_RING_DESC,
95 : : .nb_align = I40E_ALIGN_RING_DESC,
96 : : };
97 : :
98 : 0 : dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
99 : : .nb_max = I40E_MAX_RING_DESC,
100 : : .nb_min = I40E_MIN_RING_DESC,
101 : : .nb_align = I40E_ALIGN_RING_DESC,
102 : : };
103 : :
104 : 0 : dev_info->switch_info.name =
105 : 0 : rte_eth_devices[ethdev->data->port_id].device->name;
106 : 0 : dev_info->switch_info.domain_id = representor->switch_domain_id;
107 : 0 : dev_info->switch_info.port_id = representor->vf_id;
108 : :
109 : 0 : return 0;
110 : : }
111 : :
112 : : static int
113 : 0 : i40e_vf_representor_dev_configure(__rte_unused struct rte_eth_dev *dev)
114 : : {
115 : 0 : return 0;
116 : : }
117 : :
118 : : static int
119 : 0 : i40e_vf_representor_dev_start(__rte_unused struct rte_eth_dev *dev)
120 : : {
121 : 0 : return 0;
122 : : }
123 : :
124 : : static int
125 : 0 : i40e_vf_representor_dev_stop(__rte_unused struct rte_eth_dev *dev)
126 : : {
127 : 0 : return 0;
128 : : }
129 : :
130 : : static int
131 : 0 : i40e_vf_representor_rx_queue_setup(__rte_unused struct rte_eth_dev *dev,
132 : : __rte_unused uint16_t rx_queue_id,
133 : : __rte_unused uint16_t nb_rx_desc,
134 : : __rte_unused unsigned int socket_id,
135 : : __rte_unused const struct rte_eth_rxconf *rx_conf,
136 : : __rte_unused struct rte_mempool *mb_pool)
137 : : {
138 : 0 : return 0;
139 : : }
140 : :
141 : : static int
142 : 0 : i40e_vf_representor_tx_queue_setup(__rte_unused struct rte_eth_dev *dev,
143 : : __rte_unused uint16_t rx_queue_id,
144 : : __rte_unused uint16_t nb_rx_desc,
145 : : __rte_unused unsigned int socket_id,
146 : : __rte_unused const struct rte_eth_txconf *tx_conf)
147 : : {
148 : 0 : return 0;
149 : : }
150 : :
151 : : static void
152 : : i40evf_stat_update_48(uint64_t *offset,
153 : : uint64_t *stat)
154 : : {
155 [ # # # # ]: 0 : if (*stat >= *offset)
156 : 0 : *stat = *stat - *offset;
157 : : else
158 : 0 : *stat = (uint64_t)((*stat +
159 : : ((uint64_t)1 << I40E_48_BIT_WIDTH)) - *offset);
160 : :
161 [ # # # # : 0 : *stat &= I40E_48_BIT_MASK;
# # # # #
# # # ]
162 : : }
163 : :
164 : : static void
165 : : i40evf_stat_update_32(uint64_t *offset,
166 : : uint64_t *stat)
167 : : {
168 [ # # # # : 0 : if (*stat >= *offset)
# # # # ]
169 : 0 : *stat = (uint64_t)(*stat - *offset);
170 : : else
171 : 0 : *stat = (uint64_t)((*stat +
172 : : ((uint64_t)1 << I40E_32_BIT_WIDTH)) - *offset);
173 : : }
174 : :
175 : : static int
176 : 0 : rte_pmd_i40e_get_vf_native_stats(uint16_t port,
177 : : uint16_t vf_id,
178 : : struct i40e_eth_stats *stats)
179 : : {
180 : : struct rte_eth_dev *dev;
181 : : struct i40e_pf *pf;
182 : : struct i40e_vsi *vsi;
183 : :
184 [ # # ]: 0 : RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
185 : :
186 : 0 : dev = &rte_eth_devices[port];
187 : :
188 [ # # ]: 0 : if (!is_i40e_supported(dev))
189 : : return -ENOTSUP;
190 : :
191 : 0 : pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
192 : :
193 [ # # # # ]: 0 : if (vf_id >= pf->vf_num || !pf->vfs) {
194 : 0 : PMD_DRV_LOG(ERR, "Invalid VF ID.");
195 : 0 : return -EINVAL;
196 : : }
197 : :
198 : 0 : vsi = pf->vfs[vf_id].vsi;
199 [ # # ]: 0 : if (!vsi) {
200 : 0 : PMD_DRV_LOG(ERR, "Invalid VSI.");
201 : 0 : return -EINVAL;
202 : : }
203 : :
204 : 0 : i40e_update_vsi_stats(vsi);
205 : 0 : memcpy(stats, &vsi->eth_stats, sizeof(vsi->eth_stats));
206 : :
207 : 0 : return 0;
208 : : }
209 : :
210 : : static int
211 : 0 : i40e_vf_representor_stats_get(struct rte_eth_dev *ethdev,
212 : : struct rte_eth_stats *stats)
213 : : {
214 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
215 : : struct i40e_eth_stats native_stats;
216 : : int ret;
217 : :
218 : 0 : ret = rte_pmd_i40e_get_vf_native_stats(
219 : 0 : representor->adapter->pf.dev_data->port_id,
220 : 0 : representor->vf_id, &native_stats);
221 [ # # ]: 0 : if (ret == 0) {
222 : : i40evf_stat_update_48(
223 : : &representor->stats_offset.rx_bytes,
224 : : &native_stats.rx_bytes);
225 : : i40evf_stat_update_48(
226 : : &representor->stats_offset.rx_unicast,
227 : : &native_stats.rx_unicast);
228 : : i40evf_stat_update_48(
229 : : &representor->stats_offset.rx_multicast,
230 : : &native_stats.rx_multicast);
231 : : i40evf_stat_update_48(
232 : : &representor->stats_offset.rx_broadcast,
233 : : &native_stats.rx_broadcast);
234 : : i40evf_stat_update_32(
235 : : &representor->stats_offset.rx_discards,
236 : : &native_stats.rx_discards);
237 : : i40evf_stat_update_32(
238 : : &representor->stats_offset.rx_unknown_protocol,
239 : : &native_stats.rx_unknown_protocol);
240 : : i40evf_stat_update_48(
241 : : &representor->stats_offset.tx_bytes,
242 : : &native_stats.tx_bytes);
243 : : i40evf_stat_update_48(
244 : : &representor->stats_offset.tx_unicast,
245 : : &native_stats.tx_unicast);
246 : : i40evf_stat_update_48(
247 : : &representor->stats_offset.tx_multicast,
248 : : &native_stats.tx_multicast);
249 : : i40evf_stat_update_48(
250 : : &representor->stats_offset.tx_broadcast,
251 : : &native_stats.tx_broadcast);
252 : : i40evf_stat_update_32(
253 : : &representor->stats_offset.tx_errors,
254 : : &native_stats.tx_errors);
255 : : i40evf_stat_update_32(
256 : : &representor->stats_offset.tx_discards,
257 : : &native_stats.tx_discards);
258 : :
259 : 0 : stats->ipackets = native_stats.rx_unicast +
260 : 0 : native_stats.rx_multicast +
261 : : native_stats.rx_broadcast;
262 : 0 : stats->opackets = native_stats.tx_unicast +
263 : 0 : native_stats.tx_multicast +
264 : : native_stats.tx_broadcast;
265 : 0 : stats->ibytes = native_stats.rx_bytes;
266 : 0 : stats->obytes = native_stats.tx_bytes;
267 : 0 : stats->ierrors = native_stats.rx_discards;
268 : 0 : stats->oerrors = native_stats.tx_errors + native_stats.tx_discards;
269 : : }
270 : 0 : return ret;
271 : : }
272 : :
273 : : static int
274 : 0 : i40e_vf_representor_stats_reset(struct rte_eth_dev *ethdev)
275 : : {
276 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
277 : :
278 : 0 : return rte_pmd_i40e_get_vf_native_stats(
279 : 0 : representor->adapter->pf.dev_data->port_id,
280 : 0 : representor->vf_id, &representor->stats_offset);
281 : : }
282 : :
283 : : static int
284 : 0 : i40e_vf_representor_promiscuous_enable(struct rte_eth_dev *ethdev)
285 : : {
286 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
287 : :
288 : 0 : return rte_pmd_i40e_set_vf_unicast_promisc(
289 : 0 : representor->adapter->pf.dev_data->port_id,
290 : 0 : representor->vf_id, 1);
291 : : }
292 : :
293 : : static int
294 : 0 : i40e_vf_representor_promiscuous_disable(struct rte_eth_dev *ethdev)
295 : : {
296 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
297 : :
298 : 0 : return rte_pmd_i40e_set_vf_unicast_promisc(
299 : 0 : representor->adapter->pf.dev_data->port_id,
300 : 0 : representor->vf_id, 0);
301 : : }
302 : :
303 : : static int
304 : 0 : i40e_vf_representor_allmulticast_enable(struct rte_eth_dev *ethdev)
305 : : {
306 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
307 : :
308 : 0 : return rte_pmd_i40e_set_vf_multicast_promisc(
309 : 0 : representor->adapter->pf.dev_data->port_id,
310 : 0 : representor->vf_id, 1);
311 : : }
312 : :
313 : : static int
314 : 0 : i40e_vf_representor_allmulticast_disable(struct rte_eth_dev *ethdev)
315 : : {
316 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
317 : :
318 : 0 : return rte_pmd_i40e_set_vf_multicast_promisc(
319 : 0 : representor->adapter->pf.dev_data->port_id,
320 : 0 : representor->vf_id, 0);
321 : : }
322 : :
323 : : static void
324 : 0 : i40e_vf_representor_mac_addr_remove(struct rte_eth_dev *ethdev, uint32_t index)
325 : : {
326 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
327 : :
328 : 0 : rte_pmd_i40e_remove_vf_mac_addr(
329 : 0 : representor->adapter->pf.dev_data->port_id,
330 : 0 : representor->vf_id, ðdev->data->mac_addrs[index]);
331 : 0 : }
332 : :
333 : : static int
334 : 0 : i40e_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev,
335 : : struct rte_ether_addr *mac_addr)
336 : : {
337 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
338 : :
339 : 0 : return rte_pmd_i40e_set_vf_mac_addr(
340 : 0 : representor->adapter->pf.dev_data->port_id,
341 : 0 : representor->vf_id, mac_addr);
342 : : }
343 : :
344 : : static int
345 : 0 : i40e_vf_representor_vlan_filter_set(struct rte_eth_dev *ethdev,
346 : : uint16_t vlan_id, int on)
347 : : {
348 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
349 : 0 : uint64_t vf_mask = 1ULL << representor->vf_id;
350 : :
351 : 0 : return rte_pmd_i40e_set_vf_vlan_filter(
352 : 0 : representor->adapter->pf.dev_data->port_id,
353 : : vlan_id, vf_mask, on);
354 : : }
355 : :
356 : : static int
357 : 0 : i40e_vf_representor_vlan_offload_set(struct rte_eth_dev *ethdev, int mask)
358 : : {
359 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
360 : : struct rte_eth_dev *pdev;
361 : : struct i40e_pf_vf *vf;
362 : : struct i40e_vsi *vsi;
363 : : struct i40e_pf *pf;
364 : : uint32_t vfid;
365 : :
366 : 0 : pdev = &rte_eth_devices[representor->adapter->pf.dev_data->port_id];
367 : 0 : vfid = representor->vf_id;
368 : :
369 [ # # ]: 0 : if (!is_i40e_supported(pdev)) {
370 : 0 : PMD_DRV_LOG(ERR, "Invalid PF dev.");
371 : 0 : return -EINVAL;
372 : : }
373 : :
374 : 0 : pf = I40E_DEV_PRIVATE_TO_PF(pdev->data->dev_private);
375 : :
376 [ # # # # ]: 0 : if (vfid >= pf->vf_num || !pf->vfs) {
377 : 0 : PMD_DRV_LOG(ERR, "Invalid VF ID.");
378 : 0 : return -EINVAL;
379 : : }
380 : :
381 : 0 : vf = &pf->vfs[vfid];
382 : 0 : vsi = vf->vsi;
383 [ # # ]: 0 : if (!vsi) {
384 : 0 : PMD_DRV_LOG(ERR, "Invalid VSI.");
385 : 0 : return -EINVAL;
386 : : }
387 : :
388 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_FILTER_MASK) {
389 : : /* Enable or disable VLAN filtering offload */
390 [ # # ]: 0 : if (ethdev->data->dev_conf.rxmode.offloads &
391 : : RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
392 : 0 : return i40e_vsi_config_vlan_filter(vsi, TRUE);
393 : : else
394 : 0 : return i40e_vsi_config_vlan_filter(vsi, FALSE);
395 : : }
396 : :
397 [ # # ]: 0 : if (mask & RTE_ETH_VLAN_STRIP_MASK) {
398 : : /* Enable or disable VLAN stripping offload */
399 [ # # ]: 0 : if (ethdev->data->dev_conf.rxmode.offloads &
400 : : RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
401 : 0 : return i40e_vsi_config_vlan_stripping(vsi, TRUE);
402 : : else
403 : 0 : return i40e_vsi_config_vlan_stripping(vsi, FALSE);
404 : : }
405 : :
406 : : return -EINVAL;
407 : : }
408 : :
409 : : static void
410 : 0 : i40e_vf_representor_vlan_strip_queue_set(struct rte_eth_dev *ethdev,
411 : : __rte_unused uint16_t rx_queue_id, int on)
412 : : {
413 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
414 : :
415 : 0 : rte_pmd_i40e_set_vf_vlan_stripq(
416 : 0 : representor->adapter->pf.dev_data->port_id,
417 : 0 : representor->vf_id, on);
418 : 0 : }
419 : :
420 : : static int
421 : 0 : i40e_vf_representor_vlan_pvid_set(struct rte_eth_dev *ethdev, uint16_t vlan_id,
422 : : __rte_unused int on)
423 : : {
424 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
425 : :
426 : 0 : return rte_pmd_i40e_set_vf_vlan_insert(
427 : 0 : representor->adapter->pf.dev_data->port_id,
428 : 0 : representor->vf_id, vlan_id);
429 : : }
430 : :
431 : : static const struct eth_dev_ops i40e_representor_dev_ops = {
432 : : .dev_infos_get = i40e_vf_representor_dev_infos_get,
433 : :
434 : : .dev_start = i40e_vf_representor_dev_start,
435 : : .dev_configure = i40e_vf_representor_dev_configure,
436 : : .dev_stop = i40e_vf_representor_dev_stop,
437 : :
438 : : .rx_queue_setup = i40e_vf_representor_rx_queue_setup,
439 : : .tx_queue_setup = i40e_vf_representor_tx_queue_setup,
440 : :
441 : : .link_update = i40e_vf_representor_link_update,
442 : :
443 : : .stats_get = i40e_vf_representor_stats_get,
444 : : .stats_reset = i40e_vf_representor_stats_reset,
445 : :
446 : : .promiscuous_enable = i40e_vf_representor_promiscuous_enable,
447 : : .promiscuous_disable = i40e_vf_representor_promiscuous_disable,
448 : :
449 : : .allmulticast_enable = i40e_vf_representor_allmulticast_enable,
450 : : .allmulticast_disable = i40e_vf_representor_allmulticast_disable,
451 : :
452 : : .mac_addr_remove = i40e_vf_representor_mac_addr_remove,
453 : : .mac_addr_set = i40e_vf_representor_mac_addr_set,
454 : :
455 : : .vlan_filter_set = i40e_vf_representor_vlan_filter_set,
456 : : .vlan_offload_set = i40e_vf_representor_vlan_offload_set,
457 : : .vlan_strip_queue_set = i40e_vf_representor_vlan_strip_queue_set,
458 : : .vlan_pvid_set = i40e_vf_representor_vlan_pvid_set
459 : :
460 : : };
461 : :
462 : : static uint16_t
463 : 0 : i40e_vf_representor_rx_burst(__rte_unused void *rx_queue,
464 : : __rte_unused struct rte_mbuf **rx_pkts, __rte_unused uint16_t nb_pkts)
465 : : {
466 : 0 : return 0;
467 : : }
468 : :
469 : : static uint16_t
470 : 0 : i40e_vf_representor_tx_burst(__rte_unused void *tx_queue,
471 : : __rte_unused struct rte_mbuf **tx_pkts, __rte_unused uint16_t nb_pkts)
472 : : {
473 : 0 : return 0;
474 : : }
475 : :
476 : : int
477 : 0 : i40e_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
478 : : {
479 : 0 : struct i40e_vf_representor *representor = ethdev->data->dev_private;
480 : :
481 : : struct i40e_pf *pf;
482 : : struct i40e_pf_vf *vf;
483 : : struct rte_eth_link *link;
484 : :
485 : 0 : representor->vf_id =
486 : 0 : ((struct i40e_vf_representor *)init_params)->vf_id;
487 : 0 : representor->switch_domain_id =
488 : 0 : ((struct i40e_vf_representor *)init_params)->switch_domain_id;
489 : 0 : representor->adapter =
490 : 0 : ((struct i40e_vf_representor *)init_params)->adapter;
491 : :
492 : 0 : pf = I40E_DEV_PRIVATE_TO_PF(
493 : : representor->adapter->pf.dev_data->dev_private);
494 : :
495 [ # # ]: 0 : if (representor->vf_id >= pf->vf_num)
496 : : return -ENODEV;
497 : :
498 : : /* Set representor device ops */
499 : 0 : ethdev->dev_ops = &i40e_representor_dev_ops;
500 : :
501 : : /* No data-path, but need stub Rx/Tx functions to avoid crash
502 : : * when testing with the likes of testpmd.
503 : : */
504 : 0 : ethdev->rx_pkt_burst = i40e_vf_representor_rx_burst;
505 : 0 : ethdev->tx_pkt_burst = i40e_vf_representor_tx_burst;
506 : :
507 : 0 : vf = &pf->vfs[representor->vf_id];
508 : :
509 [ # # ]: 0 : if (!vf->vsi) {
510 : 0 : PMD_DRV_LOG(ERR, "Invalid VSI.");
511 : 0 : return -ENODEV;
512 : : }
513 : :
514 : 0 : ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
515 : 0 : ethdev->data->representor_id = representor->vf_id;
516 : 0 : ethdev->data->backer_port_id = pf->dev_data->port_id;
517 : :
518 : : /* Setting the number queues allocated to the VF */
519 : 0 : ethdev->data->nb_rx_queues = vf->vsi->nb_qps;
520 : 0 : ethdev->data->nb_tx_queues = vf->vsi->nb_qps;
521 : :
522 : 0 : ethdev->data->mac_addrs = &vf->mac_addr;
523 : :
524 : : /* Link state. Inherited from PF */
525 : : link = &representor->adapter->pf.dev_data->dev_link;
526 : :
527 : 0 : ethdev->data->dev_link.link_speed = link->link_speed;
528 : 0 : ethdev->data->dev_link.link_duplex = link->link_duplex;
529 : 0 : ethdev->data->dev_link.link_status = link->link_status;
530 : 0 : ethdev->data->dev_link.link_autoneg = link->link_autoneg;
531 : :
532 : 0 : return 0;
533 : : }
534 : :
535 : : int
536 : 0 : i40e_vf_representor_uninit(struct rte_eth_dev *ethdev)
537 : : {
538 : : /* mac_addrs must not be freed because part of i40e_pf_vf */
539 : 0 : ethdev->data->mac_addrs = NULL;
540 : :
541 : 0 : return 0;
542 : : }
|