]> git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/drivers/net/ixgbe/ixgbe_vf_representor.c
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / spdk / dpdk / drivers / net / ixgbe / ixgbe_vf_representor.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation.
3 */
4
5 #include <rte_ethdev.h>
6 #include <rte_pci.h>
7 #include <rte_malloc.h>
8
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"
14
15
16 static int
17 ixgbe_vf_representor_link_update(struct rte_eth_dev *ethdev,
18 int wait_to_complete)
19 {
20 struct ixgbe_vf_representor *representor = ethdev->data->dev_private;
21
22 return ixgbe_dev_link_update_share(representor->pf_ethdev,
23 wait_to_complete, 0);
24 }
25
26 static int
27 ixgbe_vf_representor_mac_addr_set(struct rte_eth_dev *ethdev,
28 struct ether_addr *mac_addr)
29 {
30 struct ixgbe_vf_representor *representor = ethdev->data->dev_private;
31
32 return rte_pmd_ixgbe_set_vf_mac_addr(
33 representor->pf_ethdev->data->port_id,
34 representor->vf_id, mac_addr);
35 }
36
37 static void
38 ixgbe_vf_representor_dev_infos_get(struct rte_eth_dev *ethdev,
39 struct rte_eth_dev_info *dev_info)
40 {
41 struct ixgbe_vf_representor *representor = ethdev->data->dev_private;
42
43 struct ixgbe_hw *hw = IXGBE_DEV_PRIVATE_TO_HW(
44 representor->pf_ethdev->data->dev_private);
45
46 dev_info->device = representor->pf_ethdev->device;
47
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. */
56
57 dev_info->max_mac_addrs = hw->mac.num_rar_entries;
58 /**< Maximum number of MAC addresses. */
59
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. */
64
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. */
70
71 dev_info->speed_capa =
72 representor->pf_ethdev->data->dev_link.link_speed;
73 /**< Supported speeds bitmap (ETH_LINK_SPEED_). */
74
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;
79 }
80
81 static int ixgbe_vf_representor_dev_configure(
82 __rte_unused struct rte_eth_dev *dev)
83 {
84 return 0;
85 }
86
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)
94 {
95 return 0;
96 }
97
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)
104 {
105 return 0;
106 }
107
108 static int ixgbe_vf_representor_dev_start(__rte_unused struct rte_eth_dev *dev)
109 {
110 return 0;
111 }
112
113 static void ixgbe_vf_representor_dev_stop(__rte_unused struct rte_eth_dev *dev)
114 {
115 }
116
117 static int
118 ixgbe_vf_representor_vlan_filter_set(struct rte_eth_dev *ethdev,
119 uint16_t vlan_id, int on)
120 {
121 struct ixgbe_vf_representor *representor = ethdev->data->dev_private;
122 uint64_t vf_mask = 1ULL << representor->vf_id;
123
124 return rte_pmd_ixgbe_set_vf_vlan_filter(
125 representor->pf_ethdev->data->port_id, vlan_id, vf_mask, on);
126 }
127
128 static void
129 ixgbe_vf_representor_vlan_strip_queue_set(struct rte_eth_dev *ethdev,
130 __rte_unused uint16_t rx_queue_id, int on)
131 {
132 struct ixgbe_vf_representor *representor = ethdev->data->dev_private;
133
134 rte_pmd_ixgbe_set_vf_vlan_stripq(representor->pf_ethdev->data->port_id,
135 representor->vf_id, on);
136 }
137
138 struct eth_dev_ops ixgbe_vf_representor_dev_ops = {
139 .dev_infos_get = ixgbe_vf_representor_dev_infos_get,
140
141 .dev_start = ixgbe_vf_representor_dev_start,
142 .dev_configure = ixgbe_vf_representor_dev_configure,
143 .dev_stop = ixgbe_vf_representor_dev_stop,
144
145 .rx_queue_setup = ixgbe_vf_representor_rx_queue_setup,
146 .tx_queue_setup = ixgbe_vf_representor_tx_queue_setup,
147
148 .link_update = ixgbe_vf_representor_link_update,
149
150 .vlan_filter_set = ixgbe_vf_representor_vlan_filter_set,
151 .vlan_strip_queue_set = ixgbe_vf_representor_vlan_strip_queue_set,
152
153 .mac_addr_set = ixgbe_vf_representor_mac_addr_set,
154 };
155
156 static uint16_t
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)
159 {
160 return 0;
161 }
162
163 static uint16_t
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)
166 {
167 return 0;
168 }
169
170 int
171 ixgbe_vf_representor_init(struct rte_eth_dev *ethdev, void *init_params)
172 {
173 struct ixgbe_vf_representor *representor = ethdev->data->dev_private;
174
175 struct ixgbe_vf_info *vf_data;
176 struct rte_pci_device *pci_dev;
177 struct rte_eth_link *link;
178
179 if (!representor)
180 return -ENOMEM;
181
182 representor->vf_id =
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;
188
189 pci_dev = RTE_ETH_DEV_TO_PCI(representor->pf_ethdev);
190
191 if (representor->vf_id >= pci_dev->max_vfs)
192 return -ENODEV;
193
194 ethdev->data->dev_flags |= RTE_ETH_DEV_REPRESENTOR;
195
196 /* Set representor device ops */
197 ethdev->dev_ops = &ixgbe_vf_representor_dev_ops;
198
199 /* No data-path, but need stub Rx/Tx functions to avoid crash
200 * when testing with the likes of testpmd.
201 */
202 ethdev->rx_pkt_burst = ixgbe_vf_representor_rx_burst;
203 ethdev->tx_pkt_burst = ixgbe_vf_representor_tx_burst;
204
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;
208
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);
212
213 ethdev->data->mac_addrs = (struct ether_addr *)
214 vf_data[representor->vf_id].vf_mac_addresses;
215
216 /* Link state. Inherited from PF */
217 link = &representor->pf_ethdev->data->dev_link;
218
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;
223
224 return 0;
225 }
226
227 int
228 ixgbe_vf_representor_uninit(struct rte_eth_dev *ethdev __rte_unused)
229 {
230 return 0;
231 }