1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation.
5 #include <rte_ethdev.h>
7 #include <rte_malloc.h>
9 #include "base/ixgbe_type.h"
10 #include "base/ixgbe_vf.h"
11 #include "ixgbe_ethdev.h"
12 #include "ixgbe_rxtx.h"
13 #include "rte_pmd_ixgbe.h"
17 ixgbe_vf_representor_link_update(struct rte_eth_dev
*ethdev
,
20 struct ixgbe_vf_representor
*representor
= ethdev
->data
->dev_private
;
22 return ixgbe_dev_link_update_share(representor
->pf_ethdev
,
27 ixgbe_vf_representor_mac_addr_set(struct rte_eth_dev
*ethdev
,
28 struct ether_addr
*mac_addr
)
30 struct ixgbe_vf_representor
*representor
= ethdev
->data
->dev_private
;
32 return rte_pmd_ixgbe_set_vf_mac_addr(
33 representor
->pf_ethdev
->data
->port_id
,
34 representor
->vf_id
, mac_addr
);
38 ixgbe_vf_representor_dev_infos_get(struct rte_eth_dev
*ethdev
,
39 struct rte_eth_dev_info
*dev_info
)
41 struct ixgbe_vf_representor
*representor
= ethdev
->data
->dev_private
;
43 struct ixgbe_hw
*hw
= IXGBE_DEV_PRIVATE_TO_HW(
44 representor
->pf_ethdev
->data
->dev_private
);
46 dev_info
->device
= representor
->pf_ethdev
->device
;
48 dev_info
->min_rx_bufsize
= 1024;
49 /**< Minimum size of RX buffer. */
50 dev_info
->max_rx_pktlen
= 9728;
51 /**< Maximum configurable length of RX pkt. */
52 dev_info
->max_rx_queues
= IXGBE_VF_MAX_RX_QUEUES
;
53 /**< Maximum number of RX queues. */
54 dev_info
->max_tx_queues
= IXGBE_VF_MAX_TX_QUEUES
;
55 /**< Maximum number of TX queues. */
57 dev_info
->max_mac_addrs
= hw
->mac
.num_rar_entries
;
58 /**< Maximum number of MAC addresses. */
60 dev_info
->rx_offload_capa
= DEV_RX_OFFLOAD_VLAN_STRIP
|
61 DEV_RX_OFFLOAD_IPV4_CKSUM
| DEV_RX_OFFLOAD_UDP_CKSUM
|
62 DEV_RX_OFFLOAD_TCP_CKSUM
;
63 /**< Device RX offload capabilities. */
65 dev_info
->tx_offload_capa
= DEV_TX_OFFLOAD_VLAN_INSERT
|
66 DEV_TX_OFFLOAD_IPV4_CKSUM
| DEV_TX_OFFLOAD_UDP_CKSUM
|
67 DEV_TX_OFFLOAD_TCP_CKSUM
| DEV_TX_OFFLOAD_SCTP_CKSUM
|
68 DEV_TX_OFFLOAD_TCP_TSO
;
69 /**< Device TX offload capabilities. */
71 dev_info
->speed_capa
=
72 representor
->pf_ethdev
->data
->dev_link
.link_speed
;
73 /**< Supported speeds bitmap (ETH_LINK_SPEED_). */
75 dev_info
->switch_info
.name
=
76 representor
->pf_ethdev
->device
->name
;
77 dev_info
->switch_info
.domain_id
= representor
->switch_domain_id
;
78 dev_info
->switch_info
.port_id
= representor
->vf_id
;
81 static int ixgbe_vf_representor_dev_configure(
82 __rte_unused
struct rte_eth_dev
*dev
)
87 static int ixgbe_vf_representor_rx_queue_setup(
88 __rte_unused
struct rte_eth_dev
*dev
,
89 __rte_unused
uint16_t rx_queue_id
,
90 __rte_unused
uint16_t nb_rx_desc
,
91 __rte_unused
unsigned int socket_id
,
92 __rte_unused
const struct rte_eth_rxconf
*rx_conf
,
93 __rte_unused
struct rte_mempool
*mb_pool
)
98 static int ixgbe_vf_representor_tx_queue_setup(
99 __rte_unused
struct rte_eth_dev
*dev
,
100 __rte_unused
uint16_t rx_queue_id
,
101 __rte_unused
uint16_t nb_rx_desc
,
102 __rte_unused
unsigned int socket_id
,
103 __rte_unused
const struct rte_eth_txconf
*tx_conf
)
108 static int ixgbe_vf_representor_dev_start(__rte_unused
struct rte_eth_dev
*dev
)
113 static void ixgbe_vf_representor_dev_stop(__rte_unused
struct rte_eth_dev
*dev
)
118 ixgbe_vf_representor_vlan_filter_set(struct rte_eth_dev
*ethdev
,
119 uint16_t vlan_id
, int on
)
121 struct ixgbe_vf_representor
*representor
= ethdev
->data
->dev_private
;
122 uint64_t vf_mask
= 1ULL << representor
->vf_id
;
124 return rte_pmd_ixgbe_set_vf_vlan_filter(
125 representor
->pf_ethdev
->data
->port_id
, vlan_id
, vf_mask
, on
);
129 ixgbe_vf_representor_vlan_strip_queue_set(struct rte_eth_dev
*ethdev
,
130 __rte_unused
uint16_t rx_queue_id
, int on
)
132 struct ixgbe_vf_representor
*representor
= ethdev
->data
->dev_private
;
134 rte_pmd_ixgbe_set_vf_vlan_stripq(representor
->pf_ethdev
->data
->port_id
,
135 representor
->vf_id
, on
);
138 struct eth_dev_ops ixgbe_vf_representor_dev_ops
= {
139 .dev_infos_get
= ixgbe_vf_representor_dev_infos_get
,
141 .dev_start
= ixgbe_vf_representor_dev_start
,
142 .dev_configure
= ixgbe_vf_representor_dev_configure
,
143 .dev_stop
= ixgbe_vf_representor_dev_stop
,
145 .rx_queue_setup
= ixgbe_vf_representor_rx_queue_setup
,
146 .tx_queue_setup
= ixgbe_vf_representor_tx_queue_setup
,
148 .link_update
= ixgbe_vf_representor_link_update
,
150 .vlan_filter_set
= ixgbe_vf_representor_vlan_filter_set
,
151 .vlan_strip_queue_set
= ixgbe_vf_representor_vlan_strip_queue_set
,
153 .mac_addr_set
= ixgbe_vf_representor_mac_addr_set
,
157 ixgbe_vf_representor_rx_burst(__rte_unused
void *rx_queue
,
158 __rte_unused
struct rte_mbuf
**rx_pkts
, __rte_unused
uint16_t nb_pkts
)
164 ixgbe_vf_representor_tx_burst(__rte_unused
void *tx_queue
,
165 __rte_unused
struct rte_mbuf
**tx_pkts
, __rte_unused
uint16_t nb_pkts
)
171 ixgbe_vf_representor_init(struct rte_eth_dev
*ethdev
, void *init_params
)
173 struct ixgbe_vf_representor
*representor
= ethdev
->data
->dev_private
;
175 struct ixgbe_vf_info
*vf_data
;
176 struct rte_pci_device
*pci_dev
;
177 struct rte_eth_link
*link
;
183 ((struct ixgbe_vf_representor
*)init_params
)->vf_id
;
184 representor
->switch_domain_id
=
185 ((struct ixgbe_vf_representor
*)init_params
)->switch_domain_id
;
186 representor
->pf_ethdev
=
187 ((struct ixgbe_vf_representor
*)init_params
)->pf_ethdev
;
189 pci_dev
= RTE_ETH_DEV_TO_PCI(representor
->pf_ethdev
);
191 if (representor
->vf_id
>= pci_dev
->max_vfs
)
194 ethdev
->data
->dev_flags
|= RTE_ETH_DEV_REPRESENTOR
;
196 /* Set representor device ops */
197 ethdev
->dev_ops
= &ixgbe_vf_representor_dev_ops
;
199 /* No data-path, but need stub Rx/Tx functions to avoid crash
200 * when testing with the likes of testpmd.
202 ethdev
->rx_pkt_burst
= ixgbe_vf_representor_rx_burst
;
203 ethdev
->tx_pkt_burst
= ixgbe_vf_representor_tx_burst
;
205 /* Setting the number queues allocated to the VF */
206 ethdev
->data
->nb_rx_queues
= IXGBE_VF_MAX_RX_QUEUES
;
207 ethdev
->data
->nb_tx_queues
= IXGBE_VF_MAX_RX_QUEUES
;
209 /* Reference VF mac address from PF data structure */
210 vf_data
= *IXGBE_DEV_PRIVATE_TO_P_VFDATA(
211 representor
->pf_ethdev
->data
->dev_private
);
213 ethdev
->data
->mac_addrs
= (struct ether_addr
*)
214 vf_data
[representor
->vf_id
].vf_mac_addresses
;
216 /* Link state. Inherited from PF */
217 link
= &representor
->pf_ethdev
->data
->dev_link
;
219 ethdev
->data
->dev_link
.link_speed
= link
->link_speed
;
220 ethdev
->data
->dev_link
.link_duplex
= link
->link_duplex
;
221 ethdev
->data
->dev_link
.link_status
= link
->link_status
;
222 ethdev
->data
->dev_link
.link_autoneg
= link
->link_autoneg
;
228 ixgbe_vf_representor_uninit(struct rte_eth_dev
*ethdev __rte_unused
)