4 * Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
5 * Copyright (c) 2016 NXP. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Freescale Semiconductor, Inc nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 #include <rte_ethdev.h>
39 #include <rte_malloc.h>
40 #include <rte_memcpy.h>
41 #include <rte_string_fns.h>
42 #include <rte_cycles.h>
43 #include <rte_kvargs.h>
45 #include <rte_ethdev.h>
46 #include <rte_fslmc.h>
48 #include <fslmc_logs.h>
49 #include <fslmc_vfio.h>
50 #include <dpaa2_hw_pvt.h>
51 #include <dpaa2_hw_mempool.h>
52 #include <dpaa2_hw_dpio.h>
54 #include "dpaa2_ethdev.h"
56 static struct rte_dpaa2_driver rte_dpaa2_pmd;
57 static int dpaa2_dev_uninit(struct rte_eth_dev *eth_dev);
58 static int dpaa2_dev_set_link_up(struct rte_eth_dev *dev);
59 static int dpaa2_dev_set_link_down(struct rte_eth_dev *dev);
60 static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
63 * Atomically reads the link status information from global
64 * structure rte_eth_dev.
67 * - Pointer to the structure rte_eth_dev to read from.
68 * - Pointer to the buffer to be saved with the link status.
72 * - On failure, negative value.
75 dpaa2_dev_atomic_read_link_status(struct rte_eth_dev *dev,
76 struct rte_eth_link *link)
78 struct rte_eth_link *dst = link;
79 struct rte_eth_link *src = &dev->data->dev_link;
81 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
82 *(uint64_t *)src) == 0)
89 * Atomically writes the link status information into global
90 * structure rte_eth_dev.
93 * - Pointer to the structure rte_eth_dev to read from.
94 * - Pointer to the buffer to be saved with the link status.
98 * - On failure, negative value.
101 dpaa2_dev_atomic_write_link_status(struct rte_eth_dev *dev,
102 struct rte_eth_link *link)
104 struct rte_eth_link *dst = &dev->data->dev_link;
105 struct rte_eth_link *src = link;
107 if (rte_atomic64_cmpset((uint64_t *)dst, *(uint64_t *)dst,
108 *(uint64_t *)src) == 0)
115 dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
118 struct dpaa2_dev_priv *priv = dev->data->dev_private;
119 struct fsl_mc_io *dpni = priv->hw;
121 PMD_INIT_FUNC_TRACE();
124 RTE_LOG(ERR, PMD, "dpni is NULL");
129 ret = dpni_add_vlan_id(dpni, CMD_PRI_LOW,
130 priv->token, vlan_id);
132 ret = dpni_remove_vlan_id(dpni, CMD_PRI_LOW,
133 priv->token, vlan_id);
136 PMD_DRV_LOG(ERR, "ret = %d Unable to add/rem vlan %d hwid =%d",
137 ret, vlan_id, priv->hw_id);
143 dpaa2_vlan_offload_set(struct rte_eth_dev *dev, int mask)
145 struct dpaa2_dev_priv *priv = dev->data->dev_private;
146 struct fsl_mc_io *dpni = priv->hw;
149 PMD_INIT_FUNC_TRACE();
151 if (mask & ETH_VLAN_FILTER_MASK) {
152 if (dev->data->dev_conf.rxmode.hw_vlan_filter)
153 ret = dpni_enable_vlan_filter(dpni, CMD_PRI_LOW,
156 ret = dpni_enable_vlan_filter(dpni, CMD_PRI_LOW,
159 RTE_LOG(ERR, PMD, "Unable to set vlan filter ret = %d",
165 dpaa2_dev_info_get(struct rte_eth_dev *dev, struct rte_eth_dev_info *dev_info)
167 struct dpaa2_dev_priv *priv = dev->data->dev_private;
169 PMD_INIT_FUNC_TRACE();
171 dev_info->if_index = priv->hw_id;
173 dev_info->max_mac_addrs = priv->max_mac_filters;
174 dev_info->max_rx_pktlen = DPAA2_MAX_RX_PKT_LEN;
175 dev_info->min_rx_bufsize = DPAA2_MIN_RX_BUF_SIZE;
176 dev_info->max_rx_queues = (uint16_t)priv->nb_rx_queues;
177 dev_info->max_tx_queues = (uint16_t)priv->nb_tx_queues;
178 dev_info->rx_offload_capa =
179 DEV_RX_OFFLOAD_IPV4_CKSUM |
180 DEV_RX_OFFLOAD_UDP_CKSUM |
181 DEV_RX_OFFLOAD_TCP_CKSUM |
182 DEV_RX_OFFLOAD_OUTER_IPV4_CKSUM;
183 dev_info->tx_offload_capa =
184 DEV_TX_OFFLOAD_IPV4_CKSUM |
185 DEV_TX_OFFLOAD_UDP_CKSUM |
186 DEV_TX_OFFLOAD_TCP_CKSUM |
187 DEV_TX_OFFLOAD_SCTP_CKSUM |
188 DEV_TX_OFFLOAD_OUTER_IPV4_CKSUM;
189 dev_info->speed_capa = ETH_LINK_SPEED_1G |
190 ETH_LINK_SPEED_2_5G |
195 dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
197 struct dpaa2_dev_priv *priv = dev->data->dev_private;
200 struct dpaa2_queue *mc_q, *mcq;
203 struct dpaa2_queue *dpaa2_q;
205 PMD_INIT_FUNC_TRACE();
207 tot_queues = priv->nb_rx_queues + priv->nb_tx_queues;
208 mc_q = rte_malloc(NULL, sizeof(struct dpaa2_queue) * tot_queues,
209 RTE_CACHE_LINE_SIZE);
211 PMD_INIT_LOG(ERR, "malloc failed for rx/tx queues\n");
215 for (i = 0; i < priv->nb_rx_queues; i++) {
217 priv->rx_vq[i] = mc_q++;
218 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
219 dpaa2_q->q_storage = rte_malloc("dq_storage",
220 sizeof(struct queue_storage_info_t),
221 RTE_CACHE_LINE_SIZE);
222 if (!dpaa2_q->q_storage)
225 memset(dpaa2_q->q_storage, 0,
226 sizeof(struct queue_storage_info_t));
227 if (dpaa2_alloc_dq_storage(dpaa2_q->q_storage))
231 for (i = 0; i < priv->nb_tx_queues; i++) {
233 mc_q->flow_id = 0xffff;
234 priv->tx_vq[i] = mc_q++;
235 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
236 dpaa2_q->cscn = rte_malloc(NULL,
237 sizeof(struct qbman_result), 16);
243 for (dist_idx = 0; dist_idx < priv->num_dist_per_tc[DPAA2_DEF_TC];
245 mcq = (struct dpaa2_queue *)priv->rx_vq[vq_id];
246 mcq->tc_index = DPAA2_DEF_TC;
247 mcq->flow_id = dist_idx;
255 dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
256 rte_free(dpaa2_q->cscn);
257 priv->tx_vq[i--] = NULL;
259 i = priv->nb_rx_queues;
262 mc_q = priv->rx_vq[0];
264 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
265 dpaa2_free_dq_storage(dpaa2_q->q_storage);
266 rte_free(dpaa2_q->q_storage);
267 priv->rx_vq[i--] = NULL;
274 dpaa2_eth_dev_configure(struct rte_eth_dev *dev)
276 struct rte_eth_dev_data *data = dev->data;
277 struct rte_eth_conf *eth_conf = &data->dev_conf;
280 PMD_INIT_FUNC_TRACE();
282 if (eth_conf->rxmode.jumbo_frame == 1) {
283 if (eth_conf->rxmode.max_rx_pkt_len <= DPAA2_MAX_RX_PKT_LEN) {
284 ret = dpaa2_dev_mtu_set(dev,
285 eth_conf->rxmode.max_rx_pkt_len);
288 "unable to set mtu. check config\n");
296 /* Check for correct configuration */
297 if (eth_conf->rxmode.mq_mode != ETH_MQ_RX_RSS &&
298 data->nb_rx_queues > 1) {
299 PMD_INIT_LOG(ERR, "Distribution is not enabled, "
300 "but Rx queues more than 1\n");
304 if (eth_conf->rxmode.mq_mode == ETH_MQ_RX_RSS) {
305 /* Return in case number of Rx queues is 1 */
306 if (data->nb_rx_queues == 1)
308 ret = dpaa2_setup_flow_dist(dev,
309 eth_conf->rx_adv_conf.rss_conf.rss_hf);
311 PMD_INIT_LOG(ERR, "unable to set flow distribution."
312 "please check queue config\n");
319 /* Function to setup RX flow information. It contains traffic class ID,
320 * flow ID, destination configuration etc.
323 dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
324 uint16_t rx_queue_id,
325 uint16_t nb_rx_desc __rte_unused,
326 unsigned int socket_id __rte_unused,
327 const struct rte_eth_rxconf *rx_conf __rte_unused,
328 struct rte_mempool *mb_pool)
330 struct dpaa2_dev_priv *priv = dev->data->dev_private;
331 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
332 struct dpaa2_queue *dpaa2_q;
333 struct dpni_queue cfg;
339 PMD_INIT_FUNC_TRACE();
341 PMD_INIT_LOG(DEBUG, "dev =%p, queue =%d, pool = %p, conf =%p",
342 dev, rx_queue_id, mb_pool, rx_conf);
344 if (!priv->bp_list || priv->bp_list->mp != mb_pool) {
345 bpid = mempool_to_bpid(mb_pool);
346 ret = dpaa2_attach_bp_list(priv,
347 rte_dpaa2_bpid_info[bpid].bp_list);
351 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[rx_queue_id];
352 dpaa2_q->mb_pool = mb_pool; /**< mbuf pool to populate RX ring. */
354 /*Get the tc id and flow id from given VQ id*/
355 flow_id = rx_queue_id % priv->num_dist_per_tc[dpaa2_q->tc_index];
356 memset(&cfg, 0, sizeof(struct dpni_queue));
358 options = options | DPNI_QUEUE_OPT_USER_CTX;
359 cfg.user_context = (uint64_t)(dpaa2_q);
361 /*if ls2088 or rev2 device, enable the stashing */
362 if ((qbman_get_version() & 0xFFFF0000) > QMAN_REV_4000) {
363 options |= DPNI_QUEUE_OPT_FLC;
364 cfg.flc.stash_control = true;
365 cfg.flc.value &= 0xFFFFFFFFFFFFFFC0;
366 /* 00 00 00 - last 6 bit represent annotation, context stashing,
367 * data stashing setting 01 01 00 (0x14) to enable
368 * 1 line data, 1 line annotation
370 cfg.flc.value |= 0x14;
372 ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_RX,
373 dpaa2_q->tc_index, flow_id, options, &cfg);
375 PMD_INIT_LOG(ERR, "Error in setting the rx flow: = %d\n", ret);
379 if (!(priv->flags & DPAA2_RX_TAILDROP_OFF)) {
380 struct dpni_taildrop taildrop;
383 /*enabling per rx queue congestion control */
384 taildrop.threshold = CONG_THRESHOLD_RX_Q;
385 taildrop.units = DPNI_CONGESTION_UNIT_BYTES;
386 PMD_INIT_LOG(DEBUG, "Enabling Early Drop on queue = %d",
388 ret = dpni_set_taildrop(dpni, CMD_PRI_LOW, priv->token,
389 DPNI_CP_QUEUE, DPNI_QUEUE_RX,
390 dpaa2_q->tc_index, flow_id, &taildrop);
392 PMD_INIT_LOG(ERR, "Error in setting the rx flow"
393 " err : = %d\n", ret);
398 dev->data->rx_queues[rx_queue_id] = dpaa2_q;
403 dpaa2_dev_tx_queue_setup(struct rte_eth_dev *dev,
404 uint16_t tx_queue_id,
405 uint16_t nb_tx_desc __rte_unused,
406 unsigned int socket_id __rte_unused,
407 const struct rte_eth_txconf *tx_conf __rte_unused)
409 struct dpaa2_dev_priv *priv = dev->data->dev_private;
410 struct dpaa2_queue *dpaa2_q = (struct dpaa2_queue *)
411 priv->tx_vq[tx_queue_id];
412 struct fsl_mc_io *dpni = priv->hw;
413 struct dpni_queue tx_conf_cfg;
414 struct dpni_queue tx_flow_cfg;
415 uint8_t options = 0, flow_id;
419 PMD_INIT_FUNC_TRACE();
421 /* Return if queue already configured */
422 if (dpaa2_q->flow_id != 0xffff)
425 memset(&tx_conf_cfg, 0, sizeof(struct dpni_queue));
426 memset(&tx_flow_cfg, 0, sizeof(struct dpni_queue));
428 if (priv->num_tc == 1) {
430 flow_id = tx_queue_id % priv->num_dist_per_tc[tc_id];
436 ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_TX,
437 tc_id, flow_id, options, &tx_flow_cfg);
439 PMD_INIT_LOG(ERR, "Error in setting the tx flow: "
440 "tc_id=%d, flow =%d ErrorCode = %x\n",
441 tc_id, flow_id, -ret);
445 dpaa2_q->flow_id = flow_id;
447 if (tx_queue_id == 0) {
448 /*Set tx-conf and error configuration*/
449 ret = dpni_set_tx_confirmation_mode(dpni, CMD_PRI_LOW,
453 PMD_INIT_LOG(ERR, "Error in set tx conf mode settings"
454 " ErrorCode = %x", ret);
458 dpaa2_q->tc_index = tc_id;
460 if (priv->flags & DPAA2_TX_CGR_SUPPORT) {
461 struct dpni_congestion_notification_cfg cong_notif_cfg;
463 cong_notif_cfg.units = DPNI_CONGESTION_UNIT_BYTES;
464 /* Notify about congestion when the queue size is 32 KB */
465 cong_notif_cfg.threshold_entry = CONG_ENTER_TX_THRESHOLD;
466 /* Notify that the queue is not congested when the data in
467 * the queue is below this thershold.
469 cong_notif_cfg.threshold_exit = CONG_EXIT_TX_THRESHOLD;
470 cong_notif_cfg.message_ctx = 0;
471 cong_notif_cfg.message_iova = (uint64_t)dpaa2_q->cscn;
472 cong_notif_cfg.dest_cfg.dest_type = DPNI_DEST_NONE;
473 cong_notif_cfg.notification_mode =
474 DPNI_CONG_OPT_WRITE_MEM_ON_ENTER |
475 DPNI_CONG_OPT_WRITE_MEM_ON_EXIT |
476 DPNI_CONG_OPT_COHERENT_WRITE;
478 ret = dpni_set_congestion_notification(dpni, CMD_PRI_LOW,
485 "Error in setting tx congestion notification: = %d",
490 dev->data->tx_queues[tx_queue_id] = dpaa2_q;
495 dpaa2_dev_rx_queue_release(void *q __rte_unused)
497 PMD_INIT_FUNC_TRACE();
501 dpaa2_dev_tx_queue_release(void *q __rte_unused)
503 PMD_INIT_FUNC_TRACE();
506 static const uint32_t *
507 dpaa2_supported_ptypes_get(struct rte_eth_dev *dev)
509 static const uint32_t ptypes[] = {
510 /*todo -= add more types */
513 RTE_PTYPE_L3_IPV4_EXT,
515 RTE_PTYPE_L3_IPV6_EXT,
523 if (dev->rx_pkt_burst == dpaa2_dev_prefetch_rx)
529 dpaa2_dev_start(struct rte_eth_dev *dev)
531 struct rte_eth_dev_data *data = dev->data;
532 struct dpaa2_dev_priv *priv = data->dev_private;
533 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
534 struct dpni_queue cfg;
535 struct dpni_error_cfg err_cfg;
537 struct dpni_queue_id qid;
538 struct dpaa2_queue *dpaa2_q;
541 PMD_INIT_FUNC_TRACE();
543 ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token);
545 PMD_INIT_LOG(ERR, "Failure %d in enabling dpni %d device\n",
550 /* Power up the phy. Needed to make the link go Up */
551 dpaa2_dev_set_link_up(dev);
553 ret = dpni_get_qdid(dpni, CMD_PRI_LOW, priv->token,
554 DPNI_QUEUE_TX, &qdid);
556 PMD_INIT_LOG(ERR, "Error to get qdid:ErrorCode = %d\n", ret);
561 for (i = 0; i < data->nb_rx_queues; i++) {
562 dpaa2_q = (struct dpaa2_queue *)data->rx_queues[i];
563 ret = dpni_get_queue(dpni, CMD_PRI_LOW, priv->token,
564 DPNI_QUEUE_RX, dpaa2_q->tc_index,
565 dpaa2_q->flow_id, &cfg, &qid);
567 PMD_INIT_LOG(ERR, "Error to get flow "
568 "information Error code = %d\n", ret);
571 dpaa2_q->fqid = qid.fqid;
574 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
575 DPNI_OFF_RX_L3_CSUM, true);
577 PMD_INIT_LOG(ERR, "Error to set RX l3 csum:Error = %d\n", ret);
581 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
582 DPNI_OFF_RX_L4_CSUM, true);
584 PMD_INIT_LOG(ERR, "Error to get RX l4 csum:Error = %d\n", ret);
588 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
589 DPNI_OFF_TX_L3_CSUM, true);
591 PMD_INIT_LOG(ERR, "Error to set TX l3 csum:Error = %d\n", ret);
595 ret = dpni_set_offload(dpni, CMD_PRI_LOW, priv->token,
596 DPNI_OFF_TX_L4_CSUM, true);
598 PMD_INIT_LOG(ERR, "Error to get TX l4 csum:Error = %d\n", ret);
602 /*checksum errors, send them to normal path and set it in annotation */
603 err_cfg.errors = DPNI_ERROR_L3CE | DPNI_ERROR_L4CE;
605 err_cfg.error_action = DPNI_ERROR_ACTION_CONTINUE;
606 err_cfg.set_frame_annotation = true;
608 ret = dpni_set_errors_behavior(dpni, CMD_PRI_LOW,
609 priv->token, &err_cfg);
611 PMD_INIT_LOG(ERR, "Error to dpni_set_errors_behavior:"
615 /* VLAN Offload Settings */
616 if (priv->max_vlan_filters)
617 dpaa2_vlan_offload_set(dev, ETH_VLAN_FILTER_MASK);
623 * This routine disables all traffic on the adapter by issuing a
624 * global reset on the MAC.
627 dpaa2_dev_stop(struct rte_eth_dev *dev)
629 struct dpaa2_dev_priv *priv = dev->data->dev_private;
630 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
632 struct rte_eth_link link;
634 PMD_INIT_FUNC_TRACE();
636 dpaa2_dev_set_link_down(dev);
638 ret = dpni_disable(dpni, CMD_PRI_LOW, priv->token);
640 PMD_INIT_LOG(ERR, "Failure (ret %d) in disabling dpni %d dev\n",
645 /* clear the recorded link status */
646 memset(&link, 0, sizeof(link));
647 dpaa2_dev_atomic_write_link_status(dev, &link);
651 dpaa2_dev_close(struct rte_eth_dev *dev)
653 struct rte_eth_dev_data *data = dev->data;
654 struct dpaa2_dev_priv *priv = dev->data->dev_private;
655 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
657 struct rte_eth_link link;
658 struct dpaa2_queue *dpaa2_q;
660 PMD_INIT_FUNC_TRACE();
662 for (i = 0; i < data->nb_tx_queues; i++) {
663 dpaa2_q = (struct dpaa2_queue *)data->tx_queues[i];
664 if (!dpaa2_q->cscn) {
665 rte_free(dpaa2_q->cscn);
666 dpaa2_q->cscn = NULL;
670 /* Clean the device first */
671 ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token);
673 PMD_INIT_LOG(ERR, "Failure cleaning dpni device with"
674 " error code %d\n", ret);
678 memset(&link, 0, sizeof(link));
679 dpaa2_dev_atomic_write_link_status(dev, &link);
683 dpaa2_dev_promiscuous_enable(
684 struct rte_eth_dev *dev)
687 struct dpaa2_dev_priv *priv = dev->data->dev_private;
688 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
690 PMD_INIT_FUNC_TRACE();
693 RTE_LOG(ERR, PMD, "dpni is NULL");
697 ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
699 RTE_LOG(ERR, PMD, "Unable to enable U promisc mode %d", ret);
701 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
703 RTE_LOG(ERR, PMD, "Unable to enable M promisc mode %d", ret);
707 dpaa2_dev_promiscuous_disable(
708 struct rte_eth_dev *dev)
711 struct dpaa2_dev_priv *priv = dev->data->dev_private;
712 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
714 PMD_INIT_FUNC_TRACE();
717 RTE_LOG(ERR, PMD, "dpni is NULL");
721 ret = dpni_set_unicast_promisc(dpni, CMD_PRI_LOW, priv->token, false);
723 RTE_LOG(ERR, PMD, "Unable to disable U promisc mode %d", ret);
725 if (dev->data->all_multicast == 0) {
726 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW,
729 RTE_LOG(ERR, PMD, "Unable to disable M promisc mode %d",
735 dpaa2_dev_allmulticast_enable(
736 struct rte_eth_dev *dev)
739 struct dpaa2_dev_priv *priv = dev->data->dev_private;
740 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
742 PMD_INIT_FUNC_TRACE();
745 RTE_LOG(ERR, PMD, "dpni is NULL");
749 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, true);
751 RTE_LOG(ERR, PMD, "Unable to enable multicast mode %d", ret);
755 dpaa2_dev_allmulticast_disable(struct rte_eth_dev *dev)
758 struct dpaa2_dev_priv *priv = dev->data->dev_private;
759 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
761 PMD_INIT_FUNC_TRACE();
764 RTE_LOG(ERR, PMD, "dpni is NULL");
768 /* must remain on for all promiscuous */
769 if (dev->data->promiscuous == 1)
772 ret = dpni_set_multicast_promisc(dpni, CMD_PRI_LOW, priv->token, false);
774 RTE_LOG(ERR, PMD, "Unable to disable multicast mode %d", ret);
778 dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu)
781 struct dpaa2_dev_priv *priv = dev->data->dev_private;
782 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
783 uint32_t frame_size = mtu + ETHER_HDR_LEN + ETHER_CRC_LEN;
785 PMD_INIT_FUNC_TRACE();
788 RTE_LOG(ERR, PMD, "dpni is NULL");
792 /* check that mtu is within the allowed range */
793 if ((mtu < ETHER_MIN_MTU) || (frame_size > DPAA2_MAX_RX_PKT_LEN))
796 if (frame_size > ETHER_MAX_LEN)
797 dev->data->dev_conf.rxmode.jumbo_frame = 1;
799 dev->data->dev_conf.rxmode.jumbo_frame = 0;
801 /* Set the Max Rx frame length as 'mtu' +
802 * Maximum Ethernet header length
804 ret = dpni_set_max_frame_length(dpni, CMD_PRI_LOW, priv->token,
805 mtu + ETH_VLAN_HLEN);
807 PMD_DRV_LOG(ERR, "setting the max frame length failed");
810 PMD_DRV_LOG(INFO, "MTU is configured %d for the device\n", mtu);
815 dpaa2_dev_add_mac_addr(struct rte_eth_dev *dev,
816 struct ether_addr *addr,
817 __rte_unused uint32_t index,
818 __rte_unused uint32_t pool)
821 struct dpaa2_dev_priv *priv = dev->data->dev_private;
822 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
824 PMD_INIT_FUNC_TRACE();
827 RTE_LOG(ERR, PMD, "dpni is NULL");
831 ret = dpni_add_mac_addr(dpni, CMD_PRI_LOW,
832 priv->token, addr->addr_bytes);
834 RTE_LOG(ERR, PMD, "error: Adding the MAC ADDR failed:"
840 dpaa2_dev_remove_mac_addr(struct rte_eth_dev *dev,
844 struct dpaa2_dev_priv *priv = dev->data->dev_private;
845 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
846 struct rte_eth_dev_data *data = dev->data;
847 struct ether_addr *macaddr;
849 PMD_INIT_FUNC_TRACE();
851 macaddr = &data->mac_addrs[index];
854 RTE_LOG(ERR, PMD, "dpni is NULL");
858 ret = dpni_remove_mac_addr(dpni, CMD_PRI_LOW,
859 priv->token, macaddr->addr_bytes);
861 RTE_LOG(ERR, PMD, "error: Removing the MAC ADDR failed:"
866 dpaa2_dev_set_mac_addr(struct rte_eth_dev *dev,
867 struct ether_addr *addr)
870 struct dpaa2_dev_priv *priv = dev->data->dev_private;
871 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
873 PMD_INIT_FUNC_TRACE();
876 RTE_LOG(ERR, PMD, "dpni is NULL");
880 ret = dpni_set_primary_mac_addr(dpni, CMD_PRI_LOW,
881 priv->token, addr->addr_bytes);
884 RTE_LOG(ERR, PMD, "error: Setting the MAC ADDR failed %d", ret);
887 void dpaa2_dev_stats_get(struct rte_eth_dev *dev,
888 struct rte_eth_stats *stats)
890 struct dpaa2_dev_priv *priv = dev->data->dev_private;
891 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
893 uint8_t page0 = 0, page1 = 1, page2 = 2;
894 union dpni_statistics value;
896 memset(&value, 0, sizeof(union dpni_statistics));
898 PMD_INIT_FUNC_TRACE();
901 RTE_LOG(ERR, PMD, "dpni is NULL");
906 RTE_LOG(ERR, PMD, "stats is NULL");
910 /*Get Counters from page_0*/
911 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
916 stats->ipackets = value.page_0.ingress_all_frames;
917 stats->ibytes = value.page_0.ingress_all_bytes;
919 /*Get Counters from page_1*/
920 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
925 stats->opackets = value.page_1.egress_all_frames;
926 stats->obytes = value.page_1.egress_all_bytes;
928 /*Get Counters from page_2*/
929 retcode = dpni_get_statistics(dpni, CMD_PRI_LOW, priv->token,
934 /* Ingress drop frame count due to configured rules */
935 stats->ierrors = value.page_2.ingress_filtered_frames;
936 /* Ingress drop frame count due to error */
937 stats->ierrors += value.page_2.ingress_discarded_frames;
939 stats->oerrors = value.page_2.egress_discarded_frames;
940 stats->imissed = value.page_2.ingress_nobuffer_discards;
945 RTE_LOG(ERR, PMD, "Operation not completed:Error Code = %d\n", retcode);
950 void dpaa2_dev_stats_reset(struct rte_eth_dev *dev)
952 struct dpaa2_dev_priv *priv = dev->data->dev_private;
953 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
956 PMD_INIT_FUNC_TRACE();
959 RTE_LOG(ERR, PMD, "dpni is NULL");
963 retcode = dpni_reset_statistics(dpni, CMD_PRI_LOW, priv->token);
970 RTE_LOG(ERR, PMD, "Operation not completed:Error Code = %d\n", retcode);
974 /* return 0 means link status changed, -1 means not changed */
976 dpaa2_dev_link_update(struct rte_eth_dev *dev,
977 int wait_to_complete __rte_unused)
980 struct dpaa2_dev_priv *priv = dev->data->dev_private;
981 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
982 struct rte_eth_link link, old;
983 struct dpni_link_state state = {0};
985 PMD_INIT_FUNC_TRACE();
988 RTE_LOG(ERR, PMD, "error : dpni is NULL");
991 memset(&old, 0, sizeof(old));
992 dpaa2_dev_atomic_read_link_status(dev, &old);
994 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
996 RTE_LOG(ERR, PMD, "error: dpni_get_link_state %d", ret);
1000 if ((old.link_status == state.up) && (old.link_speed == state.rate)) {
1001 RTE_LOG(DEBUG, PMD, "No change in status\n");
1005 memset(&link, 0, sizeof(struct rte_eth_link));
1006 link.link_status = state.up;
1007 link.link_speed = state.rate;
1009 if (state.options & DPNI_LINK_OPT_HALF_DUPLEX)
1010 link.link_duplex = ETH_LINK_HALF_DUPLEX;
1012 link.link_duplex = ETH_LINK_FULL_DUPLEX;
1014 dpaa2_dev_atomic_write_link_status(dev, &link);
1016 if (link.link_status)
1017 PMD_DRV_LOG(INFO, "Port %d Link is Up\n", dev->data->port_id);
1019 PMD_DRV_LOG(INFO, "Port %d Link is Down\n", dev->data->port_id);
1024 * Toggle the DPNI to enable, if not already enabled.
1025 * This is not strictly PHY up/down - it is more of logical toggling.
1028 dpaa2_dev_set_link_up(struct rte_eth_dev *dev)
1031 struct dpaa2_dev_priv *priv;
1032 struct fsl_mc_io *dpni;
1035 PMD_INIT_FUNC_TRACE();
1037 priv = dev->data->dev_private;
1038 dpni = (struct fsl_mc_io *)priv->hw;
1041 RTE_LOG(ERR, PMD, "Device has not yet been configured");
1045 /* Check if DPNI is currently enabled */
1046 ret = dpni_is_enabled(dpni, CMD_PRI_LOW, priv->token, &en);
1048 /* Unable to obtain dpni status; Not continuing */
1049 PMD_DRV_LOG(ERR, "Interface Link UP failed (%d)", ret);
1053 /* Enable link if not already enabled */
1055 ret = dpni_enable(dpni, CMD_PRI_LOW, priv->token);
1057 PMD_DRV_LOG(ERR, "Interface Link UP failed (%d)", ret);
1061 /* changing tx burst function to start enqueues */
1062 dev->tx_pkt_burst = dpaa2_dev_tx;
1063 dev->data->dev_link.link_status = 1;
1065 PMD_DRV_LOG(INFO, "Port %d Link UP successful", dev->data->port_id);
1070 * Toggle the DPNI to disable, if not already disabled.
1071 * This is not strictly PHY up/down - it is more of logical toggling.
1074 dpaa2_dev_set_link_down(struct rte_eth_dev *dev)
1077 struct dpaa2_dev_priv *priv;
1078 struct fsl_mc_io *dpni;
1079 int dpni_enabled = 0;
1082 PMD_INIT_FUNC_TRACE();
1084 priv = dev->data->dev_private;
1085 dpni = (struct fsl_mc_io *)priv->hw;
1088 RTE_LOG(ERR, PMD, "Device has not yet been configured");
1092 /*changing tx burst function to avoid any more enqueues */
1093 dev->tx_pkt_burst = dummy_dev_tx;
1095 /* Loop while dpni_disable() attempts to drain the egress FQs
1096 * and confirm them back to us.
1099 ret = dpni_disable(dpni, 0, priv->token);
1101 PMD_DRV_LOG(ERR, "dpni disable failed (%d)", ret);
1104 ret = dpni_is_enabled(dpni, 0, priv->token, &dpni_enabled);
1106 PMD_DRV_LOG(ERR, "dpni_is_enabled failed (%d)", ret);
1110 /* Allow the MC some slack */
1111 rte_delay_us(100 * 1000);
1112 } while (dpni_enabled && --retries);
1115 PMD_DRV_LOG(WARNING, "Retry count exceeded disabling DPNI\n");
1116 /* todo- we may have to manually cleanup queues.
1119 PMD_DRV_LOG(INFO, "Port %d Link DOWN successful",
1120 dev->data->port_id);
1123 dev->data->dev_link.link_status = 0;
1129 dpaa2_flow_ctrl_get(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
1132 struct dpaa2_dev_priv *priv;
1133 struct fsl_mc_io *dpni;
1134 struct dpni_link_state state = {0};
1136 PMD_INIT_FUNC_TRACE();
1138 priv = dev->data->dev_private;
1139 dpni = (struct fsl_mc_io *)priv->hw;
1141 if (dpni == NULL || fc_conf == NULL) {
1142 RTE_LOG(ERR, PMD, "device not configured");
1146 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
1148 RTE_LOG(ERR, PMD, "error: dpni_get_link_state %d", ret);
1152 memset(fc_conf, 0, sizeof(struct rte_eth_fc_conf));
1153 if (state.options & DPNI_LINK_OPT_PAUSE) {
1154 /* DPNI_LINK_OPT_PAUSE set
1155 * if ASYM_PAUSE not set,
1156 * RX Side flow control (handle received Pause frame)
1157 * TX side flow control (send Pause frame)
1158 * if ASYM_PAUSE set,
1159 * RX Side flow control (handle received Pause frame)
1160 * No TX side flow control (send Pause frame disabled)
1162 if (!(state.options & DPNI_LINK_OPT_ASYM_PAUSE))
1163 fc_conf->mode = RTE_FC_FULL;
1165 fc_conf->mode = RTE_FC_RX_PAUSE;
1167 /* DPNI_LINK_OPT_PAUSE not set
1168 * if ASYM_PAUSE set,
1169 * TX side flow control (send Pause frame)
1170 * No RX side flow control (No action on pause frame rx)
1171 * if ASYM_PAUSE not set,
1172 * Flow control disabled
1174 if (state.options & DPNI_LINK_OPT_ASYM_PAUSE)
1175 fc_conf->mode = RTE_FC_TX_PAUSE;
1177 fc_conf->mode = RTE_FC_NONE;
1184 dpaa2_flow_ctrl_set(struct rte_eth_dev *dev, struct rte_eth_fc_conf *fc_conf)
1187 struct dpaa2_dev_priv *priv;
1188 struct fsl_mc_io *dpni;
1189 struct dpni_link_state state = {0};
1190 struct dpni_link_cfg cfg = {0};
1192 PMD_INIT_FUNC_TRACE();
1194 priv = dev->data->dev_private;
1195 dpni = (struct fsl_mc_io *)priv->hw;
1198 RTE_LOG(ERR, PMD, "dpni is NULL");
1202 /* It is necessary to obtain the current state before setting fc_conf
1203 * as MC would return error in case rate, autoneg or duplex values are
1206 ret = dpni_get_link_state(dpni, CMD_PRI_LOW, priv->token, &state);
1208 RTE_LOG(ERR, PMD, "Unable to get link state (err=%d)", ret);
1212 /* Disable link before setting configuration */
1213 dpaa2_dev_set_link_down(dev);
1215 /* Based on fc_conf, update cfg */
1216 cfg.rate = state.rate;
1217 cfg.options = state.options;
1219 /* update cfg with fc_conf */
1220 switch (fc_conf->mode) {
1222 /* Full flow control;
1223 * OPT_PAUSE set, ASYM_PAUSE not set
1225 cfg.options |= DPNI_LINK_OPT_PAUSE;
1226 cfg.options &= ~DPNI_LINK_OPT_ASYM_PAUSE;
1227 case RTE_FC_TX_PAUSE:
1228 /* Enable RX flow control
1229 * OPT_PAUSE not set;
1232 cfg.options |= DPNI_LINK_OPT_ASYM_PAUSE;
1233 cfg.options &= ~DPNI_LINK_OPT_PAUSE;
1235 case RTE_FC_RX_PAUSE:
1236 /* Enable TX Flow control
1240 cfg.options |= DPNI_LINK_OPT_PAUSE;
1241 cfg.options |= DPNI_LINK_OPT_ASYM_PAUSE;
1244 /* Disable Flow control
1246 * ASYM_PAUSE not set
1248 cfg.options &= ~DPNI_LINK_OPT_PAUSE;
1249 cfg.options &= ~DPNI_LINK_OPT_ASYM_PAUSE;
1252 RTE_LOG(ERR, PMD, "Incorrect Flow control flag (%d)",
1257 ret = dpni_set_link_cfg(dpni, CMD_PRI_LOW, priv->token, &cfg);
1259 RTE_LOG(ERR, PMD, "Unable to set Link configuration (err=%d)",
1263 dpaa2_dev_set_link_up(dev);
1268 static struct eth_dev_ops dpaa2_ethdev_ops = {
1269 .dev_configure = dpaa2_eth_dev_configure,
1270 .dev_start = dpaa2_dev_start,
1271 .dev_stop = dpaa2_dev_stop,
1272 .dev_close = dpaa2_dev_close,
1273 .promiscuous_enable = dpaa2_dev_promiscuous_enable,
1274 .promiscuous_disable = dpaa2_dev_promiscuous_disable,
1275 .allmulticast_enable = dpaa2_dev_allmulticast_enable,
1276 .allmulticast_disable = dpaa2_dev_allmulticast_disable,
1277 .dev_set_link_up = dpaa2_dev_set_link_up,
1278 .dev_set_link_down = dpaa2_dev_set_link_down,
1279 .link_update = dpaa2_dev_link_update,
1280 .stats_get = dpaa2_dev_stats_get,
1281 .stats_reset = dpaa2_dev_stats_reset,
1282 .dev_infos_get = dpaa2_dev_info_get,
1283 .dev_supported_ptypes_get = dpaa2_supported_ptypes_get,
1284 .mtu_set = dpaa2_dev_mtu_set,
1285 .vlan_filter_set = dpaa2_vlan_filter_set,
1286 .vlan_offload_set = dpaa2_vlan_offload_set,
1287 .rx_queue_setup = dpaa2_dev_rx_queue_setup,
1288 .rx_queue_release = dpaa2_dev_rx_queue_release,
1289 .tx_queue_setup = dpaa2_dev_tx_queue_setup,
1290 .tx_queue_release = dpaa2_dev_tx_queue_release,
1291 .flow_ctrl_get = dpaa2_flow_ctrl_get,
1292 .flow_ctrl_set = dpaa2_flow_ctrl_set,
1293 .mac_addr_add = dpaa2_dev_add_mac_addr,
1294 .mac_addr_remove = dpaa2_dev_remove_mac_addr,
1295 .mac_addr_set = dpaa2_dev_set_mac_addr,
1299 dpaa2_dev_init(struct rte_eth_dev *eth_dev)
1301 struct rte_device *dev = eth_dev->device;
1302 struct rte_dpaa2_device *dpaa2_dev;
1303 struct fsl_mc_io *dpni_dev;
1304 struct dpni_attr attr;
1305 struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
1306 struct dpni_buffer_layout layout;
1309 PMD_INIT_FUNC_TRACE();
1311 /* For secondary processes, the primary has done all the work */
1312 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1315 dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device);
1317 hw_id = dpaa2_dev->object_id;
1319 dpni_dev = rte_malloc(NULL, sizeof(struct fsl_mc_io), 0);
1321 PMD_INIT_LOG(ERR, "malloc failed for dpni device\n");
1325 dpni_dev->regs = rte_mcp_ptr_list[0];
1326 ret = dpni_open(dpni_dev, CMD_PRI_LOW, hw_id, &priv->token);
1329 "Failure in opening dpni@%d with err code %d\n",
1335 /* Clean the device first */
1336 ret = dpni_reset(dpni_dev, CMD_PRI_LOW, priv->token);
1339 "Failure cleaning dpni@%d with err code %d\n",
1344 ret = dpni_get_attributes(dpni_dev, CMD_PRI_LOW, priv->token, &attr);
1347 "Failure in get dpni@%d attribute, err code %d\n",
1352 priv->num_tc = attr.num_tcs;
1353 for (i = 0; i < attr.num_tcs; i++) {
1354 priv->num_dist_per_tc[i] = attr.num_queues;
1358 /* Distribution is per Tc only,
1359 * so choosing RX queues from default TC only
1361 priv->nb_rx_queues = priv->num_dist_per_tc[DPAA2_DEF_TC];
1363 if (attr.num_tcs == 1)
1364 priv->nb_tx_queues = attr.num_queues;
1366 priv->nb_tx_queues = attr.num_tcs;
1368 PMD_INIT_LOG(DEBUG, "num_tc %d", priv->num_tc);
1369 PMD_INIT_LOG(DEBUG, "nb_rx_queues %d", priv->nb_rx_queues);
1371 priv->hw = dpni_dev;
1372 priv->hw_id = hw_id;
1373 priv->options = attr.options;
1374 priv->max_mac_filters = attr.mac_filter_entries;
1375 priv->max_vlan_filters = attr.vlan_filter_entries;
1378 priv->flags |= DPAA2_TX_CGR_SUPPORT;
1379 PMD_INIT_LOG(INFO, "Enable the tx congestion control support");
1381 /* Allocate memory for hardware structure for queues */
1382 ret = dpaa2_alloc_rx_tx_queues(eth_dev);
1384 PMD_INIT_LOG(ERR, "dpaa2_alloc_rx_tx_queuesFailed\n");
1388 /* Allocate memory for storing MAC addresses */
1389 eth_dev->data->mac_addrs = rte_zmalloc("dpni",
1390 ETHER_ADDR_LEN * attr.mac_filter_entries, 0);
1391 if (eth_dev->data->mac_addrs == NULL) {
1393 "Failed to allocate %d bytes needed to store MAC addresses",
1394 ETHER_ADDR_LEN * attr.mac_filter_entries);
1399 ret = dpni_get_primary_mac_addr(dpni_dev, CMD_PRI_LOW,
1401 (uint8_t *)(eth_dev->data->mac_addrs[0].addr_bytes));
1403 PMD_INIT_LOG(ERR, "DPNI get mac address failed:Err Code = %d\n",
1408 /* ... tx buffer layout ... */
1409 memset(&layout, 0, sizeof(struct dpni_buffer_layout));
1410 layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
1411 layout.pass_frame_status = 1;
1412 ret = dpni_set_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token,
1413 DPNI_QUEUE_TX, &layout);
1415 PMD_INIT_LOG(ERR, "Error (%d) in setting tx buffer layout",
1420 /* ... tx-conf and error buffer layout ... */
1421 memset(&layout, 0, sizeof(struct dpni_buffer_layout));
1422 layout.options = DPNI_BUF_LAYOUT_OPT_FRAME_STATUS;
1423 layout.pass_frame_status = 1;
1424 ret = dpni_set_buffer_layout(dpni_dev, CMD_PRI_LOW, priv->token,
1425 DPNI_QUEUE_TX_CONFIRM, &layout);
1427 PMD_INIT_LOG(ERR, "Error (%d) in setting tx-conf buffer layout",
1432 eth_dev->dev_ops = &dpaa2_ethdev_ops;
1433 eth_dev->data->drv_name = rte_dpaa2_pmd.driver.name;
1435 eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
1436 eth_dev->tx_pkt_burst = dpaa2_dev_tx;
1437 rte_fslmc_vfio_dmamap();
1441 dpaa2_dev_uninit(eth_dev);
1446 dpaa2_dev_uninit(struct rte_eth_dev *eth_dev)
1448 struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
1449 struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
1451 struct dpaa2_queue *dpaa2_q;
1453 PMD_INIT_FUNC_TRACE();
1455 if (rte_eal_process_type() != RTE_PROC_PRIMARY)
1459 PMD_INIT_LOG(WARNING, "Already closed or not started");
1463 dpaa2_dev_close(eth_dev);
1465 if (priv->rx_vq[0]) {
1466 /* cleaning up queue storage */
1467 for (i = 0; i < priv->nb_rx_queues; i++) {
1468 dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
1469 if (dpaa2_q->q_storage)
1470 rte_free(dpaa2_q->q_storage);
1472 /*free the all queue memory */
1473 rte_free(priv->rx_vq[0]);
1474 priv->rx_vq[0] = NULL;
1477 /* free memory for storing MAC addresses */
1478 if (eth_dev->data->mac_addrs) {
1479 rte_free(eth_dev->data->mac_addrs);
1480 eth_dev->data->mac_addrs = NULL;
1483 /* Close the device at underlying layer*/
1484 ret = dpni_close(dpni, CMD_PRI_LOW, priv->token);
1487 "Failure closing dpni device with err code %d\n",
1491 /* Free the allocated memory for ethernet private data and dpni*/
1495 eth_dev->dev_ops = NULL;
1496 eth_dev->rx_pkt_burst = NULL;
1497 eth_dev->tx_pkt_burst = NULL;
1503 rte_dpaa2_probe(struct rte_dpaa2_driver *dpaa2_drv __rte_unused,
1504 struct rte_dpaa2_device *dpaa2_dev)
1506 struct rte_eth_dev *eth_dev;
1507 char ethdev_name[RTE_ETH_NAME_MAX_LEN];
1511 sprintf(ethdev_name, "dpni-%d", dpaa2_dev->object_id);
1513 eth_dev = rte_eth_dev_allocate(ethdev_name);
1514 if (eth_dev == NULL)
1517 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
1518 eth_dev->data->dev_private = rte_zmalloc(
1519 "ethdev private structure",
1520 sizeof(struct dpaa2_dev_priv),
1521 RTE_CACHE_LINE_SIZE);
1522 if (eth_dev->data->dev_private == NULL) {
1523 PMD_INIT_LOG(CRIT, "Cannot allocate memzone for"
1524 " private port data\n");
1525 rte_eth_dev_release_port(eth_dev);
1529 eth_dev->device = &dpaa2_dev->device;
1530 dpaa2_dev->eth_dev = eth_dev;
1531 eth_dev->data->rx_mbuf_alloc_failed = 0;
1533 /* Invoke PMD device initialization function */
1534 diag = dpaa2_dev_init(eth_dev);
1538 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
1539 rte_free(eth_dev->data->dev_private);
1540 rte_eth_dev_release_port(eth_dev);
1545 rte_dpaa2_remove(struct rte_dpaa2_device *dpaa2_dev)
1547 struct rte_eth_dev *eth_dev;
1549 eth_dev = dpaa2_dev->eth_dev;
1550 dpaa2_dev_uninit(eth_dev);
1552 if (rte_eal_process_type() == RTE_PROC_PRIMARY)
1553 rte_free(eth_dev->data->dev_private);
1554 rte_eth_dev_release_port(eth_dev);
1559 static struct rte_dpaa2_driver rte_dpaa2_pmd = {
1560 .drv_type = DPAA2_MC_DPNI_DEVID,
1561 .probe = rte_dpaa2_probe,
1562 .remove = rte_dpaa2_remove,
1565 RTE_PMD_REGISTER_DPAA2(net_dpaa2, rte_dpaa2_pmd);