Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2023 Intel Corporation
3 : : */
4 : :
5 : : #include <rte_atomic.h>
6 : : #include <rte_eal.h>
7 : : #include <rte_ether.h>
8 : : #include <rte_malloc.h>
9 : : #include <rte_memzone.h>
10 : : #include <rte_dev.h>
11 : : #include <errno.h>
12 : : #include <rte_alarm.h>
13 : : #include <rte_hash_crc.h>
14 : :
15 : : #include "cpfl_ethdev.h"
16 : : #include <ethdev_private.h>
17 : : #include <sys/utsname.h>
18 : : #include "cpfl_rxtx.h"
19 : : #include "cpfl_flow.h"
20 : : #include "cpfl_rules.h"
21 : : #include "../common/tx.h"
22 : :
23 : : #define CPFL_REPRESENTOR "representor"
24 : : #define CPFL_TX_SINGLE_Q "tx_single"
25 : : #define CPFL_RX_SINGLE_Q "rx_single"
26 : : #define CPFL_VPORT "vport"
27 : :
28 : : #ifdef RTE_HAS_JANSSON
29 : : #define CPFL_FLOW_PARSER "flow_parser"
30 : : #endif
31 : :
32 : : #define VCPF_FID 0
33 : : #define CPFL_FID 6
34 : :
35 : : rte_spinlock_t cpfl_adapter_lock;
36 : : /* A list for all adapters, one adapter matches one PCI device */
37 : : struct cpfl_adapter_list cpfl_adapter_list;
38 : : bool cpfl_adapter_list_init;
39 : :
40 : : static const char * const cpfl_valid_args_first[] = {
41 : : CPFL_REPRESENTOR,
42 : : CPFL_TX_SINGLE_Q,
43 : : CPFL_RX_SINGLE_Q,
44 : : CPFL_VPORT,
45 : : #ifdef RTE_HAS_JANSSON
46 : : CPFL_FLOW_PARSER,
47 : : #endif
48 : : NULL
49 : : };
50 : :
51 : : static const char * const cpfl_valid_args_again[] = {
52 : : CPFL_REPRESENTOR,
53 : : NULL
54 : : };
55 : :
56 : : uint32_t cpfl_supported_speeds[] = {
57 : : RTE_ETH_SPEED_NUM_NONE,
58 : : RTE_ETH_SPEED_NUM_10M,
59 : : RTE_ETH_SPEED_NUM_100M,
60 : : RTE_ETH_SPEED_NUM_1G,
61 : : RTE_ETH_SPEED_NUM_2_5G,
62 : : RTE_ETH_SPEED_NUM_5G,
63 : : RTE_ETH_SPEED_NUM_10G,
64 : : RTE_ETH_SPEED_NUM_20G,
65 : : RTE_ETH_SPEED_NUM_25G,
66 : : RTE_ETH_SPEED_NUM_40G,
67 : : RTE_ETH_SPEED_NUM_50G,
68 : : RTE_ETH_SPEED_NUM_56G,
69 : : RTE_ETH_SPEED_NUM_100G,
70 : : RTE_ETH_SPEED_NUM_200G,
71 : : RTE_ETH_SPEED_NUM_400G,
72 : : };
73 : :
74 : : static const uint64_t cpfl_map_hena_rss[] = {
75 : : [IDPF_HASH_NONF_UNICAST_IPV4_UDP] =
76 : : RTE_ETH_RSS_NONFRAG_IPV4_UDP,
77 : : [IDPF_HASH_NONF_MULTICAST_IPV4_UDP] =
78 : : RTE_ETH_RSS_NONFRAG_IPV4_UDP,
79 : : [IDPF_HASH_NONF_IPV4_UDP] =
80 : : RTE_ETH_RSS_NONFRAG_IPV4_UDP,
81 : : [IDPF_HASH_NONF_IPV4_TCP_SYN_NO_ACK] =
82 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP,
83 : : [IDPF_HASH_NONF_IPV4_TCP] =
84 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP,
85 : : [IDPF_HASH_NONF_IPV4_SCTP] =
86 : : RTE_ETH_RSS_NONFRAG_IPV4_SCTP,
87 : : [IDPF_HASH_NONF_IPV4_OTHER] =
88 : : RTE_ETH_RSS_NONFRAG_IPV4_OTHER,
89 : : [IDPF_HASH_FRAG_IPV4] = RTE_ETH_RSS_FRAG_IPV4,
90 : :
91 : : /* IPv6 */
92 : : [IDPF_HASH_NONF_UNICAST_IPV6_UDP] =
93 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP,
94 : : [IDPF_HASH_NONF_MULTICAST_IPV6_UDP] =
95 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP,
96 : : [IDPF_HASH_NONF_IPV6_UDP] =
97 : : RTE_ETH_RSS_NONFRAG_IPV6_UDP,
98 : : [IDPF_HASH_NONF_IPV6_TCP_SYN_NO_ACK] =
99 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP,
100 : : [IDPF_HASH_NONF_IPV6_TCP] =
101 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP,
102 : : [IDPF_HASH_NONF_IPV6_SCTP] =
103 : : RTE_ETH_RSS_NONFRAG_IPV6_SCTP,
104 : : [IDPF_HASH_NONF_IPV6_OTHER] =
105 : : RTE_ETH_RSS_NONFRAG_IPV6_OTHER,
106 : : [IDPF_HASH_FRAG_IPV6] = RTE_ETH_RSS_FRAG_IPV6,
107 : :
108 : : /* L2 Payload */
109 : : [IDPF_HASH_L2_PAYLOAD] = RTE_ETH_RSS_L2_PAYLOAD
110 : : };
111 : :
112 : : static const uint64_t cpfl_ipv4_rss = RTE_ETH_RSS_NONFRAG_IPV4_UDP |
113 : : RTE_ETH_RSS_NONFRAG_IPV4_TCP |
114 : : RTE_ETH_RSS_NONFRAG_IPV4_SCTP |
115 : : RTE_ETH_RSS_NONFRAG_IPV4_OTHER |
116 : : RTE_ETH_RSS_FRAG_IPV4;
117 : :
118 : : static const uint64_t cpfl_ipv6_rss = RTE_ETH_RSS_NONFRAG_IPV6_UDP |
119 : : RTE_ETH_RSS_NONFRAG_IPV6_TCP |
120 : : RTE_ETH_RSS_NONFRAG_IPV6_SCTP |
121 : : RTE_ETH_RSS_NONFRAG_IPV6_OTHER |
122 : : RTE_ETH_RSS_FRAG_IPV6;
123 : :
124 : : struct rte_cpfl_xstats_name_off {
125 : : char name[RTE_ETH_XSTATS_NAME_SIZE];
126 : : unsigned int offset;
127 : : };
128 : :
129 : : static const struct rte_cpfl_xstats_name_off rte_cpfl_stats_strings[] = {
130 : : {"rx_bytes", offsetof(struct virtchnl2_vport_stats, rx_bytes)},
131 : : {"rx_unicast_packets", offsetof(struct virtchnl2_vport_stats, rx_unicast)},
132 : : {"rx_multicast_packets", offsetof(struct virtchnl2_vport_stats, rx_multicast)},
133 : : {"rx_broadcast_packets", offsetof(struct virtchnl2_vport_stats, rx_broadcast)},
134 : : {"rx_dropped_packets", offsetof(struct virtchnl2_vport_stats, rx_discards)},
135 : : {"rx_errors", offsetof(struct virtchnl2_vport_stats, rx_errors)},
136 : : {"rx_unknown_protocol_packets", offsetof(struct virtchnl2_vport_stats,
137 : : rx_unknown_protocol)},
138 : : {"tx_bytes", offsetof(struct virtchnl2_vport_stats, tx_bytes)},
139 : : {"tx_unicast_packets", offsetof(struct virtchnl2_vport_stats, tx_unicast)},
140 : : {"tx_multicast_packets", offsetof(struct virtchnl2_vport_stats, tx_multicast)},
141 : : {"tx_broadcast_packets", offsetof(struct virtchnl2_vport_stats, tx_broadcast)},
142 : : {"tx_dropped_packets", offsetof(struct virtchnl2_vport_stats, tx_discards)},
143 : : {"tx_error_packets", offsetof(struct virtchnl2_vport_stats, tx_errors)}};
144 : :
145 : : #define CPFL_NB_XSTATS RTE_DIM(rte_cpfl_stats_strings)
146 : :
147 : : static int
148 : 0 : cpfl_dev_link_update(struct rte_eth_dev *dev,
149 : : __rte_unused int wait_to_complete)
150 : : {
151 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
152 : : struct idpf_vport *vport = &cpfl_vport->base;
153 : : struct rte_eth_link new_link;
154 : : unsigned int i;
155 : :
156 : : memset(&new_link, 0, sizeof(new_link));
157 : :
158 [ # # ]: 0 : for (i = 0; i < RTE_DIM(cpfl_supported_speeds); i++) {
159 [ # # ]: 0 : if (vport->link_speed == cpfl_supported_speeds[i]) {
160 : 0 : new_link.link_speed = vport->link_speed;
161 : 0 : break;
162 : : }
163 : : }
164 : :
165 [ # # ]: 0 : if (i == RTE_DIM(cpfl_supported_speeds)) {
166 [ # # ]: 0 : if (vport->link_up)
167 : 0 : new_link.link_speed = RTE_ETH_SPEED_NUM_UNKNOWN;
168 : : else
169 : 0 : new_link.link_speed = RTE_ETH_SPEED_NUM_NONE;
170 : : }
171 : :
172 : 0 : new_link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
173 : 0 : new_link.link_status = vport->link_up ? RTE_ETH_LINK_UP :
174 : : RTE_ETH_LINK_DOWN;
175 : 0 : new_link.link_autoneg = (dev->data->dev_conf.link_speeds & RTE_ETH_LINK_SPEED_FIXED) ?
176 [ # # ]: 0 : RTE_ETH_LINK_FIXED : RTE_ETH_LINK_AUTONEG;
177 : :
178 : 0 : return rte_eth_linkstatus_set(dev, &new_link);
179 : : }
180 : :
181 : : static int
182 : 0 : cpfl_hairpin_cap_get(struct rte_eth_dev *dev,
183 : : struct rte_eth_hairpin_cap *cap)
184 : : {
185 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
186 : :
187 [ # # ]: 0 : if (cpfl_vport->p2p_q_chunks_info == NULL)
188 : : return -ENOTSUP;
189 : :
190 : 0 : cap->max_nb_queues = CPFL_MAX_P2P_NB_QUEUES;
191 : 0 : cap->max_rx_2_tx = CPFL_MAX_HAIRPINQ_RX_2_TX;
192 : 0 : cap->max_tx_2_rx = CPFL_MAX_HAIRPINQ_TX_2_RX;
193 : 0 : cap->max_nb_desc = CPFL_MAX_HAIRPINQ_NB_DESC;
194 : :
195 : 0 : return 0;
196 : : }
197 : :
198 : : static int
199 : 0 : cpfl_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
200 : : {
201 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
202 : : struct idpf_vport *vport = &cpfl_vport->base;
203 : 0 : struct idpf_adapter *base = vport->adapter;
204 : :
205 : 0 : dev_info->max_rx_queues = base->caps.max_rx_q;
206 : 0 : dev_info->max_tx_queues = base->caps.max_tx_q;
207 : 0 : dev_info->min_rx_bufsize = CPFL_MIN_BUF_SIZE;
208 : 0 : dev_info->max_rx_pktlen = vport->max_mtu + CPFL_ETH_OVERHEAD;
209 : :
210 : 0 : dev_info->max_mtu = vport->max_mtu;
211 : 0 : dev_info->min_mtu = RTE_ETHER_MIN_MTU;
212 : :
213 [ # # ]: 0 : if (base->caps.rss_caps != 0) {
214 : 0 : dev_info->hash_key_size = vport->rss_key_size;
215 : 0 : dev_info->reta_size = vport->rss_lut_size;
216 : 0 : dev_info->flow_type_rss_offloads = CPFL_RSS_OFFLOAD_ALL;
217 : : }
218 : :
219 : 0 : dev_info->rx_offload_capa =
220 : : RTE_ETH_RX_OFFLOAD_IPV4_CKSUM |
221 : : RTE_ETH_RX_OFFLOAD_UDP_CKSUM |
222 : : RTE_ETH_RX_OFFLOAD_TCP_CKSUM |
223 : : RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
224 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP |
225 : : RTE_ETH_RX_OFFLOAD_SCATTER;
226 : :
227 : 0 : dev_info->tx_offload_capa =
228 : : RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
229 : : RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
230 : : RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
231 : : RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
232 : : RTE_ETH_TX_OFFLOAD_TCP_TSO |
233 : : RTE_ETH_TX_OFFLOAD_MULTI_SEGS |
234 : : RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
235 : :
236 : 0 : dev_info->default_txconf = (struct rte_eth_txconf) {
237 : : .tx_free_thresh = CPFL_DEFAULT_TX_FREE_THRESH,
238 : : .tx_rs_thresh = CPFL_DEFAULT_TX_RS_THRESH,
239 : : };
240 : :
241 : 0 : dev_info->default_rxconf = (struct rte_eth_rxconf) {
242 : : .rx_free_thresh = CPFL_DEFAULT_RX_FREE_THRESH,
243 : : };
244 : :
245 : 0 : dev_info->tx_desc_lim = (struct rte_eth_desc_lim) {
246 : : .nb_max = CPFL_MAX_RING_DESC,
247 : : .nb_min = CPFL_MIN_RING_DESC,
248 : : .nb_align = CPFL_ALIGN_RING_DESC,
249 : : };
250 : :
251 : 0 : dev_info->rx_desc_lim = (struct rte_eth_desc_lim) {
252 : : .nb_max = CPFL_MAX_RING_DESC,
253 : : .nb_min = CPFL_MIN_RING_DESC,
254 : : .nb_align = CPFL_ALIGN_RING_DESC,
255 : : };
256 : :
257 : 0 : return 0;
258 : : }
259 : :
260 : : static int
261 : 0 : cpfl_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
262 : : {
263 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
264 : : struct idpf_vport *vport = &cpfl_vport->base;
265 : :
266 : : /* mtu setting is forbidden if port is start */
267 [ # # ]: 0 : if (dev->data->dev_started) {
268 : 0 : PMD_DRV_LOG(ERR, "port must be stopped before configuration");
269 : 0 : return -EBUSY;
270 : : }
271 : :
272 [ # # ]: 0 : if (mtu > vport->max_mtu) {
273 : 0 : PMD_DRV_LOG(ERR, "MTU should be less than %d", vport->max_mtu);
274 : 0 : return -EINVAL;
275 : : }
276 : :
277 : 0 : vport->max_pkt_len = mtu + CPFL_ETH_OVERHEAD;
278 : :
279 : 0 : return 0;
280 : : }
281 : :
282 : : static const uint32_t *
283 : 0 : cpfl_dev_supported_ptypes_get(struct rte_eth_dev *dev __rte_unused,
284 : : size_t *no_of_elements)
285 : : {
286 : : static const uint32_t ptypes[] = {
287 : : RTE_PTYPE_L2_ETHER,
288 : : RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
289 : : RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
290 : : RTE_PTYPE_L4_FRAG,
291 : : RTE_PTYPE_L4_UDP,
292 : : RTE_PTYPE_L4_TCP,
293 : : RTE_PTYPE_L4_SCTP,
294 : : RTE_PTYPE_L4_ICMP,
295 : : };
296 : :
297 : 0 : *no_of_elements = RTE_DIM(ptypes);
298 : 0 : return ptypes;
299 : : }
300 : :
301 : : static uint64_t
302 : 0 : cpfl_get_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)
303 : : {
304 : : uint64_t mbuf_alloc_failed = 0;
305 : : struct cpfl_rx_queue *cpfl_rxq;
306 : : int i = 0;
307 : :
308 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
309 : 0 : cpfl_rxq = dev->data->rx_queues[i];
310 : 0 : mbuf_alloc_failed +=
311 : 0 : rte_atomic_load_explicit(&cpfl_rxq->base.rx_stats.mbuf_alloc_failed,
312 : : rte_memory_order_relaxed);
313 : : }
314 : :
315 : 0 : return mbuf_alloc_failed;
316 : : }
317 : :
318 : : static int
319 : 0 : cpfl_dev_stats_get(struct rte_eth_dev *dev, struct rte_eth_stats *stats,
320 : : struct eth_queue_stats *qstats __rte_unused)
321 : : {
322 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
323 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
324 : 0 : struct virtchnl2_vport_stats *pstats = NULL;
325 : : int ret;
326 : :
327 : 0 : ret = idpf_vc_stats_query(vport, &pstats);
328 [ # # ]: 0 : if (ret == 0) {
329 [ # # ]: 0 : uint8_t crc_stats_len = (dev->data->dev_conf.rxmode.offloads &
330 : : RTE_ETH_RX_OFFLOAD_KEEP_CRC) ? 0 :
331 : : RTE_ETHER_CRC_LEN;
332 : :
333 : 0 : idpf_vport_stats_update(&vport->eth_stats_offset, pstats);
334 : 0 : stats->ipackets = pstats->rx_unicast + pstats->rx_multicast +
335 : 0 : pstats->rx_broadcast;
336 : 0 : stats->opackets = pstats->tx_broadcast + pstats->tx_multicast +
337 : 0 : pstats->tx_unicast;
338 : 0 : stats->imissed = pstats->rx_discards;
339 : 0 : stats->ierrors = pstats->rx_errors;
340 : 0 : stats->oerrors = pstats->tx_errors + pstats->tx_discards;
341 : 0 : stats->ibytes = pstats->rx_bytes;
342 : 0 : stats->ibytes -= stats->ipackets * crc_stats_len;
343 : 0 : stats->obytes = pstats->tx_bytes;
344 : :
345 : 0 : dev->data->rx_mbuf_alloc_failed = cpfl_get_mbuf_alloc_failed_stats(dev);
346 : 0 : stats->rx_nombuf = dev->data->rx_mbuf_alloc_failed;
347 : : } else {
348 : 0 : PMD_DRV_LOG(ERR, "Get statistics failed");
349 : : }
350 : 0 : return ret;
351 : : }
352 : :
353 : : static void
354 : 0 : cpfl_reset_mbuf_alloc_failed_stats(struct rte_eth_dev *dev)
355 : : {
356 : : struct cpfl_rx_queue *cpfl_rxq;
357 : : int i;
358 : :
359 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
360 : 0 : cpfl_rxq = dev->data->rx_queues[i];
361 : 0 : rte_atomic_store_explicit(&cpfl_rxq->base.rx_stats.mbuf_alloc_failed, 0,
362 : : rte_memory_order_relaxed);
363 : : }
364 : 0 : }
365 : :
366 : : static int
367 : 0 : cpfl_dev_stats_reset(struct rte_eth_dev *dev)
368 : : {
369 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
370 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
371 : 0 : struct virtchnl2_vport_stats *pstats = NULL;
372 : : int ret;
373 : :
374 : : /* VF devices do not support VIRTCHNL2_OP_GET_STATS */
375 [ # # ]: 0 : if (idpf_is_vf_device(&vport->adapter->hw)) {
376 : 0 : cpfl_reset_mbuf_alloc_failed_stats(dev);
377 : 0 : return 0;
378 : : }
379 : :
380 : 0 : ret = idpf_vc_stats_query(vport, &pstats);
381 [ # # ]: 0 : if (ret != 0)
382 : : return ret;
383 : :
384 : : /* set stats offset base on current values */
385 : 0 : vport->eth_stats_offset = *pstats;
386 : :
387 : 0 : cpfl_reset_mbuf_alloc_failed_stats(dev);
388 : :
389 : 0 : return 0;
390 : : }
391 : :
392 : 0 : static int cpfl_dev_xstats_reset(struct rte_eth_dev *dev)
393 : : {
394 : 0 : cpfl_dev_stats_reset(dev);
395 : 0 : return 0;
396 : : }
397 : :
398 : 0 : static int cpfl_dev_xstats_get(struct rte_eth_dev *dev,
399 : : struct rte_eth_xstat *xstats, unsigned int n)
400 : : {
401 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
402 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
403 : 0 : struct virtchnl2_vport_stats *pstats = NULL;
404 : : unsigned int i;
405 : : int ret;
406 : :
407 [ # # ]: 0 : if (n < CPFL_NB_XSTATS)
408 : : return CPFL_NB_XSTATS;
409 : :
410 [ # # ]: 0 : if (!xstats)
411 : : return CPFL_NB_XSTATS;
412 : :
413 : 0 : ret = idpf_vc_stats_query(vport, &pstats);
414 [ # # ]: 0 : if (ret) {
415 : 0 : PMD_DRV_LOG(ERR, "Get statistics failed");
416 : 0 : return 0;
417 : : }
418 : :
419 : 0 : idpf_vport_stats_update(&vport->eth_stats_offset, pstats);
420 : :
421 : : /* loop over xstats array and values from pstats */
422 [ # # ]: 0 : for (i = 0; i < CPFL_NB_XSTATS; i++) {
423 : 0 : xstats[i].id = i;
424 : 0 : xstats[i].value = *(uint64_t *)(((char *)pstats) +
425 : 0 : rte_cpfl_stats_strings[i].offset);
426 : : }
427 : : return CPFL_NB_XSTATS;
428 : : }
429 : :
430 : 0 : static int cpfl_dev_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
431 : : struct rte_eth_xstat_name *xstats_names,
432 : : __rte_unused unsigned int limit)
433 : : {
434 : : unsigned int i;
435 : :
436 [ # # ]: 0 : if (xstats_names) {
437 [ # # ]: 0 : for (i = 0; i < CPFL_NB_XSTATS; i++) {
438 : 0 : snprintf(xstats_names[i].name,
439 : : sizeof(xstats_names[i].name),
440 : 0 : "%s", rte_cpfl_stats_strings[i].name);
441 : : }
442 : : }
443 : 0 : return CPFL_NB_XSTATS;
444 : : }
445 : :
446 : 0 : static int cpfl_config_rss_hf(struct idpf_vport *vport, uint64_t rss_hf)
447 : : {
448 : : uint64_t hena = 0;
449 : : uint16_t i;
450 : :
451 : : /**
452 : : * RTE_ETH_RSS_IPV4 and RTE_ETH_RSS_IPV6 can be considered as 2
453 : : * generalizations of all other IPv4 and IPv6 RSS types.
454 : : */
455 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV4)
456 : 0 : rss_hf |= cpfl_ipv4_rss;
457 : :
458 [ # # ]: 0 : if (rss_hf & RTE_ETH_RSS_IPV6)
459 : 0 : rss_hf |= cpfl_ipv6_rss;
460 : :
461 [ # # ]: 0 : for (i = 0; i < RTE_DIM(cpfl_map_hena_rss); i++) {
462 [ # # ]: 0 : if (cpfl_map_hena_rss[i] & rss_hf)
463 : 0 : hena |= BIT_ULL(i);
464 : : }
465 : :
466 : : /**
467 : : * At present, cp doesn't process the virtual channel msg of rss_hf configuration,
468 : : * tips are given below.
469 : : */
470 [ # # ]: 0 : if (hena != vport->rss_hf)
471 : 0 : PMD_DRV_LOG(WARNING, "Updating RSS Hash Function is not supported at present.");
472 : :
473 : 0 : return 0;
474 : : }
475 : :
476 : : static int
477 : 0 : cpfl_init_rss(struct idpf_vport *vport)
478 : : {
479 : : struct rte_eth_rss_conf *rss_conf;
480 : : struct rte_eth_dev_data *dev_data;
481 : : uint16_t i, nb_q;
482 : : int ret = 0;
483 : :
484 : 0 : dev_data = vport->dev_data;
485 : : rss_conf = &dev_data->dev_conf.rx_adv_conf.rss_conf;
486 : 0 : nb_q = dev_data->nb_rx_queues;
487 : :
488 [ # # ]: 0 : if (rss_conf->rss_key == NULL) {
489 [ # # ]: 0 : for (i = 0; i < vport->rss_key_size; i++)
490 : 0 : vport->rss_key[i] = (uint8_t)rte_rand();
491 [ # # ]: 0 : } else if (rss_conf->rss_key_len != vport->rss_key_size) {
492 : 0 : PMD_INIT_LOG(ERR, "Invalid RSS key length in RSS configuration, should be %d",
493 : : vport->rss_key_size);
494 : 0 : return -EINVAL;
495 : : } else {
496 : 0 : memcpy(vport->rss_key, rss_conf->rss_key,
497 : : vport->rss_key_size);
498 : : }
499 : :
500 [ # # ]: 0 : for (i = 0; i < vport->rss_lut_size; i++)
501 : 0 : vport->rss_lut[i] = i % nb_q;
502 : :
503 : 0 : vport->rss_hf = IDPF_DEFAULT_RSS_HASH_EXPANDED;
504 : :
505 : 0 : ret = idpf_vport_rss_config(vport);
506 [ # # ]: 0 : if (ret != 0)
507 : 0 : PMD_INIT_LOG(ERR, "Failed to configure RSS");
508 : :
509 : : return ret;
510 : : }
511 : :
512 : : static int
513 : 0 : cpfl_rss_reta_update(struct rte_eth_dev *dev,
514 : : struct rte_eth_rss_reta_entry64 *reta_conf,
515 : : uint16_t reta_size)
516 : : {
517 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
518 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
519 : 0 : struct idpf_adapter *base = vport->adapter;
520 : : uint16_t idx, shift;
521 : : int ret = 0;
522 : : uint16_t i;
523 : :
524 [ # # # # ]: 0 : if (base->caps.rss_caps == 0 || dev->data->nb_rx_queues == 0) {
525 : 0 : PMD_DRV_LOG(DEBUG, "RSS is not supported");
526 : 0 : return -ENOTSUP;
527 : : }
528 : :
529 [ # # ]: 0 : if (reta_size != vport->rss_lut_size) {
530 : 0 : PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
531 : : "(%d) doesn't match the number of hardware can "
532 : : "support (%d)",
533 : : reta_size, vport->rss_lut_size);
534 : 0 : return -EINVAL;
535 : : }
536 : :
537 [ # # ]: 0 : for (i = 0; i < reta_size; i++) {
538 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
539 : 0 : shift = i % RTE_ETH_RETA_GROUP_SIZE;
540 [ # # ]: 0 : if (reta_conf[idx].mask & (1ULL << shift))
541 : 0 : vport->rss_lut[i] = reta_conf[idx].reta[shift];
542 : : }
543 : :
544 : : /* send virtchnl ops to configure RSS */
545 : 0 : ret = idpf_vc_rss_lut_set(vport);
546 [ # # ]: 0 : if (ret)
547 : 0 : PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
548 : :
549 : : return ret;
550 : : }
551 : :
552 : : static int
553 : 0 : cpfl_rss_reta_query(struct rte_eth_dev *dev,
554 : : struct rte_eth_rss_reta_entry64 *reta_conf,
555 : : uint16_t reta_size)
556 : : {
557 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
558 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
559 : 0 : struct idpf_adapter *base = vport->adapter;
560 : : uint16_t idx, shift;
561 : : int ret = 0;
562 : : uint16_t i;
563 : :
564 [ # # # # ]: 0 : if (base->caps.rss_caps == 0 || dev->data->nb_rx_queues == 0) {
565 : 0 : PMD_DRV_LOG(DEBUG, "RSS is not supported");
566 : 0 : return -ENOTSUP;
567 : : }
568 : :
569 [ # # ]: 0 : if (reta_size != vport->rss_lut_size) {
570 : 0 : PMD_DRV_LOG(ERR, "The size of hash lookup table configured "
571 : : "(%d) doesn't match the number of hardware can "
572 : : "support (%d)", reta_size, vport->rss_lut_size);
573 : 0 : return -EINVAL;
574 : : }
575 : :
576 : 0 : ret = idpf_vc_rss_lut_get(vport);
577 [ # # ]: 0 : if (ret) {
578 : 0 : PMD_DRV_LOG(ERR, "Failed to get RSS LUT");
579 : 0 : return ret;
580 : : }
581 : :
582 [ # # ]: 0 : for (i = 0; i < reta_size; i++) {
583 : 0 : idx = i / RTE_ETH_RETA_GROUP_SIZE;
584 : 0 : shift = i % RTE_ETH_RETA_GROUP_SIZE;
585 [ # # ]: 0 : if (reta_conf[idx].mask & (1ULL << shift))
586 : 0 : reta_conf[idx].reta[shift] = vport->rss_lut[i];
587 : : }
588 : :
589 : : return 0;
590 : : }
591 : :
592 : : static int
593 : 0 : cpfl_rss_hash_update(struct rte_eth_dev *dev,
594 : : struct rte_eth_rss_conf *rss_conf)
595 : : {
596 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
597 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
598 : 0 : struct idpf_adapter *base = vport->adapter;
599 : : int ret = 0;
600 : :
601 [ # # # # ]: 0 : if (base->caps.rss_caps == 0 || dev->data->nb_rx_queues == 0) {
602 : 0 : PMD_DRV_LOG(DEBUG, "RSS is not supported");
603 : 0 : return -ENOTSUP;
604 : : }
605 : :
606 [ # # # # ]: 0 : if (!rss_conf->rss_key || rss_conf->rss_key_len == 0) {
607 : 0 : PMD_DRV_LOG(DEBUG, "No key to be configured");
608 : 0 : goto skip_rss_key;
609 [ # # ]: 0 : } else if (rss_conf->rss_key_len != vport->rss_key_size) {
610 : 0 : PMD_DRV_LOG(ERR, "The size of hash key configured "
611 : : "(%d) doesn't match the size of hardware can "
612 : : "support (%d)",
613 : : rss_conf->rss_key_len,
614 : : vport->rss_key_size);
615 : 0 : return -EINVAL;
616 : : }
617 : :
618 : 0 : memcpy(vport->rss_key, rss_conf->rss_key,
619 : : vport->rss_key_size);
620 : 0 : ret = idpf_vc_rss_key_set(vport);
621 [ # # ]: 0 : if (ret != 0) {
622 : 0 : PMD_INIT_LOG(ERR, "Failed to configure RSS key");
623 : 0 : return ret;
624 : : }
625 : :
626 : 0 : skip_rss_key:
627 : 0 : ret = cpfl_config_rss_hf(vport, rss_conf->rss_hf);
628 [ # # ]: 0 : if (ret != 0) {
629 : 0 : PMD_INIT_LOG(ERR, "Failed to configure RSS hash");
630 : 0 : return ret;
631 : : }
632 : :
633 : : return 0;
634 : : }
635 : :
636 : : static uint64_t
637 : 0 : cpfl_map_general_rss_hf(uint64_t config_rss_hf, uint64_t last_general_rss_hf)
638 : : {
639 : : uint64_t valid_rss_hf = 0;
640 : : uint16_t i;
641 : :
642 [ # # ]: 0 : for (i = 0; i < RTE_DIM(cpfl_map_hena_rss); i++) {
643 : 0 : uint64_t bit = BIT_ULL(i);
644 : :
645 [ # # ]: 0 : if (bit & config_rss_hf)
646 : 0 : valid_rss_hf |= cpfl_map_hena_rss[i];
647 : : }
648 : :
649 [ # # ]: 0 : if (valid_rss_hf & cpfl_ipv4_rss)
650 : 0 : valid_rss_hf |= last_general_rss_hf & RTE_ETH_RSS_IPV4;
651 : :
652 [ # # ]: 0 : if (valid_rss_hf & cpfl_ipv6_rss)
653 : 0 : valid_rss_hf |= last_general_rss_hf & RTE_ETH_RSS_IPV6;
654 : :
655 : 0 : return valid_rss_hf;
656 : : }
657 : :
658 : : static int
659 : 0 : cpfl_rss_hash_conf_get(struct rte_eth_dev *dev,
660 : : struct rte_eth_rss_conf *rss_conf)
661 : : {
662 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
663 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
664 : 0 : struct idpf_adapter *base = vport->adapter;
665 : : int ret = 0;
666 : :
667 [ # # # # ]: 0 : if (base->caps.rss_caps == 0 || dev->data->nb_rx_queues == 0) {
668 : 0 : PMD_DRV_LOG(DEBUG, "RSS is not supported");
669 : 0 : return -ENOTSUP;
670 : : }
671 : :
672 : 0 : ret = idpf_vc_rss_hash_get(vport);
673 [ # # ]: 0 : if (ret) {
674 : 0 : PMD_DRV_LOG(ERR, "Failed to get RSS hf");
675 : 0 : return ret;
676 : : }
677 : :
678 : 0 : rss_conf->rss_hf = cpfl_map_general_rss_hf(vport->rss_hf, vport->last_general_rss_hf);
679 : :
680 [ # # ]: 0 : if (!rss_conf->rss_key)
681 : : return 0;
682 : :
683 : 0 : ret = idpf_vc_rss_key_get(vport);
684 [ # # ]: 0 : if (ret) {
685 : 0 : PMD_DRV_LOG(ERR, "Failed to get RSS key");
686 : 0 : return ret;
687 : : }
688 : :
689 [ # # ]: 0 : if (rss_conf->rss_key_len > vport->rss_key_size)
690 : 0 : rss_conf->rss_key_len = vport->rss_key_size;
691 : :
692 : 0 : memcpy(rss_conf->rss_key, vport->rss_key, rss_conf->rss_key_len);
693 : :
694 : 0 : return 0;
695 : : }
696 : :
697 : : static int
698 : 0 : cpfl_dev_configure(struct rte_eth_dev *dev)
699 : : {
700 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
701 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
702 : : struct rte_eth_conf *conf = &dev->data->dev_conf;
703 : 0 : struct idpf_adapter *base = vport->adapter;
704 : : int ret;
705 : :
706 [ # # ]: 0 : if (conf->link_speeds & RTE_ETH_LINK_SPEED_FIXED) {
707 : 0 : PMD_INIT_LOG(ERR, "Setting link speed is not supported");
708 : 0 : return -ENOTSUP;
709 : : }
710 : :
711 [ # # ]: 0 : if (conf->lpbk_mode != 0) {
712 : 0 : PMD_INIT_LOG(ERR, "Loopback operation mode %d is not supported",
713 : : conf->lpbk_mode);
714 : 0 : return -ENOTSUP;
715 : : }
716 : :
717 [ # # ]: 0 : if (conf->dcb_capability_en != 0) {
718 : 0 : PMD_INIT_LOG(ERR, "Priority Flow Control(PFC) if not supported");
719 : 0 : return -ENOTSUP;
720 : : }
721 : :
722 [ # # ]: 0 : if (conf->intr_conf.lsc != 0) {
723 : 0 : PMD_INIT_LOG(ERR, "LSC interrupt is not supported");
724 : 0 : return -ENOTSUP;
725 : : }
726 : :
727 [ # # ]: 0 : if (conf->intr_conf.rxq != 0) {
728 : 0 : PMD_INIT_LOG(ERR, "RXQ interrupt is not supported");
729 : 0 : return -ENOTSUP;
730 : : }
731 : :
732 [ # # ]: 0 : if (conf->intr_conf.rmv != 0) {
733 : 0 : PMD_INIT_LOG(ERR, "RMV interrupt is not supported");
734 : 0 : return -ENOTSUP;
735 : : }
736 : :
737 [ # # # # ]: 0 : if (base->caps.rss_caps != 0 && dev->data->nb_rx_queues != 0) {
738 : 0 : ret = cpfl_init_rss(vport);
739 [ # # ]: 0 : if (ret != 0) {
740 : 0 : PMD_INIT_LOG(ERR, "Failed to init rss");
741 : 0 : return ret;
742 : : }
743 : : }
744 : :
745 : 0 : vport->max_pkt_len =
746 [ # # ]: 0 : (dev->data->mtu == 0) ? CPFL_DEFAULT_MTU : dev->data->mtu +
747 : : CPFL_ETH_OVERHEAD;
748 : :
749 : 0 : return 0;
750 : : }
751 : :
752 : : static int
753 : 0 : cpfl_config_rx_queues_irqs(struct rte_eth_dev *dev)
754 : : {
755 : 0 : uint32_t qids[CPFL_MAX_P2P_NB_QUEUES + IDPF_DEFAULT_RXQ_NUM] = {0};
756 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
757 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
758 : 0 : uint16_t nb_rx_queues = dev->data->nb_rx_queues;
759 : : struct cpfl_rx_queue *cpfl_rxq;
760 : : int i;
761 : :
762 [ # # ]: 0 : for (i = 0; i < nb_rx_queues; i++) {
763 : 0 : cpfl_rxq = dev->data->rx_queues[i];
764 [ # # ]: 0 : if (cpfl_rxq->hairpin_info.hairpin_q)
765 : 0 : qids[i] = cpfl_hw_qid_get(cpfl_vport->p2p_q_chunks_info->rx_start_qid,
766 : 0 : (i - cpfl_vport->nb_data_rxq));
767 : : else
768 : 0 : qids[i] = cpfl_hw_qid_get(vport->chunks_info.rx_start_qid, i);
769 : : }
770 : 0 : return idpf_vport_irq_map_config_by_qids(vport, qids, nb_rx_queues);
771 : : }
772 : :
773 : : /* Update hairpin_info for dev's tx hairpin queue */
774 : : static int
775 : 0 : cpfl_txq_hairpin_info_update(struct rte_eth_dev *dev, uint16_t rx_port)
776 : : {
777 : 0 : struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private;
778 : 0 : struct rte_eth_dev *peer_dev = &rte_eth_devices[rx_port];
779 : 0 : struct cpfl_vport *cpfl_rx_vport = peer_dev->data->dev_private;
780 : : struct cpfl_txq_hairpin_info *hairpin_info;
781 : : struct cpfl_tx_queue *cpfl_txq;
782 : : int i;
783 : :
784 [ # # ]: 0 : for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) {
785 : 0 : cpfl_txq = dev->data->tx_queues[i];
786 : : hairpin_info = &cpfl_txq->hairpin_info;
787 [ # # ]: 0 : if (hairpin_info->peer_rxp != rx_port) {
788 : 0 : PMD_DRV_LOG(ERR, "port %d is not the peer port", rx_port);
789 : 0 : return -EINVAL;
790 : : }
791 : 0 : hairpin_info->peer_rxq_id =
792 : 0 : cpfl_hw_qid_get(cpfl_rx_vport->p2p_q_chunks_info->rx_start_qid,
793 : 0 : hairpin_info->peer_rxq_id - cpfl_rx_vport->nb_data_rxq);
794 : : }
795 : :
796 : : return 0;
797 : : }
798 : :
799 : : /* Bind Rx hairpin queue's memory zone to peer Tx hairpin queue's memory zone */
800 : : static void
801 : 0 : cpfl_rxq_hairpin_mz_bind(struct rte_eth_dev *dev)
802 : : {
803 : 0 : struct cpfl_vport *cpfl_rx_vport = dev->data->dev_private;
804 : : struct idpf_vport *vport = &cpfl_rx_vport->base;
805 : 0 : struct idpf_adapter *adapter = vport->adapter;
806 : : struct idpf_hw *hw = &adapter->hw;
807 : : struct cpfl_rx_queue *cpfl_rxq;
808 : : struct cpfl_tx_queue *cpfl_txq;
809 : : struct rte_eth_dev *peer_dev;
810 : : const struct rte_memzone *mz;
811 : : uint16_t peer_tx_port;
812 : : uint16_t peer_tx_qid;
813 : : int i;
814 : :
815 [ # # ]: 0 : for (i = cpfl_rx_vport->nb_data_rxq; i < dev->data->nb_rx_queues; i++) {
816 : 0 : cpfl_rxq = dev->data->rx_queues[i];
817 : 0 : peer_tx_port = cpfl_rxq->hairpin_info.peer_txp;
818 : 0 : peer_tx_qid = cpfl_rxq->hairpin_info.peer_txq_id;
819 : 0 : peer_dev = &rte_eth_devices[peer_tx_port];
820 : 0 : cpfl_txq = peer_dev->data->tx_queues[peer_tx_qid];
821 : :
822 : : /* bind rx queue */
823 : 0 : mz = cpfl_txq->base.mz;
824 : 0 : cpfl_rxq->base.rx_ring_phys_addr = mz->iova;
825 : 0 : cpfl_rxq->base.rx_ring = mz->addr;
826 : 0 : cpfl_rxq->base.mz = mz;
827 : :
828 : : /* bind rx buffer queue */
829 : 0 : mz = cpfl_txq->base.complq->mz;
830 : 0 : cpfl_rxq->base.bufq1->rx_ring_phys_addr = mz->iova;
831 : 0 : cpfl_rxq->base.bufq1->rx_ring = mz->addr;
832 : 0 : cpfl_rxq->base.bufq1->mz = mz;
833 : 0 : cpfl_rxq->base.bufq1->qrx_tail = hw->hw_addr +
834 : 0 : cpfl_hw_qtail_get(cpfl_rx_vport->p2p_q_chunks_info->rx_buf_qtail_start,
835 : 0 : 0, cpfl_rx_vport->p2p_q_chunks_info->rx_buf_qtail_spacing);
836 : : }
837 : 0 : }
838 : :
839 : : static int
840 : 0 : cpfl_rss_lut_config(struct cpfl_vport *cpfl_vport, uint16_t nb_q)
841 : : {
842 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
843 : 0 : uint16_t lut_size = vport->rss_lut_size;
844 : : uint16_t i;
845 : : int ret;
846 : :
847 [ # # ]: 0 : for (i = 0; i < lut_size; i++)
848 : 0 : vport->rss_lut[i] = i % nb_q;
849 : :
850 : 0 : ret = idpf_vc_rss_lut_set(vport);
851 [ # # ]: 0 : if (ret)
852 : 0 : PMD_INIT_LOG(ERR, "Failed to configure RSS lut");
853 : :
854 : 0 : return ret;
855 : : }
856 : :
857 : : static int
858 : 0 : cpfl_start_queues(struct rte_eth_dev *dev)
859 : : {
860 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
861 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
862 : : struct cpfl_rx_queue *cpfl_rxq;
863 : : struct cpfl_tx_queue *cpfl_txq;
864 : : int update_flag = 0;
865 : : int err = 0;
866 : : int i;
867 : :
868 : : /* For normal data queues, configure, init and enale Txq.
869 : : * For non-manual bind hairpin queues, configure Txq.
870 : : */
871 [ # # ]: 0 : for (i = 0; i < dev->data->nb_tx_queues; i++) {
872 : 0 : cpfl_txq = dev->data->tx_queues[i];
873 [ # # # # ]: 0 : if (cpfl_txq == NULL || cpfl_txq->base.tx_deferred_start)
874 : 0 : continue;
875 [ # # ]: 0 : if (!cpfl_txq->hairpin_info.hairpin_q) {
876 : 0 : err = cpfl_tx_queue_start(dev, i);
877 [ # # ]: 0 : if (err != 0) {
878 : 0 : PMD_DRV_LOG(ERR, "Fail to start Tx queue %u", i);
879 : 0 : return err;
880 : : }
881 [ # # ]: 0 : } else if (!cpfl_vport->p2p_manual_bind) {
882 [ # # ]: 0 : if (update_flag == 0) {
883 : 0 : err = cpfl_txq_hairpin_info_update(dev,
884 : 0 : cpfl_txq->hairpin_info.peer_rxp);
885 [ # # ]: 0 : if (err != 0) {
886 : 0 : PMD_DRV_LOG(ERR, "Fail to update Tx hairpin queue info");
887 : 0 : return err;
888 : : }
889 : : update_flag = 1;
890 : : }
891 : 0 : err = cpfl_hairpin_txq_config(vport, cpfl_txq);
892 [ # # ]: 0 : if (err != 0) {
893 : 0 : PMD_DRV_LOG(ERR, "Fail to configure hairpin Tx queue %u", i);
894 : 0 : return err;
895 : : }
896 : : }
897 : : }
898 : :
899 : : /* For non-manual bind hairpin queues, configure Tx completion queue first.*/
900 [ # # # # ]: 0 : if (!cpfl_vport->p2p_manual_bind && cpfl_vport->p2p_tx_complq != NULL) {
901 : 0 : err = cpfl_hairpin_tx_complq_config(cpfl_vport);
902 [ # # ]: 0 : if (err != 0) {
903 : 0 : PMD_DRV_LOG(ERR, "Fail to config Tx completion queue");
904 : 0 : return err;
905 : : }
906 : : }
907 : :
908 : : /* For non-manual bind hairpin queues, configure Rx buffer queue.*/
909 [ # # # # ]: 0 : if (!cpfl_vport->p2p_manual_bind && cpfl_vport->p2p_rx_bufq != NULL) {
910 : 0 : cpfl_rxq_hairpin_mz_bind(dev);
911 : 0 : err = cpfl_hairpin_rx_bufq_config(cpfl_vport);
912 [ # # ]: 0 : if (err != 0) {
913 : 0 : PMD_DRV_LOG(ERR, "Fail to config Rx buffer queue");
914 : 0 : return err;
915 : : }
916 : : }
917 : :
918 : : /* For normal data queues, configure, init and enale Rxq.
919 : : * For non-manual bind hairpin queues, configure Rxq, and then init Rxq.
920 : : */
921 [ # # ]: 0 : for (i = 0; i < dev->data->nb_rx_queues; i++) {
922 : 0 : cpfl_rxq = dev->data->rx_queues[i];
923 [ # # # # ]: 0 : if (cpfl_rxq == NULL || cpfl_rxq->base.rx_deferred_start)
924 : 0 : continue;
925 [ # # ]: 0 : if (!cpfl_rxq->hairpin_info.hairpin_q) {
926 : 0 : err = cpfl_rx_queue_start(dev, i);
927 [ # # ]: 0 : if (err != 0) {
928 : 0 : PMD_DRV_LOG(ERR, "Fail to start Rx queue %u", i);
929 : 0 : return err;
930 : : }
931 [ # # ]: 0 : } else if (!cpfl_vport->p2p_manual_bind) {
932 : 0 : err = cpfl_hairpin_rxq_config(vport, cpfl_rxq);
933 [ # # ]: 0 : if (err != 0) {
934 : 0 : PMD_DRV_LOG(ERR, "Fail to configure hairpin Rx queue %u", i);
935 : 0 : return err;
936 : : }
937 : 0 : err = cpfl_rx_queue_init(dev, i);
938 [ # # ]: 0 : if (err != 0) {
939 : 0 : PMD_DRV_LOG(ERR, "Fail to init hairpin Rx queue %u", i);
940 : 0 : return err;
941 : : }
942 : : }
943 : : }
944 : :
945 : : /* For non-manual bind hairpin queues, enable Tx queue and Rx queue,
946 : : * then enable Tx completion queue and Rx buffer queue.
947 : : */
948 [ # # ]: 0 : for (i = cpfl_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) {
949 : 0 : cpfl_txq = dev->data->tx_queues[i];
950 [ # # # # ]: 0 : if (cpfl_txq->hairpin_info.hairpin_q && !cpfl_vport->p2p_manual_bind) {
951 : 0 : err = cpfl_switch_hairpin_rxtx_queue(cpfl_vport,
952 : 0 : i - cpfl_vport->nb_data_txq,
953 : : false, true);
954 [ # # ]: 0 : if (err)
955 : 0 : PMD_DRV_LOG(ERR, "Failed to switch hairpin TX queue %u on",
956 : : i);
957 : : }
958 : : }
959 : :
960 [ # # ]: 0 : for (i = cpfl_vport->nb_data_rxq; i < dev->data->nb_rx_queues; i++) {
961 : 0 : cpfl_rxq = dev->data->rx_queues[i];
962 [ # # # # ]: 0 : if (cpfl_rxq->hairpin_info.hairpin_q && !cpfl_vport->p2p_manual_bind) {
963 : 0 : err = cpfl_switch_hairpin_rxtx_queue(cpfl_vport,
964 : 0 : i - cpfl_vport->nb_data_rxq,
965 : : true, true);
966 [ # # ]: 0 : if (err)
967 : 0 : PMD_DRV_LOG(ERR, "Failed to switch hairpin RX queue %u on",
968 : : i);
969 : : else
970 : 0 : cpfl_rxq->base.q_started = true;
971 : : }
972 : : }
973 : :
974 [ # # ]: 0 : if (!cpfl_vport->p2p_manual_bind &&
975 [ # # ]: 0 : cpfl_vport->p2p_tx_complq != NULL &&
976 [ # # ]: 0 : cpfl_vport->p2p_rx_bufq != NULL) {
977 : 0 : err = cpfl_switch_hairpin_complq(cpfl_vport, true);
978 [ # # ]: 0 : if (err != 0) {
979 : 0 : PMD_DRV_LOG(ERR, "Failed to switch hairpin Tx complq");
980 : 0 : return err;
981 : : }
982 : 0 : err = cpfl_switch_hairpin_bufq(cpfl_vport, true);
983 [ # # ]: 0 : if (err != 0) {
984 : 0 : PMD_DRV_LOG(ERR, "Failed to switch hairpin Rx bufq");
985 : 0 : return err;
986 : : }
987 : : }
988 : :
989 : : /* re-configure RSS lut if there's hairpin queue */
990 [ # # ]: 0 : if (cpfl_vport->nb_p2p_rxq > 0)
991 : 0 : err = cpfl_rss_lut_config(cpfl_vport, cpfl_vport->nb_data_rxq);
992 : :
993 : : return err;
994 : : }
995 : :
996 : : static int
997 : 0 : cpfl_dev_start(struct rte_eth_dev *dev)
998 : : {
999 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
1000 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
1001 : 0 : struct idpf_adapter *base = vport->adapter;
1002 : 0 : struct cpfl_adapter_ext *adapter = CPFL_ADAPTER_TO_EXT(base);
1003 : 0 : uint16_t num_allocated_vectors = base->caps.num_allocated_vectors;
1004 : : uint16_t req_vecs_num;
1005 : : int ret;
1006 : :
1007 : : req_vecs_num = CPFL_DFLT_Q_VEC_NUM;
1008 [ # # ]: 0 : if (req_vecs_num + adapter->used_vecs_num > num_allocated_vectors) {
1009 : 0 : PMD_DRV_LOG(ERR, "The accumulated request vectors' number should be less than %d",
1010 : : num_allocated_vectors);
1011 : : ret = -EINVAL;
1012 : 0 : goto err_vec;
1013 : : }
1014 : :
1015 : 0 : ret = idpf_vc_vectors_alloc(vport, req_vecs_num);
1016 [ # # ]: 0 : if (ret != 0) {
1017 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate interrupt vectors");
1018 : 0 : goto err_vec;
1019 : : }
1020 : 0 : adapter->used_vecs_num += req_vecs_num;
1021 : :
1022 : 0 : ret = cpfl_config_rx_queues_irqs(dev);
1023 [ # # ]: 0 : if (ret != 0) {
1024 : 0 : PMD_DRV_LOG(ERR, "Failed to configure irqs");
1025 : 0 : goto err_irq;
1026 : : }
1027 : :
1028 : 0 : ret = cpfl_start_queues(dev);
1029 [ # # ]: 0 : if (ret != 0) {
1030 : 0 : PMD_DRV_LOG(ERR, "Failed to start queues");
1031 : 0 : goto err_startq;
1032 : : }
1033 : :
1034 : 0 : cpfl_set_rx_function(dev);
1035 : 0 : cpfl_set_tx_function(dev);
1036 : :
1037 : 0 : ret = idpf_vc_vport_ena_dis(vport, true);
1038 [ # # ]: 0 : if (ret != 0) {
1039 : 0 : PMD_DRV_LOG(ERR, "Failed to enable vport");
1040 : 0 : goto err_vport;
1041 : : }
1042 : :
1043 [ # # ]: 0 : if (cpfl_dev_stats_reset(dev))
1044 : 0 : PMD_DRV_LOG(ERR, "Failed to reset stats");
1045 : :
1046 : : return 0;
1047 : :
1048 : : err_vport:
1049 : 0 : cpfl_stop_queues(dev);
1050 : 0 : err_startq:
1051 : 0 : idpf_vport_irq_unmap_config(vport, dev->data->nb_rx_queues);
1052 : 0 : err_irq:
1053 : 0 : idpf_vc_vectors_dealloc(vport);
1054 : : err_vec:
1055 : : return ret;
1056 : : }
1057 : :
1058 : : static int
1059 : 0 : cpfl_dev_stop(struct rte_eth_dev *dev)
1060 : : {
1061 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
1062 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
1063 : :
1064 [ # # ]: 0 : if (dev->data->dev_started == 0)
1065 : : return 0;
1066 : :
1067 : 0 : idpf_vc_vport_ena_dis(vport, false);
1068 : :
1069 : 0 : cpfl_stop_queues(dev);
1070 : :
1071 : 0 : idpf_vport_irq_unmap_config(vport, dev->data->nb_rx_queues);
1072 : :
1073 : 0 : idpf_vc_vectors_dealloc(vport);
1074 : :
1075 : 0 : return 0;
1076 : : }
1077 : :
1078 : : static void
1079 : 0 : cpfl_flow_free(struct cpfl_vport *vport)
1080 : : {
1081 : : struct rte_flow *p_flow;
1082 : :
1083 [ # # ]: 0 : while ((p_flow = TAILQ_FIRST(&vport->itf.flow_list))) {
1084 [ # # ]: 0 : TAILQ_REMOVE(&vport->itf.flow_list, p_flow, next);
1085 [ # # ]: 0 : if (p_flow->engine->free)
1086 : 0 : p_flow->engine->free(p_flow);
1087 : 0 : rte_free(p_flow);
1088 : : }
1089 : 0 : }
1090 : :
1091 : : static int
1092 : 0 : cpfl_p2p_queue_grps_del(struct idpf_vport *vport)
1093 : : {
1094 : : struct virtchnl2_queue_group_id qg_ids;
1095 : : int ret = 0;
1096 : :
1097 : : memset(&qg_ids, 0, sizeof(qg_ids));
1098 : 0 : qg_ids.queue_group_id = CPFL_P2P_QUEUE_GRP_ID;
1099 : 0 : qg_ids.queue_group_type = VIRTCHNL2_QUEUE_GROUP_P2P;
1100 : 0 : ret = idpf_vc_queue_grps_del(vport, CPFL_P2P_NB_QUEUE_GRPS, &qg_ids);
1101 [ # # ]: 0 : if (ret)
1102 : 0 : PMD_DRV_LOG(ERR, "Failed to delete p2p queue groups");
1103 : 0 : return ret;
1104 : : }
1105 : :
1106 : : static int
1107 : 0 : cpfl_dev_close(struct rte_eth_dev *dev)
1108 : : {
1109 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
1110 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
1111 : 0 : struct cpfl_adapter_ext *adapter = CPFL_ADAPTER_TO_EXT(vport->adapter);
1112 : :
1113 : 0 : cpfl_dev_stop(dev);
1114 [ # # ]: 0 : if (cpfl_vport->p2p_mp) {
1115 : 0 : rte_mempool_free(cpfl_vport->p2p_mp);
1116 : 0 : cpfl_vport->p2p_mp = NULL;
1117 : : }
1118 : :
1119 [ # # # # ]: 0 : if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq)
1120 : 0 : cpfl_p2p_queue_grps_del(vport);
1121 : :
1122 : 0 : cpfl_flow_free(cpfl_vport);
1123 : 0 : idpf_vport_deinit(vport);
1124 : 0 : rte_free(cpfl_vport->p2p_q_chunks_info);
1125 : :
1126 : 0 : adapter->cur_vports &= ~RTE_BIT32(vport->devarg_id);
1127 : 0 : adapter->cur_vport_nb--;
1128 : 0 : dev->data->dev_private = NULL;
1129 : 0 : adapter->vports[vport->sw_idx] = NULL;
1130 : : idpf_free_dma_mem(NULL, &cpfl_vport->itf.flow_dma);
1131 : 0 : rte_free(cpfl_vport);
1132 : :
1133 : 0 : return 0;
1134 : : }
1135 : :
1136 : : static int
1137 : 0 : cpfl_dev_flow_ops_get(struct rte_eth_dev *dev,
1138 : : const struct rte_flow_ops **ops)
1139 : : {
1140 : : struct cpfl_itf *itf;
1141 : :
1142 [ # # ]: 0 : if (!dev)
1143 : : return -EINVAL;
1144 : :
1145 : 0 : itf = CPFL_DEV_TO_ITF(dev);
1146 : :
1147 : : /* only vport support rte_flow */
1148 [ # # ]: 0 : if (itf->type != CPFL_ITF_TYPE_VPORT)
1149 : : return -ENOTSUP;
1150 : : #ifdef RTE_HAS_JANSSON
1151 : 0 : *ops = &cpfl_flow_ops;
1152 : : #else
1153 : : *ops = NULL;
1154 : : PMD_DRV_LOG(NOTICE, "not support rte_flow, please install json-c library.");
1155 : : #endif
1156 : 0 : return 0;
1157 : : }
1158 : :
1159 : : static int
1160 : 0 : cpfl_hairpin_get_peer_ports(struct rte_eth_dev *dev, uint16_t *peer_ports,
1161 : : size_t len, uint32_t tx)
1162 : : {
1163 : 0 : struct cpfl_vport *cpfl_vport =
1164 : 0 : (struct cpfl_vport *)dev->data->dev_private;
1165 : : struct ci_tx_queue *txq;
1166 : : struct idpf_rx_queue *rxq;
1167 : : struct cpfl_tx_queue *cpfl_txq;
1168 : : struct cpfl_rx_queue *cpfl_rxq;
1169 : : uint16_t i;
1170 : : uint16_t j = 0;
1171 : :
1172 [ # # ]: 0 : if (len <= 0)
1173 : : return -EINVAL;
1174 : :
1175 [ # # ]: 0 : if (cpfl_vport->p2p_q_chunks_info == NULL)
1176 : : return -ENOTSUP;
1177 : :
1178 [ # # ]: 0 : if (tx > 0) {
1179 [ # # ]: 0 : for (i = cpfl_vport->nb_data_txq, j = 0; i < dev->data->nb_tx_queues; i++, j++) {
1180 : 0 : txq = dev->data->tx_queues[i];
1181 [ # # # # ]: 0 : if (txq == NULL || j >= len)
1182 : : return -EINVAL;
1183 : : cpfl_txq = (struct cpfl_tx_queue *)txq;
1184 : 0 : peer_ports[j] = cpfl_txq->hairpin_info.peer_rxp;
1185 : : }
1186 : : } else if (tx == 0) {
1187 [ # # ]: 0 : for (i = cpfl_vport->nb_data_rxq, j = 0; i < dev->data->nb_rx_queues; i++, j++) {
1188 : 0 : rxq = dev->data->rx_queues[i];
1189 [ # # # # ]: 0 : if (rxq == NULL || j >= len)
1190 : : return -EINVAL;
1191 : : cpfl_rxq = (struct cpfl_rx_queue *)rxq;
1192 : 0 : peer_ports[j] = cpfl_rxq->hairpin_info.peer_txp;
1193 : : }
1194 : : }
1195 : :
1196 : 0 : return j;
1197 : : }
1198 : :
1199 : : static int
1200 : 0 : cpfl_hairpin_bind(struct rte_eth_dev *dev, uint16_t rx_port)
1201 : : {
1202 : 0 : struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private;
1203 : 0 : struct idpf_vport *tx_vport = &cpfl_tx_vport->base;
1204 : : struct cpfl_vport *cpfl_rx_vport;
1205 : : struct cpfl_tx_queue *cpfl_txq;
1206 : : struct cpfl_rx_queue *cpfl_rxq;
1207 : : struct rte_eth_dev *peer_dev;
1208 : : struct idpf_vport *rx_vport;
1209 : : int err = 0;
1210 : : int i;
1211 : :
1212 : 0 : err = cpfl_txq_hairpin_info_update(dev, rx_port);
1213 [ # # ]: 0 : if (err != 0) {
1214 : 0 : PMD_DRV_LOG(ERR, "Fail to update Tx hairpin queue info.");
1215 : 0 : return err;
1216 : : }
1217 : :
1218 : : /* configure hairpin queues */
1219 [ # # ]: 0 : for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) {
1220 : 0 : cpfl_txq = dev->data->tx_queues[i];
1221 : 0 : err = cpfl_hairpin_txq_config(tx_vport, cpfl_txq);
1222 [ # # ]: 0 : if (err != 0) {
1223 : 0 : PMD_DRV_LOG(ERR, "Fail to configure hairpin Tx queue %u", i);
1224 : 0 : return err;
1225 : : }
1226 : : }
1227 : :
1228 : 0 : err = cpfl_hairpin_tx_complq_config(cpfl_tx_vport);
1229 [ # # ]: 0 : if (err != 0) {
1230 : 0 : PMD_DRV_LOG(ERR, "Fail to config Tx completion queue");
1231 : 0 : return err;
1232 : : }
1233 : :
1234 : 0 : peer_dev = &rte_eth_devices[rx_port];
1235 : 0 : cpfl_rx_vport = (struct cpfl_vport *)peer_dev->data->dev_private;
1236 : 0 : rx_vport = &cpfl_rx_vport->base;
1237 : 0 : cpfl_rxq_hairpin_mz_bind(peer_dev);
1238 : :
1239 : 0 : err = cpfl_hairpin_rx_bufq_config(cpfl_rx_vport);
1240 [ # # ]: 0 : if (err != 0) {
1241 : 0 : PMD_DRV_LOG(ERR, "Fail to config Rx buffer queue");
1242 : 0 : return err;
1243 : : }
1244 : :
1245 [ # # ]: 0 : for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) {
1246 : 0 : cpfl_rxq = peer_dev->data->rx_queues[i];
1247 : 0 : err = cpfl_hairpin_rxq_config(rx_vport, cpfl_rxq);
1248 [ # # ]: 0 : if (err != 0) {
1249 : 0 : PMD_DRV_LOG(ERR, "Fail to configure hairpin Rx queue %u", i);
1250 : 0 : return err;
1251 : : }
1252 : 0 : err = cpfl_rx_queue_init(peer_dev, i);
1253 [ # # ]: 0 : if (err != 0) {
1254 : 0 : PMD_DRV_LOG(ERR, "Fail to init hairpin Rx queue %u", i);
1255 : 0 : return err;
1256 : : }
1257 : : }
1258 : :
1259 : : /* enable hairpin queues */
1260 [ # # ]: 0 : for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) {
1261 : : cpfl_txq = dev->data->tx_queues[i];
1262 : 0 : err = cpfl_switch_hairpin_rxtx_queue(cpfl_tx_vport,
1263 : 0 : i - cpfl_tx_vport->nb_data_txq,
1264 : : false, true);
1265 [ # # ]: 0 : if (err != 0) {
1266 : 0 : PMD_DRV_LOG(ERR, "Failed to switch hairpin TX queue %u on",
1267 : : i);
1268 : 0 : return err;
1269 : : }
1270 : : }
1271 : :
1272 : 0 : err = cpfl_switch_hairpin_complq(cpfl_tx_vport, true);
1273 [ # # ]: 0 : if (err != 0) {
1274 : 0 : PMD_DRV_LOG(ERR, "Failed to switch hairpin Tx complq");
1275 : 0 : return err;
1276 : : }
1277 : :
1278 [ # # ]: 0 : for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) {
1279 : 0 : cpfl_rxq = peer_dev->data->rx_queues[i];
1280 : 0 : err = cpfl_switch_hairpin_rxtx_queue(cpfl_rx_vport,
1281 : 0 : i - cpfl_rx_vport->nb_data_rxq,
1282 : : true, true);
1283 [ # # ]: 0 : if (err != 0) {
1284 : 0 : PMD_DRV_LOG(ERR, "Failed to switch hairpin RX queue %u on",
1285 : : i);
1286 : : }
1287 : 0 : cpfl_rxq->base.q_started = true;
1288 : : }
1289 : :
1290 : 0 : err = cpfl_switch_hairpin_bufq(cpfl_rx_vport, true);
1291 [ # # ]: 0 : if (err != 0) {
1292 : 0 : PMD_DRV_LOG(ERR, "Failed to switch hairpin Rx buffer queue");
1293 : 0 : return err;
1294 : : }
1295 : :
1296 : : return 0;
1297 : : }
1298 : :
1299 : : static int
1300 : 0 : cpfl_hairpin_unbind(struct rte_eth_dev *dev, uint16_t rx_port)
1301 : : {
1302 : 0 : struct cpfl_vport *cpfl_tx_vport = dev->data->dev_private;
1303 : 0 : struct rte_eth_dev *peer_dev = &rte_eth_devices[rx_port];
1304 : 0 : struct cpfl_vport *cpfl_rx_vport = peer_dev->data->dev_private;
1305 : : struct cpfl_rx_queue *cpfl_rxq;
1306 : : int i;
1307 : :
1308 : : /* disable hairpin queues */
1309 [ # # ]: 0 : for (i = cpfl_tx_vport->nb_data_txq; i < dev->data->nb_tx_queues; i++) {
1310 : 0 : cpfl_switch_hairpin_rxtx_queue(cpfl_tx_vport,
1311 : 0 : i - cpfl_tx_vport->nb_data_txq,
1312 : : false, false);
1313 : : }
1314 : :
1315 : 0 : cpfl_switch_hairpin_complq(cpfl_tx_vport, false);
1316 : :
1317 [ # # ]: 0 : for (i = cpfl_rx_vport->nb_data_rxq; i < peer_dev->data->nb_rx_queues; i++) {
1318 : 0 : cpfl_rxq = peer_dev->data->rx_queues[i];
1319 : 0 : cpfl_switch_hairpin_rxtx_queue(cpfl_rx_vport,
1320 : 0 : i - cpfl_rx_vport->nb_data_rxq,
1321 : : true, false);
1322 : 0 : cpfl_rxq->base.q_started = false;
1323 : : }
1324 : :
1325 : 0 : cpfl_switch_hairpin_bufq(cpfl_rx_vport, false);
1326 : :
1327 : 0 : return 0;
1328 : : }
1329 : :
1330 : : static int
1331 : 0 : cpfl_timesync_enable(struct rte_eth_dev *dev)
1332 : : {
1333 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
1334 : : struct idpf_vport *vport = &cpfl_vport->base;
1335 : 0 : struct idpf_adapter *adapter = vport->adapter;
1336 : : struct timespec sys_ts;
1337 : : uint64_t ns;
1338 : : int ret;
1339 : :
1340 [ # # # # ]: 0 : if (dev->data->dev_started && !(dev->data->dev_conf.rxmode.offloads &
1341 : : RTE_ETH_RX_OFFLOAD_TIMESTAMP)) {
1342 : 0 : PMD_DRV_LOG(ERR, "Rx timestamp offload not configured");
1343 : 0 : return -1;
1344 : : }
1345 : :
1346 : : /* PTP state is shared by all vports of the adapter. */
1347 [ # # ]: 0 : if (adapter->ptp != NULL)
1348 : : return 0;
1349 : :
1350 : 0 : adapter->ptp = rte_zmalloc(NULL, sizeof(struct idpf_ptp), 0);
1351 [ # # ]: 0 : if (adapter->ptp == NULL) {
1352 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for PTP");
1353 : 0 : return -ENOMEM;
1354 : : }
1355 : :
1356 : 0 : ret = idpf_ptp_get_caps(adapter);
1357 [ # # ]: 0 : if (ret) {
1358 : 0 : PMD_DRV_LOG(ERR, "Failed to get PTP capabilities, err=%d", ret);
1359 : 0 : goto fail_ptp;
1360 : : }
1361 : :
1362 : : /*
1363 : : * Write the default increment time value if the clock adjustments
1364 : : * are enabled.
1365 : : */
1366 [ # # ]: 0 : if (adapter->ptp->adj_dev_clk_time_access != IDPF_PTP_NONE) {
1367 : 0 : ret = idpf_ptp_adj_dev_clk_fine(adapter, adapter->ptp->base_incval);
1368 [ # # ]: 0 : if (ret) {
1369 : 0 : PMD_DRV_LOG(ERR, "PTP set incval failed, err=%d", ret);
1370 : 0 : goto fail_ptp;
1371 : : }
1372 : : }
1373 : :
1374 : : /* Do not initialize the PTP if the device clock time cannot be read. */
1375 [ # # ]: 0 : if (adapter->ptp->get_dev_clk_time_access == IDPF_PTP_NONE) {
1376 : 0 : PMD_DRV_LOG(ERR, "Getting device clock time is not supported");
1377 : : ret = -EIO;
1378 : 0 : goto fail_ptp;
1379 : : }
1380 : :
1381 : : /* Set the device clock time to system time. */
1382 [ # # ]: 0 : if (adapter->ptp->set_dev_clk_time_access != IDPF_PTP_NONE) {
1383 : 0 : clock_gettime(CLOCK_REALTIME, &sys_ts);
1384 : : ns = rte_timespec_to_ns(&sys_ts);
1385 : 0 : ret = idpf_ptp_set_dev_clk_time(adapter, ns);
1386 [ # # ]: 0 : if (ret) {
1387 : 0 : PMD_DRV_LOG(ERR, "PTP set clock time failed, err=%d", ret);
1388 : 0 : goto fail_ptp;
1389 : : }
1390 : : }
1391 : :
1392 : 0 : adapter->ptp->cmd.shtime_enable_mask = PF_GLTSYN_CMD_SYNC_SHTIME_EN_M;
1393 : 0 : adapter->ptp->cmd.exec_cmd_mask = PF_GLTSYN_CMD_SYNC_EXEC_CMD_M;
1394 : :
1395 : 0 : return 0;
1396 : :
1397 : 0 : fail_ptp:
1398 : 0 : rte_free(adapter->ptp);
1399 : 0 : adapter->ptp = NULL;
1400 : 0 : return ret;
1401 : : }
1402 : :
1403 : : static int
1404 : 0 : cpfl_timesync_read_time(struct rte_eth_dev *dev, struct timespec *ts)
1405 : : {
1406 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
1407 : 0 : struct idpf_adapter *adapter = cpfl_vport->base.adapter;
1408 : : uint64_t time;
1409 : : int ret;
1410 : :
1411 : 0 : ret = idpf_ptp_read_src_clk_reg(adapter, &time);
1412 [ # # ]: 0 : if (ret)
1413 : 0 : PMD_DRV_LOG(ERR, "PTP read time failed, err %d", ret);
1414 : : else
1415 [ # # ]: 0 : *ts = rte_ns_to_timespec(time);
1416 : :
1417 : 0 : return ret;
1418 : : }
1419 : :
1420 : : static int
1421 : 0 : cpfl_timesync_disable(struct rte_eth_dev *dev)
1422 : : {
1423 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
1424 : 0 : struct idpf_adapter *adapter = cpfl_vport->base.adapter;
1425 : :
1426 [ # # ]: 0 : if (adapter->ptp != NULL) {
1427 : 0 : rte_free(adapter->ptp);
1428 : 0 : adapter->ptp = NULL;
1429 : : }
1430 : :
1431 : 0 : return 0;
1432 : : }
1433 : :
1434 : : static const struct eth_dev_ops cpfl_eth_dev_ops = {
1435 : : .dev_configure = cpfl_dev_configure,
1436 : : .dev_close = cpfl_dev_close,
1437 : : .rx_queue_setup = cpfl_rx_queue_setup,
1438 : : .tx_queue_setup = cpfl_tx_queue_setup,
1439 : : .dev_infos_get = cpfl_dev_info_get,
1440 : : .dev_start = cpfl_dev_start,
1441 : : .dev_stop = cpfl_dev_stop,
1442 : : .link_update = cpfl_dev_link_update,
1443 : : .rx_queue_start = cpfl_rx_queue_start,
1444 : : .tx_queue_start = cpfl_tx_queue_start,
1445 : : .rx_queue_stop = cpfl_rx_queue_stop,
1446 : : .tx_queue_stop = cpfl_tx_queue_stop,
1447 : : .rx_queue_release = cpfl_dev_rx_queue_release,
1448 : : .tx_queue_release = cpfl_dev_tx_queue_release,
1449 : : .mtu_set = cpfl_dev_mtu_set,
1450 : : .dev_supported_ptypes_get = cpfl_dev_supported_ptypes_get,
1451 : : .stats_get = cpfl_dev_stats_get,
1452 : : .stats_reset = cpfl_dev_stats_reset,
1453 : : .reta_update = cpfl_rss_reta_update,
1454 : : .reta_query = cpfl_rss_reta_query,
1455 : : .rss_hash_update = cpfl_rss_hash_update,
1456 : : .rss_hash_conf_get = cpfl_rss_hash_conf_get,
1457 : : .xstats_get = cpfl_dev_xstats_get,
1458 : : .xstats_get_names = cpfl_dev_xstats_get_names,
1459 : : .xstats_reset = cpfl_dev_xstats_reset,
1460 : : .flow_ops_get = cpfl_dev_flow_ops_get,
1461 : : .hairpin_cap_get = cpfl_hairpin_cap_get,
1462 : : .rx_hairpin_queue_setup = cpfl_rx_hairpin_queue_setup,
1463 : : .tx_hairpin_queue_setup = cpfl_tx_hairpin_queue_setup,
1464 : : .hairpin_get_peer_ports = cpfl_hairpin_get_peer_ports,
1465 : : .hairpin_bind = cpfl_hairpin_bind,
1466 : : .hairpin_unbind = cpfl_hairpin_unbind,
1467 : : .timesync_enable = cpfl_timesync_enable,
1468 : : .timesync_read_time = cpfl_timesync_read_time,
1469 : : .timesync_disable = cpfl_timesync_disable,
1470 : : };
1471 : :
1472 : : static int
1473 : : insert_value(struct cpfl_devargs *devargs, uint16_t id)
1474 : : {
1475 : : uint16_t i;
1476 : :
1477 : : /* ignore duplicate */
1478 [ # # # # ]: 0 : for (i = 0; i < devargs->req_vport_nb; i++) {
1479 [ # # # # ]: 0 : if (devargs->req_vports[i] == id)
1480 : : return 0;
1481 : : }
1482 : :
1483 : 0 : devargs->req_vports[devargs->req_vport_nb] = id;
1484 : 0 : devargs->req_vport_nb++;
1485 : :
1486 : 0 : return 0;
1487 : : }
1488 : :
1489 : : static const char *
1490 : 0 : parse_range(const char *value, struct cpfl_devargs *devargs)
1491 : : {
1492 : : uint16_t lo, hi, i;
1493 : 0 : int n = 0;
1494 : : int result;
1495 : : const char *pos = value;
1496 : :
1497 : 0 : result = sscanf(value, "%hu%n-%hu%n", &lo, &n, &hi, &n);
1498 [ # # ]: 0 : if (result == 1) {
1499 : 0 : if (insert_value(devargs, lo) != 0)
1500 : : return NULL;
1501 [ # # ]: 0 : } else if (result == 2) {
1502 [ # # ]: 0 : if (lo > hi)
1503 : : return NULL;
1504 [ # # ]: 0 : for (i = lo; i <= hi; i++) {
1505 : : if (insert_value(devargs, i) != 0)
1506 : : return NULL;
1507 : : }
1508 : : } else {
1509 : : return NULL;
1510 : : }
1511 : :
1512 : 0 : return pos + n;
1513 : : }
1514 : :
1515 : : static int
1516 : 0 : parse_vport(const char *key, const char *value, void *args)
1517 : : {
1518 : : struct cpfl_devargs *devargs = args;
1519 : : const char *pos = value;
1520 : :
1521 : 0 : devargs->req_vport_nb = 0;
1522 : :
1523 [ # # ]: 0 : if (*pos == '[')
1524 : 0 : pos++;
1525 : :
1526 : : while (1) {
1527 : 0 : pos = parse_range(pos, devargs);
1528 [ # # ]: 0 : if (pos == NULL) {
1529 : 0 : PMD_INIT_LOG(ERR, "invalid value:\"%s\" for key:\"%s\", ",
1530 : : value, key);
1531 : 0 : return -EINVAL;
1532 : : }
1533 [ # # ]: 0 : if (*pos != ',')
1534 : : break;
1535 : 0 : pos++;
1536 : : }
1537 : :
1538 [ # # # # ]: 0 : if (*value == '[' && *pos != ']') {
1539 : 0 : PMD_INIT_LOG(ERR, "invalid value:\"%s\" for key:\"%s\", ",
1540 : : value, key);
1541 : 0 : return -EINVAL;
1542 : : }
1543 : :
1544 : : return 0;
1545 : : }
1546 : :
1547 : : static int
1548 : 0 : parse_bool(const char *key, const char *value, void *args)
1549 : : {
1550 : : bool *i = args;
1551 : : char *end;
1552 : : int num;
1553 : :
1554 : 0 : errno = 0;
1555 : :
1556 : 0 : num = strtoul(value, &end, 10);
1557 : :
1558 [ # # # # ]: 0 : if (errno == ERANGE || (num != 0 && num != 1)) {
1559 : 0 : PMD_INIT_LOG(ERR, "invalid value:\"%s\" for key:\"%s\", value must be 0 or 1",
1560 : : value, key);
1561 : 0 : return -EINVAL;
1562 : : }
1563 : :
1564 : 0 : *i = (num == 1);
1565 : 0 : return 0;
1566 : : }
1567 : :
1568 : : static int
1569 : : enlist(uint16_t *list, uint16_t *len_list, const uint16_t max_list, uint16_t val)
1570 : : {
1571 : : uint16_t i;
1572 : :
1573 [ # # # # ]: 0 : for (i = 0; i < *len_list; i++) {
1574 [ # # # # ]: 0 : if (list[i] == val)
1575 : : return 0;
1576 : : }
1577 [ # # # # ]: 0 : if (*len_list >= max_list)
1578 : : return -1;
1579 : 0 : list[(*len_list)++] = val;
1580 : : return 0;
1581 : : }
1582 : :
1583 : : static const char *
1584 : 0 : process_range(const char *str, uint16_t *list, uint16_t *len_list,
1585 : : const uint16_t max_list)
1586 : : {
1587 : : uint16_t lo, hi, val;
1588 : 0 : int result, n = 0;
1589 : : const char *pos = str;
1590 : :
1591 : 0 : result = sscanf(str, "%hu%n-%hu%n", &lo, &n, &hi, &n);
1592 [ # # ]: 0 : if (result == 1) {
1593 : 0 : if (enlist(list, len_list, max_list, lo) != 0)
1594 : : return NULL;
1595 [ # # ]: 0 : } else if (result == 2) {
1596 [ # # ]: 0 : if (lo > hi)
1597 : : return NULL;
1598 [ # # ]: 0 : for (val = lo; val <= hi; val++) {
1599 : : if (enlist(list, len_list, max_list, val) != 0)
1600 : : return NULL;
1601 : : }
1602 : : } else {
1603 : : return NULL;
1604 : : }
1605 : 0 : return pos + n;
1606 : : }
1607 : :
1608 : : static const char *
1609 : 0 : process_list(const char *str, uint16_t *list, uint16_t *len_list, const uint16_t max_list)
1610 : : {
1611 : : const char *pos = str;
1612 : :
1613 [ # # ]: 0 : if (*pos == '[')
1614 : 0 : pos++;
1615 : : while (1) {
1616 : 0 : pos = process_range(pos, list, len_list, max_list);
1617 [ # # ]: 0 : if (pos == NULL)
1618 : : return NULL;
1619 [ # # ]: 0 : if (*pos != ',') /* end of list */
1620 : : break;
1621 : 0 : pos++;
1622 : : }
1623 [ # # # # ]: 0 : if (*str == '[' && *pos != ']')
1624 : : return NULL;
1625 [ # # ]: 0 : if (*pos == ']')
1626 : 0 : pos++;
1627 : : return pos;
1628 : : }
1629 : :
1630 : : static int
1631 : 0 : parse_repr(const char *key __rte_unused, const char *value, void *args)
1632 : : {
1633 : : struct cpfl_devargs *devargs = args;
1634 : : struct rte_eth_devargs *eth_da;
1635 : : const char *str = value;
1636 : :
1637 [ # # ]: 0 : if (devargs->repr_args_num == CPFL_REPR_ARG_NUM_MAX)
1638 : : return -EINVAL;
1639 : :
1640 : 0 : eth_da = &devargs->repr_args[devargs->repr_args_num];
1641 : :
1642 [ # # ]: 0 : if (str[0] == 'c') {
1643 : 0 : str += 1;
1644 : 0 : str = process_list(str, eth_da->mh_controllers,
1645 : : ð_da->nb_mh_controllers,
1646 : : RTE_DIM(eth_da->mh_controllers));
1647 [ # # ]: 0 : if (str == NULL)
1648 : 0 : goto done;
1649 : : }
1650 [ # # # # ]: 0 : if (str[0] == 'p' && str[1] == 'f') {
1651 : 0 : eth_da->type = RTE_ETH_REPRESENTOR_PF;
1652 : 0 : str += 2;
1653 : 0 : str = process_list(str, eth_da->ports,
1654 : : ð_da->nb_ports, RTE_DIM(eth_da->ports));
1655 [ # # # # ]: 0 : if (str == NULL || str[0] == '\0')
1656 : 0 : goto done;
1657 [ # # ]: 0 : } else if (eth_da->nb_mh_controllers > 0) {
1658 : : /* 'c' must followed by 'pf'. */
1659 : : str = NULL;
1660 : 0 : goto done;
1661 : : }
1662 [ # # # # ]: 0 : if (str[0] == 'v' && str[1] == 'f') {
1663 : 0 : eth_da->type = RTE_ETH_REPRESENTOR_VF;
1664 : 0 : str += 2;
1665 [ # # # # ]: 0 : } else if (str[0] == 's' && str[1] == 'f') {
1666 : 0 : eth_da->type = RTE_ETH_REPRESENTOR_SF;
1667 : 0 : str += 2;
1668 : : } else {
1669 : : /* 'pf' must followed by 'vf' or 'sf'. */
1670 [ # # ]: 0 : if (eth_da->type == RTE_ETH_REPRESENTOR_PF) {
1671 : : str = NULL;
1672 : 0 : goto done;
1673 : : }
1674 : 0 : eth_da->type = RTE_ETH_REPRESENTOR_VF;
1675 : : }
1676 : 0 : str = process_list(str, eth_da->representor_ports,
1677 : : ð_da->nb_representor_ports,
1678 : : RTE_DIM(eth_da->representor_ports));
1679 : 0 : done:
1680 [ # # ]: 0 : if (str == NULL) {
1681 : 0 : PMD_DRV_LOG(ERR, "wrong representor format: %s", value);
1682 : 0 : return -1;
1683 : : }
1684 : :
1685 : 0 : devargs->repr_args_num++;
1686 : :
1687 : 0 : return 0;
1688 : : }
1689 : :
1690 : : #ifdef RTE_HAS_JANSSON
1691 : : static int
1692 : 0 : parse_file(const char *key, const char *value, void *args)
1693 : : {
1694 : : char *name = args;
1695 : :
1696 [ # # ]: 0 : if (strlen(value) > CPFL_FLOW_FILE_LEN - 1) {
1697 : 0 : PMD_DRV_LOG(ERR, "file path(%s) is too long.", value);
1698 : 0 : return -1;
1699 : : }
1700 : :
1701 : 0 : PMD_DRV_LOG(DEBUG, "value:\"%s\" for key:\"%s\"", value, key);
1702 : : strlcpy(name, value, CPFL_FLOW_FILE_LEN);
1703 : :
1704 : 0 : return 0;
1705 : : }
1706 : : #endif
1707 : :
1708 : : static int
1709 : 0 : cpfl_parse_devargs(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter,
1710 : : bool first, struct cpfl_devargs *cpfl_args)
1711 : : {
1712 : 0 : struct rte_devargs *devargs = pci_dev->device.devargs;
1713 : : struct rte_kvargs *kvlist;
1714 : : int ret;
1715 : :
1716 [ # # ]: 0 : if (devargs == NULL)
1717 : : return 0;
1718 : :
1719 [ # # ]: 0 : kvlist = rte_kvargs_parse(devargs->args,
1720 : : first ? cpfl_valid_args_first : cpfl_valid_args_again);
1721 [ # # ]: 0 : if (kvlist == NULL) {
1722 : 0 : PMD_INIT_LOG(ERR, "invalid kvargs key");
1723 : 0 : return -EINVAL;
1724 : : }
1725 : :
1726 [ # # ]: 0 : if (rte_kvargs_count(kvlist, CPFL_VPORT) > 1) {
1727 : 0 : PMD_INIT_LOG(ERR, "devarg vport is duplicated.");
1728 : : ret = -EINVAL;
1729 : 0 : goto fail;
1730 : : }
1731 : :
1732 : 0 : ret = rte_kvargs_process(kvlist, CPFL_REPRESENTOR, &parse_repr, cpfl_args);
1733 : :
1734 [ # # ]: 0 : if (ret != 0)
1735 : 0 : goto fail;
1736 : :
1737 [ # # ]: 0 : if (!first)
1738 : 0 : goto finish;
1739 : :
1740 : 0 : ret = rte_kvargs_process(kvlist, CPFL_VPORT, &parse_vport,
1741 : : cpfl_args);
1742 [ # # ]: 0 : if (ret != 0)
1743 : 0 : goto fail;
1744 : :
1745 : 0 : ret = rte_kvargs_process(kvlist, CPFL_TX_SINGLE_Q, &parse_bool,
1746 : 0 : &adapter->base.is_tx_singleq);
1747 [ # # ]: 0 : if (ret != 0)
1748 : 0 : goto fail;
1749 : :
1750 : 0 : ret = rte_kvargs_process(kvlist, CPFL_RX_SINGLE_Q, &parse_bool,
1751 : 0 : &adapter->base.is_rx_singleq);
1752 [ # # ]: 0 : if (ret != 0)
1753 : 0 : goto fail;
1754 : : #ifdef RTE_HAS_JANSSON
1755 [ # # ]: 0 : if (rte_kvargs_get(kvlist, CPFL_FLOW_PARSER)) {
1756 : 0 : ret = rte_kvargs_process(kvlist, CPFL_FLOW_PARSER,
1757 : 0 : &parse_file, cpfl_args->flow_parser);
1758 [ # # ]: 0 : if (ret) {
1759 : 0 : PMD_DRV_LOG(ERR, "Failed to parser flow_parser, ret: %d", ret);
1760 : 0 : goto fail;
1761 : : }
1762 : : } else {
1763 : 0 : cpfl_args->flow_parser[0] = '\0';
1764 : : }
1765 : : #endif
1766 : 0 : finish:
1767 : 0 : fail:
1768 : 0 : rte_kvargs_free(kvlist);
1769 : 0 : return ret;
1770 : : }
1771 : :
1772 : : static struct cpfl_vport *
1773 : : cpfl_find_vport(struct cpfl_adapter_ext *adapter, uint32_t vport_id)
1774 : : {
1775 : : struct cpfl_vport *vport = NULL;
1776 : : int i;
1777 : :
1778 [ # # ]: 0 : for (i = 0; i < adapter->cur_vport_nb; i++) {
1779 : 0 : vport = adapter->vports[i];
1780 [ # # ]: 0 : if (vport == NULL)
1781 : 0 : continue;
1782 [ # # ]: 0 : if (vport->base.vport_id != vport_id)
1783 : 0 : continue;
1784 : : else
1785 : : return vport;
1786 : : }
1787 : :
1788 : : return NULL;
1789 : : }
1790 : :
1791 : : static void
1792 : 0 : cpfl_handle_vchnl_event_msg(struct cpfl_adapter_ext *adapter, uint8_t *msg, uint16_t msglen)
1793 : : {
1794 : : struct virtchnl2_event *vc_event = (struct virtchnl2_event *)msg;
1795 : : struct cpfl_vport *vport;
1796 : : struct rte_eth_dev_data *data;
1797 : : struct rte_eth_dev *dev;
1798 : :
1799 [ # # ]: 0 : if (msglen < sizeof(struct virtchnl2_event)) {
1800 : 0 : PMD_DRV_LOG(ERR, "Error event");
1801 : 0 : return;
1802 : : }
1803 : :
1804 : : /* ignore if it is ctrl vport */
1805 [ # # ]: 0 : if (!idpf_is_vf_device(&adapter->base.hw) &&
1806 [ # # ]: 0 : adapter->ctrl_vport.base.vport_id == vc_event->vport_id)
1807 : : return;
1808 : :
1809 : 0 : vport = cpfl_find_vport(adapter, vc_event->vport_id);
1810 [ # # ]: 0 : if (!vport) {
1811 : 0 : PMD_DRV_LOG(ERR, "Can't find vport.");
1812 : 0 : return;
1813 : : }
1814 : :
1815 : 0 : data = vport->itf.data;
1816 : 0 : dev = &rte_eth_devices[data->port_id];
1817 : :
1818 [ # # ]: 0 : switch (vc_event->event) {
1819 : 0 : case VIRTCHNL2_EVENT_LINK_CHANGE:
1820 : 0 : PMD_DRV_LOG(DEBUG, "VIRTCHNL2_EVENT_LINK_CHANGE");
1821 : 0 : vport->base.link_up = !!(vc_event->link_status);
1822 : 0 : vport->base.link_speed = vc_event->link_speed;
1823 : 0 : cpfl_dev_link_update(dev, 0);
1824 : 0 : break;
1825 : 0 : default:
1826 : 0 : PMD_DRV_LOG(ERR, " unknown event received %u", vc_event->event);
1827 : 0 : break;
1828 : : }
1829 : : }
1830 : :
1831 : : int
1832 : 0 : cpfl_vport_info_create(struct cpfl_adapter_ext *adapter,
1833 : : struct cpfl_vport_id *vport_identity,
1834 : : struct cpchnl2_event_vport_created *vport_created)
1835 : : {
1836 : 0 : struct cpfl_vport_info *info = NULL;
1837 : : int ret;
1838 : :
1839 : 0 : rte_spinlock_lock(&adapter->vport_map_lock);
1840 : 0 : ret = rte_hash_lookup_data(adapter->vport_map_hash, vport_identity, (void **)&info);
1841 [ # # ]: 0 : if (ret >= 0) {
1842 : 0 : PMD_DRV_LOG(WARNING, "vport already exist, overwrite info anyway");
1843 : : /* overwrite info */
1844 [ # # ]: 0 : if (info)
1845 : 0 : info->vport = *vport_created;
1846 : 0 : goto fini;
1847 : : }
1848 : :
1849 : 0 : info = rte_zmalloc(NULL, sizeof(*info), 0);
1850 [ # # ]: 0 : if (info == NULL) {
1851 : 0 : PMD_DRV_LOG(ERR, "Failed to alloc memory for vport map info");
1852 : : ret = -ENOMEM;
1853 : 0 : goto err;
1854 : : }
1855 : :
1856 : 0 : info->vport = *vport_created;
1857 : :
1858 : 0 : ret = rte_hash_add_key_data(adapter->vport_map_hash, vport_identity, info);
1859 [ # # ]: 0 : if (ret < 0) {
1860 : 0 : PMD_DRV_LOG(ERR, "Failed to add vport map into hash");
1861 : 0 : rte_free(info);
1862 : 0 : goto err;
1863 : : }
1864 : :
1865 : 0 : fini:
1866 : : rte_spinlock_unlock(&adapter->vport_map_lock);
1867 : 0 : return 0;
1868 : 0 : err:
1869 : : rte_spinlock_unlock(&adapter->vport_map_lock);
1870 : 0 : return ret;
1871 : : }
1872 : :
1873 : : static int
1874 : 0 : cpfl_vport_info_destroy(struct cpfl_adapter_ext *adapter, struct cpfl_vport_id *vport_identity)
1875 : : {
1876 : : struct cpfl_vport_info *info;
1877 : : int ret;
1878 : :
1879 : 0 : rte_spinlock_lock(&adapter->vport_map_lock);
1880 : 0 : ret = rte_hash_lookup_data(adapter->vport_map_hash, vport_identity, (void **)&info);
1881 [ # # ]: 0 : if (ret < 0) {
1882 : 0 : PMD_DRV_LOG(ERR, "vport id doesn't exist");
1883 : 0 : goto err;
1884 : : }
1885 : :
1886 : 0 : rte_hash_del_key(adapter->vport_map_hash, vport_identity);
1887 : : rte_spinlock_unlock(&adapter->vport_map_lock);
1888 : 0 : rte_free(info);
1889 : :
1890 : 0 : return 0;
1891 : :
1892 : : err:
1893 : : rte_spinlock_unlock(&adapter->vport_map_lock);
1894 : 0 : return ret;
1895 : : }
1896 : :
1897 : : static void
1898 : 0 : cpfl_handle_cpchnl_event_msg(struct cpfl_adapter_ext *adapter, uint8_t *msg, uint16_t msglen)
1899 : : {
1900 : : struct cpchnl2_event_info *cpchnl2_event = (struct cpchnl2_event_info *)msg;
1901 : : struct cpchnl2_event_vport_created *vport_created;
1902 : 0 : struct cpfl_vport_id vport_identity = { 0 };
1903 : :
1904 [ # # ]: 0 : if (msglen < sizeof(struct cpchnl2_event_info)) {
1905 : 0 : PMD_DRV_LOG(ERR, "Error event");
1906 : 0 : return;
1907 : : }
1908 : :
1909 [ # # # ]: 0 : switch (cpchnl2_event->header.type) {
1910 : 0 : case CPCHNL2_EVENT_VPORT_CREATED:
1911 : 0 : vport_identity.vport_id = cpchnl2_event->data.vport_created.vport.vport_id;
1912 : 0 : vport_created = &cpchnl2_event->data.vport_created;
1913 : 0 : vport_identity.func_type = vport_created->info.func_type;
1914 : 0 : vport_identity.pf_id = vport_created->info.pf_id;
1915 : 0 : vport_identity.vf_id = vport_created->info.vf_id;
1916 [ # # ]: 0 : if (cpfl_vport_info_create(adapter, &vport_identity, vport_created))
1917 : 0 : PMD_DRV_LOG(WARNING, "Failed to handle CPCHNL2_EVENT_VPORT_CREATED");
1918 : : break;
1919 : 0 : case CPCHNL2_EVENT_VPORT_DESTROYED:
1920 : 0 : vport_identity.vport_id = cpchnl2_event->data.vport_destroyed.vport.vport_id;
1921 : 0 : vport_identity.func_type = cpchnl2_event->data.vport_destroyed.func.func_type;
1922 : 0 : vport_identity.pf_id = cpchnl2_event->data.vport_destroyed.func.pf_id;
1923 : 0 : vport_identity.vf_id = cpchnl2_event->data.vport_destroyed.func.vf_id;
1924 [ # # ]: 0 : if (cpfl_vport_info_destroy(adapter, &vport_identity))
1925 : 0 : PMD_DRV_LOG(WARNING, "Failed to handle CPCHNL2_EVENT_VPORT_DESTROY");
1926 : : break;
1927 : 0 : default:
1928 : 0 : PMD_DRV_LOG(ERR, " unknown event received %u", cpchnl2_event->header.type);
1929 : 0 : break;
1930 : : }
1931 : : }
1932 : :
1933 : : static void
1934 : 0 : cpfl_handle_virtchnl_msg(struct cpfl_adapter_ext *adapter)
1935 : : {
1936 : : struct idpf_adapter *base = &adapter->base;
1937 : 0 : struct idpf_dma_mem *dma_mem = NULL;
1938 : 0 : struct idpf_hw *hw = &base->hw;
1939 : : struct idpf_ctlq_msg ctlq_msg;
1940 : : enum idpf_mbx_opc mbx_op;
1941 : 0 : uint16_t pending = 1;
1942 : : uint32_t vc_op;
1943 : : int ret;
1944 : :
1945 [ # # ]: 0 : while (pending) {
1946 : 0 : ret = idpf_vc_ctlq_recv(hw->arq, &pending, &ctlq_msg);
1947 [ # # ]: 0 : if (ret) {
1948 : 0 : PMD_DRV_LOG(INFO, "Failed to read msg from virtual channel, ret: %d", ret);
1949 : 0 : return;
1950 : : }
1951 : :
1952 [ # # ]: 0 : memcpy(base->mbx_resp, ctlq_msg.ctx.indirect.payload->va,
1953 : : IDPF_DFLT_MBX_BUF_SIZE);
1954 : :
1955 : 0 : mbx_op = rte_le_to_cpu_16(ctlq_msg.opcode);
1956 : 0 : vc_op = rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_opcode);
1957 : 0 : base->cmd_retval = rte_le_to_cpu_32(ctlq_msg.cookie.mbx.chnl_retval);
1958 : :
1959 [ # # ]: 0 : switch (mbx_op) {
1960 : 0 : case idpf_mbq_opc_send_msg_to_peer_pf:
1961 : : case idpf_mbq_opc_send_msg_to_peer_drv:
1962 [ # # ]: 0 : if (vc_op == VIRTCHNL2_OP_EVENT) {
1963 : 0 : cpfl_handle_vchnl_event_msg(adapter, adapter->base.mbx_resp,
1964 : 0 : ctlq_msg.data_len);
1965 [ # # ]: 0 : } else if (vc_op == CPCHNL2_OP_EVENT) {
1966 : 0 : cpfl_handle_cpchnl_event_msg(adapter, adapter->base.mbx_resp,
1967 : 0 : ctlq_msg.data_len);
1968 : : } else {
1969 [ # # ]: 0 : if (vc_op == base->pend_cmd)
1970 : : notify_cmd(base, base->cmd_retval);
1971 : : else
1972 : 0 : PMD_DRV_LOG(ERR, "command mismatch, expect %u, get %u",
1973 : : base->pend_cmd, vc_op);
1974 : :
1975 : 0 : PMD_DRV_LOG(DEBUG, " Virtual channel response is received,"
1976 : : "opcode = %d", vc_op);
1977 : : }
1978 : 0 : goto post_buf;
1979 : 0 : default:
1980 : 0 : PMD_DRV_LOG(DEBUG, "Request %u is not supported yet", mbx_op);
1981 : : }
1982 : : }
1983 : :
1984 : 0 : post_buf:
1985 [ # # ]: 0 : if (ctlq_msg.data_len)
1986 : 0 : dma_mem = ctlq_msg.ctx.indirect.payload;
1987 : : else
1988 : 0 : pending = 0;
1989 : :
1990 : 0 : ret = idpf_vc_ctlq_post_rx_buffs(hw, hw->arq, &pending, &dma_mem);
1991 [ # # # # ]: 0 : if (ret && dma_mem)
1992 : : idpf_free_dma_mem(hw, dma_mem);
1993 : : }
1994 : :
1995 : : static void
1996 : 0 : cpfl_dev_alarm_handler(void *param)
1997 : : {
1998 : : struct cpfl_adapter_ext *adapter = param;
1999 : :
2000 : 0 : cpfl_handle_virtchnl_msg(adapter);
2001 : :
2002 : 0 : rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter);
2003 : 0 : }
2004 : :
2005 : : static
2006 : 0 : int vcpf_save_vport_info_response(struct cpfl_vport *cpfl_vport,
2007 : : struct cpchnl2_get_vport_info_response *response)
2008 : : {
2009 : : struct cpchnl2_vport_info *info;
2010 : : struct vcpf_vport_info *vport_info;
2011 : : struct cpchnl2_queue_group_info *qgp;
2012 : : struct cpchnl2_queue_chunk *q_chnk;
2013 : : u16 num_queue_groups;
2014 : : u16 num_chunks;
2015 : : u32 q_type;
2016 : :
2017 : : info = &response->info;
2018 : : vport_info = &cpfl_vport->vport_info;
2019 : 0 : vport_info->vport_index = info->vport_index;
2020 : 0 : vport_info->vsi_id = info->vsi_id;
2021 : :
2022 : 0 : num_queue_groups = response->queue_groups.num_queue_groups;
2023 [ # # ]: 0 : for (u16 i = 0; i < num_queue_groups; i++) {
2024 : 0 : qgp = &response->queue_groups.groups[i];
2025 : 0 : num_chunks = qgp->chunks.num_chunks;
2026 : : /* rx q and tx q are stored in first 2 chunks */
2027 [ # # ]: 0 : for (u16 j = 0; j < (num_chunks - 2); j++) {
2028 : : q_chnk = &qgp->chunks.chunks[j];
2029 : 0 : q_type = q_chnk->type;
2030 [ # # ]: 0 : if (q_type == VIRTCHNL2_QUEUE_TYPE_TX) {
2031 : 0 : vport_info->abs_start_txq_id = q_chnk->start_queue_id;
2032 : 0 : vport_info->num_tx_q = q_chnk->num_queues;
2033 [ # # ]: 0 : } else if (q_type == VIRTCHNL2_QUEUE_TYPE_RX) {
2034 : 0 : vport_info->abs_start_rxq_id = q_chnk->start_queue_id;
2035 : 0 : vport_info->num_rx_q = q_chnk->num_queues;
2036 : : }
2037 : : }
2038 : : }
2039 : 0 : return 0;
2040 : : }
2041 : :
2042 : : static int
2043 : 0 : cpfl_stop_cfgqs(struct cpfl_adapter_ext *adapter)
2044 : : {
2045 : : int i, ret;
2046 : :
2047 [ # # ]: 0 : for (i = 0; i < adapter->num_tx_cfgq; i++) {
2048 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw))
2049 : 0 : ret = idpf_vc_ena_dis_one_queue_vcpf(&adapter->base,
2050 : 0 : adapter->cfgq_info[0].id,
2051 : : VIRTCHNL2_QUEUE_TYPE_CONFIG_TX, false);
2052 : : else
2053 : 0 : ret = idpf_vc_queue_switch(&adapter->ctrl_vport.base, i, false, false,
2054 : : VIRTCHNL2_QUEUE_TYPE_CONFIG_TX);
2055 : :
2056 [ # # ]: 0 : if (ret) {
2057 : 0 : PMD_DRV_LOG(ERR, "Fail to disable Tx config queue.");
2058 : 0 : return ret;
2059 : : }
2060 : : }
2061 : :
2062 [ # # ]: 0 : for (i = 0; i < adapter->num_rx_cfgq; i++) {
2063 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw))
2064 : 0 : ret = idpf_vc_ena_dis_one_queue_vcpf(&adapter->base,
2065 : 0 : adapter->cfgq_info[1].id,
2066 : : VIRTCHNL2_QUEUE_TYPE_CONFIG_RX, false);
2067 : : else
2068 : 0 : ret = idpf_vc_queue_switch(&adapter->ctrl_vport.base, i, true, false,
2069 : : VIRTCHNL2_QUEUE_TYPE_CONFIG_RX);
2070 : :
2071 [ # # ]: 0 : if (ret) {
2072 : 0 : PMD_DRV_LOG(ERR, "Fail to disable Rx config queue.");
2073 : 0 : return ret;
2074 : : }
2075 : : }
2076 : :
2077 : : return 0;
2078 : :
2079 : : }
2080 : :
2081 : : static int
2082 : 0 : cpfl_start_cfgqs(struct cpfl_adapter_ext *adapter)
2083 : : {
2084 : : int i, ret;
2085 : :
2086 : 0 : ret = cpfl_config_ctlq_tx(adapter);
2087 [ # # ]: 0 : if (ret) {
2088 : 0 : PMD_DRV_LOG(ERR, "Fail to configure Tx config queue.");
2089 : 0 : return ret;
2090 : : }
2091 : :
2092 : 0 : ret = cpfl_config_ctlq_rx(adapter);
2093 [ # # ]: 0 : if (ret) {
2094 : 0 : PMD_DRV_LOG(ERR, "Fail to configure Rx config queue.");
2095 : 0 : return ret;
2096 : : }
2097 : :
2098 [ # # ]: 0 : for (i = 0; i < adapter->num_tx_cfgq; i++) {
2099 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw))
2100 : 0 : ret = idpf_vc_ena_dis_one_queue_vcpf(&adapter->base,
2101 : 0 : adapter->cfgq_info[0].id,
2102 : : VIRTCHNL2_QUEUE_TYPE_CONFIG_TX, true);
2103 : : else
2104 : 0 : ret = idpf_vc_queue_switch(&adapter->ctrl_vport.base, i, false, true,
2105 : : VIRTCHNL2_QUEUE_TYPE_CONFIG_TX);
2106 [ # # ]: 0 : if (ret) {
2107 : 0 : PMD_DRV_LOG(ERR, "Fail to enable Tx config queue.");
2108 : 0 : return ret;
2109 : : }
2110 : : }
2111 : :
2112 [ # # ]: 0 : for (i = 0; i < adapter->num_rx_cfgq; i++) {
2113 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw))
2114 : 0 : ret = idpf_vc_ena_dis_one_queue_vcpf(&adapter->base,
2115 : 0 : adapter->cfgq_info[1].id,
2116 : : VIRTCHNL2_QUEUE_TYPE_CONFIG_RX, true);
2117 : : else
2118 : 0 : ret = idpf_vc_queue_switch(&adapter->ctrl_vport.base, i, true, true,
2119 : : VIRTCHNL2_QUEUE_TYPE_CONFIG_RX);
2120 [ # # ]: 0 : if (ret) {
2121 : 0 : PMD_DRV_LOG(ERR, "Fail to enable Rx config queue.");
2122 : 0 : return ret;
2123 : : }
2124 : : }
2125 : :
2126 : : return 0;
2127 : : }
2128 : :
2129 : : static void
2130 : 0 : cpfl_remove_cfgqs(struct cpfl_adapter_ext *adapter)
2131 : : {
2132 : 0 : struct idpf_hw *hw = (struct idpf_hw *)(&adapter->base.hw);
2133 : : struct cpfl_ctlq_create_info *create_cfgq_info;
2134 : : int i;
2135 : :
2136 : 0 : create_cfgq_info = adapter->cfgq_info;
2137 : :
2138 [ # # ]: 0 : for (i = 0; i < adapter->num_cfgq; i++) {
2139 [ # # ]: 0 : if (adapter->ctlqp[i]) {
2140 : 0 : cpfl_vport_ctlq_remove(hw, adapter->ctlqp[i]);
2141 : 0 : adapter->ctlqp[i] = NULL;
2142 : : }
2143 [ # # ]: 0 : if (create_cfgq_info[i].ring_mem.va)
2144 : : idpf_free_dma_mem(&adapter->base.hw, &create_cfgq_info[i].ring_mem);
2145 [ # # ]: 0 : if (create_cfgq_info[i].buf_mem.va)
2146 : : idpf_free_dma_mem(&adapter->base.hw, &create_cfgq_info[i].buf_mem);
2147 : : }
2148 [ # # ]: 0 : if (adapter->ctlqp) {
2149 : 0 : rte_free(adapter->ctlqp);
2150 : 0 : adapter->ctlqp = NULL;
2151 : : }
2152 : 0 : }
2153 : :
2154 : : static int
2155 : 0 : cpfl_add_cfgqs(struct cpfl_adapter_ext *adapter)
2156 : : {
2157 : : struct idpf_ctlq_info *cfg_cq;
2158 : : int ret = 0;
2159 : : int i = 0;
2160 : :
2161 : 0 : adapter->ctlqp = rte_zmalloc("ctlqp", adapter->num_cfgq *
2162 : : sizeof(struct idpf_ctlq_info *),
2163 : : RTE_CACHE_LINE_SIZE);
2164 : :
2165 [ # # ]: 0 : if (!adapter->ctlqp) {
2166 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for control queues");
2167 : 0 : return -ENOMEM;
2168 : : }
2169 : :
2170 [ # # ]: 0 : for (i = 0; i < adapter->num_cfgq; i++) {
2171 : 0 : cfg_cq = NULL;
2172 : 0 : ret = cpfl_vport_ctlq_add((struct idpf_hw *)(&adapter->base.hw),
2173 : 0 : &adapter->cfgq_info[i],
2174 : : &cfg_cq);
2175 [ # # # # ]: 0 : if (ret || !cfg_cq) {
2176 : 0 : PMD_DRV_LOG(ERR, "ctlq add failed for queue id: %d",
2177 : : adapter->cfgq_info[i].id);
2178 : 0 : cpfl_remove_cfgqs(adapter);
2179 : 0 : return ret;
2180 : : }
2181 : 0 : PMD_DRV_LOG(INFO, "added cfgq to hw. queue id: %d",
2182 : : adapter->cfgq_info[i].id);
2183 : 0 : adapter->ctlqp[i] = cfg_cq;
2184 : : }
2185 : :
2186 : : return ret;
2187 : : }
2188 : :
2189 : : static
2190 : 0 : int vcpf_save_chunk_in_cfgq(struct cpfl_adapter_ext *adapter)
2191 : : {
2192 : 0 : struct virtchnl2_add_queues *add_q =
2193 : : (struct virtchnl2_add_queues *)adapter->addq_recv_info;
2194 : : struct vcpf_cfg_queue *cfgq;
2195 : : struct virtchnl2_queue_reg_chunk *q_chnk;
2196 : : u16 rx, tx, num_chunks, num_q, struct_size;
2197 : : u32 q_id, q_type;
2198 : :
2199 : : rx = 0; tx = 0;
2200 : :
2201 : 0 : cfgq = rte_zmalloc("cfgq", adapter->num_cfgq * sizeof(struct vcpf_cfg_queue),
2202 : : RTE_CACHE_LINE_SIZE);
2203 [ # # ]: 0 : if (!cfgq) {
2204 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for cfgq");
2205 : 0 : return -ENOMEM;
2206 : : }
2207 : :
2208 : 0 : struct_size = idpf_struct_size(add_q, chunks.chunks, (add_q->chunks.num_chunks - 1));
2209 : 0 : adapter->cfgq_in.cfgq_add = rte_zmalloc("config_queues", struct_size, 0);
2210 [ # # ]: 0 : if (!adapter->cfgq_in.cfgq_add) {
2211 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for add_q");
2212 : 0 : return -ENOMEM;
2213 : : }
2214 : : memcpy(adapter->cfgq_in.cfgq_add, add_q, struct_size);
2215 : :
2216 : 0 : num_chunks = add_q->chunks.num_chunks;
2217 [ # # ]: 0 : for (u16 i = 0; i < num_chunks; i++) {
2218 : 0 : num_q = add_q->chunks.chunks[i].num_queues;
2219 : : q_chnk = &add_q->chunks.chunks[i];
2220 [ # # ]: 0 : for (u16 j = 0; j < num_q; j++) {
2221 [ # # # # ]: 0 : if (rx > adapter->num_cfgq || tx > adapter->num_cfgq)
2222 : : break;
2223 : 0 : q_id = q_chnk->start_queue_id + j;
2224 : 0 : q_type = q_chnk->type;
2225 [ # # ]: 0 : if (q_type == VIRTCHNL2_QUEUE_TYPE_MBX_TX) {
2226 : 0 : cfgq[0].qid = q_id;
2227 : 0 : cfgq[0].qtail_reg_start = q_chnk->qtail_reg_start;
2228 : 0 : cfgq[0].qtail_reg_spacing = q_chnk->qtail_reg_spacing;
2229 : 0 : q_chnk->type = VIRTCHNL2_QUEUE_TYPE_CONFIG_TX;
2230 : 0 : tx++;
2231 [ # # ]: 0 : } else if (q_type == VIRTCHNL2_QUEUE_TYPE_MBX_RX) {
2232 : 0 : cfgq[1].qid = q_id;
2233 : 0 : cfgq[1].qtail_reg_start = q_chnk->qtail_reg_start;
2234 : 0 : cfgq[1].qtail_reg_spacing = q_chnk->qtail_reg_spacing;
2235 : 0 : q_chnk->type = VIRTCHNL2_QUEUE_TYPE_CONFIG_RX;
2236 : 0 : rx++;
2237 : : }
2238 : : }
2239 : : }
2240 : :
2241 : 0 : adapter->cfgq_in.cfgq = cfgq;
2242 : 0 : adapter->cfgq_in.num_cfgq = adapter->num_cfgq;
2243 : :
2244 : 0 : return 0;
2245 : : }
2246 : :
2247 : : #define CPFL_CFGQ_RING_LEN 512
2248 : : #define CPFL_CFGQ_DESCRIPTOR_SIZE 32
2249 : : #define CPFL_CFGQ_BUFFER_SIZE 256
2250 : : #define CPFL_CFGQ_RING_SIZE 512
2251 : :
2252 : : static int
2253 : 0 : cpfl_cfgq_setup(struct cpfl_adapter_ext *adapter)
2254 : : {
2255 : : struct cpfl_ctlq_create_info *create_cfgq_info;
2256 : : struct cpfl_vport *vport;
2257 : : struct vcpf_cfgq_info *cfgq_info = &adapter->cfgq_in;
2258 : : int i, err;
2259 : : uint32_t ring_size = CPFL_CFGQ_RING_SIZE * sizeof(struct idpf_ctlq_desc);
2260 : : uint32_t buf_size = CPFL_CFGQ_RING_SIZE * CPFL_CFGQ_BUFFER_SIZE;
2261 : : uint64_t tx_qtail_start;
2262 : : uint64_t rx_qtail_start;
2263 : : uint32_t tx_qtail_spacing;
2264 : : uint32_t rx_qtail_spacing;
2265 : :
2266 : : vport = &adapter->ctrl_vport;
2267 : :
2268 : 0 : tx_qtail_start = vport->base.chunks_info.tx_qtail_start;
2269 : 0 : tx_qtail_spacing = vport->base.chunks_info.tx_qtail_spacing;
2270 : 0 : rx_qtail_start = vport->base.chunks_info.rx_qtail_start;
2271 : 0 : rx_qtail_spacing = vport->base.chunks_info.rx_qtail_spacing;
2272 : :
2273 : 0 : adapter->cfgq_info = rte_zmalloc("cfgq_info", adapter->num_cfgq *
2274 : : sizeof(struct cpfl_ctlq_create_info),
2275 : : RTE_CACHE_LINE_SIZE);
2276 : :
2277 [ # # ]: 0 : if (!adapter->cfgq_info) {
2278 : 0 : PMD_DRV_LOG(ERR, "Failed to allocate memory for cfgq_info");
2279 : 0 : return -ENOMEM;
2280 : : }
2281 : :
2282 : : create_cfgq_info = adapter->cfgq_info;
2283 : :
2284 [ # # ]: 0 : for (i = 0; i < adapter->num_cfgq; i++) {
2285 [ # # ]: 0 : if (i % 2 == 0) {
2286 : : /* Setup Tx config queue */
2287 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw))
2288 : 0 : create_cfgq_info[i].id = cfgq_info->cfgq[i].qid;
2289 : : else
2290 : 0 : create_cfgq_info[i].id = vport->base.chunks_info.tx_start_qid +
2291 : 0 : i / 2;
2292 : :
2293 : 0 : create_cfgq_info[i].type = IDPF_CTLQ_TYPE_CONFIG_TX;
2294 : 0 : create_cfgq_info[i].len = CPFL_CFGQ_RING_SIZE;
2295 : 0 : create_cfgq_info[i].buf_size = CPFL_CFGQ_BUFFER_SIZE;
2296 : 0 : memset(&create_cfgq_info[i].reg, 0, sizeof(struct idpf_ctlq_reg));
2297 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw))
2298 : 0 : create_cfgq_info[i].reg.tail = cfgq_info->cfgq[i].qtail_reg_start;
2299 : : else
2300 : 0 : create_cfgq_info[i].reg.tail = tx_qtail_start +
2301 : 0 : i / 2 * tx_qtail_spacing;
2302 : :
2303 : : } else {
2304 : : /* Setup Rx config queue */
2305 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw))
2306 : 0 : create_cfgq_info[i].id = cfgq_info->cfgq[i].qid;
2307 : : else
2308 : 0 : create_cfgq_info[i].id = vport->base.chunks_info.rx_start_qid +
2309 : 0 : i / 2;
2310 : :
2311 : 0 : create_cfgq_info[i].type = IDPF_CTLQ_TYPE_CONFIG_RX;
2312 : 0 : create_cfgq_info[i].len = CPFL_CFGQ_RING_SIZE;
2313 : 0 : create_cfgq_info[i].buf_size = CPFL_CFGQ_BUFFER_SIZE;
2314 : 0 : memset(&create_cfgq_info[i].reg, 0, sizeof(struct idpf_ctlq_reg));
2315 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw))
2316 : 0 : create_cfgq_info[i].reg.tail = cfgq_info->cfgq[i].qtail_reg_start;
2317 : : else
2318 : 0 : create_cfgq_info[i].reg.tail = rx_qtail_start +
2319 : 0 : i / 2 * rx_qtail_spacing;
2320 : :
2321 : :
2322 [ # # ]: 0 : if (!idpf_alloc_dma_mem(&adapter->base.hw, &create_cfgq_info[i].buf_mem,
2323 : : buf_size)) {
2324 : : err = -ENOMEM;
2325 : 0 : goto free_mem;
2326 : : }
2327 : : }
2328 [ # # ]: 0 : if (!idpf_alloc_dma_mem(&adapter->base.hw, &create_cfgq_info[i].ring_mem,
2329 : : ring_size)) {
2330 : : err = -ENOMEM;
2331 : 0 : goto free_mem;
2332 : : }
2333 : : }
2334 : :
2335 : : return 0;
2336 : : free_mem:
2337 [ # # ]: 0 : for (i = 0; i < adapter->num_cfgq; i++) {
2338 [ # # ]: 0 : if (create_cfgq_info[i].ring_mem.va)
2339 : : idpf_free_dma_mem(&adapter->base.hw, &create_cfgq_info[i].ring_mem);
2340 [ # # ]: 0 : if (create_cfgq_info[i].buf_mem.va)
2341 : : idpf_free_dma_mem(&adapter->base.hw, &create_cfgq_info[i].buf_mem);
2342 : : }
2343 [ # # ]: 0 : if (adapter->cfgq_info) {
2344 : 0 : rte_free(adapter->cfgq_info);
2345 : 0 : adapter->cfgq_info = NULL;
2346 : : }
2347 : : return err;
2348 : : }
2349 : :
2350 : : static int
2351 : 0 : cpfl_init_ctrl_vport(struct cpfl_adapter_ext *adapter)
2352 : : {
2353 : : struct cpfl_vport *vport = &adapter->ctrl_vport;
2354 : : struct virtchnl2_create_vport *vport_info =
2355 : : (struct virtchnl2_create_vport *)adapter->ctrl_vport_recv_info;
2356 : : int i;
2357 : :
2358 : 0 : vport->itf.adapter = adapter;
2359 : 0 : vport->base.adapter = &adapter->base;
2360 : 0 : vport->base.vport_id = vport_info->vport_id;
2361 : :
2362 [ # # ]: 0 : for (i = 0; i < vport_info->chunks.num_chunks; i++) {
2363 [ # # ]: 0 : if (vport_info->chunks.chunks[i].type == VIRTCHNL2_QUEUE_TYPE_TX) {
2364 : 0 : vport->base.chunks_info.tx_start_qid =
2365 : 0 : vport_info->chunks.chunks[i].start_queue_id;
2366 : 0 : vport->base.chunks_info.tx_qtail_start =
2367 : 0 : vport_info->chunks.chunks[i].qtail_reg_start;
2368 : 0 : vport->base.chunks_info.tx_qtail_spacing =
2369 : 0 : vport_info->chunks.chunks[i].qtail_reg_spacing;
2370 [ # # ]: 0 : } else if (vport_info->chunks.chunks[i].type == VIRTCHNL2_QUEUE_TYPE_RX) {
2371 : 0 : vport->base.chunks_info.rx_start_qid =
2372 : 0 : vport_info->chunks.chunks[i].start_queue_id;
2373 : 0 : vport->base.chunks_info.rx_qtail_start =
2374 : 0 : vport_info->chunks.chunks[i].qtail_reg_start;
2375 : 0 : vport->base.chunks_info.rx_qtail_spacing =
2376 : 0 : vport_info->chunks.chunks[i].qtail_reg_spacing;
2377 : : } else {
2378 : 0 : PMD_INIT_LOG(ERR, "Unsupported chunk type");
2379 : 0 : return -EINVAL;
2380 : : }
2381 : : }
2382 : :
2383 : : return 0;
2384 : : }
2385 : :
2386 : : static void
2387 : 0 : cpfl_ctrl_path_close(struct cpfl_adapter_ext *adapter)
2388 : : {
2389 : 0 : cpfl_stop_cfgqs(adapter);
2390 : 0 : cpfl_remove_cfgqs(adapter);
2391 [ # # ]: 0 : if (!idpf_is_vf_device(&adapter->base.hw))
2392 : 0 : idpf_vc_vport_destroy(&adapter->ctrl_vport.base);
2393 : : else
2394 : 0 : vcpf_del_queues(adapter);
2395 : 0 : }
2396 : :
2397 : : static int
2398 : 0 : cpfl_ctrl_path_open(struct cpfl_adapter_ext *adapter)
2399 : : {
2400 : : int ret;
2401 : :
2402 [ # # ]: 0 : if (!idpf_is_vf_device(&adapter->base.hw)) {
2403 : 0 : ret = cpfl_vc_create_ctrl_vport(adapter);
2404 [ # # ]: 0 : if (ret) {
2405 : 0 : PMD_INIT_LOG(ERR, "Failed to create control vport");
2406 : 0 : return ret;
2407 : : }
2408 : :
2409 : 0 : ret = cpfl_init_ctrl_vport(adapter);
2410 [ # # ]: 0 : if (ret) {
2411 : 0 : PMD_INIT_LOG(ERR, "Failed to init control vport");
2412 : 0 : goto err_init_ctrl_vport;
2413 : : }
2414 : : } else {
2415 : 0 : ret = vcpf_add_queues(adapter);
2416 [ # # ]: 0 : if (ret) {
2417 : 0 : PMD_INIT_LOG(ERR, "Failed to add queues");
2418 : 0 : return ret;
2419 : : }
2420 : :
2421 : 0 : ret = vcpf_save_chunk_in_cfgq(adapter);
2422 [ # # ]: 0 : if (ret) {
2423 : 0 : PMD_INIT_LOG(ERR, "Failed to save config queue chunk");
2424 : 0 : return ret;
2425 : : }
2426 : : }
2427 : :
2428 : 0 : ret = cpfl_cfgq_setup(adapter);
2429 [ # # ]: 0 : if (ret) {
2430 : 0 : PMD_INIT_LOG(ERR, "Failed to setup control queues");
2431 [ # # ]: 0 : if (!idpf_is_vf_device(&adapter->base.hw))
2432 : 0 : goto err_cfgq_setup;
2433 : : else
2434 : 0 : goto err_del_cfg;
2435 : : }
2436 : :
2437 : 0 : ret = cpfl_add_cfgqs(adapter);
2438 [ # # ]: 0 : if (ret) {
2439 : 0 : PMD_INIT_LOG(ERR, "Failed to add control queues");
2440 : 0 : goto err_add_cfgq;
2441 : : }
2442 : :
2443 : 0 : ret = cpfl_start_cfgqs(adapter);
2444 [ # # ]: 0 : if (ret) {
2445 : 0 : PMD_INIT_LOG(ERR, "Failed to start control queues");
2446 : 0 : goto err_start_cfgqs;
2447 : : }
2448 : :
2449 : : return 0;
2450 : :
2451 : : err_start_cfgqs:
2452 : 0 : cpfl_stop_cfgqs(adapter);
2453 : 0 : err_add_cfgq:
2454 : 0 : cpfl_remove_cfgqs(adapter);
2455 : 0 : err_cfgq_setup:
2456 : 0 : err_init_ctrl_vport:
2457 [ # # ]: 0 : if (!idpf_is_vf_device(&adapter->base.hw))
2458 : 0 : idpf_vc_vport_destroy(&adapter->ctrl_vport.base);
2459 : 0 : err_del_cfg:
2460 : 0 : vcpf_del_queues(adapter);
2461 : :
2462 : 0 : return ret;
2463 : :
2464 : : }
2465 : :
2466 : : static struct virtchnl2_get_capabilities req_caps = {
2467 : : .csum_caps =
2468 : : VIRTCHNL2_CAP_TX_CSUM_L3_IPV4 |
2469 : : VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_TCP |
2470 : : VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_UDP |
2471 : : VIRTCHNL2_CAP_TX_CSUM_L4_IPV4_SCTP |
2472 : : VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_TCP |
2473 : : VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_UDP |
2474 : : VIRTCHNL2_CAP_TX_CSUM_L4_IPV6_SCTP |
2475 : : VIRTCHNL2_CAP_TX_CSUM_GENERIC |
2476 : : VIRTCHNL2_CAP_RX_CSUM_L3_IPV4 |
2477 : : VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_TCP |
2478 : : VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_UDP |
2479 : : VIRTCHNL2_CAP_RX_CSUM_L4_IPV4_SCTP |
2480 : : VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_TCP |
2481 : : VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_UDP |
2482 : : VIRTCHNL2_CAP_RX_CSUM_L4_IPV6_SCTP |
2483 : : VIRTCHNL2_CAP_RX_CSUM_GENERIC,
2484 : :
2485 : : .rss_caps =
2486 : : VIRTCHNL2_CAP_RSS_IPV4_TCP |
2487 : : VIRTCHNL2_CAP_RSS_IPV4_UDP |
2488 : : VIRTCHNL2_CAP_RSS_IPV4_SCTP |
2489 : : VIRTCHNL2_CAP_RSS_IPV4_OTHER |
2490 : : VIRTCHNL2_CAP_RSS_IPV6_TCP |
2491 : : VIRTCHNL2_CAP_RSS_IPV6_UDP |
2492 : : VIRTCHNL2_CAP_RSS_IPV6_SCTP |
2493 : : VIRTCHNL2_CAP_RSS_IPV6_OTHER |
2494 : : VIRTCHNL2_CAP_RSS_IPV4_AH |
2495 : : VIRTCHNL2_CAP_RSS_IPV4_ESP |
2496 : : VIRTCHNL2_CAP_RSS_IPV4_AH_ESP |
2497 : : VIRTCHNL2_CAP_RSS_IPV6_AH |
2498 : : VIRTCHNL2_CAP_RSS_IPV6_ESP |
2499 : : VIRTCHNL2_CAP_RSS_IPV6_AH_ESP,
2500 : :
2501 : : .other_caps = VIRTCHNL2_CAP_WB_ON_ITR
2502 : : };
2503 : :
2504 : : static int
2505 : 0 : cpfl_vport_map_init(struct cpfl_adapter_ext *adapter)
2506 : : {
2507 : : char hname[32];
2508 : :
2509 : 0 : snprintf(hname, 32, "%s-vport", adapter->name);
2510 : :
2511 : : rte_spinlock_init(&adapter->vport_map_lock);
2512 : :
2513 : : #define CPFL_VPORT_MAP_HASH_ENTRY_NUM 2048
2514 : :
2515 : 0 : struct rte_hash_parameters params = {
2516 : : .name = adapter->name,
2517 : : .entries = CPFL_VPORT_MAP_HASH_ENTRY_NUM,
2518 : : .key_len = sizeof(struct cpfl_vport_id),
2519 : : .hash_func = rte_hash_crc,
2520 : : .socket_id = SOCKET_ID_ANY,
2521 : : };
2522 : :
2523 : 0 : adapter->vport_map_hash = rte_hash_create(¶ms);
2524 : :
2525 [ # # ]: 0 : if (adapter->vport_map_hash == NULL) {
2526 : 0 : PMD_INIT_LOG(ERR, "Failed to create vport map hash");
2527 : 0 : return -EINVAL;
2528 : : }
2529 : :
2530 : : return 0;
2531 : : }
2532 : :
2533 : : static void
2534 : 0 : cpfl_vport_map_uninit(struct cpfl_adapter_ext *adapter)
2535 : : {
2536 : 0 : const void *key = NULL;
2537 : : struct cpfl_vport_map_info *info;
2538 : 0 : uint32_t iter = 0;
2539 : :
2540 [ # # ]: 0 : while (rte_hash_iterate(adapter->vport_map_hash, &key, (void **)&info, &iter) >= 0)
2541 : 0 : rte_free(info);
2542 : :
2543 : 0 : rte_hash_free(adapter->vport_map_hash);
2544 : 0 : }
2545 : :
2546 : : static int
2547 : 0 : cpfl_repr_allowlist_init(struct cpfl_adapter_ext *adapter)
2548 : : {
2549 : : char hname[32];
2550 : :
2551 : 0 : snprintf(hname, 32, "%s-repr_al", adapter->name);
2552 : :
2553 : : rte_spinlock_init(&adapter->repr_lock);
2554 : :
2555 : : #define CPFL_REPR_HASH_ENTRY_NUM 2048
2556 : :
2557 : 0 : struct rte_hash_parameters params = {
2558 : : .name = hname,
2559 : : .entries = CPFL_REPR_HASH_ENTRY_NUM,
2560 : : .key_len = sizeof(struct cpfl_repr_id),
2561 : : .hash_func = rte_hash_crc,
2562 : : .socket_id = SOCKET_ID_ANY,
2563 : : };
2564 : :
2565 : 0 : adapter->repr_allowlist_hash = rte_hash_create(¶ms);
2566 : :
2567 [ # # ]: 0 : if (adapter->repr_allowlist_hash == NULL) {
2568 : 0 : PMD_INIT_LOG(ERR, "Failed to create repr allowlist hash");
2569 : 0 : return -EINVAL;
2570 : : }
2571 : :
2572 : : return 0;
2573 : : }
2574 : :
2575 : : static void
2576 : : cpfl_repr_allowlist_uninit(struct cpfl_adapter_ext *adapter)
2577 : : {
2578 : 0 : rte_hash_free(adapter->repr_allowlist_hash);
2579 : 0 : }
2580 : :
2581 : : static uint8_t
2582 : 0 : get_running_host_id(void)
2583 : : {
2584 : : struct utsname unamedata;
2585 : : uint8_t host_id = CPFL_INVALID_HOST_ID;
2586 : :
2587 [ # # ]: 0 : if (uname(&unamedata) != 0)
2588 : 0 : PMD_INIT_LOG(ERR, "Cannot fetch node_name for host");
2589 [ # # ]: 0 : else if (strstr(unamedata.nodename, "ipu-imc"))
2590 : 0 : PMD_INIT_LOG(ERR, "CPFL PMD cannot be running on IMC.");
2591 [ # # ]: 0 : else if (strstr(unamedata.nodename, "ipu-acc"))
2592 : : host_id = CPFL_HOST_ID_ACC;
2593 : : else
2594 : : host_id = CPFL_HOST_ID_HOST;
2595 : :
2596 : 0 : return host_id;
2597 : : }
2598 : :
2599 : : static uint8_t
2600 : : set_config_queue_details(struct cpfl_adapter_ext *adapter, struct rte_pci_addr *pci_addr)
2601 : : {
2602 [ # # ]: 0 : if (pci_addr->function == CPFL_FID) {
2603 : 0 : adapter->num_cfgq = CPFL_CFGQ_NUM;
2604 : 0 : adapter->num_rx_cfgq = CPFL_RX_CFGQ_NUM;
2605 : 0 : adapter->num_tx_cfgq = CPFL_TX_CFGQ_NUM;
2606 [ # # ]: 0 : } else if (pci_addr->function == VCPF_FID) {
2607 : 0 : adapter->num_cfgq = VCPF_CFGQ_NUM;
2608 : 0 : adapter->num_rx_cfgq = VCPF_RX_CFGQ_NUM;
2609 : 0 : adapter->num_tx_cfgq = VCPF_TX_CFGQ_NUM;
2610 : : }
2611 : :
2612 : : return 0;
2613 : : }
2614 : :
2615 : : static int
2616 : 0 : cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter,
2617 : : struct cpfl_devargs *devargs)
2618 : : {
2619 : 0 : struct idpf_adapter *base = &adapter->base;
2620 : : struct idpf_hw *hw = &base->hw;
2621 : : struct rte_pci_addr *pci_addr = &pci_dev->addr;
2622 : : int ret = 0;
2623 : :
2624 : : #ifndef RTE_HAS_JANSSON
2625 : : RTE_SET_USED(devargs);
2626 : : #endif
2627 : :
2628 : 0 : hw->hw_addr = (void *)pci_dev->mem_resource[0].addr;
2629 : 0 : hw->hw_addr_len = pci_dev->mem_resource[0].len;
2630 : 0 : hw->back = base;
2631 : 0 : hw->vendor_id = pci_dev->id.vendor_id;
2632 : 0 : hw->device_id = pci_dev->id.device_id;
2633 : 0 : hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
2634 : 0 : adapter->host_id = get_running_host_id();
2635 : :
2636 : 0 : strlcpy(adapter->name, pci_dev->device.name, sizeof(adapter->name));
2637 : :
2638 : 0 : memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
2639 : :
2640 : 0 : ret = idpf_adapter_init(base);
2641 [ # # ]: 0 : if (ret != 0) {
2642 : 0 : PMD_INIT_LOG(ERR, "Failed to init adapter");
2643 : 0 : goto err_adapter_init;
2644 : : }
2645 : :
2646 : 0 : ret = cpfl_vport_map_init(adapter);
2647 [ # # ]: 0 : if (ret) {
2648 : 0 : PMD_INIT_LOG(ERR, "Failed to init vport map");
2649 : 0 : goto err_vport_map_init;
2650 : : }
2651 : :
2652 : 0 : ret = cpfl_repr_allowlist_init(adapter);
2653 [ # # ]: 0 : if (ret) {
2654 : 0 : PMD_INIT_LOG(ERR, "Failed to init representor allowlist");
2655 : 0 : goto err_repr_allowlist_init;
2656 : : }
2657 : :
2658 : 0 : rte_eal_alarm_set(CPFL_ALARM_INTERVAL, cpfl_dev_alarm_handler, adapter);
2659 : :
2660 : 0 : adapter->max_vport_nb = adapter->base.caps.max_vports > CPFL_MAX_VPORT_NUM ?
2661 : 0 : CPFL_MAX_VPORT_NUM : adapter->base.caps.max_vports;
2662 : :
2663 : 0 : adapter->vports = rte_zmalloc("vports",
2664 : 0 : adapter->max_vport_nb *
2665 : : sizeof(*adapter->vports),
2666 : : 0);
2667 [ # # ]: 0 : if (adapter->vports == NULL) {
2668 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate vports memory");
2669 : : ret = -ENOMEM;
2670 : 0 : goto err_vports_alloc;
2671 : : }
2672 : :
2673 : : /* set the number of config queues to be requested */
2674 : : ret = set_config_queue_details(adapter, pci_addr);
2675 : : if (ret) {
2676 : : PMD_INIT_LOG(ERR, "Failed to set the config queue details");
2677 : : return -1;
2678 : : }
2679 : :
2680 [ # # ]: 0 : if (pci_addr->function == VCPF_FID || pci_addr->function == CPFL_FID) {
2681 : 0 : ret = cpfl_ctrl_path_open(adapter);
2682 [ # # ]: 0 : if (ret) {
2683 : 0 : PMD_INIT_LOG(ERR, "Failed to setup control path");
2684 [ # # ]: 0 : if (pci_addr->function == CPFL_FID)
2685 : 0 : goto err_create_ctrl_vport;
2686 : : else
2687 : : return ret;
2688 : : }
2689 : :
2690 : : }
2691 : :
2692 : : #ifdef RTE_HAS_JANSSON
2693 : 0 : ret = cpfl_flow_init(adapter, devargs);
2694 [ # # ]: 0 : if (ret) {
2695 : 0 : PMD_INIT_LOG(ERR, "Failed to init flow module");
2696 : 0 : goto err_flow_init;
2697 : : }
2698 : : #endif
2699 : 0 : adapter->cur_vports = 0;
2700 : 0 : adapter->cur_vport_nb = 0;
2701 : :
2702 : 0 : adapter->used_vecs_num = 0;
2703 : :
2704 : 0 : return ret;
2705 : :
2706 : : #ifdef RTE_HAS_JANSSON
2707 : : err_flow_init:
2708 : 0 : cpfl_ctrl_path_close(adapter);
2709 : : #endif
2710 : 0 : err_create_ctrl_vport:
2711 : 0 : rte_free(adapter->vports);
2712 : 0 : err_vports_alloc:
2713 : 0 : rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
2714 : : cpfl_repr_allowlist_uninit(adapter);
2715 : 0 : err_repr_allowlist_init:
2716 : 0 : cpfl_vport_map_uninit(adapter);
2717 : 0 : err_vport_map_init:
2718 : 0 : idpf_adapter_deinit(base);
2719 : : err_adapter_init:
2720 : : return ret;
2721 : : }
2722 : :
2723 : : static uint16_t
2724 : : cpfl_vport_idx_alloc(struct cpfl_adapter_ext *adapter)
2725 : : {
2726 : : uint16_t vport_idx;
2727 : : uint16_t i;
2728 : :
2729 [ # # ]: 0 : for (i = 0; i < adapter->max_vport_nb; i++) {
2730 [ # # ]: 0 : if (adapter->vports[i] == NULL)
2731 : : break;
2732 : : }
2733 : :
2734 [ # # ]: 0 : if (i == adapter->max_vport_nb)
2735 : : vport_idx = CPFL_INVALID_VPORT_IDX;
2736 : : else
2737 : : vport_idx = i;
2738 : :
2739 : : return vport_idx;
2740 : : }
2741 : :
2742 : : static int
2743 : 0 : cpfl_p2p_q_grps_add(struct idpf_vport *vport,
2744 : : struct virtchnl2_add_queue_groups *p2p_queue_grps_info,
2745 : : uint8_t *p2p_q_vc_out_info)
2746 : : {
2747 : : int ret;
2748 : :
2749 : 0 : p2p_queue_grps_info->vport_id = vport->vport_id;
2750 : 0 : p2p_queue_grps_info->num_queue_groups = CPFL_P2P_NB_QUEUE_GRPS;
2751 : 0 : p2p_queue_grps_info->groups[0].num_rx_q = CPFL_MAX_P2P_NB_QUEUES;
2752 : 0 : p2p_queue_grps_info->groups[0].num_rx_bufq = CPFL_P2P_NB_RX_BUFQ;
2753 : 0 : p2p_queue_grps_info->groups[0].num_tx_q = CPFL_MAX_P2P_NB_QUEUES;
2754 : 0 : p2p_queue_grps_info->groups[0].num_tx_complq = CPFL_P2P_NB_TX_COMPLQ;
2755 : 0 : p2p_queue_grps_info->groups[0].qg_id.queue_group_id = CPFL_P2P_QUEUE_GRP_ID;
2756 : 0 : p2p_queue_grps_info->groups[0].qg_id.queue_group_type = VIRTCHNL2_QUEUE_GROUP_P2P;
2757 : 0 : p2p_queue_grps_info->groups[0].rx_q_grp_info.rss_lut_size = 0;
2758 : 0 : p2p_queue_grps_info->groups[0].tx_q_grp_info.tx_tc = 0;
2759 : 0 : p2p_queue_grps_info->groups[0].tx_q_grp_info.priority = 0;
2760 : 0 : p2p_queue_grps_info->groups[0].tx_q_grp_info.is_sp = 0;
2761 : 0 : p2p_queue_grps_info->groups[0].tx_q_grp_info.pir_weight = 0;
2762 : :
2763 : 0 : ret = idpf_vc_queue_grps_add(vport, p2p_queue_grps_info, p2p_q_vc_out_info);
2764 [ # # ]: 0 : if (ret != 0) {
2765 : 0 : PMD_DRV_LOG(ERR, "Failed to add p2p queue groups.");
2766 : 0 : return ret;
2767 : : }
2768 : :
2769 : : return ret;
2770 : : }
2771 : :
2772 : : static int
2773 : 0 : cpfl_p2p_queue_info_init(struct cpfl_vport *cpfl_vport,
2774 : : struct virtchnl2_add_queue_groups *p2p_q_vc_out_info)
2775 : : {
2776 : 0 : struct p2p_queue_chunks_info *p2p_q_chunks_info = cpfl_vport->p2p_q_chunks_info;
2777 : : struct virtchnl2_queue_reg_chunks *vc_chunks_out;
2778 : : int i, type;
2779 : :
2780 [ # # ]: 0 : if (p2p_q_vc_out_info->groups[0].qg_id.queue_group_type !=
2781 : : VIRTCHNL2_QUEUE_GROUP_P2P) {
2782 : 0 : PMD_DRV_LOG(ERR, "Add queue group response mismatch.");
2783 : 0 : return -EINVAL;
2784 : : }
2785 : :
2786 : : vc_chunks_out = &p2p_q_vc_out_info->groups[0].chunks;
2787 : :
2788 [ # # ]: 0 : for (i = 0; i < vc_chunks_out->num_chunks; i++) {
2789 : 0 : type = vc_chunks_out->chunks[i].type;
2790 [ # # # # : 0 : switch (type) {
# ]
2791 : 0 : case VIRTCHNL2_QUEUE_TYPE_TX:
2792 : 0 : p2p_q_chunks_info->tx_start_qid =
2793 : 0 : vc_chunks_out->chunks[i].start_queue_id;
2794 : 0 : p2p_q_chunks_info->tx_qtail_start =
2795 : 0 : vc_chunks_out->chunks[i].qtail_reg_start;
2796 : 0 : p2p_q_chunks_info->tx_qtail_spacing =
2797 : 0 : vc_chunks_out->chunks[i].qtail_reg_spacing;
2798 : 0 : break;
2799 : 0 : case VIRTCHNL2_QUEUE_TYPE_RX:
2800 : 0 : p2p_q_chunks_info->rx_start_qid =
2801 : 0 : vc_chunks_out->chunks[i].start_queue_id;
2802 : 0 : p2p_q_chunks_info->rx_qtail_start =
2803 : 0 : vc_chunks_out->chunks[i].qtail_reg_start;
2804 : 0 : p2p_q_chunks_info->rx_qtail_spacing =
2805 : 0 : vc_chunks_out->chunks[i].qtail_reg_spacing;
2806 : 0 : break;
2807 : 0 : case VIRTCHNL2_QUEUE_TYPE_TX_COMPLETION:
2808 : 0 : p2p_q_chunks_info->tx_compl_start_qid =
2809 : 0 : vc_chunks_out->chunks[i].start_queue_id;
2810 : 0 : p2p_q_chunks_info->tx_compl_qtail_start =
2811 : 0 : vc_chunks_out->chunks[i].qtail_reg_start;
2812 : 0 : p2p_q_chunks_info->tx_compl_qtail_spacing =
2813 : 0 : vc_chunks_out->chunks[i].qtail_reg_spacing;
2814 : 0 : break;
2815 : 0 : case VIRTCHNL2_QUEUE_TYPE_RX_BUFFER:
2816 : 0 : p2p_q_chunks_info->rx_buf_start_qid =
2817 : 0 : vc_chunks_out->chunks[i].start_queue_id;
2818 : 0 : p2p_q_chunks_info->rx_buf_qtail_start =
2819 : 0 : vc_chunks_out->chunks[i].qtail_reg_start;
2820 : 0 : p2p_q_chunks_info->rx_buf_qtail_spacing =
2821 : 0 : vc_chunks_out->chunks[i].qtail_reg_spacing;
2822 : 0 : break;
2823 : 0 : default:
2824 : 0 : PMD_DRV_LOG(ERR, "Unsupported queue type");
2825 : 0 : break;
2826 : : }
2827 : : }
2828 : :
2829 : : return 0;
2830 : : }
2831 : :
2832 : : int
2833 : 0 : cpfl_alloc_dma_mem_batch(struct idpf_dma_mem *orig_dma, struct idpf_dma_mem *dma, uint32_t size,
2834 : : int batch_size)
2835 : : {
2836 : : int i;
2837 : :
2838 [ # # ]: 0 : if (!idpf_alloc_dma_mem(NULL, orig_dma, (uint64_t)size * (1 + batch_size))) {
2839 : 0 : PMD_INIT_LOG(ERR, "Could not alloc dma memory");
2840 : 0 : return -ENOMEM;
2841 : : }
2842 : :
2843 [ # # ]: 0 : for (i = 0; i < batch_size; i++) {
2844 : 0 : dma[i].va = (void *)((char *)orig_dma->va + size * (i + 1));
2845 : 0 : dma[i].pa = orig_dma->pa + size * (i + 1);
2846 : 0 : dma[i].size = size;
2847 : 0 : dma[i].zone = NULL;
2848 : : }
2849 : : return 0;
2850 : : }
2851 : :
2852 : : static int
2853 : 0 : cpfl_dev_vport_init(struct rte_eth_dev *dev, void *init_params)
2854 : : {
2855 : 0 : struct cpfl_vport *cpfl_vport = dev->data->dev_private;
2856 : 0 : struct idpf_vport *vport = &cpfl_vport->base;
2857 : : struct cpfl_vport_param *param = init_params;
2858 : 0 : struct cpfl_adapter_ext *adapter = param->adapter;
2859 : : /* for sending create vport virtchnl msg prepare */
2860 : : struct virtchnl2_create_vport create_vport_info;
2861 : : struct virtchnl2_add_queue_groups p2p_queue_grps_info;
2862 : : struct cpchnl2_get_vport_info_response response;
2863 : 0 : uint8_t p2p_q_vc_out_info[IDPF_DFLT_MBX_BUF_SIZE] = {0};
2864 : : struct cpfl_vport_id vi;
2865 : : struct cpchnl2_vport_id v_id;
2866 : : struct rte_pci_device *pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2867 : : int ret = 0;
2868 : :
2869 : 0 : dev->dev_ops = &cpfl_eth_dev_ops;
2870 : 0 : vport->adapter = &adapter->base;
2871 : 0 : vport->sw_idx = param->idx;
2872 : 0 : vport->devarg_id = param->devarg_id;
2873 : :
2874 : : memset(&create_vport_info, 0, sizeof(create_vport_info));
2875 : 0 : ret = idpf_vport_info_init(vport, &create_vport_info);
2876 [ # # ]: 0 : if (ret != 0) {
2877 : 0 : PMD_INIT_LOG(ERR, "Failed to init vport req_info.");
2878 : 0 : goto err;
2879 : : }
2880 : :
2881 : 0 : ret = idpf_vport_init(vport, &create_vport_info, dev->data);
2882 [ # # ]: 0 : if (ret != 0) {
2883 : 0 : PMD_INIT_LOG(ERR, "Failed to init vports.");
2884 : 0 : goto err;
2885 : : }
2886 : :
2887 : 0 : cpfl_vport->itf.type = CPFL_ITF_TYPE_VPORT;
2888 : 0 : cpfl_vport->itf.adapter = adapter;
2889 : 0 : cpfl_vport->itf.data = dev->data;
2890 : 0 : TAILQ_INIT(&cpfl_vport->itf.flow_list);
2891 : 0 : adapter->vports[param->idx] = cpfl_vport;
2892 : 0 : adapter->cur_vports |= RTE_BIT32(param->devarg_id);
2893 : 0 : adapter->cur_vport_nb++;
2894 : :
2895 : 0 : dev->data->mac_addrs = rte_zmalloc(NULL, RTE_ETHER_ADDR_LEN, 0);
2896 [ # # ]: 0 : if (dev->data->mac_addrs == NULL) {
2897 : 0 : PMD_INIT_LOG(ERR, "Cannot allocate mac_addr memory.");
2898 : : ret = -ENOMEM;
2899 : 0 : goto err_mac_addrs;
2900 : : }
2901 : :
2902 : : rte_ether_addr_copy((struct rte_ether_addr *)vport->default_mac_addr,
2903 : : &dev->data->mac_addrs[0]);
2904 : :
2905 : 0 : memset(cpfl_vport->itf.dma, 0, sizeof(cpfl_vport->itf.dma));
2906 : 0 : memset(cpfl_vport->itf.msg, 0, sizeof(cpfl_vport->itf.msg));
2907 : 0 : ret = cpfl_alloc_dma_mem_batch(&cpfl_vport->itf.flow_dma,
2908 : : cpfl_vport->itf.dma,
2909 : : sizeof(union cpfl_rule_cfg_pkt_record),
2910 : : CPFL_FLOW_BATCH_SIZE);
2911 [ # # ]: 0 : if (ret < 0)
2912 : 0 : goto err_mac_addrs;
2913 : :
2914 [ # # # # ]: 0 : if (!adapter->base.is_rx_singleq && !adapter->base.is_tx_singleq) {
2915 : : memset(&p2p_queue_grps_info, 0, sizeof(p2p_queue_grps_info));
2916 : 0 : ret = cpfl_p2p_q_grps_add(vport, &p2p_queue_grps_info, p2p_q_vc_out_info);
2917 [ # # ]: 0 : if (ret != 0) {
2918 : 0 : PMD_INIT_LOG(WARNING, "Failed to add p2p queue group.");
2919 : 0 : return 0;
2920 : : }
2921 : 0 : cpfl_vport->p2p_q_chunks_info = rte_zmalloc(NULL,
2922 : : sizeof(struct p2p_queue_chunks_info), 0);
2923 [ # # ]: 0 : if (cpfl_vport->p2p_q_chunks_info == NULL) {
2924 : 0 : PMD_INIT_LOG(WARNING, "Failed to allocate p2p queue info.");
2925 : 0 : cpfl_p2p_queue_grps_del(vport);
2926 : 0 : return 0;
2927 : : }
2928 : 0 : ret = cpfl_p2p_queue_info_init(cpfl_vport,
2929 : : (struct virtchnl2_add_queue_groups *)p2p_q_vc_out_info);
2930 [ # # ]: 0 : if (ret != 0) {
2931 : 0 : PMD_INIT_LOG(WARNING, "Failed to init p2p queue info.");
2932 : 0 : rte_free(cpfl_vport->p2p_q_chunks_info);
2933 : 0 : cpfl_p2p_queue_grps_del(vport);
2934 : : }
2935 : : }
2936 : : /* get the vport info */
2937 [ # # ]: 0 : if (idpf_is_vf_device(&adapter->base.hw)) {
2938 : 0 : pci_dev = RTE_CLASS_TO_BUS_DEVICE(dev, *pci_dev);
2939 : 0 : vi.func_type = VCPF_CPCHNL2_FTYPE_LAN_VF;
2940 : 0 : vi.pf_id = CPFL_HOST0_CPF_ID;
2941 : 0 : vi.vf_id = VCPF_VF_ID_FROM_PCI(pci_dev->addr.devid,
2942 : : pci_dev->addr.function);
2943 : :
2944 : 0 : v_id.vport_id = cpfl_vport->base.vport_info.info.vport_id;
2945 : 0 : v_id.vport_type = cpfl_vport->base.vport_info.info.vport_type;
2946 : :
2947 : 0 : ret = cpfl_cc_vport_info_get(adapter, &v_id, &vi, &response);
2948 [ # # ]: 0 : if (ret != 0) {
2949 : 0 : PMD_INIT_LOG(ERR, "Failed to send vport info cpchnl message.");
2950 : 0 : return -1;
2951 : : }
2952 : :
2953 : 0 : ret = vcpf_save_vport_info_response(cpfl_vport, &response);
2954 [ # # ]: 0 : if (ret != 0) {
2955 : 0 : PMD_INIT_LOG(ERR, "Failed to save cpchnl response.");
2956 : 0 : return -1;
2957 : : }
2958 : : }
2959 : :
2960 : : return 0;
2961 : :
2962 : 0 : err_mac_addrs:
2963 : 0 : adapter->vports[param->idx] = NULL; /* reset */
2964 : 0 : idpf_vport_deinit(vport);
2965 : 0 : adapter->cur_vports &= ~RTE_BIT32(param->devarg_id);
2966 : 0 : adapter->cur_vport_nb--;
2967 : : err:
2968 : : return ret;
2969 : : }
2970 : :
2971 : : static const struct rte_pci_id pci_id_cpfl_map[] = {
2972 : : { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, CPFL_DEV_ID_MEV) },
2973 : : { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, CPFL_DEV_ID_MMG) },
2974 : : { .vendor_id = 0, /* sentinel */ },
2975 : : };
2976 : :
2977 : : static const struct rte_pci_id pci_id_vcpf_map[] = {
2978 : : { RTE_PCI_DEVICE(IDPF_INTEL_VENDOR_ID, IXD_DEV_ID_VCPF) },
2979 : : { .vendor_id = 0, /* sentinel */ },
2980 : : };
2981 : :
2982 : : static struct cpfl_adapter_ext *
2983 : 0 : cpfl_find_adapter_ext(struct rte_pci_device *pci_dev)
2984 : : {
2985 : : struct cpfl_adapter_ext *adapter;
2986 : : int found = 0;
2987 : :
2988 [ # # ]: 0 : if (pci_dev == NULL)
2989 : : return NULL;
2990 : :
2991 : : rte_spinlock_lock(&cpfl_adapter_lock);
2992 [ # # ]: 0 : TAILQ_FOREACH(adapter, &cpfl_adapter_list, next) {
2993 [ # # ]: 0 : if (strncmp(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE) == 0) {
2994 : : found = 1;
2995 : : break;
2996 : : }
2997 : : }
2998 : : rte_spinlock_unlock(&cpfl_adapter_lock);
2999 : :
3000 [ # # ]: 0 : if (found == 0)
3001 : 0 : return NULL;
3002 : :
3003 : : return adapter;
3004 : : }
3005 : :
3006 : : static void
3007 : 0 : cpfl_adapter_ext_deinit(struct cpfl_adapter_ext *adapter)
3008 : : {
3009 : : #ifdef RTE_HAS_JANSSON
3010 : 0 : cpfl_flow_uninit(adapter);
3011 : : #endif
3012 : 0 : cpfl_ctrl_path_close(adapter);
3013 : 0 : rte_eal_alarm_cancel(cpfl_dev_alarm_handler, adapter);
3014 : 0 : cpfl_vport_map_uninit(adapter);
3015 : 0 : idpf_adapter_deinit(&adapter->base);
3016 : :
3017 : 0 : rte_free(adapter->vports);
3018 : 0 : adapter->vports = NULL;
3019 : 0 : }
3020 : :
3021 : : static int
3022 : 0 : cpfl_vport_devargs_process(struct cpfl_adapter_ext *adapter, struct cpfl_devargs *devargs)
3023 : : {
3024 : : int i;
3025 : :
3026 : : /* refine vport number, at least 1 vport */
3027 [ # # ]: 0 : if (devargs->req_vport_nb == 0) {
3028 : 0 : devargs->req_vport_nb = 1;
3029 : 0 : devargs->req_vports[0] = 0;
3030 : : }
3031 : :
3032 : : /* check parsed devargs */
3033 : 0 : if (adapter->cur_vport_nb + devargs->req_vport_nb >
3034 [ # # ]: 0 : adapter->max_vport_nb) {
3035 : 0 : PMD_INIT_LOG(ERR, "Total vport number can't be > %d",
3036 : : adapter->max_vport_nb);
3037 : 0 : return -EINVAL;
3038 : : }
3039 : :
3040 [ # # ]: 0 : for (i = 0; i < devargs->req_vport_nb; i++) {
3041 [ # # ]: 0 : if (devargs->req_vports[i] > adapter->max_vport_nb - 1) {
3042 : 0 : PMD_INIT_LOG(ERR, "Invalid vport id %d, it should be 0 ~ %d",
3043 : : devargs->req_vports[i], adapter->max_vport_nb - 1);
3044 : 0 : return -EINVAL;
3045 : : }
3046 : :
3047 [ # # ]: 0 : if (adapter->cur_vports & RTE_BIT32(devargs->req_vports[i])) {
3048 : 0 : PMD_INIT_LOG(ERR, "Vport %d has been requested",
3049 : : devargs->req_vports[i]);
3050 : 0 : return -EINVAL;
3051 : : }
3052 : : }
3053 : :
3054 : : return 0;
3055 : : }
3056 : :
3057 : : static int
3058 : 0 : cpfl_vport_create(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter,
3059 : : struct cpfl_devargs *devargs)
3060 : : {
3061 : : struct cpfl_vport_param vport_param;
3062 : : char name[RTE_ETH_NAME_MAX_LEN];
3063 : : int ret, i;
3064 : :
3065 [ # # ]: 0 : for (i = 0; i < devargs->req_vport_nb; i++) {
3066 : 0 : vport_param.adapter = adapter;
3067 : 0 : vport_param.devarg_id = devargs->req_vports[i];
3068 : 0 : vport_param.idx = cpfl_vport_idx_alloc(adapter);
3069 [ # # ]: 0 : if (vport_param.idx == CPFL_INVALID_VPORT_IDX) {
3070 : 0 : PMD_INIT_LOG(ERR, "No space for vport %u", vport_param.devarg_id);
3071 : 0 : break;
3072 : : }
3073 : 0 : snprintf(name, sizeof(name), "net_%s_vport_%d",
3074 : : pci_dev->device.name,
3075 : : devargs->req_vports[i]);
3076 : 0 : ret = rte_eth_dev_create(&pci_dev->device, name,
3077 : : sizeof(struct cpfl_vport),
3078 : : NULL, NULL, cpfl_dev_vport_init,
3079 : : &vport_param);
3080 [ # # ]: 0 : if (ret != 0)
3081 : 0 : PMD_DRV_LOG(ERR, "Failed to create vport %d",
3082 : : vport_param.devarg_id);
3083 : : }
3084 : :
3085 : 0 : return 0;
3086 : : }
3087 : :
3088 : : static int
3089 : 0 : cpfl_pci_probe_first(struct rte_pci_device *pci_dev)
3090 : : {
3091 : : struct cpfl_adapter_ext *adapter;
3092 : : struct cpfl_devargs devargs;
3093 : : int retval;
3094 : : uint16_t port_id;
3095 : :
3096 : 0 : adapter = rte_zmalloc("cpfl_adapter_ext",
3097 : : sizeof(struct cpfl_adapter_ext), 0);
3098 [ # # ]: 0 : if (adapter == NULL) {
3099 : 0 : PMD_INIT_LOG(ERR, "Failed to allocate adapter.");
3100 : 0 : return -ENOMEM;
3101 : : }
3102 : :
3103 : : memset(&devargs, 0, sizeof(devargs));
3104 : :
3105 : 0 : retval = cpfl_parse_devargs(pci_dev, adapter, true, &devargs);
3106 [ # # ]: 0 : if (retval != 0) {
3107 : 0 : PMD_INIT_LOG(ERR, "Failed to parse private devargs");
3108 : 0 : return retval;
3109 : : }
3110 : :
3111 : 0 : retval = cpfl_adapter_ext_init(pci_dev, adapter, &devargs);
3112 [ # # ]: 0 : if (retval != 0) {
3113 : 0 : PMD_INIT_LOG(ERR, "Failed to init adapter.");
3114 : 0 : return retval;
3115 : : }
3116 : :
3117 : : rte_spinlock_lock(&cpfl_adapter_lock);
3118 : 0 : TAILQ_INSERT_TAIL(&cpfl_adapter_list, adapter, next);
3119 : : rte_spinlock_unlock(&cpfl_adapter_lock);
3120 : :
3121 : 0 : retval = cpfl_vport_devargs_process(adapter, &devargs);
3122 [ # # ]: 0 : if (retval != 0) {
3123 : 0 : PMD_INIT_LOG(ERR, "Failed to process vport devargs");
3124 : 0 : goto err;
3125 : : }
3126 : :
3127 : 0 : retval = cpfl_vport_create(pci_dev, adapter, &devargs);
3128 [ # # ]: 0 : if (retval != 0) {
3129 : 0 : PMD_INIT_LOG(ERR, "Failed to create vports.");
3130 : 0 : goto err;
3131 : : }
3132 : :
3133 : 0 : retval = cpfl_repr_devargs_process(adapter, &devargs);
3134 [ # # ]: 0 : if (retval != 0) {
3135 : 0 : PMD_INIT_LOG(ERR, "Failed to process repr devargs");
3136 : 0 : goto close_ethdev;
3137 : : }
3138 : :
3139 : 0 : retval = cpfl_repr_create(pci_dev, adapter);
3140 [ # # ]: 0 : if (retval != 0) {
3141 : 0 : PMD_INIT_LOG(ERR, "Failed to create representors ");
3142 : 0 : goto close_ethdev;
3143 : : }
3144 : :
3145 : :
3146 : : return 0;
3147 : :
3148 : 0 : close_ethdev:
3149 : : /* Ethdev created can be found RTE_ETH_FOREACH_DEV_OF through rte_device */
3150 [ # # ]: 0 : RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) {
3151 : 0 : rte_eth_dev_close(port_id);
3152 : : }
3153 : 0 : err:
3154 : : rte_spinlock_lock(&cpfl_adapter_lock);
3155 [ # # ]: 0 : TAILQ_REMOVE(&cpfl_adapter_list, adapter, next);
3156 : : rte_spinlock_unlock(&cpfl_adapter_lock);
3157 : 0 : cpfl_adapter_ext_deinit(adapter);
3158 : 0 : rte_free(adapter);
3159 : 0 : return retval;
3160 : : }
3161 : :
3162 : : static int
3163 : 0 : cpfl_pci_probe_again(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter)
3164 : : {
3165 : : struct cpfl_devargs devargs;
3166 : : int ret;
3167 : :
3168 : : memset(&devargs, 0, sizeof(devargs));
3169 : 0 : ret = cpfl_parse_devargs(pci_dev, adapter, false, &devargs);
3170 [ # # ]: 0 : if (ret != 0) {
3171 : 0 : PMD_INIT_LOG(ERR, "Failed to parse private devargs");
3172 : 0 : return ret;
3173 : : }
3174 : :
3175 : 0 : ret = cpfl_repr_devargs_process(adapter, &devargs);
3176 [ # # ]: 0 : if (ret != 0) {
3177 : 0 : PMD_INIT_LOG(ERR, "Failed to process reprenstor devargs");
3178 : 0 : return ret;
3179 : : }
3180 : :
3181 : 0 : ret = cpfl_repr_create(pci_dev, adapter);
3182 [ # # ]: 0 : if (ret != 0) {
3183 : 0 : PMD_INIT_LOG(ERR, "Failed to create representors ");
3184 : 0 : return ret;
3185 : : }
3186 : :
3187 : : return 0;
3188 : : }
3189 : :
3190 : : static int
3191 : 0 : cpfl_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
3192 : : struct rte_pci_device *pci_dev)
3193 : : {
3194 : : struct cpfl_adapter_ext *adapter;
3195 : :
3196 [ # # ]: 0 : if (!cpfl_adapter_list_init) {
3197 : : rte_spinlock_init(&cpfl_adapter_lock);
3198 : 0 : TAILQ_INIT(&cpfl_adapter_list);
3199 : 0 : cpfl_adapter_list_init = true;
3200 : : }
3201 : :
3202 : 0 : adapter = cpfl_find_adapter_ext(pci_dev);
3203 : :
3204 [ # # ]: 0 : if (adapter == NULL)
3205 : 0 : return cpfl_pci_probe_first(pci_dev);
3206 : : else
3207 : 0 : return cpfl_pci_probe_again(pci_dev, adapter);
3208 : : }
3209 : :
3210 : : static int
3211 : 0 : cpfl_pci_remove(struct rte_pci_device *pci_dev)
3212 : : {
3213 : 0 : struct cpfl_adapter_ext *adapter = cpfl_find_adapter_ext(pci_dev);
3214 : : uint16_t port_id;
3215 : :
3216 : : /* Ethdev created can be found RTE_ETH_FOREACH_DEV_OF through rte_device */
3217 [ # # ]: 0 : RTE_ETH_FOREACH_DEV_OF(port_id, &pci_dev->device) {
3218 : 0 : rte_eth_dev_close(port_id);
3219 : : }
3220 : :
3221 : : rte_spinlock_lock(&cpfl_adapter_lock);
3222 [ # # ]: 0 : TAILQ_REMOVE(&cpfl_adapter_list, adapter, next);
3223 : : rte_spinlock_unlock(&cpfl_adapter_lock);
3224 : 0 : cpfl_adapter_ext_deinit(adapter);
3225 : 0 : rte_free(adapter);
3226 : :
3227 : 0 : return 0;
3228 : : }
3229 : :
3230 : : static struct rte_pci_driver rte_cpfl_pmd = {
3231 : : .id_table = pci_id_cpfl_map,
3232 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING |
3233 : : RTE_PCI_DRV_PROBE_AGAIN,
3234 : : .probe = cpfl_pci_probe,
3235 : : .remove = cpfl_pci_remove,
3236 : : };
3237 : :
3238 : : static struct rte_pci_driver rte_vcpf_pmd = {
3239 : : .id_table = pci_id_vcpf_map,
3240 : : .drv_flags = RTE_PCI_DRV_NEED_MAPPING |
3241 : : RTE_PCI_DRV_PROBE_AGAIN,
3242 : : .probe = cpfl_pci_probe,
3243 : : .remove = cpfl_pci_remove,
3244 : : };
3245 : :
3246 : : /**
3247 : : * Driver initialization routine.
3248 : : * Invoked once at EAL init time.
3249 : : * Register itself as the [Poll Mode] Driver of PCI devices.
3250 : : */
3251 : 306 : RTE_PMD_REGISTER_PCI(net_cpfl, rte_cpfl_pmd);
3252 : : RTE_PMD_REGISTER_PCI_TABLE(net_cpfl, pci_id_cpfl_map);
3253 : : RTE_PMD_REGISTER_KMOD_DEP(net_cpfl, "* igb_uio | vfio-pci");
3254 : 306 : RTE_PMD_REGISTER_PCI(net_vcpf, rte_vcpf_pmd);
3255 : : RTE_PMD_REGISTER_PCI_TABLE(net_vcpf, pci_id_vcpf_map);
3256 : : RTE_PMD_REGISTER_KMOD_DEP(net_vcpf, "vfio-pci");
3257 : : RTE_PMD_REGISTER_PARAM_STRING(net_cpfl,
3258 : : CPFL_TX_SINGLE_Q "=<0|1> "
3259 : : CPFL_RX_SINGLE_Q "=<0|1> "
3260 : : CPFL_VPORT "=[vport0_begin[-vport0_end][,vport1_begin[-vport1_end]][,..]]");
3261 : :
3262 [ - + ]: 306 : RTE_LOG_REGISTER_SUFFIX(cpfl_logtype_init, init, NOTICE);
3263 [ - + ]: 306 : RTE_LOG_REGISTER_SUFFIX(cpfl_logtype_driver, driver, NOTICE);
|