1 /* SPDX-License-Identifier: BSD-3-Clause
3 * Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
4 * Copyright 2017-2020 NXP
15 #include <sys/types.h>
16 #include <sys/syscall.h>
18 #include <rte_string_fns.h>
19 #include <rte_byteorder.h>
20 #include <rte_common.h>
21 #include <rte_interrupts.h>
23 #include <rte_debug.h>
25 #include <rte_atomic.h>
26 #include <rte_branch_prediction.h>
27 #include <rte_memory.h>
28 #include <rte_tailq.h>
30 #include <rte_alarm.h>
31 #include <rte_ether.h>
32 #include <rte_ethdev_driver.h>
33 #include <rte_malloc.h>
36 #include <rte_dpaa_bus.h>
37 #include <rte_dpaa_logs.h>
38 #include <dpaa_mempool.h>
40 #include <dpaa_ethdev.h>
41 #include <dpaa_rxtx.h>
42 #include <dpaa_flow.h>
43 #include <rte_pmd_dpaa.h>
51 /* Supported Rx offloads */
52 static uint64_t dev_rx_offloads_sup =
53 DEV_RX_OFFLOAD_JUMBO_FRAME |
54 DEV_RX_OFFLOAD_SCATTER;
56 /* Rx offloads which cannot be disabled */
57 static uint64_t dev_rx_offloads_nodis =
58 DEV_RX_OFFLOAD_IPV4_CKSUM |
59 DEV_RX_OFFLOAD_UDP_CKSUM |
60 DEV_RX_OFFLOAD_TCP_CKSUM |
61 DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM |
62 DEV_RX_OFFLOAD_RSS_HASH;
64 /* Supported Tx offloads */
65 static uint64_t dev_tx_offloads_sup =
66 DEV_TX_OFFLOAD_MT_LOCKFREE |
67 DEV_TX_OFFLOAD_MBUF_FAST_FREE;
69 /* Tx offloads which cannot be disabled */
70 static uint64_t dev_tx_offloads_nodis =
71 DEV_TX_OFFLOAD_IPV4_CKSUM |
72 DEV_TX_OFFLOAD_UDP_CKSUM |
73 DEV_TX_OFFLOAD_TCP_CKSUM |
74 DEV_TX_OFFLOAD_SCTP_CKSUM |
75 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM |
76 DEV_TX_OFFLOAD_MULTI_SEGS;
78 /* Keep track of whether QMAN and BMAN have been globally initialized */
79 static int is_global_init;
80 static int fmc_q = 1; /* Indicates the use of static fmc for distribution */
81 static int default_q; /* use default queue - FMC is not executed*/
82 /* At present we only allow up to 4 push mode queues as default - as each of
83 * this queue need dedicated portal and we are short of portals.
85 #define DPAA_MAX_PUSH_MODE_QUEUE 8
86 #define DPAA_DEFAULT_PUSH_MODE_QUEUE 4
88 static int dpaa_push_mode_max_queue = DPAA_DEFAULT_PUSH_MODE_QUEUE;
89 static int dpaa_push_queue_idx; /* Queue index which are in push mode*/
92 /* Per RX FQ Taildrop in frame count */
93 static unsigned int td_threshold = CGR_RX_PERFQ_THRESH;
95 /* Per TX FQ Taildrop in frame count, disabled by default */
96 static unsigned int td_tx_threshold;
98 struct rte_dpaa_xstats_name_off {
99 char name[RTE_ETH_XSTATS_NAME_SIZE];
103 static const struct rte_dpaa_xstats_name_off dpaa_xstats_strings[] = {
105 offsetof(struct dpaa_if_stats, raln)},
107 offsetof(struct dpaa_if_stats, rxpf)},
109 offsetof(struct dpaa_if_stats, rfcs)},
111 offsetof(struct dpaa_if_stats, rvlan)},
113 offsetof(struct dpaa_if_stats, rerr)},
115 offsetof(struct dpaa_if_stats, rdrp)},
117 offsetof(struct dpaa_if_stats, rund)},
119 offsetof(struct dpaa_if_stats, rovr)},
121 offsetof(struct dpaa_if_stats, rfrg)},
123 offsetof(struct dpaa_if_stats, txpf)},
125 offsetof(struct dpaa_if_stats, terr)},
127 offsetof(struct dpaa_if_stats, tvlan)},
129 offsetof(struct dpaa_if_stats, tund)},
132 static struct rte_dpaa_driver rte_dpaa_pmd;
135 dpaa_eth_dev_info(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info);
137 static int dpaa_eth_link_update(struct rte_eth_dev *dev,
138 int wait_to_complete __rte_unused);
140 static void dpaa_interrupt_handler(void *param);
143 dpaa_poll_queue_default_config(struct qm_mcc_initfq *opts)
145 memset(opts, 0, sizeof(struct qm_mcc_initfq));
146 opts->we_mask = QM_INITFQ_WE_FQCTRL | QM_INITFQ_WE_CONTEXTA;
147 opts->fqd.fq_ctrl = QM_FQCTRL_AVOIDBLOCK | QM_FQCTRL_CTXASTASHING |
148 QM_FQCTRL_PREFERINCACHE;
149 opts->fqd.context_a.stashing.exclusive = 0;
150 if (dpaa_svr_family != SVR_LS1046A_FAMILY)
151 opts->fqd.context_a.stashing.annotation_cl =
152 DPAA_IF_RX_ANNOTATION_STASH;
153 opts->fqd.context_a.stashing.data_cl = DPAA_IF_RX_DATA_STASH;
154 opts->fqd.context_a.stashing.context_cl = DPAA_IF_RX_CONTEXT_STASH;
158 dpaa_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
160 uint32_t frame_size = mtu + RTE_ETHER_HDR_LEN + RTE_ETHER_CRC_LEN
162 uint32_t buffsz = dev->data->min_rx_buf_size - RTE_PKTMBUF_HEADROOM;
164 PMD_INIT_FUNC_TRACE();
166 if (mtu < RTE_ETHER_MIN_MTU || frame_size > DPAA_MAX_RX_PKT_LEN)
169 * Refuse mtu that requires the support of scattered packets
170 * when this feature has not been enabled before.
172 if (dev->data->min_rx_buf_size &&
173 !dev->data->scattered_rx && frame_size > buffsz) {
174 DPAA_PMD_ERR("SG not enabled, will not fit in one buffer");
178 /* check <seg size> * <max_seg> >= max_frame */
179 if (dev->data->min_rx_buf_size && dev->data->scattered_rx &&
180 (frame_size > buffsz * DPAA_SGT_MAX_ENTRIES)) {
181 DPAA_PMD_ERR("Too big to fit for Max SG list %d",
182 buffsz * DPAA_SGT_MAX_ENTRIES);
186 if (frame_size > RTE_ETHER_MAX_LEN)
187 dev->data->dev_conf.rxmode.offloads |=
188 DEV_RX_OFFLOAD_JUMBO_FRAME;
190 dev->data->dev_conf.rxmode.offloads &=
191 ~DEV_RX_OFFLOAD_JUMBO_FRAME;
193 dev->data->dev_conf.rxmode.max_rx_pkt_len = frame_size;
195 fman_if_set_maxfrm(dev->process_private, frame_size);
201 dpaa_eth_dev_configure(struct rte_eth_dev *dev)
203 struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
204 uint64_t rx_offloads = eth_conf->rxmode.offloads;
205 uint64_t tx_offloads = eth_conf->txmode.offloads;
206 struct rte_device *rdev = dev->device;
207 struct rte_dpaa_device *dpaa_dev;
208 struct fman_if *fif = dev->process_private;
209 struct __fman_if *__fif;
210 struct rte_intr_handle *intr_handle;
213 PMD_INIT_FUNC_TRACE();
215 dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
216 intr_handle = &dpaa_dev->intr_handle;
217 __fif = container_of(fif, struct __fman_if, __if);
219 /* Rx offloads which are enabled by default */
220 if (dev_rx_offloads_nodis & ~rx_offloads) {
222 "Some of rx offloads enabled by default - requested 0x%" PRIx64
223 " fixed are 0x%" PRIx64,
224 rx_offloads, dev_rx_offloads_nodis);
227 /* Tx offloads which are enabled by default */
228 if (dev_tx_offloads_nodis & ~tx_offloads) {
230 "Some of tx offloads enabled by default - requested 0x%" PRIx64
231 " fixed are 0x%" PRIx64,
232 tx_offloads, dev_tx_offloads_nodis);
235 if (rx_offloads & DEV_RX_OFFLOAD_JUMBO_FRAME) {
238 DPAA_PMD_DEBUG("enabling jumbo");
240 if (dev->data->dev_conf.rxmode.max_rx_pkt_len <=
242 max_len = dev->data->dev_conf.rxmode.max_rx_pkt_len;
244 DPAA_PMD_INFO("enabling jumbo override conf max len=%d "
246 dev->data->dev_conf.rxmode.max_rx_pkt_len,
247 DPAA_MAX_RX_PKT_LEN);
248 max_len = DPAA_MAX_RX_PKT_LEN;
251 fman_if_set_maxfrm(dev->process_private, max_len);
252 dev->data->mtu = max_len
253 - RTE_ETHER_HDR_LEN - RTE_ETHER_CRC_LEN - VLAN_TAG_SIZE;
256 if (rx_offloads & DEV_RX_OFFLOAD_SCATTER) {
257 DPAA_PMD_DEBUG("enabling scatter mode");
258 fman_if_set_sg(dev->process_private, 1);
259 dev->data->scattered_rx = 1;
262 if (!(default_q || fmc_q)) {
263 if (dpaa_fm_config(dev,
264 eth_conf->rx_adv_conf.rss_conf.rss_hf)) {
265 dpaa_write_fm_config_to_file();
266 DPAA_PMD_ERR("FM port configuration: Failed\n");
269 dpaa_write_fm_config_to_file();
272 /* if the interrupts were configured on this devices*/
273 if (intr_handle && intr_handle->fd) {
274 if (dev->data->dev_conf.intr_conf.lsc != 0)
275 rte_intr_callback_register(intr_handle,
276 dpaa_interrupt_handler,
279 ret = dpaa_intr_enable(__fif->node_name, intr_handle->fd);
281 if (dev->data->dev_conf.intr_conf.lsc != 0) {
282 rte_intr_callback_unregister(intr_handle,
283 dpaa_interrupt_handler,
286 printf("Failed to enable interrupt: Not Supported\n");
288 printf("Failed to enable interrupt\n");
290 dev->data->dev_conf.intr_conf.lsc = 0;
291 dev->data->dev_flags &= ~RTE_ETH_DEV_INTR_LSC;
297 static const uint32_t *
298 dpaa_supported_ptypes_get(struct rte_eth_dev *dev)
300 static const uint32_t ptypes[] = {
302 RTE_PTYPE_L2_ETHER_VLAN,
303 RTE_PTYPE_L2_ETHER_ARP,
304 RTE_PTYPE_L3_IPV4_EXT_UNKNOWN,
305 RTE_PTYPE_L3_IPV6_EXT_UNKNOWN,
315 PMD_INIT_FUNC_TRACE();
317 if (dev->rx_pkt_burst == dpaa_eth_queue_rx)
322 static void dpaa_interrupt_handler(void *param)
324 struct rte_eth_dev *dev = param;
325 struct rte_device *rdev = dev->device;
326 struct rte_dpaa_device *dpaa_dev;
327 struct rte_intr_handle *intr_handle;
331 dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
332 intr_handle = &dpaa_dev->intr_handle;
334 bytes_read = read(intr_handle->fd, &buf, sizeof(uint64_t));
336 DPAA_PMD_ERR("Error reading eventfd\n");
337 dpaa_eth_link_update(dev, 0);
338 rte_eth_dev_callback_process(dev, RTE_ETH_EVENT_INTR_LSC, NULL);
341 static int dpaa_eth_dev_start(struct rte_eth_dev *dev)
343 struct dpaa_if *dpaa_intf = dev->data->dev_private;
345 PMD_INIT_FUNC_TRACE();
347 if (!(default_q || fmc_q))
348 dpaa_write_fm_config_to_file();
350 /* Change tx callback to the real one */
351 if (dpaa_intf->cgr_tx)
352 dev->tx_pkt_burst = dpaa_eth_queue_tx_slow;
354 dev->tx_pkt_burst = dpaa_eth_queue_tx;
356 fman_if_enable_rx(dev->process_private);
361 static void dpaa_eth_dev_stop(struct rte_eth_dev *dev)
363 struct fman_if *fif = dev->process_private;
365 PMD_INIT_FUNC_TRACE();
367 if (!fif->is_shared_mac)
368 fman_if_disable_rx(fif);
369 dev->tx_pkt_burst = dpaa_eth_tx_drop_all;
372 static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
374 struct fman_if *fif = dev->process_private;
375 struct __fman_if *__fif;
376 struct rte_device *rdev = dev->device;
377 struct rte_dpaa_device *dpaa_dev;
378 struct rte_intr_handle *intr_handle;
380 PMD_INIT_FUNC_TRACE();
382 dpaa_dev = container_of(rdev, struct rte_dpaa_device, device);
383 intr_handle = &dpaa_dev->intr_handle;
384 __fif = container_of(fif, struct __fman_if, __if);
386 dpaa_eth_dev_stop(dev);
388 if (intr_handle && intr_handle->fd &&
389 dev->data->dev_conf.intr_conf.lsc != 0) {
390 dpaa_intr_disable(__fif->node_name);
391 rte_intr_callback_unregister(intr_handle,
392 dpaa_interrupt_handler,
400 dpaa_fw_version_get(struct rte_eth_dev *dev __rte_unused,
405 FILE *svr_file = NULL;
406 unsigned int svr_ver = 0;
408 PMD_INIT_FUNC_TRACE();
410 svr_file = fopen(DPAA_SOC_ID_FILE, "r");
412 DPAA_PMD_ERR("Unable to open SoC device");
413 return -ENOTSUP; /* Not supported on this infra */
415 if (fscanf(svr_file, "svr:%x", &svr_ver) > 0)
416 dpaa_svr_family = svr_ver & SVR_MASK;
418 DPAA_PMD_ERR("Unable to read SoC device");
422 ret = snprintf(fw_version, fw_size, "SVR:%x-fman-v%x",
423 svr_ver, fman_ip_rev);
424 ret += 1; /* add the size of '\0' */
426 if (fw_size < (uint32_t)ret)
432 static int dpaa_eth_dev_info(struct rte_eth_dev *dev,
433 struct rte_eth_dev_info *dev_info)
435 struct dpaa_if *dpaa_intf = dev->data->dev_private;
436 struct fman_if *fif = dev->process_private;
438 DPAA_PMD_DEBUG(": %s", dpaa_intf->name);
440 dev_info->max_rx_queues = dpaa_intf->nb_rx_queues;
441 dev_info->max_tx_queues = dpaa_intf->nb_tx_queues;
442 dev_info->max_rx_pktlen = DPAA_MAX_RX_PKT_LEN;
443 dev_info->max_mac_addrs = DPAA_MAX_MAC_FILTER;
444 dev_info->max_hash_mac_addrs = 0;
445 dev_info->max_vfs = 0;
446 dev_info->max_vmdq_pools = ETH_16_POOLS;
447 dev_info->flow_type_rss_offloads = DPAA_RSS_OFFLOAD_ALL;
449 if (fif->mac_type == fman_mac_1g) {
450 dev_info->speed_capa = ETH_LINK_SPEED_1G;
451 } else if (fif->mac_type == fman_mac_2_5g) {
452 dev_info->speed_capa = ETH_LINK_SPEED_1G
453 | ETH_LINK_SPEED_2_5G;
454 } else if (fif->mac_type == fman_mac_10g) {
455 dev_info->speed_capa = ETH_LINK_SPEED_1G
456 | ETH_LINK_SPEED_2_5G
457 | ETH_LINK_SPEED_10G;
459 DPAA_PMD_ERR("invalid link_speed: %s, %d",
460 dpaa_intf->name, fif->mac_type);
464 dev_info->rx_offload_capa = dev_rx_offloads_sup |
465 dev_rx_offloads_nodis;
466 dev_info->tx_offload_capa = dev_tx_offloads_sup |
467 dev_tx_offloads_nodis;
468 dev_info->default_rxportconf.burst_size = DPAA_DEF_RX_BURST_SIZE;
469 dev_info->default_txportconf.burst_size = DPAA_DEF_TX_BURST_SIZE;
470 dev_info->default_rxportconf.nb_queues = 1;
471 dev_info->default_txportconf.nb_queues = 1;
472 dev_info->default_txportconf.ring_size = CGR_TX_CGR_THRESH;
473 dev_info->default_rxportconf.ring_size = CGR_RX_PERFQ_THRESH;
479 dpaa_dev_rx_burst_mode_get(struct rte_eth_dev *dev,
480 __rte_unused uint16_t queue_id,
481 struct rte_eth_burst_mode *mode)
483 struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
486 const struct burst_info {
489 } rx_offload_map[] = {
490 {DEV_RX_OFFLOAD_JUMBO_FRAME, " Jumbo frame,"},
491 {DEV_RX_OFFLOAD_SCATTER, " Scattered,"},
492 {DEV_RX_OFFLOAD_IPV4_CKSUM, " IPV4 csum,"},
493 {DEV_RX_OFFLOAD_UDP_CKSUM, " UDP csum,"},
494 {DEV_RX_OFFLOAD_TCP_CKSUM, " TCP csum,"},
495 {DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM, " Outer IPV4 csum,"},
496 {DEV_RX_OFFLOAD_RSS_HASH, " RSS,"}
499 /* Update Rx offload info */
500 for (i = 0; i < RTE_DIM(rx_offload_map); i++) {
501 if (eth_conf->rxmode.offloads & rx_offload_map[i].flags) {
502 snprintf(mode->info, sizeof(mode->info), "%s",
503 rx_offload_map[i].output);
512 dpaa_dev_tx_burst_mode_get(struct rte_eth_dev *dev,
513 __rte_unused uint16_t queue_id,
514 struct rte_eth_burst_mode *mode)
516 struct rte_eth_conf *eth_conf = &dev->data->dev_conf;
519 const struct burst_info {
522 } tx_offload_map[] = {
523 {DEV_TX_OFFLOAD_MT_LOCKFREE, " MT lockfree,"},
524 {DEV_TX_OFFLOAD_MBUF_FAST_FREE, " MBUF free disable,"},
525 {DEV_TX_OFFLOAD_IPV4_CKSUM, " IPV4 csum,"},
526 {DEV_TX_OFFLOAD_UDP_CKSUM, " UDP csum,"},
527 {DEV_TX_OFFLOAD_TCP_CKSUM, " TCP csum,"},
528 {DEV_TX_OFFLOAD_SCTP_CKSUM, " SCTP csum,"},
529 {DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM, " Outer IPV4 csum,"},
530 {DEV_TX_OFFLOAD_MULTI_SEGS, " Scattered,"}
533 /* Update Tx offload info */
534 for (i = 0; i < RTE_DIM(tx_offload_map); i++) {
535 if (eth_conf->txmode.offloads & tx_offload_map[i].flags) {
536 snprintf(mode->info, sizeof(mode->info), "%s",
537 tx_offload_map[i].output);
545 static int dpaa_eth_link_update(struct rte_eth_dev *dev,
546 int wait_to_complete __rte_unused)
548 struct dpaa_if *dpaa_intf = dev->data->dev_private;
549 struct rte_eth_link *link = &dev->data->dev_link;
550 struct fman_if *fif = dev->process_private;
551 struct __fman_if *__fif = container_of(fif, struct __fman_if, __if);
554 PMD_INIT_FUNC_TRACE();
556 if (fif->mac_type == fman_mac_1g)
557 link->link_speed = ETH_SPEED_NUM_1G;
558 else if (fif->mac_type == fman_mac_2_5g)
559 link->link_speed = ETH_SPEED_NUM_2_5G;
560 else if (fif->mac_type == fman_mac_10g)
561 link->link_speed = ETH_SPEED_NUM_10G;
563 DPAA_PMD_ERR("invalid link_speed: %s, %d",
564 dpaa_intf->name, fif->mac_type);
566 if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC) {
567 ret = dpaa_get_link_status(__fif->node_name);
570 link->link_status = ret;
572 link->link_status = dpaa_intf->valid;
575 link->link_duplex = ETH_LINK_FULL_DUPLEX;
576 link->link_autoneg = ETH_LINK_AUTONEG;
578 DPAA_PMD_INFO("Port %d Link is %s\n", dev->data->port_id,
579 link->link_status ? "Up" : "Down");
583 static int dpaa_eth_stats_get(struct rte_eth_dev *dev,
584 struct rte_eth_stats *stats)
586 PMD_INIT_FUNC_TRACE();
588 fman_if_stats_get(dev->process_private, stats);
592 static int dpaa_eth_stats_reset(struct rte_eth_dev *dev)
594 PMD_INIT_FUNC_TRACE();
596 fman_if_stats_reset(dev->process_private);
602 dpaa_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats,
605 unsigned int i = 0, num = RTE_DIM(dpaa_xstats_strings);
606 uint64_t values[sizeof(struct dpaa_if_stats) / 8];
614 fman_if_stats_get_all(dev->process_private, values,
615 sizeof(struct dpaa_if_stats) / 8);
617 for (i = 0; i < num; i++) {
619 xstats[i].value = values[dpaa_xstats_strings[i].offset / 8];
625 dpaa_xstats_get_names(__rte_unused struct rte_eth_dev *dev,
626 struct rte_eth_xstat_name *xstats_names,
629 unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings);
631 if (limit < stat_cnt)
634 if (xstats_names != NULL)
635 for (i = 0; i < stat_cnt; i++)
636 strlcpy(xstats_names[i].name,
637 dpaa_xstats_strings[i].name,
638 sizeof(xstats_names[i].name));
644 dpaa_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids,
645 uint64_t *values, unsigned int n)
647 unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings);
648 uint64_t values_copy[sizeof(struct dpaa_if_stats) / 8];
657 fman_if_stats_get_all(dev->process_private, values_copy,
658 sizeof(struct dpaa_if_stats) / 8);
660 for (i = 0; i < stat_cnt; i++)
662 values_copy[dpaa_xstats_strings[i].offset / 8];
667 dpaa_xstats_get_by_id(dev, NULL, values_copy, stat_cnt);
669 for (i = 0; i < n; i++) {
670 if (ids[i] >= stat_cnt) {
671 DPAA_PMD_ERR("id value isn't valid");
674 values[i] = values_copy[ids[i]];
680 dpaa_xstats_get_names_by_id(
681 struct rte_eth_dev *dev,
682 struct rte_eth_xstat_name *xstats_names,
686 unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings);
687 struct rte_eth_xstat_name xstats_names_copy[stat_cnt];
690 return dpaa_xstats_get_names(dev, xstats_names, limit);
692 dpaa_xstats_get_names(dev, xstats_names_copy, limit);
694 for (i = 0; i < limit; i++) {
695 if (ids[i] >= stat_cnt) {
696 DPAA_PMD_ERR("id value isn't valid");
699 strcpy(xstats_names[i].name, xstats_names_copy[ids[i]].name);
704 static int dpaa_eth_promiscuous_enable(struct rte_eth_dev *dev)
706 PMD_INIT_FUNC_TRACE();
708 fman_if_promiscuous_enable(dev->process_private);
713 static int dpaa_eth_promiscuous_disable(struct rte_eth_dev *dev)
715 PMD_INIT_FUNC_TRACE();
717 fman_if_promiscuous_disable(dev->process_private);
722 static int dpaa_eth_multicast_enable(struct rte_eth_dev *dev)
724 PMD_INIT_FUNC_TRACE();
726 fman_if_set_mcast_filter_table(dev->process_private);
731 static int dpaa_eth_multicast_disable(struct rte_eth_dev *dev)
733 PMD_INIT_FUNC_TRACE();
735 fman_if_reset_mcast_filter_table(dev->process_private);
740 static void dpaa_fman_if_pool_setup(struct rte_eth_dev *dev)
742 struct dpaa_if *dpaa_intf = dev->data->dev_private;
743 struct fman_if_ic_params icp;
747 memset(&icp, 0, sizeof(icp));
748 /* set ICEOF for to the default value , which is 0*/
749 icp.iciof = DEFAULT_ICIOF;
750 icp.iceof = DEFAULT_RX_ICEOF;
751 icp.icsz = DEFAULT_ICSZ;
752 fman_if_set_ic_params(dev->process_private, &icp);
754 fd_offset = RTE_PKTMBUF_HEADROOM + DPAA_HW_BUF_RESERVE;
755 fman_if_set_fdoff(dev->process_private, fd_offset);
757 /* Buffer pool size should be equal to Dataroom Size*/
758 bp_size = rte_pktmbuf_data_room_size(dpaa_intf->bp_info->mp);
760 fman_if_set_bp(dev->process_private,
761 dpaa_intf->bp_info->mp->size,
762 dpaa_intf->bp_info->bpid, bp_size);
765 static inline int dpaa_eth_rx_queue_bp_check(struct rte_eth_dev *dev,
766 int8_t vsp_id, uint32_t bpid)
768 struct dpaa_if *dpaa_intf = dev->data->dev_private;
769 struct fman_if *fif = dev->process_private;
771 if (fif->num_profiles) {
773 vsp_id = fif->base_profile_id;
779 if (dpaa_intf->vsp_bpid[vsp_id] &&
780 bpid != dpaa_intf->vsp_bpid[vsp_id]) {
781 DPAA_PMD_ERR("Various MPs are assigned to RXQs with same VSP");
790 int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
792 unsigned int socket_id __rte_unused,
793 const struct rte_eth_rxconf *rx_conf,
794 struct rte_mempool *mp)
796 struct dpaa_if *dpaa_intf = dev->data->dev_private;
797 struct fman_if *fif = dev->process_private;
798 struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_idx];
799 struct qm_mcc_initfq opts = {0};
802 u32 buffsz = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
804 PMD_INIT_FUNC_TRACE();
806 if (queue_idx >= dev->data->nb_rx_queues) {
807 rte_errno = EOVERFLOW;
808 DPAA_PMD_ERR("%p: queue index out of range (%u >= %u)",
809 (void *)dev, queue_idx, dev->data->nb_rx_queues);
813 /* Rx deferred start is not supported */
814 if (rx_conf->rx_deferred_start) {
815 DPAA_PMD_ERR("%p:Rx deferred start not supported", (void *)dev);
818 rxq->nb_desc = UINT16_MAX;
819 rxq->offloads = rx_conf->offloads;
821 DPAA_PMD_INFO("Rx queue setup for queue index: %d fq_id (0x%x)",
822 queue_idx, rxq->fqid);
824 if (!fif->num_profiles) {
825 if (dpaa_intf->bp_info && dpaa_intf->bp_info->bp &&
826 dpaa_intf->bp_info->mp != mp) {
827 DPAA_PMD_WARN("Multiple pools on same interface not"
832 if (dpaa_eth_rx_queue_bp_check(dev, rxq->vsp_id,
833 DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid)) {
838 /* Max packet can fit in single buffer */
839 if (dev->data->dev_conf.rxmode.max_rx_pkt_len <= buffsz) {
841 } else if (dev->data->dev_conf.rxmode.offloads &
842 DEV_RX_OFFLOAD_SCATTER) {
843 if (dev->data->dev_conf.rxmode.max_rx_pkt_len >
844 buffsz * DPAA_SGT_MAX_ENTRIES) {
845 DPAA_PMD_ERR("max RxPkt size %d too big to fit "
847 dev->data->dev_conf.rxmode.max_rx_pkt_len,
848 buffsz * DPAA_SGT_MAX_ENTRIES);
849 rte_errno = EOVERFLOW;
853 DPAA_PMD_WARN("The requested maximum Rx packet size (%u) is"
854 " larger than a single mbuf (%u) and scattered"
855 " mode has not been requested",
856 dev->data->dev_conf.rxmode.max_rx_pkt_len,
857 buffsz - RTE_PKTMBUF_HEADROOM);
860 dpaa_intf->bp_info = DPAA_MEMPOOL_TO_POOL_INFO(mp);
862 /* For shared interface, it's done in kernel, skip.*/
863 if (!fif->is_shared_mac)
864 dpaa_fman_if_pool_setup(dev);
866 if (fif->num_profiles) {
867 int8_t vsp_id = rxq->vsp_id;
870 ret = dpaa_port_vsp_update(dpaa_intf, fmc_q, vsp_id,
871 DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid,
874 DPAA_PMD_ERR("dpaa_port_vsp_update failed");
878 DPAA_PMD_INFO("Base profile is associated to"
879 " RXQ fqid:%d\r\n", rxq->fqid);
880 if (fif->is_shared_mac) {
881 DPAA_PMD_ERR("Fatal: Base profile is associated"
882 " to shared interface on DPDK.");
885 dpaa_intf->vsp_bpid[fif->base_profile_id] =
886 DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid;
889 dpaa_intf->vsp_bpid[0] =
890 DPAA_MEMPOOL_TO_POOL_INFO(mp)->bpid;
893 dpaa_intf->valid = 1;
894 DPAA_PMD_DEBUG("if:%s sg_on = %d, max_frm =%d", dpaa_intf->name,
895 fman_if_get_sg_enable(fif),
896 dev->data->dev_conf.rxmode.max_rx_pkt_len);
897 /* checking if push mode only, no error check for now */
898 if (!rxq->is_static &&
899 dpaa_push_mode_max_queue > dpaa_push_queue_idx) {
900 struct qman_portal *qp;
903 dpaa_push_queue_idx++;
904 opts.we_mask = QM_INITFQ_WE_FQCTRL | QM_INITFQ_WE_CONTEXTA;
905 opts.fqd.fq_ctrl = QM_FQCTRL_AVOIDBLOCK |
906 QM_FQCTRL_CTXASTASHING |
907 QM_FQCTRL_PREFERINCACHE;
908 opts.fqd.context_a.stashing.exclusive = 0;
909 /* In muticore scenario stashing becomes a bottleneck on LS1046.
910 * So do not enable stashing in this case
912 if (dpaa_svr_family != SVR_LS1046A_FAMILY)
913 opts.fqd.context_a.stashing.annotation_cl =
914 DPAA_IF_RX_ANNOTATION_STASH;
915 opts.fqd.context_a.stashing.data_cl = DPAA_IF_RX_DATA_STASH;
916 opts.fqd.context_a.stashing.context_cl =
917 DPAA_IF_RX_CONTEXT_STASH;
919 /*Create a channel and associate given queue with the channel*/
920 qman_alloc_pool_range((u32 *)&rxq->ch_id, 1, 1, 0);
921 opts.we_mask = opts.we_mask | QM_INITFQ_WE_DESTWQ;
922 opts.fqd.dest.channel = rxq->ch_id;
923 opts.fqd.dest.wq = DPAA_IF_RX_PRIORITY;
924 flags = QMAN_INITFQ_FLAG_SCHED;
926 /* Configure tail drop */
927 if (dpaa_intf->cgr_rx) {
928 opts.we_mask |= QM_INITFQ_WE_CGID;
929 opts.fqd.cgid = dpaa_intf->cgr_rx[queue_idx].cgrid;
930 opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
932 ret = qman_init_fq(rxq, flags, &opts);
934 DPAA_PMD_ERR("Channel/Q association failed. fqid 0x%x "
935 "ret:%d(%s)", rxq->fqid, ret, strerror(ret));
938 if (dpaa_svr_family == SVR_LS1043A_FAMILY) {
939 rxq->cb.dqrr_dpdk_pull_cb = dpaa_rx_cb_no_prefetch;
941 rxq->cb.dqrr_dpdk_pull_cb = dpaa_rx_cb;
942 rxq->cb.dqrr_prepare = dpaa_rx_cb_prepare;
945 rxq->is_static = true;
947 /* Allocate qman specific portals */
948 qp = fsl_qman_fq_portal_create(&q_fd);
950 DPAA_PMD_ERR("Unable to alloc fq portal");
955 /* Set up the device interrupt handler */
956 if (!dev->intr_handle) {
957 struct rte_dpaa_device *dpaa_dev;
958 struct rte_device *rdev = dev->device;
960 dpaa_dev = container_of(rdev, struct rte_dpaa_device,
962 dev->intr_handle = &dpaa_dev->intr_handle;
963 dev->intr_handle->intr_vec = rte_zmalloc(NULL,
964 dpaa_push_mode_max_queue, 0);
965 if (!dev->intr_handle->intr_vec) {
966 DPAA_PMD_ERR("intr_vec alloc failed");
969 dev->intr_handle->nb_efd = dpaa_push_mode_max_queue;
970 dev->intr_handle->max_intr = dpaa_push_mode_max_queue;
973 dev->intr_handle->type = RTE_INTR_HANDLE_EXT;
974 dev->intr_handle->intr_vec[queue_idx] = queue_idx + 1;
975 dev->intr_handle->efds[queue_idx] = q_fd;
978 rxq->bp_array = rte_dpaa_bpid_info;
979 dev->data->rx_queues[queue_idx] = rxq;
981 /* configure the CGR size as per the desc size */
982 if (dpaa_intf->cgr_rx) {
983 struct qm_mcc_initcgr cgr_opts = {0};
985 rxq->nb_desc = nb_desc;
986 /* Enable tail drop with cgr on this queue */
987 qm_cgr_cs_thres_set64(&cgr_opts.cgr.cs_thres, nb_desc, 0);
988 ret = qman_modify_cgr(dpaa_intf->cgr_rx, 0, &cgr_opts);
991 "rx taildrop modify fail on fqid %d (ret=%d)",
1000 dpaa_eth_eventq_attach(const struct rte_eth_dev *dev,
1001 int eth_rx_queue_id,
1003 const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
1007 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1008 struct qman_fq *rxq = &dpaa_intf->rx_queues[eth_rx_queue_id];
1009 struct qm_mcc_initfq opts = {0};
1011 if (dpaa_push_mode_max_queue)
1012 DPAA_PMD_WARN("PUSH mode q and EVENTDEV are not compatible\n"
1013 "PUSH mode already enabled for first %d queues.\n"
1014 "To disable set DPAA_PUSH_QUEUES_NUMBER to 0\n",
1015 dpaa_push_mode_max_queue);
1017 dpaa_poll_queue_default_config(&opts);
1019 switch (queue_conf->ev.sched_type) {
1020 case RTE_SCHED_TYPE_ATOMIC:
1021 opts.fqd.fq_ctrl |= QM_FQCTRL_HOLDACTIVE;
1022 /* Reset FQCTRL_AVOIDBLOCK bit as it is unnecessary
1023 * configuration with HOLD_ACTIVE setting
1025 opts.fqd.fq_ctrl &= (~QM_FQCTRL_AVOIDBLOCK);
1026 rxq->cb.dqrr_dpdk_cb = dpaa_rx_cb_atomic;
1028 case RTE_SCHED_TYPE_ORDERED:
1029 DPAA_PMD_ERR("Ordered queue schedule type is not supported\n");
1032 opts.fqd.fq_ctrl |= QM_FQCTRL_AVOIDBLOCK;
1033 rxq->cb.dqrr_dpdk_cb = dpaa_rx_cb_parallel;
1037 opts.we_mask = opts.we_mask | QM_INITFQ_WE_DESTWQ;
1038 opts.fqd.dest.channel = ch_id;
1039 opts.fqd.dest.wq = queue_conf->ev.priority;
1041 if (dpaa_intf->cgr_rx) {
1042 opts.we_mask |= QM_INITFQ_WE_CGID;
1043 opts.fqd.cgid = dpaa_intf->cgr_rx[eth_rx_queue_id].cgrid;
1044 opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
1047 flags = QMAN_INITFQ_FLAG_SCHED;
1049 ret = qman_init_fq(rxq, flags, &opts);
1051 DPAA_PMD_ERR("Ev-Channel/Q association failed. fqid 0x%x "
1052 "ret:%d(%s)", rxq->fqid, ret, strerror(ret));
1056 /* copy configuration which needs to be filled during dequeue */
1057 memcpy(&rxq->ev, &queue_conf->ev, sizeof(struct rte_event));
1058 dev->data->rx_queues[eth_rx_queue_id] = rxq;
1064 dpaa_eth_eventq_detach(const struct rte_eth_dev *dev,
1065 int eth_rx_queue_id)
1067 struct qm_mcc_initfq opts;
1070 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1071 struct qman_fq *rxq = &dpaa_intf->rx_queues[eth_rx_queue_id];
1073 dpaa_poll_queue_default_config(&opts);
1075 if (dpaa_intf->cgr_rx) {
1076 opts.we_mask |= QM_INITFQ_WE_CGID;
1077 opts.fqd.cgid = dpaa_intf->cgr_rx[eth_rx_queue_id].cgrid;
1078 opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
1081 ret = qman_init_fq(rxq, flags, &opts);
1083 DPAA_PMD_ERR("init rx fqid %d failed with ret: %d",
1087 rxq->cb.dqrr_dpdk_cb = NULL;
1088 dev->data->rx_queues[eth_rx_queue_id] = NULL;
1094 void dpaa_eth_rx_queue_release(void *rxq __rte_unused)
1096 PMD_INIT_FUNC_TRACE();
1100 int dpaa_eth_tx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
1101 uint16_t nb_desc __rte_unused,
1102 unsigned int socket_id __rte_unused,
1103 const struct rte_eth_txconf *tx_conf)
1105 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1106 struct qman_fq *txq = &dpaa_intf->tx_queues[queue_idx];
1108 PMD_INIT_FUNC_TRACE();
1110 /* Tx deferred start is not supported */
1111 if (tx_conf->tx_deferred_start) {
1112 DPAA_PMD_ERR("%p:Tx deferred start not supported", (void *)dev);
1115 txq->nb_desc = UINT16_MAX;
1116 txq->offloads = tx_conf->offloads;
1118 if (queue_idx >= dev->data->nb_tx_queues) {
1119 rte_errno = EOVERFLOW;
1120 DPAA_PMD_ERR("%p: queue index out of range (%u >= %u)",
1121 (void *)dev, queue_idx, dev->data->nb_tx_queues);
1125 DPAA_PMD_INFO("Tx queue setup for queue index: %d fq_id (0x%x)",
1126 queue_idx, txq->fqid);
1127 dev->data->tx_queues[queue_idx] = txq;
1132 static void dpaa_eth_tx_queue_release(void *txq __rte_unused)
1134 PMD_INIT_FUNC_TRACE();
1138 dpaa_dev_rx_queue_count(struct rte_eth_dev *dev, uint16_t rx_queue_id)
1140 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1141 struct qman_fq *rxq = &dpaa_intf->rx_queues[rx_queue_id];
1144 PMD_INIT_FUNC_TRACE();
1146 if (qman_query_fq_frm_cnt(rxq, &frm_cnt) == 0) {
1147 DPAA_PMD_DEBUG("RX frame count for q(%d) is %u",
1148 rx_queue_id, frm_cnt);
1153 static int dpaa_link_down(struct rte_eth_dev *dev)
1155 struct fman_if *fif = dev->process_private;
1156 struct __fman_if *__fif;
1158 PMD_INIT_FUNC_TRACE();
1160 __fif = container_of(fif, struct __fman_if, __if);
1162 if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
1163 dpaa_update_link_status(__fif->node_name, ETH_LINK_DOWN);
1165 dpaa_eth_dev_stop(dev);
1169 static int dpaa_link_up(struct rte_eth_dev *dev)
1171 struct fman_if *fif = dev->process_private;
1172 struct __fman_if *__fif;
1174 PMD_INIT_FUNC_TRACE();
1176 __fif = container_of(fif, struct __fman_if, __if);
1178 if (dev->data->dev_flags & RTE_ETH_DEV_INTR_LSC)
1179 dpaa_update_link_status(__fif->node_name, ETH_LINK_UP);
1181 dpaa_eth_dev_start(dev);
1186 dpaa_flow_ctrl_set(struct rte_eth_dev *dev,
1187 struct rte_eth_fc_conf *fc_conf)
1189 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1190 struct rte_eth_fc_conf *net_fc;
1192 PMD_INIT_FUNC_TRACE();
1194 if (!(dpaa_intf->fc_conf)) {
1195 dpaa_intf->fc_conf = rte_zmalloc(NULL,
1196 sizeof(struct rte_eth_fc_conf), MAX_CACHELINE);
1197 if (!dpaa_intf->fc_conf) {
1198 DPAA_PMD_ERR("unable to save flow control info");
1202 net_fc = dpaa_intf->fc_conf;
1204 if (fc_conf->high_water < fc_conf->low_water) {
1205 DPAA_PMD_ERR("Incorrect Flow Control Configuration");
1209 if (fc_conf->mode == RTE_FC_NONE) {
1211 } else if (fc_conf->mode == RTE_FC_TX_PAUSE ||
1212 fc_conf->mode == RTE_FC_FULL) {
1213 fman_if_set_fc_threshold(dev->process_private,
1214 fc_conf->high_water,
1216 dpaa_intf->bp_info->bpid);
1217 if (fc_conf->pause_time)
1218 fman_if_set_fc_quanta(dev->process_private,
1219 fc_conf->pause_time);
1222 /* Save the information in dpaa device */
1223 net_fc->pause_time = fc_conf->pause_time;
1224 net_fc->high_water = fc_conf->high_water;
1225 net_fc->low_water = fc_conf->low_water;
1226 net_fc->send_xon = fc_conf->send_xon;
1227 net_fc->mac_ctrl_frame_fwd = fc_conf->mac_ctrl_frame_fwd;
1228 net_fc->mode = fc_conf->mode;
1229 net_fc->autoneg = fc_conf->autoneg;
1235 dpaa_flow_ctrl_get(struct rte_eth_dev *dev,
1236 struct rte_eth_fc_conf *fc_conf)
1238 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1239 struct rte_eth_fc_conf *net_fc = dpaa_intf->fc_conf;
1242 PMD_INIT_FUNC_TRACE();
1245 fc_conf->pause_time = net_fc->pause_time;
1246 fc_conf->high_water = net_fc->high_water;
1247 fc_conf->low_water = net_fc->low_water;
1248 fc_conf->send_xon = net_fc->send_xon;
1249 fc_conf->mac_ctrl_frame_fwd = net_fc->mac_ctrl_frame_fwd;
1250 fc_conf->mode = net_fc->mode;
1251 fc_conf->autoneg = net_fc->autoneg;
1254 ret = fman_if_get_fc_threshold(dev->process_private);
1256 fc_conf->mode = RTE_FC_TX_PAUSE;
1257 fc_conf->pause_time =
1258 fman_if_get_fc_quanta(dev->process_private);
1260 fc_conf->mode = RTE_FC_NONE;
1267 dpaa_dev_add_mac_addr(struct rte_eth_dev *dev,
1268 struct rte_ether_addr *addr,
1270 __rte_unused uint32_t pool)
1274 PMD_INIT_FUNC_TRACE();
1276 ret = fman_if_add_mac_addr(dev->process_private,
1277 addr->addr_bytes, index);
1280 DPAA_PMD_ERR("Adding the MAC ADDR failed: err = %d", ret);
1285 dpaa_dev_remove_mac_addr(struct rte_eth_dev *dev,
1288 PMD_INIT_FUNC_TRACE();
1290 fman_if_clear_mac_addr(dev->process_private, index);
1294 dpaa_dev_set_mac_addr(struct rte_eth_dev *dev,
1295 struct rte_ether_addr *addr)
1299 PMD_INIT_FUNC_TRACE();
1301 ret = fman_if_add_mac_addr(dev->process_private, addr->addr_bytes, 0);
1303 DPAA_PMD_ERR("Setting the MAC ADDR failed %d", ret);
1309 dpaa_dev_rss_hash_update(struct rte_eth_dev *dev,
1310 struct rte_eth_rss_conf *rss_conf)
1312 struct rte_eth_dev_data *data = dev->data;
1313 struct rte_eth_conf *eth_conf = &data->dev_conf;
1315 PMD_INIT_FUNC_TRACE();
1317 if (!(default_q || fmc_q)) {
1318 if (dpaa_fm_config(dev, rss_conf->rss_hf)) {
1319 DPAA_PMD_ERR("FM port configuration: Failed\n");
1322 eth_conf->rx_adv_conf.rss_conf.rss_hf = rss_conf->rss_hf;
1324 DPAA_PMD_ERR("Function not supported\n");
1331 dpaa_dev_rss_hash_conf_get(struct rte_eth_dev *dev,
1332 struct rte_eth_rss_conf *rss_conf)
1334 struct rte_eth_dev_data *data = dev->data;
1335 struct rte_eth_conf *eth_conf = &data->dev_conf;
1337 /* dpaa does not support rss_key, so length should be 0*/
1338 rss_conf->rss_key_len = 0;
1339 rss_conf->rss_hf = eth_conf->rx_adv_conf.rss_conf.rss_hf;
1343 static int dpaa_dev_queue_intr_enable(struct rte_eth_dev *dev,
1346 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1347 struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_id];
1349 if (!rxq->is_static)
1352 return qman_fq_portal_irqsource_add(rxq->qp, QM_PIRQ_DQRI);
1355 static int dpaa_dev_queue_intr_disable(struct rte_eth_dev *dev,
1358 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1359 struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_id];
1363 if (!rxq->is_static)
1366 qman_fq_portal_irqsource_remove(rxq->qp, ~0);
1368 temp1 = read(rxq->q_fd, &temp, sizeof(temp));
1369 if (temp1 != sizeof(temp))
1370 DPAA_PMD_ERR("irq read error");
1372 qman_fq_portal_thread_irq(rxq->qp);
1378 dpaa_rxq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1379 struct rte_eth_rxq_info *qinfo)
1381 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1382 struct qman_fq *rxq;
1384 rxq = dev->data->rx_queues[queue_id];
1386 qinfo->mp = dpaa_intf->bp_info->mp;
1387 qinfo->scattered_rx = dev->data->scattered_rx;
1388 qinfo->nb_desc = rxq->nb_desc;
1389 qinfo->conf.rx_free_thresh = 1;
1390 qinfo->conf.rx_drop_en = 1;
1391 qinfo->conf.rx_deferred_start = 0;
1392 qinfo->conf.offloads = rxq->offloads;
1396 dpaa_txq_info_get(struct rte_eth_dev *dev, uint16_t queue_id,
1397 struct rte_eth_txq_info *qinfo)
1399 struct qman_fq *txq;
1401 txq = dev->data->tx_queues[queue_id];
1403 qinfo->nb_desc = txq->nb_desc;
1404 qinfo->conf.tx_thresh.pthresh = 0;
1405 qinfo->conf.tx_thresh.hthresh = 0;
1406 qinfo->conf.tx_thresh.wthresh = 0;
1408 qinfo->conf.tx_free_thresh = 0;
1409 qinfo->conf.tx_rs_thresh = 0;
1410 qinfo->conf.offloads = txq->offloads;
1411 qinfo->conf.tx_deferred_start = 0;
1414 static struct eth_dev_ops dpaa_devops = {
1415 .dev_configure = dpaa_eth_dev_configure,
1416 .dev_start = dpaa_eth_dev_start,
1417 .dev_stop = dpaa_eth_dev_stop,
1418 .dev_close = dpaa_eth_dev_close,
1419 .dev_infos_get = dpaa_eth_dev_info,
1420 .dev_supported_ptypes_get = dpaa_supported_ptypes_get,
1422 .rx_queue_setup = dpaa_eth_rx_queue_setup,
1423 .tx_queue_setup = dpaa_eth_tx_queue_setup,
1424 .rx_queue_release = dpaa_eth_rx_queue_release,
1425 .tx_queue_release = dpaa_eth_tx_queue_release,
1426 .rx_burst_mode_get = dpaa_dev_rx_burst_mode_get,
1427 .tx_burst_mode_get = dpaa_dev_tx_burst_mode_get,
1428 .rxq_info_get = dpaa_rxq_info_get,
1429 .txq_info_get = dpaa_txq_info_get,
1431 .flow_ctrl_get = dpaa_flow_ctrl_get,
1432 .flow_ctrl_set = dpaa_flow_ctrl_set,
1434 .link_update = dpaa_eth_link_update,
1435 .stats_get = dpaa_eth_stats_get,
1436 .xstats_get = dpaa_dev_xstats_get,
1437 .xstats_get_by_id = dpaa_xstats_get_by_id,
1438 .xstats_get_names_by_id = dpaa_xstats_get_names_by_id,
1439 .xstats_get_names = dpaa_xstats_get_names,
1440 .xstats_reset = dpaa_eth_stats_reset,
1441 .stats_reset = dpaa_eth_stats_reset,
1442 .promiscuous_enable = dpaa_eth_promiscuous_enable,
1443 .promiscuous_disable = dpaa_eth_promiscuous_disable,
1444 .allmulticast_enable = dpaa_eth_multicast_enable,
1445 .allmulticast_disable = dpaa_eth_multicast_disable,
1446 .mtu_set = dpaa_mtu_set,
1447 .dev_set_link_down = dpaa_link_down,
1448 .dev_set_link_up = dpaa_link_up,
1449 .mac_addr_add = dpaa_dev_add_mac_addr,
1450 .mac_addr_remove = dpaa_dev_remove_mac_addr,
1451 .mac_addr_set = dpaa_dev_set_mac_addr,
1453 .fw_version_get = dpaa_fw_version_get,
1455 .rx_queue_intr_enable = dpaa_dev_queue_intr_enable,
1456 .rx_queue_intr_disable = dpaa_dev_queue_intr_disable,
1457 .rss_hash_update = dpaa_dev_rss_hash_update,
1458 .rss_hash_conf_get = dpaa_dev_rss_hash_conf_get,
1462 is_device_supported(struct rte_eth_dev *dev, struct rte_dpaa_driver *drv)
1464 if (strcmp(dev->device->driver->name,
1472 is_dpaa_supported(struct rte_eth_dev *dev)
1474 return is_device_supported(dev, &rte_dpaa_pmd);
1478 rte_pmd_dpaa_set_tx_loopback(uint16_t port, uint8_t on)
1480 struct rte_eth_dev *dev;
1482 RTE_ETH_VALID_PORTID_OR_ERR_RET(port, -ENODEV);
1484 dev = &rte_eth_devices[port];
1486 if (!is_dpaa_supported(dev))
1490 fman_if_loopback_enable(dev->process_private);
1492 fman_if_loopback_disable(dev->process_private);
1497 static int dpaa_fc_set_default(struct dpaa_if *dpaa_intf,
1498 struct fman_if *fman_intf)
1500 struct rte_eth_fc_conf *fc_conf;
1503 PMD_INIT_FUNC_TRACE();
1505 if (!(dpaa_intf->fc_conf)) {
1506 dpaa_intf->fc_conf = rte_zmalloc(NULL,
1507 sizeof(struct rte_eth_fc_conf), MAX_CACHELINE);
1508 if (!dpaa_intf->fc_conf) {
1509 DPAA_PMD_ERR("unable to save flow control info");
1513 fc_conf = dpaa_intf->fc_conf;
1514 ret = fman_if_get_fc_threshold(fman_intf);
1516 fc_conf->mode = RTE_FC_TX_PAUSE;
1517 fc_conf->pause_time = fman_if_get_fc_quanta(fman_intf);
1519 fc_conf->mode = RTE_FC_NONE;
1525 /* Initialise an Rx FQ */
1526 static int dpaa_rx_queue_init(struct qman_fq *fq, struct qman_cgr *cgr_rx,
1529 struct qm_mcc_initfq opts = {0};
1531 u32 flags = QMAN_FQ_FLAG_NO_ENQUEUE;
1532 struct qm_mcc_initcgr cgr_opts = {
1533 .we_mask = QM_CGR_WE_CS_THRES |
1537 .cstd_en = QM_CGR_EN,
1538 .mode = QMAN_CGR_MODE_FRAME
1542 if (fmc_q || default_q) {
1543 ret = qman_reserve_fqid(fqid);
1545 DPAA_PMD_ERR("reserve rx fqid 0x%x failed, ret: %d",
1551 DPAA_PMD_DEBUG("creating rx fq %p, fqid 0x%x", fq, fqid);
1552 ret = qman_create_fq(fqid, flags, fq);
1554 DPAA_PMD_ERR("create rx fqid 0x%x failed with ret: %d",
1558 fq->is_static = false;
1560 dpaa_poll_queue_default_config(&opts);
1563 /* Enable tail drop with cgr on this queue */
1564 qm_cgr_cs_thres_set64(&cgr_opts.cgr.cs_thres, td_threshold, 0);
1566 ret = qman_create_cgr(cgr_rx, QMAN_CGR_FLAG_USE_INIT,
1570 "rx taildrop init fail on rx fqid 0x%x(ret=%d)",
1574 opts.we_mask |= QM_INITFQ_WE_CGID;
1575 opts.fqd.cgid = cgr_rx->cgrid;
1576 opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
1579 ret = qman_init_fq(fq, 0, &opts);
1581 DPAA_PMD_ERR("init rx fqid 0x%x failed with ret:%d", fqid, ret);
1585 /* Initialise a Tx FQ */
1586 static int dpaa_tx_queue_init(struct qman_fq *fq,
1587 struct fman_if *fman_intf,
1588 struct qman_cgr *cgr_tx)
1590 struct qm_mcc_initfq opts = {0};
1591 struct qm_mcc_initcgr cgr_opts = {
1592 .we_mask = QM_CGR_WE_CS_THRES |
1596 .cstd_en = QM_CGR_EN,
1597 .mode = QMAN_CGR_MODE_FRAME
1602 ret = qman_create_fq(0, QMAN_FQ_FLAG_DYNAMIC_FQID |
1603 QMAN_FQ_FLAG_TO_DCPORTAL, fq);
1605 DPAA_PMD_ERR("create tx fq failed with ret: %d", ret);
1608 opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL |
1609 QM_INITFQ_WE_CONTEXTB | QM_INITFQ_WE_CONTEXTA;
1610 opts.fqd.dest.channel = fman_intf->tx_channel_id;
1611 opts.fqd.dest.wq = DPAA_IF_TX_PRIORITY;
1612 opts.fqd.fq_ctrl = QM_FQCTRL_PREFERINCACHE;
1613 opts.fqd.context_b = 0;
1614 /* no tx-confirmation */
1615 opts.fqd.context_a.hi = 0x80000000 | fman_dealloc_bufs_mask_hi;
1616 opts.fqd.context_a.lo = 0 | fman_dealloc_bufs_mask_lo;
1617 DPAA_PMD_DEBUG("init tx fq %p, fqid 0x%x", fq, fq->fqid);
1620 /* Enable tail drop with cgr on this queue */
1621 qm_cgr_cs_thres_set64(&cgr_opts.cgr.cs_thres,
1622 td_tx_threshold, 0);
1624 ret = qman_create_cgr(cgr_tx, QMAN_CGR_FLAG_USE_INIT,
1628 "rx taildrop init fail on rx fqid 0x%x(ret=%d)",
1632 opts.we_mask |= QM_INITFQ_WE_CGID;
1633 opts.fqd.cgid = cgr_tx->cgrid;
1634 opts.fqd.fq_ctrl |= QM_FQCTRL_CGE;
1635 DPAA_PMD_DEBUG("Tx FQ tail drop enabled, threshold = %d\n",
1639 ret = qman_init_fq(fq, QMAN_INITFQ_FLAG_SCHED, &opts);
1641 DPAA_PMD_ERR("init tx fqid 0x%x failed %d", fq->fqid, ret);
1645 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
1646 /* Initialise a DEBUG FQ ([rt]x_error, rx_default). */
1647 static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
1649 struct qm_mcc_initfq opts = {0};
1652 PMD_INIT_FUNC_TRACE();
1654 ret = qman_reserve_fqid(fqid);
1656 DPAA_PMD_ERR("Reserve debug fqid %d failed with ret: %d",
1660 /* "map" this Rx FQ to one of the interfaces Tx FQID */
1661 DPAA_PMD_DEBUG("Creating debug fq %p, fqid %d", fq, fqid);
1662 ret = qman_create_fq(fqid, QMAN_FQ_FLAG_NO_ENQUEUE, fq);
1664 DPAA_PMD_ERR("create debug fqid %d failed with ret: %d",
1668 opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL;
1669 opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
1670 ret = qman_init_fq(fq, 0, &opts);
1672 DPAA_PMD_ERR("init debug fqid %d failed with ret: %d",
1678 /* Initialise a network interface */
1680 dpaa_dev_init_secondary(struct rte_eth_dev *eth_dev)
1682 struct rte_dpaa_device *dpaa_device;
1683 struct fm_eth_port_cfg *cfg;
1684 struct dpaa_if *dpaa_intf;
1685 struct fman_if *fman_intf;
1688 PMD_INIT_FUNC_TRACE();
1690 dpaa_device = DEV_TO_DPAA_DEVICE(eth_dev->device);
1691 dev_id = dpaa_device->id.dev_id;
1692 cfg = dpaa_get_eth_port_cfg(dev_id);
1693 fman_intf = cfg->fman_if;
1694 eth_dev->process_private = fman_intf;
1696 /* Plugging of UCODE burst API not supported in Secondary */
1697 dpaa_intf = eth_dev->data->dev_private;
1698 eth_dev->rx_pkt_burst = dpaa_eth_queue_rx;
1699 if (dpaa_intf->cgr_tx)
1700 eth_dev->tx_pkt_burst = dpaa_eth_queue_tx_slow;
1702 eth_dev->tx_pkt_burst = dpaa_eth_queue_tx;
1703 #ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
1704 qman_set_fq_lookup_table(
1705 dpaa_intf->rx_queues->qman_fq_lookup_table);
1711 /* Initialise a network interface */
1713 dpaa_dev_init(struct rte_eth_dev *eth_dev)
1715 int num_rx_fqs, fqid;
1718 struct rte_dpaa_device *dpaa_device;
1719 struct dpaa_if *dpaa_intf;
1720 struct fm_eth_port_cfg *cfg;
1721 struct fman_if *fman_intf;
1722 struct fman_if_bpool *bp, *tmp_bp;
1723 uint32_t cgrid[DPAA_MAX_NUM_PCD_QUEUES];
1724 uint32_t cgrid_tx[MAX_DPAA_CORES];
1725 uint32_t dev_rx_fqids[DPAA_MAX_NUM_PCD_QUEUES];
1726 int8_t dev_vspids[DPAA_MAX_NUM_PCD_QUEUES];
1729 PMD_INIT_FUNC_TRACE();
1731 dpaa_device = DEV_TO_DPAA_DEVICE(eth_dev->device);
1732 dev_id = dpaa_device->id.dev_id;
1733 dpaa_intf = eth_dev->data->dev_private;
1734 cfg = dpaa_get_eth_port_cfg(dev_id);
1735 fman_intf = cfg->fman_if;
1737 dpaa_intf->name = dpaa_device->name;
1739 /* save fman_if & cfg in the interface struture */
1740 eth_dev->process_private = fman_intf;
1741 dpaa_intf->ifid = dev_id;
1742 dpaa_intf->cfg = cfg;
1744 memset((char *)dev_rx_fqids, 0,
1745 sizeof(uint32_t) * DPAA_MAX_NUM_PCD_QUEUES);
1747 memset(dev_vspids, -1, DPAA_MAX_NUM_PCD_QUEUES);
1749 /* Initialize Rx FQ's */
1751 num_rx_fqs = DPAA_DEFAULT_NUM_PCD_QUEUES;
1753 num_rx_fqs = dpaa_port_fmc_init(fman_intf, dev_rx_fqids,
1755 DPAA_MAX_NUM_PCD_QUEUES);
1756 if (num_rx_fqs < 0) {
1757 DPAA_PMD_ERR("%s FMC initializes failed!",
1762 DPAA_PMD_WARN("%s is not configured by FMC.",
1766 /* FMCLESS mode, load balance to multiple cores.*/
1767 num_rx_fqs = rte_lcore_count();
1770 /* Each device can not have more than DPAA_MAX_NUM_PCD_QUEUES RX
1773 if (num_rx_fqs < 0 || num_rx_fqs > DPAA_MAX_NUM_PCD_QUEUES) {
1774 DPAA_PMD_ERR("Invalid number of RX queues\n");
1778 if (num_rx_fqs > 0) {
1779 dpaa_intf->rx_queues = rte_zmalloc(NULL,
1780 sizeof(struct qman_fq) * num_rx_fqs, MAX_CACHELINE);
1781 if (!dpaa_intf->rx_queues) {
1782 DPAA_PMD_ERR("Failed to alloc mem for RX queues\n");
1786 dpaa_intf->rx_queues = NULL;
1789 memset(cgrid, 0, sizeof(cgrid));
1790 memset(cgrid_tx, 0, sizeof(cgrid_tx));
1792 /* if DPAA_TX_TAILDROP_THRESHOLD is set, use that value; if 0, it means
1793 * Tx tail drop is disabled.
1795 if (getenv("DPAA_TX_TAILDROP_THRESHOLD")) {
1796 td_tx_threshold = atoi(getenv("DPAA_TX_TAILDROP_THRESHOLD"));
1797 DPAA_PMD_DEBUG("Tail drop threshold env configured: %u",
1799 /* if a very large value is being configured */
1800 if (td_tx_threshold > UINT16_MAX)
1801 td_tx_threshold = CGR_RX_PERFQ_THRESH;
1804 /* If congestion control is enabled globally*/
1805 if (num_rx_fqs > 0 && td_threshold) {
1806 dpaa_intf->cgr_rx = rte_zmalloc(NULL,
1807 sizeof(struct qman_cgr) * num_rx_fqs, MAX_CACHELINE);
1808 if (!dpaa_intf->cgr_rx) {
1809 DPAA_PMD_ERR("Failed to alloc mem for cgr_rx\n");
1814 ret = qman_alloc_cgrid_range(&cgrid[0], num_rx_fqs, 1, 0);
1815 if (ret != num_rx_fqs) {
1816 DPAA_PMD_WARN("insufficient CGRIDs available");
1821 dpaa_intf->cgr_rx = NULL;
1824 if (!fmc_q && !default_q) {
1825 ret = qman_alloc_fqid_range(dev_rx_fqids, num_rx_fqs,
1828 DPAA_PMD_ERR("Failed to alloc rx fqid's\n");
1833 for (loop = 0; loop < num_rx_fqs; loop++) {
1837 fqid = dev_rx_fqids[loop];
1839 vsp_id = dev_vspids[loop];
1841 if (dpaa_intf->cgr_rx)
1842 dpaa_intf->cgr_rx[loop].cgrid = cgrid[loop];
1844 ret = dpaa_rx_queue_init(&dpaa_intf->rx_queues[loop],
1845 dpaa_intf->cgr_rx ? &dpaa_intf->cgr_rx[loop] : NULL,
1849 dpaa_intf->rx_queues[loop].vsp_id = vsp_id;
1850 dpaa_intf->rx_queues[loop].dpaa_intf = dpaa_intf;
1852 dpaa_intf->nb_rx_queues = num_rx_fqs;
1854 /* Initialise Tx FQs.free_rx Have as many Tx FQ's as number of cores */
1855 dpaa_intf->tx_queues = rte_zmalloc(NULL, sizeof(struct qman_fq) *
1856 MAX_DPAA_CORES, MAX_CACHELINE);
1857 if (!dpaa_intf->tx_queues) {
1858 DPAA_PMD_ERR("Failed to alloc mem for TX queues\n");
1863 /* If congestion control is enabled globally*/
1864 if (td_tx_threshold) {
1865 dpaa_intf->cgr_tx = rte_zmalloc(NULL,
1866 sizeof(struct qman_cgr) * MAX_DPAA_CORES,
1868 if (!dpaa_intf->cgr_tx) {
1869 DPAA_PMD_ERR("Failed to alloc mem for cgr_tx\n");
1874 ret = qman_alloc_cgrid_range(&cgrid_tx[0], MAX_DPAA_CORES,
1876 if (ret != MAX_DPAA_CORES) {
1877 DPAA_PMD_WARN("insufficient CGRIDs available");
1882 dpaa_intf->cgr_tx = NULL;
1886 for (loop = 0; loop < MAX_DPAA_CORES; loop++) {
1887 if (dpaa_intf->cgr_tx)
1888 dpaa_intf->cgr_tx[loop].cgrid = cgrid_tx[loop];
1890 ret = dpaa_tx_queue_init(&dpaa_intf->tx_queues[loop],
1892 dpaa_intf->cgr_tx ? &dpaa_intf->cgr_tx[loop] : NULL);
1895 dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf;
1897 dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
1899 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
1900 dpaa_debug_queue_init(&dpaa_intf->debug_queues[
1901 DPAA_DEBUG_FQ_RX_ERROR], fman_intf->fqid_rx_err);
1902 dpaa_intf->debug_queues[DPAA_DEBUG_FQ_RX_ERROR].dpaa_intf = dpaa_intf;
1903 dpaa_debug_queue_init(&dpaa_intf->debug_queues[
1904 DPAA_DEBUG_FQ_TX_ERROR], fman_intf->fqid_tx_err);
1905 dpaa_intf->debug_queues[DPAA_DEBUG_FQ_TX_ERROR].dpaa_intf = dpaa_intf;
1908 DPAA_PMD_DEBUG("All frame queues created");
1910 /* Get the initial configuration for flow control */
1911 dpaa_fc_set_default(dpaa_intf, fman_intf);
1913 /* reset bpool list, initialize bpool dynamically */
1914 list_for_each_entry_safe(bp, tmp_bp, &cfg->fman_if->bpool_list, node) {
1915 list_del(&bp->node);
1919 /* Populate ethdev structure */
1920 eth_dev->dev_ops = &dpaa_devops;
1921 eth_dev->rx_queue_count = dpaa_dev_rx_queue_count;
1922 eth_dev->rx_pkt_burst = dpaa_eth_queue_rx;
1923 eth_dev->tx_pkt_burst = dpaa_eth_tx_drop_all;
1925 /* Allocate memory for storing MAC addresses */
1926 eth_dev->data->mac_addrs = rte_zmalloc("mac_addr",
1927 RTE_ETHER_ADDR_LEN * DPAA_MAX_MAC_FILTER, 0);
1928 if (eth_dev->data->mac_addrs == NULL) {
1929 DPAA_PMD_ERR("Failed to allocate %d bytes needed to "
1930 "store MAC addresses",
1931 RTE_ETHER_ADDR_LEN * DPAA_MAX_MAC_FILTER);
1936 /* copy the primary mac address */
1937 rte_ether_addr_copy(&fman_intf->mac_addr, ð_dev->data->mac_addrs[0]);
1939 RTE_LOG(INFO, PMD, "net: dpaa: %s: %02x:%02x:%02x:%02x:%02x:%02x\n",
1941 fman_intf->mac_addr.addr_bytes[0],
1942 fman_intf->mac_addr.addr_bytes[1],
1943 fman_intf->mac_addr.addr_bytes[2],
1944 fman_intf->mac_addr.addr_bytes[3],
1945 fman_intf->mac_addr.addr_bytes[4],
1946 fman_intf->mac_addr.addr_bytes[5]);
1948 if (!fman_intf->is_shared_mac) {
1949 /* Disable RX mode */
1950 fman_if_discard_rx_errors(fman_intf);
1951 fman_if_disable_rx(fman_intf);
1952 /* Disable promiscuous mode */
1953 fman_if_promiscuous_disable(fman_intf);
1954 /* Disable multicast */
1955 fman_if_reset_mcast_filter_table(fman_intf);
1956 /* Reset interface statistics */
1957 fman_if_stats_reset(fman_intf);
1958 /* Disable SG by default */
1959 fman_if_set_sg(fman_intf, 0);
1960 fman_if_set_maxfrm(fman_intf,
1961 RTE_ETHER_MAX_LEN + VLAN_TAG_SIZE);
1967 rte_free(dpaa_intf->tx_queues);
1968 dpaa_intf->tx_queues = NULL;
1969 dpaa_intf->nb_tx_queues = 0;
1972 rte_free(dpaa_intf->cgr_rx);
1973 rte_free(dpaa_intf->cgr_tx);
1974 rte_free(dpaa_intf->rx_queues);
1975 dpaa_intf->rx_queues = NULL;
1976 dpaa_intf->nb_rx_queues = 0;
1981 dpaa_dev_uninit(struct rte_eth_dev *dev)
1983 struct dpaa_if *dpaa_intf = dev->data->dev_private;
1986 PMD_INIT_FUNC_TRACE();
1988 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1992 DPAA_PMD_WARN("Already closed or not started");
1996 /* DPAA FM deconfig */
1997 if (!(default_q || fmc_q)) {
1998 if (dpaa_fm_deconfig(dpaa_intf, dev->process_private))
1999 DPAA_PMD_WARN("DPAA FM deconfig failed\n");
2002 dpaa_eth_dev_close(dev);
2004 /* release configuration memory */
2005 if (dpaa_intf->fc_conf)
2006 rte_free(dpaa_intf->fc_conf);
2008 /* Release RX congestion Groups */
2009 if (dpaa_intf->cgr_rx) {
2010 for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
2011 qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
2013 qman_release_cgrid_range(dpaa_intf->cgr_rx[loop].cgrid,
2014 dpaa_intf->nb_rx_queues);
2017 rte_free(dpaa_intf->cgr_rx);
2018 dpaa_intf->cgr_rx = NULL;
2020 /* Release TX congestion Groups */
2021 if (dpaa_intf->cgr_tx) {
2022 for (loop = 0; loop < MAX_DPAA_CORES; loop++)
2023 qman_delete_cgr(&dpaa_intf->cgr_tx[loop]);
2025 qman_release_cgrid_range(dpaa_intf->cgr_tx[loop].cgrid,
2027 rte_free(dpaa_intf->cgr_tx);
2028 dpaa_intf->cgr_tx = NULL;
2031 rte_free(dpaa_intf->rx_queues);
2032 dpaa_intf->rx_queues = NULL;
2034 rte_free(dpaa_intf->tx_queues);
2035 dpaa_intf->tx_queues = NULL;
2037 dev->dev_ops = NULL;
2038 dev->rx_pkt_burst = NULL;
2039 dev->tx_pkt_burst = NULL;
2045 rte_dpaa_probe(struct rte_dpaa_driver *dpaa_drv,
2046 struct rte_dpaa_device *dpaa_dev)
2050 struct rte_eth_dev *eth_dev;
2052 PMD_INIT_FUNC_TRACE();
2054 if ((DPAA_MBUF_HW_ANNOTATION + DPAA_FD_PTA_SIZE) >
2055 RTE_PKTMBUF_HEADROOM) {
2057 "RTE_PKTMBUF_HEADROOM(%d) shall be > DPAA Annotation req(%d)",
2058 RTE_PKTMBUF_HEADROOM,
2059 DPAA_MBUF_HW_ANNOTATION + DPAA_FD_PTA_SIZE);
2064 /* In case of secondary process, the device is already configured
2065 * and no further action is required, except portal initialization
2066 * and verifying secondary attachment to port name.
2068 if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
2069 eth_dev = rte_eth_dev_attach_secondary(dpaa_dev->name);
2072 eth_dev->device = &dpaa_dev->device;
2073 eth_dev->dev_ops = &dpaa_devops;
2075 ret = dpaa_dev_init_secondary(eth_dev);
2077 RTE_LOG(ERR, PMD, "secondary dev init failed\n");
2081 rte_eth_dev_probing_finish(eth_dev);
2085 if (!is_global_init && (rte_eal_process_type() == RTE_PROC_PRIMARY)) {
2086 if (access("/tmp/fmc.bin", F_OK) == -1) {
2087 DPAA_PMD_INFO("* FMC not configured.Enabling default mode");
2091 if (!(default_q || fmc_q)) {
2092 if (dpaa_fm_init()) {
2093 DPAA_PMD_ERR("FM init failed\n");
2098 /* disabling the default push mode for LS1043 */
2099 if (dpaa_svr_family == SVR_LS1043A_FAMILY)
2100 dpaa_push_mode_max_queue = 0;
2102 /* if push mode queues to be enabled. Currenly we are allowing
2103 * only one queue per thread.
2105 if (getenv("DPAA_PUSH_QUEUES_NUMBER")) {
2106 dpaa_push_mode_max_queue =
2107 atoi(getenv("DPAA_PUSH_QUEUES_NUMBER"));
2108 if (dpaa_push_mode_max_queue > DPAA_MAX_PUSH_MODE_QUEUE)
2109 dpaa_push_mode_max_queue = DPAA_MAX_PUSH_MODE_QUEUE;
2115 if (unlikely(!DPAA_PER_LCORE_PORTAL)) {
2116 ret = rte_dpaa_portal_init((void *)1);
2118 DPAA_PMD_ERR("Unable to initialize portal");
2123 eth_dev = rte_eth_dev_allocate(dpaa_dev->name);
2127 eth_dev->data->dev_private =
2128 rte_zmalloc("ethdev private structure",
2129 sizeof(struct dpaa_if),
2130 RTE_CACHE_LINE_SIZE);
2131 if (!eth_dev->data->dev_private) {
2132 DPAA_PMD_ERR("Cannot allocate memzone for port data");
2133 rte_eth_dev_release_port(eth_dev);
2137 eth_dev->device = &dpaa_dev->device;
2138 dpaa_dev->eth_dev = eth_dev;
2140 qman_ern_register_cb(dpaa_free_mbuf);
2142 if (dpaa_drv->drv_flags & RTE_DPAA_DRV_INTR_LSC)
2143 eth_dev->data->dev_flags |= RTE_ETH_DEV_INTR_LSC;
2145 /* Invoke PMD device initialization function */
2146 diag = dpaa_dev_init(eth_dev);
2148 rte_eth_dev_probing_finish(eth_dev);
2152 rte_eth_dev_release_port(eth_dev);
2157 rte_dpaa_remove(struct rte_dpaa_device *dpaa_dev)
2159 struct rte_eth_dev *eth_dev;
2161 PMD_INIT_FUNC_TRACE();
2163 eth_dev = dpaa_dev->eth_dev;
2164 dpaa_dev_uninit(eth_dev);
2166 rte_eth_dev_release_port(eth_dev);
2171 static void __attribute__((destructor(102))) dpaa_finish(void)
2173 /* For secondary, primary will do all the cleanup */
2174 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
2177 if (!(default_q || fmc_q)) {
2180 for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
2181 if (rte_eth_devices[i].dev_ops == &dpaa_devops) {
2182 struct rte_eth_dev *dev = &rte_eth_devices[i];
2183 struct dpaa_if *dpaa_intf =
2184 dev->data->dev_private;
2185 struct fman_if *fif =
2186 dev->process_private;
2187 if (dpaa_intf->port_handle)
2188 if (dpaa_fm_deconfig(dpaa_intf, fif))
2189 DPAA_PMD_WARN("DPAA FM "
2190 "deconfig failed\n");
2191 if (fif->num_profiles) {
2192 if (dpaa_port_vsp_cleanup(dpaa_intf,
2194 DPAA_PMD_WARN("DPAA FM vsp cleanup failed\n");
2200 DPAA_PMD_WARN("DPAA FM term failed\n");
2204 DPAA_PMD_INFO("DPAA fman cleaned up");
2208 static struct rte_dpaa_driver rte_dpaa_pmd = {
2209 .drv_flags = RTE_DPAA_DRV_INTR_LSC,
2210 .drv_type = FSL_DPAA_ETH,
2211 .probe = rte_dpaa_probe,
2212 .remove = rte_dpaa_remove,
2215 RTE_PMD_REGISTER_DPAA(net_dpaa, rte_dpaa_pmd);
2216 RTE_LOG_REGISTER(dpaa_logtype_pmd, pmd.net.dpaa, NOTICE);