Re: [PATCH v2 03/14] net/dpaa: remove broken debug macros

2024-10-01 Thread Hemant Agrawal



On 01-10-2024 17:38, David Marchand wrote:

On Tue, Oct 1, 2024 at 12:19 PM Thomas Monjalon  wrote:

12/09/2024 10:26, David Marchand:

Those debug macros never worked as existing callers never passed a
'level' argument.
Remove them.

Signed-off-by: David Marchand 

Why not removing the calls to these macros?

I was unclear if the fmlib enters the "base driver" category.
So I simply removed macros from the header providing wrappers to dpdk API.

Relooking, I see other changes in this directory, so I agree I may as
well remove those calls.

Hemant, opinion?

Yes, fmlib is a common base library. So, it is better to not remove the 
calls.  Otherwise, we have to maintain the changes from base.


with that

Reviewed-by:  Hemant Agrawal 




[PATCH v5 07/18] net/dpaa: add support to separate Tx conf queues

2024-10-01 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch separates Tx confirmation queues for kernel
and DPDK so as to support the VSP case.

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
 drivers/bus/dpaa/include/fsl_qman.h |  4 ++-
 drivers/net/dpaa/dpaa_ethdev.c  | 45 +
 drivers/net/dpaa/dpaa_rxtx.c|  3 +-
 3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/drivers/bus/dpaa/include/fsl_qman.h 
b/drivers/bus/dpaa/include/fsl_qman.h
index c0677976e8..db14dfb839 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2008-2012 Freescale Semiconductor, Inc.
- * Copyright 2019 NXP
+ * Copyright 2019-2022 NXP
  *
  */
 
@@ -1237,6 +1237,8 @@ struct qman_fq {
 
/* DPDK Interface */
void *dpaa_intf;
+   /*to store tx_conf_queue corresponding to tx_queue*/
+   struct qman_fq *tx_conf_queue;
 
struct rte_event ev;
/* affined portal in case of static queue */
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index bba305cfb1..3ee3029729 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1870,9 +1870,30 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
return ret;
 }
 
-/* Initialise a DEBUG FQ ([rt]x_error, rx_default) and DPAA TX CONFIRM queue
- * to support PTP
- */
+static int
+dpaa_tx_conf_queue_init(struct qman_fq *fq)
+{
+   struct qm_mcc_initfq opts = {0};
+   int ret;
+
+   PMD_INIT_FUNC_TRACE();
+
+   ret = qman_create_fq(0, QMAN_FQ_FLAG_DYNAMIC_FQID, fq);
+   if (ret) {
+   DPAA_PMD_ERR("create Tx_conf failed with ret: %d", ret);
+   return ret;
+   }
+
+   opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL;
+   opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
+   ret = qman_init_fq(fq, 0, &opts);
+   if (ret)
+   DPAA_PMD_ERR("init Tx_conf fqid %d failed with ret: %d",
+   fq->fqid, ret);
+   return ret;
+}
+
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
 static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
struct qm_mcc_initfq opts = {0};
@@ -2170,6 +2191,15 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
if (ret)
goto free_tx;
dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf;
+
+   if (dpaa_ieee_1588) {
+   ret = 
dpaa_tx_conf_queue_init(&dpaa_intf->tx_conf_queues[loop]);
+   if (ret)
+   goto free_tx;
+
+   dpaa_intf->tx_conf_queues[loop].dpaa_intf = dpaa_intf;
+   dpaa_intf->tx_queues[loop].tx_conf_queue = 
&dpaa_intf->tx_conf_queues[loop];
+   }
}
dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
 
@@ -2190,16 +2220,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
DPAA_PMD_ERR("DPAA TX ERROR queue init failed!");
goto free_tx;
}
-   dpaa_intf->debug_queues[DPAA_DEBUG_FQ_TX_ERROR].dpaa_intf = 
dpaa_intf;
-   ret = dpaa_def_queue_init(dpaa_intf->tx_conf_queues,
-   fman_intf->fqid_tx_confirm);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA TX CONFIRM queue init failed!");
-   goto free_tx;
-   }
-   dpaa_intf->tx_conf_queues->dpaa_intf = dpaa_intf;
}
-
DPAA_PMD_DEBUG("All frame queues created");
 
/* Get the initial configuration for flow control */
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 8593e20200..3bd35c7a0e 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1083,8 +1083,7 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
struct dpaa_sw_buf_free buf_to_free[DPAA_MAX_SGS * 
DPAA_MAX_DEQUEUE_NUM_FRAMES];
uint32_t free_count = 0;
struct qman_fq *fq = q;
-   struct dpaa_if *dpaa_intf = fq->dpaa_intf;
-   struct qman_fq *fq_txconf = dpaa_intf->tx_conf_queues;
+   struct qman_fq *fq_txconf = fq->tx_conf_queue;
 
if (unlikely(!DPAA_PER_LCORE_PORTAL)) {
ret = rte_dpaa_portal_init((void *)0);
-- 
2.25.1



[PATCH v5 01/18] bus/dpaa: fix PFDRs leaks due to FQRNIs

2024-10-01 Thread Hemant Agrawal
From: Gagandeep Singh 

When a Retire FQ command is executed on a FQ in the
Tentatively Scheduled or Parked states, in that case FQ
is retired immediately and a FQRNI (Frame Queue Retirement
Notification Immediate) message is generated. Software
must read this message from MR and consume it to free
the memory used by it.

Although it is not mentioned about which memory to be used
by FQRNIs in the RM but through experiments it is proven
that it can use PFDRs. So if these messages are allowed to
build up indefinitely then PFDR resources can become exhausted
and cause enqueues to stall. Therefore software must consume
these MR messages on a regular basis to avoid depleting
the available PFDR resources.

This is the PFDRs leak issue which user can experienace while
using the DPDK crypto driver and creating and destroying the
sessions multiple times. On a session destroy, DPDK calls the
qman_retire_fq() for each FQ used by the session, but it does
not handle the FQRNIs generated and allowed them to build up
indefinitely in MR.

This patch fixes this issue by consuming the FQRNIs received
from MR immediately after FQ retire by calling drain_mr_fqrni().

Please note that this drain_mr_fqrni() only look for
FQRNI type messages to consume. If there are other type of messages
like FQRN, FQRL, FQPN, ERN etc. also coming on MR then those
messages need to be handled separately.

Fixes: c47ff048b99a ("bus/dpaa: add QMAN driver core routines")
Cc: sta...@dpdk.org

Signed-off-by: Gagandeep Singh 
---
 drivers/bus/dpaa/base/qbman/qman.c | 46 --
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman.c 
b/drivers/bus/dpaa/base/qbman/qman.c
index 301057723e..9c90ee25a6 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -292,10 +292,32 @@ static inline void qman_stop_dequeues_ex(struct 
qman_portal *p)
qm_dqrr_set_maxfill(&p->p, 0);
 }
 
+static inline void qm_mr_pvb_update(struct qm_portal *portal)
+{
+   register struct qm_mr *mr = &portal->mr;
+   const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
+
+#ifdef RTE_LIBRTE_DPAA_HWDEBUG
+   DPAA_ASSERT(mr->pmode == qm_mr_pvb);
+#endif
+   /* when accessing 'verb', use __raw_readb() to ensure that compiler
+* inlining doesn't try to optimise out "excess reads".
+*/
+   if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
+   mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
+   if (!mr->pi)
+   mr->vbit ^= QM_MR_VERB_VBIT;
+   mr->fill++;
+   res = MR_INC(res);
+   }
+   dcbit_ro(res);
+}
+
 static int drain_mr_fqrni(struct qm_portal *p)
 {
const struct qm_mr_entry *msg;
 loop:
+   qm_mr_pvb_update(p);
msg = qm_mr_current(p);
if (!msg) {
/*
@@ -317,6 +339,7 @@ static int drain_mr_fqrni(struct qm_portal *p)
do {
now = mfatb();
} while ((then + 1) > now);
+   qm_mr_pvb_update(p);
msg = qm_mr_current(p);
if (!msg)
return 0;
@@ -479,27 +502,6 @@ static inline int qm_mr_init(struct qm_portal *portal,
return 0;
 }
 
-static inline void qm_mr_pvb_update(struct qm_portal *portal)
-{
-   register struct qm_mr *mr = &portal->mr;
-   const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
-
-#ifdef RTE_LIBRTE_DPAA_HWDEBUG
-   DPAA_ASSERT(mr->pmode == qm_mr_pvb);
-#endif
-   /* when accessing 'verb', use __raw_readb() to ensure that compiler
-* inlining doesn't try to optimise out "excess reads".
-*/
-   if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
-   mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
-   if (!mr->pi)
-   mr->vbit ^= QM_MR_VERB_VBIT;
-   mr->fill++;
-   res = MR_INC(res);
-   }
-   dcbit_ro(res);
-}
-
 struct qman_portal *
 qman_init_portal(struct qman_portal *portal,
   const struct qm_portal_config *c,
@@ -1794,6 +1796,8 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
}
 out:
FQUNLOCK(fq);
+   /* Draining FQRNIs, if any */
+   drain_mr_fqrni(&p->p);
return rval;
 }
 
-- 
2.25.1



[PATCH v5 03/18] bus/dpaa: fix VSP for 1G fm1-mac9 and 10

2024-10-01 Thread Hemant Agrawal
No need to classify interface separately for 1G and 10G
Note that VSP or Virtual storage profile are DPAA equivalent for SRIOV
config to logically divide a physical ports in virtual ports.

Fixes: e0718bb2ca95 ("bus/dpaa: add virtual storage profile port init")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index 41195eb0a7..beeb03dbf2 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -153,7 +153,7 @@ static void fman_if_vsp_init(struct __fman_if *__if)
size_t lenp;
const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
-   if (__if->__if.mac_type == fman_mac_1g) {
+   if (__if->__if.mac_idx <= 8) {
for_each_compatible_node(dev, NULL,
"fsl,fman-port-1g-rx-extended-args") {
prop = of_get_property(dev, "cell-index", &lenp);
@@ -176,7 +176,32 @@ static void fman_if_vsp_init(struct __fman_if *__if)
}
}
}
-   } else if (__if->__if.mac_type == fman_mac_10g) {
+
+   for_each_compatible_node(dev, NULL,
+"fsl,fman-port-op-extended-args") {
+   prop = of_get_property(dev, "cell-index", &lenp);
+
+   if (prop) {
+   cell_index = of_read_number(&prop[0],
+   lenp / sizeof(phandle));
+
+   if (cell_index == __if->__if.mac_idx) {
+   prop = of_get_property(dev,
+  "vsp-window",
+  &lenp);
+
+   if (prop) {
+   __if->__if.num_profiles =
+   of_read_number(&prop[0],
+  1);
+   __if->__if.base_profile_id =
+   of_read_number(&prop[1],
+  1);
+   }
+   }
+   }
+   }
+   } else {
for_each_compatible_node(dev, NULL,
"fsl,fman-port-10g-rx-extended-args") {
prop = of_get_property(dev, "cell-index", &lenp);
-- 
2.25.1



[PATCH v5 12/18] net/dpaa: enhance DPAA frame display

2024-10-01 Thread Hemant Agrawal
This patch enhances the received packet debugging capability.
This help displaying the full packet parsing output.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
 doc/guides/nics/dpaa.rst   |   5 ++
 drivers/net/dpaa/dpaa_ethdev.c |   9 +++
 drivers/net/dpaa/dpaa_rxtx.c   | 138 +++--
 drivers/net/dpaa/dpaa_rxtx.h   |   5 ++
 4 files changed, 133 insertions(+), 24 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index ea86e6146c..edf7a7e350 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -227,6 +227,11 @@ state during application initialization:
   application want to use eventdev with DPAA device.
   Currently these queues are not used for LS1023/LS1043 platform by default.
 
+- ``DPAA_DISPLAY_FRAME_AND_PARSER_RESULT`` (default 0)
+
+  This defines the debug flag, whether to dump the detailed frame and packet
+  parsing result for the incoming packets.
+
 
 Driver compilation and testing
 --
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index a302b24be6..4ead890278 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -2056,6 +2056,9 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
int8_t dev_vspids[DPAA_MAX_NUM_PCD_QUEUES];
int8_t vsp_id = -1;
struct rte_device *dev = eth_dev->device;
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+   char *penv;
+#endif
 
PMD_INIT_FUNC_TRACE();
 
@@ -2135,6 +2138,12 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
td_tx_threshold = CGR_RX_PERFQ_THRESH;
}
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+   penv = getenv("DPAA_DISPLAY_FRAME_AND_PARSER_RESULT");
+   if (penv)
+   dpaa_force_display_frame_set(atoi(penv));
+#endif
+
/* If congestion control is enabled globally*/
if (num_rx_fqs > 0 && td_threshold) {
dpaa_intf->cgr_rx = rte_zmalloc(NULL,
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 99fc3f1b43..945c84ab10 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -47,6 +47,10 @@
 #include 
 #include 
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+static int s_force_display_frm;
+#endif
+
 #define DPAA_MBUF_TO_CONTIG_FD(_mbuf, _fd, _bpid) \
do { \
(_fd)->opaque_addr = 0; \
@@ -58,37 +62,122 @@
} while (0)
 
 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+void
+dpaa_force_display_frame_set(int set)
+{
+   s_force_display_frm = set;
+}
+
 #define DISPLAY_PRINT printf
-static void dpaa_display_frame_info(const struct qm_fd *fd,
-   uint32_t fqid, bool rx)
+static void
+dpaa_display_frame_info(const struct qm_fd *fd,
+   uint32_t fqid, bool rx)
 {
-   int ii;
-   char *ptr;
+   int pos, offset = 0;
+   char *ptr, info[1024];
struct annotations_t *annot = rte_dpaa_mem_ptov(fd->addr);
uint8_t format;
+   const struct dpaa_eth_parse_results_t *psr;
 
-   if (!fd->status) {
-   /* Do not display correct packets.*/
+   if (!fd->status && !s_force_display_frm) {
+   /* Do not display correct packets unless force display.*/
return;
}
+   psr = &annot->parse;
 
-   format = (fd->opaque & DPAA_FD_FORMAT_MASK) >>
-   DPAA_FD_FORMAT_SHIFT;
-
-   DISPLAY_PRINT("fqid %d bpid %d addr 0x%lx, format %d\r\n",
- fqid, fd->bpid, (unsigned long)fd->addr, fd->format);
-   DISPLAY_PRINT("off %d, len %d stat 0x%x\r\n",
- fd->offset, fd->length20, fd->status);
+   format = (fd->opaque & DPAA_FD_FORMAT_MASK) >> DPAA_FD_FORMAT_SHIFT;
+   if (format == qm_fd_contig)
+   sprintf(info, "simple");
+   else if (format == qm_fd_sg)
+   sprintf(info, "sg");
+   else
+   sprintf(info, "unknown format(%d)", format);
+
+   DISPLAY_PRINT("%s: fqid=%08x, bpid=%d, phy addr=0x%lx ",
+   rx ? "RX" : "TX", fqid, fd->bpid, (unsigned long)fd->addr);
+   DISPLAY_PRINT("format=%s offset=%d, len=%d, stat=0x%x\r\n",
+   info, fd->offset, fd->length20, fd->status);
if (rx) {
-   ptr = (char *)&annot->parse;
-   DISPLAY_PRINT("RX parser result:\r\n");
-   for (ii = 0; ii < (int)sizeof(struct dpaa_eth_parse_results_t);
-   ii++) {
-   DISPLAY_PRINT("%02x ", ptr[ii]);
-   if (((ii + 1) % 16) == 0)
-   DISPLAY_PRINT("\n");
+   DISPLAY_PRINT("Display usual RX parser result:\r\n");
+   

[PATCH v5 15/18] bus/dpaa: add ONIC port mode for the DPAA eth

2024-10-01 Thread Hemant Agrawal
From: Rohit Raj 

The OH ports can also be used by two application, processing contexts
to communicate to each other.
This patch enables this mode for dpaa-eth OH port as ONIC port,
so that application can use the dpaa-eth to communicate to each
other on the same SoC.

Again,this properties is driven by the system device-tree variables.

Signed-off-by: Rohit Raj 
---
 doc/guides/nics/dpaa.rst  |  33 ++-
 drivers/bus/dpaa/base/fman/fman.c | 299 +-
 drivers/bus/dpaa/base/fman/fman_hw.c  |  20 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |   4 +-
 drivers/bus/dpaa/dpaa_bus.c   |  16 +-
 drivers/bus/dpaa/include/fman.h   |  15 +-
 drivers/net/dpaa/dpaa_ethdev.c| 114 +++--
 drivers/net/dpaa/dpaa_flow.c  |  23 +-
 drivers/net/dpaa/dpaa_fmc.c   |   2 +-
 9 files changed, 467 insertions(+), 59 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index 47dcce334c..a266e71a5b 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -136,7 +136,7 @@ RTE framework and DPAA internal components/drivers.
   The Ethernet driver is bound to a FMAN port and implements the interfaces
   needed to connect the DPAA network interface to the network stack.
   Each FMAN Port corresponds to a DPDK network interface.
-- PMD also support OH mode, where the port works as a HW assisted
+- PMD also support OH/ONIC mode, where the port works as a HW assisted
   virtual port without actually connecting to a Physical MAC.
 
 
@@ -152,7 +152,7 @@ Features
   - Promiscuous mode
   - IEEE1588 PTP
   - OH Port for inter application communication
-
+  - ONIC virtual port support
 
 DPAA Mempool Driver
 ~~~
@@ -350,6 +350,35 @@ OH Port
  Rx Packets  -
 
 
+ONIC
+
+   To use OH port to communicate between two applications, we can assign Rx 
port
+   of an O/H port to Application 1 and Tx port to Application 2 so that
+   Application 1 can send packets to Application 2. Similarly, we can assign Tx
+   port of another O/H port to Application 1 and Rx port to Application 2 so 
that
+   Application 2 can send packets to Application 1.
+
+   ONIC is logically defined to achieve it. Internally it will use one Rx queue
+   of an O/H port and one Tx queue of another O/H port.
+   For application, it will behave as single O/H port.
+
+   +--+ +--++--++--++--+
+   |  |   Tx|  |   Rx   | O/H  |   Tx   |  |   Rx   |  |
+   |  | - - - > |  | -  - > | Port | -  - > |  | -  - > |  |
+   |  | |  ||  1   ||  ||  |
+   |  | |  |+--+|  ||  |
+   | App  | | ONIC || ONIC || App  |
+   |  1   | | Port || Port ||  2   |
+   |  | |  1   |+--+|  2   ||  |
+   |  |   Rx|  |   Tx   | O/H  |   Rx   |  |   Tx   |  |
+   |  | < - - - |  | < - - -| Port | < - - -|  | < - - -|  |
+   |  | |  ||  2   ||  ||  |
+   +--+ +--++--++--++--+
+
+   All the packets received by ONIC port 1 will be send to ONIC port 2 and vice
+   versa. These ports can be used by DPDK applications just like physical 
ports.
+
+
 VSP (Virtual Storage Profile)
 ~
The storage profiled are means to provide virtualized interface. A ranges of
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index f817305ab7..efe6eab4a9 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -43,7 +43,7 @@ if_destructor(struct __fman_if *__if)
if (!__if)
return;
 
-   if (__if->__if.mac_type == fman_offline)
+   if (__if->__if.mac_type == fman_offline_internal)
goto cleanup;
 
list_for_each_entry_safe(bp, tmpbp, &__if->__if.bpool_list, node) {
@@ -465,7 +465,7 @@ fman_if_init(const struct device_node *dpa_node)
__if->__if.is_memac = 0;
 
if (is_offline)
-   __if->__if.mac_type = fman_offline;
+   __if->__if.mac_type = fman_offline_internal;
else if (of_device_is_compatible(mac_node, "fsl,fman-1g-mac"))
__if->__if.mac_type = fman_mac_1g;
else if (of_device_is_compatible(mac_node, "fsl,fman-10g-mac"))
@@ -791,6 +791,292 @@ fman_if_init(const struct device_node *dpa_node)
dname, __if->__if.tx_channel_id, __if->__if.fman_idx,
__if->__if.mac_idx);
 
+   /* Don't add OH port to the port list since they will be used by ONIC
+* ports.
+*/
+   if (!is_offline)
+   list_add_tail(&__if->__if.n

[PATCH v5 06/18] net/dpaa: support Tx confirmation to enable PTP

2024-10-01 Thread Hemant Agrawal
From: Vanshika Shukla 

TX confirmation provides dedicated confirmation
queues for transmitted packets. These queues are
used by software to get the status and release
transmitted packets buffers.

This patch also changes the IEEE1588 support as devargs

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
 doc/guides/nics/dpaa.rst   |   3 +
 drivers/net/dpaa/dpaa_ethdev.c | 124 ++---
 drivers/net/dpaa/dpaa_ethdev.h |   4 +-
 drivers/net/dpaa/dpaa_rxtx.c   |  49 +
 drivers/net/dpaa/dpaa_rxtx.h   |   2 +
 5 files changed, 154 insertions(+), 28 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index e8402dff52..acf4daab02 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -264,6 +264,9 @@ for details.
   Done
   testpmd>
 
+* Use dev arg option ``drv_ieee1588=1`` to enable ieee 1588 support at
+  driver level. e.g. ``dpaa:fm1-mac3,drv_ieee1588=1``
+
 FMAN Config
 ---
 
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 90b34e42f2..bba305cfb1 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017-2020 NXP
+ *   Copyright 2017-2020,2022-2024 NXP
  *
  */
 /* System headers */
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,6 +51,7 @@
 #include 
 #include 
 
+#define DRIVER_IEEE1588"drv_ieee1588"
 #define CHECK_INTERVAL 100  /* 100ms */
 #define MAX_REPEAT_TIME90   /* 9s (90 * 100ms) in total */
 
@@ -83,6 +85,7 @@ static uint64_t dev_tx_offloads_nodis =
 static int is_global_init;
 static int fmc_q = 1;  /* Indicates the use of static fmc for distribution */
 static int default_q;  /* use default queue - FMC is not executed*/
+int dpaa_ieee_1588;/* use to indicate if IEEE 1588 is enabled for the 
driver */
 /* At present we only allow up to 4 push mode queues as default - as each of
  * this queue need dedicated portal and we are short of portals.
  */
@@ -1826,9 +1829,15 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
opts.fqd.dest.wq = DPAA_IF_TX_PRIORITY;
opts.fqd.fq_ctrl = QM_FQCTRL_PREFERINCACHE;
opts.fqd.context_b = 0;
-   /* no tx-confirmation */
-   opts.fqd.context_a.hi = 0x8000 | fman_dealloc_bufs_mask_hi;
-   opts.fqd.context_a.lo = 0 | fman_dealloc_bufs_mask_lo;
+   if (dpaa_ieee_1588) {
+   opts.fqd.context_a.lo = 0;
+   opts.fqd.context_a.hi = fman_dealloc_bufs_mask_hi;
+   } else {
+   /* no tx-confirmation */
+   opts.fqd.context_a.lo = fman_dealloc_bufs_mask_lo;
+   opts.fqd.context_a.hi = 0x8000 | fman_dealloc_bufs_mask_hi;
+   }
+
if (fman_ip_rev >= FMAN_V3) {
/* Set B0V bit in contextA to set ASPID to 0 */
opts.fqd.context_a.hi |= 0x0400;
@@ -1861,9 +1870,10 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
return ret;
 }
 
-#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
-/* Initialise a DEBUG FQ ([rt]x_error, rx_default). */
-static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default) and DPAA TX CONFIRM queue
+ * to support PTP
+ */
+static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
struct qm_mcc_initfq opts = {0};
int ret;
@@ -1872,15 +1882,15 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, 
uint32_t fqid)
 
ret = qman_reserve_fqid(fqid);
if (ret) {
-   DPAA_PMD_ERR("Reserve debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("Reserve fqid %d failed with ret: %d",
fqid, ret);
return -EINVAL;
}
/* "map" this Rx FQ to one of the interfaces Tx FQID */
-   DPAA_PMD_DEBUG("Creating debug fq %p, fqid %d", fq, fqid);
+   DPAA_PMD_DEBUG("Creating fq %p, fqid %d", fq, fqid);
ret = qman_create_fq(fqid, QMAN_FQ_FLAG_NO_ENQUEUE, fq);
if (ret) {
-   DPAA_PMD_ERR("create debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("create fqid %d failed with ret: %d",
fqid, ret);
return ret;
}
@@ -1888,11 +1898,10 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, 
uint32_t fqid)
opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
ret = qman_init_fq(fq, 0, &opts);
if (ret)
-   DPAA_PMD_ERR("init debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("init fqid %d failed with ret: %d",
fqid, ret);
return ret;
 }
-#endif
 
 /* Initialise a network interfa

[PATCH v5 17/18] net/dpaa: improve dpaa errata A010022 handling

2024-10-01 Thread Hemant Agrawal
From: Jun Yang 

This patch improves the errata handling for
"RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022"

Signed-off-by: Jun Yang 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index d82c6f3be2..1d7efdef88 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1258,6 +1258,35 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
return new_mbufs[0];
 }
 
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+/* In case the data offset is not multiple of 16,
+ * FMAN can stall because of an errata. So reallocate
+ * the buffer in such case.
+ */
+static inline int
+dpaa_eth_ls1043a_mbuf_realloc(struct rte_mbuf *mbuf)
+{
+   uint64_t len, offset;
+
+   if (dpaa_svr_family != SVR_LS1043A_FAMILY)
+   return 0;
+
+   while (mbuf) {
+   len = mbuf->data_len;
+   offset = mbuf->data_off;
+   if ((mbuf->next &&
+   !rte_is_aligned((void *)len, 16)) ||
+   !rte_is_aligned((void *)offset, 16)) {
+   DPAA_PMD_DEBUG("Errata condition hit");
+
+   return 1;
+   }
+   mbuf = mbuf->next;
+   }
+   return 0;
+}
+#endif
+
 uint16_t
 dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
@@ -1296,14 +1325,6 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_BURST_SIZE : nb_bufs;
for (loop = 0; loop < frames_to_send; loop++) {
mbuf = *(bufs++);
-   /* In case the data offset is not multiple of 16,
-* FMAN can stall because of an errata. So reallocate
-* the buffer in such case.
-*/
-   if (dpaa_svr_family == SVR_LS1043A_FAMILY &&
-   (mbuf->data_off & 0x7F) != 0x0)
-   realloc_mbuf = 1;
-
fd_arr[loop].cmd = 0;
if (dpaa_ieee_1588) {
fd_arr[loop].cmd |= DPAA_FD_CMD_FCO |
@@ -1311,6 +1332,9 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
fd_arr[loop].cmd |= DPAA_FD_CMD_RPD |
DPAA_FD_CMD_UPD;
}
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+   realloc_mbuf = dpaa_eth_ls1043a_mbuf_realloc(mbuf);
+#endif
seqn = *dpaa_seqn(mbuf);
if (seqn != DPAA_INVALID_MBUF_SEQN) {
index = seqn - 1;
-- 
2.25.1



[PATCH v5 10/18] net/dpaa: support IEEE 1588 PTP

2024-10-01 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch adds the support for the ethdev APIs
to enable/disable and read/write/adjust IEEE1588
PTP timestamps for DPAA platform.

Signed-off-by: Vanshika Shukla 
---
 doc/guides/nics/dpaa.rst  |  1 +
 doc/guides/nics/features/dpaa.ini |  1 +
 drivers/bus/dpaa/base/fman/fman.c | 15 ++
 drivers/bus/dpaa/include/fman.h   | 45 +
 drivers/net/dpaa/dpaa_ethdev.c|  5 ++
 drivers/net/dpaa/dpaa_ethdev.h| 16 +++
 drivers/net/dpaa/dpaa_ptp.c   | 80 ++-
 7 files changed, 161 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index acf4daab02..ea86e6146c 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -148,6 +148,7 @@ Features
   - Packet type information
   - Checksum offload
   - Promiscuous mode
+  - IEEE1588 PTP
 
 DPAA Mempool Driver
 ~~~
diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index 4196dd800c..4f31b61de1 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -19,6 +19,7 @@ Flow control = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Timesync = Y
 Timestamp offload= Y
 Basic stats  = Y
 Extended stats   = Y
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index e39bc8c252..e2b7120237 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -28,6 +28,7 @@ u32 fman_dealloc_bufs_mask_lo;
 
 int fman_ccsr_map_fd = -1;
 static COMPAT_LIST_HEAD(__ifs);
+void *rtc_map;
 
 /* This is the (const) global variable that callers have read-only access to.
  * Internally, we have read-write access directly to __ifs.
@@ -539,6 +540,20 @@ fman_if_init(const struct device_node *dpa_node)
goto err;
}
 
+   if (!rtc_map) {
+   __if->rtc_map = mmap(NULL, FMAN_IEEE_1588_SIZE,
+   PROT_READ | PROT_WRITE, MAP_SHARED,
+   fman_ccsr_map_fd, FMAN_IEEE_1588_OFFSET);
+   if (__if->rtc_map == MAP_FAILED) {
+   pr_err("Can not map FMan RTC regs base\n");
+   _errno = -EINVAL;
+   goto err;
+   }
+   rtc_map = __if->rtc_map;
+   } else {
+   __if->rtc_map = rtc_map;
+   }
+
/* No channel ID for MAC-less */
assert(lenp == sizeof(*tx_channel_id));
na = of_n_addr_cells(mac_node);
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 09d1ddb897..e8bc913943 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -64,6 +64,12 @@
 #define GROUP_ADDRESS  0x0100LL
 #define HASH_CTRL_ADDR_MASK0x003F
 
+#define FMAN_RTC_MAX_NUM_OF_ALARMS 3
+#define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES4
+#define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS   3
+#define FMAN_IEEE_1588_OFFSET  0X1AFE000
+#define FMAN_IEEE_1588_SIZE4096
+
 /* Pre definitions of FMAN interface and Bpool structures */
 struct __fman_if;
 struct fman_if_bpool;
@@ -307,6 +313,44 @@ struct tx_bmi_regs {
uint32_t fmbm_trlmts;   /**< Tx Rate Limiter Scale*/
uint32_t fmbm_trlmt;/**< Tx Rate Limiter*/
 };
+
+/* Description FM RTC timer alarm */
+struct t_tmr_alarm {
+   uint32_t tmr_alarm_h;
+   uint32_t tmr_alarm_l;
+};
+
+/* Description FM RTC timer Ex trigger */
+struct t_tmr_ext_trigger {
+   uint32_t tmr_etts_h;
+   uint32_t tmr_etts_l;
+};
+
+struct rtc_regs {
+   uint32_t tmr_id;/* 0x000 Module ID register */
+   uint32_t tmr_id2;   /* 0x004 Controller ID register */
+   uint32_t reserved0008[30];
+   uint32_t tmr_ctrl;  /* 0x0080 timer control register */
+   uint32_t tmr_tevent;/* 0x0084 timer event register */
+   uint32_t tmr_temask;/* 0x0088 timer event mask register */
+   uint32_t reserved008c[3];
+   uint32_t tmr_cnt_h; /* 0x0098 timer counter high register */
+   uint32_t tmr_cnt_l; /* 0x009c timer counter low register */
+   uint32_t tmr_add;   /* 0x00a0 timer drift compensation addend 
register */
+   uint32_t tmr_acc;   /* 0x00a4 timer accumulator register */
+   uint32_t tmr_prsc;  /* 0x00a8 timer prescale */
+   uint32_t reserved00ac;
+   uint32_t tmr_off_h; /* 0x00b0 timer offset high */
+   uint32_t tmr_off_l; /* 0x00b4 timer offset low  */
+   struct t_tmr_alarm tmr_alarm[FMAN_RTC_MAX_NUM_OF_ALARMS];
+   /* 0x00b8 timer alarm */
+   uint32_t tmr_fiper[FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES];
+   /* 0x00d0 timer fixed period interval */
+   struct t_tmr_ext_trigger tmr_etts[FMAN_RTC_MAX_NUM_OF_EXT_TR

[PATCH v5 16/18] net/dpaa: improve the dpaa port cleanup

2024-10-01 Thread Hemant Agrawal
From: Gagandeep Singh 

During DPAA cleanup in FMCLESS mode, application can
see segmentation fault in device close API and in DPAA
destructor execution.
Segmentation fault in device close is because driver
reducing the number of queues initialised during
device configuration without releasing the actual queues.

And segmentation fault in DPAA destruction is because
it is trying to access RTE* devices whose memory has
been released in rte_eal_cleanup() call by the application.

This patch improves the behavior.

Signed-off-by: Gagandeep Singh 
---
 drivers/net/dpaa/dpaa_ethdev.c | 33 +++--
 drivers/net/dpaa/dpaa_flow.c   |  5 ++---
 2 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 133fbd5bc9..41ae033c75 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -561,10 +561,10 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
if (dpaa_intf->cgr_rx) {
for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
+   rte_free(dpaa_intf->cgr_rx);
+   dpaa_intf->cgr_rx = NULL;
}
 
-   rte_free(dpaa_intf->cgr_rx);
-   dpaa_intf->cgr_rx = NULL;
/* Release TX congestion Groups */
if (dpaa_intf->cgr_tx) {
for (loop = 0; loop < MAX_DPAA_CORES; loop++)
@@ -578,6 +578,15 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 
rte_free(dpaa_intf->tx_queues);
dpaa_intf->tx_queues = NULL;
+   if (dpaa_intf->port_handle) {
+   if (dpaa_fm_deconfig(dpaa_intf, fif))
+   DPAA_PMD_WARN("DPAA FM "
+   "deconfig failed\n");
+   }
+   if (fif->num_profiles) {
+   if (dpaa_port_vsp_cleanup(dpaa_intf, fif))
+   DPAA_PMD_WARN("DPAA FM vsp cleanup failed\n");
+   }
 
return ret;
 }
@@ -2607,26 +2616,6 @@ static void __attribute__((destructor(102))) 
dpaa_finish(void)
return;
 
if (!(default_q || fmc_q)) {
-   unsigned int i;
-
-   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-   if (rte_eth_devices[i].dev_ops == &dpaa_devops) {
-   struct rte_eth_dev *dev = &rte_eth_devices[i];
-   struct dpaa_if *dpaa_intf =
-   dev->data->dev_private;
-   struct fman_if *fif =
-   dev->process_private;
-   if (dpaa_intf->port_handle)
-   if (dpaa_fm_deconfig(dpaa_intf, fif))
-   DPAA_PMD_WARN("DPAA FM "
-   "deconfig failed");
-   if (fif->num_profiles) {
-   if (dpaa_port_vsp_cleanup(dpaa_intf,
- fif))
-   DPAA_PMD_WARN("DPAA FM vsp 
cleanup failed");
-   }
-   }
-   }
if (is_global_init)
if (dpaa_fm_term())
DPAA_PMD_WARN("DPAA FM term failed");
diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c
index 9fd40fa47e..8d0875f5ec 100644
--- a/drivers/net/dpaa/dpaa_flow.c
+++ b/drivers/net/dpaa/dpaa_flow.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DPAA_MAX_NUM_ETH_DEV   8
 
@@ -796,8 +797,6 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t 
req_dist_set)
return -1;
}
 
-   dpaa_intf->nb_rx_queues = dev->data->nb_rx_queues;
-
/* Open FM Port and set it in port info */
ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif);
if (ret) {
@@ -806,7 +805,7 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t 
req_dist_set)
}
 
if (fif->num_profiles) {
-   for (i = 0; i < dpaa_intf->nb_rx_queues; i++)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
dpaa_intf->rx_queues[i].vsp_id =
fm_default_vsp_id(fif);
 
-- 
2.25.1



[PATCH v5 18/18] net/dpaa: fix reallocate_mbuf handling

2024-10-01 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch fixes the bug in the reallocate_mbuf code
handling. The source location is corrected when copying
the data in the new mbuf.

Fixes: f8c7a17a48c9 ("net/dpaa: support Tx scatter gather for non-DPAA buffer")
Cc: sta...@dpdk.org

Signed-off-by: Vanshika Shukla 
---
 drivers/net/dpaa/dpaa_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 1d7efdef88..247e7b92ba 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1223,7 +1223,7 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
/* Copy the data */
data = rte_pktmbuf_append(new_mbufs[0], bytes_to_copy);
 
-   rte_memcpy((uint8_t *)data, rte_pktmbuf_mtod_offset(mbuf,
+   rte_memcpy((uint8_t *)data, rte_pktmbuf_mtod_offset(temp_mbuf,
   void *, offset1), bytes_to_copy);
 
/* Set new offsets and the temp buffers */
-- 
2.25.1



[PATCH v5 09/18] net/dpaa: support Rx/Tx timestamp read

2024-10-01 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch implements Rx/Tx timestamp read operations
for DPAA1 platform.

Signed-off-by: Vanshika Shukla 
---
 doc/guides/nics/features/dpaa.ini|  1 +
 drivers/bus/dpaa/base/fman/fman.c| 21 +++-
 drivers/bus/dpaa/base/fman/fman_hw.c |  6 ++-
 drivers/bus/dpaa/include/fman.h  | 18 ++-
 drivers/net/dpaa/dpaa_ethdev.c   |  2 +
 drivers/net/dpaa/dpaa_ethdev.h   | 17 +++
 drivers/net/dpaa/dpaa_ptp.c  | 42 
 drivers/net/dpaa/dpaa_rxtx.c | 71 
 drivers/net/dpaa/dpaa_rxtx.h |  4 +-
 drivers/net/dpaa/meson.build |  1 +
 10 files changed, 168 insertions(+), 15 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_ptp.c

diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index b136ed191a..4196dd800c 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -19,6 +19,7 @@ Flow control = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Timestamp offload= Y
 Basic stats  = Y
 Extended stats   = Y
 FW version   = Y
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index beeb03dbf2..e39bc8c252 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2010-2016 Freescale Semiconductor Inc.
- * Copyright 2017-2020 NXP
+ * Copyright 2017-2024 NXP
  *
  */
 
@@ -520,6 +520,25 @@ fman_if_init(const struct device_node *dpa_node)
goto err;
}
 
+   regs_addr = of_get_address(tx_node, 0, &__if->regs_size, NULL);
+   if (!regs_addr) {
+   FMAN_ERR(-EINVAL, "of_get_address(%s)\n", mname);
+   goto err;
+   }
+   phys_addr = of_translate_address(tx_node, regs_addr);
+   if (!phys_addr) {
+   FMAN_ERR(-EINVAL, "of_translate_address(%s, %p)\n",
+   mname, regs_addr);
+   goto err;
+   }
+   __if->tx_bmi_map = mmap(NULL, __if->regs_size,
+   PROT_READ | PROT_WRITE, MAP_SHARED,
+   fman_ccsr_map_fd, phys_addr);
+   if (__if->tx_bmi_map == MAP_FAILED) {
+   FMAN_ERR(-errno, "mmap(0x%"PRIx64")\n", phys_addr);
+   goto err;
+   }
+
/* No channel ID for MAC-less */
assert(lenp == sizeof(*tx_channel_id));
na = of_n_addr_cells(mac_node);
diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 124c69edb4..4fc41c1ae9 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright 2017,2020 NXP
+ * Copyright 2017,2020,2022 NXP
  *
  */
 
@@ -565,6 +565,10 @@ fman_if_set_ic_params(struct fman_if *fm_if,
&((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ricp;
out_be32(fmbm_ricp, val);
 
+   unsigned int *fmbm_ticp =
+   &((struct tx_bmi_regs *)__if->tx_bmi_map)->fmbm_ticp;
+   out_be32(fmbm_ticp, val);
+
return 0;
 }
 
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 6b2a1893f9..09d1ddb897 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -2,7 +2,7 @@
  *
  * Copyright 2010-2012 Freescale Semiconductor, Inc.
  * All rights reserved.
- * Copyright 2019-2021 NXP
+ * Copyright 2019-2022 NXP
  *
  */
 
@@ -292,6 +292,21 @@ struct rx_bmi_regs {
uint32_t fmbm_rdbg; /**< Rx Debug-*/
 };
 
+struct tx_bmi_regs {
+   uint32_t fmbm_tcfg; /**< Tx Configuration*/
+   uint32_t fmbm_tst;  /**< Tx Status*/
+   uint32_t fmbm_tda;  /**< Tx DMA attributes*/
+   uint32_t fmbm_tfp;  /**< Tx FIFO Parameters*/
+   uint32_t fmbm_tfed; /**< Tx Frame End Data*/
+   uint32_t fmbm_ticp; /**< Tx Internal Context Parameters*/
+   uint32_t fmbm_tfdne;/**< Tx Frame Dequeue Next Engine*/
+   uint32_t fmbm_tfca; /**< Tx Frame Attributes*/
+   uint32_t fmbm_tcfqid;   /**< Tx Confirmation Frame Queue ID*/
+   uint32_t fmbm_tefqid;   /**< Tx Error Frame Queue ID*/
+   uint32_t fmbm_tfene;/**< Tx Frame Enqueue Next Engine*/
+   uint32_t fmbm_trlmts;   /**< Tx Rate Limiter Scale*/
+   uint32_t fmbm_trlmt;/**< Tx Rate Limiter*/
+};
 struct fman_port_qmi_regs {
uint32_t fmqm_pnc;  /**< PortID n Configuration Register */
uint32_t fmqm_pns;  /**< PortID n Status Register */
@@ -380,6 +395,7 @@ struct __fman_if {
uint64_t regs_size;
void *ccsr_map;
void *bmi_map;
+   void *tx_bmi_map;
void *qmi_map;
stru

[PATCH v5 11/18] net/dpaa: implement detailed packet parsing

2024-10-01 Thread Hemant Agrawal
This patch implements the detailed packet parsing using
the annotation info from the hardware.

decode parser to set RX muf packet type by dpaa_slow_parsing.
Support to identify the IPSec ESP, GRE and SCTP packets.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
 drivers/net/dpaa/dpaa_ethdev.c |   1 +
 drivers/net/dpaa/dpaa_rxtx.c   |  35 +++-
 drivers/net/dpaa/dpaa_rxtx.h   | 143 ++---
 3 files changed, 93 insertions(+), 86 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 82d1960356..a302b24be6 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -411,6 +411,7 @@ dpaa_supported_ptypes_get(struct rte_eth_dev *dev, size_t 
*no_of_elements)
RTE_PTYPE_L4_UDP,
RTE_PTYPE_L4_SCTP,
RTE_PTYPE_TUNNEL_ESP,
+   RTE_PTYPE_TUNNEL_GRE,
};
 
PMD_INIT_FUNC_TRACE();
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index e3b4bb14ab..99fc3f1b43 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -110,11 +110,38 @@ static void dpaa_display_frame_info(const struct qm_fd 
*fd,
 #define dpaa_display_frame_info(a, b, c)
 #endif
 
-static inline void dpaa_slow_parsing(struct rte_mbuf *m __rte_unused,
-uint64_t prs __rte_unused)
+static inline void
+dpaa_slow_parsing(struct rte_mbuf *m,
+   const struct annotations_t *annot)
 {
+   const struct dpaa_eth_parse_results_t *parse;
+
DPAA_DP_LOG(DEBUG, "Slow parsing");
-   /*TBD:XXX: to be implemented*/
+   parse = &annot->parse;
+
+   if (parse->ethernet)
+   m->packet_type |= RTE_PTYPE_L2_ETHER;
+   if (parse->vlan)
+   m->packet_type |= RTE_PTYPE_L2_ETHER_VLAN;
+   if (parse->first_ipv4)
+   m->packet_type |= RTE_PTYPE_L3_IPV4;
+   if (parse->first_ipv6)
+   m->packet_type |= RTE_PTYPE_L3_IPV6;
+   if (parse->gre)
+   m->packet_type |= RTE_PTYPE_TUNNEL_GRE;
+   if (parse->last_ipv4)
+   m->packet_type |= RTE_PTYPE_L3_IPV4_EXT;
+   if (parse->last_ipv6)
+   m->packet_type |= RTE_PTYPE_L3_IPV6_EXT;
+   if (parse->l4_type == DPAA_PR_L4_TCP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_TCP;
+   else if (parse->l4_type == DPAA_PR_L4_UDP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_UDP;
+   else if (parse->l4_type == DPAA_PR_L4_IPSEC_TYPE &&
+   !parse->l4_info_err && parse->esp_sum)
+   m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
+   else if (parse->l4_type == DPAA_PR_L4_SCTP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_SCTP;
 }
 
 static inline void dpaa_eth_packet_info(struct rte_mbuf *m, void *fd_virt_addr)
@@ -228,7 +255,7 @@ static inline void dpaa_eth_packet_info(struct rte_mbuf *m, 
void *fd_virt_addr)
break;
/* More switch cases can be added */
default:
-   dpaa_slow_parsing(m, prs);
+   dpaa_slow_parsing(m, annot);
}
 
m->tx_offload = annot->parse.ip_off[0];
diff --git a/drivers/net/dpaa/dpaa_rxtx.h b/drivers/net/dpaa/dpaa_rxtx.h
index 1048e86d41..215bdeaf7f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.h
+++ b/drivers/net/dpaa/dpaa_rxtx.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017,2020-2022 NXP
+ *   Copyright 2017,2020-2024 NXP
  *
  */
 
@@ -162,98 +162,77 @@
 
 #define DPAA_PKT_L3_LEN_SHIFT  7
 
+enum dpaa_parse_result_l4_type {
+   DPAA_PR_L4_TCP_TYPE = 1,
+   DPAA_PR_L4_UDP_TYPE = 2,
+   DPAA_PR_L4_IPSEC_TYPE = 3,
+   DPAA_PR_L4_SCTP_TYPE = 4,
+   DPAA_PR_L4_DCCP_TYPE = 5
+};
+
 /**
  * FMan parse result array
  */
 struct dpaa_eth_parse_results_t {
-uint8_t lpid;   /**< Logical port id */
-uint8_t shimr;  /**< Shim header result  */
-union {
-   uint16_t  l2r;  /**< Layer 2 result */
+   uint8_t lpid; /**< Logical port id */
+   uint8_t shimr; /**< Shim header result  */
+   union {
+   uint16_t l2r; /**< Layer 2 result */
struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-   uint16_t  ethernet:1;
-   uint16_t  vlan:1;
-   uint16_t  llc_snap:1;
-   uint16_t  mpls:1;
-   uint16_t  ppoe_ppp:1;
-   uint16_t  unused_1:3;
-   uint16_t  unknown_eth_proto:1;
-   uint16_t  eth_frame_type:2;
-   uint16_t  l2r_err:5;
+   uint16_t u

[PATCH v5 14/18] bus/dpaa: add OH port mode for dpaa eth

2024-10-01 Thread Hemant Agrawal
From: Rohit Raj 

NXP DPAA architecture supports the concept of DPAA
port as Offline Port - meaning - not connected to an actual MAC.
This is an hardware assisted IPC mechanism for communiting between two
applications.

Offline(O/H) port is a type of hardware port which is able to dequeue and
enqueue from/to a QMan queue. The FMan applies a Parse Classify Distribute
(PCD) flow and (if configured to do so) enqueues the frame back in a
QMan queue.

The FMan is able to copy the frame into new buffers and enqueue back to the
QMan. This means these ports can be used to send and receive packet
between two applications.

An O/H port Have two queues. One to receive and one to send the packets.
It will loopback all the packets on Tx queue which are received
on Rx queue.

This property is completely driven by the device-tree. During the
DPAA bus scan, based on the platform device properties as in
device-tree, the port can be classified as OH port.

This patch add support in the driver to use dpaa eth port
in OH mode as well with DPDK applications.

Signed-off-by: Rohit Raj 
---
 doc/guides/nics/dpaa.rst  |  26 ++-
 drivers/bus/dpaa/base/fman/fman.c | 259 ++
 drivers/bus/dpaa/base/fman/fman_hw.c  |  24 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  19 +-
 drivers/bus/dpaa/dpaa_bus.c   |  23 +-
 drivers/bus/dpaa/include/fman.h   |  31 ++-
 drivers/net/dpaa/dpaa_ethdev.c|  85 ++-
 drivers/net/dpaa/dpaa_ethdev.h|   6 +
 drivers/net/dpaa/dpaa_flow.c  |  51 +++--
 9 files changed, 378 insertions(+), 146 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index edf7a7e350..47dcce334c 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -1,5 +1,5 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
-Copyright 2017,2020 NXP
+Copyright 2017,2020-2024 NXP
 
 
 DPAA Poll Mode Driver
@@ -136,6 +136,8 @@ RTE framework and DPAA internal components/drivers.
   The Ethernet driver is bound to a FMAN port and implements the interfaces
   needed to connect the DPAA network interface to the network stack.
   Each FMAN Port corresponds to a DPDK network interface.
+- PMD also support OH mode, where the port works as a HW assisted
+  virtual port without actually connecting to a Physical MAC.
 
 
 Features
@@ -149,6 +151,8 @@ Features
   - Checksum offload
   - Promiscuous mode
   - IEEE1588 PTP
+  - OH Port for inter application communication
+
 
 DPAA Mempool Driver
 ~~~
@@ -326,6 +330,26 @@ FMLIB
`Kernel FMD Driver

`_.
 
+OH Port
+~~~
+   Offline(O/H) port is a type of hardware port which is able to dequeue and
+   enqueue from/to a QMan queue. The FMan applies a Parse Classify Distribute 
(PCD)
+   flow and (if configured to do so) enqueues the frame back in a QMan queue.
+
+   The FMan is able to copy the frame into new buffers and enqueue back to the
+   QMan. This means these ports can be used to send and receive packets 
between two
+   applications as well.
+
+   An O/H port have two queues. One to receive and one to send the packets. It 
will
+   loopback all the packets on Tx queue which are received on Rx queue.
+
+
+     Tx Packets  -
+   | App  | - -  - - - - - - - > | O/H   |
+   |  | < - - - - - - - - -  | Port  |
+     Rx Packets  -
+
+
 VSP (Virtual Storage Profile)
 ~
The storage profiled are means to provide virtualized interface. A ranges of
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index e2b7120237..f817305ab7 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -246,26 +246,34 @@ fman_if_init(const struct device_node *dpa_node)
uint64_t port_cell_idx_val = 0;
uint64_t ext_args_cell_idx_val = 0;
 
-   const struct device_node *mac_node = NULL, *tx_node, *ext_args_node;
-   const struct device_node *pool_node, *fman_node, *rx_node;
+   const struct device_node *mac_node = NULL, *ext_args_node;
+   const struct device_node *pool_node, *fman_node;
+   const struct device_node *rx_node = NULL, *tx_node = NULL;
+   const struct device_node *oh_node = NULL;
const uint32_t *regs_addr = NULL;
const char *mname, *fname;
const char *dname = dpa_node->full_name;
size_t lenp;
-   int _errno, is_shared = 0;
+   int _errno, is_shared = 0, is_offline = 0;
const char *char_prop;
uint32_t na;
 
if (of_device_is_available(dpa_node) == false)
return 0;
 
-   if (!of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-init") &&
-   !of_device_is_compatible(dpa_node, "fsl,dpa-ethernet")) {

[PATCH v5 13/18] net/dpaa: support mempool debug

2024-10-01 Thread Hemant Agrawal
From: Gagandeep Singh 

This patch adds support to compile time debug the mempool
corruptions in dpaa driver.

Signed-off-by: Gagandeep Singh 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 945c84ab10..d82c6f3be2 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -494,6 +494,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->data_len = sg_temp->length;
first_seg->pkt_len = sg_temp->length;
rte_mbuf_refcnt_set(first_seg, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)first_seg),
+   (void **)&first_seg, 1, 1);
+#endif
 
first_seg->port = ifid;
first_seg->nb_segs = 1;
@@ -511,6 +515,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->pkt_len += sg_temp->length;
first_seg->nb_segs += 1;
rte_mbuf_refcnt_set(cur_seg, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
+   (void **)&cur_seg, 1, 1);
+#endif
prev_seg->next = cur_seg;
if (sg_temp->final) {
cur_seg->next = NULL;
@@ -522,6 +530,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->pkt_len, first_seg->nb_segs);
 
dpaa_eth_packet_info(first_seg, vaddr);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
+   (void **)&temp, 1, 1);
+#endif
rte_pktmbuf_free_seg(temp);
 
return first_seg;
@@ -562,6 +574,10 @@ dpaa_eth_fd_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
 
return mbuf;
@@ -676,6 +692,10 @@ dpaa_rx_cb_no_prefetch(struct qman_fq **fq, struct 
qm_dqrr_entry **dqrr,
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
dpaa_display_frame_info(fd, fq[0]->fqid, true);
if (dpaa_ieee_1588) {
@@ -722,6 +742,10 @@ dpaa_rx_cb(struct qman_fq **fq, struct qm_dqrr_entry 
**dqrr,
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
dpaa_display_frame_info(fd, fq[0]->fqid, true);
if (dpaa_ieee_1588) {
@@ -972,6 +996,10 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
return -1;
}
 
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
+   (void **)&temp, 1, 0);
+#endif
fd->cmd = 0;
fd->opaque_addr = 0;
 
@@ -1017,6 +1045,10 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
} else {
sg_temp->bpid =
DPAA_MEMPOOL_TO_BPID(cur_seg->pool);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   
rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
+   (void **)&cur_seg, 1, 0);
+#endif
}
} else if (RTE_MBUF_HAS_EXTBUF(cur_seg)) {
free_buf[*free_count].seg = cur_seg;
@@ -1074,6 +1106,10 @@ tx_on_dpaa_pool_unsegmented(struct rte_mbuf *mbuf,
 * released by BMAN.
 */
DPAA_MBUF_TO_CONTIG_FD(mbuf, fd_arr, bp_info->bpid);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void 
*)mbuf),
+   (void **)&mbuf, 1, 0);
+#endif
}
} else if (RTE_MBUF_HAS_EXTBUF(mbuf)) {
buf_to_free[*free_count].seg = mbuf;
@@ -1302,6 +1338,10 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_CKSUM_OFFLOAD_MASK)
dpaa_unsegmented_checksum(mbuf,
 

[PATCH v5 08/18] net/dpaa: share MAC FMC scheme and CC parse

2024-10-01 Thread Hemant Agrawal
From: Jun Yang 

For Shared MAC:
1) Allocate RXQ from VSP scheme. (Virtual Storage Profile)
2) Allocate RXQ from Coarse classifiation (CC) rules to VSP.
2) Remove RXQ allocated which is reconfigured without VSP.
3) Don't alloc default queue and err queues.

Signed-off-by: Jun Yang 
Acked-by: Hemant Agrawal 
---
 drivers/bus/dpaa/include/fman.h |   1 +
 drivers/net/dpaa/dpaa_ethdev.c  |  60 +++--
 drivers/net/dpaa/dpaa_ethdev.h  |  13 +-
 drivers/net/dpaa/dpaa_flow.c|   8 +-
 drivers/net/dpaa/dpaa_fmc.c | 421 
 drivers/net/dpaa/dpaa_rxtx.c|  20 +-
 6 files changed, 346 insertions(+), 177 deletions(-)

diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 60681068ea..6b2a1893f9 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -76,6 +76,7 @@ enum fman_mac_type {
fman_mac_1g,
fman_mac_10g,
fman_mac_2_5g,
+   fman_onic,
 };
 
 struct mac_addr {
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 3ee3029729..bf14d73433 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -255,7 +255,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
DPAA_PMD_ERR("Cannot open IF socket");
return -errno;
}
-
strncpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ - 1);
 
if (ioctl(socket_fd, SIOCGIFMTU, &ifr) < 0) {
@@ -1893,6 +1892,7 @@ dpaa_tx_conf_queue_init(struct qman_fq *fq)
return ret;
 }
 
+#if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
 /* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
 static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
@@ -1923,6 +1923,7 @@ static int dpaa_def_queue_init(struct qman_fq *fq, 
uint32_t fqid)
fqid, ret);
return ret;
 }
+#endif
 
 /* Initialise a network interface */
 static int
@@ -1957,6 +1958,41 @@ dpaa_dev_init_secondary(struct rte_eth_dev *eth_dev)
return 0;
 }
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+static int
+dpaa_error_queue_init(struct dpaa_if *dpaa_intf,
+   struct fman_if *fman_intf)
+{
+   int i, ret;
+   struct qman_fq *err_queues = dpaa_intf->debug_queues;
+   uint32_t err_fqid = 0;
+
+   if (fman_intf->is_shared_mac) {
+   DPAA_PMD_DEBUG("Shared MAC's err queues are handled in kernel");
+   return 0;
+   }
+
+   for (i = 0; i < DPAA_DEBUG_FQ_MAX_NUM; i++) {
+   if (i == DPAA_DEBUG_FQ_RX_ERROR)
+   err_fqid = fman_intf->fqid_rx_err;
+   else if (i == DPAA_DEBUG_FQ_TX_ERROR)
+   err_fqid = fman_intf->fqid_tx_err;
+   else
+   continue;
+   ret = dpaa_def_queue_init(&err_queues[i], err_fqid);
+   if (ret) {
+   DPAA_PMD_ERR("DPAA %s ERROR queue init failed!",
+   i == DPAA_DEBUG_FQ_RX_ERROR ?
+   "RX" : "TX");
+   return ret;
+   }
+   err_queues[i].dpaa_intf = dpaa_intf;
+   }
+
+   return 0;
+}
+#endif
+
 static int
 check_devargs_handler(__rte_unused const char *key, const char *value,
  __rte_unused void *opaque)
@@ -2202,25 +2238,11 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
}
}
dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
-
-#if !defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
-   if (dpaa_ieee_1588)
+#if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
+   ret = dpaa_error_queue_init(dpaa_intf, fman_intf);
+   if (ret)
+   goto free_tx;
 #endif
-   {
-   ret = dpaa_def_queue_init(&dpaa_intf->debug_queues
-   [DPAA_DEBUG_FQ_RX_ERROR], 
fman_intf->fqid_rx_err);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA RX ERROR queue init failed!");
-   goto free_tx;
-   }
-   dpaa_intf->debug_queues[DPAA_DEBUG_FQ_RX_ERROR].dpaa_intf = 
dpaa_intf;
-   ret = dpaa_def_queue_init(&dpaa_intf->debug_queues
-   [DPAA_DEBUG_FQ_TX_ERROR], 
fman_intf->fqid_tx_err);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA TX ERROR queue init failed!");
-   goto free_tx;
-   }
-   }
DPAA_PMD_DEBUG("All frame queues created");
 
/* Get the initial configuration for flow control */
diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h
index b427b29cb6..0a1ceb376a 100644
--- a/drivers/net/dpaa/dpaa_ethdev.h
+++ b/drivers/net/dpaa/dpaa_ethdev.h
@@ -78,8 +78,11 @@
 #define DPAA_IF_RX_CONTEXT_STASH 

[PATCH v5 00/18] NXP DPAA ETH driver enhancement and fixes

2024-10-01 Thread Hemant Agrawal
v5: fix individual patch compilation and checkpatch warning
v4: fix clang compilation issues
v3: addressed Ferruh's comments 
 - dropped Tx rate limit API patch
 - added one small bug fix
 - fixed removal/add of fman_offline type

v2: address review comments
 - improve commit message
 - add documentarion for new functions
 - make IEEE1588 config runtime

This series adds several enhancement to the NXP DPAA Ethernet driver.

Primarily:
1. timestamp and IEEE 1588 support
2. OH and ONIC based virtual port config in DPAA
3. frame display and debugging infra


Gagandeep Singh (3):
  bus/dpaa: fix PFDRs leaks due to FQRNIs
  net/dpaa: support mempool debug
  net/dpaa: improve the dpaa port cleanup

Hemant Agrawal (5):
  bus/dpaa: fix VSP for 1G fm1-mac9 and 10
  bus/dpaa: fix the fman details status
  bus/dpaa: add port buffer manager stats
  net/dpaa: implement detailed packet parsing
  net/dpaa: enhance DPAA frame display

Jun Yang (2):
  net/dpaa: share MAC FMC scheme and CC parse
  net/dpaa: improve dpaa errata A010022 handling

Rohit Raj (3):
  net/dpaa: fix typecasting ch ID to u32
  bus/dpaa: add OH port mode for dpaa eth
  bus/dpaa: add ONIC port mode for the DPAA eth

Vanshika Shukla (5):
  net/dpaa: support Tx confirmation to enable PTP
  net/dpaa: add support to separate Tx conf queues
  net/dpaa: support Rx/Tx timestamp read
  net/dpaa: support IEEE 1588 PTP
  net/dpaa: fix reallocate_mbuf handling

 doc/guides/nics/dpaa.rst  |  64 ++-
 doc/guides/nics/features/dpaa.ini |   2 +
 drivers/bus/dpaa/base/fman/fman.c | 583 +++---
 drivers/bus/dpaa/base/fman/fman_hw.c  | 102 +++-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  19 +-
 drivers/bus/dpaa/base/qbman/qman.c|  46 +-
 drivers/bus/dpaa/dpaa_bus.c   |  37 +-
 drivers/bus/dpaa/include/fman.h   | 112 -
 drivers/bus/dpaa/include/fsl_fman.h   |  12 +
 drivers/bus/dpaa/include/fsl_qman.h   |   4 +-
 drivers/bus/dpaa/version.map  |   4 +
 drivers/net/dpaa/dpaa_ethdev.c| 428 +---
 drivers/net/dpaa/dpaa_ethdev.h|  68 ++-
 drivers/net/dpaa/dpaa_flow.c  |  66 +--
 drivers/net/dpaa/dpaa_fmc.c   | 421 ++--
 drivers/net/dpaa/dpaa_ptp.c   | 118 +
 drivers/net/dpaa/dpaa_rxtx.c  | 378 --
 drivers/net/dpaa/dpaa_rxtx.h  | 152 +++---
 drivers/net/dpaa/meson.build  |   1 +
 19 files changed, 2105 insertions(+), 512 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_ptp.c

-- 
2.25.1



[PATCH v5 04/18] bus/dpaa: fix the fman details status

2024-10-01 Thread Hemant Agrawal
Fix the incorrect placing of brackets to calculate stats.

This corrects the "(a | b) << 32"  to  "a | (b << 32)"

Fixes: e62a3f4183f1 ("bus/dpaa: fix statistics reading")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman_hw.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 24a99f7235..97e792806f 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -243,10 +243,11 @@ fman_if_stats_get_all(struct fman_if *p, uint64_t *value, 
int n)
int i;
uint64_t base_offset = offsetof(struct memac_regs, reoct_l);
 
-   for (i = 0; i < n; i++)
-   value[i] = (((u64)in_be32((char *)regs + base_offset + 8 * i) |
-   (u64)in_be32((char *)regs + base_offset +
-   8 * i + 4)) << 32);
+   for (i = 0; i < n; i++) {
+   uint64_t a = in_be32((char *)regs + base_offset + 8 * i);
+   uint64_t b = in_be32((char *)regs + base_offset + 8 * i + 4);
+   value[i] = a | b << 32;
+   }
 }
 
 void
-- 
2.25.1



[PATCH v5 02/18] net/dpaa: fix typecasting ch ID to u32

2024-10-01 Thread Hemant Agrawal
From: Rohit Raj 

Avoid typecasting ch_id to u32 and passing it to another API since it
can corrupt other data. Instead, create new u32 variable and typecase
it back to u16 after it gets updated by the API.

Fixes: 0c504f6950b6 ("net/dpaa: support push mode")
Cc: hemant.agra...@nxp.com
Cc: sta...@dpdk.org

Signed-off-by: Rohit Raj 
---
 drivers/net/dpaa/dpaa_ethdev.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 060b8c678f..1a2de5240f 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -972,7 +972,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
struct fman_if *fif = dev->process_private;
struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_idx];
struct qm_mcc_initfq opts = {0};
-   u32 flags = 0;
+   u32 ch_id, flags = 0;
int ret;
u32 buffsz = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
uint32_t max_rx_pktlen;
@@ -1096,7 +1096,9 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
DPAA_IF_RX_CONTEXT_STASH;
 
/*Create a channel and associate given queue with the channel*/
-   qman_alloc_pool_range((u32 *)&rxq->ch_id, 1, 1, 0);
+   qman_alloc_pool_range(&ch_id, 1, 1, 0);
+   rxq->ch_id = (u16)ch_id;
+
opts.we_mask = opts.we_mask | QM_INITFQ_WE_DESTWQ;
opts.fqd.dest.channel = rxq->ch_id;
opts.fqd.dest.wq = DPAA_IF_RX_PRIORITY;
-- 
2.25.1



[PATCH v5 05/18] bus/dpaa: add port buffer manager stats

2024-10-01 Thread Hemant Agrawal
Add BMI statistics and improving the existing extended
statistics

Signed-off-by: Hemant Agrawal 
Signed-off-by: Gagandeep Singh 
---
 drivers/bus/dpaa/base/fman/fman_hw.c | 61 
 drivers/bus/dpaa/include/fman.h  |  4 +-
 drivers/bus/dpaa/include/fsl_fman.h  | 12 ++
 drivers/bus/dpaa/version.map |  4 ++
 drivers/net/dpaa/dpaa_ethdev.c   | 46 ++---
 drivers/net/dpaa/dpaa_ethdev.h   | 12 ++
 6 files changed, 132 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 97e792806f..124c69edb4 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -267,6 +267,67 @@ fman_if_stats_reset(struct fman_if *p)
;
 }
 
+void
+fman_if_bmi_stats_enable(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   uint32_t tmp;
+
+   tmp = in_be32(®s->fmbm_rstc);
+
+   tmp |= FMAN_BMI_COUNTERS_EN;
+
+   out_be32(®s->fmbm_rstc, tmp);
+}
+
+void
+fman_if_bmi_stats_disable(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   uint32_t tmp;
+
+   tmp = in_be32(®s->fmbm_rstc);
+
+   tmp &= ~FMAN_BMI_COUNTERS_EN;
+
+   out_be32(®s->fmbm_rstc, tmp);
+}
+
+void
+fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   int i = 0;
+
+   value[i++] = (u32)in_be32(®s->fmbm_rfrc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfbc);
+   value[i++] = (u32)in_be32(®s->fmbm_rlfc);
+   value[i++] = (u32)in_be32(®s->fmbm_rffc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfdc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfldec);
+   value[i++] = (u32)in_be32(®s->fmbm_rodc);
+   value[i++] = (u32)in_be32(®s->fmbm_rbdc);
+}
+
+void
+fman_if_bmi_stats_reset(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+
+   out_be32(®s->fmbm_rfrc, 0);
+   out_be32(®s->fmbm_rfbc, 0);
+   out_be32(®s->fmbm_rlfc, 0);
+   out_be32(®s->fmbm_rffc, 0);
+   out_be32(®s->fmbm_rfdc, 0);
+   out_be32(®s->fmbm_rfldec, 0);
+   out_be32(®s->fmbm_rodc, 0);
+   out_be32(®s->fmbm_rbdc, 0);
+}
+
 void
 fman_if_promiscuous_enable(struct fman_if *p)
 {
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 3a6dd555a7..60681068ea 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -56,6 +56,8 @@
 #define FMAN_PORT_BMI_FIFO_UNITS   0x100
 #define FMAN_PORT_IC_OFFSET_UNITS  0x10
 
+#define FMAN_BMI_COUNTERS_EN 0x8000
+
 #define FMAN_ENABLE_BPOOL_DEPLETION0xF0F0
 
 #define HASH_CTRL_MCAST_EN 0x0100
@@ -260,7 +262,7 @@ struct rx_bmi_regs {
/**< Buffer Manager pool Information-*/
uint32_t fmbm_acnt[FMAN_PORT_MAX_EXT_POOLS_NUM];
/**< Allocate Counter-*/
-   uint32_t reserved0130[8];
+   uint32_t reserved0120[16];
/**< 0x130/0x140 - 0x15F reserved -*/
uint32_t fmbm_rcgm[FMAN_PORT_CG_MAP_NUM];
/**< Congestion Group Map*/
diff --git a/drivers/bus/dpaa/include/fsl_fman.h 
b/drivers/bus/dpaa/include/fsl_fman.h
index 20690f8329..5a9750ad0c 100644
--- a/drivers/bus/dpaa/include/fsl_fman.h
+++ b/drivers/bus/dpaa/include/fsl_fman.h
@@ -60,6 +60,18 @@ void fman_if_stats_reset(struct fman_if *p);
 __rte_internal
 void fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n);
 
+__rte_internal
+void fman_if_bmi_stats_enable(struct fman_if *p);
+
+__rte_internal
+void fman_if_bmi_stats_disable(struct fman_if *p);
+
+__rte_internal
+void fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value);
+
+__rte_internal
+void fman_if_bmi_stats_reset(struct fman_if *p);
+
 /* Set ignore pause option for a specific interface */
 void fman_if_set_rx_ignore_pause_frames(struct fman_if *p, bool enable);
 
diff --git a/drivers/bus/dpaa/version.map b/drivers/bus/dpaa/version.map
index 3f547f75cf..a17d57632e 100644
--- a/drivers/bus/dpaa/version.map
+++ b/drivers/bus/dpaa/version.map
@@ -24,6 +24,10 @@ INTERNAL {
fman_dealloc_bufs_mask_hi;
fman_dealloc_bufs_mask_lo;
fman_if_add_mac_addr;
+   fman_if_bmi_stats_enable;
+   fman_if_bmi_stats_disable;
+   fman_if_bmi_stats_get_all;
+   fman_if_bmi_stats_reset;
fman_if_clear_mac_addr;

[PATCH v4 13/18] net/dpaa: support mempool debug

2024-09-30 Thread Hemant Agrawal
From: Gagandeep Singh 

This patch adds support to compile time debug the mempool
corruptions in dpaa driver.

Signed-off-by: Gagandeep Singh 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 945c84ab10..d82c6f3be2 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -494,6 +494,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->data_len = sg_temp->length;
first_seg->pkt_len = sg_temp->length;
rte_mbuf_refcnt_set(first_seg, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)first_seg),
+   (void **)&first_seg, 1, 1);
+#endif
 
first_seg->port = ifid;
first_seg->nb_segs = 1;
@@ -511,6 +515,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->pkt_len += sg_temp->length;
first_seg->nb_segs += 1;
rte_mbuf_refcnt_set(cur_seg, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
+   (void **)&cur_seg, 1, 1);
+#endif
prev_seg->next = cur_seg;
if (sg_temp->final) {
cur_seg->next = NULL;
@@ -522,6 +530,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->pkt_len, first_seg->nb_segs);
 
dpaa_eth_packet_info(first_seg, vaddr);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
+   (void **)&temp, 1, 1);
+#endif
rte_pktmbuf_free_seg(temp);
 
return first_seg;
@@ -562,6 +574,10 @@ dpaa_eth_fd_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
 
return mbuf;
@@ -676,6 +692,10 @@ dpaa_rx_cb_no_prefetch(struct qman_fq **fq, struct 
qm_dqrr_entry **dqrr,
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
dpaa_display_frame_info(fd, fq[0]->fqid, true);
if (dpaa_ieee_1588) {
@@ -722,6 +742,10 @@ dpaa_rx_cb(struct qman_fq **fq, struct qm_dqrr_entry 
**dqrr,
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
dpaa_display_frame_info(fd, fq[0]->fqid, true);
if (dpaa_ieee_1588) {
@@ -972,6 +996,10 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
return -1;
}
 
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
+   (void **)&temp, 1, 0);
+#endif
fd->cmd = 0;
fd->opaque_addr = 0;
 
@@ -1017,6 +1045,10 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
} else {
sg_temp->bpid =
DPAA_MEMPOOL_TO_BPID(cur_seg->pool);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   
rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
+   (void **)&cur_seg, 1, 0);
+#endif
}
} else if (RTE_MBUF_HAS_EXTBUF(cur_seg)) {
free_buf[*free_count].seg = cur_seg;
@@ -1074,6 +1106,10 @@ tx_on_dpaa_pool_unsegmented(struct rte_mbuf *mbuf,
 * released by BMAN.
 */
DPAA_MBUF_TO_CONTIG_FD(mbuf, fd_arr, bp_info->bpid);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void 
*)mbuf),
+   (void **)&mbuf, 1, 0);
+#endif
}
} else if (RTE_MBUF_HAS_EXTBUF(mbuf)) {
buf_to_free[*free_count].seg = mbuf;
@@ -1302,6 +1338,10 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_CKSUM_OFFLOAD_MASK)
dpaa_unsegmented_checksum(mbuf,
 

[PATCH v4 06/18] net/dpaa: support Tx confirmation to enable PTP

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

TX confirmation provides dedicated confirmation
queues for transmitted packets. These queues are
used by software to get the status and release
transmitted packets buffers.

This patch also changes the IEEE1588 support as devargs

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
 doc/guides/nics/dpaa.rst   |   3 +
 drivers/net/dpaa/dpaa_ethdev.c | 124 ++---
 drivers/net/dpaa/dpaa_ethdev.h |   4 +-
 drivers/net/dpaa/dpaa_rxtx.c   |  49 +
 drivers/net/dpaa/dpaa_rxtx.h   |   2 +
 5 files changed, 154 insertions(+), 28 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index e8402dff52..acf4daab02 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -264,6 +264,9 @@ for details.
   Done
   testpmd>
 
+* Use dev arg option ``drv_ieee1588=1`` to enable ieee 1588 support at
+  driver level. e.g. ``dpaa:fm1-mac3,drv_ieee1588=1``
+
 FMAN Config
 ---
 
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 90b34e42f2..bba305cfb1 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017-2020 NXP
+ *   Copyright 2017-2020,2022-2024 NXP
  *
  */
 /* System headers */
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,6 +51,7 @@
 #include 
 #include 
 
+#define DRIVER_IEEE1588"drv_ieee1588"
 #define CHECK_INTERVAL 100  /* 100ms */
 #define MAX_REPEAT_TIME90   /* 9s (90 * 100ms) in total */
 
@@ -83,6 +85,7 @@ static uint64_t dev_tx_offloads_nodis =
 static int is_global_init;
 static int fmc_q = 1;  /* Indicates the use of static fmc for distribution */
 static int default_q;  /* use default queue - FMC is not executed*/
+int dpaa_ieee_1588;/* use to indicate if IEEE 1588 is enabled for the 
driver */
 /* At present we only allow up to 4 push mode queues as default - as each of
  * this queue need dedicated portal and we are short of portals.
  */
@@ -1826,9 +1829,15 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
opts.fqd.dest.wq = DPAA_IF_TX_PRIORITY;
opts.fqd.fq_ctrl = QM_FQCTRL_PREFERINCACHE;
opts.fqd.context_b = 0;
-   /* no tx-confirmation */
-   opts.fqd.context_a.hi = 0x8000 | fman_dealloc_bufs_mask_hi;
-   opts.fqd.context_a.lo = 0 | fman_dealloc_bufs_mask_lo;
+   if (dpaa_ieee_1588) {
+   opts.fqd.context_a.lo = 0;
+   opts.fqd.context_a.hi = fman_dealloc_bufs_mask_hi;
+   } else {
+   /* no tx-confirmation */
+   opts.fqd.context_a.lo = fman_dealloc_bufs_mask_lo;
+   opts.fqd.context_a.hi = 0x8000 | fman_dealloc_bufs_mask_hi;
+   }
+
if (fman_ip_rev >= FMAN_V3) {
/* Set B0V bit in contextA to set ASPID to 0 */
opts.fqd.context_a.hi |= 0x0400;
@@ -1861,9 +1870,10 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
return ret;
 }
 
-#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
-/* Initialise a DEBUG FQ ([rt]x_error, rx_default). */
-static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default) and DPAA TX CONFIRM queue
+ * to support PTP
+ */
+static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
struct qm_mcc_initfq opts = {0};
int ret;
@@ -1872,15 +1882,15 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, 
uint32_t fqid)
 
ret = qman_reserve_fqid(fqid);
if (ret) {
-   DPAA_PMD_ERR("Reserve debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("Reserve fqid %d failed with ret: %d",
fqid, ret);
return -EINVAL;
}
/* "map" this Rx FQ to one of the interfaces Tx FQID */
-   DPAA_PMD_DEBUG("Creating debug fq %p, fqid %d", fq, fqid);
+   DPAA_PMD_DEBUG("Creating fq %p, fqid %d", fq, fqid);
ret = qman_create_fq(fqid, QMAN_FQ_FLAG_NO_ENQUEUE, fq);
if (ret) {
-   DPAA_PMD_ERR("create debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("create fqid %d failed with ret: %d",
fqid, ret);
return ret;
}
@@ -1888,11 +1898,10 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, 
uint32_t fqid)
opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
ret = qman_init_fq(fq, 0, &opts);
if (ret)
-   DPAA_PMD_ERR("init debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("init fqid %d failed with ret: %d",
fqid, ret);
return ret;
 }
-#endif
 
 /* Initialise a network interfa

[PATCH v4 04/18] bus/dpaa: fix the fman details status

2024-09-30 Thread Hemant Agrawal
Fix the incorrect placing of brackets to calculate stats.

This corrects the "(a | b) << 32"  to  "a | (b << 32)"

Fixes: e62a3f4183f1 ("bus/dpaa: fix statistics reading")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman_hw.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 24a99f7235..97e792806f 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -243,10 +243,11 @@ fman_if_stats_get_all(struct fman_if *p, uint64_t *value, 
int n)
int i;
uint64_t base_offset = offsetof(struct memac_regs, reoct_l);
 
-   for (i = 0; i < n; i++)
-   value[i] = (((u64)in_be32((char *)regs + base_offset + 8 * i) |
-   (u64)in_be32((char *)regs + base_offset +
-   8 * i + 4)) << 32);
+   for (i = 0; i < n; i++) {
+   uint64_t a = in_be32((char *)regs + base_offset + 8 * i);
+   uint64_t b = in_be32((char *)regs + base_offset + 8 * i + 4);
+   value[i] = a | b << 32;
+   }
 }
 
 void
-- 
2.25.1



[PATCH v4 18/18] net/dpaa: fix reallocate_mbuf handling

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch fixes the bug in the reallocate_mbuf code
handling. The source location is corrected when copying
the data in the new mbuf.

Fixes: f8c7a17a48c9 ("net/dpaa: support Tx scatter gather for non-DPAA buffer")
Cc: sta...@dpdk.org

Signed-off-by: Vanshika Shukla 
---
 drivers/net/dpaa/dpaa_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 1d7efdef88..247e7b92ba 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1223,7 +1223,7 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
/* Copy the data */
data = rte_pktmbuf_append(new_mbufs[0], bytes_to_copy);
 
-   rte_memcpy((uint8_t *)data, rte_pktmbuf_mtod_offset(mbuf,
+   rte_memcpy((uint8_t *)data, rte_pktmbuf_mtod_offset(temp_mbuf,
   void *, offset1), bytes_to_copy);
 
/* Set new offsets and the temp buffers */
-- 
2.25.1



[PATCH v4 07/18] net/dpaa: add support to separate Tx conf queues

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch separates Tx confirmation queues for kernel
and DPDK so as to support the VSP case.

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
 drivers/bus/dpaa/include/fsl_qman.h |  4 ++-
 drivers/net/dpaa/dpaa_ethdev.c  | 45 +
 drivers/net/dpaa/dpaa_rxtx.c|  3 +-
 3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/drivers/bus/dpaa/include/fsl_qman.h 
b/drivers/bus/dpaa/include/fsl_qman.h
index c0677976e8..db14dfb839 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2008-2012 Freescale Semiconductor, Inc.
- * Copyright 2019 NXP
+ * Copyright 2019-2022 NXP
  *
  */
 
@@ -1237,6 +1237,8 @@ struct qman_fq {
 
/* DPDK Interface */
void *dpaa_intf;
+   /*to store tx_conf_queue corresponding to tx_queue*/
+   struct qman_fq *tx_conf_queue;
 
struct rte_event ev;
/* affined portal in case of static queue */
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index bba305cfb1..3ee3029729 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1870,9 +1870,30 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
return ret;
 }
 
-/* Initialise a DEBUG FQ ([rt]x_error, rx_default) and DPAA TX CONFIRM queue
- * to support PTP
- */
+static int
+dpaa_tx_conf_queue_init(struct qman_fq *fq)
+{
+   struct qm_mcc_initfq opts = {0};
+   int ret;
+
+   PMD_INIT_FUNC_TRACE();
+
+   ret = qman_create_fq(0, QMAN_FQ_FLAG_DYNAMIC_FQID, fq);
+   if (ret) {
+   DPAA_PMD_ERR("create Tx_conf failed with ret: %d", ret);
+   return ret;
+   }
+
+   opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL;
+   opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
+   ret = qman_init_fq(fq, 0, &opts);
+   if (ret)
+   DPAA_PMD_ERR("init Tx_conf fqid %d failed with ret: %d",
+   fq->fqid, ret);
+   return ret;
+}
+
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
 static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
struct qm_mcc_initfq opts = {0};
@@ -2170,6 +2191,15 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
if (ret)
goto free_tx;
dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf;
+
+   if (dpaa_ieee_1588) {
+   ret = 
dpaa_tx_conf_queue_init(&dpaa_intf->tx_conf_queues[loop]);
+   if (ret)
+   goto free_tx;
+
+   dpaa_intf->tx_conf_queues[loop].dpaa_intf = dpaa_intf;
+   dpaa_intf->tx_queues[loop].tx_conf_queue = 
&dpaa_intf->tx_conf_queues[loop];
+   }
}
dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
 
@@ -2190,16 +2220,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
DPAA_PMD_ERR("DPAA TX ERROR queue init failed!");
goto free_tx;
}
-   dpaa_intf->debug_queues[DPAA_DEBUG_FQ_TX_ERROR].dpaa_intf = 
dpaa_intf;
-   ret = dpaa_def_queue_init(dpaa_intf->tx_conf_queues,
-   fman_intf->fqid_tx_confirm);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA TX CONFIRM queue init failed!");
-   goto free_tx;
-   }
-   dpaa_intf->tx_conf_queues->dpaa_intf = dpaa_intf;
}
-
DPAA_PMD_DEBUG("All frame queues created");
 
/* Get the initial configuration for flow control */
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 8593e20200..3bd35c7a0e 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1083,8 +1083,7 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
struct dpaa_sw_buf_free buf_to_free[DPAA_MAX_SGS * 
DPAA_MAX_DEQUEUE_NUM_FRAMES];
uint32_t free_count = 0;
struct qman_fq *fq = q;
-   struct dpaa_if *dpaa_intf = fq->dpaa_intf;
-   struct qman_fq *fq_txconf = dpaa_intf->tx_conf_queues;
+   struct qman_fq *fq_txconf = fq->tx_conf_queue;
 
if (unlikely(!DPAA_PER_LCORE_PORTAL)) {
ret = rte_dpaa_portal_init((void *)0);
-- 
2.25.1



[PATCH v4 16/18] net/dpaa: improve the dpaa port cleanup

2024-09-30 Thread Hemant Agrawal
From: Gagandeep Singh 

During DPAA cleanup in FMCLESS mode, application can
see segmentation fault in device close API and in DPAA
destructor execution.
Segmentation fault in device close is because driver
reducing the number of queues initialised during
device configuration without releasing the actual queues.

And segmentation fault in DPAA destruction is because
it is trying to access RTE* devices whose memory has
been released in rte_eal_cleanup() call by the application.

This patch improves the behavior.

Signed-off-by: Gagandeep Singh 
---
 drivers/net/dpaa/dpaa_ethdev.c | 33 +++--
 drivers/net/dpaa/dpaa_flow.c   |  5 ++---
 2 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 133fbd5bc9..41ae033c75 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -561,10 +561,10 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
if (dpaa_intf->cgr_rx) {
for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
+   rte_free(dpaa_intf->cgr_rx);
+   dpaa_intf->cgr_rx = NULL;
}
 
-   rte_free(dpaa_intf->cgr_rx);
-   dpaa_intf->cgr_rx = NULL;
/* Release TX congestion Groups */
if (dpaa_intf->cgr_tx) {
for (loop = 0; loop < MAX_DPAA_CORES; loop++)
@@ -578,6 +578,15 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 
rte_free(dpaa_intf->tx_queues);
dpaa_intf->tx_queues = NULL;
+   if (dpaa_intf->port_handle) {
+   if (dpaa_fm_deconfig(dpaa_intf, fif))
+   DPAA_PMD_WARN("DPAA FM "
+   "deconfig failed\n");
+   }
+   if (fif->num_profiles) {
+   if (dpaa_port_vsp_cleanup(dpaa_intf, fif))
+   DPAA_PMD_WARN("DPAA FM vsp cleanup failed\n");
+   }
 
return ret;
 }
@@ -2607,26 +2616,6 @@ static void __attribute__((destructor(102))) 
dpaa_finish(void)
return;
 
if (!(default_q || fmc_q)) {
-   unsigned int i;
-
-   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-   if (rte_eth_devices[i].dev_ops == &dpaa_devops) {
-   struct rte_eth_dev *dev = &rte_eth_devices[i];
-   struct dpaa_if *dpaa_intf =
-   dev->data->dev_private;
-   struct fman_if *fif =
-   dev->process_private;
-   if (dpaa_intf->port_handle)
-   if (dpaa_fm_deconfig(dpaa_intf, fif))
-   DPAA_PMD_WARN("DPAA FM "
-   "deconfig failed");
-   if (fif->num_profiles) {
-   if (dpaa_port_vsp_cleanup(dpaa_intf,
- fif))
-   DPAA_PMD_WARN("DPAA FM vsp 
cleanup failed");
-   }
-   }
-   }
if (is_global_init)
if (dpaa_fm_term())
DPAA_PMD_WARN("DPAA FM term failed");
diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c
index 62a2884172..2a22b23c8f 100644
--- a/drivers/net/dpaa/dpaa_flow.c
+++ b/drivers/net/dpaa/dpaa_flow.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DPAA_MAX_NUM_ETH_DEV   8
 
@@ -795,8 +796,6 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t 
req_dist_set)
return -1;
}
 
-   dpaa_intf->nb_rx_queues = dev->data->nb_rx_queues;
-
/* Open FM Port and set it in port info */
ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif);
if (ret) {
@@ -805,7 +804,7 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t 
req_dist_set)
}
 
if (fif->num_profiles) {
-   for (i = 0; i < dpaa_intf->nb_rx_queues; i++)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
dpaa_intf->rx_queues[i].vsp_id =
fm_default_vsp_id(fif);
 
-- 
2.25.1



[PATCH v4 17/18] net/dpaa: improve dpaa errata A010022 handling

2024-09-30 Thread Hemant Agrawal
From: Jun Yang 

This patch improves the errata handling for
"RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022"

Signed-off-by: Jun Yang 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index d82c6f3be2..1d7efdef88 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1258,6 +1258,35 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
return new_mbufs[0];
 }
 
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+/* In case the data offset is not multiple of 16,
+ * FMAN can stall because of an errata. So reallocate
+ * the buffer in such case.
+ */
+static inline int
+dpaa_eth_ls1043a_mbuf_realloc(struct rte_mbuf *mbuf)
+{
+   uint64_t len, offset;
+
+   if (dpaa_svr_family != SVR_LS1043A_FAMILY)
+   return 0;
+
+   while (mbuf) {
+   len = mbuf->data_len;
+   offset = mbuf->data_off;
+   if ((mbuf->next &&
+   !rte_is_aligned((void *)len, 16)) ||
+   !rte_is_aligned((void *)offset, 16)) {
+   DPAA_PMD_DEBUG("Errata condition hit");
+
+   return 1;
+   }
+   mbuf = mbuf->next;
+   }
+   return 0;
+}
+#endif
+
 uint16_t
 dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
@@ -1296,14 +1325,6 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_BURST_SIZE : nb_bufs;
for (loop = 0; loop < frames_to_send; loop++) {
mbuf = *(bufs++);
-   /* In case the data offset is not multiple of 16,
-* FMAN can stall because of an errata. So reallocate
-* the buffer in such case.
-*/
-   if (dpaa_svr_family == SVR_LS1043A_FAMILY &&
-   (mbuf->data_off & 0x7F) != 0x0)
-   realloc_mbuf = 1;
-
fd_arr[loop].cmd = 0;
if (dpaa_ieee_1588) {
fd_arr[loop].cmd |= DPAA_FD_CMD_FCO |
@@ -1311,6 +1332,9 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
fd_arr[loop].cmd |= DPAA_FD_CMD_RPD |
DPAA_FD_CMD_UPD;
}
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+   realloc_mbuf = dpaa_eth_ls1043a_mbuf_realloc(mbuf);
+#endif
seqn = *dpaa_seqn(mbuf);
if (seqn != DPAA_INVALID_MBUF_SEQN) {
index = seqn - 1;
-- 
2.25.1



[PATCH v4 15/18] bus/dpaa: add ONIC port mode for the DPAA eth

2024-09-30 Thread Hemant Agrawal
From: Rohit Raj 

The OH ports can also be used by two application, processing contexts
to communicate to each other.
This patch enables this mode for dpaa-eth OH port as ONIC port,
so that application can use the dpaa-eth to communicate to each
other on the same SoC.

Again,this properties is driven by the system device-tree variables.

Signed-off-by: Rohit Raj 
---
 doc/guides/nics/dpaa.rst  |  33 ++-
 drivers/bus/dpaa/base/fman/fman.c | 299 +-
 drivers/bus/dpaa/base/fman/fman_hw.c  |  20 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |   4 +-
 drivers/bus/dpaa/dpaa_bus.c   |  16 +-
 drivers/bus/dpaa/include/fman.h   |  15 +-
 drivers/net/dpaa/dpaa_ethdev.c| 114 +++--
 drivers/net/dpaa/dpaa_flow.c  |  24 +-
 drivers/net/dpaa/dpaa_fmc.c   |   2 +-
 9 files changed, 467 insertions(+), 60 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index 47dcce334c..a266e71a5b 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -136,7 +136,7 @@ RTE framework and DPAA internal components/drivers.
   The Ethernet driver is bound to a FMAN port and implements the interfaces
   needed to connect the DPAA network interface to the network stack.
   Each FMAN Port corresponds to a DPDK network interface.
-- PMD also support OH mode, where the port works as a HW assisted
+- PMD also support OH/ONIC mode, where the port works as a HW assisted
   virtual port without actually connecting to a Physical MAC.
 
 
@@ -152,7 +152,7 @@ Features
   - Promiscuous mode
   - IEEE1588 PTP
   - OH Port for inter application communication
-
+  - ONIC virtual port support
 
 DPAA Mempool Driver
 ~~~
@@ -350,6 +350,35 @@ OH Port
  Rx Packets  -
 
 
+ONIC
+
+   To use OH port to communicate between two applications, we can assign Rx 
port
+   of an O/H port to Application 1 and Tx port to Application 2 so that
+   Application 1 can send packets to Application 2. Similarly, we can assign Tx
+   port of another O/H port to Application 1 and Rx port to Application 2 so 
that
+   Application 2 can send packets to Application 1.
+
+   ONIC is logically defined to achieve it. Internally it will use one Rx queue
+   of an O/H port and one Tx queue of another O/H port.
+   For application, it will behave as single O/H port.
+
+   +--+ +--++--++--++--+
+   |  |   Tx|  |   Rx   | O/H  |   Tx   |  |   Rx   |  |
+   |  | - - - > |  | -  - > | Port | -  - > |  | -  - > |  |
+   |  | |  ||  1   ||  ||  |
+   |  | |  |+--+|  ||  |
+   | App  | | ONIC || ONIC || App  |
+   |  1   | | Port || Port ||  2   |
+   |  | |  1   |+--+|  2   ||  |
+   |  |   Rx|  |   Tx   | O/H  |   Rx   |  |   Tx   |  |
+   |  | < - - - |  | < - - -| Port | < - - -|  | < - - -|  |
+   |  | |  ||  2   ||  ||  |
+   +--+ +--++--++--++--+
+
+   All the packets received by ONIC port 1 will be send to ONIC port 2 and vice
+   versa. These ports can be used by DPDK applications just like physical 
ports.
+
+
 VSP (Virtual Storage Profile)
 ~
The storage profiled are means to provide virtualized interface. A ranges of
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index f817305ab7..efe6eab4a9 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -43,7 +43,7 @@ if_destructor(struct __fman_if *__if)
if (!__if)
return;
 
-   if (__if->__if.mac_type == fman_offline)
+   if (__if->__if.mac_type == fman_offline_internal)
goto cleanup;
 
list_for_each_entry_safe(bp, tmpbp, &__if->__if.bpool_list, node) {
@@ -465,7 +465,7 @@ fman_if_init(const struct device_node *dpa_node)
__if->__if.is_memac = 0;
 
if (is_offline)
-   __if->__if.mac_type = fman_offline;
+   __if->__if.mac_type = fman_offline_internal;
else if (of_device_is_compatible(mac_node, "fsl,fman-1g-mac"))
__if->__if.mac_type = fman_mac_1g;
else if (of_device_is_compatible(mac_node, "fsl,fman-10g-mac"))
@@ -791,6 +791,292 @@ fman_if_init(const struct device_node *dpa_node)
dname, __if->__if.tx_channel_id, __if->__if.fman_idx,
__if->__if.mac_idx);
 
+   /* Don't add OH port to the port list since they will be used by ONIC
+* ports.
+*/
+   if (!is_offline)
+   list_add_tail(&__if->__if.n

[PATCH v4 14/18] bus/dpaa: add OH port mode for dpaa eth

2024-09-30 Thread Hemant Agrawal
From: Rohit Raj 

NXP DPAA architecture supports the concept of DPAA
port as Offline Port - meaning - not connected to an actual MAC.
This is an hardware assited IPC mechanism for communiting between two
applications.

Offline(O/H) port is a type of hardware port which is able to dequeue and
enqueue from/to a QMan queue. The FMan applies a Parse Classify Distribute
(PCD) flow and (if configured to do so) enqueues the frame back in a
QMan queue.

The FMan is able to copy the frame into new buffers and enqueue back to the
QMan. This means these ports can be used to send and receive packet
between two applications.

An O/H port Have two queues. One to receive and one to send the packets.
It will loopback all the packets on Tx queue which are received
on Rx queue.

This property is completely driven by the device-tree. During the
DPAA bus scan, based on the platform device properties as in
device-tree, the port can be classified as OH port.

This patch add support in the driver to use dpaa eth port
in OH mode as well with DPDK applications.

Signed-off-by: Rohit Raj 
---
 doc/guides/nics/dpaa.rst  |  26 ++-
 drivers/bus/dpaa/base/fman/fman.c | 259 ++
 drivers/bus/dpaa/base/fman/fman_hw.c  |  24 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  19 +-
 drivers/bus/dpaa/dpaa_bus.c   |  23 +-
 drivers/bus/dpaa/include/fman.h   |  31 ++-
 drivers/net/dpaa/dpaa_ethdev.c|  85 ++-
 drivers/net/dpaa/dpaa_ethdev.h|   6 +
 drivers/net/dpaa/dpaa_flow.c  |  51 +++--
 9 files changed, 378 insertions(+), 146 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index edf7a7e350..47dcce334c 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -1,5 +1,5 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
-Copyright 2017,2020 NXP
+Copyright 2017,2020-2024 NXP
 
 
 DPAA Poll Mode Driver
@@ -136,6 +136,8 @@ RTE framework and DPAA internal components/drivers.
   The Ethernet driver is bound to a FMAN port and implements the interfaces
   needed to connect the DPAA network interface to the network stack.
   Each FMAN Port corresponds to a DPDK network interface.
+- PMD also support OH mode, where the port works as a HW assisted
+  virtual port without actually connecting to a Physical MAC.
 
 
 Features
@@ -149,6 +151,8 @@ Features
   - Checksum offload
   - Promiscuous mode
   - IEEE1588 PTP
+  - OH Port for inter application communication
+
 
 DPAA Mempool Driver
 ~~~
@@ -326,6 +330,26 @@ FMLIB
`Kernel FMD Driver

`_.
 
+OH Port
+~~~
+   Offline(O/H) port is a type of hardware port which is able to dequeue and
+   enqueue from/to a QMan queue. The FMan applies a Parse Classify Distribute 
(PCD)
+   flow and (if configured to do so) enqueues the frame back in a QMan queue.
+
+   The FMan is able to copy the frame into new buffers and enqueue back to the
+   QMan. This means these ports can be used to send and receive packets 
between two
+   applications as well.
+
+   An O/H port have two queues. One to receive and one to send the packets. It 
will
+   loopback all the packets on Tx queue which are received on Rx queue.
+
+
+     Tx Packets  -
+   | App  | - -  - - - - - - - > | O/H   |
+   |  | < - - - - - - - - -  | Port  |
+     Rx Packets  -
+
+
 VSP (Virtual Storage Profile)
 ~
The storage profiled are means to provide virtualized interface. A ranges of
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index e2b7120237..f817305ab7 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -246,26 +246,34 @@ fman_if_init(const struct device_node *dpa_node)
uint64_t port_cell_idx_val = 0;
uint64_t ext_args_cell_idx_val = 0;
 
-   const struct device_node *mac_node = NULL, *tx_node, *ext_args_node;
-   const struct device_node *pool_node, *fman_node, *rx_node;
+   const struct device_node *mac_node = NULL, *ext_args_node;
+   const struct device_node *pool_node, *fman_node;
+   const struct device_node *rx_node = NULL, *tx_node = NULL;
+   const struct device_node *oh_node = NULL;
const uint32_t *regs_addr = NULL;
const char *mname, *fname;
const char *dname = dpa_node->full_name;
size_t lenp;
-   int _errno, is_shared = 0;
+   int _errno, is_shared = 0, is_offline = 0;
const char *char_prop;
uint32_t na;
 
if (of_device_is_available(dpa_node) == false)
return 0;
 
-   if (!of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-init") &&
-   !of_device_is_compatible(dpa_node, "fsl,dpa-ethernet")) {

[PATCH v4 12/18] net/dpaa: enhance DPAA frame display

2024-09-30 Thread Hemant Agrawal
This patch enhances the received packet debugging capability.
This help displaying the full packet parsing output.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
 doc/guides/nics/dpaa.rst   |   5 ++
 drivers/net/dpaa/dpaa_ethdev.c |   9 +++
 drivers/net/dpaa/dpaa_rxtx.c   | 138 +++--
 drivers/net/dpaa/dpaa_rxtx.h   |   5 ++
 4 files changed, 133 insertions(+), 24 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index ea86e6146c..edf7a7e350 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -227,6 +227,11 @@ state during application initialization:
   application want to use eventdev with DPAA device.
   Currently these queues are not used for LS1023/LS1043 platform by default.
 
+- ``DPAA_DISPLAY_FRAME_AND_PARSER_RESULT`` (default 0)
+
+  This defines the debug flag, whether to dump the detailed frame and packet
+  parsing result for the incoming packets.
+
 
 Driver compilation and testing
 --
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index a302b24be6..4ead890278 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -2056,6 +2056,9 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
int8_t dev_vspids[DPAA_MAX_NUM_PCD_QUEUES];
int8_t vsp_id = -1;
struct rte_device *dev = eth_dev->device;
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+   char *penv;
+#endif
 
PMD_INIT_FUNC_TRACE();
 
@@ -2135,6 +2138,12 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
td_tx_threshold = CGR_RX_PERFQ_THRESH;
}
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+   penv = getenv("DPAA_DISPLAY_FRAME_AND_PARSER_RESULT");
+   if (penv)
+   dpaa_force_display_frame_set(atoi(penv));
+#endif
+
/* If congestion control is enabled globally*/
if (num_rx_fqs > 0 && td_threshold) {
dpaa_intf->cgr_rx = rte_zmalloc(NULL,
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 99fc3f1b43..945c84ab10 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -47,6 +47,10 @@
 #include 
 #include 
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+static int s_force_display_frm;
+#endif
+
 #define DPAA_MBUF_TO_CONTIG_FD(_mbuf, _fd, _bpid) \
do { \
(_fd)->opaque_addr = 0; \
@@ -58,37 +62,122 @@
} while (0)
 
 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+void
+dpaa_force_display_frame_set(int set)
+{
+   s_force_display_frm = set;
+}
+
 #define DISPLAY_PRINT printf
-static void dpaa_display_frame_info(const struct qm_fd *fd,
-   uint32_t fqid, bool rx)
+static void
+dpaa_display_frame_info(const struct qm_fd *fd,
+   uint32_t fqid, bool rx)
 {
-   int ii;
-   char *ptr;
+   int pos, offset = 0;
+   char *ptr, info[1024];
struct annotations_t *annot = rte_dpaa_mem_ptov(fd->addr);
uint8_t format;
+   const struct dpaa_eth_parse_results_t *psr;
 
-   if (!fd->status) {
-   /* Do not display correct packets.*/
+   if (!fd->status && !s_force_display_frm) {
+   /* Do not display correct packets unless force display.*/
return;
}
+   psr = &annot->parse;
 
-   format = (fd->opaque & DPAA_FD_FORMAT_MASK) >>
-   DPAA_FD_FORMAT_SHIFT;
-
-   DISPLAY_PRINT("fqid %d bpid %d addr 0x%lx, format %d\r\n",
- fqid, fd->bpid, (unsigned long)fd->addr, fd->format);
-   DISPLAY_PRINT("off %d, len %d stat 0x%x\r\n",
- fd->offset, fd->length20, fd->status);
+   format = (fd->opaque & DPAA_FD_FORMAT_MASK) >> DPAA_FD_FORMAT_SHIFT;
+   if (format == qm_fd_contig)
+   sprintf(info, "simple");
+   else if (format == qm_fd_sg)
+   sprintf(info, "sg");
+   else
+   sprintf(info, "unknown format(%d)", format);
+
+   DISPLAY_PRINT("%s: fqid=%08x, bpid=%d, phy addr=0x%lx ",
+   rx ? "RX" : "TX", fqid, fd->bpid, (unsigned long)fd->addr);
+   DISPLAY_PRINT("format=%s offset=%d, len=%d, stat=0x%x\r\n",
+   info, fd->offset, fd->length20, fd->status);
if (rx) {
-   ptr = (char *)&annot->parse;
-   DISPLAY_PRINT("RX parser result:\r\n");
-   for (ii = 0; ii < (int)sizeof(struct dpaa_eth_parse_results_t);
-   ii++) {
-   DISPLAY_PRINT("%02x ", ptr[ii]);
-   if (((ii + 1) % 16) == 0)
-   DISPLAY_PRINT("\n");
+   DISPLAY_PRINT("Display usual RX parser result:\r\n");
+   

[PATCH v4 11/18] net/dpaa: implement detailed packet parsing

2024-09-30 Thread Hemant Agrawal
This patch implements the detailed packet parsing using
the annotation info from the hardware.

decode parser to set RX muf packet type by dpaa_slow_parsing.
Support to identify the IPSec ESP, GRE and SCTP packets.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
 drivers/net/dpaa/dpaa_ethdev.c |   1 +
 drivers/net/dpaa/dpaa_rxtx.c   |  35 +++-
 drivers/net/dpaa/dpaa_rxtx.h   | 143 ++---
 3 files changed, 93 insertions(+), 86 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 82d1960356..a302b24be6 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -411,6 +411,7 @@ dpaa_supported_ptypes_get(struct rte_eth_dev *dev, size_t 
*no_of_elements)
RTE_PTYPE_L4_UDP,
RTE_PTYPE_L4_SCTP,
RTE_PTYPE_TUNNEL_ESP,
+   RTE_PTYPE_TUNNEL_GRE,
};
 
PMD_INIT_FUNC_TRACE();
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index e3b4bb14ab..99fc3f1b43 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -110,11 +110,38 @@ static void dpaa_display_frame_info(const struct qm_fd 
*fd,
 #define dpaa_display_frame_info(a, b, c)
 #endif
 
-static inline void dpaa_slow_parsing(struct rte_mbuf *m __rte_unused,
-uint64_t prs __rte_unused)
+static inline void
+dpaa_slow_parsing(struct rte_mbuf *m,
+   const struct annotations_t *annot)
 {
+   const struct dpaa_eth_parse_results_t *parse;
+
DPAA_DP_LOG(DEBUG, "Slow parsing");
-   /*TBD:XXX: to be implemented*/
+   parse = &annot->parse;
+
+   if (parse->ethernet)
+   m->packet_type |= RTE_PTYPE_L2_ETHER;
+   if (parse->vlan)
+   m->packet_type |= RTE_PTYPE_L2_ETHER_VLAN;
+   if (parse->first_ipv4)
+   m->packet_type |= RTE_PTYPE_L3_IPV4;
+   if (parse->first_ipv6)
+   m->packet_type |= RTE_PTYPE_L3_IPV6;
+   if (parse->gre)
+   m->packet_type |= RTE_PTYPE_TUNNEL_GRE;
+   if (parse->last_ipv4)
+   m->packet_type |= RTE_PTYPE_L3_IPV4_EXT;
+   if (parse->last_ipv6)
+   m->packet_type |= RTE_PTYPE_L3_IPV6_EXT;
+   if (parse->l4_type == DPAA_PR_L4_TCP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_TCP;
+   else if (parse->l4_type == DPAA_PR_L4_UDP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_UDP;
+   else if (parse->l4_type == DPAA_PR_L4_IPSEC_TYPE &&
+   !parse->l4_info_err && parse->esp_sum)
+   m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
+   else if (parse->l4_type == DPAA_PR_L4_SCTP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_SCTP;
 }
 
 static inline void dpaa_eth_packet_info(struct rte_mbuf *m, void *fd_virt_addr)
@@ -228,7 +255,7 @@ static inline void dpaa_eth_packet_info(struct rte_mbuf *m, 
void *fd_virt_addr)
break;
/* More switch cases can be added */
default:
-   dpaa_slow_parsing(m, prs);
+   dpaa_slow_parsing(m, annot);
}
 
m->tx_offload = annot->parse.ip_off[0];
diff --git a/drivers/net/dpaa/dpaa_rxtx.h b/drivers/net/dpaa/dpaa_rxtx.h
index 1048e86d41..215bdeaf7f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.h
+++ b/drivers/net/dpaa/dpaa_rxtx.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017,2020-2022 NXP
+ *   Copyright 2017,2020-2024 NXP
  *
  */
 
@@ -162,98 +162,77 @@
 
 #define DPAA_PKT_L3_LEN_SHIFT  7
 
+enum dpaa_parse_result_l4_type {
+   DPAA_PR_L4_TCP_TYPE = 1,
+   DPAA_PR_L4_UDP_TYPE = 2,
+   DPAA_PR_L4_IPSEC_TYPE = 3,
+   DPAA_PR_L4_SCTP_TYPE = 4,
+   DPAA_PR_L4_DCCP_TYPE = 5
+};
+
 /**
  * FMan parse result array
  */
 struct dpaa_eth_parse_results_t {
-uint8_t lpid;   /**< Logical port id */
-uint8_t shimr;  /**< Shim header result  */
-union {
-   uint16_t  l2r;  /**< Layer 2 result */
+   uint8_t lpid; /**< Logical port id */
+   uint8_t shimr; /**< Shim header result  */
+   union {
+   uint16_t l2r; /**< Layer 2 result */
struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-   uint16_t  ethernet:1;
-   uint16_t  vlan:1;
-   uint16_t  llc_snap:1;
-   uint16_t  mpls:1;
-   uint16_t  ppoe_ppp:1;
-   uint16_t  unused_1:3;
-   uint16_t  unknown_eth_proto:1;
-   uint16_t  eth_frame_type:2;
-   uint16_t  l2r_err:5;
+   uint16_t u

[PATCH v4 10/18] net/dpaa: support IEEE 1588 PTP

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch adds the support for the ethdev APIs
to enable/disable and read/write/adjust IEEE1588
PTP timestamps for DPAA platform.

Signed-off-by: Vanshika Shukla 
---
 doc/guides/nics/dpaa.rst  |  1 +
 doc/guides/nics/features/dpaa.ini |  1 +
 drivers/bus/dpaa/base/fman/fman.c | 15 ++
 drivers/bus/dpaa/include/fman.h   | 45 +
 drivers/net/dpaa/dpaa_ethdev.c|  5 ++
 drivers/net/dpaa/dpaa_ethdev.h| 16 +++
 drivers/net/dpaa/dpaa_ptp.c   | 80 ++-
 7 files changed, 161 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index acf4daab02..ea86e6146c 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -148,6 +148,7 @@ Features
   - Packet type information
   - Checksum offload
   - Promiscuous mode
+  - IEEE1588 PTP
 
 DPAA Mempool Driver
 ~~~
diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index 4196dd800c..4f31b61de1 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -19,6 +19,7 @@ Flow control = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Timesync = Y
 Timestamp offload= Y
 Basic stats  = Y
 Extended stats   = Y
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index e39bc8c252..e2b7120237 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -28,6 +28,7 @@ u32 fman_dealloc_bufs_mask_lo;
 
 int fman_ccsr_map_fd = -1;
 static COMPAT_LIST_HEAD(__ifs);
+void *rtc_map;
 
 /* This is the (const) global variable that callers have read-only access to.
  * Internally, we have read-write access directly to __ifs.
@@ -539,6 +540,20 @@ fman_if_init(const struct device_node *dpa_node)
goto err;
}
 
+   if (!rtc_map) {
+   __if->rtc_map = mmap(NULL, FMAN_IEEE_1588_SIZE,
+   PROT_READ | PROT_WRITE, MAP_SHARED,
+   fman_ccsr_map_fd, FMAN_IEEE_1588_OFFSET);
+   if (__if->rtc_map == MAP_FAILED) {
+   pr_err("Can not map FMan RTC regs base\n");
+   _errno = -EINVAL;
+   goto err;
+   }
+   rtc_map = __if->rtc_map;
+   } else {
+   __if->rtc_map = rtc_map;
+   }
+
/* No channel ID for MAC-less */
assert(lenp == sizeof(*tx_channel_id));
na = of_n_addr_cells(mac_node);
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 09d1ddb897..e8bc913943 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -64,6 +64,12 @@
 #define GROUP_ADDRESS  0x0100LL
 #define HASH_CTRL_ADDR_MASK0x003F
 
+#define FMAN_RTC_MAX_NUM_OF_ALARMS 3
+#define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES4
+#define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS   3
+#define FMAN_IEEE_1588_OFFSET  0X1AFE000
+#define FMAN_IEEE_1588_SIZE4096
+
 /* Pre definitions of FMAN interface and Bpool structures */
 struct __fman_if;
 struct fman_if_bpool;
@@ -307,6 +313,44 @@ struct tx_bmi_regs {
uint32_t fmbm_trlmts;   /**< Tx Rate Limiter Scale*/
uint32_t fmbm_trlmt;/**< Tx Rate Limiter*/
 };
+
+/* Description FM RTC timer alarm */
+struct t_tmr_alarm {
+   uint32_t tmr_alarm_h;
+   uint32_t tmr_alarm_l;
+};
+
+/* Description FM RTC timer Ex trigger */
+struct t_tmr_ext_trigger {
+   uint32_t tmr_etts_h;
+   uint32_t tmr_etts_l;
+};
+
+struct rtc_regs {
+   uint32_t tmr_id;/* 0x000 Module ID register */
+   uint32_t tmr_id2;   /* 0x004 Controller ID register */
+   uint32_t reserved0008[30];
+   uint32_t tmr_ctrl;  /* 0x0080 timer control register */
+   uint32_t tmr_tevent;/* 0x0084 timer event register */
+   uint32_t tmr_temask;/* 0x0088 timer event mask register */
+   uint32_t reserved008c[3];
+   uint32_t tmr_cnt_h; /* 0x0098 timer counter high register */
+   uint32_t tmr_cnt_l; /* 0x009c timer counter low register */
+   uint32_t tmr_add;   /* 0x00a0 timer drift compensation addend 
register */
+   uint32_t tmr_acc;   /* 0x00a4 timer accumulator register */
+   uint32_t tmr_prsc;  /* 0x00a8 timer prescale */
+   uint32_t reserved00ac;
+   uint32_t tmr_off_h; /* 0x00b0 timer offset high */
+   uint32_t tmr_off_l; /* 0x00b4 timer offset low  */
+   struct t_tmr_alarm tmr_alarm[FMAN_RTC_MAX_NUM_OF_ALARMS];
+   /* 0x00b8 timer alarm */
+   uint32_t tmr_fiper[FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES];
+   /* 0x00d0 timer fixed period interval */
+   struct t_tmr_ext_trigger tmr_etts[FMAN_RTC_MAX_NUM_OF_EXT_TR

[PATCH v4 09/18] net/dpaa: support Rx/Tx timestamp read

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch implements Rx/Tx timestamp read operations
for DPAA1 platform.

Signed-off-by: Vanshika Shukla 
---
 doc/guides/nics/features/dpaa.ini|  1 +
 drivers/bus/dpaa/base/fman/fman.c| 21 +++-
 drivers/bus/dpaa/base/fman/fman_hw.c |  6 ++-
 drivers/bus/dpaa/include/fman.h  | 18 ++-
 drivers/net/dpaa/dpaa_ethdev.c   |  2 +
 drivers/net/dpaa/dpaa_ethdev.h   | 17 +++
 drivers/net/dpaa/dpaa_ptp.c  | 42 
 drivers/net/dpaa/dpaa_rxtx.c | 71 
 drivers/net/dpaa/dpaa_rxtx.h |  4 +-
 drivers/net/dpaa/meson.build |  1 +
 10 files changed, 168 insertions(+), 15 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_ptp.c

diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index b136ed191a..4196dd800c 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -19,6 +19,7 @@ Flow control = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Timestamp offload= Y
 Basic stats  = Y
 Extended stats   = Y
 FW version   = Y
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index beeb03dbf2..e39bc8c252 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2010-2016 Freescale Semiconductor Inc.
- * Copyright 2017-2020 NXP
+ * Copyright 2017-2024 NXP
  *
  */
 
@@ -520,6 +520,25 @@ fman_if_init(const struct device_node *dpa_node)
goto err;
}
 
+   regs_addr = of_get_address(tx_node, 0, &__if->regs_size, NULL);
+   if (!regs_addr) {
+   FMAN_ERR(-EINVAL, "of_get_address(%s)\n", mname);
+   goto err;
+   }
+   phys_addr = of_translate_address(tx_node, regs_addr);
+   if (!phys_addr) {
+   FMAN_ERR(-EINVAL, "of_translate_address(%s, %p)\n",
+   mname, regs_addr);
+   goto err;
+   }
+   __if->tx_bmi_map = mmap(NULL, __if->regs_size,
+   PROT_READ | PROT_WRITE, MAP_SHARED,
+   fman_ccsr_map_fd, phys_addr);
+   if (__if->tx_bmi_map == MAP_FAILED) {
+   FMAN_ERR(-errno, "mmap(0x%"PRIx64")\n", phys_addr);
+   goto err;
+   }
+
/* No channel ID for MAC-less */
assert(lenp == sizeof(*tx_channel_id));
na = of_n_addr_cells(mac_node);
diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 124c69edb4..4fc41c1ae9 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright 2017,2020 NXP
+ * Copyright 2017,2020,2022 NXP
  *
  */
 
@@ -565,6 +565,10 @@ fman_if_set_ic_params(struct fman_if *fm_if,
&((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ricp;
out_be32(fmbm_ricp, val);
 
+   unsigned int *fmbm_ticp =
+   &((struct tx_bmi_regs *)__if->tx_bmi_map)->fmbm_ticp;
+   out_be32(fmbm_ticp, val);
+
return 0;
 }
 
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 6b2a1893f9..09d1ddb897 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -2,7 +2,7 @@
  *
  * Copyright 2010-2012 Freescale Semiconductor, Inc.
  * All rights reserved.
- * Copyright 2019-2021 NXP
+ * Copyright 2019-2022 NXP
  *
  */
 
@@ -292,6 +292,21 @@ struct rx_bmi_regs {
uint32_t fmbm_rdbg; /**< Rx Debug-*/
 };
 
+struct tx_bmi_regs {
+   uint32_t fmbm_tcfg; /**< Tx Configuration*/
+   uint32_t fmbm_tst;  /**< Tx Status*/
+   uint32_t fmbm_tda;  /**< Tx DMA attributes*/
+   uint32_t fmbm_tfp;  /**< Tx FIFO Parameters*/
+   uint32_t fmbm_tfed; /**< Tx Frame End Data*/
+   uint32_t fmbm_ticp; /**< Tx Internal Context Parameters*/
+   uint32_t fmbm_tfdne;/**< Tx Frame Dequeue Next Engine*/
+   uint32_t fmbm_tfca; /**< Tx Frame Attributes*/
+   uint32_t fmbm_tcfqid;   /**< Tx Confirmation Frame Queue ID*/
+   uint32_t fmbm_tefqid;   /**< Tx Error Frame Queue ID*/
+   uint32_t fmbm_tfene;/**< Tx Frame Enqueue Next Engine*/
+   uint32_t fmbm_trlmts;   /**< Tx Rate Limiter Scale*/
+   uint32_t fmbm_trlmt;/**< Tx Rate Limiter*/
+};
 struct fman_port_qmi_regs {
uint32_t fmqm_pnc;  /**< PortID n Configuration Register */
uint32_t fmqm_pns;  /**< PortID n Status Register */
@@ -380,6 +395,7 @@ struct __fman_if {
uint64_t regs_size;
void *ccsr_map;
void *bmi_map;
+   void *tx_bmi_map;
void *qmi_map;
stru

[PATCH v4 08/18] net/dpaa: share MAC FMC scheme and CC parse

2024-09-30 Thread Hemant Agrawal
From: Jun Yang 

For Shared MAC:
1) Allocate RXQ from VSP scheme. (Virtual Storage Profile)
2) Allocate RXQ from Coarse classifiation (CC) rules to VSP.
2) Remove RXQ allocated which is reconfigured without VSP.
3) Don't alloc default queue and err queues.

Signed-off-by: Jun Yang 
Acked-by: Hemant Agrawal 
---
 drivers/bus/dpaa/include/fman.h |   1 +
 drivers/net/dpaa/dpaa_ethdev.c  |  60 +++--
 drivers/net/dpaa/dpaa_ethdev.h  |  13 +-
 drivers/net/dpaa/dpaa_flow.c|   8 +-
 drivers/net/dpaa/dpaa_fmc.c | 421 
 drivers/net/dpaa/dpaa_rxtx.c|  20 +-
 6 files changed, 346 insertions(+), 177 deletions(-)

diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 60681068ea..6b2a1893f9 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -76,6 +76,7 @@ enum fman_mac_type {
fman_mac_1g,
fman_mac_10g,
fman_mac_2_5g,
+   fman_onic,
 };
 
 struct mac_addr {
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 3ee3029729..bf14d73433 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -255,7 +255,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
DPAA_PMD_ERR("Cannot open IF socket");
return -errno;
}
-
strncpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ - 1);
 
if (ioctl(socket_fd, SIOCGIFMTU, &ifr) < 0) {
@@ -1893,6 +1892,7 @@ dpaa_tx_conf_queue_init(struct qman_fq *fq)
return ret;
 }
 
+#if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
 /* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
 static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
@@ -1923,6 +1923,7 @@ static int dpaa_def_queue_init(struct qman_fq *fq, 
uint32_t fqid)
fqid, ret);
return ret;
 }
+#endif
 
 /* Initialise a network interface */
 static int
@@ -1957,6 +1958,41 @@ dpaa_dev_init_secondary(struct rte_eth_dev *eth_dev)
return 0;
 }
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+static int
+dpaa_error_queue_init(struct dpaa_if *dpaa_intf,
+   struct fman_if *fman_intf)
+{
+   int i, ret;
+   struct qman_fq *err_queues = dpaa_intf->debug_queues;
+   uint32_t err_fqid = 0;
+
+   if (fman_intf->is_shared_mac) {
+   DPAA_PMD_DEBUG("Shared MAC's err queues are handled in kernel");
+   return 0;
+   }
+
+   for (i = 0; i < DPAA_DEBUG_FQ_MAX_NUM; i++) {
+   if (i == DPAA_DEBUG_FQ_RX_ERROR)
+   err_fqid = fman_intf->fqid_rx_err;
+   else if (i == DPAA_DEBUG_FQ_TX_ERROR)
+   err_fqid = fman_intf->fqid_tx_err;
+   else
+   continue;
+   ret = dpaa_def_queue_init(&err_queues[i], err_fqid);
+   if (ret) {
+   DPAA_PMD_ERR("DPAA %s ERROR queue init failed!",
+   i == DPAA_DEBUG_FQ_RX_ERROR ?
+   "RX" : "TX");
+   return ret;
+   }
+   err_queues[i].dpaa_intf = dpaa_intf;
+   }
+
+   return 0;
+}
+#endif
+
 static int
 check_devargs_handler(__rte_unused const char *key, const char *value,
  __rte_unused void *opaque)
@@ -2202,25 +2238,11 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
}
}
dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
-
-#if !defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
-   if (dpaa_ieee_1588)
+#if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
+   ret = dpaa_error_queue_init(dpaa_intf, fman_intf);
+   if (ret)
+   goto free_tx;
 #endif
-   {
-   ret = dpaa_def_queue_init(&dpaa_intf->debug_queues
-   [DPAA_DEBUG_FQ_RX_ERROR], 
fman_intf->fqid_rx_err);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA RX ERROR queue init failed!");
-   goto free_tx;
-   }
-   dpaa_intf->debug_queues[DPAA_DEBUG_FQ_RX_ERROR].dpaa_intf = 
dpaa_intf;
-   ret = dpaa_def_queue_init(&dpaa_intf->debug_queues
-   [DPAA_DEBUG_FQ_TX_ERROR], 
fman_intf->fqid_tx_err);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA TX ERROR queue init failed!");
-   goto free_tx;
-   }
-   }
DPAA_PMD_DEBUG("All frame queues created");
 
/* Get the initial configuration for flow control */
diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h
index b427b29cb6..0a1ceb376a 100644
--- a/drivers/net/dpaa/dpaa_ethdev.h
+++ b/drivers/net/dpaa/dpaa_ethdev.h
@@ -78,8 +78,11 @@
 #define DPAA_IF_RX_CONTEXT_STASH 

[PATCH v4 05/18] bus/dpaa: add port buffer manager stats

2024-09-30 Thread Hemant Agrawal
Add BMI statistics and improving the existing extended
statistics

Signed-off-by: Hemant Agrawal 
Signed-off-by: Gagandeep Singh 
---
 drivers/bus/dpaa/base/fman/fman_hw.c | 61 
 drivers/bus/dpaa/include/fman.h  |  4 +-
 drivers/bus/dpaa/include/fsl_fman.h  | 12 ++
 drivers/bus/dpaa/version.map |  4 ++
 drivers/net/dpaa/dpaa_ethdev.c   | 46 ++---
 drivers/net/dpaa/dpaa_ethdev.h   | 12 ++
 6 files changed, 132 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 97e792806f..124c69edb4 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -267,6 +267,67 @@ fman_if_stats_reset(struct fman_if *p)
;
 }
 
+void
+fman_if_bmi_stats_enable(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   uint32_t tmp;
+
+   tmp = in_be32(®s->fmbm_rstc);
+
+   tmp |= FMAN_BMI_COUNTERS_EN;
+
+   out_be32(®s->fmbm_rstc, tmp);
+}
+
+void
+fman_if_bmi_stats_disable(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   uint32_t tmp;
+
+   tmp = in_be32(®s->fmbm_rstc);
+
+   tmp &= ~FMAN_BMI_COUNTERS_EN;
+
+   out_be32(®s->fmbm_rstc, tmp);
+}
+
+void
+fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   int i = 0;
+
+   value[i++] = (u32)in_be32(®s->fmbm_rfrc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfbc);
+   value[i++] = (u32)in_be32(®s->fmbm_rlfc);
+   value[i++] = (u32)in_be32(®s->fmbm_rffc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfdc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfldec);
+   value[i++] = (u32)in_be32(®s->fmbm_rodc);
+   value[i++] = (u32)in_be32(®s->fmbm_rbdc);
+}
+
+void
+fman_if_bmi_stats_reset(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+
+   out_be32(®s->fmbm_rfrc, 0);
+   out_be32(®s->fmbm_rfbc, 0);
+   out_be32(®s->fmbm_rlfc, 0);
+   out_be32(®s->fmbm_rffc, 0);
+   out_be32(®s->fmbm_rfdc, 0);
+   out_be32(®s->fmbm_rfldec, 0);
+   out_be32(®s->fmbm_rodc, 0);
+   out_be32(®s->fmbm_rbdc, 0);
+}
+
 void
 fman_if_promiscuous_enable(struct fman_if *p)
 {
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 3a6dd555a7..60681068ea 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -56,6 +56,8 @@
 #define FMAN_PORT_BMI_FIFO_UNITS   0x100
 #define FMAN_PORT_IC_OFFSET_UNITS  0x10
 
+#define FMAN_BMI_COUNTERS_EN 0x8000
+
 #define FMAN_ENABLE_BPOOL_DEPLETION0xF0F0
 
 #define HASH_CTRL_MCAST_EN 0x0100
@@ -260,7 +262,7 @@ struct rx_bmi_regs {
/**< Buffer Manager pool Information-*/
uint32_t fmbm_acnt[FMAN_PORT_MAX_EXT_POOLS_NUM];
/**< Allocate Counter-*/
-   uint32_t reserved0130[8];
+   uint32_t reserved0120[16];
/**< 0x130/0x140 - 0x15F reserved -*/
uint32_t fmbm_rcgm[FMAN_PORT_CG_MAP_NUM];
/**< Congestion Group Map*/
diff --git a/drivers/bus/dpaa/include/fsl_fman.h 
b/drivers/bus/dpaa/include/fsl_fman.h
index 20690f8329..5a9750ad0c 100644
--- a/drivers/bus/dpaa/include/fsl_fman.h
+++ b/drivers/bus/dpaa/include/fsl_fman.h
@@ -60,6 +60,18 @@ void fman_if_stats_reset(struct fman_if *p);
 __rte_internal
 void fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n);
 
+__rte_internal
+void fman_if_bmi_stats_enable(struct fman_if *p);
+
+__rte_internal
+void fman_if_bmi_stats_disable(struct fman_if *p);
+
+__rte_internal
+void fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value);
+
+__rte_internal
+void fman_if_bmi_stats_reset(struct fman_if *p);
+
 /* Set ignore pause option for a specific interface */
 void fman_if_set_rx_ignore_pause_frames(struct fman_if *p, bool enable);
 
diff --git a/drivers/bus/dpaa/version.map b/drivers/bus/dpaa/version.map
index 3f547f75cf..a17d57632e 100644
--- a/drivers/bus/dpaa/version.map
+++ b/drivers/bus/dpaa/version.map
@@ -24,6 +24,10 @@ INTERNAL {
fman_dealloc_bufs_mask_hi;
fman_dealloc_bufs_mask_lo;
fman_if_add_mac_addr;
+   fman_if_bmi_stats_enable;
+   fman_if_bmi_stats_disable;
+   fman_if_bmi_stats_get_all;
+   fman_if_bmi_stats_reset;
fman_if_clear_mac_addr;

[PATCH v4 02/18] net/dpaa: fix typecasting ch ID to u32

2024-09-30 Thread Hemant Agrawal
From: Rohit Raj 

Avoid typecasting ch_id to u32 and passing it to another API since it
can corrupt other data. Instead, create new u32 variable and typecase
it back to u16 after it gets updated by the API.

Fixes: 0c504f6950b6 ("net/dpaa: support push mode")
Cc: hemant.agra...@nxp.com
Cc: sta...@dpdk.org

Signed-off-by: Rohit Raj 
---
 drivers/net/dpaa/dpaa_ethdev.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 060b8c678f..1a2de5240f 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -972,7 +972,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
struct fman_if *fif = dev->process_private;
struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_idx];
struct qm_mcc_initfq opts = {0};
-   u32 flags = 0;
+   u32 ch_id, flags = 0;
int ret;
u32 buffsz = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
uint32_t max_rx_pktlen;
@@ -1096,7 +1096,9 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
DPAA_IF_RX_CONTEXT_STASH;
 
/*Create a channel and associate given queue with the channel*/
-   qman_alloc_pool_range((u32 *)&rxq->ch_id, 1, 1, 0);
+   qman_alloc_pool_range(&ch_id, 1, 1, 0);
+   rxq->ch_id = (u16)ch_id;
+
opts.we_mask = opts.we_mask | QM_INITFQ_WE_DESTWQ;
opts.fqd.dest.channel = rxq->ch_id;
opts.fqd.dest.wq = DPAA_IF_RX_PRIORITY;
-- 
2.25.1



[PATCH v4 01/18] bus/dpaa: fix PFDRs leaks due to FQRNIs

2024-09-30 Thread Hemant Agrawal
From: Gagandeep Singh 

When a Retire FQ command is executed on a FQ in the
Tentatively Scheduled or Parked states, in that case FQ
is retired immediately and a FQRNI (Frame Queue Retirement
Notification Immediate) message is generated. Software
must read this message from MR and consume it to free
the memory used by it.

Although it is not mentioned about which memory to be used
by FQRNIs in the RM but through experiments it is proven
that it can use PFDRs. So if these messages are allowed to
build up indefinitely then PFDR resources can become exhausted
and cause enqueues to stall. Therefore software must consume
these MR messages on a regular basis to avoid depleting
the available PFDR resources.

This is the PFDRs leak issue which user can experienace while
using the DPDK crypto driver and creating and destroying the
sessions multiple times. On a session destroy, DPDK calls the
qman_retire_fq() for each FQ used by the session, but it does
not handle the FQRNIs generated and allowed them to build up
indefinitely in MR.

This patch fixes this issue by consuming the FQRNIs received
from MR immediately after FQ retire by calling drain_mr_fqrni().

Please note that this drain_mr_fqrni() only look for
FQRNI type messages to consume. If there are other type of messages
like FQRN, FQRL, FQPN, ERN etc. also coming on MR then those
messages need to be handled separately.

Fixes: c47ff048b99a ("bus/dpaa: add QMAN driver core routines")
Cc: sta...@dpdk.org

Signed-off-by: Gagandeep Singh 
---
 drivers/bus/dpaa/base/qbman/qman.c | 46 --
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman.c 
b/drivers/bus/dpaa/base/qbman/qman.c
index 301057723e..9c90ee25a6 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -292,10 +292,32 @@ static inline void qman_stop_dequeues_ex(struct 
qman_portal *p)
qm_dqrr_set_maxfill(&p->p, 0);
 }
 
+static inline void qm_mr_pvb_update(struct qm_portal *portal)
+{
+   register struct qm_mr *mr = &portal->mr;
+   const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
+
+#ifdef RTE_LIBRTE_DPAA_HWDEBUG
+   DPAA_ASSERT(mr->pmode == qm_mr_pvb);
+#endif
+   /* when accessing 'verb', use __raw_readb() to ensure that compiler
+* inlining doesn't try to optimise out "excess reads".
+*/
+   if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
+   mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
+   if (!mr->pi)
+   mr->vbit ^= QM_MR_VERB_VBIT;
+   mr->fill++;
+   res = MR_INC(res);
+   }
+   dcbit_ro(res);
+}
+
 static int drain_mr_fqrni(struct qm_portal *p)
 {
const struct qm_mr_entry *msg;
 loop:
+   qm_mr_pvb_update(p);
msg = qm_mr_current(p);
if (!msg) {
/*
@@ -317,6 +339,7 @@ static int drain_mr_fqrni(struct qm_portal *p)
do {
now = mfatb();
} while ((then + 1) > now);
+   qm_mr_pvb_update(p);
msg = qm_mr_current(p);
if (!msg)
return 0;
@@ -479,27 +502,6 @@ static inline int qm_mr_init(struct qm_portal *portal,
return 0;
 }
 
-static inline void qm_mr_pvb_update(struct qm_portal *portal)
-{
-   register struct qm_mr *mr = &portal->mr;
-   const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
-
-#ifdef RTE_LIBRTE_DPAA_HWDEBUG
-   DPAA_ASSERT(mr->pmode == qm_mr_pvb);
-#endif
-   /* when accessing 'verb', use __raw_readb() to ensure that compiler
-* inlining doesn't try to optimise out "excess reads".
-*/
-   if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
-   mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
-   if (!mr->pi)
-   mr->vbit ^= QM_MR_VERB_VBIT;
-   mr->fill++;
-   res = MR_INC(res);
-   }
-   dcbit_ro(res);
-}
-
 struct qman_portal *
 qman_init_portal(struct qman_portal *portal,
   const struct qm_portal_config *c,
@@ -1794,6 +1796,8 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
}
 out:
FQUNLOCK(fq);
+   /* Draining FQRNIs, if any */
+   drain_mr_fqrni(&p->p);
return rval;
 }
 
-- 
2.25.1



[PATCH v4 00/18] NXP DPAA ETH driver enhancement and fixes

2024-09-30 Thread Hemant Agrawal
v4: fix clan compilation issues
v3: addressed Ferruh's comments 
 - dropped Tx rate limit API patch
 - added one small bug fix
 - fixed removal/add of fman_offline type

v2: address review comments
 - improve commit message
 - add documentarion for new functions
 - make IEEE1588 config runtime

This series adds several enhancement to the NXP DPAA Ethernet driver.

Primarily:
1. timestamp and IEEE 1588 support
2. OH and ONIC based virtual port config in DPAA
3. frame display and debugging infra


Gagandeep Singh (3):
  bus/dpaa: fix PFDRs leaks due to FQRNIs
  net/dpaa: support mempool debug
  net/dpaa: improve the dpaa port cleanup

Hemant Agrawal (5):
  bus/dpaa: fix VSP for 1G fm1-mac9 and 10
  bus/dpaa: fix the fman details status
  bus/dpaa: add port buffer manager stats
  net/dpaa: implement detailed packet parsing
  net/dpaa: enhance DPAA frame display

Jun Yang (2):
  net/dpaa: share MAC FMC scheme and CC parse
  net/dpaa: improve dpaa errata A010022 handling

Rohit Raj (3):
  net/dpaa: fix typecasting ch ID to u32
  bus/dpaa: add OH port mode for dpaa eth
  bus/dpaa: add ONIC port mode for the DPAA eth

Vanshika Shukla (5):
  net/dpaa: support Tx confirmation to enable PTP
  net/dpaa: add support to separate Tx conf queues
  net/dpaa: support Rx/Tx timestamp read
  net/dpaa: support IEEE 1588 PTP
  net/dpaa: fix reallocate_mbuf handling

 doc/guides/nics/dpaa.rst  |  64 ++-
 doc/guides/nics/features/dpaa.ini |   2 +
 drivers/bus/dpaa/base/fman/fman.c | 583 +++---
 drivers/bus/dpaa/base/fman/fman_hw.c  | 102 +++-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  19 +-
 drivers/bus/dpaa/base/qbman/qman.c|  46 +-
 drivers/bus/dpaa/dpaa_bus.c   |  37 +-
 drivers/bus/dpaa/include/fman.h   | 112 -
 drivers/bus/dpaa/include/fsl_fman.h   |  12 +
 drivers/bus/dpaa/include/fsl_qman.h   |   4 +-
 drivers/bus/dpaa/version.map  |   4 +
 drivers/net/dpaa/dpaa_ethdev.c| 428 +---
 drivers/net/dpaa/dpaa_ethdev.h|  68 ++-
 drivers/net/dpaa/dpaa_flow.c  |  66 +--
 drivers/net/dpaa/dpaa_fmc.c   | 421 ++--
 drivers/net/dpaa/dpaa_ptp.c   | 118 +
 drivers/net/dpaa/dpaa_rxtx.c  | 378 --
 drivers/net/dpaa/dpaa_rxtx.h  | 152 +++---
 drivers/net/dpaa/meson.build  |   1 +
 19 files changed, 2105 insertions(+), 512 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_ptp.c

-- 
2.25.1



[PATCH v4 03/18] bus/dpaa: fix VSP for 1G fm1-mac9 and 10

2024-09-30 Thread Hemant Agrawal
No need to classify interface separately for 1G and 10G
Note that VSP or Virtual storage profile are DPAA equivalent for SRIOV
config to logically divide a physical ports in virtual ports.

Fixes: e0718bb2ca95 ("bus/dpaa: add virtual storage profile port init")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index 41195eb0a7..beeb03dbf2 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -153,7 +153,7 @@ static void fman_if_vsp_init(struct __fman_if *__if)
size_t lenp;
const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
-   if (__if->__if.mac_type == fman_mac_1g) {
+   if (__if->__if.mac_idx <= 8) {
for_each_compatible_node(dev, NULL,
"fsl,fman-port-1g-rx-extended-args") {
prop = of_get_property(dev, "cell-index", &lenp);
@@ -176,7 +176,32 @@ static void fman_if_vsp_init(struct __fman_if *__if)
}
}
}
-   } else if (__if->__if.mac_type == fman_mac_10g) {
+
+   for_each_compatible_node(dev, NULL,
+"fsl,fman-port-op-extended-args") {
+   prop = of_get_property(dev, "cell-index", &lenp);
+
+   if (prop) {
+   cell_index = of_read_number(&prop[0],
+   lenp / sizeof(phandle));
+
+   if (cell_index == __if->__if.mac_idx) {
+   prop = of_get_property(dev,
+  "vsp-window",
+  &lenp);
+
+   if (prop) {
+   __if->__if.num_profiles =
+   of_read_number(&prop[0],
+  1);
+   __if->__if.base_profile_id =
+   of_read_number(&prop[1],
+  1);
+   }
+   }
+   }
+   }
+   } else {
for_each_compatible_node(dev, NULL,
"fsl,fman-port-10g-rx-extended-args") {
prop = of_get_property(dev, "cell-index", &lenp);
-- 
2.25.1



[PATCH v3 18/18] net/dpaa: fix reallocate_mbuf handling

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch fixes the bug in the reallocate_mbuf code
handling. The source location is corrected when copying
the data in the new mbuf.

Fixes: f8c7a17a48c9 ("net/dpaa: support Tx scatter gather for non-DPAA buffer")
Cc: sta...@dpdk.org

Signed-off-by: Vanshika Shukla 
---
 drivers/net/dpaa/dpaa_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 1d7efdef88..247e7b92ba 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1223,7 +1223,7 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
/* Copy the data */
data = rte_pktmbuf_append(new_mbufs[0], bytes_to_copy);
 
-   rte_memcpy((uint8_t *)data, rte_pktmbuf_mtod_offset(mbuf,
+   rte_memcpy((uint8_t *)data, rte_pktmbuf_mtod_offset(temp_mbuf,
   void *, offset1), bytes_to_copy);
 
/* Set new offsets and the temp buffers */
-- 
2.25.1



[PATCH v3 17/18] net/dpaa: improve dpaa errata A010022 handling

2024-09-30 Thread Hemant Agrawal
From: Jun Yang 

This patch improves the errata handling for
"RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022"

Signed-off-by: Jun Yang 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index d82c6f3be2..1d7efdef88 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1258,6 +1258,35 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
return new_mbufs[0];
 }
 
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+/* In case the data offset is not multiple of 16,
+ * FMAN can stall because of an errata. So reallocate
+ * the buffer in such case.
+ */
+static inline int
+dpaa_eth_ls1043a_mbuf_realloc(struct rte_mbuf *mbuf)
+{
+   uint64_t len, offset;
+
+   if (dpaa_svr_family != SVR_LS1043A_FAMILY)
+   return 0;
+
+   while (mbuf) {
+   len = mbuf->data_len;
+   offset = mbuf->data_off;
+   if ((mbuf->next &&
+   !rte_is_aligned((void *)len, 16)) ||
+   !rte_is_aligned((void *)offset, 16)) {
+   DPAA_PMD_DEBUG("Errata condition hit");
+
+   return 1;
+   }
+   mbuf = mbuf->next;
+   }
+   return 0;
+}
+#endif
+
 uint16_t
 dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
@@ -1296,14 +1325,6 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_BURST_SIZE : nb_bufs;
for (loop = 0; loop < frames_to_send; loop++) {
mbuf = *(bufs++);
-   /* In case the data offset is not multiple of 16,
-* FMAN can stall because of an errata. So reallocate
-* the buffer in such case.
-*/
-   if (dpaa_svr_family == SVR_LS1043A_FAMILY &&
-   (mbuf->data_off & 0x7F) != 0x0)
-   realloc_mbuf = 1;
-
fd_arr[loop].cmd = 0;
if (dpaa_ieee_1588) {
fd_arr[loop].cmd |= DPAA_FD_CMD_FCO |
@@ -1311,6 +1332,9 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
fd_arr[loop].cmd |= DPAA_FD_CMD_RPD |
DPAA_FD_CMD_UPD;
}
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+   realloc_mbuf = dpaa_eth_ls1043a_mbuf_realloc(mbuf);
+#endif
seqn = *dpaa_seqn(mbuf);
if (seqn != DPAA_INVALID_MBUF_SEQN) {
index = seqn - 1;
-- 
2.25.1



[PATCH v3 16/18] net/dpaa: improve the dpaa port cleanup

2024-09-30 Thread Hemant Agrawal
From: Gagandeep Singh 

During DPAA cleanup in FMCLESS mode, application can
see segmentation fault in device close API and in DPAA
destructor execution.
Segmentation fault in device close is because driver
reducing the number of queues initialised during
device configuration without releasing the actual queues.

And segmentation fault in DPAA destruction is because
it is trying to access RTE* devices whose memory has
been released in rte_eal_cleanup() call by the application.

This patch improves the behavior.

Signed-off-by: Gagandeep Singh 
---
 drivers/net/dpaa/dpaa_ethdev.c | 33 +++--
 drivers/net/dpaa/dpaa_flow.c   |  5 ++---
 2 files changed, 13 insertions(+), 25 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 133fbd5bc9..41ae033c75 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -561,10 +561,10 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
if (dpaa_intf->cgr_rx) {
for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
+   rte_free(dpaa_intf->cgr_rx);
+   dpaa_intf->cgr_rx = NULL;
}
 
-   rte_free(dpaa_intf->cgr_rx);
-   dpaa_intf->cgr_rx = NULL;
/* Release TX congestion Groups */
if (dpaa_intf->cgr_tx) {
for (loop = 0; loop < MAX_DPAA_CORES; loop++)
@@ -578,6 +578,15 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 
rte_free(dpaa_intf->tx_queues);
dpaa_intf->tx_queues = NULL;
+   if (dpaa_intf->port_handle) {
+   if (dpaa_fm_deconfig(dpaa_intf, fif))
+   DPAA_PMD_WARN("DPAA FM "
+   "deconfig failed\n");
+   }
+   if (fif->num_profiles) {
+   if (dpaa_port_vsp_cleanup(dpaa_intf, fif))
+   DPAA_PMD_WARN("DPAA FM vsp cleanup failed\n");
+   }
 
return ret;
 }
@@ -2607,26 +2616,6 @@ static void __attribute__((destructor(102))) 
dpaa_finish(void)
return;
 
if (!(default_q || fmc_q)) {
-   unsigned int i;
-
-   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-   if (rte_eth_devices[i].dev_ops == &dpaa_devops) {
-   struct rte_eth_dev *dev = &rte_eth_devices[i];
-   struct dpaa_if *dpaa_intf =
-   dev->data->dev_private;
-   struct fman_if *fif =
-   dev->process_private;
-   if (dpaa_intf->port_handle)
-   if (dpaa_fm_deconfig(dpaa_intf, fif))
-   DPAA_PMD_WARN("DPAA FM "
-   "deconfig failed");
-   if (fif->num_profiles) {
-   if (dpaa_port_vsp_cleanup(dpaa_intf,
- fif))
-   DPAA_PMD_WARN("DPAA FM vsp 
cleanup failed");
-   }
-   }
-   }
if (is_global_init)
if (dpaa_fm_term())
DPAA_PMD_WARN("DPAA FM term failed");
diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c
index b9cd11efa1..c01d8eaca1 100644
--- a/drivers/net/dpaa/dpaa_flow.c
+++ b/drivers/net/dpaa/dpaa_flow.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DPAA_MAX_NUM_ETH_DEV   8
 
@@ -811,8 +812,6 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t 
req_dist_set)
return -1;
}
 
-   dpaa_intf->nb_rx_queues = dev->data->nb_rx_queues;
-
/* Open FM Port and set it in port info */
ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif);
if (ret) {
@@ -821,7 +820,7 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t 
req_dist_set)
}
 
if (fif->num_profiles) {
-   for (i = 0; i < dpaa_intf->nb_rx_queues; i++)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
dpaa_intf->rx_queues[i].vsp_id =
fm_default_vsp_id(fif);
 
-- 
2.25.1



[PATCH v3 15/18] bus/dpaa: add ONIC port mode for the DPAA eth

2024-09-30 Thread Hemant Agrawal
From: Rohit Raj 

The OH ports can also be used by two application, processing contexts
to communicate to each other.
This patch enables this mode for dpaa-eth OH port as ONIC port,
so that application can use the dpaa-eth to communicate to each
other on the same SoC.

Again,this properties is driven by the system device-tree variables.

Signed-off-by: Rohit Raj 
---
 doc/guides/nics/dpaa.rst  |  33 ++-
 drivers/bus/dpaa/base/fman/fman.c | 299 +-
 drivers/bus/dpaa/base/fman/fman_hw.c  |  20 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |   4 +-
 drivers/bus/dpaa/dpaa_bus.c   |  16 +-
 drivers/bus/dpaa/include/fman.h   |  15 +-
 drivers/net/dpaa/dpaa_ethdev.c| 114 +++--
 drivers/net/dpaa/dpaa_flow.c  |  27 +-
 drivers/net/dpaa/dpaa_fmc.c   |   2 +-
 9 files changed, 469 insertions(+), 61 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index 47dcce334c..529d5b74f4 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -136,7 +136,7 @@ RTE framework and DPAA internal components/drivers.
   The Ethernet driver is bound to a FMAN port and implements the interfaces
   needed to connect the DPAA network interface to the network stack.
   Each FMAN Port corresponds to a DPDK network interface.
-- PMD also support OH mode, where the port works as a HW assisted
+- PMD also support OH/ONIC mode, where the port works as a HW assisted
   virtual port without actually connecting to a Physical MAC.
 
 
@@ -152,7 +152,7 @@ Features
   - Promiscuous mode
   - IEEE1588 PTP
   - OH Port for inter application communication
-
+  - ONIC virtual port support
 
 DPAA Mempool Driver
 ~~~
@@ -350,6 +350,35 @@ OH Port
  Rx Packets  -
 
 
+ONIC
+
+   To use OH port to communicate between two applications, we can assign Rx 
port
+   of an O/H port to Application 1 and Tx port to Application 2 so that
+   Application 1 can send packets to Application 2. Similarly, we can assign Tx
+   port of another O/H port to Application 1 and Rx port to Application 2 so 
that
+   Applicaiton 2 can send packets to Application 1.
+
+   ONIC is logically defined to achieve it. Internally it will use one Rx queue
+   of an O/H port and one Tx queue of another O/H port.
+   For application, it will behave as single O/H port.
+
+   +--+ +--++--++--++--+
+   |  |   Tx|  |   Rx   | O/H  |   Tx   |  |   Rx   |  |
+   |  | - - - > |  | -  - > | Port | -  - > |  | -  - > |  |
+   |  | |  ||  1   ||  ||  |
+   |  | |  |+--+|  ||  |
+   | App  | | ONIC || ONIC || App  |
+   |  1   | | Port || Port ||  2   |
+   |  | |  1   |+--+|  2   ||  |
+   |  |   Rx|  |   Tx   | O/H  |   Rx   |  |   Tx   |  |
+   |  | < - - - |  | < - - -| Port | < - - -|  | < - - -|  |
+   |  | |  ||  2   ||  ||  |
+   +--+ +--++--++--++--+
+
+   All the packets received by ONIC port 1 will be send to ONIC port 2 and vice
+   versa. These ports can be used by DPDK applications just like physical 
ports.
+
+
 VSP (Virtual Storage Profile)
 ~
The storage profiled are means to provide virtualized interface. A ranges of
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index f817305ab7..efe6eab4a9 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -43,7 +43,7 @@ if_destructor(struct __fman_if *__if)
if (!__if)
return;
 
-   if (__if->__if.mac_type == fman_offline)
+   if (__if->__if.mac_type == fman_offline_internal)
goto cleanup;
 
list_for_each_entry_safe(bp, tmpbp, &__if->__if.bpool_list, node) {
@@ -465,7 +465,7 @@ fman_if_init(const struct device_node *dpa_node)
__if->__if.is_memac = 0;
 
if (is_offline)
-   __if->__if.mac_type = fman_offline;
+   __if->__if.mac_type = fman_offline_internal;
else if (of_device_is_compatible(mac_node, "fsl,fman-1g-mac"))
__if->__if.mac_type = fman_mac_1g;
else if (of_device_is_compatible(mac_node, "fsl,fman-10g-mac"))
@@ -791,6 +791,292 @@ fman_if_init(const struct device_node *dpa_node)
dname, __if->__if.tx_channel_id, __if->__if.fman_idx,
__if->__if.mac_idx);
 
+   /* Don't add OH port to the port list since they will be used by ONIC
+* ports.
+*/
+   if (!is_offline)
+   list_add_tail(&__if->__if.n

[PATCH v3 14/18] bus/dpaa: add OH port mode for dpaa eth

2024-09-30 Thread Hemant Agrawal
From: Rohit Raj 

NXP DPAA architecture supports the concept of DPAA
port as Offline Port - meaning - not connected to an actual MAC.
This is an hardware assited IPC mechanism for communiting between two
applications.

Offline(O/H) port is a type of hardware port which is able to dequeue and
enqueue from/to a QMan queue. The FMan applies a Parse Classify Distribute
(PCD) flow and (if configured to do so) enqueues the frame back in a
QMan queue.

The FMan is able to copy the frame into new buffers and enqueue back to the
QMan. This means these ports can be used to send and receive packet
between two applications.

An O/H port Have two queues. One to receive and one to send the packets.
It will loopback all the packets on Tx queue which are received
on Rx queue.

This property is completely driven by the device-tree. During the
DPAA bus scan, based on the platform device properties as in
device-tree, the port can be classified as OH port.

This patch add support in the driver to use dpaa eth port
in OH mode as well with DPDK applications.

Signed-off-by: Rohit Raj 
---
 doc/guides/nics/dpaa.rst  |  26 ++-
 drivers/bus/dpaa/base/fman/fman.c | 259 ++
 drivers/bus/dpaa/base/fman/fman_hw.c  |  24 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  19 +-
 drivers/bus/dpaa/dpaa_bus.c   |  23 +-
 drivers/bus/dpaa/include/fman.h   |  31 ++-
 drivers/net/dpaa/dpaa_ethdev.c|  85 ++-
 drivers/net/dpaa/dpaa_ethdev.h|   6 +
 drivers/net/dpaa/dpaa_flow.c  |  66 --
 9 files changed, 393 insertions(+), 146 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index edf7a7e350..47dcce334c 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -1,5 +1,5 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
-Copyright 2017,2020 NXP
+Copyright 2017,2020-2024 NXP
 
 
 DPAA Poll Mode Driver
@@ -136,6 +136,8 @@ RTE framework and DPAA internal components/drivers.
   The Ethernet driver is bound to a FMAN port and implements the interfaces
   needed to connect the DPAA network interface to the network stack.
   Each FMAN Port corresponds to a DPDK network interface.
+- PMD also support OH mode, where the port works as a HW assisted
+  virtual port without actually connecting to a Physical MAC.
 
 
 Features
@@ -149,6 +151,8 @@ Features
   - Checksum offload
   - Promiscuous mode
   - IEEE1588 PTP
+  - OH Port for inter application communication
+
 
 DPAA Mempool Driver
 ~~~
@@ -326,6 +330,26 @@ FMLIB
`Kernel FMD Driver

`_.
 
+OH Port
+~~~
+   Offline(O/H) port is a type of hardware port which is able to dequeue and
+   enqueue from/to a QMan queue. The FMan applies a Parse Classify Distribute 
(PCD)
+   flow and (if configured to do so) enqueues the frame back in a QMan queue.
+
+   The FMan is able to copy the frame into new buffers and enqueue back to the
+   QMan. This means these ports can be used to send and receive packets 
between two
+   applications as well.
+
+   An O/H port have two queues. One to receive and one to send the packets. It 
will
+   loopback all the packets on Tx queue which are received on Rx queue.
+
+
+     Tx Packets  -
+   | App  | - -  - - - - - - - > | O/H   |
+   |  | < - - - - - - - - -  | Port  |
+     Rx Packets  -
+
+
 VSP (Virtual Storage Profile)
 ~
The storage profiled are means to provide virtualized interface. A ranges of
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index e2b7120237..f817305ab7 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -246,26 +246,34 @@ fman_if_init(const struct device_node *dpa_node)
uint64_t port_cell_idx_val = 0;
uint64_t ext_args_cell_idx_val = 0;
 
-   const struct device_node *mac_node = NULL, *tx_node, *ext_args_node;
-   const struct device_node *pool_node, *fman_node, *rx_node;
+   const struct device_node *mac_node = NULL, *ext_args_node;
+   const struct device_node *pool_node, *fman_node;
+   const struct device_node *rx_node = NULL, *tx_node = NULL;
+   const struct device_node *oh_node = NULL;
const uint32_t *regs_addr = NULL;
const char *mname, *fname;
const char *dname = dpa_node->full_name;
size_t lenp;
-   int _errno, is_shared = 0;
+   int _errno, is_shared = 0, is_offline = 0;
const char *char_prop;
uint32_t na;
 
if (of_device_is_available(dpa_node) == false)
return 0;
 
-   if (!of_device_is_compatible(dpa_node, "fsl,dpa-ethernet-init") &&
-   !of_device_is_compatible(dpa_node, "fsl,dpa-ethernet")) {

[PATCH v3 13/18] net/dpaa: support mempool debug

2024-09-30 Thread Hemant Agrawal
From: Gagandeep Singh 

This patch adds support to compile time debug the mempool
corruptions in dpaa driver.

Signed-off-by: Gagandeep Singh 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 945c84ab10..d82c6f3be2 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -494,6 +494,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->data_len = sg_temp->length;
first_seg->pkt_len = sg_temp->length;
rte_mbuf_refcnt_set(first_seg, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)first_seg),
+   (void **)&first_seg, 1, 1);
+#endif
 
first_seg->port = ifid;
first_seg->nb_segs = 1;
@@ -511,6 +515,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->pkt_len += sg_temp->length;
first_seg->nb_segs += 1;
rte_mbuf_refcnt_set(cur_seg, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
+   (void **)&cur_seg, 1, 1);
+#endif
prev_seg->next = cur_seg;
if (sg_temp->final) {
cur_seg->next = NULL;
@@ -522,6 +530,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->pkt_len, first_seg->nb_segs);
 
dpaa_eth_packet_info(first_seg, vaddr);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
+   (void **)&temp, 1, 1);
+#endif
rte_pktmbuf_free_seg(temp);
 
return first_seg;
@@ -562,6 +574,10 @@ dpaa_eth_fd_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
 
return mbuf;
@@ -676,6 +692,10 @@ dpaa_rx_cb_no_prefetch(struct qman_fq **fq, struct 
qm_dqrr_entry **dqrr,
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
dpaa_display_frame_info(fd, fq[0]->fqid, true);
if (dpaa_ieee_1588) {
@@ -722,6 +742,10 @@ dpaa_rx_cb(struct qman_fq **fq, struct qm_dqrr_entry 
**dqrr,
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
dpaa_display_frame_info(fd, fq[0]->fqid, true);
if (dpaa_ieee_1588) {
@@ -972,6 +996,10 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
return -1;
}
 
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
+   (void **)&temp, 1, 0);
+#endif
fd->cmd = 0;
fd->opaque_addr = 0;
 
@@ -1017,6 +1045,10 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
} else {
sg_temp->bpid =
DPAA_MEMPOOL_TO_BPID(cur_seg->pool);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   
rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
+   (void **)&cur_seg, 1, 0);
+#endif
}
} else if (RTE_MBUF_HAS_EXTBUF(cur_seg)) {
free_buf[*free_count].seg = cur_seg;
@@ -1074,6 +1106,10 @@ tx_on_dpaa_pool_unsegmented(struct rte_mbuf *mbuf,
 * released by BMAN.
 */
DPAA_MBUF_TO_CONTIG_FD(mbuf, fd_arr, bp_info->bpid);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void 
*)mbuf),
+   (void **)&mbuf, 1, 0);
+#endif
}
} else if (RTE_MBUF_HAS_EXTBUF(mbuf)) {
buf_to_free[*free_count].seg = mbuf;
@@ -1302,6 +1338,10 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_CKSUM_OFFLOAD_MASK)
dpaa_unsegmented_checksum(mbuf,
 

[PATCH v3 12/18] net/dpaa: enhance DPAA frame display

2024-09-30 Thread Hemant Agrawal
This patch enhances the received packet debugging capability.
This help displaying the full packet parsing output.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
 doc/guides/nics/dpaa.rst   |   5 ++
 drivers/net/dpaa/dpaa_ethdev.c |   9 +++
 drivers/net/dpaa/dpaa_rxtx.c   | 138 +++--
 drivers/net/dpaa/dpaa_rxtx.h   |   5 ++
 4 files changed, 133 insertions(+), 24 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index ea86e6146c..edf7a7e350 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -227,6 +227,11 @@ state during application initialization:
   application want to use eventdev with DPAA device.
   Currently these queues are not used for LS1023/LS1043 platform by default.
 
+- ``DPAA_DISPLAY_FRAME_AND_PARSER_RESULT`` (default 0)
+
+  This defines the debug flag, whether to dump the detailed frame and packet
+  parsing result for the incoming packets.
+
 
 Driver compilation and testing
 --
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index a302b24be6..4ead890278 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -2056,6 +2056,9 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
int8_t dev_vspids[DPAA_MAX_NUM_PCD_QUEUES];
int8_t vsp_id = -1;
struct rte_device *dev = eth_dev->device;
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+   char *penv;
+#endif
 
PMD_INIT_FUNC_TRACE();
 
@@ -2135,6 +2138,12 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
td_tx_threshold = CGR_RX_PERFQ_THRESH;
}
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+   penv = getenv("DPAA_DISPLAY_FRAME_AND_PARSER_RESULT");
+   if (penv)
+   dpaa_force_display_frame_set(atoi(penv));
+#endif
+
/* If congestion control is enabled globally*/
if (num_rx_fqs > 0 && td_threshold) {
dpaa_intf->cgr_rx = rte_zmalloc(NULL,
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 99fc3f1b43..945c84ab10 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -47,6 +47,10 @@
 #include 
 #include 
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+static int s_force_display_frm;
+#endif
+
 #define DPAA_MBUF_TO_CONTIG_FD(_mbuf, _fd, _bpid) \
do { \
(_fd)->opaque_addr = 0; \
@@ -58,37 +62,122 @@
} while (0)
 
 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+void
+dpaa_force_display_frame_set(int set)
+{
+   s_force_display_frm = set;
+}
+
 #define DISPLAY_PRINT printf
-static void dpaa_display_frame_info(const struct qm_fd *fd,
-   uint32_t fqid, bool rx)
+static void
+dpaa_display_frame_info(const struct qm_fd *fd,
+   uint32_t fqid, bool rx)
 {
-   int ii;
-   char *ptr;
+   int pos, offset = 0;
+   char *ptr, info[1024];
struct annotations_t *annot = rte_dpaa_mem_ptov(fd->addr);
uint8_t format;
+   const struct dpaa_eth_parse_results_t *psr;
 
-   if (!fd->status) {
-   /* Do not display correct packets.*/
+   if (!fd->status && !s_force_display_frm) {
+   /* Do not display correct packets unless force display.*/
return;
}
+   psr = &annot->parse;
 
-   format = (fd->opaque & DPAA_FD_FORMAT_MASK) >>
-   DPAA_FD_FORMAT_SHIFT;
-
-   DISPLAY_PRINT("fqid %d bpid %d addr 0x%lx, format %d\r\n",
- fqid, fd->bpid, (unsigned long)fd->addr, fd->format);
-   DISPLAY_PRINT("off %d, len %d stat 0x%x\r\n",
- fd->offset, fd->length20, fd->status);
+   format = (fd->opaque & DPAA_FD_FORMAT_MASK) >> DPAA_FD_FORMAT_SHIFT;
+   if (format == qm_fd_contig)
+   sprintf(info, "simple");
+   else if (format == qm_fd_sg)
+   sprintf(info, "sg");
+   else
+   sprintf(info, "unknown format(%d)", format);
+
+   DISPLAY_PRINT("%s: fqid=%08x, bpid=%d, phy addr=0x%lx ",
+   rx ? "RX" : "TX", fqid, fd->bpid, (unsigned long)fd->addr);
+   DISPLAY_PRINT("format=%s offset=%d, len=%d, stat=0x%x\r\n",
+   info, fd->offset, fd->length20, fd->status);
if (rx) {
-   ptr = (char *)&annot->parse;
-   DISPLAY_PRINT("RX parser result:\r\n");
-   for (ii = 0; ii < (int)sizeof(struct dpaa_eth_parse_results_t);
-   ii++) {
-   DISPLAY_PRINT("%02x ", ptr[ii]);
-   if (((ii + 1) % 16) == 0)
-   DISPLAY_PRINT("\n");
+   DISPLAY_PRINT("Display usual RX parser result:\r\n");
+   

[PATCH v3 11/18] net/dpaa: implement detailed packet parsing

2024-09-30 Thread Hemant Agrawal
This patch implements the detailed packet parsing using
the annotation info from the hardware.

decode parser to set RX muf packet type by dpaa_slow_parsing.
Support to identify the IPSec ESP, GRE and SCTP packets.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
 drivers/net/dpaa/dpaa_ethdev.c |   1 +
 drivers/net/dpaa/dpaa_rxtx.c   |  35 +++-
 drivers/net/dpaa/dpaa_rxtx.h   | 143 ++---
 3 files changed, 93 insertions(+), 86 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 82d1960356..a302b24be6 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -411,6 +411,7 @@ dpaa_supported_ptypes_get(struct rte_eth_dev *dev, size_t 
*no_of_elements)
RTE_PTYPE_L4_UDP,
RTE_PTYPE_L4_SCTP,
RTE_PTYPE_TUNNEL_ESP,
+   RTE_PTYPE_TUNNEL_GRE,
};
 
PMD_INIT_FUNC_TRACE();
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index e3b4bb14ab..99fc3f1b43 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -110,11 +110,38 @@ static void dpaa_display_frame_info(const struct qm_fd 
*fd,
 #define dpaa_display_frame_info(a, b, c)
 #endif
 
-static inline void dpaa_slow_parsing(struct rte_mbuf *m __rte_unused,
-uint64_t prs __rte_unused)
+static inline void
+dpaa_slow_parsing(struct rte_mbuf *m,
+   const struct annotations_t *annot)
 {
+   const struct dpaa_eth_parse_results_t *parse;
+
DPAA_DP_LOG(DEBUG, "Slow parsing");
-   /*TBD:XXX: to be implemented*/
+   parse = &annot->parse;
+
+   if (parse->ethernet)
+   m->packet_type |= RTE_PTYPE_L2_ETHER;
+   if (parse->vlan)
+   m->packet_type |= RTE_PTYPE_L2_ETHER_VLAN;
+   if (parse->first_ipv4)
+   m->packet_type |= RTE_PTYPE_L3_IPV4;
+   if (parse->first_ipv6)
+   m->packet_type |= RTE_PTYPE_L3_IPV6;
+   if (parse->gre)
+   m->packet_type |= RTE_PTYPE_TUNNEL_GRE;
+   if (parse->last_ipv4)
+   m->packet_type |= RTE_PTYPE_L3_IPV4_EXT;
+   if (parse->last_ipv6)
+   m->packet_type |= RTE_PTYPE_L3_IPV6_EXT;
+   if (parse->l4_type == DPAA_PR_L4_TCP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_TCP;
+   else if (parse->l4_type == DPAA_PR_L4_UDP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_UDP;
+   else if (parse->l4_type == DPAA_PR_L4_IPSEC_TYPE &&
+   !parse->l4_info_err && parse->esp_sum)
+   m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
+   else if (parse->l4_type == DPAA_PR_L4_SCTP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_SCTP;
 }
 
 static inline void dpaa_eth_packet_info(struct rte_mbuf *m, void *fd_virt_addr)
@@ -228,7 +255,7 @@ static inline void dpaa_eth_packet_info(struct rte_mbuf *m, 
void *fd_virt_addr)
break;
/* More switch cases can be added */
default:
-   dpaa_slow_parsing(m, prs);
+   dpaa_slow_parsing(m, annot);
}
 
m->tx_offload = annot->parse.ip_off[0];
diff --git a/drivers/net/dpaa/dpaa_rxtx.h b/drivers/net/dpaa/dpaa_rxtx.h
index 1048e86d41..215bdeaf7f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.h
+++ b/drivers/net/dpaa/dpaa_rxtx.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017,2020-2022 NXP
+ *   Copyright 2017,2020-2024 NXP
  *
  */
 
@@ -162,98 +162,77 @@
 
 #define DPAA_PKT_L3_LEN_SHIFT  7
 
+enum dpaa_parse_result_l4_type {
+   DPAA_PR_L4_TCP_TYPE = 1,
+   DPAA_PR_L4_UDP_TYPE = 2,
+   DPAA_PR_L4_IPSEC_TYPE = 3,
+   DPAA_PR_L4_SCTP_TYPE = 4,
+   DPAA_PR_L4_DCCP_TYPE = 5
+};
+
 /**
  * FMan parse result array
  */
 struct dpaa_eth_parse_results_t {
-uint8_t lpid;   /**< Logical port id */
-uint8_t shimr;  /**< Shim header result  */
-union {
-   uint16_t  l2r;  /**< Layer 2 result */
+   uint8_t lpid; /**< Logical port id */
+   uint8_t shimr; /**< Shim header result  */
+   union {
+   uint16_t l2r; /**< Layer 2 result */
struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-   uint16_t  ethernet:1;
-   uint16_t  vlan:1;
-   uint16_t  llc_snap:1;
-   uint16_t  mpls:1;
-   uint16_t  ppoe_ppp:1;
-   uint16_t  unused_1:3;
-   uint16_t  unknown_eth_proto:1;
-   uint16_t  eth_frame_type:2;
-   uint16_t  l2r_err:5;
+   uint16_t u

[PATCH v3 10/18] net/dpaa: support IEEE 1588 PTP

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch adds the support for the ethdev APIs
to enable/disable and read/write/adjust IEEE1588
PTP timestamps for DPAA platform.

Signed-off-by: Vanshika Shukla 
---
 doc/guides/nics/dpaa.rst  |  1 +
 doc/guides/nics/features/dpaa.ini |  1 +
 drivers/bus/dpaa/base/fman/fman.c | 15 ++
 drivers/bus/dpaa/include/fman.h   | 45 +
 drivers/net/dpaa/dpaa_ethdev.c|  5 ++
 drivers/net/dpaa/dpaa_ethdev.h| 16 +++
 drivers/net/dpaa/dpaa_ptp.c   | 80 ++-
 7 files changed, 161 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index acf4daab02..ea86e6146c 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -148,6 +148,7 @@ Features
   - Packet type information
   - Checksum offload
   - Promiscuous mode
+  - IEEE1588 PTP
 
 DPAA Mempool Driver
 ~~~
diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index 4196dd800c..4f31b61de1 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -19,6 +19,7 @@ Flow control = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Timesync = Y
 Timestamp offload= Y
 Basic stats  = Y
 Extended stats   = Y
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index e39bc8c252..e2b7120237 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -28,6 +28,7 @@ u32 fman_dealloc_bufs_mask_lo;
 
 int fman_ccsr_map_fd = -1;
 static COMPAT_LIST_HEAD(__ifs);
+void *rtc_map;
 
 /* This is the (const) global variable that callers have read-only access to.
  * Internally, we have read-write access directly to __ifs.
@@ -539,6 +540,20 @@ fman_if_init(const struct device_node *dpa_node)
goto err;
}
 
+   if (!rtc_map) {
+   __if->rtc_map = mmap(NULL, FMAN_IEEE_1588_SIZE,
+   PROT_READ | PROT_WRITE, MAP_SHARED,
+   fman_ccsr_map_fd, FMAN_IEEE_1588_OFFSET);
+   if (__if->rtc_map == MAP_FAILED) {
+   pr_err("Can not map FMan RTC regs base\n");
+   _errno = -EINVAL;
+   goto err;
+   }
+   rtc_map = __if->rtc_map;
+   } else {
+   __if->rtc_map = rtc_map;
+   }
+
/* No channel ID for MAC-less */
assert(lenp == sizeof(*tx_channel_id));
na = of_n_addr_cells(mac_node);
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 09d1ddb897..e8bc913943 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -64,6 +64,12 @@
 #define GROUP_ADDRESS  0x0100LL
 #define HASH_CTRL_ADDR_MASK0x003F
 
+#define FMAN_RTC_MAX_NUM_OF_ALARMS 3
+#define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES4
+#define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS   3
+#define FMAN_IEEE_1588_OFFSET  0X1AFE000
+#define FMAN_IEEE_1588_SIZE4096
+
 /* Pre definitions of FMAN interface and Bpool structures */
 struct __fman_if;
 struct fman_if_bpool;
@@ -307,6 +313,44 @@ struct tx_bmi_regs {
uint32_t fmbm_trlmts;   /**< Tx Rate Limiter Scale*/
uint32_t fmbm_trlmt;/**< Tx Rate Limiter*/
 };
+
+/* Description FM RTC timer alarm */
+struct t_tmr_alarm {
+   uint32_t tmr_alarm_h;
+   uint32_t tmr_alarm_l;
+};
+
+/* Description FM RTC timer Ex trigger */
+struct t_tmr_ext_trigger {
+   uint32_t tmr_etts_h;
+   uint32_t tmr_etts_l;
+};
+
+struct rtc_regs {
+   uint32_t tmr_id;/* 0x000 Module ID register */
+   uint32_t tmr_id2;   /* 0x004 Controller ID register */
+   uint32_t reserved0008[30];
+   uint32_t tmr_ctrl;  /* 0x0080 timer control register */
+   uint32_t tmr_tevent;/* 0x0084 timer event register */
+   uint32_t tmr_temask;/* 0x0088 timer event mask register */
+   uint32_t reserved008c[3];
+   uint32_t tmr_cnt_h; /* 0x0098 timer counter high register */
+   uint32_t tmr_cnt_l; /* 0x009c timer counter low register */
+   uint32_t tmr_add;   /* 0x00a0 timer drift compensation addend 
register */
+   uint32_t tmr_acc;   /* 0x00a4 timer accumulator register */
+   uint32_t tmr_prsc;  /* 0x00a8 timer prescale */
+   uint32_t reserved00ac;
+   uint32_t tmr_off_h; /* 0x00b0 timer offset high */
+   uint32_t tmr_off_l; /* 0x00b4 timer offset low  */
+   struct t_tmr_alarm tmr_alarm[FMAN_RTC_MAX_NUM_OF_ALARMS];
+   /* 0x00b8 timer alarm */
+   uint32_t tmr_fiper[FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES];
+   /* 0x00d0 timer fixed period interval */
+   struct t_tmr_ext_trigger tmr_etts[FMAN_RTC_MAX_NUM_OF_EXT_TR

[PATCH v3 09/18] net/dpaa: support Rx/Tx timestamp read

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch implements Rx/Tx timestamp read operations
for DPAA1 platform.

Signed-off-by: Vanshika Shukla 
---
 doc/guides/nics/features/dpaa.ini|  1 +
 drivers/bus/dpaa/base/fman/fman.c| 21 +++-
 drivers/bus/dpaa/base/fman/fman_hw.c |  6 ++-
 drivers/bus/dpaa/include/fman.h  | 18 ++-
 drivers/net/dpaa/dpaa_ethdev.c   |  2 +
 drivers/net/dpaa/dpaa_ethdev.h   | 17 +++
 drivers/net/dpaa/dpaa_ptp.c  | 42 
 drivers/net/dpaa/dpaa_rxtx.c | 71 
 drivers/net/dpaa/dpaa_rxtx.h |  4 +-
 drivers/net/dpaa/meson.build |  1 +
 10 files changed, 168 insertions(+), 15 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_ptp.c

diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index b136ed191a..4196dd800c 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -19,6 +19,7 @@ Flow control = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Timestamp offload= Y
 Basic stats  = Y
 Extended stats   = Y
 FW version   = Y
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index beeb03dbf2..e39bc8c252 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2010-2016 Freescale Semiconductor Inc.
- * Copyright 2017-2020 NXP
+ * Copyright 2017-2024 NXP
  *
  */
 
@@ -520,6 +520,25 @@ fman_if_init(const struct device_node *dpa_node)
goto err;
}
 
+   regs_addr = of_get_address(tx_node, 0, &__if->regs_size, NULL);
+   if (!regs_addr) {
+   FMAN_ERR(-EINVAL, "of_get_address(%s)\n", mname);
+   goto err;
+   }
+   phys_addr = of_translate_address(tx_node, regs_addr);
+   if (!phys_addr) {
+   FMAN_ERR(-EINVAL, "of_translate_address(%s, %p)\n",
+   mname, regs_addr);
+   goto err;
+   }
+   __if->tx_bmi_map = mmap(NULL, __if->regs_size,
+   PROT_READ | PROT_WRITE, MAP_SHARED,
+   fman_ccsr_map_fd, phys_addr);
+   if (__if->tx_bmi_map == MAP_FAILED) {
+   FMAN_ERR(-errno, "mmap(0x%"PRIx64")\n", phys_addr);
+   goto err;
+   }
+
/* No channel ID for MAC-less */
assert(lenp == sizeof(*tx_channel_id));
na = of_n_addr_cells(mac_node);
diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 124c69edb4..4fc41c1ae9 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright 2017,2020 NXP
+ * Copyright 2017,2020,2022 NXP
  *
  */
 
@@ -565,6 +565,10 @@ fman_if_set_ic_params(struct fman_if *fm_if,
&((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ricp;
out_be32(fmbm_ricp, val);
 
+   unsigned int *fmbm_ticp =
+   &((struct tx_bmi_regs *)__if->tx_bmi_map)->fmbm_ticp;
+   out_be32(fmbm_ticp, val);
+
return 0;
 }
 
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 6b2a1893f9..09d1ddb897 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -2,7 +2,7 @@
  *
  * Copyright 2010-2012 Freescale Semiconductor, Inc.
  * All rights reserved.
- * Copyright 2019-2021 NXP
+ * Copyright 2019-2022 NXP
  *
  */
 
@@ -292,6 +292,21 @@ struct rx_bmi_regs {
uint32_t fmbm_rdbg; /**< Rx Debug-*/
 };
 
+struct tx_bmi_regs {
+   uint32_t fmbm_tcfg; /**< Tx Configuration*/
+   uint32_t fmbm_tst;  /**< Tx Status*/
+   uint32_t fmbm_tda;  /**< Tx DMA attributes*/
+   uint32_t fmbm_tfp;  /**< Tx FIFO Parameters*/
+   uint32_t fmbm_tfed; /**< Tx Frame End Data*/
+   uint32_t fmbm_ticp; /**< Tx Internal Context Parameters*/
+   uint32_t fmbm_tfdne;/**< Tx Frame Dequeue Next Engine*/
+   uint32_t fmbm_tfca; /**< Tx Frame Attributes*/
+   uint32_t fmbm_tcfqid;   /**< Tx Confirmation Frame Queue ID*/
+   uint32_t fmbm_tefqid;   /**< Tx Error Frame Queue ID*/
+   uint32_t fmbm_tfene;/**< Tx Frame Enqueue Next Engine*/
+   uint32_t fmbm_trlmts;   /**< Tx Rate Limiter Scale*/
+   uint32_t fmbm_trlmt;/**< Tx Rate Limiter*/
+};
 struct fman_port_qmi_regs {
uint32_t fmqm_pnc;  /**< PortID n Configuration Register */
uint32_t fmqm_pns;  /**< PortID n Status Register */
@@ -380,6 +395,7 @@ struct __fman_if {
uint64_t regs_size;
void *ccsr_map;
void *bmi_map;
+   void *tx_bmi_map;
void *qmi_map;
stru

[PATCH v3 08/18] net/dpaa: share MAC FMC scheme and CC parse

2024-09-30 Thread Hemant Agrawal
From: Jun Yang 

For Shared MAC:
1) Allocate RXQ from VSP scheme. (Virtual Storage Profile)
2) Allocate RXQ from Coarse classifiation (CC) rules to VSP.
2) Remove RXQ allocated which is reconfigured without VSP.
3) Don't alloc default queue and err queues.

Signed-off-by: Jun Yang 
Acked-by: Hemant Agrawal 
---
 drivers/bus/dpaa/include/fman.h |   1 +
 drivers/net/dpaa/dpaa_ethdev.c  |  60 +++--
 drivers/net/dpaa/dpaa_ethdev.h  |  13 +-
 drivers/net/dpaa/dpaa_flow.c|   8 +-
 drivers/net/dpaa/dpaa_fmc.c | 421 
 drivers/net/dpaa/dpaa_rxtx.c|  20 +-
 6 files changed, 346 insertions(+), 177 deletions(-)

diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 60681068ea..6b2a1893f9 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -76,6 +76,7 @@ enum fman_mac_type {
fman_mac_1g,
fman_mac_10g,
fman_mac_2_5g,
+   fman_onic,
 };
 
 struct mac_addr {
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 3ee3029729..bf14d73433 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -255,7 +255,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
DPAA_PMD_ERR("Cannot open IF socket");
return -errno;
}
-
strncpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ - 1);
 
if (ioctl(socket_fd, SIOCGIFMTU, &ifr) < 0) {
@@ -1893,6 +1892,7 @@ dpaa_tx_conf_queue_init(struct qman_fq *fq)
return ret;
 }
 
+#if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
 /* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
 static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
@@ -1923,6 +1923,7 @@ static int dpaa_def_queue_init(struct qman_fq *fq, 
uint32_t fqid)
fqid, ret);
return ret;
 }
+#endif
 
 /* Initialise a network interface */
 static int
@@ -1957,6 +1958,41 @@ dpaa_dev_init_secondary(struct rte_eth_dev *eth_dev)
return 0;
 }
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+static int
+dpaa_error_queue_init(struct dpaa_if *dpaa_intf,
+   struct fman_if *fman_intf)
+{
+   int i, ret;
+   struct qman_fq *err_queues = dpaa_intf->debug_queues;
+   uint32_t err_fqid = 0;
+
+   if (fman_intf->is_shared_mac) {
+   DPAA_PMD_DEBUG("Shared MAC's err queues are handled in kernel");
+   return 0;
+   }
+
+   for (i = 0; i < DPAA_DEBUG_FQ_MAX_NUM; i++) {
+   if (i == DPAA_DEBUG_FQ_RX_ERROR)
+   err_fqid = fman_intf->fqid_rx_err;
+   else if (i == DPAA_DEBUG_FQ_TX_ERROR)
+   err_fqid = fman_intf->fqid_tx_err;
+   else
+   continue;
+   ret = dpaa_def_queue_init(&err_queues[i], err_fqid);
+   if (ret) {
+   DPAA_PMD_ERR("DPAA %s ERROR queue init failed!",
+   i == DPAA_DEBUG_FQ_RX_ERROR ?
+   "RX" : "TX");
+   return ret;
+   }
+   err_queues[i].dpaa_intf = dpaa_intf;
+   }
+
+   return 0;
+}
+#endif
+
 static int
 check_devargs_handler(__rte_unused const char *key, const char *value,
  __rte_unused void *opaque)
@@ -2202,25 +2238,11 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
}
}
dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
-
-#if !defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
-   if (dpaa_ieee_1588)
+#if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
+   ret = dpaa_error_queue_init(dpaa_intf, fman_intf);
+   if (ret)
+   goto free_tx;
 #endif
-   {
-   ret = dpaa_def_queue_init(&dpaa_intf->debug_queues
-   [DPAA_DEBUG_FQ_RX_ERROR], 
fman_intf->fqid_rx_err);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA RX ERROR queue init failed!");
-   goto free_tx;
-   }
-   dpaa_intf->debug_queues[DPAA_DEBUG_FQ_RX_ERROR].dpaa_intf = 
dpaa_intf;
-   ret = dpaa_def_queue_init(&dpaa_intf->debug_queues
-   [DPAA_DEBUG_FQ_TX_ERROR], 
fman_intf->fqid_tx_err);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA TX ERROR queue init failed!");
-   goto free_tx;
-   }
-   }
DPAA_PMD_DEBUG("All frame queues created");
 
/* Get the initial configuration for flow control */
diff --git a/drivers/net/dpaa/dpaa_ethdev.h b/drivers/net/dpaa/dpaa_ethdev.h
index b427b29cb6..0a1ceb376a 100644
--- a/drivers/net/dpaa/dpaa_ethdev.h
+++ b/drivers/net/dpaa/dpaa_ethdev.h
@@ -78,8 +78,11 @@
 #define DPAA_IF_RX_CONTEXT_STASH 

[PATCH v3 07/18] net/dpaa: add support to separate Tx conf queues

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch separates Tx confirmation queues for kernel
and DPDK so as to support the VSP case.

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
 drivers/bus/dpaa/include/fsl_qman.h |  4 ++-
 drivers/net/dpaa/dpaa_ethdev.c  | 45 +
 drivers/net/dpaa/dpaa_rxtx.c|  3 +-
 3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/drivers/bus/dpaa/include/fsl_qman.h 
b/drivers/bus/dpaa/include/fsl_qman.h
index c0677976e8..db14dfb839 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2008-2012 Freescale Semiconductor, Inc.
- * Copyright 2019 NXP
+ * Copyright 2019-2022 NXP
  *
  */
 
@@ -1237,6 +1237,8 @@ struct qman_fq {
 
/* DPDK Interface */
void *dpaa_intf;
+   /*to store tx_conf_queue corresponding to tx_queue*/
+   struct qman_fq *tx_conf_queue;
 
struct rte_event ev;
/* affined portal in case of static queue */
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index bba305cfb1..3ee3029729 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1870,9 +1870,30 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
return ret;
 }
 
-/* Initialise a DEBUG FQ ([rt]x_error, rx_default) and DPAA TX CONFIRM queue
- * to support PTP
- */
+static int
+dpaa_tx_conf_queue_init(struct qman_fq *fq)
+{
+   struct qm_mcc_initfq opts = {0};
+   int ret;
+
+   PMD_INIT_FUNC_TRACE();
+
+   ret = qman_create_fq(0, QMAN_FQ_FLAG_DYNAMIC_FQID, fq);
+   if (ret) {
+   DPAA_PMD_ERR("create Tx_conf failed with ret: %d", ret);
+   return ret;
+   }
+
+   opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL;
+   opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
+   ret = qman_init_fq(fq, 0, &opts);
+   if (ret)
+   DPAA_PMD_ERR("init Tx_conf fqid %d failed with ret: %d",
+   fq->fqid, ret);
+   return ret;
+}
+
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
 static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
struct qm_mcc_initfq opts = {0};
@@ -2170,6 +2191,15 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
if (ret)
goto free_tx;
dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf;
+
+   if (dpaa_ieee_1588) {
+   ret = 
dpaa_tx_conf_queue_init(&dpaa_intf->tx_conf_queues[loop]);
+   if (ret)
+   goto free_tx;
+
+   dpaa_intf->tx_conf_queues[loop].dpaa_intf = dpaa_intf;
+   dpaa_intf->tx_queues[loop].tx_conf_queue = 
&dpaa_intf->tx_conf_queues[loop];
+   }
}
dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
 
@@ -2190,16 +2220,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
DPAA_PMD_ERR("DPAA TX ERROR queue init failed!");
goto free_tx;
}
-   dpaa_intf->debug_queues[DPAA_DEBUG_FQ_TX_ERROR].dpaa_intf = 
dpaa_intf;
-   ret = dpaa_def_queue_init(dpaa_intf->tx_conf_queues,
-   fman_intf->fqid_tx_confirm);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA TX CONFIRM queue init failed!");
-   goto free_tx;
-   }
-   dpaa_intf->tx_conf_queues->dpaa_intf = dpaa_intf;
}
-
DPAA_PMD_DEBUG("All frame queues created");
 
/* Get the initial configuration for flow control */
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 8593e20200..3bd35c7a0e 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1083,8 +1083,7 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
struct dpaa_sw_buf_free buf_to_free[DPAA_MAX_SGS * 
DPAA_MAX_DEQUEUE_NUM_FRAMES];
uint32_t free_count = 0;
struct qman_fq *fq = q;
-   struct dpaa_if *dpaa_intf = fq->dpaa_intf;
-   struct qman_fq *fq_txconf = dpaa_intf->tx_conf_queues;
+   struct qman_fq *fq_txconf = fq->tx_conf_queue;
 
if (unlikely(!DPAA_PER_LCORE_PORTAL)) {
ret = rte_dpaa_portal_init((void *)0);
-- 
2.25.1



[PATCH v3 06/18] net/dpaa: support Tx confirmation to enable PTP

2024-09-30 Thread Hemant Agrawal
From: Vanshika Shukla 

TX confirmation provides dedicated confirmation
queues for transmitted packets. These queues are
used by software to get the status and release
transmitted packets buffers.

This patch also changes the IEEE1588 support as devargs

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
 doc/guides/nics/dpaa.rst   |   3 +
 drivers/net/dpaa/dpaa_ethdev.c | 124 ++---
 drivers/net/dpaa/dpaa_ethdev.h |   4 +-
 drivers/net/dpaa/dpaa_rxtx.c   |  49 +
 drivers/net/dpaa/dpaa_rxtx.h   |   2 +
 5 files changed, 154 insertions(+), 28 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index e8402dff52..acf4daab02 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -264,6 +264,9 @@ for details.
   Done
   testpmd>
 
+* Use dev arg option ``drv_ieee1588=1`` to enable ieee 1588 support at
+  driver level. e.g. ``dpaa:fm1-mac3,drv_ieee1588=1``
+
 FMAN Config
 ---
 
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 90b34e42f2..bba305cfb1 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017-2020 NXP
+ *   Copyright 2017-2020,2022-2024 NXP
  *
  */
 /* System headers */
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,6 +51,7 @@
 #include 
 #include 
 
+#define DRIVER_IEEE1588"drv_ieee1588"
 #define CHECK_INTERVAL 100  /* 100ms */
 #define MAX_REPEAT_TIME90   /* 9s (90 * 100ms) in total */
 
@@ -83,6 +85,7 @@ static uint64_t dev_tx_offloads_nodis =
 static int is_global_init;
 static int fmc_q = 1;  /* Indicates the use of static fmc for distribution */
 static int default_q;  /* use default queue - FMC is not executed*/
+int dpaa_ieee_1588;/* use to indicate if IEEE 1588 is enabled for the 
driver */
 /* At present we only allow up to 4 push mode queues as default - as each of
  * this queue need dedicated portal and we are short of portals.
  */
@@ -1826,9 +1829,15 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
opts.fqd.dest.wq = DPAA_IF_TX_PRIORITY;
opts.fqd.fq_ctrl = QM_FQCTRL_PREFERINCACHE;
opts.fqd.context_b = 0;
-   /* no tx-confirmation */
-   opts.fqd.context_a.hi = 0x8000 | fman_dealloc_bufs_mask_hi;
-   opts.fqd.context_a.lo = 0 | fman_dealloc_bufs_mask_lo;
+   if (dpaa_ieee_1588) {
+   opts.fqd.context_a.lo = 0;
+   opts.fqd.context_a.hi = fman_dealloc_bufs_mask_hi;
+   } else {
+   /* no tx-confirmation */
+   opts.fqd.context_a.lo = fman_dealloc_bufs_mask_lo;
+   opts.fqd.context_a.hi = 0x8000 | fman_dealloc_bufs_mask_hi;
+   }
+
if (fman_ip_rev >= FMAN_V3) {
/* Set B0V bit in contextA to set ASPID to 0 */
opts.fqd.context_a.hi |= 0x0400;
@@ -1861,9 +1870,10 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
return ret;
 }
 
-#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
-/* Initialise a DEBUG FQ ([rt]x_error, rx_default). */
-static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default) and DPAA TX CONFIRM queue
+ * to support PTP
+ */
+static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
struct qm_mcc_initfq opts = {0};
int ret;
@@ -1872,15 +1882,15 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, 
uint32_t fqid)
 
ret = qman_reserve_fqid(fqid);
if (ret) {
-   DPAA_PMD_ERR("Reserve debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("Reserve fqid %d failed with ret: %d",
fqid, ret);
return -EINVAL;
}
/* "map" this Rx FQ to one of the interfaces Tx FQID */
-   DPAA_PMD_DEBUG("Creating debug fq %p, fqid %d", fq, fqid);
+   DPAA_PMD_DEBUG("Creating fq %p, fqid %d", fq, fqid);
ret = qman_create_fq(fqid, QMAN_FQ_FLAG_NO_ENQUEUE, fq);
if (ret) {
-   DPAA_PMD_ERR("create debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("create fqid %d failed with ret: %d",
fqid, ret);
return ret;
}
@@ -1888,11 +1898,10 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, 
uint32_t fqid)
opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
ret = qman_init_fq(fq, 0, &opts);
if (ret)
-   DPAA_PMD_ERR("init debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("init fqid %d failed with ret: %d",
fqid, ret);
return ret;
 }
-#endif
 
 /* Initialise a network interfa

[PATCH v3 05/18] bus/dpaa: add port buffer manager stats

2024-09-30 Thread Hemant Agrawal
Add BMI statistics and improving the existing extended
statistics

Signed-off-by: Hemant Agrawal 
Signed-off-by: Gagandeep Singh 
---
 drivers/bus/dpaa/base/fman/fman_hw.c | 61 
 drivers/bus/dpaa/include/fman.h  |  4 +-
 drivers/bus/dpaa/include/fsl_fman.h  | 12 ++
 drivers/bus/dpaa/version.map |  4 ++
 drivers/net/dpaa/dpaa_ethdev.c   | 46 ++---
 drivers/net/dpaa/dpaa_ethdev.h   | 12 ++
 6 files changed, 132 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 97e792806f..124c69edb4 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -267,6 +267,67 @@ fman_if_stats_reset(struct fman_if *p)
;
 }
 
+void
+fman_if_bmi_stats_enable(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   uint32_t tmp;
+
+   tmp = in_be32(®s->fmbm_rstc);
+
+   tmp |= FMAN_BMI_COUNTERS_EN;
+
+   out_be32(®s->fmbm_rstc, tmp);
+}
+
+void
+fman_if_bmi_stats_disable(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   uint32_t tmp;
+
+   tmp = in_be32(®s->fmbm_rstc);
+
+   tmp &= ~FMAN_BMI_COUNTERS_EN;
+
+   out_be32(®s->fmbm_rstc, tmp);
+}
+
+void
+fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   int i = 0;
+
+   value[i++] = (u32)in_be32(®s->fmbm_rfrc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfbc);
+   value[i++] = (u32)in_be32(®s->fmbm_rlfc);
+   value[i++] = (u32)in_be32(®s->fmbm_rffc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfdc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfldec);
+   value[i++] = (u32)in_be32(®s->fmbm_rodc);
+   value[i++] = (u32)in_be32(®s->fmbm_rbdc);
+}
+
+void
+fman_if_bmi_stats_reset(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+
+   out_be32(®s->fmbm_rfrc, 0);
+   out_be32(®s->fmbm_rfbc, 0);
+   out_be32(®s->fmbm_rlfc, 0);
+   out_be32(®s->fmbm_rffc, 0);
+   out_be32(®s->fmbm_rfdc, 0);
+   out_be32(®s->fmbm_rfldec, 0);
+   out_be32(®s->fmbm_rodc, 0);
+   out_be32(®s->fmbm_rbdc, 0);
+}
+
 void
 fman_if_promiscuous_enable(struct fman_if *p)
 {
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 3a6dd555a7..60681068ea 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -56,6 +56,8 @@
 #define FMAN_PORT_BMI_FIFO_UNITS   0x100
 #define FMAN_PORT_IC_OFFSET_UNITS  0x10
 
+#define FMAN_BMI_COUNTERS_EN 0x8000
+
 #define FMAN_ENABLE_BPOOL_DEPLETION0xF0F0
 
 #define HASH_CTRL_MCAST_EN 0x0100
@@ -260,7 +262,7 @@ struct rx_bmi_regs {
/**< Buffer Manager pool Information-*/
uint32_t fmbm_acnt[FMAN_PORT_MAX_EXT_POOLS_NUM];
/**< Allocate Counter-*/
-   uint32_t reserved0130[8];
+   uint32_t reserved0120[16];
/**< 0x130/0x140 - 0x15F reserved -*/
uint32_t fmbm_rcgm[FMAN_PORT_CG_MAP_NUM];
/**< Congestion Group Map*/
diff --git a/drivers/bus/dpaa/include/fsl_fman.h 
b/drivers/bus/dpaa/include/fsl_fman.h
index 20690f8329..5a9750ad0c 100644
--- a/drivers/bus/dpaa/include/fsl_fman.h
+++ b/drivers/bus/dpaa/include/fsl_fman.h
@@ -60,6 +60,18 @@ void fman_if_stats_reset(struct fman_if *p);
 __rte_internal
 void fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n);
 
+__rte_internal
+void fman_if_bmi_stats_enable(struct fman_if *p);
+
+__rte_internal
+void fman_if_bmi_stats_disable(struct fman_if *p);
+
+__rte_internal
+void fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value);
+
+__rte_internal
+void fman_if_bmi_stats_reset(struct fman_if *p);
+
 /* Set ignore pause option for a specific interface */
 void fman_if_set_rx_ignore_pause_frames(struct fman_if *p, bool enable);
 
diff --git a/drivers/bus/dpaa/version.map b/drivers/bus/dpaa/version.map
index 3f547f75cf..a17d57632e 100644
--- a/drivers/bus/dpaa/version.map
+++ b/drivers/bus/dpaa/version.map
@@ -24,6 +24,10 @@ INTERNAL {
fman_dealloc_bufs_mask_hi;
fman_dealloc_bufs_mask_lo;
fman_if_add_mac_addr;
+   fman_if_bmi_stats_enable;
+   fman_if_bmi_stats_disable;
+   fman_if_bmi_stats_get_all;
+   fman_if_bmi_stats_reset;
fman_if_clear_mac_addr;

[PATCH v3 04/18] bus/dpaa: fix the fman details status

2024-09-30 Thread Hemant Agrawal
Fix the incorrect placing of brackets to calculate stats.

This corrects the "(a | b) << 32"  to  "a | (b << 32)"

Fixes: e62a3f4183f1 ("bus/dpaa: fix statistics reading")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman_hw.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 24a99f7235..97e792806f 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -243,10 +243,11 @@ fman_if_stats_get_all(struct fman_if *p, uint64_t *value, 
int n)
int i;
uint64_t base_offset = offsetof(struct memac_regs, reoct_l);
 
-   for (i = 0; i < n; i++)
-   value[i] = (((u64)in_be32((char *)regs + base_offset + 8 * i) |
-   (u64)in_be32((char *)regs + base_offset +
-   8 * i + 4)) << 32);
+   for (i = 0; i < n; i++) {
+   uint64_t a = in_be32((char *)regs + base_offset + 8 * i);
+   uint64_t b = in_be32((char *)regs + base_offset + 8 * i + 4);
+   value[i] = a | b << 32;
+   }
 }
 
 void
-- 
2.25.1



[PATCH v3 03/18] bus/dpaa: fix VSP for 1G fm1-mac9 and 10

2024-09-30 Thread Hemant Agrawal
No need to classify interface separately for 1G and 10G
Note that VSP or Virtual storage profile are DPAA equivalent for SRIOV
config to logically divide a physical ports in virtual ports.

Fixes: e0718bb2ca95 ("bus/dpaa: add virtual storage profile port init")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index 41195eb0a7..beeb03dbf2 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -153,7 +153,7 @@ static void fman_if_vsp_init(struct __fman_if *__if)
size_t lenp;
const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
-   if (__if->__if.mac_type == fman_mac_1g) {
+   if (__if->__if.mac_idx <= 8) {
for_each_compatible_node(dev, NULL,
"fsl,fman-port-1g-rx-extended-args") {
prop = of_get_property(dev, "cell-index", &lenp);
@@ -176,7 +176,32 @@ static void fman_if_vsp_init(struct __fman_if *__if)
}
}
}
-   } else if (__if->__if.mac_type == fman_mac_10g) {
+
+   for_each_compatible_node(dev, NULL,
+"fsl,fman-port-op-extended-args") {
+   prop = of_get_property(dev, "cell-index", &lenp);
+
+   if (prop) {
+   cell_index = of_read_number(&prop[0],
+   lenp / sizeof(phandle));
+
+   if (cell_index == __if->__if.mac_idx) {
+   prop = of_get_property(dev,
+  "vsp-window",
+  &lenp);
+
+   if (prop) {
+   __if->__if.num_profiles =
+   of_read_number(&prop[0],
+  1);
+   __if->__if.base_profile_id =
+   of_read_number(&prop[1],
+  1);
+   }
+   }
+   }
+   }
+   } else {
for_each_compatible_node(dev, NULL,
"fsl,fman-port-10g-rx-extended-args") {
prop = of_get_property(dev, "cell-index", &lenp);
-- 
2.25.1



[PATCH v3 02/18] net/dpaa: fix typecasting ch ID to u32

2024-09-30 Thread Hemant Agrawal
From: Rohit Raj 

Avoid typecasting ch_id to u32 and passing it to another API since it
can corrupt other data. Instead, create new u32 variable and typecase
it back to u16 after it gets updated by the API.

Fixes: 0c504f6950b6 ("net/dpaa: support push mode")
Cc: hemant.agra...@nxp.com
Cc: sta...@dpdk.org

Signed-off-by: Rohit Raj 
---
 drivers/net/dpaa/dpaa_ethdev.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 060b8c678f..1a2de5240f 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -972,7 +972,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
struct fman_if *fif = dev->process_private;
struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_idx];
struct qm_mcc_initfq opts = {0};
-   u32 flags = 0;
+   u32 ch_id, flags = 0;
int ret;
u32 buffsz = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
uint32_t max_rx_pktlen;
@@ -1096,7 +1096,9 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
DPAA_IF_RX_CONTEXT_STASH;
 
/*Create a channel and associate given queue with the channel*/
-   qman_alloc_pool_range((u32 *)&rxq->ch_id, 1, 1, 0);
+   qman_alloc_pool_range(&ch_id, 1, 1, 0);
+   rxq->ch_id = (u16)ch_id;
+
opts.we_mask = opts.we_mask | QM_INITFQ_WE_DESTWQ;
opts.fqd.dest.channel = rxq->ch_id;
opts.fqd.dest.wq = DPAA_IF_RX_PRIORITY;
-- 
2.25.1



[PATCH v3 01/18] bus/dpaa: fix PFDRs leaks due to FQRNIs

2024-09-30 Thread Hemant Agrawal
From: Gagandeep Singh 

When a Retire FQ command is executed on a FQ in the
Tentatively Scheduled or Parked states, in that case FQ
is retired immediately and a FQRNI (Frame Queue Retirement
Notification Immediate) message is generated. Software
must read this message from MR and consume it to free
the memory used by it.

Although it is not mentioned about which memory to be used
by FQRNIs in the RM but through experiments it is proven
that it can use PFDRs. So if these messages are allowed to
build up indefinitely then PFDR resources can become exhausted
and cause enqueues to stall. Therefore software must consume
these MR messages on a regular basis to avoid depleting
the available PFDR resources.

This is the PFDRs leak issue which user can experienace while
using the DPDK crypto driver and creating and destroying the
sessions multiple times. On a session destroy, DPDK calls the
qman_retire_fq() for each FQ used by the session, but it does
not handle the FQRNIs generated and allowed them to build up
indefinitely in MR.

This patch fixes this issue by consuming the FQRNIs received
from MR immediately after FQ retire by calling drain_mr_fqrni().

Please note that this drain_mr_fqrni() only look for
FQRNI type messages to consume. If there are other type of messages
like FQRN, FQRL, FQPN, ERN etc. also coming on MR then those
messages need to be handled separately.

Fixes: c47ff048b99a ("bus/dpaa: add QMAN driver core routines")
Cc: sta...@dpdk.org

Signed-off-by: Gagandeep Singh 
---
 drivers/bus/dpaa/base/qbman/qman.c | 46 --
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman.c 
b/drivers/bus/dpaa/base/qbman/qman.c
index 301057723e..9c90ee25a6 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -292,10 +292,32 @@ static inline void qman_stop_dequeues_ex(struct 
qman_portal *p)
qm_dqrr_set_maxfill(&p->p, 0);
 }
 
+static inline void qm_mr_pvb_update(struct qm_portal *portal)
+{
+   register struct qm_mr *mr = &portal->mr;
+   const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
+
+#ifdef RTE_LIBRTE_DPAA_HWDEBUG
+   DPAA_ASSERT(mr->pmode == qm_mr_pvb);
+#endif
+   /* when accessing 'verb', use __raw_readb() to ensure that compiler
+* inlining doesn't try to optimise out "excess reads".
+*/
+   if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
+   mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
+   if (!mr->pi)
+   mr->vbit ^= QM_MR_VERB_VBIT;
+   mr->fill++;
+   res = MR_INC(res);
+   }
+   dcbit_ro(res);
+}
+
 static int drain_mr_fqrni(struct qm_portal *p)
 {
const struct qm_mr_entry *msg;
 loop:
+   qm_mr_pvb_update(p);
msg = qm_mr_current(p);
if (!msg) {
/*
@@ -317,6 +339,7 @@ static int drain_mr_fqrni(struct qm_portal *p)
do {
now = mfatb();
} while ((then + 1) > now);
+   qm_mr_pvb_update(p);
msg = qm_mr_current(p);
if (!msg)
return 0;
@@ -479,27 +502,6 @@ static inline int qm_mr_init(struct qm_portal *portal,
return 0;
 }
 
-static inline void qm_mr_pvb_update(struct qm_portal *portal)
-{
-   register struct qm_mr *mr = &portal->mr;
-   const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
-
-#ifdef RTE_LIBRTE_DPAA_HWDEBUG
-   DPAA_ASSERT(mr->pmode == qm_mr_pvb);
-#endif
-   /* when accessing 'verb', use __raw_readb() to ensure that compiler
-* inlining doesn't try to optimise out "excess reads".
-*/
-   if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
-   mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
-   if (!mr->pi)
-   mr->vbit ^= QM_MR_VERB_VBIT;
-   mr->fill++;
-   res = MR_INC(res);
-   }
-   dcbit_ro(res);
-}
-
 struct qman_portal *
 qman_init_portal(struct qman_portal *portal,
   const struct qm_portal_config *c,
@@ -1794,6 +1796,8 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
}
 out:
FQUNLOCK(fq);
+   /* Draining FQRNIs, if any */
+   drain_mr_fqrni(&p->p);
return rval;
 }
 
-- 
2.25.1



[PATCH v3 00/18] NXP DPAA ETH driver enhancement and fixes

2024-09-30 Thread Hemant Agrawal
v3: addressed Ferruh's comments 
 - dropped Tx rate limit API patch
 - added one small bug fix
 - fixed removal/add of fman_offline type

v2: address review comments
 - improve commit message
 - add documentarion for new functions
 - make IEEE1588 config runtime

This series adds several enhancement to the NXP DPAA Ethernet driver.

Primarily:
1. timestamp and IEEE 1588 support
2. OH and ONIC based virtual port config in DPAA
3. frame display and debugging infra

Gagandeep Singh (3):
  bus/dpaa: fix PFDRs leaks due to FQRNIs
  net/dpaa: support mempool debug
  net/dpaa: improve the dpaa port cleanup

Hemant Agrawal (5):
  bus/dpaa: fix VSP for 1G fm1-mac9 and 10
  bus/dpaa: fix the fman details status
  bus/dpaa: add port buffer manager stats
  net/dpaa: implement detailed packet parsing
  net/dpaa: enhance DPAA frame display

Jun Yang (2):
  net/dpaa: share MAC FMC scheme and CC parse
  net/dpaa: improve dpaa errata A010022 handling

Rohit Raj (3):
  net/dpaa: fix typecasting ch ID to u32
  bus/dpaa: add OH port mode for dpaa eth
  bus/dpaa: add ONIC port mode for the DPAA eth

Vanshika Shukla (5):
  net/dpaa: support Tx confirmation to enable PTP
  net/dpaa: add support to separate Tx conf queues
  net/dpaa: support Rx/Tx timestamp read
  net/dpaa: support IEEE 1588 PTP
  net/dpaa: fix reallocate_mbuf handling

 doc/guides/nics/dpaa.rst  |  64 ++-
 doc/guides/nics/features/dpaa.ini |   2 +
 drivers/bus/dpaa/base/fman/fman.c | 583 +++---
 drivers/bus/dpaa/base/fman/fman_hw.c  | 102 +++-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  19 +-
 drivers/bus/dpaa/base/qbman/qman.c|  46 +-
 drivers/bus/dpaa/dpaa_bus.c   |  37 +-
 drivers/bus/dpaa/include/fman.h   | 112 -
 drivers/bus/dpaa/include/fsl_fman.h   |  12 +
 drivers/bus/dpaa/include/fsl_qman.h   |   4 +-
 drivers/bus/dpaa/version.map  |   4 +
 drivers/net/dpaa/dpaa_ethdev.c| 428 +---
 drivers/net/dpaa/dpaa_ethdev.h|  68 ++-
 drivers/net/dpaa/dpaa_flow.c  |  82 +--
 drivers/net/dpaa/dpaa_fmc.c   | 421 ++--
 drivers/net/dpaa/dpaa_ptp.c   | 118 +
 drivers/net/dpaa/dpaa_rxtx.c  | 378 --
 drivers/net/dpaa/dpaa_rxtx.h  | 152 +++---
 drivers/net/dpaa/meson.build  |   1 +
 19 files changed, 2121 insertions(+), 512 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_ptp.c

-- 
2.25.1



Re: [PATCH v3 15/18] baseband/la12xx: prevent use after free

2024-09-30 Thread Hemant Agrawal



On 29-09-2024 21:04, Stephen Hemminger wrote:

It is possible that the info pointer (hp) could get freed twice.
Fix by nulling after free.

In function 'setup_la12xx_dev',
inlined from 'la12xx_bbdev_create' at 
../drivers/baseband/la12xx/bbdev_la12xx.c:1029:8,
inlined from 'la12xx_bbdev_probe' at 
../drivers/baseband/la12xx/bbdev_la12xx.c:1075:9:
../drivers/baseband/la12xx/bbdev_la12xx.c:901:9: error: pointer 'hp_info' may 
be used after 'rte_free' [-Werror=use-after-free]
901 | rte_free(hp);
| ^~~~
../drivers/baseband/la12xx/bbdev_la12xx.c:791:17: note: call to 'rte_free' here
791 | rte_free(hp);
| ^~~~

Fixes: 24d0ba22546e ("baseband/la12xx: add queue and modem config")
Cc: hemant.agra...@nxp.com
Cc: sta...@dpdk.org
Signed-off-by: Stephen Hemminger 
---
  drivers/baseband/la12xx/bbdev_la12xx.c | 1 +
  1 file changed, 1 insertion(+)

diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c 
b/drivers/baseband/la12xx/bbdev_la12xx.c
index 1a56e73abd..cad6f9490e 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -789,6 +789,7 @@ setup_la12xx_dev(struct rte_bbdev *dev)
ipc_priv->hugepg_start.size = hp->len;
  
  		rte_free(hp);

+   hp = NULL;
    }
  
  	dev_ipc = open_ipc_dev(priv->modem_id);

Reviewed-by:  Hemant Agrawal 


RE: [PATCH v2 14/18] net/dpaa: add Tx rate limiting DPAA PMD API

2024-09-21 Thread Hemant Agrawal
HI Ferruh,

> -Original Message-
> From: Ferruh Yigit 
> Sent: Sunday, September 22, 2024 8:44 AM
> To: Hemant Agrawal ; dev@dpdk.org
> Cc: ferruh.yi...@intel.com; Vinod Pullabhatla ;
> Rohit Raj 
> Subject: Re: [PATCH v2 14/18] net/dpaa: add Tx rate limiting DPAA PMD API
> Importance: High
> 
> On 8/23/2024 8:32 AM, Hemant Agrawal wrote:
> > diff --git a/drivers/net/dpaa/version.map
> > b/drivers/net/dpaa/version.map index 3fdb63caf3..24a28ce649 100644
> > --- a/drivers/net/dpaa/version.map
> > +++ b/drivers/net/dpaa/version.map
> > @@ -6,6 +6,13 @@ DPDK_25 {
> > local: *;
> >  };
> >
> > +EXPERIMENTAL {
> > +   global:
> > +
> > +   # added in 24.11
> > +   rte_pmd_dpaa_port_set_rate_limit;
> > +};
> > +
> >  INTERNAL {
> > global:
> >
> 
> PMD specific API needs to be justified, can't we use TM framework for this,
> does TM needs to be improved for this support?
> 
> What do you think to send the rest of the set without this patch, so they can
> progress, and this one can be discussed separately (assuming there is no
> dependency).

[Hemant] I think, I replied to your earlier concerns. 

We are yet to implement TM framework for DPAA1.  But that involves more of 
egress QoS.

This one is additional capability to limit the ingress port. Kind of policing 
in Rx side.

However, if you still disagree. Please apply the series without this patch.


RE: [PATCH v2 00/18] NXP DPAA ETH driver enhancement and fixes

2024-09-21 Thread Hemant Agrawal
Series
Acked-by: Hemant Agrawal 

> -Original Message-
> From: Ferruh Yigit 
> Sent: Sunday, September 22, 2024 8:43 AM
> To: Hemant Agrawal ; dev@dpdk.org
> Cc: ferruh.yi...@intel.com
> Subject: Re: [PATCH v2 00/18] NXP DPAA ETH driver enhancement and fixes
> 
> On 8/23/2024 8:32 AM, Hemant Agrawal wrote:
> > v2: address review comments
> >  - improve commit message
> >  - add documentarion for new functions
> >  - make IEEE1588 config runtime
> >
> > This series adds several enhancement to the NXP DPAA Ethernet driver.
> >
> > Primarily:
> > 1. timestamp and IEEE 1588 support
> > 2. OH and ONIC based virtual port config in DPAA 3. frame display and
> > debugging infra
> >
> > Gagandeep Singh (3):
> >   bus/dpaa: fix PFDRs leaks due to FQRNIs
> >   net/dpaa: support mempool debug
> >   net/dpaa: improve the dpaa port cleanup
> >
> > Hemant Agrawal (5):
> >   bus/dpaa: fix VSP for 1G fm1-mac9 and 10
> >   bus/dpaa: fix the fman details status
> >   bus/dpaa: add port buffer manager stats
> >   net/dpaa: implement detailed packet parsing
> >   net/dpaa: enhance DPAA frame display
> >
> > Jun Yang (2):
> >   net/dpaa: share MAC FMC scheme and CC parse
> >   net/dpaa: improve dpaa errata A010022 handling
> >
> > Rohit Raj (3):
> >   net/dpaa: fix typecasting ch ID to u32
> >   bus/dpaa: add OH port mode for dpaa eth
> >   bus/dpaa: add ONIC port mode for the DPAA eth
> >
> > Vanshika Shukla (4):
> >   net/dpaa: support Tx confirmation to enable PTP
> >   net/dpaa: add support to separate Tx conf queues
> >   net/dpaa: support Rx/Tx timestamp read
> >   net/dpaa: support IEEE 1588 PTP
> >
> > Vinod Pullabhatla (1):
> >   net/dpaa: add Tx rate limiting DPAA PMD API
> >
> 
> Hi Hemant,
> 
> Can you please ack/review series to proceed?



Re: [PATCH v3 0/2] bbdev: dump debug information

2024-09-19 Thread Hemant Agrawal

Hi Nicolas,

    I have ack your patches.

 One suggestion, if you can use "--in-reply-to=" in you patch series, 
it will be helpful. This will link your new series with old series.



Regards

Hemant



On 14-09-2024 04:48, Nicolas Chautru wrote:

v3: updated based on Maxime comments related to passing string
through function prototype. Thanks

v2: updated with comments from Hemant and rebased.

v1: Hi Maxime.

Adding new support to support troubleshooting. This provides
to the application an API to dump into file information
to help troubleshoot issue on a queue. Some of it is tracked
at bbdev level and some extra information can be tracked
as an option at PMD level. This is for 24.11.
In practive logging is not enabled at run time, but information
can be dump into file when an issue happens and requires extra
information. This collates now multiple source of errors detected
notably at driver level made more explicit.

Thanks,
Nic

Nicolas Chautru (2):
   bbdev: add new function to dump debug information
   baseband/acc: improvement to logging mechanism

  drivers/baseband/acc/acc_common.h  |  38 +
  drivers/baseband/acc/rte_vrb_pmd.c | 129 +
  lib/bbdev/rte_bbdev.c  | 213 +
  lib/bbdev/rte_bbdev.h  |  47 +++
  lib/bbdev/rte_bbdev_pmd.h  |   9 ++
  lib/bbdev/version.map  |   4 +
  6 files changed, 413 insertions(+), 27 deletions(-)



Re: [PATCH v3 2/2] baseband/acc: improvement to logging mechanism

2024-09-19 Thread Hemant Agrawal

Acked-by: Hemant Agrawal 




Re: [PATCH v3 1/2] bbdev: add new function to dump debug information

2024-09-19 Thread Hemant Agrawal

Acked-by: Hemant Agrawal 




Re: [PATCH v3 1/1] bbdev: removing unnecessary symbols from version map

2024-09-17 Thread Hemant Agrawal

Acked-by: Hemant Agrawal 




Re: [PATCH v2 1/1] drivers/baseband: device queues initialization

2024-08-25 Thread Hemant Agrawal



On 23-08-2024 20:26, Hernan Vargas wrote:

Cosmetic change to keep code consistency in PMD for queue
initialization set to zero.
No functional impact.

Signed-off-by: Hernan Vargas 
---
  drivers/baseband/acc/rte_acc100_pmd.c  | 1 +
  drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c | 2 ++
  drivers/baseband/fpga_lte_fec/fpga_lte_fec.c   | 2 ++
  drivers/baseband/la12xx/bbdev_la12xx.c | 2 ++
  4 files changed, 7 insertions(+)

diff --git a/drivers/baseband/acc/rte_acc100_pmd.c 
b/drivers/baseband/acc/rte_acc100_pmd.c
index ab69350080f0..9b12fa7048c2 100644
--- a/drivers/baseband/acc/rte_acc100_pmd.c
+++ b/drivers/baseband/acc/rte_acc100_pmd.c
@@ -1030,6 +1030,7 @@ acc100_dev_info_get(struct rte_bbdev *dev,
dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = 
d->acc_conf.q_dl_5g.num_aqs_per_groups *
d->acc_conf.q_dl_5g.num_qgroups;
dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
+   dev_info->num_queues[RTE_BBDEV_OP_MLDTS] = 0;
dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 
d->acc_conf.q_ul_4g.num_qgroups;
dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 
d->acc_conf.q_dl_4g.num_qgroups;
dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = 
d->acc_conf.q_ul_5g.num_qgroups;
diff --git a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c 
b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
index 9b253cde280d..dad16ad422b5 100644
--- a/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
+++ b/drivers/baseband/fpga_5gnr_fec/rte_fpga_5gnr_fec.c
@@ -625,6 +625,8 @@ fpga_5gnr_dev_info_get(struct rte_bbdev *dev, struct 
rte_bbdev_driver_info *dev_
dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0;
dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = dev_info->max_num_queues 
/ 2;
dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = dev_info->max_num_queues 
/ 2;
+   dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
+   dev_info->num_queues[RTE_BBDEV_OP_MLDTS] = 0;
dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = 1;
dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = 1;
  }
diff --git a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c 
b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
index a4a963f74dbf..c6a3c3805a04 100644
--- a/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
+++ b/drivers/baseband/fpga_lte_fec/fpga_lte_fec.c
@@ -659,6 +659,8 @@ fpga_dev_info_get(struct rte_bbdev *dev,
dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = dev_info->max_num_queues 
/ 2;
dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = 0;
dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = 0;
+   dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
+   dev_info->num_queues[RTE_BBDEV_OP_MLDTS] = 0;
dev_info->queue_priority[RTE_BBDEV_OP_TURBO_DEC] = 1;
dev_info->queue_priority[RTE_BBDEV_OP_TURBO_ENC] = 1;
  }
diff --git a/drivers/baseband/la12xx/bbdev_la12xx.c 
b/drivers/baseband/la12xx/bbdev_la12xx.c
index 1a56e73abdab..c13eabbf4b6e 100644
--- a/drivers/baseband/la12xx/bbdev_la12xx.c
+++ b/drivers/baseband/la12xx/bbdev_la12xx.c
@@ -108,6 +108,8 @@ la12xx_info_get(struct rte_bbdev *dev __rte_unused,
dev_info->num_queues[RTE_BBDEV_OP_TURBO_ENC] = 0;
dev_info->num_queues[RTE_BBDEV_OP_LDPC_DEC] = LA12XX_MAX_QUEUES / 2;
dev_info->num_queues[RTE_BBDEV_OP_LDPC_ENC] = LA12XX_MAX_QUEUES / 2;
+   dev_info->num_queues[RTE_BBDEV_OP_FFT] = 0;
+   dev_info->num_queues[RTE_BBDEV_OP_MLDTS] = 0;
dev_info->queue_priority[RTE_BBDEV_OP_LDPC_DEC] = 1;
dev_info->queue_priority[RTE_BBDEV_OP_LDPC_ENC] = 1;
rte_bbdev_log_debug("got device info from %u", dev->data->dev_id);

Acked-by: Hemant Agrawal 


Re: [PATCH 11/17] net/dpaa: enhance DPAA frame display

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:09, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

This patch enhances the received packet debugging capability.
This help displaying the full packet parsing output.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
  doc/guides/nics/dpaa.rst   |   5 ++
  drivers/net/dpaa/dpaa_ethdev.c |   6 ++
  drivers/net/dpaa/dpaa_rxtx.c   | 138 +++--
  drivers/net/dpaa/dpaa_rxtx.h   |   5 ++
  4 files changed, 130 insertions(+), 24 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index 580edd9327..448607e9ac 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -227,6 +227,11 @@ state during application initialization:
application want to use eventdev with DPAA device.
Currently these queues are not used for LS1023/LS1043 platform by default.
  
+- ``DPAA_DISPLAY_FRAME_AND_PARSER_RESULT`` (default 0)

+
+  This defines the debug flag, whether to dump the detailed frame and packet
+  parsing result for the incoming packets.
+


If this is for debug, why not implement it as devarg.

Environment variables are supported by a few drivers, and as DPDK
drivers are userspace applications we can benefit from them, true.

But that is yet another way for configuration, I am feeling it is more
suitable way of configuration for applications. For drivers we already
have a devarg way, sticking to same configuration way provides more
consistency for users.


For the debugging flags, devargs don't work well, at least for us. 
Customers are using EAL argument embedded in their application code. 
Changing devargs means they recompile their code.


In the production, the env variables are working better for us. They 
just need to set it and they can re-use the existing production builds 
to collect more logs.



  
  Driver compilation and testing

  --
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index e92f1c25b2..979220a700 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -2094,6 +2094,12 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
td_tx_threshold = CGR_RX_PERFQ_THRESH;
}
  
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER

+   penv = getenv("DPAA_DISPLAY_FRAME_AND_PARSER_RESULT");
+   if (penv)
+   dpaa_force_display_frame_set(atoi(penv));
+#endif


'penv' is not defined and build fails when macro enabled.


fixed



It seems even yourself not testing with the macro, this is why using
compile time macros is bad for long term, it is hard to detect when they
are broken.

Can't you convert this macro to some runtime configuration, that is
enabled/disable via devargs, so easier to test, ensuring it is not broken.
Or other option can be to switch ETHDEV debug macro, which is used more,
by multiple cases, so more likely to be tested better.

run time checks are effecting datapath.  We usually ask customers to 
re-compile only the net_dpaa libarry and replace it in their test for 
debugging purpose.




<...>


Re: [PATCH 09/17] net/dpaa: support IEEE 1588 PTP

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:09, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

From: Vanshika Shukla 

This patch adds the support for the ethdev APIs
to enable/disable and read/write/adjust IEEE1588
PTP timestamps for DPAA platform.

Signed-off-by: Vanshika Shukla 
---
  doc/guides/nics/dpaa.rst  |  1 +
  drivers/bus/dpaa/base/fman/fman.c | 15 ++
  drivers/bus/dpaa/include/fman.h   | 45 +
  drivers/net/dpaa/dpaa_ethdev.c|  5 ++
  drivers/net/dpaa/dpaa_ethdev.h| 16 +++
  drivers/net/dpaa/dpaa_ptp.c   | 80 ++-
  6 files changed, 160 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index e8402dff52..580edd9327 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -148,6 +148,7 @@ Features
- Packet type information
- Checksum offload
- Promiscuous mode
+  - IEEE1588 PTP


When PTP is enabled, please update the .ini file to advertise the feature.

ok, fixed it in relevant patch.


Re: [PATCH 17/17] net/dpaa: improve dpaa errata A010022 handling

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:11, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

From: Jun Yang 

This patch improves the errata handling for
"RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022"

Signed-off-by: Jun Yang 
---
  drivers/net/dpaa/dpaa_rxtx.c | 40 
  1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 84fd0c57a4..325785480a 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1264,6 +1264,35 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
return new_mbufs[0];
  }
  
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022

+/* In case the data offset is not multiple of 16,
+ * FMAN can stall because of an errata. So reallocate
+ * the buffer in such case.
+ */
+static inline int
+dpaa_eth_ls1043a_mbuf_realloc(struct rte_mbuf *mbuf)
+{
+   uint64_t len, offset;
+
+   if (dpaa_svr_family != SVR_LS1043A_FAMILY)
+   return 0;
+
+   while (mbuf) {
+   len = mbuf->data_len;
+   offset = mbuf->data_off;
+   if ((mbuf->next &&
+   !rte_is_aligned((void *)len, 16)) ||
+   !rte_is_aligned((void *)offset, 16)) {
+   DPAA_PMD_DEBUG("Errata condition hit");
+
+   return 1;
+   }
+   mbuf = mbuf->next;
+   }
+   return 0;
+}
+#endif
+
  uint16_t
  dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
  {
@@ -1304,20 +1333,15 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_BURST_SIZE : nb_bufs;
for (loop = 0; loop < frames_to_send; loop++) {
mbuf = *(bufs++);
-   /* In case the data offset is not multiple of 16,
-* FMAN can stall because of an errata. So reallocate
-* the buffer in such case.
-*/
-   if (dpaa_svr_family == SVR_LS1043A_FAMILY &&
-   (mbuf->data_off & 0x7F) != 0x0)
-   realloc_mbuf = 1;
-


Previous approach seems better, detect when need to apply this errata,
and apply automatically.

Now there is a macro controlling it, how a user will know this errata is
required and how to enable it. And this prevent same binary distributed
multiple environments combination of errata required and not required.

Why not stick to the old method?


Currently only the LS1043 platform is effected by this errata. Other 
DPAA paltforms are not impacted.


So, only LS1043 customers, if they are using impacted scenario need to 
enable it. Other DPAA SoC customers will not be impacted


by these additional checks in datapath.





fd_arr[loop].cmd = 0;
  #if defined(RTE_LIBRTE_IEEE1588)
fd_arr[loop].cmd |= DPAA_FD_CMD_FCO |
qman_fq_fqid(fq_txconf);
fd_arr[loop].cmd |= DPAA_FD_CMD_RPD |
DPAA_FD_CMD_UPD;
+#endif
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+   realloc_mbuf = dpaa_eth_ls1043a_mbuf_realloc(mbuf);
  #endif
seqn = *dpaa_seqn(mbuf);
if (seqn != DPAA_INVALID_MBUF_SEQN) {


Re: [PATCH 14/17] bus/dpaa: add OH port mode for dpaa eth

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:10, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

From: Rohit Raj 

NXP DPAA architecture supports the concept of DPAA
port as Offline Port - meaning - not connected to an actual MAC.
This is an virtual port to be used by application for exchanging data.


Is this for application sending some control messages to the device via
port?
Or is this a way for multiple application communicating with each other
with the help of this port?


This is a  kind of hardware assisted IPC for exchanging data between the 
two applications or processing domains.


We have added more comments and documentation for it.


This property is completely driven by the device-tree. During the
DPAA bus scan, based on the platform device properties as in
device-tree, the port can be classified as OH port.

This patch add support in the driver to use dpaa eth port
in OH mode as well with DPDK applications.

Signed-off-by: Rohit Raj 


Re: [PATCH 13/17] net/dpaa: add Tx rate limiting DPAA PMD API

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:10, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

From: Vinod Pullabhatla 

Add support to set Tx rate on DPAA platform through PMD APIs

Signed-off-by: Vinod Pullabhatla 
Signed-off-by: Rohit Raj 

<...>


diff --git a/drivers/net/dpaa/rte_pmd_dpaa.h b/drivers/net/dpaa/rte_pmd_dpaa.h
index ec45633ba2..b48adff570 100644
--- a/drivers/net/dpaa/rte_pmd_dpaa.h
+++ b/drivers/net/dpaa/rte_pmd_dpaa.h
@@ -1,5 +1,5 @@
  /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2018 NXP
+ * Copyright 2018,2022 NXP
   */
  
  #ifndef _PMD_DPAA_H_

@@ -31,4 +31,27 @@
  int
  rte_pmd_dpaa_set_tx_loopback(uint16_t port, uint8_t on);
  
+/**

+ * Set TX rate limit
+ *
+ * @param port_id
+ *The port identifier of the Ethernet device.
+ * @param burst
+ *Max burst size(KBytes) of the Ethernet device.
+ *0 - Disable TX rate limit.
+ * @param rate
+ *Max rate(Kb/sec) of the Ethernet device.
+ *0 - Disable TX rate limit.
+ * @return
+ *0 - if successful.
+ *<0 - if failed, with proper error code.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ */
+__rte_experimental
+int
+rte_pmd_dpaa_port_set_rate_limit(uint16_t port_id, uint16_t burst,
+uint32_t rate);
+


We are trying to avoid from PMD specific APIs as much as possible.

Can't this be implemented via TM / metering? Or flow API?


We are yet to implement TM framework for DPAA1.  But that involves more 
of egress QoS.


This one is additional capability to limit the ingress port. Kind of 
policing in Rx side.






Re: [PATCH 10/17] net/dpaa: implement detailed packet parsing

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:09, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

This patch implements the detailed packet parsing using
the annotation info from the hardware.

decode parser to set RX muf packet type by dpaa_slow_parsing.
Support to identify the IPSec ESP, GRE and SCTP packets.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
  drivers/net/dpaa/dpaa_rxtx.c |  35 -
  drivers/net/dpaa/dpaa_rxtx.h | 143 +++
  2 files changed, 92 insertions(+), 86 deletions(-)


Please update '.dev_supported_ptypes_get()' function to advertise
supported packet types.

done


Re: [PATCH 07/17] net/dpaa: share MAC FMC scheme and CC parse

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:09, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

From: Jun Yang 

For Shared MAC:
1) Allocate RXQ from VSP scheme.
2) Allocate RXQ from CC directed to VSP.


What is CC, please explain in the commit log.

Coarse Classification to determine VSP (VF)

2) Remove RXQ allocated which is reconfigured without VSP.
3) Don't alloc default queue and err queues.

Signed-off-by: Jun Yang 
Acked-by: Hemant Agrawal 

<...>


diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index c15538116d..bbccd2a89b 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -693,13 +693,26 @@ dpaa_rx_cb_atomic(void *event,
  }
  
  #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER

-static inline void dpaa_eth_err_queue(struct dpaa_if *dpaa_intf)
+static inline void
+dpaa_eth_err_queue(struct qman_fq *fq)
  {
struct rte_mbuf *mbuf;
struct qman_fq *debug_fq;
int ret, i;
struct qm_dqrr_entry *dq;
struct qm_fd *fd;
+   struct dpaa_if *dpaa_intf;
+
+   dpaa_intf = fq->dpaa_intf;
+   if (fq != &dpaa_intf->rx_queues[0]) {
+   /** Associate error queues to the first RXQ.*/
+   return;
+   }
+
+   if (dpaa_intf->cfg->fman_if->is_shared_mac) {
+   /** Error queues of shared MAC are handled in kernel. */


This is doxygen syntax, is using '/** ' instead of '/* ' intentional?


It was not intentional.  The code is coming from a baremetal env. We 
have fixed it now.





<...>


Re: [PATCH 05/17] net/dpaa: support Tx confirmation to enable PTP

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:08, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

From: Vanshika Shukla 

TX confirmation provides dedicated confirmation
queues for transmitted packets. These queues are
used by software to get the status and release
transmitted packets buffers.

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
  drivers/net/dpaa/dpaa_ethdev.c | 45 ++---
  drivers/net/dpaa/dpaa_ethdev.h |  3 +-
  drivers/net/dpaa/dpaa_rxtx.c   | 52 ++
  drivers/net/dpaa/dpaa_rxtx.h   |  2 ++
  4 files changed, 90 insertions(+), 12 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 90b34e42f2..9ffb8c578c 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1826,9 +1826,15 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
opts.fqd.dest.wq = DPAA_IF_TX_PRIORITY;
opts.fqd.fq_ctrl = QM_FQCTRL_PREFERINCACHE;
opts.fqd.context_b = 0;
+#if defined(RTE_LIBRTE_IEEE1588)
+   opts.fqd.context_a.lo = 0;
+   opts.fqd.context_a.hi = fman_dealloc_bufs_mask_hi;
+#else


There is already a target to remove 'RTE_LIBRTE_IEEE1588' macro [1],
waiting for drivers clean up, lets not introduce more of it.

Can you use runtime configuration to enable PTP support?


OK, we have made it device args based control.



[1]
https://patches.dpdk.org/project/dpdk/patch/20230203132810.14187-1-tho...@monjalon.net/


Re: [PATCH 04/17] bus/dpaa: add port buffer manager stats

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:08, Ferruh Yigit wrote:

On 8/1/2024 11:53 AM, Hemant Agrawal wrote:

Add BMI statistics and improving the existing extended
statistics

Signed-off-by: Hemant Agrawal 
Signed-off-by: Gagandeep Singh 
---
  drivers/bus/dpaa/base/fman/fman_hw.c | 65 +++-
  drivers/bus/dpaa/include/fman.h  |  4 +-
  drivers/bus/dpaa/include/fsl_fman.h  | 12 +
  drivers/bus/dpaa/version.map |  4 ++
  drivers/net/dpaa/dpaa_ethdev.c   | 46 +---
  drivers/net/dpaa/dpaa_ethdev.h   | 12 +
  6 files changed, 134 insertions(+), 9 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 24a99f7235..27b39a4975 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -244,8 +244,8 @@ fman_if_stats_get_all(struct fman_if *p, uint64_t *value, 
int n)
uint64_t base_offset = offsetof(struct memac_regs, reoct_l);
  
  	for (i = 0; i < n; i++)

-   value[i] = (((u64)in_be32((char *)regs + base_offset + 8 * i) |
-   (u64)in_be32((char *)regs + base_offset +
+   value[i] = ((u64)in_be32((char *)regs + base_offset + 8 * i) |
+   ((u64)in_be32((char *)regs + base_offset +
8 * i + 4)) << 32);


Above change looks like a bug fix, it is converting from
"(a | b) << 32"  to  "a | (b << 32)"

Syntax wise a small change that is easy to miss, but impacts the result.

Why not simplify it something like:
uint64_t a = in_be32((char *)regs + base_offset + 8 * i)
uint64_t b = in_be32((char *)regs + base_offset + 8 * i + 4)
value[i] = a | b << 32

Anyway, my point is, should it go to its own patch, with fixes tag and
stable tag, so it can be backported to stable releases.

<...>

Thanks for the suggestion.  we made it a separate patch for it.


Re: [PATCH 03/17] bus/dpaa: fix VSP for 1G fm1-mac9 and 10

2024-08-23 Thread Hemant Agrawal



On 07-08-2024 21:08, Ferruh Yigit wrote:

On 8/1/2024 11:52 AM, Hemant Agrawal wrote:

No need to classify interface separately for 1G and 10G

Fixes: e0718bb2ca95 ("bus/dpaa: add virtual storage profile port init")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 


Can you please briefly explain what is VSP in the commit log, at worst
provide what the acronym stands for.
Fixed the commit logs. VSP is virtual storage profile. It is a SRIOV 
equivalent in DPAA for creating VF interfaces with VSP.


[PATCH v2 18/18] net/dpaa: improve dpaa errata A010022 handling

2024-08-23 Thread Hemant Agrawal
From: Jun Yang 

This patch improves the errata handling for
"RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022"

Signed-off-by: Jun Yang 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index d82c6f3be2..1d7efdef88 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1258,6 +1258,35 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
return new_mbufs[0];
 }
 
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+/* In case the data offset is not multiple of 16,
+ * FMAN can stall because of an errata. So reallocate
+ * the buffer in such case.
+ */
+static inline int
+dpaa_eth_ls1043a_mbuf_realloc(struct rte_mbuf *mbuf)
+{
+   uint64_t len, offset;
+
+   if (dpaa_svr_family != SVR_LS1043A_FAMILY)
+   return 0;
+
+   while (mbuf) {
+   len = mbuf->data_len;
+   offset = mbuf->data_off;
+   if ((mbuf->next &&
+   !rte_is_aligned((void *)len, 16)) ||
+   !rte_is_aligned((void *)offset, 16)) {
+   DPAA_PMD_DEBUG("Errata condition hit");
+
+   return 1;
+   }
+   mbuf = mbuf->next;
+   }
+   return 0;
+}
+#endif
+
 uint16_t
 dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
@@ -1296,14 +1325,6 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_BURST_SIZE : nb_bufs;
for (loop = 0; loop < frames_to_send; loop++) {
mbuf = *(bufs++);
-   /* In case the data offset is not multiple of 16,
-* FMAN can stall because of an errata. So reallocate
-* the buffer in such case.
-*/
-   if (dpaa_svr_family == SVR_LS1043A_FAMILY &&
-   (mbuf->data_off & 0x7F) != 0x0)
-   realloc_mbuf = 1;
-
fd_arr[loop].cmd = 0;
if (dpaa_ieee_1588) {
fd_arr[loop].cmd |= DPAA_FD_CMD_FCO |
@@ -1311,6 +1332,9 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
fd_arr[loop].cmd |= DPAA_FD_CMD_RPD |
DPAA_FD_CMD_UPD;
}
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+   realloc_mbuf = dpaa_eth_ls1043a_mbuf_realloc(mbuf);
+#endif
seqn = *dpaa_seqn(mbuf);
if (seqn != DPAA_INVALID_MBUF_SEQN) {
index = seqn - 1;
-- 
2.25.1



[PATCH v2 17/18] net/dpaa: improve the dpaa port cleanup

2024-08-23 Thread Hemant Agrawal
From: Gagandeep Singh 

During DPAA cleanup in FMCLESS mode, application can
see segmentation fault in device close API and in DPAA
destructor execution.
Segmentation fault in device close is because driver
reducing the number of queues initialised during
device configuration without releasing the actual queues.

And segmentation fault in DPAA destruction is because
it is trying to access RTE* devices whose memory has
been released in rte_eal_cleanup() call by the application.

This patch improves the behavior.

Signed-off-by: Gagandeep Singh 
---
 drivers/net/dpaa/dpaa_ethdev.c | 33 +++--
 drivers/net/dpaa/dpaa_flow.c   |  8 
 2 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 133fbd5bc9..41ae033c75 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -561,10 +561,10 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
if (dpaa_intf->cgr_rx) {
for (loop = 0; loop < dpaa_intf->nb_rx_queues; loop++)
qman_delete_cgr(&dpaa_intf->cgr_rx[loop]);
+   rte_free(dpaa_intf->cgr_rx);
+   dpaa_intf->cgr_rx = NULL;
}
 
-   rte_free(dpaa_intf->cgr_rx);
-   dpaa_intf->cgr_rx = NULL;
/* Release TX congestion Groups */
if (dpaa_intf->cgr_tx) {
for (loop = 0; loop < MAX_DPAA_CORES; loop++)
@@ -578,6 +578,15 @@ static int dpaa_eth_dev_close(struct rte_eth_dev *dev)
 
rte_free(dpaa_intf->tx_queues);
dpaa_intf->tx_queues = NULL;
+   if (dpaa_intf->port_handle) {
+   if (dpaa_fm_deconfig(dpaa_intf, fif))
+   DPAA_PMD_WARN("DPAA FM "
+   "deconfig failed\n");
+   }
+   if (fif->num_profiles) {
+   if (dpaa_port_vsp_cleanup(dpaa_intf, fif))
+   DPAA_PMD_WARN("DPAA FM vsp cleanup failed\n");
+   }
 
return ret;
 }
@@ -2607,26 +2616,6 @@ static void __attribute__((destructor(102))) 
dpaa_finish(void)
return;
 
if (!(default_q || fmc_q)) {
-   unsigned int i;
-
-   for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
-   if (rte_eth_devices[i].dev_ops == &dpaa_devops) {
-   struct rte_eth_dev *dev = &rte_eth_devices[i];
-   struct dpaa_if *dpaa_intf =
-   dev->data->dev_private;
-   struct fman_if *fif =
-   dev->process_private;
-   if (dpaa_intf->port_handle)
-   if (dpaa_fm_deconfig(dpaa_intf, fif))
-   DPAA_PMD_WARN("DPAA FM "
-   "deconfig failed");
-   if (fif->num_profiles) {
-   if (dpaa_port_vsp_cleanup(dpaa_intf,
- fif))
-   DPAA_PMD_WARN("DPAA FM vsp 
cleanup failed");
-   }
-   }
-   }
if (is_global_init)
if (dpaa_fm_term())
DPAA_PMD_WARN("DPAA FM term failed");
diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c
index 810b187405..2240f8d27c 100644
--- a/drivers/net/dpaa/dpaa_flow.c
+++ b/drivers/net/dpaa/dpaa_flow.c
@@ -1,5 +1,5 @@
 /* SPDX-License-Identifier: BSD-3-Clause
- * Copyright 2017-2019,2021 NXP
+ * Copyright 2017-2019,2021-2023 NXP
  */
 
 /* System headers */
@@ -812,8 +812,6 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t 
req_dist_set)
return -1;
}
 
-   dpaa_intf->nb_rx_queues = dev->data->nb_rx_queues;
-
/* Open FM Port and set it in port info */
ret = set_fm_port_handle(dpaa_intf, req_dist_set, fif);
if (ret) {
@@ -822,7 +820,7 @@ int dpaa_fm_config(struct rte_eth_dev *dev, uint64_t 
req_dist_set)
}
 
if (fif->num_profiles) {
-   for (i = 0; i < dpaa_intf->nb_rx_queues; i++)
+   for (i = 0; i < dev->data->nb_rx_queues; i++)
dpaa_intf->rx_queues[i].vsp_id =
fm_default_vsp_id(fif);
 
@@ -1147,6 +1145,8 @@ int rte_pmd_dpaa_port_set_rate_limit(uint16_t port_id, 
uint16_t burst,
 
if (ret) {
DPAA_PMD_ERR("Failed to set rate limit ret = %#x\n", -ret);
+   if (!port_handle_exists)
+   fm_port_close(handle);
return -ret;
}
 
-- 
2.25.1



[PATCH v2 16/18] bus/dpaa: add ONIC port mode for the DPAA eth

2024-08-23 Thread Hemant Agrawal
From: Rohit Raj 

The OH ports can also be used by two application, processing contexts
to communicate to each other.
This patch enables this mode for dpaa-eth OH port as ONIC port,
so that application can use the dpaa-eth to communicate to each
other on the same SoC.

Again,this properties is driven by the system device-tree variables.

Signed-off-by: Rohit Raj 
---
 doc/guides/nics/dpaa.rst  |  33 ++-
 drivers/bus/dpaa/base/fman/fman.c | 299 +-
 drivers/bus/dpaa/base/fman/fman_hw.c  |  20 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |   4 +-
 drivers/bus/dpaa/dpaa_bus.c   |  10 +-
 drivers/bus/dpaa/include/fman.h   |  15 +-
 drivers/net/dpaa/dpaa_ethdev.c| 114 +++--
 drivers/net/dpaa/dpaa_flow.c  |  28 +-
 drivers/net/dpaa/dpaa_fmc.c   |   3 +-
 9 files changed, 467 insertions(+), 59 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index 47dcce334c..529d5b74f4 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -136,7 +136,7 @@ RTE framework and DPAA internal components/drivers.
   The Ethernet driver is bound to a FMAN port and implements the interfaces
   needed to connect the DPAA network interface to the network stack.
   Each FMAN Port corresponds to a DPDK network interface.
-- PMD also support OH mode, where the port works as a HW assisted
+- PMD also support OH/ONIC mode, where the port works as a HW assisted
   virtual port without actually connecting to a Physical MAC.
 
 
@@ -152,7 +152,7 @@ Features
   - Promiscuous mode
   - IEEE1588 PTP
   - OH Port for inter application communication
-
+  - ONIC virtual port support
 
 DPAA Mempool Driver
 ~~~
@@ -350,6 +350,35 @@ OH Port
  Rx Packets  -
 
 
+ONIC
+
+   To use OH port to communicate between two applications, we can assign Rx 
port
+   of an O/H port to Application 1 and Tx port to Application 2 so that
+   Application 1 can send packets to Application 2. Similarly, we can assign Tx
+   port of another O/H port to Application 1 and Rx port to Application 2 so 
that
+   Applicaiton 2 can send packets to Application 1.
+
+   ONIC is logically defined to achieve it. Internally it will use one Rx queue
+   of an O/H port and one Tx queue of another O/H port.
+   For application, it will behave as single O/H port.
+
+   +--+ +--++--++--++--+
+   |  |   Tx|  |   Rx   | O/H  |   Tx   |  |   Rx   |  |
+   |  | - - - > |  | -  - > | Port | -  - > |  | -  - > |  |
+   |  | |  ||  1   ||  ||  |
+   |  | |  |+--+|  ||  |
+   | App  | | ONIC || ONIC || App  |
+   |  1   | | Port || Port ||  2   |
+   |  | |  1   |+--+|  2   ||  |
+   |  |   Rx|  |   Tx   | O/H  |   Rx   |  |   Tx   |  |
+   |  | < - - - |  | < - - -| Port | < - - -|  | < - - -|  |
+   |  | |  ||  2   ||  ||  |
+   +--+ +--++--++--++--+
+
+   All the packets received by ONIC port 1 will be send to ONIC port 2 and vice
+   versa. These ports can be used by DPDK applications just like physical 
ports.
+
+
 VSP (Virtual Storage Profile)
 ~
The storage profiled are means to provide virtualized interface. A ranges of
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index f817305ab7..efe6eab4a9 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -43,7 +43,7 @@ if_destructor(struct __fman_if *__if)
if (!__if)
return;
 
-   if (__if->__if.mac_type == fman_offline)
+   if (__if->__if.mac_type == fman_offline_internal)
goto cleanup;
 
list_for_each_entry_safe(bp, tmpbp, &__if->__if.bpool_list, node) {
@@ -465,7 +465,7 @@ fman_if_init(const struct device_node *dpa_node)
__if->__if.is_memac = 0;
 
if (is_offline)
-   __if->__if.mac_type = fman_offline;
+   __if->__if.mac_type = fman_offline_internal;
else if (of_device_is_compatible(mac_node, "fsl,fman-1g-mac"))
__if->__if.mac_type = fman_mac_1g;
else if (of_device_is_compatible(mac_node, "fsl,fman-10g-mac"))
@@ -791,6 +791,292 @@ fman_if_init(const struct device_node *dpa_node)
dname, __if->__if.tx_channel_id, __if->__if.fman_idx,
__if->__if.mac_idx);
 
+   /* Don't add OH port to the port list since they will be used by ONIC
+* ports.
+*/
+   if (!is_offline)
+   list_add_tail(&__if->__if.n

[PATCH v2 15/18] bus/dpaa: add OH port mode for dpaa eth

2024-08-23 Thread Hemant Agrawal
From: Rohit Raj 

NXP DPAA architecture supports the concept of DPAA
port as Offline Port - meaning - not connected to an actual MAC.
This is an hardware assited IPC mechanism for communiting between two
applications.

Offline(O/H) port is a type of hardware port which is able to dequeue and
enqueue from/to a QMan queue. The FMan applies a Parse Classify Distribute
(PCD) flow and (if configured to do so) enqueues the frame back in a
QMan queue.

The FMan is able to copy the frame into new buffers and enqueue back to the
QMan. This means these ports can be used to send and receive packet
between two applications.

An O/H port Have two queues. One to receive and one to send the packets.
It will loopback all the packets on Tx queue which are received
on Rx queue.

This property is completely driven by the device-tree. During the
DPAA bus scan, based on the platform device properties as in
device-tree, the port can be classified as OH port.

This patch add support in the driver to use dpaa eth port
in OH mode as well with DPDK applications.

Signed-off-by: Rohit Raj 
---
 doc/guides/nics/dpaa.rst  |  26 ++-
 drivers/bus/dpaa/base/fman/fman.c | 261 ++
 drivers/bus/dpaa/base/fman/fman_hw.c  |  24 +-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  19 +-
 drivers/bus/dpaa/dpaa_bus.c   |  23 +-
 drivers/bus/dpaa/include/fman.h   |  33 ++-
 drivers/net/dpaa/dpaa_ethdev.c|  85 ++-
 drivers/net/dpaa/dpaa_ethdev.h|   6 +
 drivers/net/dpaa/dpaa_flow.c  |  39 ++--
 drivers/net/dpaa/dpaa_fmc.c   |   3 +-
 10 files changed, 376 insertions(+), 143 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index edf7a7e350..47dcce334c 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -1,5 +1,5 @@
 ..  SPDX-License-Identifier: BSD-3-Clause
-Copyright 2017,2020 NXP
+Copyright 2017,2020-2024 NXP
 
 
 DPAA Poll Mode Driver
@@ -136,6 +136,8 @@ RTE framework and DPAA internal components/drivers.
   The Ethernet driver is bound to a FMAN port and implements the interfaces
   needed to connect the DPAA network interface to the network stack.
   Each FMAN Port corresponds to a DPDK network interface.
+- PMD also support OH mode, where the port works as a HW assisted
+  virtual port without actually connecting to a Physical MAC.
 
 
 Features
@@ -149,6 +151,8 @@ Features
   - Checksum offload
   - Promiscuous mode
   - IEEE1588 PTP
+  - OH Port for inter application communication
+
 
 DPAA Mempool Driver
 ~~~
@@ -326,6 +330,26 @@ FMLIB
`Kernel FMD Driver

`_.
 
+OH Port
+~~~
+   Offline(O/H) port is a type of hardware port which is able to dequeue and
+   enqueue from/to a QMan queue. The FMan applies a Parse Classify Distribute 
(PCD)
+   flow and (if configured to do so) enqueues the frame back in a QMan queue.
+
+   The FMan is able to copy the frame into new buffers and enqueue back to the
+   QMan. This means these ports can be used to send and receive packets 
between two
+   applications as well.
+
+   An O/H port have two queues. One to receive and one to send the packets. It 
will
+   loopback all the packets on Tx queue which are received on Rx queue.
+
+
+     Tx Packets  -
+   | App  | - -  - - - - - - - > | O/H   |
+   |  | < - - - - - - - - -  | Port  |
+     Rx Packets  -
+
+
 VSP (Virtual Storage Profile)
 ~
The storage profiled are means to provide virtualized interface. A ranges of
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index a79b0b75dd..f817305ab7 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -43,7 +43,7 @@ if_destructor(struct __fman_if *__if)
if (!__if)
return;
 
-   if (__if->__if.mac_type == fman_offline_internal)
+   if (__if->__if.mac_type == fman_offline)
goto cleanup;
 
list_for_each_entry_safe(bp, tmpbp, &__if->__if.bpool_list, node) {
@@ -246,26 +246,34 @@ fman_if_init(const struct device_node *dpa_node)
uint64_t port_cell_idx_val = 0;
uint64_t ext_args_cell_idx_val = 0;
 
-   const struct device_node *mac_node = NULL, *tx_node, *ext_args_node;
-   const struct device_node *pool_node, *fman_node, *rx_node;
+   const struct device_node *mac_node = NULL, *ext_args_node;
+   const struct device_node *pool_node, *fman_node;
+   const struct device_node *rx_node = NULL, *tx_node = NULL;
+   const struct device_node *oh_node = NULL;
const uint32_t *regs_addr = NULL;
const char *mname, *fname;
const char *dname = dpa_node->full_name;
size_t lenp;
-   

[PATCH v2 14/18] net/dpaa: add Tx rate limiting DPAA PMD API

2024-08-23 Thread Hemant Agrawal
From: Vinod Pullabhatla 

Add support to set Tx rate on DPAA platform through PMD APIs

Signed-off-by: Vinod Pullabhatla 
Signed-off-by: Rohit Raj 
---
 .mailmap |  1 +
 drivers/net/dpaa/dpaa_flow.c | 95 +---
 drivers/net/dpaa/fmlib/fm_lib.c  | 32 +-
 drivers/net/dpaa/fmlib/fm_port_ext.h |  2 +-
 drivers/net/dpaa/rte_pmd_dpaa.h  | 25 +++-
 drivers/net/dpaa/version.map |  7 ++
 6 files changed, 151 insertions(+), 11 deletions(-)

diff --git a/.mailmap b/.mailmap
index 4a508bafad..cb0fd52404 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1562,6 +1562,7 @@ Vincent Jardin 
 Vincent Li 
 Vincent S. Cojot 
 Vinh Tran 
+Vinod Pullabhatla 
 Vipin Padmam Ramesh 
 Vipin Varghese  
 Vipul Ashri 
diff --git a/drivers/net/dpaa/dpaa_flow.c b/drivers/net/dpaa/dpaa_flow.c
index 082bd5d014..dfc81e4e43 100644
--- a/drivers/net/dpaa/dpaa_flow.c
+++ b/drivers/net/dpaa/dpaa_flow.c
@@ -13,6 +13,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #define DPAA_MAX_NUM_ETH_DEV   8
 
@@ -29,6 +30,11 @@ return 
&scheme_params->param.key_ext_and_hash.extract_array[hdr_idx];
 #define SCH_EXT_FULL_FLD(scheme_params, hdr_idx) \
SCH_EXT_HDR(scheme_params, hdr_idx).extract_by_hdr_type.full_field
 
+/* FMAN mac indexes mappings (0 is unused, first 8 are for 1G, next for 10G
+ * ports).
+ */
+const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
+
 /* FM global info */
 struct dpaa_fm_info {
t_handle fman_handle;
@@ -649,7 +655,7 @@ static inline int set_pcd_netenv_scheme(struct dpaa_if 
*dpaa_intf,
 }
 
 
-static inline int get_port_type(struct fman_if *fif)
+static inline int get_rx_port_type(struct fman_if *fif)
 {
/* For 1G fm-mac9 and fm-mac10 ports, configure the VSP as 10G
 * ports so that kernel can configure correct port.
@@ -668,6 +674,19 @@ static inline int get_port_type(struct fman_if *fif)
return -1;
 }
 
+static inline int get_tx_port_type(struct fman_if *fif)
+{
+   if (fif->mac_type == fman_mac_1g)
+   return e_FM_PORT_TYPE_TX;
+   else if (fif->mac_type == fman_mac_2_5g)
+   return e_FM_PORT_TYPE_TX_2_5G;
+   else if (fif->mac_type == fman_mac_10g)
+   return e_FM_PORT_TYPE_TX_10G;
+
+   DPAA_PMD_ERR("MAC type unsupported");
+   return -1;
+}
+
 static inline int set_fm_port_handle(struct dpaa_if *dpaa_intf,
 uint64_t req_dist_set,
 struct fman_if *fif)
@@ -676,17 +695,12 @@ static inline int set_fm_port_handle(struct dpaa_if 
*dpaa_intf,
ioc_fm_pcd_net_env_params_t dist_units;
PMD_INIT_FUNC_TRACE();
 
-   /* FMAN mac indexes mappings (0 is unused,
-* first 8 are for 1G, next for 10G ports
-*/
-   uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
-
/* Memset FM port params */
memset(&fm_port_params, 0, sizeof(fm_port_params));
 
/* Set FM port params */
fm_port_params.h_fm = fm_info.fman_handle;
-   fm_port_params.port_type = get_port_type(fif);
+   fm_port_params.port_type = get_rx_port_type(fif);
fm_port_params.port_id = mac_idx[fif->mac_idx];
 
/* FM PORT Open */
@@ -949,7 +963,6 @@ static int dpaa_port_vsp_configure(struct dpaa_if 
*dpaa_intf,
 {
t_fm_vsp_params vsp_params;
t_fm_buffer_prefix_content buf_prefix_cont;
-   uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
uint8_t idx = mac_idx[fif->mac_idx];
int ret;
 
@@ -1079,3 +1092,69 @@ int dpaa_port_vsp_cleanup(struct dpaa_if *dpaa_intf, 
struct fman_if *fif)
 
return E_OK;
 }
+
+int rte_pmd_dpaa_port_set_rate_limit(uint16_t port_id, uint16_t burst,
+uint32_t rate)
+{
+   t_fm_port_rate_limit port_rate_limit;
+   bool port_handle_exists = true;
+   void *handle;
+   uint32_t ret;
+   struct rte_eth_dev *dev;
+   struct dpaa_if *dpaa_intf;
+   struct fman_if *fif;
+
+   RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
+   dev = &rte_eth_devices[port_id];
+   dpaa_intf = dev->data->dev_private;
+   fif = dev->process_private;
+
+   memset(&port_rate_limit, 0, sizeof(port_rate_limit));
+   port_rate_limit.max_burst_size = burst;
+   port_rate_limit.rate_limit = rate;
+
+   DPAA_PMD_DEBUG("Setting Rate Limiter for port:%s  Max Burst =%u Max 
Rate =%u\n",
+  dpaa_intf->name, burst, rate);
+
+   if (!dpaa_intf->port_handle) {
+   t_fm_port_params fm_port_params;
+
+   /* Memset FM port params */
+   memset(&fm_port_params, 0, sizeof(fm_port_params));
+
+   /* Set FM port params */
+   fm_port_params.h_fm = fm_open(0);
+   fm_port_params.port_type = get_tx_port_type(fif);
+   fm_port_params.port_id = mac_idx[fif->mac_idx];
+
+   /* FM PORT Open */
+   

[PATCH v2 13/18] net/dpaa: support mempool debug

2024-08-23 Thread Hemant Agrawal
From: Gagandeep Singh 

This patch adds support to compile time debug the mempool
corruptions in dpaa driver.

Signed-off-by: Gagandeep Singh 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 40 insertions(+)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 945c84ab10..d82c6f3be2 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -494,6 +494,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->data_len = sg_temp->length;
first_seg->pkt_len = sg_temp->length;
rte_mbuf_refcnt_set(first_seg, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)first_seg),
+   (void **)&first_seg, 1, 1);
+#endif
 
first_seg->port = ifid;
first_seg->nb_segs = 1;
@@ -511,6 +515,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->pkt_len += sg_temp->length;
first_seg->nb_segs += 1;
rte_mbuf_refcnt_set(cur_seg, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
+   (void **)&cur_seg, 1, 1);
+#endif
prev_seg->next = cur_seg;
if (sg_temp->final) {
cur_seg->next = NULL;
@@ -522,6 +530,10 @@ dpaa_eth_sg_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
first_seg->pkt_len, first_seg->nb_segs);
 
dpaa_eth_packet_info(first_seg, vaddr);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
+   (void **)&temp, 1, 1);
+#endif
rte_pktmbuf_free_seg(temp);
 
return first_seg;
@@ -562,6 +574,10 @@ dpaa_eth_fd_to_mbuf(const struct qm_fd *fd, uint32_t ifid)
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
 
return mbuf;
@@ -676,6 +692,10 @@ dpaa_rx_cb_no_prefetch(struct qman_fq **fq, struct 
qm_dqrr_entry **dqrr,
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
dpaa_display_frame_info(fd, fq[0]->fqid, true);
if (dpaa_ieee_1588) {
@@ -722,6 +742,10 @@ dpaa_rx_cb(struct qman_fq **fq, struct qm_dqrr_entry 
**dqrr,
mbuf->ol_flags = 0;
mbuf->next = NULL;
rte_mbuf_refcnt_set(mbuf, 1);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)mbuf),
+   (void **)&mbuf, 1, 1);
+#endif
dpaa_eth_packet_info(mbuf, mbuf->buf_addr);
dpaa_display_frame_info(fd, fq[0]->fqid, true);
if (dpaa_ieee_1588) {
@@ -972,6 +996,10 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
return -1;
}
 
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void *)temp),
+   (void **)&temp, 1, 0);
+#endif
fd->cmd = 0;
fd->opaque_addr = 0;
 
@@ -1017,6 +1045,10 @@ dpaa_eth_mbuf_to_sg_fd(struct rte_mbuf *mbuf,
} else {
sg_temp->bpid =
DPAA_MEMPOOL_TO_BPID(cur_seg->pool);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   
rte_mempool_check_cookies(rte_mempool_from_obj((void *)cur_seg),
+   (void **)&cur_seg, 1, 0);
+#endif
}
} else if (RTE_MBUF_HAS_EXTBUF(cur_seg)) {
free_buf[*free_count].seg = cur_seg;
@@ -1074,6 +1106,10 @@ tx_on_dpaa_pool_unsegmented(struct rte_mbuf *mbuf,
 * released by BMAN.
 */
DPAA_MBUF_TO_CONTIG_FD(mbuf, fd_arr, bp_info->bpid);
+#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
+   rte_mempool_check_cookies(rte_mempool_from_obj((void 
*)mbuf),
+   (void **)&mbuf, 1, 0);
+#endif
}
} else if (RTE_MBUF_HAS_EXTBUF(mbuf)) {
buf_to_free[*free_count].seg = mbuf;
@@ -1302,6 +1338,10 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_CKSUM_OFFLOAD_MASK)
dpaa_unsegmented_checksum(mbuf,
 

[PATCH v2 12/18] net/dpaa: enhance DPAA frame display

2024-08-23 Thread Hemant Agrawal
This patch enhances the received packet debugging capability.
This help displaying the full packet parsing output.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
 doc/guides/nics/dpaa.rst   |   5 ++
 drivers/net/dpaa/dpaa_ethdev.c |   9 +++
 drivers/net/dpaa/dpaa_rxtx.c   | 138 +++--
 drivers/net/dpaa/dpaa_rxtx.h   |   5 ++
 4 files changed, 133 insertions(+), 24 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index ea86e6146c..edf7a7e350 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -227,6 +227,11 @@ state during application initialization:
   application want to use eventdev with DPAA device.
   Currently these queues are not used for LS1023/LS1043 platform by default.
 
+- ``DPAA_DISPLAY_FRAME_AND_PARSER_RESULT`` (default 0)
+
+  This defines the debug flag, whether to dump the detailed frame and packet
+  parsing result for the incoming packets.
+
 
 Driver compilation and testing
 --
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index a302b24be6..4ead890278 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -2056,6 +2056,9 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
int8_t dev_vspids[DPAA_MAX_NUM_PCD_QUEUES];
int8_t vsp_id = -1;
struct rte_device *dev = eth_dev->device;
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+   char *penv;
+#endif
 
PMD_INIT_FUNC_TRACE();
 
@@ -2135,6 +2138,12 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
td_tx_threshold = CGR_RX_PERFQ_THRESH;
}
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+   penv = getenv("DPAA_DISPLAY_FRAME_AND_PARSER_RESULT");
+   if (penv)
+   dpaa_force_display_frame_set(atoi(penv));
+#endif
+
/* If congestion control is enabled globally*/
if (num_rx_fqs > 0 && td_threshold) {
dpaa_intf->cgr_rx = rte_zmalloc(NULL,
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 99fc3f1b43..945c84ab10 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -47,6 +47,10 @@
 #include 
 #include 
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+static int s_force_display_frm;
+#endif
+
 #define DPAA_MBUF_TO_CONTIG_FD(_mbuf, _fd, _bpid) \
do { \
(_fd)->opaque_addr = 0; \
@@ -58,37 +62,122 @@
} while (0)
 
 #ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+void
+dpaa_force_display_frame_set(int set)
+{
+   s_force_display_frm = set;
+}
+
 #define DISPLAY_PRINT printf
-static void dpaa_display_frame_info(const struct qm_fd *fd,
-   uint32_t fqid, bool rx)
+static void
+dpaa_display_frame_info(const struct qm_fd *fd,
+   uint32_t fqid, bool rx)
 {
-   int ii;
-   char *ptr;
+   int pos, offset = 0;
+   char *ptr, info[1024];
struct annotations_t *annot = rte_dpaa_mem_ptov(fd->addr);
uint8_t format;
+   const struct dpaa_eth_parse_results_t *psr;
 
-   if (!fd->status) {
-   /* Do not display correct packets.*/
+   if (!fd->status && !s_force_display_frm) {
+   /* Do not display correct packets unless force display.*/
return;
}
+   psr = &annot->parse;
 
-   format = (fd->opaque & DPAA_FD_FORMAT_MASK) >>
-   DPAA_FD_FORMAT_SHIFT;
-
-   DISPLAY_PRINT("fqid %d bpid %d addr 0x%lx, format %d\r\n",
- fqid, fd->bpid, (unsigned long)fd->addr, fd->format);
-   DISPLAY_PRINT("off %d, len %d stat 0x%x\r\n",
- fd->offset, fd->length20, fd->status);
+   format = (fd->opaque & DPAA_FD_FORMAT_MASK) >> DPAA_FD_FORMAT_SHIFT;
+   if (format == qm_fd_contig)
+   sprintf(info, "simple");
+   else if (format == qm_fd_sg)
+   sprintf(info, "sg");
+   else
+   sprintf(info, "unknown format(%d)", format);
+
+   DISPLAY_PRINT("%s: fqid=%08x, bpid=%d, phy addr=0x%lx ",
+   rx ? "RX" : "TX", fqid, fd->bpid, (unsigned long)fd->addr);
+   DISPLAY_PRINT("format=%s offset=%d, len=%d, stat=0x%x\r\n",
+   info, fd->offset, fd->length20, fd->status);
if (rx) {
-   ptr = (char *)&annot->parse;
-   DISPLAY_PRINT("RX parser result:\r\n");
-   for (ii = 0; ii < (int)sizeof(struct dpaa_eth_parse_results_t);
-   ii++) {
-   DISPLAY_PRINT("%02x ", ptr[ii]);
-   if (((ii + 1) % 16) == 0)
-   DISPLAY_PRINT("\n");
+   DISPLAY_PRINT("Display usual RX parser result:\r\n");
+   

[PATCH v2 11/18] net/dpaa: implement detailed packet parsing

2024-08-23 Thread Hemant Agrawal
This patch implements the detailed packet parsing using
the annotation info from the hardware.

decode parser to set RX muf packet type by dpaa_slow_parsing.
Support to identify the IPSec ESP, GRE and SCTP packets.

Signed-off-by: Jun Yang 
Signed-off-by: Hemant Agrawal 
---
 drivers/net/dpaa/dpaa_ethdev.c |   1 +
 drivers/net/dpaa/dpaa_rxtx.c   |  35 +++-
 drivers/net/dpaa/dpaa_rxtx.h   | 143 ++---
 3 files changed, 93 insertions(+), 86 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 82d1960356..a302b24be6 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -411,6 +411,7 @@ dpaa_supported_ptypes_get(struct rte_eth_dev *dev, size_t 
*no_of_elements)
RTE_PTYPE_L4_UDP,
RTE_PTYPE_L4_SCTP,
RTE_PTYPE_TUNNEL_ESP,
+   RTE_PTYPE_TUNNEL_GRE,
};
 
PMD_INIT_FUNC_TRACE();
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index e3b4bb14ab..99fc3f1b43 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -110,11 +110,38 @@ static void dpaa_display_frame_info(const struct qm_fd 
*fd,
 #define dpaa_display_frame_info(a, b, c)
 #endif
 
-static inline void dpaa_slow_parsing(struct rte_mbuf *m __rte_unused,
-uint64_t prs __rte_unused)
+static inline void
+dpaa_slow_parsing(struct rte_mbuf *m,
+   const struct annotations_t *annot)
 {
+   const struct dpaa_eth_parse_results_t *parse;
+
DPAA_DP_LOG(DEBUG, "Slow parsing");
-   /*TBD:XXX: to be implemented*/
+   parse = &annot->parse;
+
+   if (parse->ethernet)
+   m->packet_type |= RTE_PTYPE_L2_ETHER;
+   if (parse->vlan)
+   m->packet_type |= RTE_PTYPE_L2_ETHER_VLAN;
+   if (parse->first_ipv4)
+   m->packet_type |= RTE_PTYPE_L3_IPV4;
+   if (parse->first_ipv6)
+   m->packet_type |= RTE_PTYPE_L3_IPV6;
+   if (parse->gre)
+   m->packet_type |= RTE_PTYPE_TUNNEL_GRE;
+   if (parse->last_ipv4)
+   m->packet_type |= RTE_PTYPE_L3_IPV4_EXT;
+   if (parse->last_ipv6)
+   m->packet_type |= RTE_PTYPE_L3_IPV6_EXT;
+   if (parse->l4_type == DPAA_PR_L4_TCP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_TCP;
+   else if (parse->l4_type == DPAA_PR_L4_UDP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_UDP;
+   else if (parse->l4_type == DPAA_PR_L4_IPSEC_TYPE &&
+   !parse->l4_info_err && parse->esp_sum)
+   m->packet_type |= RTE_PTYPE_TUNNEL_ESP;
+   else if (parse->l4_type == DPAA_PR_L4_SCTP_TYPE)
+   m->packet_type |= RTE_PTYPE_L4_SCTP;
 }
 
 static inline void dpaa_eth_packet_info(struct rte_mbuf *m, void *fd_virt_addr)
@@ -228,7 +255,7 @@ static inline void dpaa_eth_packet_info(struct rte_mbuf *m, 
void *fd_virt_addr)
break;
/* More switch cases can be added */
default:
-   dpaa_slow_parsing(m, prs);
+   dpaa_slow_parsing(m, annot);
}
 
m->tx_offload = annot->parse.ip_off[0];
diff --git a/drivers/net/dpaa/dpaa_rxtx.h b/drivers/net/dpaa/dpaa_rxtx.h
index 1048e86d41..215bdeaf7f 100644
--- a/drivers/net/dpaa/dpaa_rxtx.h
+++ b/drivers/net/dpaa/dpaa_rxtx.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017,2020-2022 NXP
+ *   Copyright 2017,2020-2024 NXP
  *
  */
 
@@ -162,98 +162,77 @@
 
 #define DPAA_PKT_L3_LEN_SHIFT  7
 
+enum dpaa_parse_result_l4_type {
+   DPAA_PR_L4_TCP_TYPE = 1,
+   DPAA_PR_L4_UDP_TYPE = 2,
+   DPAA_PR_L4_IPSEC_TYPE = 3,
+   DPAA_PR_L4_SCTP_TYPE = 4,
+   DPAA_PR_L4_DCCP_TYPE = 5
+};
+
 /**
  * FMan parse result array
  */
 struct dpaa_eth_parse_results_t {
-uint8_t lpid;   /**< Logical port id */
-uint8_t shimr;  /**< Shim header result  */
-union {
-   uint16_t  l2r;  /**< Layer 2 result */
+   uint8_t lpid; /**< Logical port id */
+   uint8_t shimr; /**< Shim header result  */
+   union {
+   uint16_t l2r; /**< Layer 2 result */
struct {
-#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-   uint16_t  ethernet:1;
-   uint16_t  vlan:1;
-   uint16_t  llc_snap:1;
-   uint16_t  mpls:1;
-   uint16_t  ppoe_ppp:1;
-   uint16_t  unused_1:3;
-   uint16_t  unknown_eth_proto:1;
-   uint16_t  eth_frame_type:2;
-   uint16_t  l2r_err:5;
+   uint16_t u

[PATCH v2 10/18] net/dpaa: support IEEE 1588 PTP

2024-08-23 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch adds the support for the ethdev APIs
to enable/disable and read/write/adjust IEEE1588
PTP timestamps for DPAA platform.

Signed-off-by: Vanshika Shukla 
---
 doc/guides/nics/dpaa.rst  |  1 +
 doc/guides/nics/features/dpaa.ini |  2 +
 drivers/bus/dpaa/base/fman/fman.c | 15 ++
 drivers/bus/dpaa/include/fman.h   | 45 +
 drivers/net/dpaa/dpaa_ethdev.c|  5 ++
 drivers/net/dpaa/dpaa_ethdev.h| 16 +++
 drivers/net/dpaa/dpaa_ptp.c   | 80 ++-
 7 files changed, 162 insertions(+), 2 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index acf4daab02..ea86e6146c 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -148,6 +148,7 @@ Features
   - Packet type information
   - Checksum offload
   - Promiscuous mode
+  - IEEE1588 PTP
 
 DPAA Mempool Driver
 ~~~
diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index 4196dd800c..2c2e79dcb5 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -19,9 +19,11 @@ Flow control = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Timesync = Y
 Timestamp offload= Y
 Basic stats  = Y
 Extended stats   = Y
 FW version   = Y
 ARMv8= Y
 Usage doc= Y
+
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index 89786636d9..a79b0b75dd 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -28,6 +28,7 @@ u32 fman_dealloc_bufs_mask_lo;
 
 int fman_ccsr_map_fd = -1;
 static COMPAT_LIST_HEAD(__ifs);
+void *rtc_map;
 
 /* This is the (const) global variable that callers have read-only access to.
  * Internally, we have read-write access directly to __ifs.
@@ -539,6 +540,20 @@ fman_if_init(const struct device_node *dpa_node)
goto err;
}
 
+   if (!rtc_map) {
+   __if->rtc_map = mmap(NULL, FMAN_IEEE_1588_SIZE,
+   PROT_READ | PROT_WRITE, MAP_SHARED,
+   fman_ccsr_map_fd, FMAN_IEEE_1588_OFFSET);
+   if (__if->rtc_map == MAP_FAILED) {
+   pr_err("Can not map FMan RTC regs base\n");
+   _errno = -EINVAL;
+   goto err;
+   }
+   rtc_map = __if->rtc_map;
+   } else {
+   __if->rtc_map = rtc_map;
+   }
+
/* No channel ID for MAC-less */
assert(lenp == sizeof(*tx_channel_id));
na = of_n_addr_cells(mac_node);
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 857eef3d2f..109c1a4a22 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -64,6 +64,12 @@
 #define GROUP_ADDRESS  0x0100LL
 #define HASH_CTRL_ADDR_MASK0x003F
 
+#define FMAN_RTC_MAX_NUM_OF_ALARMS 3
+#define FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES4
+#define FMAN_RTC_MAX_NUM_OF_EXT_TRIGGERS   3
+#define FMAN_IEEE_1588_OFFSET  0X1AFE000
+#define FMAN_IEEE_1588_SIZE4096
+
 /* Pre definitions of FMAN interface and Bpool structures */
 struct __fman_if;
 struct fman_if_bpool;
@@ -307,6 +313,44 @@ struct tx_bmi_regs {
uint32_t fmbm_trlmts;   /**< Tx Rate Limiter Scale*/
uint32_t fmbm_trlmt;/**< Tx Rate Limiter*/
 };
+
+/* Description FM RTC timer alarm */
+struct t_tmr_alarm {
+   uint32_t tmr_alarm_h;
+   uint32_t tmr_alarm_l;
+};
+
+/* Description FM RTC timer Ex trigger */
+struct t_tmr_ext_trigger {
+   uint32_t tmr_etts_h;
+   uint32_t tmr_etts_l;
+};
+
+struct rtc_regs {
+   uint32_t tmr_id;/* 0x000 Module ID register */
+   uint32_t tmr_id2;   /* 0x004 Controller ID register */
+   uint32_t reserved0008[30];
+   uint32_t tmr_ctrl;  /* 0x0080 timer control register */
+   uint32_t tmr_tevent;/* 0x0084 timer event register */
+   uint32_t tmr_temask;/* 0x0088 timer event mask register */
+   uint32_t reserved008c[3];
+   uint32_t tmr_cnt_h; /* 0x0098 timer counter high register */
+   uint32_t tmr_cnt_l; /* 0x009c timer counter low register */
+   uint32_t tmr_add;   /* 0x00a0 timer drift compensation addend 
register */
+   uint32_t tmr_acc;   /* 0x00a4 timer accumulator register */
+   uint32_t tmr_prsc;  /* 0x00a8 timer prescale */
+   uint32_t reserved00ac;
+   uint32_t tmr_off_h; /* 0x00b0 timer offset high */
+   uint32_t tmr_off_l; /* 0x00b4 timer offset low  */
+   struct t_tmr_alarm tmr_alarm[FMAN_RTC_MAX_NUM_OF_ALARMS];
+   /* 0x00b8 timer alarm */
+   uint32_t tmr_fiper[FMAN_RTC_MAX_NUM_OF_PERIODIC_PULSES];
+   /* 0x00d0 timer fixed period

[PATCH v2 09/18] net/dpaa: support Rx/Tx timestamp read

2024-08-23 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch implements Rx/Tx timestamp read operations
for DPAA1 platform.

Signed-off-by: Vanshika Shukla 
---
 doc/guides/nics/features/dpaa.ini|  1 +
 drivers/bus/dpaa/base/fman/fman.c| 21 +++-
 drivers/bus/dpaa/base/fman/fman_hw.c |  6 ++-
 drivers/bus/dpaa/include/fman.h  | 18 ++-
 drivers/net/dpaa/dpaa_ethdev.c   |  2 +
 drivers/net/dpaa/dpaa_ethdev.h   | 17 +++
 drivers/net/dpaa/dpaa_ptp.c  | 43 +
 drivers/net/dpaa/dpaa_rxtx.c | 71 
 drivers/net/dpaa/dpaa_rxtx.h |  4 +-
 drivers/net/dpaa/meson.build |  1 +
 10 files changed, 169 insertions(+), 15 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_ptp.c

diff --git a/doc/guides/nics/features/dpaa.ini 
b/doc/guides/nics/features/dpaa.ini
index b136ed191a..4196dd800c 100644
--- a/doc/guides/nics/features/dpaa.ini
+++ b/doc/guides/nics/features/dpaa.ini
@@ -19,6 +19,7 @@ Flow control = Y
 L3 checksum offload  = Y
 L4 checksum offload  = Y
 Packet type parsing  = Y
+Timestamp offload= Y
 Basic stats  = Y
 Extended stats   = Y
 FW version   = Y
diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index bf41a3ed96..89786636d9 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2010-2016 Freescale Semiconductor Inc.
- * Copyright 2017-2020 NXP
+ * Copyright 2017-2024 NXP
  *
  */
 
@@ -520,6 +520,25 @@ fman_if_init(const struct device_node *dpa_node)
goto err;
}
 
+   regs_addr = of_get_address(tx_node, 0, &__if->regs_size, NULL);
+   if (!regs_addr) {
+   FMAN_ERR(-EINVAL, "of_get_address(%s)\n", mname);
+   goto err;
+   }
+   phys_addr = of_translate_address(tx_node, regs_addr);
+   if (!phys_addr) {
+   FMAN_ERR(-EINVAL, "of_translate_address(%s, %p)\n",
+   mname, regs_addr);
+   goto err;
+   }
+   __if->tx_bmi_map = mmap(NULL, __if->regs_size,
+   PROT_READ | PROT_WRITE, MAP_SHARED,
+   fman_ccsr_map_fd, phys_addr);
+   if (__if->tx_bmi_map == MAP_FAILED) {
+   FMAN_ERR(-errno, "mmap(0x%"PRIx64")\n", phys_addr);
+   goto err;
+   }
+
/* No channel ID for MAC-less */
assert(lenp == sizeof(*tx_channel_id));
na = of_n_addr_cells(mac_node);
diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 124c69edb4..4fc41c1ae9 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- * Copyright 2017,2020 NXP
+ * Copyright 2017,2020,2022 NXP
  *
  */
 
@@ -565,6 +565,10 @@ fman_if_set_ic_params(struct fman_if *fm_if,
&((struct rx_bmi_regs *)__if->bmi_map)->fmbm_ricp;
out_be32(fmbm_ricp, val);
 
+   unsigned int *fmbm_ticp =
+   &((struct tx_bmi_regs *)__if->tx_bmi_map)->fmbm_ticp;
+   out_be32(fmbm_ticp, val);
+
return 0;
 }
 
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 3642b43be7..857eef3d2f 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -2,7 +2,7 @@
  *
  * Copyright 2010-2012 Freescale Semiconductor, Inc.
  * All rights reserved.
- * Copyright 2019-2021 NXP
+ * Copyright 2019-2022 NXP
  *
  */
 
@@ -292,6 +292,21 @@ struct rx_bmi_regs {
uint32_t fmbm_rdbg; /**< Rx Debug-*/
 };
 
+struct tx_bmi_regs {
+   uint32_t fmbm_tcfg; /**< Tx Configuration*/
+   uint32_t fmbm_tst;  /**< Tx Status*/
+   uint32_t fmbm_tda;  /**< Tx DMA attributes*/
+   uint32_t fmbm_tfp;  /**< Tx FIFO Parameters*/
+   uint32_t fmbm_tfed; /**< Tx Frame End Data*/
+   uint32_t fmbm_ticp; /**< Tx Internal Context Parameters*/
+   uint32_t fmbm_tfdne;/**< Tx Frame Dequeue Next Engine*/
+   uint32_t fmbm_tfca; /**< Tx Frame Attributes*/
+   uint32_t fmbm_tcfqid;   /**< Tx Confirmation Frame Queue ID*/
+   uint32_t fmbm_tefqid;   /**< Tx Error Frame Queue ID*/
+   uint32_t fmbm_tfene;/**< Tx Frame Enqueue Next Engine*/
+   uint32_t fmbm_trlmts;   /**< Tx Rate Limiter Scale*/
+   uint32_t fmbm_trlmt;/**< Tx Rate Limiter*/
+};
 struct fman_port_qmi_regs {
uint32_t fmqm_pnc;  /**< PortID n Configuration Register */
uint32_t fmqm_pns;  /**< PortID n Status Register */
@@ -380,6 +395,7 @@ struct __fman_if {
uint64_t regs_size;
void *ccsr_map;
void *bmi_map;
+   void *tx_bmi_map;
void *qmi_map;
str

[PATCH v2 08/18] net/dpaa: share MAC FMC scheme and CC parse

2024-08-23 Thread Hemant Agrawal
From: Jun Yang 

For Shared MAC:
1) Allocate RXQ from VSP scheme. (Virtual Storage Profile)
2) Allocate RXQ from Coarse classifiation (CC) rules to VSP.
2) Remove RXQ allocated which is reconfigured without VSP.
3) Don't alloc default queue and err queues.

Signed-off-by: Jun Yang 
Acked-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman.c |   2 +-
 drivers/bus/dpaa/include/fman.h   |   3 +-
 drivers/net/dpaa/dpaa_ethdev.c|  60 +++--
 drivers/net/dpaa/dpaa_ethdev.h|  13 +-
 drivers/net/dpaa/dpaa_flow.c  |   8 +-
 drivers/net/dpaa/dpaa_fmc.c   | 421 +++---
 drivers/net/dpaa/dpaa_rxtx.c  |  20 +-
 7 files changed, 348 insertions(+), 179 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index beeb03dbf2..bf41a3ed96 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -42,7 +42,7 @@ if_destructor(struct __fman_if *__if)
if (!__if)
return;
 
-   if (__if->__if.mac_type == fman_offline)
+   if (__if->__if.mac_type == fman_offline_internal)
goto cleanup;
 
list_for_each_entry_safe(bp, tmpbp, &__if->__if.bpool_list, node) {
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 60681068ea..3642b43be7 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -72,10 +72,11 @@ TAILQ_HEAD(rte_fman_if_list, __fman_if);
 
 /* Represents the different flavour of network interface */
 enum fman_mac_type {
-   fman_offline = 0,
+   fman_offline_internal = 0,
fman_mac_1g,
fman_mac_10g,
fman_mac_2_5g,
+   fman_onic,
 };
 
 struct mac_addr {
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 3ee3029729..bf14d73433 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -255,7 +255,6 @@ dpaa_eth_dev_configure(struct rte_eth_dev *dev)
DPAA_PMD_ERR("Cannot open IF socket");
return -errno;
}
-
strncpy(ifr.ifr_name, dpaa_intf->name, IFNAMSIZ - 1);
 
if (ioctl(socket_fd, SIOCGIFMTU, &ifr) < 0) {
@@ -1893,6 +1892,7 @@ dpaa_tx_conf_queue_init(struct qman_fq *fq)
return ret;
 }
 
+#if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
 /* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
 static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
@@ -1923,6 +1923,7 @@ static int dpaa_def_queue_init(struct qman_fq *fq, 
uint32_t fqid)
fqid, ret);
return ret;
 }
+#endif
 
 /* Initialise a network interface */
 static int
@@ -1957,6 +1958,41 @@ dpaa_dev_init_secondary(struct rte_eth_dev *eth_dev)
return 0;
 }
 
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+static int
+dpaa_error_queue_init(struct dpaa_if *dpaa_intf,
+   struct fman_if *fman_intf)
+{
+   int i, ret;
+   struct qman_fq *err_queues = dpaa_intf->debug_queues;
+   uint32_t err_fqid = 0;
+
+   if (fman_intf->is_shared_mac) {
+   DPAA_PMD_DEBUG("Shared MAC's err queues are handled in kernel");
+   return 0;
+   }
+
+   for (i = 0; i < DPAA_DEBUG_FQ_MAX_NUM; i++) {
+   if (i == DPAA_DEBUG_FQ_RX_ERROR)
+   err_fqid = fman_intf->fqid_rx_err;
+   else if (i == DPAA_DEBUG_FQ_TX_ERROR)
+   err_fqid = fman_intf->fqid_tx_err;
+   else
+   continue;
+   ret = dpaa_def_queue_init(&err_queues[i], err_fqid);
+   if (ret) {
+   DPAA_PMD_ERR("DPAA %s ERROR queue init failed!",
+   i == DPAA_DEBUG_FQ_RX_ERROR ?
+   "RX" : "TX");
+   return ret;
+   }
+   err_queues[i].dpaa_intf = dpaa_intf;
+   }
+
+   return 0;
+}
+#endif
+
 static int
 check_devargs_handler(__rte_unused const char *key, const char *value,
  __rte_unused void *opaque)
@@ -2202,25 +2238,11 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
}
}
dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
-
-#if !defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
-   if (dpaa_ieee_1588)
+#if defined(RTE_LIBRTE_DPAA_DEBUG_DRIVER)
+   ret = dpaa_error_queue_init(dpaa_intf, fman_intf);
+   if (ret)
+   goto free_tx;
 #endif
-   {
-   ret = dpaa_def_queue_init(&dpaa_intf->debug_queues
-   [DPAA_DEBUG_FQ_RX_ERROR], 
fman_intf->fqid_rx_err);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA RX ERROR queue init failed!");
-   goto free_tx;
-   }
-   dpaa_intf->

[PATCH v2 07/18] net/dpaa: add support to separate Tx conf queues

2024-08-23 Thread Hemant Agrawal
From: Vanshika Shukla 

This patch separates Tx confirmation queues for kernel
and DPDK so as to support the VSP case.

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
 drivers/bus/dpaa/include/fsl_qman.h |  4 ++-
 drivers/net/dpaa/dpaa_ethdev.c  | 45 +
 drivers/net/dpaa/dpaa_rxtx.c|  3 +-
 3 files changed, 37 insertions(+), 15 deletions(-)

diff --git a/drivers/bus/dpaa/include/fsl_qman.h 
b/drivers/bus/dpaa/include/fsl_qman.h
index c0677976e8..db14dfb839 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
  *
  * Copyright 2008-2012 Freescale Semiconductor, Inc.
- * Copyright 2019 NXP
+ * Copyright 2019-2022 NXP
  *
  */
 
@@ -1237,6 +1237,8 @@ struct qman_fq {
 
/* DPDK Interface */
void *dpaa_intf;
+   /*to store tx_conf_queue corresponding to tx_queue*/
+   struct qman_fq *tx_conf_queue;
 
struct rte_event ev;
/* affined portal in case of static queue */
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index bba305cfb1..3ee3029729 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1870,9 +1870,30 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
return ret;
 }
 
-/* Initialise a DEBUG FQ ([rt]x_error, rx_default) and DPAA TX CONFIRM queue
- * to support PTP
- */
+static int
+dpaa_tx_conf_queue_init(struct qman_fq *fq)
+{
+   struct qm_mcc_initfq opts = {0};
+   int ret;
+
+   PMD_INIT_FUNC_TRACE();
+
+   ret = qman_create_fq(0, QMAN_FQ_FLAG_DYNAMIC_FQID, fq);
+   if (ret) {
+   DPAA_PMD_ERR("create Tx_conf failed with ret: %d", ret);
+   return ret;
+   }
+
+   opts.we_mask = QM_INITFQ_WE_DESTWQ | QM_INITFQ_WE_FQCTRL;
+   opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
+   ret = qman_init_fq(fq, 0, &opts);
+   if (ret)
+   DPAA_PMD_ERR("init Tx_conf fqid %d failed with ret: %d",
+   fq->fqid, ret);
+   return ret;
+}
+
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default) */
 static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
struct qm_mcc_initfq opts = {0};
@@ -2170,6 +2191,15 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
if (ret)
goto free_tx;
dpaa_intf->tx_queues[loop].dpaa_intf = dpaa_intf;
+
+   if (dpaa_ieee_1588) {
+   ret = 
dpaa_tx_conf_queue_init(&dpaa_intf->tx_conf_queues[loop]);
+   if (ret)
+   goto free_tx;
+
+   dpaa_intf->tx_conf_queues[loop].dpaa_intf = dpaa_intf;
+   dpaa_intf->tx_queues[loop].tx_conf_queue = 
&dpaa_intf->tx_conf_queues[loop];
+   }
}
dpaa_intf->nb_tx_queues = MAX_DPAA_CORES;
 
@@ -2190,16 +2220,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
DPAA_PMD_ERR("DPAA TX ERROR queue init failed!");
goto free_tx;
}
-   dpaa_intf->debug_queues[DPAA_DEBUG_FQ_TX_ERROR].dpaa_intf = 
dpaa_intf;
-   ret = dpaa_def_queue_init(dpaa_intf->tx_conf_queues,
-   fman_intf->fqid_tx_confirm);
-   if (ret) {
-   DPAA_PMD_ERR("DPAA TX CONFIRM queue init failed!");
-   goto free_tx;
-   }
-   dpaa_intf->tx_conf_queues->dpaa_intf = dpaa_intf;
}
-
DPAA_PMD_DEBUG("All frame queues created");
 
/* Get the initial configuration for flow control */
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 8593e20200..3bd35c7a0e 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1083,8 +1083,7 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
struct dpaa_sw_buf_free buf_to_free[DPAA_MAX_SGS * 
DPAA_MAX_DEQUEUE_NUM_FRAMES];
uint32_t free_count = 0;
struct qman_fq *fq = q;
-   struct dpaa_if *dpaa_intf = fq->dpaa_intf;
-   struct qman_fq *fq_txconf = dpaa_intf->tx_conf_queues;
+   struct qman_fq *fq_txconf = fq->tx_conf_queue;
 
if (unlikely(!DPAA_PER_LCORE_PORTAL)) {
ret = rte_dpaa_portal_init((void *)0);
-- 
2.25.1



[PATCH v2 06/18] net/dpaa: support Tx confirmation to enable PTP

2024-08-23 Thread Hemant Agrawal
From: Vanshika Shukla 

TX confirmation provides dedicated confirmation
queues for transmitted packets. These queues are
used by software to get the status and release
transmitted packets buffers.

This patch also changes the IEEE1588 support as devargs

Signed-off-by: Vanshika Shukla 
Acked-by: Hemant Agrawal 
---
 doc/guides/nics/dpaa.rst   |   3 +
 drivers/net/dpaa/dpaa_ethdev.c | 124 ++---
 drivers/net/dpaa/dpaa_ethdev.h |   4 +-
 drivers/net/dpaa/dpaa_rxtx.c   |  49 +
 drivers/net/dpaa/dpaa_rxtx.h   |   2 +
 5 files changed, 154 insertions(+), 28 deletions(-)

diff --git a/doc/guides/nics/dpaa.rst b/doc/guides/nics/dpaa.rst
index e8402dff52..acf4daab02 100644
--- a/doc/guides/nics/dpaa.rst
+++ b/doc/guides/nics/dpaa.rst
@@ -264,6 +264,9 @@ for details.
   Done
   testpmd>
 
+* Use dev arg option ``drv_ieee1588=1`` to enable ieee 1588 support at
+  driver level. e.g. ``dpaa:fm1-mac3,drv_ieee1588=1``
+
 FMAN Config
 ---
 
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 90b34e42f2..bba305cfb1 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2017-2020 NXP
+ *   Copyright 2017-2020,2022-2024 NXP
  *
  */
 /* System headers */
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -50,6 +51,7 @@
 #include 
 #include 
 
+#define DRIVER_IEEE1588"drv_ieee1588"
 #define CHECK_INTERVAL 100  /* 100ms */
 #define MAX_REPEAT_TIME90   /* 9s (90 * 100ms) in total */
 
@@ -83,6 +85,7 @@ static uint64_t dev_tx_offloads_nodis =
 static int is_global_init;
 static int fmc_q = 1;  /* Indicates the use of static fmc for distribution */
 static int default_q;  /* use default queue - FMC is not executed*/
+int dpaa_ieee_1588;/* use to indicate if IEEE 1588 is enabled for the 
driver */
 /* At present we only allow up to 4 push mode queues as default - as each of
  * this queue need dedicated portal and we are short of portals.
  */
@@ -1826,9 +1829,15 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
opts.fqd.dest.wq = DPAA_IF_TX_PRIORITY;
opts.fqd.fq_ctrl = QM_FQCTRL_PREFERINCACHE;
opts.fqd.context_b = 0;
-   /* no tx-confirmation */
-   opts.fqd.context_a.hi = 0x8000 | fman_dealloc_bufs_mask_hi;
-   opts.fqd.context_a.lo = 0 | fman_dealloc_bufs_mask_lo;
+   if (dpaa_ieee_1588) {
+   opts.fqd.context_a.lo = 0;
+   opts.fqd.context_a.hi = fman_dealloc_bufs_mask_hi;
+   } else {
+   /* no tx-confirmation */
+   opts.fqd.context_a.lo = fman_dealloc_bufs_mask_lo;
+   opts.fqd.context_a.hi = 0x8000 | fman_dealloc_bufs_mask_hi;
+   }
+
if (fman_ip_rev >= FMAN_V3) {
/* Set B0V bit in contextA to set ASPID to 0 */
opts.fqd.context_a.hi |= 0x0400;
@@ -1861,9 +1870,10 @@ static int dpaa_tx_queue_init(struct qman_fq *fq,
return ret;
 }
 
-#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
-/* Initialise a DEBUG FQ ([rt]x_error, rx_default). */
-static int dpaa_debug_queue_init(struct qman_fq *fq, uint32_t fqid)
+/* Initialise a DEBUG FQ ([rt]x_error, rx_default) and DPAA TX CONFIRM queue
+ * to support PTP
+ */
+static int dpaa_def_queue_init(struct qman_fq *fq, uint32_t fqid)
 {
struct qm_mcc_initfq opts = {0};
int ret;
@@ -1872,15 +1882,15 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, 
uint32_t fqid)
 
ret = qman_reserve_fqid(fqid);
if (ret) {
-   DPAA_PMD_ERR("Reserve debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("Reserve fqid %d failed with ret: %d",
fqid, ret);
return -EINVAL;
}
/* "map" this Rx FQ to one of the interfaces Tx FQID */
-   DPAA_PMD_DEBUG("Creating debug fq %p, fqid %d", fq, fqid);
+   DPAA_PMD_DEBUG("Creating fq %p, fqid %d", fq, fqid);
ret = qman_create_fq(fqid, QMAN_FQ_FLAG_NO_ENQUEUE, fq);
if (ret) {
-   DPAA_PMD_ERR("create debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("create fqid %d failed with ret: %d",
fqid, ret);
return ret;
}
@@ -1888,11 +1898,10 @@ static int dpaa_debug_queue_init(struct qman_fq *fq, 
uint32_t fqid)
opts.fqd.dest.wq = DPAA_IF_DEBUG_PRIORITY;
ret = qman_init_fq(fq, 0, &opts);
if (ret)
-   DPAA_PMD_ERR("init debug fqid %d failed with ret: %d",
+   DPAA_PMD_ERR("init fqid %d failed with ret: %d",
fqid, ret);
return ret;
 }
-#endif
 
 /* Initialise a network interfa

[PATCH v2 05/18] bus/dpaa: add port buffer manager stats

2024-08-23 Thread Hemant Agrawal
Add BMI statistics and improving the existing extended
statistics

Signed-off-by: Hemant Agrawal 
Signed-off-by: Gagandeep Singh 
---
 drivers/bus/dpaa/base/fman/fman_hw.c | 61 
 drivers/bus/dpaa/include/fman.h  |  4 +-
 drivers/bus/dpaa/include/fsl_fman.h  | 12 ++
 drivers/bus/dpaa/version.map |  4 ++
 drivers/net/dpaa/dpaa_ethdev.c   | 46 ++---
 drivers/net/dpaa/dpaa_ethdev.h   | 12 ++
 6 files changed, 132 insertions(+), 7 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 97e792806f..124c69edb4 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -267,6 +267,67 @@ fman_if_stats_reset(struct fman_if *p)
;
 }
 
+void
+fman_if_bmi_stats_enable(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   uint32_t tmp;
+
+   tmp = in_be32(®s->fmbm_rstc);
+
+   tmp |= FMAN_BMI_COUNTERS_EN;
+
+   out_be32(®s->fmbm_rstc, tmp);
+}
+
+void
+fman_if_bmi_stats_disable(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   uint32_t tmp;
+
+   tmp = in_be32(®s->fmbm_rstc);
+
+   tmp &= ~FMAN_BMI_COUNTERS_EN;
+
+   out_be32(®s->fmbm_rstc, tmp);
+}
+
+void
+fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+   int i = 0;
+
+   value[i++] = (u32)in_be32(®s->fmbm_rfrc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfbc);
+   value[i++] = (u32)in_be32(®s->fmbm_rlfc);
+   value[i++] = (u32)in_be32(®s->fmbm_rffc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfdc);
+   value[i++] = (u32)in_be32(®s->fmbm_rfldec);
+   value[i++] = (u32)in_be32(®s->fmbm_rodc);
+   value[i++] = (u32)in_be32(®s->fmbm_rbdc);
+}
+
+void
+fman_if_bmi_stats_reset(struct fman_if *p)
+{
+   struct __fman_if *m = container_of(p, struct __fman_if, __if);
+   struct rx_bmi_regs *regs = (struct rx_bmi_regs *)m->bmi_map;
+
+   out_be32(®s->fmbm_rfrc, 0);
+   out_be32(®s->fmbm_rfbc, 0);
+   out_be32(®s->fmbm_rlfc, 0);
+   out_be32(®s->fmbm_rffc, 0);
+   out_be32(®s->fmbm_rfdc, 0);
+   out_be32(®s->fmbm_rfldec, 0);
+   out_be32(®s->fmbm_rodc, 0);
+   out_be32(®s->fmbm_rbdc, 0);
+}
+
 void
 fman_if_promiscuous_enable(struct fman_if *p)
 {
diff --git a/drivers/bus/dpaa/include/fman.h b/drivers/bus/dpaa/include/fman.h
index 3a6dd555a7..60681068ea 100644
--- a/drivers/bus/dpaa/include/fman.h
+++ b/drivers/bus/dpaa/include/fman.h
@@ -56,6 +56,8 @@
 #define FMAN_PORT_BMI_FIFO_UNITS   0x100
 #define FMAN_PORT_IC_OFFSET_UNITS  0x10
 
+#define FMAN_BMI_COUNTERS_EN 0x8000
+
 #define FMAN_ENABLE_BPOOL_DEPLETION0xF0F0
 
 #define HASH_CTRL_MCAST_EN 0x0100
@@ -260,7 +262,7 @@ struct rx_bmi_regs {
/**< Buffer Manager pool Information-*/
uint32_t fmbm_acnt[FMAN_PORT_MAX_EXT_POOLS_NUM];
/**< Allocate Counter-*/
-   uint32_t reserved0130[8];
+   uint32_t reserved0120[16];
/**< 0x130/0x140 - 0x15F reserved -*/
uint32_t fmbm_rcgm[FMAN_PORT_CG_MAP_NUM];
/**< Congestion Group Map*/
diff --git a/drivers/bus/dpaa/include/fsl_fman.h 
b/drivers/bus/dpaa/include/fsl_fman.h
index 20690f8329..5a9750ad0c 100644
--- a/drivers/bus/dpaa/include/fsl_fman.h
+++ b/drivers/bus/dpaa/include/fsl_fman.h
@@ -60,6 +60,18 @@ void fman_if_stats_reset(struct fman_if *p);
 __rte_internal
 void fman_if_stats_get_all(struct fman_if *p, uint64_t *value, int n);
 
+__rte_internal
+void fman_if_bmi_stats_enable(struct fman_if *p);
+
+__rte_internal
+void fman_if_bmi_stats_disable(struct fman_if *p);
+
+__rte_internal
+void fman_if_bmi_stats_get_all(struct fman_if *p, uint64_t *value);
+
+__rte_internal
+void fman_if_bmi_stats_reset(struct fman_if *p);
+
 /* Set ignore pause option for a specific interface */
 void fman_if_set_rx_ignore_pause_frames(struct fman_if *p, bool enable);
 
diff --git a/drivers/bus/dpaa/version.map b/drivers/bus/dpaa/version.map
index 3f547f75cf..a17d57632e 100644
--- a/drivers/bus/dpaa/version.map
+++ b/drivers/bus/dpaa/version.map
@@ -24,6 +24,10 @@ INTERNAL {
fman_dealloc_bufs_mask_hi;
fman_dealloc_bufs_mask_lo;
fman_if_add_mac_addr;
+   fman_if_bmi_stats_enable;
+   fman_if_bmi_stats_disable;
+   fman_if_bmi_stats_get_all;
+   fman_if_bmi_stats_reset;
fman_if_clear_mac_addr;

[PATCH v2 04/18] bus/dpaa: fix the fman details status

2024-08-23 Thread Hemant Agrawal
Fix the incorrect placing of brackets to calculate stats.

This corrects the "(a | b) << 32"  to  "a | (b << 32)"

Fixes: e62a3f4183f1 ("bus/dpaa: fix statistics reading")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman_hw.c | 9 +
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman_hw.c 
b/drivers/bus/dpaa/base/fman/fman_hw.c
index 24a99f7235..97e792806f 100644
--- a/drivers/bus/dpaa/base/fman/fman_hw.c
+++ b/drivers/bus/dpaa/base/fman/fman_hw.c
@@ -243,10 +243,11 @@ fman_if_stats_get_all(struct fman_if *p, uint64_t *value, 
int n)
int i;
uint64_t base_offset = offsetof(struct memac_regs, reoct_l);
 
-   for (i = 0; i < n; i++)
-   value[i] = (((u64)in_be32((char *)regs + base_offset + 8 * i) |
-   (u64)in_be32((char *)regs + base_offset +
-   8 * i + 4)) << 32);
+   for (i = 0; i < n; i++) {
+   uint64_t a = in_be32((char *)regs + base_offset + 8 * i);
+   uint64_t b = in_be32((char *)regs + base_offset + 8 * i + 4);
+   value[i] = a | b << 32;
+   }
 }
 
 void
-- 
2.25.1



[PATCH v2 03/18] bus/dpaa: fix VSP for 1G fm1-mac9 and 10

2024-08-23 Thread Hemant Agrawal
No need to classify interface separately for 1G and 10G
Note that VSP or Virtual storage profile are DPAA equivalent for SRIOV
config to logically divide a physical ports in virtual ports.

Fixes: e0718bb2ca95 ("bus/dpaa: add virtual storage profile port init")
Cc: sta...@dpdk.org

Signed-off-by: Hemant Agrawal 
---
 drivers/bus/dpaa/base/fman/fman.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/dpaa/base/fman/fman.c 
b/drivers/bus/dpaa/base/fman/fman.c
index 41195eb0a7..beeb03dbf2 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -153,7 +153,7 @@ static void fman_if_vsp_init(struct __fman_if *__if)
size_t lenp;
const uint8_t mac_idx[] = {-1, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1};
 
-   if (__if->__if.mac_type == fman_mac_1g) {
+   if (__if->__if.mac_idx <= 8) {
for_each_compatible_node(dev, NULL,
"fsl,fman-port-1g-rx-extended-args") {
prop = of_get_property(dev, "cell-index", &lenp);
@@ -176,7 +176,32 @@ static void fman_if_vsp_init(struct __fman_if *__if)
}
}
}
-   } else if (__if->__if.mac_type == fman_mac_10g) {
+
+   for_each_compatible_node(dev, NULL,
+"fsl,fman-port-op-extended-args") {
+   prop = of_get_property(dev, "cell-index", &lenp);
+
+   if (prop) {
+   cell_index = of_read_number(&prop[0],
+   lenp / sizeof(phandle));
+
+   if (cell_index == __if->__if.mac_idx) {
+   prop = of_get_property(dev,
+  "vsp-window",
+  &lenp);
+
+   if (prop) {
+   __if->__if.num_profiles =
+   of_read_number(&prop[0],
+  1);
+   __if->__if.base_profile_id =
+   of_read_number(&prop[1],
+  1);
+   }
+   }
+   }
+   }
+   } else {
for_each_compatible_node(dev, NULL,
"fsl,fman-port-10g-rx-extended-args") {
prop = of_get_property(dev, "cell-index", &lenp);
-- 
2.25.1



[PATCH v2 02/18] net/dpaa: fix typecasting ch ID to u32

2024-08-23 Thread Hemant Agrawal
From: Rohit Raj 

Avoid typecasting ch_id to u32 and passing it to another API since it
can corrupt other data. Instead, create new u32 variable and typecase
it back to u16 after it gets updated by the API.

Fixes: 0c504f6950b6 ("net/dpaa: support push mode")
Cc: hemant.agra...@nxp.com
Cc: sta...@dpdk.org

Signed-off-by: Rohit Raj 
---
 drivers/net/dpaa/dpaa_ethdev.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index 060b8c678f..1a2de5240f 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -972,7 +972,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
struct fman_if *fif = dev->process_private;
struct qman_fq *rxq = &dpaa_intf->rx_queues[queue_idx];
struct qm_mcc_initfq opts = {0};
-   u32 flags = 0;
+   u32 ch_id, flags = 0;
int ret;
u32 buffsz = rte_pktmbuf_data_room_size(mp) - RTE_PKTMBUF_HEADROOM;
uint32_t max_rx_pktlen;
@@ -1096,7 +1096,9 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, 
uint16_t queue_idx,
DPAA_IF_RX_CONTEXT_STASH;
 
/*Create a channel and associate given queue with the channel*/
-   qman_alloc_pool_range((u32 *)&rxq->ch_id, 1, 1, 0);
+   qman_alloc_pool_range(&ch_id, 1, 1, 0);
+   rxq->ch_id = (u16)ch_id;
+
opts.we_mask = opts.we_mask | QM_INITFQ_WE_DESTWQ;
opts.fqd.dest.channel = rxq->ch_id;
opts.fqd.dest.wq = DPAA_IF_RX_PRIORITY;
-- 
2.25.1



[PATCH v2 01/18] bus/dpaa: fix PFDRs leaks due to FQRNIs

2024-08-23 Thread Hemant Agrawal
From: Gagandeep Singh 

When a Retire FQ command is executed on a FQ in the
Tentatively Scheduled or Parked states, in that case FQ
is retired immediately and a FQRNI (Frame Queue Retirement
Notification Immediate) message is generated. Software
must read this message from MR and consume it to free
the memory used by it.

Although it is not mentioned about which memory to be used
by FQRNIs in the RM but through experiments it is proven
that it can use PFDRs. So if these messages are allowed to
build up indefinitely then PFDR resources can become exhausted
and cause enqueues to stall. Therefore software must consume
these MR messages on a regular basis to avoid depleting
the available PFDR resources.

This is the PFDRs leak issue which user can experienace while
using the DPDK crypto driver and creating and destroying the
sessions multiple times. On a session destroy, DPDK calls the
qman_retire_fq() for each FQ used by the session, but it does
not handle the FQRNIs generated and allowed them to build up
indefinitely in MR.

This patch fixes this issue by consuming the FQRNIs received
from MR immediately after FQ retire by calling drain_mr_fqrni().

Please note that this drain_mr_fqrni() only look for
FQRNI type messages to consume. If there are other type of messages
like FQRN, FQRL, FQPN, ERN etc. also coming on MR then those
messages need to be handled separately.

Fixes: c47ff048b99a ("bus/dpaa: add QMAN driver core routines")
Cc: sta...@dpdk.org

Signed-off-by: Gagandeep Singh 
---
 drivers/bus/dpaa/base/qbman/qman.c | 46 --
 1 file changed, 25 insertions(+), 21 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman.c 
b/drivers/bus/dpaa/base/qbman/qman.c
index 301057723e..9c90ee25a6 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -292,10 +292,32 @@ static inline void qman_stop_dequeues_ex(struct 
qman_portal *p)
qm_dqrr_set_maxfill(&p->p, 0);
 }
 
+static inline void qm_mr_pvb_update(struct qm_portal *portal)
+{
+   register struct qm_mr *mr = &portal->mr;
+   const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
+
+#ifdef RTE_LIBRTE_DPAA_HWDEBUG
+   DPAA_ASSERT(mr->pmode == qm_mr_pvb);
+#endif
+   /* when accessing 'verb', use __raw_readb() to ensure that compiler
+* inlining doesn't try to optimise out "excess reads".
+*/
+   if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
+   mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
+   if (!mr->pi)
+   mr->vbit ^= QM_MR_VERB_VBIT;
+   mr->fill++;
+   res = MR_INC(res);
+   }
+   dcbit_ro(res);
+}
+
 static int drain_mr_fqrni(struct qm_portal *p)
 {
const struct qm_mr_entry *msg;
 loop:
+   qm_mr_pvb_update(p);
msg = qm_mr_current(p);
if (!msg) {
/*
@@ -317,6 +339,7 @@ static int drain_mr_fqrni(struct qm_portal *p)
do {
now = mfatb();
} while ((then + 1) > now);
+   qm_mr_pvb_update(p);
msg = qm_mr_current(p);
if (!msg)
return 0;
@@ -479,27 +502,6 @@ static inline int qm_mr_init(struct qm_portal *portal,
return 0;
 }
 
-static inline void qm_mr_pvb_update(struct qm_portal *portal)
-{
-   register struct qm_mr *mr = &portal->mr;
-   const struct qm_mr_entry *res = qm_cl(mr->ring, mr->pi);
-
-#ifdef RTE_LIBRTE_DPAA_HWDEBUG
-   DPAA_ASSERT(mr->pmode == qm_mr_pvb);
-#endif
-   /* when accessing 'verb', use __raw_readb() to ensure that compiler
-* inlining doesn't try to optimise out "excess reads".
-*/
-   if ((__raw_readb(&res->ern.verb) & QM_MR_VERB_VBIT) == mr->vbit) {
-   mr->pi = (mr->pi + 1) & (QM_MR_SIZE - 1);
-   if (!mr->pi)
-   mr->vbit ^= QM_MR_VERB_VBIT;
-   mr->fill++;
-   res = MR_INC(res);
-   }
-   dcbit_ro(res);
-}
-
 struct qman_portal *
 qman_init_portal(struct qman_portal *portal,
   const struct qm_portal_config *c,
@@ -1794,6 +1796,8 @@ int qman_retire_fq(struct qman_fq *fq, u32 *flags)
}
 out:
FQUNLOCK(fq);
+   /* Draining FQRNIs, if any */
+   drain_mr_fqrni(&p->p);
return rval;
 }
 
-- 
2.25.1



[PATCH v2 00/18] NXP DPAA ETH driver enhancement and fixes

2024-08-23 Thread Hemant Agrawal
v2: address review comments
 - improve commit message
 - add documentarion for new functions
 - make IEEE1588 config runtime

This series adds several enhancement to the NXP DPAA Ethernet driver.

Primarily:
1. timestamp and IEEE 1588 support
2. OH and ONIC based virtual port config in DPAA
3. frame display and debugging infra

Gagandeep Singh (3):
  bus/dpaa: fix PFDRs leaks due to FQRNIs
  net/dpaa: support mempool debug
  net/dpaa: improve the dpaa port cleanup

Hemant Agrawal (5):
  bus/dpaa: fix VSP for 1G fm1-mac9 and 10
  bus/dpaa: fix the fman details status
  bus/dpaa: add port buffer manager stats
  net/dpaa: implement detailed packet parsing
  net/dpaa: enhance DPAA frame display

Jun Yang (2):
  net/dpaa: share MAC FMC scheme and CC parse
  net/dpaa: improve dpaa errata A010022 handling

Rohit Raj (3):
  net/dpaa: fix typecasting ch ID to u32
  bus/dpaa: add OH port mode for dpaa eth
  bus/dpaa: add ONIC port mode for the DPAA eth

Vanshika Shukla (4):
  net/dpaa: support Tx confirmation to enable PTP
  net/dpaa: add support to separate Tx conf queues
  net/dpaa: support Rx/Tx timestamp read
  net/dpaa: support IEEE 1588 PTP

Vinod Pullabhatla (1):
  net/dpaa: add Tx rate limiting DPAA PMD API

 .mailmap  |   1 +
 doc/guides/nics/dpaa.rst  |  64 ++-
 doc/guides/nics/features/dpaa.ini |   3 +
 drivers/bus/dpaa/base/fman/fman.c | 583 +++---
 drivers/bus/dpaa/base/fman/fman_hw.c  | 102 +++-
 drivers/bus/dpaa/base/fman/netcfg_layer.c |  19 +-
 drivers/bus/dpaa/base/qbman/qman.c|  46 +-
 drivers/bus/dpaa/dpaa_bus.c   |  31 +-
 drivers/bus/dpaa/include/fman.h   | 112 -
 drivers/bus/dpaa/include/fsl_fman.h   |  12 +
 drivers/bus/dpaa/include/fsl_qman.h   |   4 +-
 drivers/bus/dpaa/version.map  |   4 +
 drivers/net/dpaa/dpaa_ethdev.c| 428 +---
 drivers/net/dpaa/dpaa_ethdev.h|  68 ++-
 drivers/net/dpaa/dpaa_flow.c  | 150 --
 drivers/net/dpaa/dpaa_fmc.c   | 421 ++--
 drivers/net/dpaa/dpaa_ptp.c   | 119 +
 drivers/net/dpaa/dpaa_rxtx.c  | 376 --
 drivers/net/dpaa/dpaa_rxtx.h  | 152 +++---
 drivers/net/dpaa/fmlib/fm_lib.c   |  32 +-
 drivers/net/dpaa/fmlib/fm_port_ext.h  |   2 +-
 drivers/net/dpaa/meson.build  |   1 +
 drivers/net/dpaa/rte_pmd_dpaa.h   |  25 +-
 drivers/net/dpaa/version.map  |   7 +
 24 files changed, 2250 insertions(+), 512 deletions(-)
 create mode 100644 drivers/net/dpaa/dpaa_ptp.c

-- 
2.25.1



Re: [PATCH v2 0/3] bbdev: sdditional queue stats

2024-08-13 Thread Hemant Agrawal

Series-

Acked-by: Hemant Agrawal 


On 13-08-2024 05:11, Nicolas Chautru wrote:

v2: update to ABI doc suggested by Maxime.

  These series include introducing a new paramter in the queue stat
which can be used to monitor the number of available enqueue
still possible.
The acc PMD is then refactored to use a set of common function
to update several queue status parameters including the new one.
The application is also updated.
Thanks
Nic

Nicolas Chautru (3):
   bbdev: new queue stat for available enqueue depth
   baseband/acc: refactor queue status update
   test/bbdev: update for queue stats

  app/test-bbdev/test_bbdev_perf.c   |  1 +
  doc/guides/rel_notes/release_24_11.rst |  3 ++
  drivers/baseband/acc/acc_common.h  | 18 
  drivers/baseband/acc/rte_acc100_pmd.c  | 45 ++-
  drivers/baseband/acc/rte_vrb_pmd.c | 61 --
  lib/bbdev/rte_bbdev.h  |  2 +
  6 files changed, 56 insertions(+), 74 deletions(-)



Re: [PATCH 00/17] NXP DPAA ETH driver enhancement and fixes

2024-08-08 Thread Hemant Agrawal



On 07-08-2024 21:12, Ferruh Yigit wrote:

On 8/1/2024 11:52 AM, Hemant Agrawal wrote:

This series adds several enhancement to the NXP DPAA Ethernet driver.

Primarily:
1. timestamp and IEEE 1588 support
2. OH and ONIC based virtual port config in DPAA
3. frame display and debugging infra

Gagandeep Singh (3):
   bus/dpaa: fix PFDRs leaks due to FQRNIs
   net/dpaa: support mempool debug
   net/dpaa: improve the dpaa port cleanup

Hemant Agrawal (4):
   bus/dpaa: fix VSP for 1G fm1-mac9 and 10
   bus/dpaa: add port buffer manager stats
   net/dpaa: implement detailed packet parsing
   net/dpaa: enhance DPAA frame display

Jun Yang (2):
   net/dpaa: share MAC FMC scheme and CC parse
   net/dpaa: improve dpaa errata A010022 handling

Rohit Raj (3):
   net/dpaa: fix typecasting ch ID to u32
   bus/dpaa: add OH port mode for dpaa eth
   bus/dpaa: add ONIC port mode for the DPAA eth

Vanshika Shukla (4):
   net/dpaa: support Tx confirmation to enable PTP
   net/dpaa: add support to separate Tx conf queues
   net/dpaa: support Rx/Tx timestamp read
   net/dpaa: support IEEE 1588 PTP

Vinod Pullabhatla (1):
   net/dpaa: add Tx rate limiting DPAA PMD API


There are some new features in this series, it can be good to add
release note update for those.
(But please not as a separate doc update, but each patch adding a
feature can update the document.)


Hi Ferruh,

    Thanks for the detailed review. We will re-work as advised.


Regards,

Hemant




Re: [v1 5/7] net/dpaa2: support FLC stashing API

2024-08-06 Thread Hemant Agrawal

Hi Gagan,


I think this patch shall come before the 4th patch:   [v1 4/7] 
crypto/dpaa2_sec: enhance pdcp FLC handling



- Hemant


On 06-08-2024 14:11, Gagandeep Singh wrote:

From: Jun Yang 

Configure flow steering action with FLC enabled to align stashing
setting with RSS configuration.

Signed-off-by: Jun Yang 
Acked-by: Hemant Agrawal 
---
  drivers/bus/fslmc/portal/dpaa2_hw_pvt.h | 44 +
  drivers/net/dpaa2/dpaa2_ethdev.c| 25 +++---
  2 files changed, 58 insertions(+), 11 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h 
b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
index 169c7917ea..4c30e6db18 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
@@ -179,6 +179,7 @@ struct __rte_cache_aligned dpaa2_queue {
uint16_t resv;
uint64_t offloads;
uint64_t lpbk_cntx;
+   uint8_t data_stashing_off;
  };
  
  struct swp_active_dqs {

@@ -463,6 +464,49 @@ struct qbman_result *get_swp_active_dqs(uint16_t 
dpio_index)
return rte_global_active_dqs_list[dpio_index].global_active_dqs;
  }
  
+/* 00 00 00 - last 6 bit represent data, annotation,

+ * context stashing setting 01 01 00 (0x14)
+ * (in following order ->DS AS CS)
+ * to enable 1 line data, 1 line annotation.
+ * For LX2, this setting should be 01 00 00 (0x10)
+ */
+#define DPAA2_FLC_STASHING_MAX_BIT_SIZE 2
+#define DPAA2_FLC_STASHING_MAX_CACHE_LINE \
+   ((1ULL << DPAA2_FLC_STASHING_MAX_BIT_SIZE) - 1)
+
+enum dpaa2_flc_stashing_type {
+   DPAA2_FLC_CNTX_STASHING = 0,
+   DPAA2_FLC_ANNO_STASHING =
+   DPAA2_FLC_CNTX_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE,
+   DPAA2_FLC_DATA_STASHING =
+   DPAA2_FLC_ANNO_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE,
+   DPAA2_FLC_END_STASHING =
+   DPAA2_FLC_DATA_STASHING + DPAA2_FLC_STASHING_MAX_BIT_SIZE
+};
+
+#define DPAA2_STASHING_ALIGN_SIZE (1 << DPAA2_FLC_END_STASHING)
+
+static inline void
+dpaa2_flc_stashing_set(enum dpaa2_flc_stashing_type type,
+   uint8_t cache_line, uint64_t *flc)
+{
+   RTE_ASSERT(cache_line <= DPAA2_FLC_STASHING_MAX_CACHE_LINE);
+   RTE_ASSERT(type == DPAA2_FLC_CNTX_STASHING ||
+   type == DPAA2_FLC_ANNO_STASHING ||
+   type == DPAA2_FLC_DATA_STASHING);
+
+   (*flc) &= ~(DPAA2_FLC_STASHING_MAX_CACHE_LINE << type);
+   (*flc) |= (cache_line << type);
+}
+
+static inline void
+dpaa2_flc_stashing_clear_all(uint64_t *flc)
+{
+   dpaa2_flc_stashing_set(DPAA2_FLC_CNTX_STASHING, 0, flc);
+   dpaa2_flc_stashing_set(DPAA2_FLC_ANNO_STASHING, 0, flc);
+   dpaa2_flc_stashing_set(DPAA2_FLC_DATA_STASHING, 0, flc);
+}
+
  static inline
  void set_swp_active_dqs(uint16_t dpio_index, struct qbman_result *dqs)
  {
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 449bbda7ca..726bc0cf3e 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -786,17 +786,20 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
if ((dpaa2_svr_family & 0x) != SVR_LS2080A) {
options |= DPNI_QUEUE_OPT_FLC;
cfg.flc.stash_control = true;
-   cfg.flc.value &= 0xFFC0;
-   /* 00 00 00 - last 6 bit represent annotation, context stashing,
-* data stashing setting 01 01 00 (0x14)
-* (in following order ->DS AS CS)
-* to enable 1 line data, 1 line annotation.
-* For LX2, this setting should be 01 00 00 (0x10)
-*/
-   if ((dpaa2_svr_family & 0x) == SVR_LX2160A)
-   cfg.flc.value |= 0x10;
-   else
-   cfg.flc.value |= 0x14;
+   dpaa2_flc_stashing_clear_all(&cfg.flc.value);
+   if (getenv("DPAA2_DATA_STASHING_OFF")) {
+   dpaa2_flc_stashing_set(DPAA2_FLC_DATA_STASHING, 0,
+   &cfg.flc.value);
+   dpaa2_q->data_stashing_off = 1;
+   } else {
+   dpaa2_flc_stashing_set(DPAA2_FLC_DATA_STASHING, 1,
+   &cfg.flc.value);
+   dpaa2_q->data_stashing_off = 0;
+   }
+   if ((dpaa2_svr_family & 0x) != SVR_LX2160A) {
+   dpaa2_flc_stashing_set(DPAA2_FLC_ANNO_STASHING, 1,
+   &cfg.flc.value);
+   }
}
ret = dpni_set_queue(dpni, CMD_PRI_LOW, priv->token, DPNI_QUEUE_RX,
 dpaa2_q->tc_index, flow_id, options, &cfg);


Re: [v1 7/7] crypto/dpaa2_sec: rework debug code

2024-08-06 Thread Hemant Agrawal

Hi Gagan,

On 06-08-2024 14:11, Gagandeep Singh wrote:

From: Jun Yang 

Output debug information according to various modes.

Signed-off-by: Jun Yang 
---
  drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c | 63 -
  1 file changed, 48 insertions(+), 15 deletions(-)

diff --git a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c 
b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
index 1e28c71b53..da3bd871ba 100644
--- a/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
+++ b/drivers/crypto/dpaa2_sec/dpaa2_sec_dpseci.c
@@ -1095,7 +1095,7 @@ build_auth_fd(dpaa2_sec_session *sess, struct 
rte_crypto_op *op,
  
  static int

  build_cipher_sg_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,
-   struct qbman_fd *fd, __rte_unused uint16_t bpid)
+   struct qbman_fd *fd, uint16_t bpid)
  {
struct rte_crypto_sym_op *sym_op = op->sym;
struct qbman_fle *ip_fle, *op_fle, *sge, *fle;
@@ -1105,6 +1105,10 @@ build_cipher_sg_fd(dpaa2_sec_session *sess, struct 
rte_crypto_op *op,
struct rte_mbuf *mbuf;
uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
sess->iv.offset);
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+   char debug_str[1024];
+   int offset;
+#endif
  
  	data_len = sym_op->cipher.data.length;

data_offset = sym_op->cipher.data.offset;
@@ -1210,14 +1214,26 @@ build_cipher_sg_fd(dpaa2_sec_session *sess, struct 
rte_crypto_op *op,
DPAA2_SET_FD_COMPOUND_FMT(fd);
DPAA2_SET_FD_FLC(fd, DPAA2_VADDR_TO_IOVA(flc));
  
-	DPAA2_SEC_DP_DEBUG(

-   "CIPHER SG: fdaddr =%" PRIx64 " bpid =%d meta =%d"
-   " off =%d, len =%d\n",
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+   offset = sprintf(debug_str,
+   "CIPHER SG: fdaddr =%" PRIx64 ", from %s pool ",
DPAA2_GET_FD_ADDR(fd),
-   DPAA2_GET_FD_BPID(fd),
-   rte_dpaa2_bpid_info[bpid].meta_data_size,
-   DPAA2_GET_FD_OFFSET(fd),
-   DPAA2_GET_FD_LEN(fd));
+   bpid < MAX_BPID ? "SW" : "BMAN");
+   if (bpid < MAX_BPID) {
+   offset += sprintf(&debug_str[offset],
+   "bpid = %d ", bpid);
+   }
+   offset += sprintf(&debug_str[offset],
+   "private size = %d ",
+   mbuf->pool->private_data_size);
+   offset += sprintf(&debug_str[offset],
+   "off =%d, len =%d\n",
+   DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_LEN(fd));
+   DPAA2_SEC_DP_DEBUG("%s", debug_str);
+#else
+   RTE_SET_USED(bpid);
+#endif
+
return 0;
  }
  
@@ -1233,6 +1249,10 @@ build_cipher_fd(dpaa2_sec_session *sess, struct rte_crypto_op *op,

uint8_t *iv_ptr = rte_crypto_op_ctod_offset(op, uint8_t *,
sess->iv.offset);
struct rte_mbuf *dst;
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+   char debug_str[1024];
+   int offset;
+#endif
  
  	data_len = sym_op->cipher.data.length;

data_offset = sym_op->cipher.data.offset;
@@ -1324,14 +1344,23 @@ build_cipher_fd(dpaa2_sec_session *sess, struct 
rte_crypto_op *op,
DPAA2_SET_FLE_FIN(sge);
DPAA2_SET_FLE_FIN(fle);
  
-	DPAA2_SEC_DP_DEBUG(

-   "CIPHER: fdaddr =%" PRIx64 " bpid =%d meta =%d"
-   " off =%d, len =%d\n",
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+   offset = sprintf(debug_str,
+   "CIPHER: fdaddr =%" PRIx64 ", from %s pool ",
DPAA2_GET_FD_ADDR(fd),
-   DPAA2_GET_FD_BPID(fd),
-   rte_dpaa2_bpid_info[bpid].meta_data_size,
-   DPAA2_GET_FD_OFFSET(fd),
-   DPAA2_GET_FD_LEN(fd));
+   bpid < MAX_BPID ? "SW" : "BMAN");
+   if (bpid < MAX_BPID) {
+   offset += sprintf(&debug_str[offset],
+   "bpid = %d ", bpid);
+   }
+   offset += sprintf(&debug_str[offset],
+   "private size = %d ",
+   dst->pool->private_data_size);
+   offset += sprintf(&debug_str[offset],
+   "off =%d, len =%d\n",
+   DPAA2_GET_FD_OFFSET(fd), DPAA2_GET_FD_LEN(fd));
+   DPAA2_SEC_DP_DEBUG("%s", debug_str);
+#endif
  
  	return 0;

  }
@@ -1564,6 +1593,10 @@ sec_fd_to_mbuf(const struct qbman_fd *fd, struct 
dpaa2_sec_qp *qp)
struct qbman_fle *fle;
struct rte_crypto_op *op;
struct rte_mbuf *dst, *src;
+#if (RTE_LOG_DEBUG <= RTE_LOG_DP_LEVEL)
+   char debug_str[1024];
+   int offset;
+#endif


you have defined these variables but not used?  have you missed 
something in this patch?



  
  	if (DPAA2_FD_GET_FORMAT(fd) == qbman_fd_single)

return sec_simple_fd_to_mbuf(fd);


[PATCH 17/17] net/dpaa: improve dpaa errata A010022 handling

2024-08-01 Thread Hemant Agrawal
From: Jun Yang 

This patch improves the errata handling for
"RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022"

Signed-off-by: Jun Yang 
---
 drivers/net/dpaa/dpaa_rxtx.c | 40 
 1 file changed, 32 insertions(+), 8 deletions(-)

diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index 84fd0c57a4..325785480a 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1264,6 +1264,35 @@ reallocate_mbuf(struct qman_fq *txq, struct rte_mbuf 
*mbuf)
return new_mbufs[0];
 }
 
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+/* In case the data offset is not multiple of 16,
+ * FMAN can stall because of an errata. So reallocate
+ * the buffer in such case.
+ */
+static inline int
+dpaa_eth_ls1043a_mbuf_realloc(struct rte_mbuf *mbuf)
+{
+   uint64_t len, offset;
+
+   if (dpaa_svr_family != SVR_LS1043A_FAMILY)
+   return 0;
+
+   while (mbuf) {
+   len = mbuf->data_len;
+   offset = mbuf->data_off;
+   if ((mbuf->next &&
+   !rte_is_aligned((void *)len, 16)) ||
+   !rte_is_aligned((void *)offset, 16)) {
+   DPAA_PMD_DEBUG("Errata condition hit");
+
+   return 1;
+   }
+   mbuf = mbuf->next;
+   }
+   return 0;
+}
+#endif
+
 uint16_t
 dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, uint16_t nb_bufs)
 {
@@ -1304,20 +1333,15 @@ dpaa_eth_queue_tx(void *q, struct rte_mbuf **bufs, 
uint16_t nb_bufs)
DPAA_TX_BURST_SIZE : nb_bufs;
for (loop = 0; loop < frames_to_send; loop++) {
mbuf = *(bufs++);
-   /* In case the data offset is not multiple of 16,
-* FMAN can stall because of an errata. So reallocate
-* the buffer in such case.
-*/
-   if (dpaa_svr_family == SVR_LS1043A_FAMILY &&
-   (mbuf->data_off & 0x7F) != 0x0)
-   realloc_mbuf = 1;
-
fd_arr[loop].cmd = 0;
 #if defined(RTE_LIBRTE_IEEE1588)
fd_arr[loop].cmd |= DPAA_FD_CMD_FCO |
qman_fq_fqid(fq_txconf);
fd_arr[loop].cmd |= DPAA_FD_CMD_RPD |
DPAA_FD_CMD_UPD;
+#endif
+#ifdef RTE_LIBRTE_DPAA_ERRATA_LS1043_A010022
+   realloc_mbuf = dpaa_eth_ls1043a_mbuf_realloc(mbuf);
 #endif
seqn = *dpaa_seqn(mbuf);
if (seqn != DPAA_INVALID_MBUF_SEQN) {
-- 
2.25.1



  1   2   3   4   5   6   7   8   9   10   >