1 /* * SPDX-License-Identifier: BSD-3-Clause
3 * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
4 * Copyright 2016-2021 NXP
12 #include <ethdev_driver.h>
13 #include <rte_malloc.h>
14 #include <rte_memcpy.h>
15 #include <rte_string_fns.h>
16 #include <rte_cycles.h>
17 #include <rte_kvargs.h>
19 #include <rte_fslmc.h>
20 #include <rte_flow_driver.h>
22 #include "dpaa2_pmd_logs.h"
23 #include <fslmc_vfio.h>
24 #include <dpaa2_hw_pvt.h>
25 #include <dpaa2_hw_mempool.h>
26 #include <dpaa2_hw_dpio.h>
27 #include <mc/fsl_dpmng.h>
28 #include "dpaa2_ethdev.h"
29 #include "dpaa2_sparser.h"
30 #include <fsl_qbman_debug.h>
32 #define DRIVER_LOOPBACK_MODE "drv_loopback"
33 #define DRIVER_NO_PREFETCH_MODE "drv_no_prefetch"
34 #define DRIVER_TX_CONF "drv_tx_conf"
35 #define DRIVER_ERROR_QUEUE "drv_err_queue"
36 #define CHECK_INTERVAL 100 /* 100ms */
37 #define MAX_REPEAT_TIME 90 /* 9s (90 * 100ms) in total */
39 /* Supported Rx offloads */
40 static uint64_t dev_rx_offloads_sup =
41 RTE_ETH_RX_OFFLOAD_CHECKSUM |
42 RTE_ETH_RX_OFFLOAD_SCTP_CKSUM |
43 RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM |
44 RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM |
45 RTE_ETH_RX_OFFLOAD_VLAN_STRIP |
46 RTE_ETH_RX_OFFLOAD_VLAN_FILTER |
47 RTE_ETH_RX_OFFLOAD_TIMESTAMP;
49 /* Rx offloads which cannot be disabled */
50 static uint64_t dev_rx_offloads_nodis =
51 RTE_ETH_RX_OFFLOAD_RSS_HASH |
52 RTE_ETH_RX_OFFLOAD_SCATTER;
54 /* Supported Tx offloads */
55 static uint64_t dev_tx_offloads_sup =
56 RTE_ETH_TX_OFFLOAD_VLAN_INSERT |
57 RTE_ETH_TX_OFFLOAD_IPV4_CKSUM |
58 RTE_ETH_TX_OFFLOAD_UDP_CKSUM |
59 RTE_ETH_TX_OFFLOAD_TCP_CKSUM |
60 RTE_ETH_TX_OFFLOAD_SCTP_CKSUM |
61 RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM |
62 RTE_ETH_TX_OFFLOAD_MT_LOCKFREE |
63 RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE;
65 /* Tx offloads which cannot be disabled */
66 static uint64_t dev_tx_offloads_nodis =
67 RTE_ETH_TX_OFFLOAD_MULTI_SEGS;
69 /* enable timestamp in mbuf */
70 bool dpaa2_enable_ts[RTE_MAX_ETHPORTS];
71 uint64_t dpaa2_timestamp_rx_dynflag;
72 int dpaa2_timestamp_dynfield_offset = -1;
74 /* Enable error queue */
75 bool dpaa2_enable_err_queue;
77 #define MAX_NB_RX_DESC 11264
80 struct rte_dpaa2_xstats_name_off {
81 char name[RTE_ETH_XSTATS_NAME_SIZE];
82 uint8_t page_id; /* dpni statistics page id */
83 uint8_t stats_id; /* stats id in the given page */
86 static const struct rte_dpaa2_xstats_name_off dpaa2_xstats_strings[] = {
87 {"ingress_multicast_frames", 0, 2},
88 {"ingress_multicast_bytes", 0, 3},
89 {"ingress_broadcast_frames", 0, 4},
90 {"ingress_broadcast_bytes", 0, 5},
91 {"egress_multicast_frames", 1, 2},
92 {"egress_multicast_bytes", 1, 3},
93 {"egress_broadcast_frames", 1, 4},
94 {"egress_broadcast_bytes", 1, 5},
95 {"ingress_filtered_frames", 2, 0},
96 {"ingress_discarded_frames", 2, 1},
97 {"ingress_nobuffer_discards", 2, 2},
98 {"egress_discarded_frames", 2, 3},
99 {"egress_confirmed_frames", 2, 4},
100 {"cgr_reject_frames", 4, 0},
101 {"cgr_reject_bytes", 4, 1},
104 static struct rte_dpaa2_driver rte_dpaa2_pmd;
105 static int dpaa2_dev_link_update(struct rte_eth_dev *dev,
106 int wait_to_complete);
107 static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev);
108 static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev);
109 static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
112 dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
115 struct dpaa2_dev_priv *priv = dev->data->dev_private;
116 struct fsl_mc_io *dpni = dev->process_private;
118 PMD_INIT_FUNC_TRACE();
121 DPAA2_PMD_ERR("dpni is NULL");
126 ret = dpni_add_vlan_id(dpni, CMD_PRI_LOW, priv->token,
129 ret = dpni_remove_vlan_id(dpni, CMD_PRI_LOW,
130 priv->token, vlan_id);
133 DPAA2_PMD_ERR("ret = %d Unable to add/rem vlan %d hwid =%d",
134 ret, vlan_id, priv->hw_id);
140 dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask)
142 struct dpaa2_dev_priv *priv = dev->data->dev_private;
143 struct fsl_mc_io *dpni = dev->process_private;
146 PMD_INIT_FUNC_TRACE();
148 if (mask & RTE_ETH_VLAN_FILTER_MASK) {
149 /* VLAN Filter not available */
150 if (!priv->max_vlan_filters) {
151 DPAA2_PMD_INFO("VLAN filter not available");
155 if (dev->data->dev_conf.rxmode.offloads &
156 RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
157 ret = dpni_enable_vlan_filter(dpni, CMD_PRI_LOW,
160 ret = dpni_enable_vlan_filter(dpni, CMD_PRI_LOW,
163 DPAA2_PMD_INFO("Unable to set vlan filter = %d", ret);
170 dpaa2_vlan_tpid_set(struct rte_eth_dev *dev,
171 enum rte_vlan_type vlan_type __rte_unused,
174 struct dpaa2_dev_priv *priv = dev->data->dev_private;
175 struct fsl_mc_io *dpni = dev->process_private;
178 PMD_INIT_FUNC_TRACE();
180 /* nothing to be done for standard vlan tpids */
181 if (tpid == 0x8100 || tpid == 0x88A8)
184 ret = dpni_add_custom_tpid(dpni, CMD_PRI_LOW,
187 DPAA2_PMD_INFO("Unable to set vlan tpid = %d", ret);
188 /* if already configured tpids, remove them first */
190 struct dpni_custom_tpid_cfg tpid_list = {0};
192 ret = dpni_get_custom_tpid(dpni, CMD_PRI_LOW,
193 priv->token, &tpid_list);
196 ret = dpni_remove_custom_tpid(dpni, CMD_PRI_LOW,
197 priv->token, tpid_list.tpid1);
200 ret = dpni_add_custom_tpid(dpni, CMD_PRI_LOW,
208 dpaa2_fw_version_get(struct rte_eth_dev *dev,
213 struct fsl_mc_io *dpni = dev->process_private;
214 struct mc_soc_version mc_plat_info = {0};
215 struct mc_version mc_ver_info = {0};
217 PMD_INIT_FUNC_TRACE();
219 if (mc_get_soc_version(dpni, CMD_PRI_LOW, &mc_plat_info))
220 DPAA2_PMD_WARN("\tmc_get_soc_version failed");
222 if (mc_get_version(dpni, CMD_PRI_LOW, &mc_ver_info))
223 DPAA2_PMD_WARN("\tmc_get_version failed");
225 ret = snprintf(fw_version, fw_size,
230 mc_ver_info.revision);
234 ret += 1; /* add the size of '\0' */
235 if (fw_size < (size_t)ret)
242 dpaa2_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
244 struct dpaa2_dev_priv *priv = dev->data->dev_private;
246 PMD_INIT_FUNC_TRACE();
248 dev_info->max_mac_addrs = priv->max_mac_filters;
249 dev_info->max_rx_pktlen = DPAA2_MAX_RX_PKT_LEN;
250 dev_info->min_rx_bufsize = DPAA2_MIN_RX_BUF_SIZE;
251 dev_info->max_rx_queues = (uint16_t)priv->nb_rx_queues;
252 dev_info->max_tx_queues = (uint16_t)priv->nb_tx_queues;
253 dev_info->rx_offload_capa = dev_rx_offloads_sup |
254 dev_rx_offloads_nodis;
255 dev_info->tx_offload_capa = dev_tx_offloads_sup |
256 dev_tx_offloads_nodis;
257 dev_info->speed_capa = RTE_ETH_LINK_SPEED_1G |
258 RTE_ETH_LINK_SPEED_2_5G |
259 RTE_ETH_LINK_SPEED_10G;
260 dev_info->dev_capa &= ~RTE_ETH_DEV_CAPA_FLOW_RULE_KEEP;
262 dev_info->max_hash_mac_addrs = 0;
263 dev_info->max_vfs = 0;
264 dev_info->max_vmdq_pools = RTE_ETH_16_POOLS;
265 dev_info->flow_type_rss_offloads = DPAA2_RSS_OFFLOAD_ALL;
267 dev_info->default_rxportconf.burst_size = dpaa2_dqrr_size;
268 /* same is rx size for best perf */
269 dev_info->default_txportconf.burst_size = dpaa2_dqrr_size;
271 dev_info->default_rxportconf.nb_queues = 1;
272 dev_info->default_txportconf.nb_queues = 1;
273 dev_info->default_txportconf.ring_size = CONG_ENTER_TX_THRESHOLD;
274 dev_info->default_rxportconf.ring_size = DPAA2_RX_DEFAULT_NBDESC;
276 if (dpaa2_svr_family == SVR_LX2160A) {
277 dev_info->speed_capa |= RTE_ETH_LINK_SPEED_25G |
278 RTE_ETH_LINK_SPEED_40G |
279 RTE_ETH_LINK_SPEED_50G |
280 RTE_ETH_LINK_SPEED_100G;
287 dpaa2_dev_rx_burst_mode_get(struct rte_eth_dev *dev,
288 __rte_unused uint16_t queue_id,
289 struct rte_eth_burst_mode *mode)
291 struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
294 const struct burst_info {
297 } rx_offload_map[] = {
298 {RTE_ETH_RX_OFFLOAD_CHECKSUM, " Checksum,"},
299 {RTE_ETH_RX_OFFLOAD_SCTP_CKSUM, " SCTP csum,"},
300 {RTE_ETH_RX_OFFLOAD_OUTER_IPV4_CKSUM, " Outer IPV4 csum,"},
301 {RTE_ETH_RX_OFFLOAD_OUTER_UDP_CKSUM, " Outer UDP csum,"},
302 {RTE_ETH_RX_OFFLOAD_VLAN_STRIP, " VLAN strip,"},
303 {RTE_ETH_RX_OFFLOAD_VLAN_FILTER, " VLAN filter,"},
304 {RTE_ETH_RX_OFFLOAD_TIMESTAMP, " Timestamp,"},
305 {RTE_ETH_RX_OFFLOAD_RSS_HASH, " RSS,"},
306 {RTE_ETH_RX_OFFLOAD_SCATTER, " Scattered,"}
309 /* Update Rx offload info */
310 for (i = 0; i < RTE_DIM(rx_offload_map); i++) {
311 if (eth_conf->rxmode.offloads & rx_offload_map[i].flags) {
312 snprintf(mode->info, sizeof(mode->info), "%s",
313 rx_offload_map[i].output);
322 dpaa2_dev_tx_burst_mode_get(struct rte_eth_dev *dev,
323 __rte_unused uint16_t queue_id,
324 struct rte_eth_burst_mode *mode)
326 struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
329 const struct burst_info {
332 } tx_offload_map[] = {
333 {RTE_ETH_TX_OFFLOAD_VLAN_INSERT, " VLAN Insert,"},
334 {RTE_ETH_TX_OFFLOAD_IPV4_CKSUM, " IPV4 csum,"},
335 {RTE_ETH_TX_OFFLOAD_UDP_CKSUM, " UDP csum,"},
336 {RTE_ETH_TX_OFFLOAD_TCP_CKSUM, " TCP csum,"},
337 {RTE_ETH_TX_OFFLOAD_SCTP_CKSUM, " SCTP csum,"},
338 {RTE_ETH_TX_OFFLOAD_OUTER_IPV4_CKSUM, " Outer IPV4 csum,"},
339 {RTE_ETH_TX_OFFLOAD_MT_LOCKFREE, " MT lockfree,"},
340 {RTE_ETH_TX_OFFLOAD_MBUF_FAST_FREE, " MBUF free disable,"},
341 {RTE_ETH_TX_OFFLOAD_MULTI_SEGS, " Scattered,"}
344 /* Update Tx offload info */
345 for (i = 0; i < RTE_DIM(tx_offload_map); i++) {
346 if (eth_conf->txmode.offloads & tx_offload_map[i].flags) {
347 snprintf(mode->info, sizeof(mode->info), "%s",
348 tx_offload_map[i].output);
357 dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
359 struct dpaa2_dev_priv *priv = dev->data->dev_private;
362 uint8_t num_rxqueue_per_tc;
363 struct dpaa2_queue *mc_q, *mcq;
366 struct dpaa2_queue *dpaa2_q;
368 PMD_INIT_FUNC_TRACE();
370 num_rxqueue_per_tc = (priv->nb_rx_queues / priv->num_rx_tc);
371 if (priv->flags & DPAA2_TX_CONF_ENABLE)
372 tot_queues = priv->nb_rx_queues + 2 * priv->nb_tx_queues;
374 tot_queues = priv->nb_rx_queues + priv->nb_tx_queues;
375 mc_q = rte_malloc(NULL, sizeof(struct dpaa2_queue) * tot_queues,
376 RTE_CACHE_LINE_SIZE);
378 DPAA2_PMD_ERR("Memory allocation failed for rx/tx queues");
382 for (i = 0; i < priv->nb_rx_queues; i++) {
383 mc_q->eth_data = dev->data;
384 priv->rx_vq[i] = mc_q++;
385 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
386 dpaa2_q->q_storage = rte_malloc("dq_storage",
387 sizeof(struct queue_storage_info_t),
388 RTE_CACHE_LINE_SIZE);
389 if (!dpaa2_q->q_storage)
392 memset(dpaa2_q->q_storage, 0,
393 sizeof(struct queue_storage_info_t));
394 if (dpaa2_alloc_dq_storage(dpaa2_q->q_storage))
398 if (dpaa2_enable_err_queue) {
399 priv->rx_err_vq = rte_zmalloc("dpni_rx_err",
400 sizeof(struct dpaa2_queue), 0);
402 dpaa2_q = (struct dpaa2_queue *)priv->rx_err_vq;
403 dpaa2_q->q_storage = rte_malloc("err_dq_storage",
404 sizeof(struct queue_storage_info_t) *
406 RTE_CACHE_LINE_SIZE);
407 if (!dpaa2_q->q_storage)
410 memset(dpaa2_q->q_storage, 0,
411 sizeof(struct queue_storage_info_t));
412 for (i = 0; i < RTE_MAX_LCORE; i++)
413 if (dpaa2_alloc_dq_storage(&dpaa2_q->q_storage[i]))
417 for (i = 0; i < priv->nb_tx_queues; i++) {
418 mc_q->eth_data = dev->data;
419 mc_q->flow_id = 0xffff;
420 priv->tx_vq[i] = mc_q++;
421 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
422 dpaa2_q->cscn = rte_malloc(NULL,
423 sizeof(struct qbman_result), 16);
428 if (priv->flags & DPAA2_TX_CONF_ENABLE) {
429 /*Setup tx confirmation queues*/
430 for (i = 0; i < priv->nb_tx_queues; i++) {
431 mc_q->eth_data = dev->data;
434 priv->tx_conf_vq[i] = mc_q++;
435 dpaa2_q = (struct dpaa2_queue *)priv->tx_conf_vq[i];
437 rte_malloc("dq_storage",
438 sizeof(struct queue_storage_info_t),
439 RTE_CACHE_LINE_SIZE);
440 if (!dpaa2_q->q_storage)
443 memset(dpaa2_q->q_storage, 0,
444 sizeof(struct queue_storage_info_t));
445 if (dpaa2_alloc_dq_storage(dpaa2_q->q_storage))
451 for (dist_idx = 0; dist_idx < priv->nb_rx_queues; dist_idx++) {
452 mcq = (struct dpaa2_queue *)priv->rx_vq[vq_id];
453 mcq->tc_index = dist_idx / num_rxqueue_per_tc;
454 mcq->flow_id = dist_idx % num_rxqueue_per_tc;
462 dpaa2_q = (struct dpaa2_queue *)priv->tx_conf_vq[i];
463 rte_free(dpaa2_q->q_storage);
464 priv->tx_conf_vq[i--] = NULL;
466 i = priv->nb_tx_queues;
470 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
471 rte_free(dpaa2_q->cscn);
472 priv->tx_vq[i--] = NULL;
474 i = priv->nb_rx_queues;
477 mc_q = priv->rx_vq[0];
479 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
480 dpaa2_free_dq_storage(dpaa2_q->q_storage);
481 rte_free(dpaa2_q->q_storage);
482 priv->rx_vq[i--] = NULL;
485 if (dpaa2_enable_err_queue) {
486 dpaa2_q = (struct dpaa2_queue *)priv->rx_err_vq;
487 if (dpaa2_q->q_storage)
488 dpaa2_free_dq_storage(dpaa2_q->q_storage);
489 rte_free(dpaa2_q->q_storage);
497 dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
499 struct dpaa2_dev_priv *priv = dev->data->dev_private;
500 struct dpaa2_queue *dpaa2_q;
503 PMD_INIT_FUNC_TRACE();
505 /* Queue allocation base */
506 if (priv->rx_vq[0]) {
507 /* cleaning up queue storage */
508 for (i = 0; i < priv->nb_rx_queues; i++) {
509 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
510 if (dpaa2_q->q_storage)
511 rte_free(dpaa2_q->q_storage);
513 /* cleanup tx queue cscn */
514 for (i = 0; i < priv->nb_tx_queues; i++) {
515 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
516 rte_free(dpaa2_q->cscn);
518 if (priv->flags & DPAA2_TX_CONF_ENABLE) {
519 /* cleanup tx conf queue storage */
520 for (i = 0; i < priv->nb_tx_queues; i++) {
521 dpaa2_q = (struct dpaa2_queue *)
523 rte_free(dpaa2_q->q_storage);
526 /*free memory for all queues (RX+TX) */
527 rte_free(priv->rx_vq[0]);
528 priv->rx_vq[0] = NULL;
533 dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
535 struct dpaa2_dev_priv *priv = dev->data->dev_private;
536 struct fsl_mc_io *dpni = dev->process_private;
537 struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
538 uint64_t rx_offloads = eth_conf->rxmode.offloads;
539 uint64_t tx_offloads = eth_conf->txmode.offloads;
540 int rx_l3_csum_offload = false;
541 int rx_l4_csum_offload = false;
542 int tx_l3_csum_offload = false;
543 int tx_l4_csum_offload = false;
545 uint32_t max_rx_pktlen;
547 PMD_INIT_FUNC_TRACE();
549 /* Rx offloads which are enabled by default */
550 if (dev_rx_offloads_nodis & ~rx_offloads) {
552 "Some of rx offloads enabled by default - requested 0x%" PRIx64
553 " fixed are 0x%" PRIx64,
554 rx_offloads, dev_rx_offloads_nodis);
557 /* Tx offloads which are enabled by default */
558 if (dev_tx_offloads_nodis & ~tx_offloads) {
560 "Some of tx offloads enabled by default - requested 0x%" PRIx64
561 " fixed are 0x%" PRIx64,
562 tx_offloads, dev_tx_offloads_nodis);
565 max_rx_pktlen = eth_conf->rxmode.mtu + RTE_ETHER_HDR_LEN +
566 RTE_ETHER_CRC_LEN + VLAN_TAG_SIZE;
567 if (max_rx_pktlen <= DPAA2_MAX_RX_PKT_LEN) {
568 ret = dpni_set_max_frame_length(dpni, CMD_PRI_LOW,
569 priv->token, max_rx_pktlen - RTE_ETHER_CRC_LEN);
571 DPAA2_PMD_ERR("Unable to set mtu. check config");
574 DPAA2_PMD_INFO("MTU configured for the device: %d",
580 if (eth_conf->rxmode.mq_mode == RTE_ETH_MQ_RX_RSS) {
581 for (tc_index = 0; tc_index < priv->num_rx_tc; tc_index++) {
582 ret = dpaa2_setup_flow_dist(dev,
583 eth_conf->rx_adv_conf.rss_conf.rss_hf,
587 "Unable to set flow distribution on tc%d."
588 "Check queue config", tc_index);
594 if (rx_offloads & RTE_ETH_RX_OFFLOAD_IPV4_CKSUM)
595 rx_l3_csum_offload = true;
597 if ((rx_offloads & RTE_ETH_RX_OFFLOAD_UDP_CKSUM) ||
598 (rx_offloads & RTE_ETH_RX_OFFLOAD_TCP_CKSUM) ||
599 (rx_offloads & RTE_ETH_RX_OFFLOAD_SCTP_CKSUM))
600 rx_l4_csum_offload = true;
602 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
603 DPNI_OFF_RX_L3_CSUM, rx_l3_csum_offload);
605 DPAA2_PMD_ERR("Error to set RX l3 csum:Error = %d", ret);
609 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
610 DPNI_OFF_RX_L4_CSUM, rx_l4_csum_offload);
612 DPAA2_PMD_ERR("Error to get RX l4 csum:Error = %d", ret);
616 #if !defined(RTE_LIBRTE_IEEE1588)
617 if (rx_offloads & RTE_ETH_RX_OFFLOAD_TIMESTAMP)
620 ret = rte_mbuf_dyn_rx_timestamp_register(
621 &dpaa2_timestamp_dynfield_offset,
622 &dpaa2_timestamp_rx_dynflag);
624 DPAA2_PMD_ERR("Error to register timestamp field/flag");
627 dpaa2_enable_ts[dev->data->port_id] = true;
630 if (tx_offloads & RTE_ETH_TX_OFFLOAD_IPV4_CKSUM)
631 tx_l3_csum_offload = true;
633 if ((tx_offloads & RTE_ETH_TX_OFFLOAD_UDP_CKSUM) ||
634 (tx_offloads & RTE_ETH_TX_OFFLOAD_TCP_CKSUM) ||
635 (tx_offloads & RTE_ETH_TX_OFFLOAD_SCTP_CKSUM))
636 tx_l4_csum_offload = true;
638 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
639 DPNI_OFF_TX_L3_CSUM, tx_l3_csum_offload);
641 DPAA2_PMD_ERR("Error to set TX l3 csum:Error = %d", ret);
645 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
646 DPNI_OFF_TX_L4_CSUM, tx_l4_csum_offload);
648 DPAA2_PMD_ERR("Error to get TX l4 csum:Error = %d", ret);
652 /* Enabling hash results in FD requires setting DPNI_FLCTYPE_HASH in
653 * dpni_set_offload API. Setting this FLCTYPE for DPNI sets the FD[SC]
654 * to 0 for LS2 in the hardware thus disabling data/annotation
655 * stashing. For LX2 this is fixed in hardware and thus hash result and
656 * parse results can be received in FD using this option.
658 if (dpaa2_svr_family == SVR_LX2160A) {
659 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
660 DPNI_FLCTYPE_HASH, true);
662 DPAA2_PMD_ERR("Error setting FLCTYPE: Err = %d", ret);
667 if (rx_offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
668 dpaa2_vlan_offload_set(dev, RTE_ETH_VLAN_FILTER_MASK);
675 /* Function to setup RX flow information. It contains traffic class ID,
676 * flow ID, destination configuration etc.
679 dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
680 uint16_t rx_queue_id,
682 unsigned int socket_id __rte_unused,
683 const struct rte_eth_rxconf *rx_conf,
684 struct rte_mempool *mb_pool)
686 struct dpaa2_dev_priv *priv = dev->data->dev_private;
687 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
688 struct dpaa2_queue *dpaa2_q;
689 struct dpni_queue cfg;
695 PMD_INIT_FUNC_TRACE();
697 DPAA2_PMD_DEBUG("dev =%p, queue =%d, pool = %p, conf =%p",
698 dev, rx_queue_id, mb_pool, rx_conf);
700 total_nb_rx_desc += nb_rx_desc;
701 if (total_nb_rx_desc > MAX_NB_RX_DESC) {
702 DPAA2_PMD_WARN("\nTotal nb_rx_desc exceeds %d limit. Please use Normal buffers",
704 DPAA2_PMD_WARN("To use Normal buffers, run 'export DPNI_NORMAL_BUF=1' before running dynamic_dpl.sh script");
707 /* Rx deferred start is not supported */
708 if (rx_conf->rx_deferred_start) {
709 DPAA2_PMD_ERR("%p:Rx deferred start not supported",
714 if (!priv->bp_list || priv->bp_list->mp != mb_pool) {
715 bpid = mempool_to_bpid(mb_pool);
716 ret = dpaa2_attach_bp_list(priv,
717 rte_dpaa2_bpid_info[bpid].bp_list);
721 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[rx_queue_id];
722 dpaa2_q->mb_pool = mb_pool; /**< mbuf pool to populate RX ring. */
723 dpaa2_q->bp_array = rte_dpaa2_bpid_info;
724 dpaa2_q->nb_desc = UINT16_MAX;
725 dpaa2_q->offloads = rx_conf->offloads;
727 /*Get the flow id from given VQ id*/
728 flow_id = dpaa2_q->flow_id;
729 memset(&cfg, 0, sizeof(struct dpni_queue));
731 options = options | DPNI_QUEUE_OPT_USER_CTX;
732 cfg.user_context = (size_t)(dpaa2_q);
734 /* check if a private cgr available. */
735 for (i = 0; i < priv->max_cgs; i++) {
736 if (!priv->cgid_in_use[i]) {
737 priv->cgid_in_use[i] = 1;
742 if (i < priv->max_cgs) {
743 options |= DPNI_QUEUE_OPT_SET_CGID;
745 dpaa2_q->cgid = cfg.cgid;
747 dpaa2_q->cgid = 0xff;
750 /*if ls2088 or rev2 device, enable the stashing */
752 if ((dpaa2_svr_family & 0xffff0000) != SVR_LS2080A) {
753 options |= DPNI_QUEUE_OPT_FLC;
754 cfg.flc.stash_control = true;
755 cfg.flc.value &= 0xFFFFFFFFFFFFFFC0;
756 /* 00 00 00 - last 6 bit represent annotation, context stashing,
757 * data stashing setting 01 01 00 (0x14)
758 * (in following order ->DS AS CS)
759 * to enable 1 line data, 1 line annotation.
760 * For LX2, this setting should be 01 00 00 (0x10)
762 if ((dpaa2_svr_family & 0xffff0000) == SVR_LX2160A)
763 cfg.flc.value |= 0x10;
765 cfg.flc.value |= 0x14;
767 ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_RX,
768 dpaa2_q->tc_index, flow_id, options, &cfg);
770 DPAA2_PMD_ERR("Error in setting the rx flow: = %d", ret);
774 if (!(priv->flags & DPAA2_RX_TAILDROP_OFF)) {
775 struct dpni_taildrop taildrop;
778 dpaa2_q->nb_desc = nb_rx_desc;
779 /* Private CGR will use tail drop length as nb_rx_desc.
780 * for rest cases we can use standard byte based tail drop.
781 * There is no HW restriction, but number of CGRs are limited,
782 * hence this restriction is placed.
784 if (dpaa2_q->cgid != 0xff) {
785 /*enabling per rx queue congestion control */
786 taildrop.threshold = nb_rx_desc;
787 taildrop.units = DPNI_CONGESTION_UNIT_FRAMES;
789 DPAA2_PMD_DEBUG("Enabling CG Tail Drop on queue = %d",
791 ret = dpni_set_taildrop(dpni, CMD_PRI_LOW, priv->token,
792 DPNI_CP_CONGESTION_GROUP,
795 dpaa2_q->cgid, &taildrop);
797 /*enabling per rx queue congestion control */
798 taildrop.threshold = CONG_THRESHOLD_RX_BYTES_Q;
799 taildrop.units = DPNI_CONGESTION_UNIT_BYTES;
800 taildrop.oal = CONG_RX_OAL;
801 DPAA2_PMD_DEBUG("Enabling Byte based Drop on queue= %d",
803 ret = dpni_set_taildrop(dpni, CMD_PRI_LOW, priv->token,
804 DPNI_CP_QUEUE, DPNI_QUEUE_RX,
805 dpaa2_q->tc_index, flow_id,
809 DPAA2_PMD_ERR("Error in setting taildrop. err=(%d)",
813 } else { /* Disable tail Drop */
814 struct dpni_taildrop taildrop = {0};
815 DPAA2_PMD_INFO("Tail drop is disabled on queue");
818 if (dpaa2_q->cgid != 0xff) {
819 ret = dpni_set_taildrop(dpni, CMD_PRI_LOW, priv->token,
820 DPNI_CP_CONGESTION_GROUP, DPNI_QUEUE_RX,
822 dpaa2_q->cgid, &taildrop);
824 ret = dpni_set_taildrop(dpni, CMD_PRI_LOW, priv->token,
825 DPNI_CP_QUEUE, DPNI_QUEUE_RX,
826 dpaa2_q->tc_index, flow_id, &taildrop);
829 DPAA2_PMD_ERR("Error in setting taildrop. err=(%d)",
835 dev->data->rx_queues[rx_queue_id] = dpaa2_q;
840 dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
841 uint16_t tx_queue_id,
843 unsigned int socket_id __rte_unused,
844 const struct rte_eth_txconf *tx_conf)
846 struct dpaa2_dev_priv *priv = dev->data->dev_private;
847 struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)
848 priv->tx_vq[tx_queue_id];
849 struct dpaa2_queue *dpaa2_tx_conf_q = (struct dpaa2_queue *)
850 priv->tx_conf_vq[tx_queue_id];
851 struct fsl_mc_io *dpni = dev->process_private;
852 struct dpni_queue tx_conf_cfg;
853 struct dpni_queue tx_flow_cfg;
854 uint8_t options = 0, flow_id;
855 struct dpni_queue_id qid;
859 PMD_INIT_FUNC_TRACE();
861 /* Tx deferred start is not supported */
862 if (tx_conf->tx_deferred_start) {
863 DPAA2_PMD_ERR("%p:Tx deferred start not supported",
868 dpaa2_q->nb_desc = UINT16_MAX;
869 dpaa2_q->offloads = tx_conf->offloads;
871 /* Return if queue already configured */
872 if (dpaa2_q->flow_id != 0xffff) {
873 dev->data->tx_queues[tx_queue_id] = dpaa2_q;
877 memset(&tx_conf_cfg, 0, sizeof(struct dpni_queue));
878 memset(&tx_flow_cfg, 0, sizeof(struct dpni_queue));
883 ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_TX,
884 tc_id, flow_id, options, &tx_flow_cfg);
886 DPAA2_PMD_ERR("Error in setting the tx flow: "
887 "tc_id=%d, flow=%d err=%d",
888 tc_id, flow_id, ret);
892 dpaa2_q->flow_id = flow_id;
894 if (tx_queue_id == 0) {
895 /*Set tx-conf and error configuration*/
896 if (priv->flags & DPAA2_TX_CONF_ENABLE)
897 ret = dpni_set_tx_confirmation_mode(dpni, CMD_PRI_LOW,
901 ret = dpni_set_tx_confirmation_mode(dpni, CMD_PRI_LOW,
905 DPAA2_PMD_ERR("Error in set tx conf mode settings: "
910 dpaa2_q->tc_index = tc_id;
912 ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
913 DPNI_QUEUE_TX, dpaa2_q->tc_index,
914 dpaa2_q->flow_id, &tx_flow_cfg, &qid);
916 DPAA2_PMD_ERR("Error in getting LFQID err=%d", ret);
919 dpaa2_q->fqid = qid.fqid;
921 if (!(priv->flags & DPAA2_TX_CGR_OFF)) {
922 struct dpni_congestion_notification_cfg cong_notif_cfg = {0};
924 dpaa2_q->nb_desc = nb_tx_desc;
926 cong_notif_cfg.units = DPNI_CONGESTION_UNIT_FRAMES;
927 cong_notif_cfg.threshold_entry = nb_tx_desc;
928 /* Notify that the queue is not congested when the data in
929 * the queue is below this threshold.(90% of value)
931 cong_notif_cfg.threshold_exit = (nb_tx_desc * 9) / 10;
932 cong_notif_cfg.message_ctx = 0;
933 cong_notif_cfg.message_iova =
934 (size_t)DPAA2_VADDR_TO_IOVA(dpaa2_q->cscn);
935 cong_notif_cfg.dest_cfg.dest_type = DPNI_DEST_NONE;
936 cong_notif_cfg.notification_mode =
937 DPNI_CONG_OPT_WRITE_MEM_ON_ENTER |
938 DPNI_CONG_OPT_WRITE_MEM_ON_EXIT |
939 DPNI_CONG_OPT_COHERENT_WRITE;
940 cong_notif_cfg.cg_point = DPNI_CP_QUEUE;
942 ret = dpni_set_congestion_notification(dpni, CMD_PRI_LOW,
949 "Error in setting tx congestion notification: "
954 dpaa2_q->cb_eqresp_free = dpaa2_dev_free_eqresp_buf;
955 dev->data->tx_queues[tx_queue_id] = dpaa2_q;
957 if (priv->flags & DPAA2_TX_CONF_ENABLE) {
958 dpaa2_q->tx_conf_queue = dpaa2_tx_conf_q;
959 options = options | DPNI_QUEUE_OPT_USER_CTX;
960 tx_conf_cfg.user_context = (size_t)(dpaa2_q);
961 ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token,
962 DPNI_QUEUE_TX_CONFIRM, dpaa2_tx_conf_q->tc_index,
963 dpaa2_tx_conf_q->flow_id, options, &tx_conf_cfg);
965 DPAA2_PMD_ERR("Error in setting the tx conf flow: "
966 "tc_index=%d, flow=%d err=%d",
967 dpaa2_tx_conf_q->tc_index,
968 dpaa2_tx_conf_q->flow_id, ret);
972 ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
973 DPNI_QUEUE_TX_CONFIRM, dpaa2_tx_conf_q->tc_index,
974 dpaa2_tx_conf_q->flow_id, &tx_conf_cfg, &qid);
976 DPAA2_PMD_ERR("Error in getting LFQID err=%d", ret);
979 dpaa2_tx_conf_q->fqid = qid.fqid;
985 dpaa2_dev_rx_queue_release(struct rte_eth_dev *dev, uint16_t rx_queue_id)
987 struct dpaa2_queue *dpaa2_q = dev->data->rx_queues[rx_queue_id];
988 struct dpaa2_dev_priv *priv = dpaa2_q->eth_data->dev_private;
989 struct fsl_mc_io *dpni =
990 (struct fsl_mc_io *)priv->eth_dev->process_private;
993 struct dpni_queue cfg;
995 memset(&cfg, 0, sizeof(struct dpni_queue));
996 PMD_INIT_FUNC_TRACE();
998 total_nb_rx_desc -= dpaa2_q->nb_desc;
1000 if (dpaa2_q->cgid != 0xff) {
1001 options = DPNI_QUEUE_OPT_CLEAR_CGID;
1002 cfg.cgid = dpaa2_q->cgid;
1004 ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token,
1006 dpaa2_q->tc_index, dpaa2_q->flow_id,
1009 DPAA2_PMD_ERR("Unable to clear CGR from q=%u err=%d",
1010 dpaa2_q->fqid, ret);
1011 priv->cgid_in_use[dpaa2_q->cgid] = 0;
1012 dpaa2_q->cgid = 0xff;
1017 dpaa2_dev_rx_queue_count(void *rx_queue)
1020 struct dpaa2_queue *dpaa2_q;
1021 struct qbman_swp *swp;
1022 struct qbman_fq_query_np_rslt state;
1023 uint32_t frame_cnt = 0;
1025 if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
1026 ret = dpaa2_affine_qbman_swp();
1029 "Failed to allocate IO portal, tid: %d\n",
1034 swp = DPAA2_PER_LCORE_PORTAL;
1038 if (qbman_fq_query_state(swp, dpaa2_q->fqid, &state) == 0) {
1039 frame_cnt = qbman_fq_state_frame_count(&state);
1040 DPAA2_PMD_DP_DEBUG("RX frame count for q(%p) is %u",
1041 rx_queue, frame_cnt);
1046 static const uint32_t *
1047 dpaa2_supported_ptypes_get(struct rte_eth_dev *dev)
1049 static const uint32_t ptypes[] = {
1050 /*todo -= add more types */
1053 RTE_PTYPE_L3_IPV4_EXT,
1055 RTE_PTYPE_L3_IPV6_EXT,
1063 if (dev->rx_pkt_burst == dpaa2_dev_prefetch_rx ||
1064 dev->rx_pkt_burst == dpaa2_dev_rx ||
1065 dev->rx_pkt_burst == dpaa2_dev_loopback_rx)
1071 * Dpaa2 link Interrupt handler
1074 * The address of parameter (struct rte_eth_dev *) registered before.
1080 dpaa2_interrupt_handler(void *param)
1082 struct rte_eth_dev *dev = param;
1083 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1084 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1086 int irq_index = DPNI_IRQ_INDEX;
1087 unsigned int status = 0, clear = 0;
1089 PMD_INIT_FUNC_TRACE();
1092 DPAA2_PMD_ERR("dpni is NULL");
1096 ret = dpni_get_irq_status(dpni, CMD_PRI_LOW, priv->token,
1097 irq_index, &status);
1098 if (unlikely(ret)) {
1099 DPAA2_PMD_ERR("Can't get irq status (err %d)", ret);
1104 if (status & DPNI_IRQ_EVENT_LINK_CHANGED) {
1105 clear = DPNI_IRQ_EVENT_LINK_CHANGED;
1106 dpaa2_dev_link_update(dev, 0);
1107 /* calling all the apps registered for link status event */
1108 rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
1111 ret = dpni_clear_irq_status(dpni, CMD_PRI_LOW, priv->token,
1114 DPAA2_PMD_ERR("Can't clear irq status (err %d)", ret);
1118 dpaa2_eth_setup_irqs(struct rte_eth_dev *dev, int enable)
1121 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1122 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1123 int irq_index = DPNI_IRQ_INDEX;
1124 unsigned int mask = DPNI_IRQ_EVENT_LINK_CHANGED;
1126 PMD_INIT_FUNC_TRACE();
1128 err = dpni_set_irq_mask(dpni, CMD_PRI_LOW, priv->token,
1131 DPAA2_PMD_ERR("Error: dpni_set_irq_mask():%d (%s)", err,
1136 err = dpni_set_irq_enable(dpni, CMD_PRI_LOW, priv->token,
1139 DPAA2_PMD_ERR("Error: dpni_set_irq_enable():%d (%s)", err,
1146 dpaa2_dev_start(struct rte_eth_dev *dev)
1148 struct rte_device *rdev = dev->device;
1149 struct rte_dpaa2_device *dpaa2_dev;
1150 struct rte_eth_dev_data *data = dev->data;
1151 struct dpaa2_dev_priv *priv = data->dev_private;
1152 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1153 struct dpni_queue cfg;
1154 struct dpni_error_cfg err_cfg;
1156 struct dpni_queue_id qid;
1157 struct dpaa2_queue *dpaa2_q;
1159 struct rte_intr_handle *intr_handle;
1161 dpaa2_dev = container_of(rdev, struct rte_dpaa2_device, device);
1162 intr_handle = dpaa2_dev->intr_handle;
1164 PMD_INIT_FUNC_TRACE();
1166 ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token);
1168 DPAA2_PMD_ERR("Failure in enabling dpni %d device: err=%d",
1173 /* Power up the phy. Needed to make the link go UP */
1174 dpaa2_dev_set_link_up(dev);
1176 ret = dpni_get_qdid(dpni, CMD_PRI_LOW, priv->token,
1177 DPNI_QUEUE_TX, &qdid);
1179 DPAA2_PMD_ERR("Error in getting qdid: err=%d", ret);
1184 for (i = 0; i < data->nb_rx_queues; i++) {
1185 dpaa2_q = (struct dpaa2_queue *)data->rx_queues[i];
1186 ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
1187 DPNI_QUEUE_RX, dpaa2_q->tc_index,
1188 dpaa2_q->flow_id, &cfg, &qid);
1190 DPAA2_PMD_ERR("Error in getting flow information: "
1194 dpaa2_q->fqid = qid.fqid;
1197 if (dpaa2_enable_err_queue) {
1198 ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
1199 DPNI_QUEUE_RX_ERR, 0, 0, &cfg, &qid);
1201 DPAA2_PMD_ERR("Error getting rx err flow information: err=%d",
1205 dpaa2_q = (struct dpaa2_queue *)priv->rx_err_vq;
1206 dpaa2_q->fqid = qid.fqid;
1207 dpaa2_q->eth_data = dev->data;
1209 err_cfg.errors = DPNI_ERROR_DISC;
1210 err_cfg.error_action = DPNI_ERROR_ACTION_SEND_TO_ERROR_QUEUE;
1212 /* checksum errors, send them to normal path
1213 * and set it in annotation
1215 err_cfg.errors = DPNI_ERROR_L3CE | DPNI_ERROR_L4CE;
1217 /* if packet with parse error are not to be dropped */
1218 err_cfg.errors |= DPNI_ERROR_PHE;
1220 err_cfg.error_action = DPNI_ERROR_ACTION_CONTINUE;
1222 err_cfg.set_frame_annotation = true;
1224 ret = dpni_set_errors_behavior(dpni, CMD_PRI_LOW,
1225 priv->token, &err_cfg);
1227 DPAA2_PMD_ERR("Error to dpni_set_errors_behavior: code = %d",
1232 /* if the interrupts were configured on this devices*/
1233 if (intr_handle && rte_intr_fd_get(intr_handle) &&
1234 dev->data->dev_conf.intr_conf.lsc != 0) {
1235 /* Registering LSC interrupt handler */
1236 rte_intr_callback_register(intr_handle,
1237 dpaa2_interrupt_handler,
1240 /* enable vfio intr/eventfd mapping
1241 * Interrupt index 0 is required, so we can not use
1244 rte_dpaa2_intr_enable(intr_handle, DPNI_IRQ_INDEX);
1246 /* enable dpni_irqs */
1247 dpaa2_eth_setup_irqs(dev, 1);
1250 /* Change the tx burst function if ordered queues are used */
1251 if (priv->en_ordered)
1252 dev->tx_pkt_burst = dpaa2_dev_tx_ordered;
1258 * This routine disables all traffic on the adapter by issuing a
1259 * global reset on the MAC.
1262 dpaa2_dev_stop(struct rte_eth_dev *dev)
1264 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1265 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1267 struct rte_eth_link link;
1268 struct rte_device *rdev = dev->device;
1269 struct rte_intr_handle *intr_handle;
1270 struct rte_dpaa2_device *dpaa2_dev;
1272 dpaa2_dev = container_of(rdev, struct rte_dpaa2_device, device);
1273 intr_handle = dpaa2_dev->intr_handle;
1275 PMD_INIT_FUNC_TRACE();
1277 /* reset interrupt callback */
1278 if (intr_handle && rte_intr_fd_get(intr_handle) &&
1279 dev->data->dev_conf.intr_conf.lsc != 0) {
1280 /*disable dpni irqs */
1281 dpaa2_eth_setup_irqs(dev, 0);
1283 /* disable vfio intr before callback unregister */
1284 rte_dpaa2_intr_disable(intr_handle, DPNI_IRQ_INDEX);
1286 /* Unregistering LSC interrupt handler */
1287 rte_intr_callback_unregister(intr_handle,
1288 dpaa2_interrupt_handler,
1292 dpaa2_dev_set_link_down(dev);
1294 ret = dpni_disable(dpni, CMD_PRI_LOW, priv->token);
1296 DPAA2_PMD_ERR("Failure (ret %d) in disabling dpni %d dev",
1301 /* clear the recorded link status */
1302 memset(&link, 0, sizeof(link));
1303 rte_eth_linkstatus_set(dev, &link);
1309 dpaa2_dev_close(struct rte_eth_dev *dev)
1311 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1312 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1314 struct rte_eth_link link;
1316 PMD_INIT_FUNC_TRACE();
1318 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1322 DPAA2_PMD_WARN("Already closed or not started");
1326 dpaa2_tm_deinit(dev);
1327 dpaa2_flow_clean(dev);
1328 /* Clean the device first */
1329 ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token);
1331 DPAA2_PMD_ERR("Failure cleaning dpni device: err=%d", ret);
1335 memset(&link, 0, sizeof(link));
1336 rte_eth_linkstatus_set(dev, &link);
1338 /* Free private queues memory */
1339 dpaa2_free_rx_tx_queues(dev);
1340 /* Close the device at underlying layer*/
1341 ret = dpni_close(dpni, CMD_PRI_LOW, priv->token);
1343 DPAA2_PMD_ERR("Failure closing dpni device with err code %d",
1347 /* Free the allocated memory for ethernet private data and dpni*/
1349 dev->process_private = NULL;
1352 for (i = 0; i < MAX_TCS; i++)
1353 rte_free((void *)(size_t)priv->extract.tc_extract_param[i]);
1355 if (priv->extract.qos_extract_param)
1356 rte_free((void *)(size_t)priv->extract.qos_extract_param);
1358 DPAA2_PMD_INFO("%s: netdev deleted", dev->data->name);
1363 dpaa2_dev_promiscuous_enable(
1364 struct rte_eth_dev *dev)
1367 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1368 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1370 PMD_INIT_FUNC_TRACE();
1373 DPAA2_PMD_ERR("dpni is NULL");
1377 ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
1379 DPAA2_PMD_ERR("Unable to enable U promisc mode %d", ret);
1381 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
1383 DPAA2_PMD_ERR("Unable to enable M promisc mode %d", ret);
1389 dpaa2_dev_promiscuous_disable(
1390 struct rte_eth_dev *dev)
1393 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1394 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1396 PMD_INIT_FUNC_TRACE();
1399 DPAA2_PMD_ERR("dpni is NULL");
1403 ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, false);
1405 DPAA2_PMD_ERR("Unable to disable U promisc mode %d", ret);
1407 if (dev->data->all_multicast == 0) {
1408 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW,
1409 priv->token, false);
1411 DPAA2_PMD_ERR("Unable to disable M promisc mode %d",
1419 dpaa2_dev_allmulticast_enable(
1420 struct rte_eth_dev *dev)
1423 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1424 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1426 PMD_INIT_FUNC_TRACE();
1429 DPAA2_PMD_ERR("dpni is NULL");
1433 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
1435 DPAA2_PMD_ERR("Unable to enable multicast mode %d", ret);
1441 dpaa2_dev_allmulticast_disable(struct rte_eth_dev *dev)
1444 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1445 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1447 PMD_INIT_FUNC_TRACE();
1450 DPAA2_PMD_ERR("dpni is NULL");
1454 /* must remain on for all promiscuous */
1455 if (dev->data->promiscuous == 1)
1458 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, false);
1460 DPAA2_PMD_ERR("Unable to disable multicast mode %d", ret);
1466 dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
1469 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1470 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1471 uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN
1474 PMD_INIT_FUNC_TRACE();
1477 DPAA2_PMD_ERR("dpni is NULL");
1481 /* Set the Max Rx frame length as 'mtu' +
1482 * Maximum Ethernet header length
1484 ret = dpni_set_max_frame_length(dpni, CMD_PRI_LOW, priv->token,
1485 frame_size - RTE_ETHER_CRC_LEN);
1487 DPAA2_PMD_ERR("Setting the max frame length failed");
1490 DPAA2_PMD_INFO("MTU configured for the device: %d", mtu);
1495 dpaa2_dev_add_mac_addr(struct rte_eth_dev *dev,
1496 struct rte_ether_addr *addr,
1497 __rte_unused uint32_t index,
1498 __rte_unused uint32_t pool)
1501 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1502 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1504 PMD_INIT_FUNC_TRACE();
1507 DPAA2_PMD_ERR("dpni is NULL");
1511 ret = dpni_add_mac_addr(dpni, CMD_PRI_LOW, priv->token,
1512 addr->addr_bytes, 0, 0, 0);
1515 "error: Adding the MAC ADDR failed: err = %d", ret);
1520 dpaa2_dev_remove_mac_addr(struct rte_eth_dev *dev,
1524 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1525 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1526 struct rte_eth_dev_data *data = dev->data;
1527 struct rte_ether_addr *macaddr;
1529 PMD_INIT_FUNC_TRACE();
1531 macaddr = &data->mac_addrs[index];
1534 DPAA2_PMD_ERR("dpni is NULL");
1538 ret = dpni_remove_mac_addr(dpni, CMD_PRI_LOW,
1539 priv->token, macaddr->addr_bytes);
1542 "error: Removing the MAC ADDR failed: err = %d", ret);
1546 dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev,
1547 struct rte_ether_addr *addr)
1550 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1551 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1553 PMD_INIT_FUNC_TRACE();
1556 DPAA2_PMD_ERR("dpni is NULL");
1560 ret = dpni_set_primary_mac_addr(dpni, CMD_PRI_LOW,
1561 priv->token, addr->addr_bytes);
1565 "error: Setting the MAC ADDR failed %d", ret);
1571 int dpaa2_dev_stats_get(struct rte_eth_dev *dev,
1572 struct rte_eth_stats *stats)
1574 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1575 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1577 uint8_t page0 = 0, page1 = 1, page2 = 2;
1578 union dpni_statistics value;
1580 struct dpaa2_queue *dpaa2_rxq, *dpaa2_txq;
1582 memset(&value, 0, sizeof(union dpni_statistics));
1584 PMD_INIT_FUNC_TRACE();
1587 DPAA2_PMD_ERR("dpni is NULL");
1592 DPAA2_PMD_ERR("stats is NULL");
1596 /*Get Counters from page_0*/
1597 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1602 stats->ipackets = value.page_0.ingress_all_frames;
1603 stats->ibytes = value.page_0.ingress_all_bytes;
1605 /*Get Counters from page_1*/
1606 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1611 stats->opackets = value.page_1.egress_all_frames;
1612 stats->obytes = value.page_1.egress_all_bytes;
1614 /*Get Counters from page_2*/
1615 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1620 /* Ingress drop frame count due to configured rules */
1621 stats->ierrors = value.page_2.ingress_filtered_frames;
1622 /* Ingress drop frame count due to error */
1623 stats->ierrors += value.page_2.ingress_discarded_frames;
1625 stats->oerrors = value.page_2.egress_discarded_frames;
1626 stats->imissed = value.page_2.ingress_nobuffer_discards;
1628 /* Fill in per queue stats */
1629 for (i = 0; (i < RTE_ETHDEV_QUEUE_STAT_CNTRS) &&
1630 (i < priv->nb_rx_queues || i < priv->nb_tx_queues); ++i) {
1631 dpaa2_rxq = (struct dpaa2_queue *)priv->rx_vq[i];
1632 dpaa2_txq = (struct dpaa2_queue *)priv->tx_vq[i];
1634 stats->q_ipackets[i] = dpaa2_rxq->rx_pkts;
1636 stats->q_opackets[i] = dpaa2_txq->tx_pkts;
1638 /* Byte counting is not implemented */
1639 stats->q_ibytes[i] = 0;
1640 stats->q_obytes[i] = 0;
1646 DPAA2_PMD_ERR("Operation not completed:Error Code = %d", retcode);
1651 dpaa2_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
1654 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1655 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1657 union dpni_statistics value[5] = {};
1658 unsigned int i = 0, num = RTE_DIM(dpaa2_xstats_strings);
1666 /* Get Counters from page_0*/
1667 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1672 /* Get Counters from page_1*/
1673 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1678 /* Get Counters from page_2*/
1679 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1684 for (i = 0; i < priv->max_cgs; i++) {
1685 if (!priv->cgid_in_use[i]) {
1686 /* Get Counters from page_4*/
1687 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW,
1696 for (i = 0; i < num; i++) {
1698 xstats[i].value = value[dpaa2_xstats_strings[i].page_id].
1699 raw.counter[dpaa2_xstats_strings[i].stats_id];
1703 DPAA2_PMD_ERR("Error in obtaining extended stats (%d)", retcode);
1708 dpaa2_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
1709 struct rte_eth_xstat_name *xstats_names,
1712 unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
1714 if (limit < stat_cnt)
1717 if (xstats_names != NULL)
1718 for (i = 0; i < stat_cnt; i++)
1719 strlcpy(xstats_names[i].name,
1720 dpaa2_xstats_strings[i].name,
1721 sizeof(xstats_names[i].name));
1727 dpaa2_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
1728 uint64_t *values, unsigned int n)
1730 unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
1731 uint64_t values_copy[stat_cnt];
1734 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1735 struct fsl_mc_io *dpni =
1736 (struct fsl_mc_io *)dev->process_private;
1738 union dpni_statistics value[5] = {};
1746 /* Get Counters from page_0*/
1747 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1752 /* Get Counters from page_1*/
1753 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1758 /* Get Counters from page_2*/
1759 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1764 /* Get Counters from page_4*/
1765 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
1770 for (i = 0; i < stat_cnt; i++) {
1771 values[i] = value[dpaa2_xstats_strings[i].page_id].
1772 raw.counter[dpaa2_xstats_strings[i].stats_id];
1777 dpaa2_xstats_get_by_id(dev, NULL, values_copy, stat_cnt);
1779 for (i = 0; i < n; i++) {
1780 if (ids[i] >= stat_cnt) {
1781 DPAA2_PMD_ERR("xstats id value isn't valid");
1784 values[i] = values_copy[ids[i]];
1790 dpaa2_xstats_get_names_by_id(
1791 struct rte_eth_dev *dev,
1792 const uint64_t *ids,
1793 struct rte_eth_xstat_name *xstats_names,
1796 unsigned int i, stat_cnt = RTE_DIM(dpaa2_xstats_strings);
1797 struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
1800 return dpaa2_xstats_get_names(dev, xstats_names, limit);
1802 dpaa2_xstats_get_names(dev, xstats_names_copy, limit);
1804 for (i = 0; i < limit; i++) {
1805 if (ids[i] >= stat_cnt) {
1806 DPAA2_PMD_ERR("xstats id value isn't valid");
1809 strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name);
1815 dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
1817 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1818 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1821 struct dpaa2_queue *dpaa2_q;
1823 PMD_INIT_FUNC_TRACE();
1826 DPAA2_PMD_ERR("dpni is NULL");
1830 retcode = dpni_reset_statistics(dpni, CMD_PRI_LOW, priv->token);
1834 /* Reset the per queue stats in dpaa2_queue structure */
1835 for (i = 0; i < priv->nb_rx_queues; i++) {
1836 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
1838 dpaa2_q->rx_pkts = 0;
1841 for (i = 0; i < priv->nb_tx_queues; i++) {
1842 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
1844 dpaa2_q->tx_pkts = 0;
1850 DPAA2_PMD_ERR("Operation not completed:Error Code = %d", retcode);
1854 /* return 0 means link status changed, -1 means not changed */
1856 dpaa2_dev_link_update(struct rte_eth_dev *dev,
1857 int wait_to_complete)
1860 struct dpaa2_dev_priv *priv = dev->data->dev_private;
1861 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
1862 struct rte_eth_link link;
1863 struct dpni_link_state state = {0};
1867 DPAA2_PMD_ERR("dpni is NULL");
1871 for (count = 0; count <= MAX_REPEAT_TIME; count++) {
1872 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token,
1875 DPAA2_PMD_DEBUG("error: dpni_get_link_state %d", ret);
1878 if (state.up == RTE_ETH_LINK_DOWN &&
1880 rte_delay_ms(CHECK_INTERVAL);
1885 memset(&link, 0, sizeof(struct rte_eth_link));
1886 link.link_status = state.up;
1887 link.link_speed = state.rate;
1889 if (state.options & DPNI_LINK_OPT_HALF_DUPLEX)
1890 link.link_duplex = RTE_ETH_LINK_HALF_DUPLEX;
1892 link.link_duplex = RTE_ETH_LINK_FULL_DUPLEX;
1894 ret = rte_eth_linkstatus_set(dev, &link);
1896 DPAA2_PMD_DEBUG("No change in status");
1898 DPAA2_PMD_INFO("Port %d Link is %s\n", dev->data->port_id,
1899 link.link_status ? "Up" : "Down");
1905 * Toggle the DPNI to enable, if not already enabled.
1906 * This is not strictly PHY up/down - it is more of logical toggling.
1909 dpaa2_dev_set_link_up(struct rte_eth_dev *dev)
1912 struct dpaa2_dev_priv *priv;
1913 struct fsl_mc_io *dpni;
1915 struct dpni_link_state state = {0};
1917 priv = dev->data->dev_private;
1918 dpni = (struct fsl_mc_io *)dev->process_private;
1921 DPAA2_PMD_ERR("dpni is NULL");
1925 /* Check if DPNI is currently enabled */
1926 ret = dpni_is_enabled(dpni, CMD_PRI_LOW, priv->token, &en);
1928 /* Unable to obtain dpni status; Not continuing */
1929 DPAA2_PMD_ERR("Interface Link UP failed (%d)", ret);
1933 /* Enable link if not already enabled */
1935 ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token);
1937 DPAA2_PMD_ERR("Interface Link UP failed (%d)", ret);
1941 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
1943 DPAA2_PMD_DEBUG("Unable to get link state (%d)", ret);
1947 /* changing tx burst function to start enqueues */
1948 dev->tx_pkt_burst = dpaa2_dev_tx;
1949 dev->data->dev_link.link_status = state.up;
1950 dev->data->dev_link.link_speed = state.rate;
1953 DPAA2_PMD_INFO("Port %d Link is Up", dev->data->port_id);
1955 DPAA2_PMD_INFO("Port %d Link is Down", dev->data->port_id);
1960 * Toggle the DPNI to disable, if not already disabled.
1961 * This is not strictly PHY up/down - it is more of logical toggling.
1964 dpaa2_dev_set_link_down(struct rte_eth_dev *dev)
1967 struct dpaa2_dev_priv *priv;
1968 struct fsl_mc_io *dpni;
1969 int dpni_enabled = 0;
1972 PMD_INIT_FUNC_TRACE();
1974 priv = dev->data->dev_private;
1975 dpni = (struct fsl_mc_io *)dev->process_private;
1978 DPAA2_PMD_ERR("Device has not yet been configured");
1982 /*changing tx burst function to avoid any more enqueues */
1983 dev->tx_pkt_burst = dummy_dev_tx;
1985 /* Loop while dpni_disable() attempts to drain the egress FQs
1986 * and confirm them back to us.
1989 ret = dpni_disable(dpni, 0, priv->token);
1991 DPAA2_PMD_ERR("dpni disable failed (%d)", ret);
1994 ret = dpni_is_enabled(dpni, 0, priv->token, &dpni_enabled);
1996 DPAA2_PMD_ERR("dpni enable check failed (%d)", ret);
2000 /* Allow the MC some slack */
2001 rte_delay_us(100 * 1000);
2002 } while (dpni_enabled && --retries);
2005 DPAA2_PMD_WARN("Retry count exceeded disabling dpni");
2006 /* todo- we may have to manually cleanup queues.
2009 DPAA2_PMD_INFO("Port %d Link DOWN successful",
2010 dev->data->port_id);
2013 dev->data->dev_link.link_status = 0;
2019 dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
2022 struct dpaa2_dev_priv *priv;
2023 struct fsl_mc_io *dpni;
2024 struct dpni_link_state state = {0};
2026 PMD_INIT_FUNC_TRACE();
2028 priv = dev->data->dev_private;
2029 dpni = (struct fsl_mc_io *)dev->process_private;
2031 if (dpni == NULL || fc_conf == NULL) {
2032 DPAA2_PMD_ERR("device not configured");
2036 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
2038 DPAA2_PMD_ERR("error: dpni_get_link_state %d", ret);
2042 memset(fc_conf, 0, sizeof(struct rte_eth_fc_conf));
2043 if (state.options & DPNI_LINK_OPT_PAUSE) {
2044 /* DPNI_LINK_OPT_PAUSE set
2045 * if ASYM_PAUSE not set,
2046 * RX Side flow control (handle received Pause frame)
2047 * TX side flow control (send Pause frame)
2048 * if ASYM_PAUSE set,
2049 * RX Side flow control (handle received Pause frame)
2050 * No TX side flow control (send Pause frame disabled)
2052 if (!(state.options & DPNI_LINK_OPT_ASYM_PAUSE))
2053 fc_conf->mode = RTE_ETH_FC_FULL;
2055 fc_conf->mode = RTE_ETH_FC_RX_PAUSE;
2057 /* DPNI_LINK_OPT_PAUSE not set
2058 * if ASYM_PAUSE set,
2059 * TX side flow control (send Pause frame)
2060 * No RX side flow control (No action on pause frame rx)
2061 * if ASYM_PAUSE not set,
2062 * Flow control disabled
2064 if (state.options & DPNI_LINK_OPT_ASYM_PAUSE)
2065 fc_conf->mode = RTE_ETH_FC_TX_PAUSE;
2067 fc_conf->mode = RTE_ETH_FC_NONE;
2074 dpaa2_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
2077 struct dpaa2_dev_priv *priv;
2078 struct fsl_mc_io *dpni;
2079 struct dpni_link_state state = {0};
2080 struct dpni_link_cfg cfg = {0};
2082 PMD_INIT_FUNC_TRACE();
2084 priv = dev->data->dev_private;
2085 dpni = (struct fsl_mc_io *)dev->process_private;
2088 DPAA2_PMD_ERR("dpni is NULL");
2092 /* It is necessary to obtain the current state before setting fc_conf
2093 * as MC would return error in case rate, autoneg or duplex values are
2096 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
2098 DPAA2_PMD_ERR("Unable to get link state (err=%d)", ret);
2102 /* Disable link before setting configuration */
2103 dpaa2_dev_set_link_down(dev);
2105 /* Based on fc_conf, update cfg */
2106 cfg.rate = state.rate;
2107 cfg.options = state.options;
2109 /* update cfg with fc_conf */
2110 switch (fc_conf->mode) {
2111 case RTE_ETH_FC_FULL:
2112 /* Full flow control;
2113 * OPT_PAUSE set, ASYM_PAUSE not set
2115 cfg.options |= DPNI_LINK_OPT_PAUSE;
2116 cfg.options &= ~DPNI_LINK_OPT_ASYM_PAUSE;
2118 case RTE_ETH_FC_TX_PAUSE:
2119 /* Enable RX flow control
2120 * OPT_PAUSE not set;
2123 cfg.options |= DPNI_LINK_OPT_ASYM_PAUSE;
2124 cfg.options &= ~DPNI_LINK_OPT_PAUSE;
2126 case RTE_ETH_FC_RX_PAUSE:
2127 /* Enable TX Flow control
2131 cfg.options |= DPNI_LINK_OPT_PAUSE;
2132 cfg.options |= DPNI_LINK_OPT_ASYM_PAUSE;
2134 case RTE_ETH_FC_NONE:
2135 /* Disable Flow control
2137 * ASYM_PAUSE not set
2139 cfg.options &= ~DPNI_LINK_OPT_PAUSE;
2140 cfg.options &= ~DPNI_LINK_OPT_ASYM_PAUSE;
2143 DPAA2_PMD_ERR("Incorrect Flow control flag (%d)",
2148 ret = dpni_set_link_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg);
2150 DPAA2_PMD_ERR("Unable to set Link configuration (err=%d)",
2154 dpaa2_dev_set_link_up(dev);
2160 dpaa2_dev_rss_hash_update(struct rte_eth_dev *dev,
2161 struct rte_eth_rss_conf *rss_conf)
2163 struct rte_eth_dev_data *data = dev->data;
2164 struct dpaa2_dev_priv *priv = data->dev_private;
2165 struct rte_eth_conf *eth_conf = &data->dev_conf;
2168 PMD_INIT_FUNC_TRACE();
2170 if (rss_conf->rss_hf) {
2171 for (tc_index = 0; tc_index < priv->num_rx_tc; tc_index++) {
2172 ret = dpaa2_setup_flow_dist(dev, rss_conf->rss_hf,
2175 DPAA2_PMD_ERR("Unable to set flow dist on tc%d",
2181 for (tc_index = 0; tc_index < priv->num_rx_tc; tc_index++) {
2182 ret = dpaa2_remove_flow_dist(dev, tc_index);
2185 "Unable to remove flow dist on tc%d",
2191 eth_conf->rx_adv_conf.rss_conf.rss_hf = rss_conf->rss_hf;
2196 dpaa2_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
2197 struct rte_eth_rss_conf *rss_conf)
2199 struct rte_eth_dev_data *data = dev->data;
2200 struct rte_eth_conf *eth_conf = &data->dev_conf;
2202 /* dpaa2 does not support rss_key, so length should be 0*/
2203 rss_conf->rss_key_len = 0;
2204 rss_conf->rss_hf = eth_conf->rx_adv_conf.rss_conf.rss_hf;
2208 int dpaa2_eth_eventq_attach(const struct rte_eth_dev *dev,
2209 int eth_rx_queue_id,
2210 struct dpaa2_dpcon_dev *dpcon,
2211 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
2213 struct dpaa2_dev_priv *eth_priv = dev->data->dev_private;
2214 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
2215 struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id];
2216 uint8_t flow_id = dpaa2_ethq->flow_id;
2217 struct dpni_queue cfg;
2218 uint8_t options, priority;
2221 if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_PARALLEL)
2222 dpaa2_ethq->cb = dpaa2_dev_process_parallel_event;
2223 else if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_ATOMIC)
2224 dpaa2_ethq->cb = dpaa2_dev_process_atomic_event;
2225 else if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_ORDERED)
2226 dpaa2_ethq->cb = dpaa2_dev_process_ordered_event;
2230 priority = (RTE_EVENT_DEV_PRIORITY_LOWEST / queue_conf->ev.priority) *
2231 (dpcon->num_priorities - 1);
2233 memset(&cfg, 0, sizeof(struct dpni_queue));
2234 options = DPNI_QUEUE_OPT_DEST;
2235 cfg.destination.type = DPNI_DEST_DPCON;
2236 cfg.destination.id = dpcon->dpcon_id;
2237 cfg.destination.priority = priority;
2239 if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_ATOMIC) {
2240 options |= DPNI_QUEUE_OPT_HOLD_ACTIVE;
2241 cfg.destination.hold_active = 1;
2244 if (queue_conf->ev.sched_type == RTE_SCHED_TYPE_ORDERED &&
2245 !eth_priv->en_ordered) {
2246 struct opr_cfg ocfg;
2248 /* Restoration window size = 256 frames */
2250 /* Restoration window size = 512 frames for LX2 */
2251 if (dpaa2_svr_family == SVR_LX2160A)
2253 /* Auto advance NESN window enabled */
2255 /* Late arrival window size disabled */
2257 /* ORL resource exhaustion advance NESN disabled */
2259 /* Loose ordering enabled */
2261 eth_priv->en_loose_ordered = 1;
2262 /* Strict ordering enabled if explicitly set */
2263 if (getenv("DPAA2_STRICT_ORDERING_ENABLE")) {
2265 eth_priv->en_loose_ordered = 0;
2268 ret = dpni_set_opr(dpni, CMD_PRI_LOW, eth_priv->token,
2269 dpaa2_ethq->tc_index, flow_id,
2270 OPR_OPT_CREATE, &ocfg, 0);
2272 DPAA2_PMD_ERR("Error setting opr: ret: %d\n", ret);
2276 eth_priv->en_ordered = 1;
2279 options |= DPNI_QUEUE_OPT_USER_CTX;
2280 cfg.user_context = (size_t)(dpaa2_ethq);
2282 ret = dpni_set_queue(dpni, CMD_PRI_LOW, eth_priv->token, DPNI_QUEUE_RX,
2283 dpaa2_ethq->tc_index, flow_id, options, &cfg);
2285 DPAA2_PMD_ERR("Error in dpni_set_queue: ret: %d", ret);
2289 memcpy(&dpaa2_ethq->ev, &queue_conf->ev, sizeof(struct rte_event));
2294 int dpaa2_eth_eventq_detach(const struct rte_eth_dev *dev,
2295 int eth_rx_queue_id)
2297 struct dpaa2_dev_priv *eth_priv = dev->data->dev_private;
2298 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
2299 struct dpaa2_queue *dpaa2_ethq = eth_priv->rx_vq[eth_rx_queue_id];
2300 uint8_t flow_id = dpaa2_ethq->flow_id;
2301 struct dpni_queue cfg;
2305 memset(&cfg, 0, sizeof(struct dpni_queue));
2306 options = DPNI_QUEUE_OPT_DEST;
2307 cfg.destination.type = DPNI_DEST_NONE;
2309 ret = dpni_set_queue(dpni, CMD_PRI_LOW, eth_priv->token, DPNI_QUEUE_RX,
2310 dpaa2_ethq->tc_index, flow_id, options, &cfg);
2312 DPAA2_PMD_ERR("Error in dpni_set_queue: ret: %d", ret);
2318 dpaa2_dev_flow_ops_get(struct rte_eth_dev *dev,
2319 const struct rte_flow_ops **ops)
2324 *ops = &dpaa2_flow_ops;
2329 dpaa2_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
2330 struct rte_eth_rxq_info *qinfo)
2332 struct dpaa2_queue *rxq;
2333 struct dpaa2_dev_priv *priv = dev->data->dev_private;
2334 struct fsl_mc_io *dpni = (struct fsl_mc_io *)dev->process_private;
2335 uint16_t max_frame_length;
2337 rxq = (struct dpaa2_queue *)dev->data->rx_queues[queue_id];
2339 qinfo->mp = rxq->mb_pool;
2340 qinfo->scattered_rx = dev->data->scattered_rx;
2341 qinfo->nb_desc = rxq->nb_desc;
2342 if (dpni_get_max_frame_length(dpni, CMD_PRI_LOW, priv->token,
2343 &max_frame_length) == 0)
2344 qinfo->rx_buf_size = max_frame_length;
2346 qinfo->conf.rx_free_thresh = 1;
2347 qinfo->conf.rx_drop_en = 1;
2348 qinfo->conf.rx_deferred_start = 0;
2349 qinfo->conf.offloads = rxq->offloads;
2353 dpaa2_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
2354 struct rte_eth_txq_info *qinfo)
2356 struct dpaa2_queue *txq;
2358 txq = dev->data->tx_queues[queue_id];
2360 qinfo->nb_desc = txq->nb_desc;
2361 qinfo->conf.tx_thresh.pthresh = 0;
2362 qinfo->conf.tx_thresh.hthresh = 0;
2363 qinfo->conf.tx_thresh.wthresh = 0;
2365 qinfo->conf.tx_free_thresh = 0;
2366 qinfo->conf.tx_rs_thresh = 0;
2367 qinfo->conf.offloads = txq->offloads;
2368 qinfo->conf.tx_deferred_start = 0;
2372 dpaa2_tm_ops_get(struct rte_eth_dev *dev __rte_unused, void *ops)
2374 *(const void **)ops = &dpaa2_tm_ops;
2380 rte_pmd_dpaa2_thread_init(void)
2384 if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
2385 ret = dpaa2_affine_qbman_swp();
2388 "Failed to allocate IO portal, tid: %d\n",
2395 static struct eth_dev_ops dpaa2_ethdev_ops = {
2396 .dev_configure = dpaa2_eth_dev_configure,
2397 .dev_start = dpaa2_dev_start,
2398 .dev_stop = dpaa2_dev_stop,
2399 .dev_close = dpaa2_dev_close,
2400 .promiscuous_enable = dpaa2_dev_promiscuous_enable,
2401 .promiscuous_disable = dpaa2_dev_promiscuous_disable,
2402 .allmulticast_enable = dpaa2_dev_allmulticast_enable,
2403 .allmulticast_disable = dpaa2_dev_allmulticast_disable,
2404 .dev_set_link_up = dpaa2_dev_set_link_up,
2405 .dev_set_link_down = dpaa2_dev_set_link_down,
2406 .link_update = dpaa2_dev_link_update,
2407 .stats_get = dpaa2_dev_stats_get,
2408 .xstats_get = dpaa2_dev_xstats_get,
2409 .xstats_get_by_id = dpaa2_xstats_get_by_id,
2410 .xstats_get_names_by_id = dpaa2_xstats_get_names_by_id,
2411 .xstats_get_names = dpaa2_xstats_get_names,
2412 .stats_reset = dpaa2_dev_stats_reset,
2413 .xstats_reset = dpaa2_dev_stats_reset,
2414 .fw_version_get = dpaa2_fw_version_get,
2415 .dev_infos_get = dpaa2_dev_info_get,
2416 .dev_supported_ptypes_get = dpaa2_supported_ptypes_get,
2417 .mtu_set = dpaa2_dev_mtu_set,
2418 .vlan_filter_set = dpaa2_vlan_filter_set,
2419 .vlan_offload_set = dpaa2_vlan_offload_set,
2420 .vlan_tpid_set = dpaa2_vlan_tpid_set,
2421 .rx_queue_setup = dpaa2_dev_rx_queue_setup,
2422 .rx_queue_release = dpaa2_dev_rx_queue_release,
2423 .tx_queue_setup = dpaa2_dev_tx_queue_setup,
2424 .rx_burst_mode_get = dpaa2_dev_rx_burst_mode_get,
2425 .tx_burst_mode_get = dpaa2_dev_tx_burst_mode_get,
2426 .flow_ctrl_get = dpaa2_flow_ctrl_get,
2427 .flow_ctrl_set = dpaa2_flow_ctrl_set,
2428 .mac_addr_add = dpaa2_dev_add_mac_addr,
2429 .mac_addr_remove = dpaa2_dev_remove_mac_addr,
2430 .mac_addr_set = dpaa2_dev_set_mac_addr,
2431 .rss_hash_update = dpaa2_dev_rss_hash_update,
2432 .rss_hash_conf_get = dpaa2_dev_rss_hash_conf_get,
2433 .flow_ops_get = dpaa2_dev_flow_ops_get,
2434 .rxq_info_get = dpaa2_rxq_info_get,
2435 .txq_info_get = dpaa2_txq_info_get,
2436 .tm_ops_get = dpaa2_tm_ops_get,
2437 #if defined(RTE_LIBRTE_IEEE1588)
2438 .timesync_enable = dpaa2_timesync_enable,
2439 .timesync_disable = dpaa2_timesync_disable,
2440 .timesync_read_time = dpaa2_timesync_read_time,
2441 .timesync_write_time = dpaa2_timesync_write_time,
2442 .timesync_adjust_time = dpaa2_timesync_adjust_time,
2443 .timesync_read_rx_timestamp = dpaa2_timesync_read_rx_timestamp,
2444 .timesync_read_tx_timestamp = dpaa2_timesync_read_tx_timestamp,
2448 /* Populate the mac address from physically available (u-boot/firmware) and/or
2449 * one set by higher layers like MC (restool) etc.
2450 * Returns the table of MAC entries (multiple entries)
2453 populate_mac_addr(struct fsl_mc_io *dpni_dev, struct dpaa2_dev_priv *priv,
2454 struct rte_ether_addr *mac_entry)
2457 struct rte_ether_addr phy_mac, prime_mac;
2459 memset(&phy_mac, 0, sizeof(struct rte_ether_addr));
2460 memset(&prime_mac, 0, sizeof(struct rte_ether_addr));
2462 /* Get the physical device MAC address */
2463 ret = dpni_get_port_mac_addr(dpni_dev, CMD_PRI_LOW, priv->token,
2464 phy_mac.addr_bytes);
2466 DPAA2_PMD_ERR("DPNI get physical port MAC failed: %d", ret);
2470 ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW, priv->token,
2471 prime_mac.addr_bytes);
2473 DPAA2_PMD_ERR("DPNI get Prime port MAC failed: %d", ret);
2477 /* Now that both MAC have been obtained, do:
2478 * if not_empty_mac(phy) && phy != Prime, overwrite prime with Phy
2480 * If empty_mac(phy), return prime.
2481 * if both are empty, create random MAC, set as prime and return
2483 if (!rte_is_zero_ether_addr(&phy_mac)) {
2484 /* If the addresses are not same, overwrite prime */
2485 if (!rte_is_same_ether_addr(&phy_mac, &prime_mac)) {
2486 ret = dpni_set_primary_mac_addr(dpni_dev, CMD_PRI_LOW,
2488 phy_mac.addr_bytes);
2490 DPAA2_PMD_ERR("Unable to set MAC Address: %d",
2494 memcpy(&prime_mac, &phy_mac,
2495 sizeof(struct rte_ether_addr));
2497 } else if (rte_is_zero_ether_addr(&prime_mac)) {
2498 /* In case phys and prime, both are zero, create random MAC */
2499 rte_eth_random_addr(prime_mac.addr_bytes);
2500 ret = dpni_set_primary_mac_addr(dpni_dev, CMD_PRI_LOW,
2502 prime_mac.addr_bytes);
2504 DPAA2_PMD_ERR("Unable to set MAC Address: %d", ret);
2509 /* prime_mac the final MAC address */
2510 memcpy(mac_entry, &prime_mac, sizeof(struct rte_ether_addr));
2518 check_devargs_handler(__rte_unused const char *key, const char *value,
2519 __rte_unused void *opaque)
2521 if (strcmp(value, "1"))
2528 dpaa2_get_devargs(struct rte_devargs *devargs, const char *key)
2530 struct rte_kvargs *kvlist;
2535 kvlist = rte_kvargs_parse(devargs->args, NULL);
2539 if (!rte_kvargs_count(kvlist, key)) {
2540 rte_kvargs_free(kvlist);
2544 if (rte_kvargs_process(kvlist, key,
2545 check_devargs_handler, NULL) < 0) {
2546 rte_kvargs_free(kvlist);
2549 rte_kvargs_free(kvlist);
2555 dpaa2_dev_init(struct rte_eth_dev *eth_dev)
2557 struct rte_device *dev = eth_dev->device;
2558 struct rte_dpaa2_device *dpaa2_dev;
2559 struct fsl_mc_io *dpni_dev;
2560 struct dpni_attr attr;
2561 struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
2562 struct dpni_buffer_layout layout;
2565 PMD_INIT_FUNC_TRACE();
2567 dpni_dev = rte_malloc(NULL, sizeof(struct fsl_mc_io), 0);
2569 DPAA2_PMD_ERR("Memory allocation failed for dpni device");
2572 dpni_dev->regs = dpaa2_get_mcp_ptr(MC_PORTAL_INDEX);
2573 eth_dev->process_private = (void *)dpni_dev;
2575 /* For secondary processes, the primary has done all the work */
2576 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
2577 /* In case of secondary, only burst and ops API need to be
2580 eth_dev->dev_ops = &dpaa2_ethdev_ops;
2581 eth_dev->rx_queue_count = dpaa2_dev_rx_queue_count;
2582 if (dpaa2_get_devargs(dev->devargs, DRIVER_LOOPBACK_MODE))
2583 eth_dev->rx_pkt_burst = dpaa2_dev_loopback_rx;
2584 else if (dpaa2_get_devargs(dev->devargs,
2585 DRIVER_NO_PREFETCH_MODE))
2586 eth_dev->rx_pkt_burst = dpaa2_dev_rx;
2588 eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
2589 eth_dev->tx_pkt_burst = dpaa2_dev_tx;
2593 dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device);
2595 hw_id = dpaa2_dev->object_id;
2596 ret = dpni_open(dpni_dev, CMD_PRI_LOW, hw_id, &priv->token);
2599 "Failure in opening dpni@%d with err code %d",
2605 /* Clean the device first */
2606 ret = dpni_reset(dpni_dev, CMD_PRI_LOW, priv->token);
2608 DPAA2_PMD_ERR("Failure cleaning dpni@%d with err code %d",
2613 ret = dpni_get_attributes(dpni_dev, CMD_PRI_LOW, priv->token, &attr);
2616 "Failure in get dpni@%d attribute, err code %d",
2621 priv->num_rx_tc = attr.num_rx_tcs;
2622 priv->qos_entries = attr.qos_entries;
2623 priv->fs_entries = attr.fs_entries;
2624 priv->dist_queues = attr.num_queues;
2626 /* only if the custom CG is enabled */
2627 if (attr.options & DPNI_OPT_CUSTOM_CG)
2628 priv->max_cgs = attr.num_cgs;
2632 for (i = 0; i < priv->max_cgs; i++)
2633 priv->cgid_in_use[i] = 0;
2635 for (i = 0; i < attr.num_rx_tcs; i++)
2636 priv->nb_rx_queues += attr.num_queues;
2638 /* Using number of TX queues as number of TX TCs */
2639 priv->nb_tx_queues = attr.num_tx_tcs;
2641 DPAA2_PMD_DEBUG("RX-TC= %d, rx_queues= %d, tx_queues=%d, max_cgs=%d",
2642 priv->num_rx_tc, priv->nb_rx_queues,
2643 priv->nb_tx_queues, priv->max_cgs);
2645 priv->hw = dpni_dev;
2646 priv->hw_id = hw_id;
2647 priv->options = attr.options;
2648 priv->max_mac_filters = attr.mac_filter_entries;
2649 priv->max_vlan_filters = attr.vlan_filter_entries;
2651 #if defined(RTE_LIBRTE_IEEE1588)
2652 printf("DPDK IEEE1588 is enabled\n");
2653 priv->flags |= DPAA2_TX_CONF_ENABLE;
2655 /* Used with ``fslmc:dpni.1,drv_tx_conf=1`` */
2656 if (dpaa2_get_devargs(dev->devargs, DRIVER_TX_CONF)) {
2657 priv->flags |= DPAA2_TX_CONF_ENABLE;
2658 DPAA2_PMD_INFO("TX_CONF Enabled");
2661 if (dpaa2_get_devargs(dev->devargs, DRIVER_ERROR_QUEUE)) {
2662 dpaa2_enable_err_queue = 1;
2663 DPAA2_PMD_INFO("Enable error queue");
2666 /* Allocate memory for hardware structure for queues */
2667 ret = dpaa2_alloc_rx_tx_queues(eth_dev);
2669 DPAA2_PMD_ERR("Queue allocation Failed");
2673 /* Allocate memory for storing MAC addresses.
2674 * Table of mac_filter_entries size is allocated so that RTE ether lib
2675 * can add MAC entries when rte_eth_dev_mac_addr_add is called.
2677 eth_dev->data->mac_addrs = rte_zmalloc("dpni",
2678 RTE_ETHER_ADDR_LEN * attr.mac_filter_entries, 0);
2679 if (eth_dev->data->mac_addrs == NULL) {
2681 "Failed to allocate %d bytes needed to store MAC addresses",
2682 RTE_ETHER_ADDR_LEN * attr.mac_filter_entries);
2687 ret = populate_mac_addr(dpni_dev, priv, ð_dev->data->mac_addrs[0]);
2689 DPAA2_PMD_ERR("Unable to fetch MAC Address for device");
2690 rte_free(eth_dev->data->mac_addrs);
2691 eth_dev->data->mac_addrs = NULL;
2695 /* ... tx buffer layout ... */
2696 memset(&layout, 0, sizeof(struct dpni_buffer_layout));
2697 if (priv->flags & DPAA2_TX_CONF_ENABLE) {
2698 layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
2699 DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
2700 layout.pass_timestamp = true;
2702 layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
2704 layout.pass_frame_status = 1;
2705 ret = dpni_set_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token,
2706 DPNI_QUEUE_TX, &layout);
2708 DPAA2_PMD_ERR("Error (%d) in setting tx buffer layout", ret);
2712 /* ... tx-conf and error buffer layout ... */
2713 memset(&layout, 0, sizeof(struct dpni_buffer_layout));
2714 if (priv->flags & DPAA2_TX_CONF_ENABLE) {
2715 layout.options = DPNI_BUF_LAYOUT_OPT_TIMESTAMP;
2716 layout.pass_timestamp = true;
2718 layout.options |= DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
2719 layout.pass_frame_status = 1;
2720 ret = dpni_set_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token,
2721 DPNI_QUEUE_TX_CONFIRM, &layout);
2723 DPAA2_PMD_ERR("Error (%d) in setting tx-conf buffer layout",
2728 eth_dev->dev_ops = &dpaa2_ethdev_ops;
2730 if (dpaa2_get_devargs(dev->devargs, DRIVER_LOOPBACK_MODE)) {
2731 eth_dev->rx_pkt_burst = dpaa2_dev_loopback_rx;
2732 DPAA2_PMD_INFO("Loopback mode");
2733 } else if (dpaa2_get_devargs(dev->devargs, DRIVER_NO_PREFETCH_MODE)) {
2734 eth_dev->rx_pkt_burst = dpaa2_dev_rx;
2735 DPAA2_PMD_INFO("No Prefetch mode");
2737 eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
2739 eth_dev->tx_pkt_burst = dpaa2_dev_tx;
2741 /* Init fields w.r.t. classification */
2742 memset(&priv->extract.qos_key_extract, 0,
2743 sizeof(struct dpaa2_key_extract));
2744 priv->extract.qos_extract_param = (size_t)rte_malloc(NULL, 256, 64);
2745 if (!priv->extract.qos_extract_param) {
2746 DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow "
2747 " classification ", ret);
2750 priv->extract.qos_key_extract.key_info.ipv4_src_offset =
2751 IP_ADDRESS_OFFSET_INVALID;
2752 priv->extract.qos_key_extract.key_info.ipv4_dst_offset =
2753 IP_ADDRESS_OFFSET_INVALID;
2754 priv->extract.qos_key_extract.key_info.ipv6_src_offset =
2755 IP_ADDRESS_OFFSET_INVALID;
2756 priv->extract.qos_key_extract.key_info.ipv6_dst_offset =
2757 IP_ADDRESS_OFFSET_INVALID;
2759 for (i = 0; i < MAX_TCS; i++) {
2760 memset(&priv->extract.tc_key_extract[i], 0,
2761 sizeof(struct dpaa2_key_extract));
2762 priv->extract.tc_extract_param[i] =
2763 (size_t)rte_malloc(NULL, 256, 64);
2764 if (!priv->extract.tc_extract_param[i]) {
2765 DPAA2_PMD_ERR(" Error(%d) in allocation resources for flow classification",
2769 priv->extract.tc_key_extract[i].key_info.ipv4_src_offset =
2770 IP_ADDRESS_OFFSET_INVALID;
2771 priv->extract.tc_key_extract[i].key_info.ipv4_dst_offset =
2772 IP_ADDRESS_OFFSET_INVALID;
2773 priv->extract.tc_key_extract[i].key_info.ipv6_src_offset =
2774 IP_ADDRESS_OFFSET_INVALID;
2775 priv->extract.tc_key_extract[i].key_info.ipv6_dst_offset =
2776 IP_ADDRESS_OFFSET_INVALID;
2779 ret = dpni_set_max_frame_length(dpni_dev, CMD_PRI_LOW, priv->token,
2780 RTE_ETHER_MAX_LEN - RTE_ETHER_CRC_LEN
2783 DPAA2_PMD_ERR("Unable to set mtu. check config");
2787 /*TODO To enable soft parser support DPAA2 driver needs to integrate
2788 * with external entity to receive byte code for software sequence
2789 * and same will be offload to the H/W using MC interface.
2790 * Currently it is assumed that DPAA2 driver has byte code by some
2791 * mean and same if offloaded to H/W.
2793 if (getenv("DPAA2_ENABLE_SOFT_PARSER")) {
2794 WRIOP_SS_INITIALIZER(priv);
2795 ret = dpaa2_eth_load_wriop_soft_parser(priv, DPNI_SS_INGRESS);
2797 DPAA2_PMD_ERR(" Error(%d) in loading softparser\n",
2802 ret = dpaa2_eth_enable_wriop_soft_parser(priv,
2805 DPAA2_PMD_ERR(" Error(%d) in enabling softparser\n",
2810 RTE_LOG(INFO, PMD, "%s: netdev created\n", eth_dev->data->name);
2813 dpaa2_dev_close(eth_dev);
2818 int dpaa2_dev_is_dpaa2(struct rte_eth_dev *dev)
2820 return dev->device->driver == &rte_dpaa2_pmd.driver;
2824 rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv,
2825 struct rte_dpaa2_device *dpaa2_dev)
2827 struct rte_eth_dev *eth_dev;
2828 struct dpaa2_dev_priv *dev_priv;
2831 if ((DPAA2_MBUF_HW_ANNOTATION + DPAA2_FD_PTA_SIZE) >
2832 RTE_PKTMBUF_HEADROOM) {
2834 "RTE_PKTMBUF_HEADROOM(%d) shall be > DPAA2 Annotation req(%d)",
2835 RTE_PKTMBUF_HEADROOM,
2836 DPAA2_MBUF_HW_ANNOTATION + DPAA2_FD_PTA_SIZE);
2841 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
2842 eth_dev = rte_eth_dev_allocate(dpaa2_dev->device.name);
2845 dev_priv = rte_zmalloc("ethdev private structure",
2846 sizeof(struct dpaa2_dev_priv),
2847 RTE_CACHE_LINE_SIZE);
2848 if (dev_priv == NULL) {
2850 "Unable to allocate memory for private data");
2851 rte_eth_dev_release_port(eth_dev);
2854 eth_dev->data->dev_private = (void *)dev_priv;
2855 /* Store a pointer to eth_dev in dev_private */
2856 dev_priv->eth_dev = eth_dev;
2858 eth_dev = rte_eth_dev_attach_secondary(dpaa2_dev->device.name);
2860 DPAA2_PMD_DEBUG("returning enodev");
2865 eth_dev->device = &dpaa2_dev->device;
2867 dpaa2_dev->eth_dev = eth_dev;
2868 eth_dev->data->rx_mbuf_alloc_failed = 0;
2870 if (dpaa2_drv->drv_flags & RTE_DPAA2_DRV_INTR_LSC)
2871 eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
2873 eth_dev->data->dev_flags |= RTE_ETH_DEV_AUTOFILL_QUEUE_XSTATS;
2875 /* Invoke PMD device initialization function */
2876 diag = dpaa2_dev_init(eth_dev);
2878 rte_eth_dev_probing_finish(eth_dev);
2882 rte_eth_dev_release_port(eth_dev);
2887 rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
2889 struct rte_eth_dev *eth_dev;
2892 eth_dev = dpaa2_dev->eth_dev;
2893 dpaa2_dev_close(eth_dev);
2894 ret = rte_eth_dev_release_port(eth_dev);
2899 static struct rte_dpaa2_driver rte_dpaa2_pmd = {
2900 .drv_flags = RTE_DPAA2_DRV_INTR_LSC | RTE_DPAA2_DRV_IOVA_AS_VA,
2901 .drv_type = DPAA2_ETH,
2902 .probe = rte_dpaa2_probe,
2903 .remove = rte_dpaa2_remove,
2906 RTE_PMD_REGISTER_DPAA2(NET_DPAA2_PMD_DRIVER_NAME, rte_dpaa2_pmd);
2907 RTE_PMD_REGISTER_PARAM_STRING(NET_DPAA2_PMD_DRIVER_NAME,
2908 DRIVER_LOOPBACK_MODE "=<int> "
2909 DRIVER_NO_PREFETCH_MODE "=<int>"
2910 DRIVER_TX_CONF "=<int>"
2911 DRIVER_ERROR_QUEUE "=<int>");
2912 RTE_LOG_REGISTER_DEFAULT(dpaa2_logtype_pmd, NOTICE);