DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements
@ 2018-12-27  6:22 Hemant Agrawal
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 01/20] bus/fslmc: fix to reset portal memory before use Hemant Agrawal
                   ` (20 more replies)
  0 siblings, 21 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:22 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

This patch set covers following:

1. Fixes in the existing NXP DPAA2 bus and net pmd
2. New object (DPDMUX) support in NIC driver for better classification
3. Improvements to support secondary process
4. Upgrade the low level QBMAN HW lib

Akhil Goyal (1):
  net/dpaa2: enable optional timestamp in mbuf

Hemant Agrawal (8):
  bus/fslmc: fix to use correct physical core for logical core
  net/dpaa2: fix bad check for not-null
  bus/fslmc: fix to convert error msg to warning
  net/dpaa2: fix device init for secondary process
  bus/fslmc: upgrade to latest qbman library
  bus/fslmc: add dynamic config for memback portal mode
  bus/fslmc: rename portal pi index to consumer index
  bus/fslmc: make portal func static

Nipun Gupta (4):
  net/dpaa2: add dpdmux mc flib
  bus/fslmc: add support for scanning DPDMUX object
  net/dpaa2: add dpdmux initialization and configuration
  net/dpaa2: add API to support custom hash key

Pankaj Chauhan (1):
  bus/fslmc: add function to map any addr via VFIO

Sachin Saxena (1):
  bus/fslmc: fix to reset portal memory before use

Shreyansh Jain (4):
  bus/fslmc: fix parse method for bus devices
  mempool/dpaa2: support saving context of buffer pool
  net/dpaa2: change ref of device to private device
  bus/fslmc: add support for secondary processes

Youri Querry (1):
  bus/fslmc: fix the ring mode to use correct cache settings

 doc/api/doxy-api-index.md                     |   1 +
 doc/api/doxy-api.conf.in                      |   1 +
 drivers/bus/fslmc/fslmc_bus.c                 |  38 +-
 drivers/bus/fslmc/fslmc_vfio.c                |  97 +-
 drivers/bus/fslmc/fslmc_vfio.h                |   1 +
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      | 100 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h      |   2 -
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h       |   6 +-
 .../bus/fslmc/qbman/include/fsl_qbman_base.h  |  11 +-
 drivers/bus/fslmc/qbman/qbman_portal.c        | 123 ++-
 drivers/bus/fslmc/qbman/qbman_portal.h        |   2 +-
 drivers/bus/fslmc/qbman/qbman_sys.h           |  34 +-
 drivers/bus/fslmc/rte_bus_fslmc_version.map   |   7 +
 drivers/bus/fslmc/rte_fslmc.h                 |   1 +
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      |  12 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.h      |   2 +-
 drivers/net/dpaa2/Makefile                    |   4 +
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c        |  54 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  26 +-
 drivers/net/dpaa2/dpaa2_ethdev.h              |   6 +
 drivers/net/dpaa2/dpaa2_mux.c                 | 222 +++++
 drivers/net/dpaa2/dpaa2_rxtx.c                |  41 +-
 drivers/net/dpaa2/mc/dpdmux.c                 | 929 ++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux.h             | 410 ++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h         | 221 +++++
 drivers/net/dpaa2/meson.build                 |   4 +
 drivers/net/dpaa2/rte_pmd_dpaa2.h             |  90 ++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map   |   8 +
 28 files changed, 2317 insertions(+), 136 deletions(-)
 create mode 100644 drivers/net/dpaa2/dpaa2_mux.c
 create mode 100644 drivers/net/dpaa2/mc/dpdmux.c
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux.h
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
 create mode 100644 drivers/net/dpaa2/rte_pmd_dpaa2.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 01/20] bus/fslmc: fix to reset portal memory before use
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
@ 2018-12-27  6:22 ` Hemant Agrawal
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 02/20] bus/fslmc: fix the ring mode to use correct cache settings Hemant Agrawal
                   ` (19 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:22 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Sachin Saxena, stable

From: Sachin Saxena <sachin.saxena@nxp.com>

Uninitialized portal memory is causing unwanted issues.

Fixes: 293c0ca94c36 ("bus/fslmc: support memory backed portals with QBMAN 5.0")
Cc: stable@dpdk.org

Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index ce0699842..4fc6efec5 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -369,6 +369,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 	dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX];
 
 	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
+	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
+
 	if (!dpio_dev->dpio) {
 		DPAA2_BUS_ERR("Memory allocation failure");
 		goto err;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 02/20] bus/fslmc: fix the ring mode to use correct cache settings
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 01/20] bus/fslmc: fix to reset portal memory before use Hemant Agrawal
@ 2018-12-27  6:22 ` Hemant Agrawal
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 03/20] bus/fslmc: fix to use correct physical core for logical core Hemant Agrawal
                   ` (18 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:22 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Youri Querry, stable

From: Youri Querry <youri.querry_1@nxp.com>

The code was incorrectly using the cache inhibited access.
It shall use cached enabled access for better performance.

Fixes: 293c0ca94c36 ("bus/fslmc: support memory backed portals with QBMAN 5.0")
Cc: stable@dpdk.org

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c | 12 ++++++------
 drivers/bus/fslmc/qbman/qbman_sys.h    |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 3380e54f5..bbea37efc 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -683,8 +683,8 @@ static int qbman_swp_enqueue_ring_mode_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 				eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
@@ -809,8 +809,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 					eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
@@ -941,8 +941,8 @@ static int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 					eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index d41af8358..0571097ab 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -55,6 +55,7 @@
 #define QBMAN_CENA_SWP_RR(vb)  (0x700 + ((uint32_t)(vb) >> 1))
 #define QBMAN_CENA_SWP_VDQCR   0x780
 #define QBMAN_CENA_SWP_EQCR_CI 0x840
+#define QBMAN_CENA_SWP_EQCR_CI_MEMBACK 0x1840
 
 /* CENA register offsets in memory-backed mode */
 #define QBMAN_CENA_SWP_DQRR_MEM(n)  (0x800 + ((uint32_t)(n) << 6))
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 03/20] bus/fslmc: fix to use correct physical core for logical core
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 01/20] bus/fslmc: fix to reset portal memory before use Hemant Agrawal
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 02/20] bus/fslmc: fix the ring mode to use correct cache settings Hemant Agrawal
@ 2018-12-27  6:22 ` Hemant Agrawal
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 04/20] net/dpaa2: fix bad check for not-null Hemant Agrawal
                   ` (17 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:22 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

Existing code is using the lcore id as the physical core
id. Add code to get the right physical id.

Also, dpaa2 can not support one lcore mapping to multiple cpus,
print err on such cases.

Fixes: ce9efbf5bb09 ("bus/fslmc: support dynamic logging")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 76 ++++++++++++++++++++----
 1 file changed, 63 insertions(+), 13 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 4fc6efec5..ba2e28ce1 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -53,6 +53,10 @@ static uint32_t io_space_count;
 /* Variable to store DPAA2 platform type */
 uint32_t dpaa2_svr_family;
 
+/* Physical core id for lcores running on dpaa2. */
+/* DPAA2 only support 1 lcore to 1 phy cpu mapping */
+static unsigned int dpaa2_cpu[RTE_MAX_LCORE];
+
 /* Variable to store DPAA2 DQRR size */
 uint8_t dpaa2_dqrr_size;
 /* Variable to store DPAA2 EQCR size */
@@ -92,7 +96,8 @@ dpaa2_core_cluster_sdest(int cpu_id)
 }
 
 #ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
-static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
+static void
+dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, int lcoreid)
 {
 #define STRING_LEN	28
 #define COMMAND_LEN	50
@@ -125,7 +130,7 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
 		return;
 	}
 
-	cpu_mask = cpu_mask << rte_lcore_id();
+	cpu_mask = cpu_mask << dpaa2_cpu[lcoreid];
 	snprintf(command, COMMAND_LEN, "echo %X > /proc/irq/%s/smp_affinity",
 		 cpu_mask, token);
 	ret = system(command);
@@ -139,7 +144,7 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
 	fclose(file);
 }
 
-static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
+static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 {
 	struct epoll_event epoll_ev;
 	int eventfd, dpio_epoll_fd, ret;
@@ -176,32 +181,36 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
 	}
 	dpio_dev->epoll_fd = dpio_epoll_fd;
 
-	dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id);
+	dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id, lcoreid);
 
 	return 0;
 }
 #endif
 
 static int
-dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
+dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 {
 	int sdest, ret;
+	int cpu_id;
 
 	/* Set the Stashing Destination */
-	if (cpu_id < 0) {
-		cpu_id = rte_get_master_lcore();
-		if (cpu_id < 0) {
+	if (lcoreid < 0) {
+		lcoreid = rte_get_master_lcore();
+		if (lcoreid < 0) {
 			DPAA2_BUS_ERR("Getting CPU Index failed");
 			return -1;
 		}
 	}
+
+	cpu_id = dpaa2_cpu[lcoreid];
+
 	/* Set the STASH Destination depending on Current CPU ID.
 	 * Valid values of SDEST are 4,5,6,7. Where,
 	 */
 
 	sdest = dpaa2_core_cluster_sdest(cpu_id);
-	DPAA2_BUS_DEBUG("Portal= %d  CPU= %u SDEST= %d",
-			dpio_dev->index, cpu_id, sdest);
+	DPAA2_BUS_DEBUG("Portal= %d  CPU= %u lcore id =%u SDEST= %d",
+			dpio_dev->index, cpu_id, lcoreid, sdest);
 
 	ret = dpio_set_stashing_destination(dpio_dev->dpio, CMD_PRI_LOW,
 					    dpio_dev->token, sdest);
@@ -211,7 +220,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
 	}
 
 #ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
-	if (dpaa2_dpio_intr_init(dpio_dev)) {
+	if (dpaa2_dpio_intr_init(dpio_dev, lcoreid)) {
 		DPAA2_BUS_ERR("Interrupt registration failed for dpio");
 		return -1;
 	}
@@ -220,7 +229,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
 	return 0;
 }
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id)
+struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
 	int ret;
@@ -236,7 +245,7 @@ struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id)
 	DPAA2_BUS_DEBUG("New Portal %p (%d) affined thread - %lu",
 			dpio_dev, dpio_dev->index, syscall(SYS_gettid));
 
-	ret = dpaa2_configure_stashing(dpio_dev, cpu_id);
+	ret = dpaa2_configure_stashing(dpio_dev, lcoreid);
 	if (ret)
 		DPAA2_BUS_ERR("dpaa2_configure_stashing failed");
 
@@ -340,6 +349,39 @@ dpaa2_affine_qbman_ethrx_swp(void)
 	}
 }
 
+/*
+ * This checks for not supported lcore mappings as well as get the physical
+ * cpuid for the lcore.
+ * one lcore can only map to 1 cpu i.e. 1@10-14 not supported.
+ * one cpu can be mapped to more than one lcores.
+ */
+static int
+dpaa2_check_lcore_cpuset(void)
+{
+	unsigned int lcore_id, i;
+	int ret = 0;
+
+	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
+		dpaa2_cpu[lcore_id] = 0xffffffff;
+
+	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
+		for (i = 0; i < RTE_MAX_LCORE; i++) {
+			if (CPU_ISSET(i, &lcore_config[lcore_id].cpuset)) {
+				RTE_LOG(DEBUG, EAL, "lcore id = %u cpu=%u\n",
+					lcore_id, i);
+				if (dpaa2_cpu[lcore_id] != 0xffffffff) {
+					DPAA2_BUS_ERR(
+				    "ERR:lcore map to multi-cpu not supported");
+					ret = -1;
+				} else  {
+					dpaa2_cpu[lcore_id] = i;
+				}
+			}
+		}
+	}
+	return ret;
+}
+
 static int
 dpaa2_create_dpio_device(int vdev_fd,
 			 struct vfio_device_info *obj_info,
@@ -349,6 +391,7 @@ dpaa2_create_dpio_device(int vdev_fd,
 	struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)};
 	struct qbman_swp_desc p_des;
 	struct dpio_attr attr;
+	static int check_lcore_cpuset;
 
 	if (obj_info->num_regions < NUM_DPIO_REGIONS) {
 		DPAA2_BUS_ERR("Not sufficient number of DPIO regions");
@@ -368,6 +411,13 @@ dpaa2_create_dpio_device(int vdev_fd,
 	/* Using single portal  for all devices */
 	dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX];
 
+	if (!check_lcore_cpuset) {
+		check_lcore_cpuset = 1;
+
+		if (dpaa2_check_lcore_cpuset() < 0)
+			goto err;
+	}
+
 	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
 	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 04/20] net/dpaa2: fix bad check for not-null
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (2 preceding siblings ...)
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 03/20] bus/fslmc: fix to use correct physical core for logical core Hemant Agrawal
@ 2018-12-27  6:22 ` Hemant Agrawal
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 05/20] bus/fslmc: fix to convert error msg to warning Hemant Agrawal
                   ` (16 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:22 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

The check !dpaa2->cscn is not correct to check non-null value.

Fixes: 5d9a1e4d23fe ("net/dpaa2: enhance queue memory cleanup")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index fa71807e6..8d4ea1bca 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -311,8 +311,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
 		/* cleanup tx queue cscn */
 		for (i = 0; i < priv->nb_tx_queues; i++) {
 			dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
-			if (!dpaa2_q->cscn)
-				rte_free(dpaa2_q->cscn);
+			rte_free(dpaa2_q->cscn);
 		}
 		/*free memory for all queues (RX+TX) */
 		rte_free(priv->rx_vq[0]);
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 05/20] bus/fslmc: fix to convert error msg to warning
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (3 preceding siblings ...)
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 04/20] net/dpaa2: fix bad check for not-null Hemant Agrawal
@ 2018-12-27  6:22 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 06/20] bus/fslmc: fix parse method for bus devices Hemant Agrawal
                   ` (15 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:22 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

This is just a information. No need to print
it as a error.

Fixes: ce9efbf5bb09 ("bus/fslmc: support dynamic logging")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 493b6e5be..ce82a99f6 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -176,7 +176,7 @@ static int vfio_map_irq_region(struct fslmc_vfio_group *group)
 	vaddr = (unsigned long *)mmap(NULL, 0x1000, PROT_WRITE |
 		PROT_READ, MAP_SHARED, container_device_fd, 0x6030000);
 	if (vaddr == MAP_FAILED) {
-		DPAA2_BUS_ERR("Unable to map region (errno = %d)", errno);
+		DPAA2_BUS_INFO("Unable to map region (errno = %d)", errno);
 		return -errno;
 	}
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 06/20] bus/fslmc: fix parse method for bus devices
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (4 preceding siblings ...)
  2018-12-27  6:22 ` [dpdk-dev] [PATCH 05/20] bus/fslmc: fix to convert error msg to warning Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 07/20] net/dpaa2: fix device init for secondary process Hemant Agrawal
                   ` (14 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

From: Shreyansh Jain <shreyansh.jain@nxp.com>

Current code expects that bus->parse() would get a string containing
the name of the bus. That is incorrect. bus->parse() is expected
to have strings like:
  dpni.1,key=val
  dpio.2,key=val

when user passed:
  -b fslmc:dpni.1,key=val

This commit fixes this behavior.

Fixes: 50245be05d1a ("bus/fslmc: support device blacklisting")
Cc: stable@dpdk.org

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 89af9385a..565e0148f 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- *   Copyright 2016 NXP
+ *   Copyright 2016,2018 NXP
  *
  */
 
@@ -227,20 +227,16 @@ static int
 rte_fslmc_parse(const char *name, void *addr)
 {
 	uint16_t dev_id;
-	char *t_ptr;
-	char *sep = strchr(name, ':');
+	char *t_ptr = NULL, *dname = NULL;
 
-	if (strncmp(name, RTE_STR(FSLMC_BUS_NAME),
-		strlen(RTE_STR(FSLMC_BUS_NAME)))) {
-		return -EINVAL;
-	}
+	/* 'name' is expected to contain name of device, for example, dpio.1,
+	 * dpni.2, etc.
+	 */
 
-	if (!sep) {
-		DPAA2_BUS_ERR("Incorrect device name observed");
+	dname = strdup(name);
+	if (!dname)
 		return -EINVAL;
-	}
-
-	t_ptr = (char *)(sep + 1);
+	t_ptr = dname;
 
 	if (strncmp("dpni", t_ptr, 4) &&
 	    strncmp("dpseci", t_ptr, 6) &&
@@ -251,24 +247,29 @@ rte_fslmc_parse(const char *name, void *addr)
 	    strncmp("dpmcp", t_ptr, 5) &&
 	    strncmp("dpdmai", t_ptr, 6)) {
 		DPAA2_BUS_ERR("Unknown or unsupported device");
-		return -EINVAL;
+		goto err_out;
 	}
 
 	t_ptr = strchr(name, '.');
 	if (!t_ptr) {
 		DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
-		return -EINVAL;
+		goto err_out;
 	}
 
 	t_ptr = (char *)(t_ptr + 1);
 	if (sscanf(t_ptr, "%hu", &dev_id) <= 0) {
 		DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
-		return -EINVAL;
+		goto err_out;
 	}
+	free(dname);
 
 	if (addr)
-		strcpy(addr, (char *)(sep + 1));
+		strcpy(addr, name);
+
 	return 0;
+err_out:
+	free(dname);
+	return -EINVAL;
 }
 
 static int
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 07/20] net/dpaa2: fix device init for secondary process
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (5 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 06/20] bus/fslmc: fix parse method for bus devices Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 08/20] net/dpaa2: enable optional timestamp in mbuf Hemant Agrawal
                   ` (13 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

In order to support I/O from secondary process, the
burst APIs and OPS APIs shall be mapped/plugged.

Fixes: c147eae01cb3 ("net/dpaa2: introduce NXP DPAA2 driver")
Cc: stable@dpdk.org

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 8d4ea1bca..39f85ae7b 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1918,8 +1918,15 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* For secondary processes, the primary has done all the work */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		/* In case of secondary, only burst and ops API need to be
+		 * plugged.
+		 */
+		eth_dev->dev_ops = &dpaa2_ethdev_ops;
+		eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
+		eth_dev->tx_pkt_burst = dpaa2_dev_tx;
 		return 0;
+	}
 
 	dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 08/20] net/dpaa2: enable optional timestamp in mbuf
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (6 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 07/20] net/dpaa2: fix device init for secondary process Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 09/20] bus/fslmc: upgrade to latest qbman library Hemant Agrawal
                   ` (12 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Akhil Goyal

From: Akhil Goyal <akhil.goyal@nxp.com>

This patch enables the population of timestamp field
in mbuf on packet receive.
It may give performance impact on LX2xxx platforms.
So, it has been made optional for Lx2xxx platform.
One shall call, rte_dpaa2_enable_ts() to enable it.

Nothing is required for LS2 and LS1088 platforms.

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
 doc/api/doxy-api-index.md                   |  1 +
 doc/api/doxy-api.conf.in                    |  1 +
 drivers/net/dpaa2/Makefile                  |  2 ++
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c      |  2 ++
 drivers/net/dpaa2/dpaa2_ethdev.c            |  9 +++++
 drivers/net/dpaa2/dpaa2_ethdev.h            |  4 +++
 drivers/net/dpaa2/dpaa2_rxtx.c              | 18 ++++++++++
 drivers/net/dpaa2/meson.build               |  2 ++
 drivers/net/dpaa2/rte_pmd_dpaa2.h           | 39 +++++++++++++++++++++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |  6 ++++
 10 files changed, 84 insertions(+)
 create mode 100644 drivers/net/dpaa2/rte_pmd_dpaa2.h

diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index e27874c5a..d95ad566c 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -43,6 +43,7 @@ The public API headers are grouped by topics:
   [i40e]               (@ref rte_pmd_i40e.h),
   [bnxt]               (@ref rte_pmd_bnxt.h),
   [dpaa]               (@ref rte_pmd_dpaa.h),
+  [dpaa2]              (@ref rte_pmd_dpaa2.h),
   [dpaa2_mempool]      (@ref rte_dpaa2_mempool.h),
   [dpaa2_cmdif]        (@ref rte_pmd_dpaa2_cmdif.h),
   [dpaa2_qdma]         (@ref rte_pmd_dpaa2_qdma.h),
diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index 77ba327a8..bef9320c0 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -9,6 +9,7 @@ INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \
                           @TOPDIR@/drivers/net/bnxt \
                           @TOPDIR@/drivers/net/bonding \
                           @TOPDIR@/drivers/net/dpaa \
+                          @TOPDIR@/drivers/net/dpaa2 \
                           @TOPDIR@/drivers/net/i40e \
                           @TOPDIR@/drivers/net/ixgbe \
                           @TOPDIR@/drivers/net/softnic \
diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index ca5f7a336..2b9c011d6 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -42,4 +42,6 @@ LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
 LDLIBS += -lrte_common_dpaax
 
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_DPAA2_PMD)-include := rte_pmd_dpaa2.h
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
index 713a41bf3..a6f86df8c 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
@@ -296,8 +296,10 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
 			 DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
 			 DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
 			 DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
+			 DPNI_BUF_LAYOUT_OPT_TIMESTAMP |
 			 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
 
+	layout.pass_timestamp = true;
 	layout.pass_frame_status = 1;
 	layout.private_data_size = DPAA2_FD_PTA_SIZE;
 	layout.pass_parser_result = 1;
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 39f85ae7b..861fbcd90 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -56,6 +56,9 @@ static uint64_t dev_tx_offloads_nodis =
 		DEV_TX_OFFLOAD_MT_LOCKFREE |
 		DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+/* enable timestamp in mbuf */
+enum pmd_dpaa2_ts dpaa2_enable_ts;
+
 struct rte_dpaa2_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	uint8_t page_id; /* dpni statistics page id */
@@ -88,6 +91,12 @@ static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 int dpaa2_logtype_pmd;
 
+__rte_experimental void
+rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable)
+{
+	dpaa2_enable_ts = enable;
+}
+
 static int
 dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 {
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index bd69f523d..7cf6e4191 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -9,6 +9,7 @@
 #define _DPAA2_ETHDEV_H
 
 #include <rte_event_eth_rx_adapter.h>
+#include <rte_pmd_dpaa2.h>
 
 #include <mc/fsl_dpni.h>
 #include <mc/fsl_mc_sys.h>
@@ -83,6 +84,9 @@
 #define DPAA2_PKT_TYPE_VLAN_1		0x0160
 #define DPAA2_PKT_TYPE_VLAN_2		0x0260
 
+/* enable timestamp in mbuf*/
+extern enum pmd_dpaa2_ts dpaa2_enable_ts;
+
 struct dpaa2_dev_priv {
 	void *hw;
 	int32_t hw_id;
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index eab943dcf..816ea00fd 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -42,6 +42,7 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf,
 static inline void __attribute__((hot))
 dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd)
 {
+	struct dpaa2_annot_hdr *annotation;
 	uint16_t frc = DPAA2_GET_FD_FRC_PARSE_SUM(fd);
 
 	m->packet_type = RTE_PTYPE_UNKNOWN;
@@ -104,6 +105,19 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd)
 	}
 	m->hash.rss = fd->simple.flc_hi;
 	m->ol_flags |= PKT_RX_RSS_HASH;
+
+	if (dpaa2_enable_ts == PMD_DPAA2_ENABLE_TS) {
+		annotation = (struct dpaa2_annot_hdr *)
+			((size_t)DPAA2_IOVA_TO_VADDR(
+			DPAA2_GET_FD_ADDR(fd)) + DPAA2_FD_PTA_SIZE);
+		m->timestamp = annotation->word2;
+		m->ol_flags |= PKT_RX_TIMESTAMP;
+		DPAA2_PMD_DP_DEBUG("pkt timestamp:0x%" PRIx64 "", m->timestamp);
+	}
+
+	DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
+		"ol_flags =0x%" PRIx64 "",
+		frc, m->packet_type, m->ol_flags);
 }
 
 static inline uint32_t __attribute__((hot))
@@ -205,6 +219,10 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)
 	else if (BIT_ISSET_AT_POS(annotation->word8, DPAA2_ETH_FAS_L4CE))
 		mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
+	mbuf->ol_flags |= PKT_RX_TIMESTAMP;
+	mbuf->timestamp = annotation->word2;
+	DPAA2_PMD_DP_DEBUG("pkt timestamp: 0x%" PRIx64 "", mbuf->timestamp);
+
 	/* Check detailed parsing requirement */
 	if (annotation->word3 & 0x7FFFFC3FFFF)
 		return dpaa2_dev_rx_parse_slow(mbuf, annotation);
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index b34595258..07aada87c 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -18,3 +18,5 @@ includes += include_directories('base', 'mc')
 
 # depends on fslmc bus which uses experimental API
 allow_experimental_apis = true
+
+install_headers('rte_pmd_dpaa2.h')
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
new file mode 100644
index 000000000..f9303acad
--- /dev/null
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#ifndef _RTE_PMD_DPAA2_H
+#define _RTE_PMD_DPAA2_H
+
+/**
+ * @file rte_pmd_dpaa2.h
+ *
+ * NXP dpaa2 PMD specific functions.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ */
+
+#include <rte_flow.h>
+
+enum pmd_dpaa2_ts {
+	PMD_DPAA2_DISABLE_TS,
+	PMD_DPAA2_ENABLE_TS
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Enable/Disable timestamping update in mbuf for LX2160 kind of devices.
+ * For LS2088/LS1088 devices, timestamping will be updated in mbuf without
+ * calling this API.
+ *
+ * @param pmd_dpaa2_ts
+ *    Enum to enable/disable timestamp update in mbuf for LX2160 devices.
+ */
+__rte_experimental
+void rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts);
+
+#endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index 09f4364bc..de95a03cd 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -10,3 +10,9 @@ DPDK_17.11 {
 	dpaa2_eth_eventq_detach;
 
 } DPDK_17.05;
+
+EXPERIMENTAL {
+	global:
+
+	rte_pmd_dpaa2_set_timestamp;
+} DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 09/20] bus/fslmc: upgrade to latest qbman library
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (7 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 08/20] net/dpaa2: enable optional timestamp in mbuf Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 10/20] bus/fslmc: add dynamic config for memback portal mode Hemant Agrawal
                   ` (11 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Youri Querry, Nipun Gupta

This patch upgrades and sync the dpdk based qbman code
with new version of qbman flib.

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c |  8 ++++----
 drivers/bus/fslmc/qbman/qbman_sys.h    | 17 +++++++++++------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index bbea37efc..2f572a08b 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -201,7 +201,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	p->vdq.valid_bit = QB_VALID_BIT;
 	p->dqrr.valid_bit = QB_VALID_BIT;
 	qman_version = p->desc.qman_version;
-	if ((qman_version & 0xFFFF0000) < QMAN_REV_4100) {
+	if ((qman_version & QMAN_REV_MASK) < QMAN_REV_4100) {
 		p->dqrr.dqrr_size = 4;
 		p->dqrr.reset_bug = 1;
 	} else {
@@ -1315,9 +1315,9 @@ const struct qbman_result *qbman_swp_dqrr_next_mem_back(struct qbman_swp *s)
 	 */
 	flags = p->dq.stat;
 	response_verb = verb & QBMAN_RESPONSE_VERB_MASK;
-	if ((response_verb == QBMAN_RESULT_DQ) &&
-	    (flags & QBMAN_DQ_STAT_VOLATILE) &&
-	    (flags & QBMAN_DQ_STAT_EXPIRED))
+	if ((response_verb == QBMAN_RESULT_DQ)
+			&& (flags & QBMAN_DQ_STAT_VOLATILE)
+			&& (flags & QBMAN_DQ_STAT_EXPIRED))
 		atomic_inc(&s->vdq.busy);
 	return p;
 }
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index 0571097ab..e3bd1c5e6 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -387,6 +387,10 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 {
 	uint32_t reg;
 	int i;
+	int cena_region_size = 4*1024;
+
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+		cena_region_size = 64*1024;
 #ifdef RTE_ARCH_64
 	uint8_t wn = CENA_WRITE_ENABLE;
 #else
@@ -396,7 +400,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	s->addr_cena = d->cena_bar;
 	s->addr_cinh = d->cinh_bar;
 	s->idx = (uint32_t)d->idx;
-	s->cena = malloc(64*1024);
+	s->cena = malloc(cena_region_size);
+
 	if (!s->cena) {
 		pr_err("Could not allocate page for cena shadow\n");
 		return -1;
@@ -412,12 +417,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	QBMAN_BUG_ON(reg);
 #endif
 	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
-		memset(s->addr_cena, 0, 64*1024);
+		memset(s->addr_cena, 0, cena_region_size);
 	else {
 		/* Invalidate the portal memory.
 		 * This ensures no stale cache lines
 		 */
-		for (i = 0; i < 0x1000; i += 64)
+		for (i = 0; i < cena_region_size; i += 64)
 			dccivac(s->addr_cena + i);
 	}
 
@@ -425,12 +430,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 		reg = qbman_set_swp_cfg(dqrr_size, wn,
 					0, 3, 2, 3, 1, 1, 1, 1, 1, 1);
 	else {
-		if ((d->qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
+		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
-						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
+						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
 		else
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
-						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
+						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
 	}
 
 	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 10/20] bus/fslmc: add dynamic config for memback portal mode
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (8 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 09/20] bus/fslmc: upgrade to latest qbman library Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 11/20] bus/fslmc: rename portal pi index to consumer index Hemant Agrawal
                   ` (10 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Roy Pledge, Youri Querry

Add flag in portal init to adjust the qbman memory type,
to decide between legacy portal mode or newly introduced
memory backed portals.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |  2 +
 .../bus/fslmc/qbman/include/fsl_qbman_base.h  | 11 +++-
 drivers/bus/fslmc/qbman/qbman_portal.c        | 52 +++++++++++--------
 drivers/bus/fslmc/qbman/qbman_sys.h           | 20 ++++---
 4 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index ba2e28ce1..37723a094 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -509,6 +509,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 	p_des.cinh_bar = (void *)(dpio_dev->qbman_portal_ci_paddr);
 	p_des.irq = -1;
 	p_des.qman_version = attr.qbman_version;
+	p_des.eqcr_mode = qman_eqcr_vb_ring;
+	p_des.cena_access_mode = qman_cena_fastest_access;
 
 	dpio_dev->sw_portal = qbman_swp_init(&p_des);
 	if (dpio_dev->sw_portal == NULL) {
diff --git a/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h b/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
index bb60a98f9..48bdaafa4 100644
--- a/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
+++ b/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Copyright 2017-2018 NXP
  *
  */
 #ifndef _FSL_QBMAN_BASE_H
@@ -33,7 +34,12 @@ struct qbman_block_desc {
 
 enum qbman_eqcr_mode {
 	qman_eqcr_vb_ring = 2, /* Valid bit, with eqcr in ring mode */
-	qman_eqcr_vb_array, /* Valid bit, with eqcr in array mode */
+	qman_eqcr_vb_array,    /* Valid bit, with eqcr in array mode */
+};
+
+enum qbman_cena_access_mode {
+	qman_cena_fastest_access = 0, /* Use memory backed node if available */
+	qman_cena_direct_access,      /* Use direct access to the CENA region */
 };
 
 /**
@@ -46,6 +52,8 @@ enum qbman_eqcr_mode {
  * @qman_version: the qman version.
  * @eqcr_mode: Select the eqcr mode, currently only valid bit ring mode and
  * valid bit array mode are supported.
+ * @cena_access_mode: Mode used to access the CENA region, direct
+ *                    or memory backed.
  *
  * Descriptor for a QBMan software portal, expressed in terms that make sense to
  * the user context. Ie. on MC, this information is likely to be true-physical,
@@ -62,6 +70,7 @@ struct qbman_swp_desc {
 	int idx;
 	uint32_t qman_version;
 	enum qbman_eqcr_mode eqcr_mode;
+	enum qbman_cena_access_mode cena_access_mode;
 };
 
 /* Driver object for managing a QBMan portal */
diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 2f572a08b..08bfdc9f8 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -194,7 +194,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	p->sdq |= qbman_sdqcr_dct_prio_ics << QB_SDQCR_DCT_SHIFT;
 	p->sdq |= qbman_sdqcr_fc_up_to_3 << QB_SDQCR_FC_SHIFT;
 	p->sdq |= QMAN_SDQCR_TOKEN << QB_SDQCR_TOK_SHIFT;
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		p->mr.valid_bit = QB_VALID_BIT;
 
 	atomic_set(&p->vdq.busy, 1);
@@ -233,7 +234,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_SDQCR, 0);
 
 	p->eqcr.pi_ring_size = 8;
-	if ((qman_version & 0xFFFF0000) >= QMAN_REV_5000) {
+	if ((qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access)) {
 		p->eqcr.pi_ring_size = 32;
 		qbman_swp_enqueue_array_mode_ptr =
 				qbman_swp_enqueue_array_mode_mem_back;
@@ -253,7 +255,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	eqcr_pi = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI);
 	p->eqcr.pi = eqcr_pi & p->eqcr.pi_mask;
 	p->eqcr.pi_vb = eqcr_pi & QB_VALID_BIT;
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		p->eqcr.ci = qbman_cinh_read(&p->sys,
 				QBMAN_CINH_SWP_EQCR_CI) & p->eqcr.pi_mask;
 	else
@@ -362,10 +365,11 @@ void *qbman_swp_mc_start(struct qbman_swp *p)
 #ifdef QBMAN_CHECKING
 	QBMAN_BUG_ON(p->mc.check != swp_mc_can_start);
 #endif
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
-		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR);
-	else
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		    && (p->desc.cena_access_mode == qman_cena_fastest_access))
 		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR_MEM);
+	else
+		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR);
 #ifdef QBMAN_CHECKING
 	if (!ret)
 		p->mc.check = swp_mc_can_submit;
@@ -385,16 +389,17 @@ void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint8_t cmd_verb)
 	 * caller wants to OR but has forgotten to do so.
 	 */
 	QBMAN_BUG_ON((*v & cmd_verb) != *v);
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000) {
-		dma_wmb();
-		*v = cmd_verb | p->mc.valid_bit;
-		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR, cmd);
-		clean(cmd);
-	} else {
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		    && (p->desc.cena_access_mode == qman_cena_fastest_access)) {
 		*v = cmd_verb | p->mr.valid_bit;
 		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR_MEM, cmd);
 		dma_wmb();
 		qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_CR_RT, QMAN_RT_MODE);
+	} else {
+		dma_wmb();
+		*v = cmd_verb | p->mc.valid_bit;
+		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR, cmd);
+		clean(cmd);
 	}
 #ifdef QBMAN_CHECKING
 	p->mc.check = swp_mc_can_poll;
@@ -407,30 +412,31 @@ void *qbman_swp_mc_result(struct qbman_swp *p)
 #ifdef QBMAN_CHECKING
 	QBMAN_BUG_ON(p->mc.check != swp_mc_can_poll);
 #endif
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000) {
-		qbman_cena_invalidate_prefetch(&p->sys,
-				QBMAN_CENA_SWP_RR(p->mc.valid_bit));
-		ret = qbman_cena_read(&p->sys,
-				QBMAN_CENA_SWP_RR(p->mc.valid_bit));
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		&& (p->desc.cena_access_mode == qman_cena_fastest_access)) {
+		ret = qbman_cena_read(&p->sys, QBMAN_CENA_SWP_RR_MEM);
+		/* Command completed if the valid bit is toggled */
+		if (p->mr.valid_bit != (ret[0] & QB_VALID_BIT))
+			return NULL;
 		/* Remove the valid-bit -
 		 * command completed iff the rest is non-zero
 		 */
 		verb = ret[0] & ~QB_VALID_BIT;
 		if (!verb)
 			return NULL;
-		p->mc.valid_bit ^= QB_VALID_BIT;
+		p->mr.valid_bit ^= QB_VALID_BIT;
 	} else {
-		ret = qbman_cena_read(&p->sys, QBMAN_CENA_SWP_RR_MEM);
-		/* Command completed if the valid bit is toggled */
-		if (p->mr.valid_bit != (ret[0] & QB_VALID_BIT))
-			return NULL;
+		qbman_cena_invalidate_prefetch(&p->sys,
+			QBMAN_CENA_SWP_RR(p->mc.valid_bit));
+		ret = qbman_cena_read(&p->sys,
+				      QBMAN_CENA_SWP_RR(p->mc.valid_bit));
 		/* Remove the valid-bit -
 		 * command completed iff the rest is non-zero
 		 */
 		verb = ret[0] & ~QB_VALID_BIT;
 		if (!verb)
 			return NULL;
-		p->mr.valid_bit ^= QB_VALID_BIT;
+		p->mc.valid_bit ^= QB_VALID_BIT;
 	}
 #ifdef QBMAN_CHECKING
 	p->mc.check = swp_mc_can_start;
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index e3bd1c5e6..71f7a6782 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -389,7 +389,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	int i;
 	int cena_region_size = 4*1024;
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		cena_region_size = 64*1024;
 #ifdef RTE_ARCH_64
 	uint8_t wn = CENA_WRITE_ENABLE;
@@ -416,7 +417,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
 	QBMAN_BUG_ON(reg);
 #endif
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		memset(s->addr_cena, 0, cena_region_size);
 	else {
 		/* Invalidate the portal memory.
@@ -426,11 +428,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 			dccivac(s->addr_cena + i);
 	}
 
-	if (s->eqcr_mode == qman_eqcr_vb_array)
+	if (s->eqcr_mode == qman_eqcr_vb_array) {
 		reg = qbman_set_swp_cfg(dqrr_size, wn,
 					0, 3, 2, 3, 1, 1, 1, 1, 1, 1);
-	else {
-		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	} else {
+		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000 &&
+			    (d->cena_access_mode == qman_cena_fastest_access))
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
 						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
 		else
@@ -438,11 +441,11 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
 	}
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		reg |= 1 << SWP_CFG_CPBS_SHIFT | /* memory-backed mode */
 		       1 << SWP_CFG_VPM_SHIFT |  /* VDQCR read triggered mode */
 		       1 << SWP_CFG_CPM_SHIFT;   /* CR read triggered mode */
-	}
 
 	qbman_cinh_write(s, QBMAN_CINH_SWP_CFG, reg);
 	reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
@@ -452,7 +455,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 		return -1;
 	}
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access)) {
 		qbman_cinh_write(s, QBMAN_CINH_SWP_EQCR_PI, QMAN_RT_MODE);
 		qbman_cinh_write(s, QBMAN_CINH_SWP_RCR_PI, QMAN_RT_MODE);
 	}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 11/20] bus/fslmc: rename portal pi index to consumer index
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (9 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 10/20] bus/fslmc: add dynamic config for memback portal mode Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 12/20] bus/fslmc: make portal func static Hemant Agrawal
                   ` (9 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Youri Querry

This is to align with the latest qbman hw library

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c | 51 +++++++++++---------------
 drivers/bus/fslmc/qbman/qbman_portal.h |  2 +-
 2 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 08bfdc9f8..14f4b0344 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -251,21 +251,21 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	}
 
 	for (mask_size = p->eqcr.pi_ring_size; mask_size > 0; mask_size >>= 1)
-		p->eqcr.pi_mask = (p->eqcr.pi_mask<<1) + 1;
+		p->eqcr.pi_ci_mask = (p->eqcr.pi_ci_mask<<1) + 1;
 	eqcr_pi = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI);
-	p->eqcr.pi = eqcr_pi & p->eqcr.pi_mask;
+	p->eqcr.pi = eqcr_pi & p->eqcr.pi_ci_mask;
 	p->eqcr.pi_vb = eqcr_pi & QB_VALID_BIT;
 	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
 			&& (d->cena_access_mode == qman_cena_fastest_access))
-		p->eqcr.ci = qbman_cinh_read(&p->sys,
-				QBMAN_CINH_SWP_EQCR_CI) & p->eqcr.pi_mask;
+		p->eqcr.ci = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI)
+					     & p->eqcr.pi_ci_mask;
 	else
-		p->eqcr.ci = qbman_cinh_read(&p->sys,
-				QBMAN_CINH_SWP_EQCR_PI) & p->eqcr.pi_mask;
+		p->eqcr.ci = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_CI)
+					     & p->eqcr.pi_ci_mask;
 	p->eqcr.available = p->eqcr.pi_ring_size -
 				qm_cyc_diff(p->eqcr.pi_ring_size,
-				p->eqcr.ci & (p->eqcr.pi_mask<<1),
-				p->eqcr.pi & (p->eqcr.pi_mask<<1));
+				p->eqcr.ci & (p->eqcr.pi_ci_mask<<1),
+				p->eqcr.pi & (p->eqcr.pi_ci_mask<<1));
 
 	portal_idx_map[p->desc.idx] = p;
 	return p;
@@ -646,8 +646,8 @@ static int qbman_swp_enqueue_ring_mode_direct(struct qbman_swp *s,
 	const uint32_t *cl = qb_cl(d);
 	uint32_t eqcr_ci, full_mask, half_mask;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -685,8 +685,8 @@ static int qbman_swp_enqueue_ring_mode_mem_back(struct qbman_swp *s,
 	const uint32_t *cl = qb_cl(d);
 	uint32_t eqcr_ci, full_mask, half_mask;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -743,8 +743,8 @@ static int qbman_swp_enqueue_multiple_direct(struct qbman_swp *s,
 	int i, num_enqueued = 0;
 	uint64_t addr_cena;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -811,8 +811,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 	uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask;
 	int i, num_enqueued = 0;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -833,15 +833,6 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 				QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask));
 		memcpy(&p[1], &cl[1], 28);
 		memcpy(&p[8], &fd[i], sizeof(*fd));
-		eqcr_pi++;
-	}
-
-	/* Set the verb byte, have to substitute in the valid-bit */
-	eqcr_pi = s->eqcr.pi;
-	for (i = 0; i < num_enqueued; i++) {
-		p = qbman_cena_write_start_wo_shadow(&s->sys,
-				QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask));
-		p[0] = cl[0] | s->eqcr.pi_vb;
 		if (flags && (flags[i] & QBMAN_ENQUEUE_FLAG_DCA)) {
 			struct qbman_eq_desc *d = (struct qbman_eq_desc *)p;
 
@@ -849,6 +840,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 				((flags[i]) & QBMAN_EQCR_DCA_IDXMASK);
 		}
 		eqcr_pi++;
+		p[0] = cl[0] | s->eqcr.pi_vb;
+
 		if (!(eqcr_pi & half_mask))
 			s->eqcr.pi_vb ^= QB_VALID_BIT;
 	}
@@ -880,8 +873,8 @@ static int qbman_swp_enqueue_multiple_desc_direct(struct qbman_swp *s,
 	int i, num_enqueued = 0;
 	uint64_t addr_cena;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -943,8 +936,8 @@ static int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s,
 	uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask;
 	int i, num_enqueued = 0;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
diff --git a/drivers/bus/fslmc/qbman/qbman_portal.h b/drivers/bus/fslmc/qbman/qbman_portal.h
index 3b0fc540b..e54f2661c 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.h
+++ b/drivers/bus/fslmc/qbman/qbman_portal.h
@@ -98,7 +98,7 @@ struct qbman_swp {
 		uint32_t pi;
 		uint32_t pi_vb;
 		uint32_t pi_ring_size;
-		uint32_t pi_mask;
+		uint32_t pi_ci_mask;
 		uint32_t ci;
 		int available;
 	} eqcr;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 12/20] bus/fslmc: make portal func static
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (10 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 11/20] bus/fslmc: rename portal pi index to consumer index Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 13/20] net/dpaa2: add dpdmux mc flib Hemant Agrawal
                   ` (8 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

It was not required to be a function.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 37723a094..cd28441f3 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -229,7 +229,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 	return 0;
 }
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
+static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
 	int ret;
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
index 462501a2e..4354c76de 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
@@ -37,8 +37,6 @@ extern uint8_t dpaa2_eqcr_size;
 
 extern struct dpaa2_io_portal_t dpaa2_io_portal[RTE_MAX_LCORE];
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id);
-
 /* Affine a DPIO portal to current processing thread */
 int dpaa2_affine_qbman_swp(void);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 13/20] net/dpaa2: add dpdmux mc flib
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (11 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 12/20] bus/fslmc: make portal func static Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 14/20] bus/fslmc: add support for scanning DPDMUX object Hemant Agrawal
                   ` (7 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

dpdmux object is added as a part of net driver as it is used to
de-multiplex packets to separate interfaces on basis of specific rules.
These rules can be configured from the software

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/Makefile            |   1 +
 drivers/net/dpaa2/mc/dpdmux.c         | 929 ++++++++++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux.h     | 410 ++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h | 221 ++++++
 drivers/net/dpaa2/meson.build         |   1 +
 5 files changed, 1562 insertions(+)
 create mode 100644 drivers/net/dpaa2/mc/dpdmux.c
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux.h
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h

diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index 2b9c011d6..c58a39725 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -35,6 +35,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpkg.c
+SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpdmux.c
 
 LDLIBS += -lrte_bus_fslmc
 LDLIBS += -lrte_mempool_dpaa2
diff --git a/drivers/net/dpaa2/mc/dpdmux.c b/drivers/net/dpaa2/mc/dpdmux.c
new file mode 100644
index 000000000..7962213b7
--- /dev/null
+++ b/drivers/net/dpaa2/mc/dpdmux.c
@@ -0,0 +1,929 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#include <fsl_mc_sys.h>
+#include <fsl_mc_cmd.h>
+#include <fsl_dpdmux.h>
+#include <fsl_dpdmux_cmd.h>
+
+/** @addtogroup dpdmux
+ * @{
+ */
+
+/**
+ * dpdmux_open() - Open a control session for the specified object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @dpdmux_id:		DPDMUX unique ID
+ * @token:		Returned token; use in subsequent API calls
+ *
+ * This function can be used to open a control session for an
+ * already created object; an object may have been declared in
+ * the DPL or by calling the dpdmux_create() function.
+ * This function returns a unique authentication token,
+ * associated with the specific object ID and the specific MC
+ * portal; this token must be used in all subsequent commands for
+ * this specific object.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_open(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		int dpdmux_id,
+		uint16_t *token)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_open *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_OPEN,
+					  cmd_flags,
+					  0);
+	cmd_params = (struct dpdmux_cmd_open *)cmd.params;
+	cmd_params->dpdmux_id = cpu_to_le32(dpdmux_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*token = mc_cmd_hdr_read_token(&cmd);
+
+	return 0;
+}
+
+/**
+ * dpdmux_close() - Close the control session of the object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPDMUX object
+ *
+ * After this function is called, no further operations are
+ * allowed on the object without opening a new control session.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_close(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CLOSE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_create() - Create the DPDMUX object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @dprc_token:	Parent container token; '0' for default container
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @cfg:	Configuration structure
+ * @obj_id: returned object id
+ *
+ * Create the DPDMUX object, allocate required resources and
+ * perform required initialization.
+ *
+ * The object can be created either by declaring it in the
+ * DPL file, or by calling this function.
+ *
+ * The function accepts an authentication token of a parent
+ * container that this object should be assigned to. The token
+ * can be '0' so the object will be assigned to the default container.
+ * The newly created object can be opened with the returned
+ * object id and using the container's associated tokens and MC portals.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_create(struct fsl_mc_io *mc_io,
+		  uint16_t dprc_token,
+		  uint32_t cmd_flags,
+		  const struct dpdmux_cfg	*cfg,
+		  uint32_t *obj_id)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_create *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CREATE,
+					  cmd_flags,
+					  dprc_token);
+	cmd_params = (struct dpdmux_cmd_create *)cmd.params;
+	cmd_params->method = cfg->method;
+	cmd_params->manip = cfg->manip;
+	cmd_params->num_ifs = cpu_to_le16(cfg->num_ifs);
+	cmd_params->adv_max_dmat_entries =
+			cpu_to_le16(cfg->adv.max_dmat_entries);
+	cmd_params->adv_max_mc_groups = cpu_to_le16(cfg->adv.max_mc_groups);
+	cmd_params->adv_max_vlan_ids = cpu_to_le16(cfg->adv.max_vlan_ids);
+	cmd_params->options = cpu_to_le64(cfg->adv.options);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*obj_id = mc_cmd_read_object_id(&cmd);
+
+	return 0;
+}
+
+/**
+ * dpdmux_destroy() - Destroy the DPDMUX object and release all its resources.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @dprc_token: Parent container token; '0' for default container
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @object_id:	The object id; it must be a valid id within the container that
+ * created this object;
+ *
+ * The function accepts the authentication token of the parent container that
+ * created the object (not the one that currently owns the object). The object
+ * is searched within parent using the provided 'object_id'.
+ * All tokens to the object must be closed before calling destroy.
+ *
+ * Return:	'0' on Success; error code otherwise.
+ */
+int dpdmux_destroy(struct fsl_mc_io *mc_io,
+		   uint16_t dprc_token,
+		   uint32_t cmd_flags,
+		   uint32_t object_id)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_destroy *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_DESTROY,
+					  cmd_flags,
+					  dprc_token);
+	cmd_params = (struct dpdmux_cmd_destroy *)cmd.params;
+	cmd_params->dpdmux_id = cpu_to_le32(object_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_enable() - Enable DPDMUX functionality
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_enable(struct fsl_mc_io *mc_io,
+		  uint32_t cmd_flags,
+		  uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_ENABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_disable() - Disable DPDMUX functionality
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_disable(struct fsl_mc_io *mc_io,
+		   uint32_t cmd_flags,
+		   uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_DISABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_is_enabled() - Check if the DPDMUX is enabled.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @en:		Returns '1' if object is enabled; '0' otherwise
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      int *en)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_is_enabled *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IS_ENABLED,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_is_enabled *)cmd.params;
+	*en = dpdmux_get_field(rsp_params->en, ENABLE);
+
+	return 0;
+}
+
+/**
+ * dpdmux_reset() - Reset the DPDMUX, returns the object to initial state.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_reset(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_RESET,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_get_attributes() - Retrieve DPDMUX attributes
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @attr:	Returned object's attributes
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  struct dpdmux_attr *attr)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_get_attr *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_ATTR,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_get_attr *)cmd.params;
+	attr->id = le32_to_cpu(rsp_params->id);
+	attr->options = le64_to_cpu(rsp_params->options);
+	attr->method = rsp_params->method;
+	attr->manip = rsp_params->manip;
+	attr->num_ifs = le16_to_cpu(rsp_params->num_ifs);
+	attr->mem_size = le16_to_cpu(rsp_params->mem_size);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_enable() - Enable Interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface Identifier
+ *
+ * Return:	Completion status. '0' on Success; Error code otherwise.
+ */
+int dpdmux_if_enable(struct fsl_mc_io *mc_io,
+		     uint32_t cmd_flags,
+		     uint16_t token,
+		     uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_ENABLE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_disable() - Disable Interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface Identifier
+ *
+ * Return:	Completion status. '0' on Success; Error code otherwise.
+ */
+int dpdmux_if_disable(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_DISABLE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_set_max_frame_length() - Set the maximum frame length in DPDMUX
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPDMUX object
+ * @max_frame_length:	The required maximum frame length
+ *
+ * Update the maximum frame length on all DMUX interfaces.
+ * In case of VEPA, the maximum frame length on all dmux interfaces
+ * will be updated with the minimum value of the mfls of the connected
+ * dpnis and the actual value of dmux mfl.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
+				uint32_t cmd_flags,
+				uint16_t token,
+				uint16_t max_frame_length)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_set_max_frame_length *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_MAX_FRAME_LENGTH,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_set_max_frame_length *)cmd.params;
+	cmd_params->max_frame_length = cpu_to_le16(max_frame_length);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_ul_reset_counters() - Function resets the uplink counter
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_UL_RESET_COUNTERS,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_set_accepted_frames() - Set the accepted frame types
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface ID (0 for uplink, or 1-num_ifs);
+ * @cfg:	Frame types configuration
+ *
+ * if 'DPDMUX_ADMIT_ONLY_VLAN_TAGGED' is set - untagged frames or
+ * priority-tagged frames are discarded.
+ * if 'DPDMUX_ADMIT_ONLY_UNTAGGED' is set - untagged frames or
+ * priority-tagged frames are accepted.
+ * if 'DPDMUX_ADMIT_ALL' is set (default mode) - all VLAN tagged,
+ * untagged and priority-tagged frame are accepted;
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint16_t if_id,
+				  const struct dpdmux_accepted_frames *cfg)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_set_accepted_frames *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_ACCEPTED_FRAMES,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_set_accepted_frames *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	dpdmux_set_field(cmd_params->frames_options,
+			 ACCEPTED_FRAMES_TYPE,
+			 cfg->type);
+	dpdmux_set_field(cmd_params->frames_options,
+			 UNACCEPTED_FRAMES_ACTION,
+			 cfg->unaccept_act);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_attributes() - Obtain DPDMUX interface attributes
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface ID (0 for uplink, or 1-num_ifs);
+ * @attr:	Interface attributes
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_if_attr *attr)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if *cmd_params;
+	struct dpdmux_rsp_if_get_attr *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_ATTR,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_attr *)cmd.params;
+	attr->rate = le32_to_cpu(rsp_params->rate);
+	attr->enabled = dpdmux_get_field(rsp_params->enabled, ENABLE);
+	attr->is_default = dpdmux_get_field(rsp_params->enabled, IS_DEFAULT);
+	attr->accept_frame_type = dpdmux_get_field(
+				  rsp_params->accepted_frames_type,
+				  ACCEPTED_FRAMES_TYPE);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_remove_l2_rule() - Remove L2 rule from DPDMUX table
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Destination interface ID
+ * @rule:	L2 rule
+ *
+ * Function removes a L2 rule from DPDMUX table
+ * or adds an interface to an existing multicast address
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     const struct dpdmux_l2_rule *rule)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_l2_rule *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_REMOVE_L2_RULE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_l2_rule *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->vlan_id = cpu_to_le16(rule->vlan_id);
+	cmd_params->mac_addr5 = rule->mac_addr[5];
+	cmd_params->mac_addr4 = rule->mac_addr[4];
+	cmd_params->mac_addr3 = rule->mac_addr[3];
+	cmd_params->mac_addr2 = rule->mac_addr[2];
+	cmd_params->mac_addr1 = rule->mac_addr[1];
+	cmd_params->mac_addr0 = rule->mac_addr[0];
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_add_l2_rule() - Add L2 rule into DPDMUX table
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Destination interface ID
+ * @rule:	L2 rule
+ *
+ * Function adds a L2 rule into DPDMUX table
+ * or adds an interface to an existing multicast address
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  const struct dpdmux_l2_rule *rule)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_l2_rule *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_ADD_L2_RULE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_l2_rule *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->vlan_id = cpu_to_le16(rule->vlan_id);
+	cmd_params->mac_addr5 = rule->mac_addr[5];
+	cmd_params->mac_addr4 = rule->mac_addr[4];
+	cmd_params->mac_addr3 = rule->mac_addr[3];
+	cmd_params->mac_addr2 = rule->mac_addr[2];
+	cmd_params->mac_addr1 = rule->mac_addr[1];
+	cmd_params->mac_addr0 = rule->mac_addr[0];
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_counter() - Functions obtains specific counter of an interface
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPDMUX object
+ * @if_id:  Interface Id
+ * @counter_type: counter type
+ * @counter: Returned specific counter information
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  enum dpdmux_counter_type counter_type,
+			  uint64_t *counter)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_get_counter *cmd_params;
+	struct dpdmux_rsp_if_get_counter *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_COUNTER,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_get_counter *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->counter_type = counter_type;
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_counter *)cmd.params;
+	*counter = le64_to_cpu(rsp_params->counter);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_set_link_cfg() - set the link configuration.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ * @cfg: Link configuration
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t token,
+			   uint16_t if_id,
+			   struct dpdmux_link_cfg *cfg)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_set_link_cfg *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_LINK_CFG,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_set_link_cfg *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->rate = cpu_to_le32(cfg->rate);
+	cmd_params->options = cpu_to_le64(cfg->options);
+	cmd_params->advertising = cpu_to_le64(cfg->advertising);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_link_state - Return the link state
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ * @state: link state
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_link_state *state)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_get_link_state *cmd_params;
+	struct dpdmux_rsp_if_get_link_state *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_LINK_STATE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_get_link_state *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_link_state *)cmd.params;
+	state->rate = le32_to_cpu(rsp_params->rate);
+	state->options = le64_to_cpu(rsp_params->options);
+	state->up = dpdmux_get_field(rsp_params->up, UP);
+	state->state_valid = dpdmux_get_field(rsp_params->up, STATE_VALID);
+	state->supported = le64_to_cpu(rsp_params->supported);
+	state->advertising = le64_to_cpu(rsp_params->advertising);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_set_default - Set default interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_DEFAULT,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_default - Get default interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t *if_id)
+{
+	struct dpdmux_cmd_if *rsp_params;
+	struct mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_DEFAULT,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_cmd_if *)cmd.params;
+	*if_id = le16_to_cpu(rsp_params->if_id);
+
+	return 0;
+}
+
+/**
+ * dpdmux_set_custom_key - Set a custom classification key.
+ *
+ * This API is only available for DPDMUX instance created with
+ * DPDMUX_METHOD_CUSTOM.  This API must be called before populating the
+ * classification table using dpdmux_add_custom_cls_entry.
+ *
+ * Calls to dpdmux_set_custom_key remove all existing classification entries
+ * that may have been added previously using dpdmux_add_custom_cls_entry.
+ *
+ * @mc_io:		Pointer to MC portal's I/O object
+ * @cmd_flags:		Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPSW object
+ * @if_id:		Interface id
+ * @key_cfg_iova:	DMA address of a configuration structure set up using
+ *			dpkg_prepare_key_cfg. Maximum key size is 24 bytes
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
+			uint32_t cmd_flags,
+			uint16_t token,
+			uint64_t key_cfg_iova)
+{
+	struct dpdmux_set_custom_key *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_CUSTOM_KEY,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_set_custom_key *)cmd.params;
+	cmd_params->key_cfg_iova = cpu_to_le64(key_cfg_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_add_custom_cls_entry - Adds a custom classification entry.
+ *
+ * This API is only available for DPDMUX instances created with
+ * DPDMUX_METHOD_CUSTOM.  Before calling this function a classification key
+ * composition rule must be set up using dpdmux_set_custom_key.
+ *
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @rule: Classification rule to insert.  Rules cannot be duplicated, if a
+ *	matching rule already exists, the action will be replaced.
+ * @action: Action to perform for matching traffic.
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule,
+		struct dpdmux_cls_action *action)
+{
+	struct dpdmux_cmd_add_custom_cls_entry *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_ADD_CUSTOM_CLS_ENTRY,
+					  cmd_flags,
+					  token);
+
+	cmd_params = (struct dpdmux_cmd_add_custom_cls_entry *)cmd.params;
+	cmd_params->key_size = rule->key_size;
+	cmd_params->dest_if = cpu_to_le16(action->dest_if);
+	cmd_params->key_iova = cpu_to_le64(rule->key_iova);
+	cmd_params->mask_iova = cpu_to_le64(rule->mask_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_remove_custom_cls_entry - Removes a custom classification entry.
+ *
+ * This API is only available for DPDMUX instances created with
+ * DPDMUX_METHOD_CUSTOM.  The API can be used to remove classification
+ * entries previously inserted using dpdmux_add_custom_cls_entry.
+ *
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @rule: Classification rule to remove
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule)
+{
+	struct dpdmux_cmd_remove_custom_cls_entry *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_REMOVE_CUSTOM_CLS_ENTRY,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_remove_custom_cls_entry *)cmd.params;
+	cmd_params->key_size = rule->key_size;
+	cmd_params->key_iova = cpu_to_le64(rule->key_iova);
+	cmd_params->mask_iova = cpu_to_le64(rule->mask_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_get_api_version() - Get Data Path Demux API version
+ * @mc_io:  Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @major_ver:	Major version of data path demux API
+ * @minor_ver:	Minor version of data path demux API
+ *
+ * Return:  '0' on Success; Error code otherwise.
+ */
+int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t *major_ver,
+			   uint16_t *minor_ver)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_get_api_version *rsp_params;
+	int err;
+
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_API_VERSION,
+					cmd_flags,
+					0);
+
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	rsp_params = (struct dpdmux_rsp_get_api_version *)cmd.params;
+	*major_ver = le16_to_cpu(rsp_params->major);
+	*minor_ver = le16_to_cpu(rsp_params->minor);
+
+	return 0;
+}
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux.h b/drivers/net/dpaa2/mc/fsl_dpdmux.h
new file mode 100644
index 000000000..c69cb7aab
--- /dev/null
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux.h
@@ -0,0 +1,410 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#ifndef __FSL_DPDMUX_H
+#define __FSL_DPDMUX_H
+
+#include <fsl_net.h>
+
+struct fsl_mc_io;
+
+/** @addtogroup dpdmux Data Path Demux API
+ * Contains API for handling DPDMUX topology and functionality
+ * @{
+ */
+
+int dpdmux_open(struct fsl_mc_io *mc_io,
+		uint32_t  cmd_flags,
+		int  dpdmux_id,
+		uint16_t  *token);
+
+int dpdmux_close(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token);
+
+/**
+ * DPDMUX general options
+ */
+
+/**
+ * Enable bridging between internal interfaces
+ */
+#define DPDMUX_OPT_BRIDGE_EN	0x0000000000000002ULL
+
+/**
+ * Mask support for classification
+ */
+#define DPDMUX_OPT_CLS_MASK_SUPPORT		0x0000000000000020ULL
+
+#define DPDMUX_IRQ_INDEX_IF	0x0000
+#define DPDMUX_IRQ_INDEX	0x0001
+
+/**
+ * IRQ event - Indicates that the link state changed
+ */
+#define DPDMUX_IRQ_EVENT_LINK_CHANGED	0x0001
+
+/**
+ * enum dpdmux_manip - DPDMUX manipulation operations
+ * @DPDMUX_MANIP_NONE:	No manipulation on frames
+ * @DPDMUX_MANIP_ADD_REMOVE_S_VLAN: Add S-VLAN on egress, remove it on ingress
+ */
+enum dpdmux_manip {
+	DPDMUX_MANIP_NONE = 0x0,
+	DPDMUX_MANIP_ADD_REMOVE_S_VLAN = 0x1
+};
+
+/**
+ * enum dpdmux_method - DPDMUX method options
+ * @DPDMUX_METHOD_NONE: no DPDMUX method
+ * @DPDMUX_METHOD_C_VLAN_MAC: DPDMUX based on C-VLAN and MAC address
+ * @DPDMUX_METHOD_MAC: DPDMUX based on MAC address
+ * @DPDMUX_METHOD_C_VLAN: DPDMUX based on C-VLAN
+ * @DPDMUX_METHOD_S_VLAN: DPDMUX based on S-VLAN
+ */
+enum dpdmux_method {
+	DPDMUX_METHOD_NONE = 0x0,
+	DPDMUX_METHOD_C_VLAN_MAC = 0x1,
+	DPDMUX_METHOD_MAC = 0x2,
+	DPDMUX_METHOD_C_VLAN = 0x3,
+	DPDMUX_METHOD_S_VLAN = 0x4,
+	DPDMUX_METHOD_CUSTOM = 0x5,
+};
+
+/**
+ * struct dpdmux_cfg - DPDMUX configuration parameters
+ * @method: Defines the operation method for the DPDMUX address table
+ * @manip: Required manipulation operation
+ * @num_ifs: Number of interfaces (excluding the uplink interface)
+ * @adv: Advanced parameters; default is all zeros;
+ *	use this structure to change default settings
+ * @adv.options: DPDMUX options - combination of 'DPDMUX_OPT_<X>' flags.
+ * @adv.max_dmat_entries: Maximum entries in DPDMUX address table
+ *	0 - indicates default: 64 entries per interface.
+ * @adv.max_mc_groups: Number of multicast groups in DPDMUX table
+ *	0 - indicates default: 32 multicast groups.
+ * @adv.max_vlan_ids: Maximum vlan ids allowed in the system -
+ *	relevant only case of working in mac+vlan method.
+ *	0 - indicates default 16 vlan ids.
+ */
+struct dpdmux_cfg {
+	enum dpdmux_method method;
+	enum dpdmux_manip manip;
+	uint16_t num_ifs;
+	struct {
+		uint64_t options;
+		uint16_t max_dmat_entries;
+		uint16_t max_mc_groups;
+		uint16_t max_vlan_ids;
+	} adv;
+};
+
+int dpdmux_create(struct fsl_mc_io *mc_io,
+		  uint16_t dprc_token,
+		  uint32_t cmd_flags,
+		  const struct dpdmux_cfg *cfg,
+		  uint32_t *obj_id);
+
+int dpdmux_destroy(struct fsl_mc_io *mc_io,
+		   uint16_t dprc_token,
+		   uint32_t cmd_flags,
+		   uint32_t object_id);
+
+int dpdmux_enable(struct fsl_mc_io *mc_io,
+		  uint32_t cmd_flags,
+		  uint16_t token);
+
+int dpdmux_disable(struct fsl_mc_io *mc_io,
+		   uint32_t cmd_flags,
+		   uint16_t token);
+
+int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      int *en);
+
+int dpdmux_reset(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token);
+
+/**
+ * struct dpdmux_attr - Structure representing DPDMUX attributes
+ * @id: DPDMUX object ID
+ * @options: Configuration options (bitmap)
+ * @method: DPDMUX address table method
+ * @manip: DPDMUX manipulation type
+ * @num_ifs: Number of interfaces (excluding the uplink interface)
+ * @mem_size: DPDMUX frame storage memory size
+ */
+struct dpdmux_attr {
+	int id;
+	uint64_t options;
+	enum dpdmux_method method;
+	enum dpdmux_manip manip;
+	uint16_t num_ifs;
+	uint16_t mem_size;
+};
+
+int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  struct dpdmux_attr *attr);
+
+int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
+				uint32_t cmd_flags,
+				uint16_t token,
+				uint16_t max_frame_length);
+
+/**
+ * enum dpdmux_counter_type - Counter types
+ * @DPDMUX_CNT_ING_FRAME: Counts ingress frames
+ * @DPDMUX_CNT_ING_BYTE: Counts ingress bytes
+ * @DPDMUX_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
+ * @DPDMUX_CNT_ING_FRAME_DISCARD: Counts discarded ingress frames
+ * @DPDMUX_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
+ * @DPDMUX_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
+ * @DPDMUX_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
+ * @DPDMUX_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
+ * @DPDMUX_CNT_EGR_FRAME: Counts egress frames
+ * @DPDMUX_CNT_EGR_BYTE: Counts egress bytes
+ * @DPDMUX_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
+ */
+enum dpdmux_counter_type {
+	DPDMUX_CNT_ING_FRAME = 0x0,
+	DPDMUX_CNT_ING_BYTE = 0x1,
+	DPDMUX_CNT_ING_FLTR_FRAME = 0x2,
+	DPDMUX_CNT_ING_FRAME_DISCARD = 0x3,
+	DPDMUX_CNT_ING_MCAST_FRAME = 0x4,
+	DPDMUX_CNT_ING_MCAST_BYTE = 0x5,
+	DPDMUX_CNT_ING_BCAST_FRAME = 0x6,
+	DPDMUX_CNT_ING_BCAST_BYTES = 0x7,
+	DPDMUX_CNT_EGR_FRAME = 0x8,
+	DPDMUX_CNT_EGR_BYTE = 0x9,
+	DPDMUX_CNT_EGR_FRAME_DISCARD = 0xa
+};
+
+/**
+ * enum dpdmux_accepted_frames_type - DPDMUX frame types
+ * @DPDMUX_ADMIT_ALL: The device accepts VLAN tagged, untagged and
+ *			priority-tagged frames
+ * @DPDMUX_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
+ *				priority-tagged frames that are received on this
+ *				interface
+ * @DPDMUX_ADMIT_ONLY_UNTAGGED: Untagged frames or priority-tagged frames
+ *				received on this interface are accepted
+ */
+enum dpdmux_accepted_frames_type {
+	DPDMUX_ADMIT_ALL = 0,
+	DPDMUX_ADMIT_ONLY_VLAN_TAGGED = 1,
+	DPDMUX_ADMIT_ONLY_UNTAGGED = 2
+};
+
+/**
+ * enum dpdmux_action - DPDMUX action for un-accepted frames
+ * @DPDMUX_ACTION_DROP: Drop un-accepted frames
+ * @DPDMUX_ACTION_REDIRECT_TO_CTRL: Redirect un-accepted frames to the
+ *					control interface
+ */
+enum dpdmux_action {
+	DPDMUX_ACTION_DROP = 0,
+	DPDMUX_ACTION_REDIRECT_TO_CTRL = 1
+};
+
+/**
+ * struct dpdmux_accepted_frames - Frame types configuration
+ * @type: Defines ingress accepted frames
+ * @unaccept_act: Defines action on frames not accepted
+ */
+struct dpdmux_accepted_frames {
+	enum dpdmux_accepted_frames_type type;
+	enum dpdmux_action unaccept_act;
+};
+
+int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint16_t if_id,
+				  const struct dpdmux_accepted_frames *cfg);
+
+/**
+ * struct dpdmux_if_attr - Structure representing frame types configuration
+ * @rate: Configured interface rate (in bits per second)
+ * @enabled: Indicates if interface is enabled
+ * @accept_frame_type: Indicates type of accepted frames for the interface
+ */
+struct dpdmux_if_attr {
+	uint32_t rate;
+	int enabled;
+	int is_default;
+	enum dpdmux_accepted_frames_type accept_frame_type;
+};
+
+int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_if_attr *attr);
+
+int dpdmux_if_enable(struct fsl_mc_io *mc_io,
+		     uint32_t cmd_flags,
+		     uint16_t token,
+		     uint16_t if_id);
+
+int dpdmux_if_disable(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      uint16_t if_id);
+
+/**
+ * struct dpdmux_l2_rule - Structure representing L2 rule
+ * @mac_addr: MAC address
+ * @vlan_id: VLAN ID
+ */
+struct dpdmux_l2_rule {
+	uint8_t mac_addr[6];
+	uint16_t vlan_id;
+};
+
+int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     const struct dpdmux_l2_rule *rule);
+
+int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  const struct dpdmux_l2_rule *rule);
+
+int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  enum dpdmux_counter_type counter_type,
+			  uint64_t *counter);
+
+int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token);
+
+/**
+ * Enable auto-negotiation
+ */
+#define DPDMUX_LINK_OPT_AUTONEG		0x0000000000000001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPDMUX_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
+/**
+ * Enable pause frames
+ */
+#define DPDMUX_LINK_OPT_PAUSE		0x0000000000000004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPDMUX_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
+
+/**
+ * struct dpdmux_link_cfg - Structure representing DPDMUX link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
+ */
+struct dpdmux_link_cfg {
+	uint32_t rate;
+	uint64_t options;
+	uint64_t advertising;
+};
+
+int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t token,
+			   uint16_t if_id,
+			   struct dpdmux_link_cfg *cfg);
+/**
+ * struct dpdmux_link_state - Structure representing DPDMUX link state
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
+ * @up: 0 - down, 1 - up
+ * @state_valid: Ignore/Update the state of the link
+ * @supported: Speeds capability of the phy (bitmap)
+ * @advertising: Speeds that are advertised for autoneg (bitmap)
+ */
+struct dpdmux_link_state {
+	uint32_t rate;
+	uint64_t options;
+	int      up;
+	int      state_valid;
+	uint64_t supported;
+	uint64_t advertising;
+};
+
+int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_link_state *state);
+
+int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t if_id);
+
+int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t *if_id);
+
+int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
+			uint32_t cmd_flags,
+			uint16_t token,
+			uint64_t key_cfg_iova);
+
+/**
+ * struct dpdmux_rule_cfg - Custom classification rule.
+ *
+ * @key_iova: DMA address of buffer storing the look-up value
+ * @mask_iova: DMA address of the mask used for TCAM classification
+ * @key_size: size, in bytes, of the look-up value. This must match the size
+ *	of the look-up key defined using dpdmux_set_custom_key, otherwise the
+ *	entry will never be hit
+ */
+struct dpdmux_rule_cfg {
+	uint64_t key_iova;
+	uint64_t mask_iova;
+	uint8_t key_size;
+};
+
+/**
+ * struct dpdmux_cls_action - Action to execute for frames matching the
+ *	classification entry
+ *
+ * @dest_if: Interface to forward the frames to. Port numbering is similar to
+ *	the one used to connect interfaces:
+ *	- 0 is the uplink port,
+ *	- all others are downlink ports.
+ */
+struct dpdmux_cls_action {
+	uint16_t dest_if;
+};
+
+int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule,
+		struct dpdmux_cls_action *action);
+
+int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule);
+
+int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t *major_ver,
+			   uint16_t *minor_ver);
+
+#endif /* __FSL_DPDMUX_H */
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
new file mode 100644
index 000000000..a36349feb
--- /dev/null
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
@@ -0,0 +1,221 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#ifndef _FSL_DPDMUX_CMD_H
+#define _FSL_DPDMUX_CMD_H
+
+/* DPDMUX Version */
+#define DPDMUX_VER_MAJOR		6
+#define DPDMUX_VER_MINOR		3
+
+#define DPDMUX_CMD_BASE_VERSION		1
+#define DPDMUX_CMD_VERSION_2		2
+#define DPDMUX_CMD_ID_OFFSET		4
+
+#define DPDMUX_CMD(id)	(((id) << DPDMUX_CMD_ID_OFFSET) |\
+				DPDMUX_CMD_BASE_VERSION)
+#define DPDMUX_CMD_V2(id) (((id) << DPDMUX_CMD_ID_OFFSET) | \
+				DPDMUX_CMD_VERSION_2)
+
+/* Command IDs */
+#define DPDMUX_CMDID_CLOSE			DPDMUX_CMD(0x800)
+#define DPDMUX_CMDID_OPEN			DPDMUX_CMD(0x806)
+#define DPDMUX_CMDID_CREATE			DPDMUX_CMD(0x906)
+#define DPDMUX_CMDID_DESTROY			DPDMUX_CMD(0x986)
+#define DPDMUX_CMDID_GET_API_VERSION		DPDMUX_CMD(0xa06)
+
+#define DPDMUX_CMDID_ENABLE			DPDMUX_CMD(0x002)
+#define DPDMUX_CMDID_DISABLE			DPDMUX_CMD(0x003)
+#define DPDMUX_CMDID_GET_ATTR			DPDMUX_CMD(0x004)
+#define DPDMUX_CMDID_RESET			DPDMUX_CMD(0x005)
+#define DPDMUX_CMDID_IS_ENABLED			DPDMUX_CMD(0x006)
+
+#define DPDMUX_CMDID_SET_MAX_FRAME_LENGTH	DPDMUX_CMD(0x0a1)
+
+#define DPDMUX_CMDID_UL_RESET_COUNTERS		DPDMUX_CMD(0x0a3)
+
+#define DPDMUX_CMDID_IF_SET_ACCEPTED_FRAMES	DPDMUX_CMD(0x0a7)
+#define DPDMUX_CMDID_IF_GET_ATTR		DPDMUX_CMD(0x0a8)
+#define DPDMUX_CMDID_IF_ENABLE			DPDMUX_CMD(0x0a9)
+#define DPDMUX_CMDID_IF_DISABLE			DPDMUX_CMD(0x0aa)
+
+#define DPDMUX_CMDID_IF_ADD_L2_RULE		DPDMUX_CMD(0x0b0)
+#define DPDMUX_CMDID_IF_REMOVE_L2_RULE		DPDMUX_CMD(0x0b1)
+#define DPDMUX_CMDID_IF_GET_COUNTER		DPDMUX_CMD(0x0b2)
+#define DPDMUX_CMDID_IF_SET_LINK_CFG		DPDMUX_CMD_V2(0x0b3)
+#define DPDMUX_CMDID_IF_GET_LINK_STATE		DPDMUX_CMD_V2(0x0b4)
+
+#define DPDMUX_CMDID_SET_CUSTOM_KEY		DPDMUX_CMD(0x0b5)
+#define DPDMUX_CMDID_ADD_CUSTOM_CLS_ENTRY	DPDMUX_CMD(0x0b6)
+#define DPDMUX_CMDID_REMOVE_CUSTOM_CLS_ENTRY	DPDMUX_CMD(0x0b7)
+
+#define DPDMUX_CMDID_IF_SET_DEFAULT		DPDMUX_CMD(0x0b8)
+#define DPDMUX_CMDID_IF_GET_DEFAULT		DPDMUX_CMD(0x0b9)
+
+#define DPDMUX_MASK(field)        \
+	GENMASK(DPDMUX_##field##_SHIFT + DPDMUX_##field##_SIZE - 1, \
+		DPDMUX_##field##_SHIFT)
+#define dpdmux_set_field(var, field, val) \
+	((var) |= (((val) << DPDMUX_##field##_SHIFT) & DPDMUX_MASK(field)))
+#define dpdmux_get_field(var, field)      \
+	(((var) & DPDMUX_MASK(field)) >> DPDMUX_##field##_SHIFT)
+
+#pragma pack(push, 1)
+struct dpdmux_cmd_open {
+	uint32_t dpdmux_id;
+};
+
+struct dpdmux_cmd_create {
+	uint8_t method;
+	uint8_t manip;
+	uint16_t num_ifs;
+	uint32_t pad;
+
+	uint16_t adv_max_dmat_entries;
+	uint16_t adv_max_mc_groups;
+	uint16_t adv_max_vlan_ids;
+	uint16_t pad1;
+
+	uint64_t options;
+};
+
+struct dpdmux_cmd_destroy {
+	uint32_t dpdmux_id;
+};
+
+#define DPDMUX_ENABLE_SHIFT	0
+#define DPDMUX_ENABLE_SIZE	1
+#define DPDMUX_IS_DEFAULT_SHIFT		1
+#define DPDMUX_IS_DEFAULT_SIZE		1
+
+struct dpdmux_rsp_is_enabled {
+	uint8_t en;
+};
+
+struct dpdmux_rsp_get_attr {
+	uint8_t method;
+	uint8_t manip;
+	uint16_t num_ifs;
+	uint16_t mem_size;
+	uint16_t pad;
+
+	uint64_t pad1;
+
+	uint32_t id;
+	uint32_t pad2;
+
+	uint64_t options;
+};
+
+struct dpdmux_cmd_set_max_frame_length {
+	uint16_t max_frame_length;
+};
+
+#define DPDMUX_ACCEPTED_FRAMES_TYPE_SHIFT	0
+#define DPDMUX_ACCEPTED_FRAMES_TYPE_SIZE	4
+#define DPDMUX_UNACCEPTED_FRAMES_ACTION_SHIFT	4
+#define DPDMUX_UNACCEPTED_FRAMES_ACTION_SIZE	4
+
+struct dpdmux_cmd_if_set_accepted_frames {
+	uint16_t if_id;
+	uint8_t frames_options;
+};
+
+struct dpdmux_cmd_if {
+	uint16_t if_id;
+};
+
+struct dpdmux_rsp_if_get_attr {
+	uint8_t pad[3];
+	uint8_t enabled;
+	uint8_t pad1[3];
+	uint8_t accepted_frames_type;
+	uint32_t rate;
+};
+
+struct dpdmux_cmd_if_l2_rule {
+	uint16_t if_id;
+	uint8_t mac_addr5;
+	uint8_t mac_addr4;
+	uint8_t mac_addr3;
+	uint8_t mac_addr2;
+	uint8_t mac_addr1;
+	uint8_t mac_addr0;
+
+	uint32_t pad;
+	uint16_t vlan_id;
+};
+
+struct dpdmux_cmd_if_get_counter {
+	uint16_t if_id;
+	uint8_t counter_type;
+};
+
+struct dpdmux_rsp_if_get_counter {
+	uint64_t pad;
+	uint64_t counter;
+};
+
+struct dpdmux_cmd_if_set_link_cfg {
+	uint16_t if_id;
+	uint16_t pad[3];
+
+	uint32_t rate;
+	uint32_t pad1;
+
+	uint64_t options;
+	uint64_t advertising;
+};
+
+struct dpdmux_cmd_if_get_link_state {
+	uint16_t if_id;
+};
+
+#define DPDMUX_UP_SHIFT				0
+#define DPDMUX_UP_SIZE				1
+#define DPDMUX_STATE_VALID_SHIFT	1
+#define DPDMUX_STATE_VALID_SIZE		1
+struct dpdmux_rsp_if_get_link_state {
+	uint32_t pad;
+	uint8_t up;
+	uint8_t pad1[3];
+
+	uint32_t rate;
+	uint32_t pad2;
+
+	uint64_t options;
+	uint64_t supported;
+	uint64_t advertising;
+};
+
+struct dpdmux_rsp_get_api_version {
+	uint16_t major;
+	uint16_t minor;
+};
+
+struct dpdmux_set_custom_key {
+	uint64_t pad[6];
+	uint64_t key_cfg_iova;
+};
+
+struct dpdmux_cmd_add_custom_cls_entry {
+	uint8_t pad[3];
+	uint8_t key_size;
+	uint16_t pad1;
+	uint16_t dest_if;
+	uint64_t key_iova;
+	uint64_t mask_iova;
+};
+
+struct dpdmux_cmd_remove_custom_cls_entry {
+	uint8_t pad[3];
+	uint8_t key_size;
+	uint32_t pad1;
+	uint64_t key_iova;
+	uint64_t mask_iova;
+};
+#pragma pack(pop)
+#endif /* _FSL_DPDMUX_CMD_H */
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index 07aada87c..c7c2df417 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -12,6 +12,7 @@ sources = files('base/dpaa2_hw_dpni.c',
 		'dpaa2_ethdev.c',
 		'dpaa2_rxtx.c',
 		'mc/dpkg.c',
+		'mc/dpdmux.c',
 		'mc/dpni.c')
 
 includes += include_directories('base', 'mc')
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 14/20] bus/fslmc: add support for scanning DPDMUX object
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (12 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 13/20] net/dpaa2: add dpdmux mc flib Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 15/20] net/dpaa2: add dpdmux initialization and configuration Hemant Agrawal
                   ` (6 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

Add support in bus and vfio to scan dpdmux type of objects

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c  | 5 ++++-
 drivers/bus/fslmc/fslmc_vfio.c | 2 ++
 drivers/bus/fslmc/rte_fslmc.h  | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 565e0148f..fa1505377 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -187,6 +187,8 @@ scan_one_fslmc_device(char *dev_name)
 		dev->dev_type = DPAA2_MPORTAL;
 	else if (!strncmp("dpdmai", t_ptr, 6))
 		dev->dev_type = DPAA2_QDMA;
+	else if (!strncmp("dpdmux", t_ptr, 6))
+		dev->dev_type = DPAA2_MUX;
 	else
 		dev->dev_type = DPAA2_UNKNOWN;
 
@@ -245,7 +247,8 @@ rte_fslmc_parse(const char *name, void *addr)
 	    strncmp("dpio", t_ptr, 4) &&
 	    strncmp("dpci", t_ptr, 4) &&
 	    strncmp("dpmcp", t_ptr, 5) &&
-	    strncmp("dpdmai", t_ptr, 6)) {
+	    strncmp("dpdmai", t_ptr, 6) &&
+	    strncmp("dpdmux", t_ptr, 6)) {
 		DPAA2_BUS_ERR("Unknown or unsupported device");
 		goto err_out;
 	}
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index ce82a99f6..98768a46c 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -560,6 +560,7 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev)
 	case DPAA2_IO:
 	case DPAA2_CI:
 	case DPAA2_BPOOL:
+	case DPAA2_MUX:
 		TAILQ_FOREACH(object, &dpaa2_obj_list, next) {
 			if (dev->dev_type == object->dev_type)
 				object->create(dev_fd, &device_info,
@@ -691,6 +692,7 @@ fslmc_vfio_process_group(void)
 		case DPAA2_IO:
 		case DPAA2_CI:
 		case DPAA2_BPOOL:
+		case DPAA2_MUX:
 			/* Call the object creation routine and remove the
 			 * device entry from device list
 			 */
diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h
index cea5b78f9..5cfb24505 100644
--- a/drivers/bus/fslmc/rte_fslmc.h
+++ b/drivers/bus/fslmc/rte_fslmc.h
@@ -66,6 +66,7 @@ enum rte_dpaa2_dev_type {
 	DPAA2_CI,	/**< DPCI type device */
 	DPAA2_MPORTAL,  /**< DPMCP type device */
 	DPAA2_QDMA,     /**< DPDMAI type device */
+	DPAA2_MUX,	/**< DPDMUX type device */
 	/* Unknown device placeholder */
 	DPAA2_UNKNOWN,
 	DPAA2_DEVTYPE_MAX,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 15/20] net/dpaa2: add dpdmux initialization and configuration
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (13 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 14/20] bus/fslmc: add support for scanning DPDMUX object Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 16/20] net/dpaa2: add API to support custom hash key Hemant Agrawal
                   ` (5 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

This patch introduces an rte pmd API to configure dpdmux from
the application.
dpdmux can work in association with dpni as an additional
distribution capability on the NIC.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/Makefile                  |   1 +
 drivers/net/dpaa2/dpaa2_ethdev.h            |   2 +
 drivers/net/dpaa2/dpaa2_mux.c               | 222 ++++++++++++++++++++
 drivers/net/dpaa2/meson.build               |   1 +
 drivers/net/dpaa2/rte_pmd_dpaa2.h           |  23 ++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |   1 +
 6 files changed, 250 insertions(+)
 create mode 100644 drivers/net/dpaa2/dpaa2_mux.c

diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index c58a39725..562551175 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -33,6 +33,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += base/dpaa2_hw_dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_mux.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpkg.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpdmux.c
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index 7cf6e4191..420ad6446 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -11,6 +11,8 @@
 #include <rte_event_eth_rx_adapter.h>
 #include <rte_pmd_dpaa2.h>
 
+#include <dpaa2_hw_pvt.h>
+
 #include <mc/fsl_dpni.h>
 #include <mc/fsl_mc_sys.h>
 
diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
new file mode 100644
index 000000000..1d043dcdc
--- /dev/null
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -0,0 +1,222 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#include <sys/queue.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#include <rte_ethdev.h>
+#include <rte_log.h>
+#include <rte_eth_ctrl.h>
+#include <rte_malloc.h>
+#include <rte_flow_driver.h>
+#include <rte_tailq.h>
+
+#include <rte_fslmc.h>
+#include <fsl_dpdmux.h>
+#include <fsl_dpkg.h>
+
+#include <dpaa2_ethdev.h>
+#include <dpaa2_pmd_logs.h>
+
+struct dpaa2_dpdmux_dev {
+	TAILQ_ENTRY(dpaa2_dpdmux_dev) next;
+		/**< Pointer to Next device instance */
+	struct fsl_mc_io dpdmux;  /** handle to DPDMUX portal object */
+	uint16_t token;
+	uint32_t dpdmux_id; /*HW ID for DPDMUX object */
+	uint8_t num_ifs;   /* Number of interfaces in DPDMUX */
+};
+
+struct rte_flow {
+	struct dpdmux_rule_cfg rule;
+};
+
+TAILQ_HEAD(dpdmux_dev_list, dpaa2_dpdmux_dev);
+static struct dpdmux_dev_list dpdmux_dev_list =
+	TAILQ_HEAD_INITIALIZER(dpdmux_dev_list); /*!< DPDMUX device list */
+
+static struct dpaa2_dpdmux_dev *get_dpdmux_from_id(uint32_t dpdmux_id)
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev = NULL;
+
+	/* Get DPBP dev handle from list using index */
+	TAILQ_FOREACH(dpdmux_dev, &dpdmux_dev_list, next) {
+		if (dpdmux_dev->dpdmux_id == dpdmux_id)
+			break;
+	}
+
+	return dpdmux_dev;
+}
+
+struct rte_flow *
+rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
+			      struct rte_flow_item *pattern[],
+			      struct rte_flow_action *actions[])
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev;
+	struct dpkg_profile_cfg kg_cfg;
+	const struct rte_flow_item_ipv4 *spec;
+	const struct rte_flow_action_vf *vf_conf;
+	struct dpdmux_cls_action dpdmux_action;
+	struct rte_flow *flow = NULL;
+	void *key_iova, *mask_iova, *key_cfg_iova = NULL;
+	int ret;
+
+	if (pattern[0]->type != RTE_FLOW_ITEM_TYPE_IPV4) {
+		DPAA2_PMD_ERR("Not supported pattern type: %d",
+			      pattern[0]->type);
+		return NULL;
+	}
+
+	/* Find the DPDMUX from dpdmux_id in our list */
+	dpdmux_dev = get_dpdmux_from_id(dpdmux_id);
+	if (!dpdmux_dev) {
+		DPAA2_PMD_ERR("Invalid dpdmux_id: %d", dpdmux_id);
+		return NULL;
+	}
+
+	key_cfg_iova = rte_zmalloc(NULL, DIST_PARAM_IOVA_SIZE,
+				   RTE_CACHE_LINE_SIZE);
+	if (!key_cfg_iova) {
+		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
+		return NULL;
+	}
+
+	/* Currently taking only IP protocol as an extract type.
+	 * This can be exended to other fields using pattern->type.
+	 */
+	memset(&kg_cfg, 0, sizeof(struct dpkg_profile_cfg));
+	kg_cfg.extracts[0].extract.from_hdr.prot = NET_PROT_IP;
+	kg_cfg.extracts[0].extract.from_hdr.field = NH_FLD_IP_PROTO;
+	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_HDR;
+	kg_cfg.extracts[0].extract.from_hdr.type = DPKG_FULL_FIELD;
+	kg_cfg.num_extracts = 1;
+
+	ret = dpkg_prepare_key_cfg(&kg_cfg, key_cfg_iova);
+	if (ret) {
+		DPAA2_PMD_ERR("dpkg_prepare_key_cfg failed: err(%d)", ret);
+		goto creation_error;
+	}
+
+	ret = dpdmux_set_custom_key(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token,
+			(uint64_t)(DPAA2_VADDR_TO_IOVA(key_cfg_iova)));
+	if (ret) {
+		DPAA2_PMD_ERR("dpdmux_set_custom_key failed: err(%d)", ret);
+		goto creation_error;
+	}
+
+	/* As now our key extract parameters are set, let us configure
+	 * the rule.
+	 */
+	flow = rte_zmalloc(NULL, sizeof(struct rte_flow) +
+			   (2 * DIST_PARAM_IOVA_SIZE), RTE_CACHE_LINE_SIZE);
+	if (!flow) {
+		DPAA2_PMD_ERR(
+			"Memory allocation failure for rule configration\n");
+		goto creation_error;
+	}
+	key_iova = (void *)((size_t)flow + sizeof(struct rte_flow));
+	mask_iova = (void *)((size_t)key_iova + DIST_PARAM_IOVA_SIZE);
+
+	spec = (const struct rte_flow_item_ipv4 *)pattern[0]->spec;
+	memcpy(key_iova, (const void *)&spec->hdr.next_proto_id,
+	       sizeof(uint8_t));
+	memcpy(mask_iova, pattern[0]->mask, sizeof(uint8_t));
+
+	flow->rule.key_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(key_iova));
+	flow->rule.mask_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(mask_iova));
+	flow->rule.key_size = sizeof(uint8_t);
+
+	vf_conf = (const struct rte_flow_action_vf *)(actions[0]->conf);
+	if (vf_conf->id == 0 || vf_conf->id > dpdmux_dev->num_ifs) {
+		DPAA2_PMD_ERR("Invalid destination id\n");
+		goto creation_error;
+	}
+	dpdmux_action.dest_if = vf_conf->id;
+
+	ret = dpdmux_add_custom_cls_entry(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+					  dpdmux_dev->token, &flow->rule,
+					  &dpdmux_action);
+	if (ret) {
+		DPAA2_PMD_ERR("dpdmux_add_custom_cls_entry failed: err(%d)",
+			      ret);
+		goto creation_error;
+	}
+
+	return flow;
+
+creation_error:
+	rte_free((void *)key_cfg_iova);
+	rte_free((void *)flow);
+	return NULL;
+}
+
+static int
+dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
+			   struct vfio_device_info *obj_info __rte_unused,
+			   int dpdmux_id)
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev;
+	struct dpdmux_attr attr;
+	int ret;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* Allocate DPAA2 dpdmux handle */
+	dpdmux_dev = rte_malloc(NULL, sizeof(struct dpaa2_dpdmux_dev), 0);
+	if (!dpdmux_dev) {
+		DPAA2_PMD_ERR("Memory allocation failed for DPDMUX Device");
+		return -1;
+	}
+
+	/* Open the dpdmux object */
+	dpdmux_dev->dpdmux.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+	ret = dpdmux_open(&dpdmux_dev->dpdmux, CMD_PRI_LOW, dpdmux_id,
+			  &dpdmux_dev->token);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to open dpdmux object: err(%d)", ret);
+		goto init_err;
+	}
+
+	ret = dpdmux_get_attributes(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token, &attr);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to get dpdmux attr: err(%d)", ret);
+		goto init_err;
+	}
+
+	ret = dpdmux_if_set_default(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token, 1);
+	if (ret) {
+		DPAA2_PMD_ERR("setting default interface failed in %s",
+			      __func__);
+		goto init_err;
+	}
+
+	dpdmux_dev->dpdmux_id = dpdmux_id;
+	dpdmux_dev->num_ifs = attr.num_ifs;
+
+	TAILQ_INSERT_TAIL(&dpdmux_dev_list, dpdmux_dev, next);
+
+	return 0;
+
+init_err:
+	if (dpdmux_dev)
+		rte_free(dpdmux_dev);
+
+	return -1;
+}
+
+static struct rte_dpaa2_object rte_dpaa2_dpdmux_obj = {
+	.dev_type = DPAA2_MUX,
+	.create = dpaa2_create_dpdmux_device,
+};
+
+RTE_PMD_REGISTER_DPAA2_OBJECT(dpdmux, rte_dpaa2_dpdmux_obj);
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index c7c2df417..801cbf5d7 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -9,6 +9,7 @@ endif
 
 deps += ['mempool_dpaa2']
 sources = files('base/dpaa2_hw_dpni.c',
+		'dpaa2_mux.c',
 		'dpaa2_ethdev.c',
 		'dpaa2_rxtx.c',
 		'mc/dpkg.c',
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
index f9303acad..57de27f21 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2.h
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -36,4 +36,27 @@ enum pmd_dpaa2_ts {
 __rte_experimental
 void rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Create a flow rule to demultiplex ethernet traffic to separate network
+ * interfaces.
+ *
+ * @param dpdmux_id
+ *    ID of the DPDMUX MC object.
+ * @param[in] pattern
+ *    Pattern specification.
+ * @param[in] actions
+ *    Associated actions.
+ *
+ * @return
+ *    A valid handle in case of success, NULL otherwise.
+ */
+__rte_experimental
+struct rte_flow *
+rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
+			      struct rte_flow_item *pattern[],
+			      struct rte_flow_action *actions[]);
+
 #endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index de95a03cd..1661c5fb5 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -14,5 +14,6 @@ DPDK_17.11 {
 EXPERIMENTAL {
 	global:
 
+	rte_pmd_dpaa2_mux_flow_create;
 	rte_pmd_dpaa2_set_timestamp;
 } DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 16/20] net/dpaa2: add API to support custom hash key
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (14 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 15/20] net/dpaa2: add dpdmux initialization and configuration Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 17/20] mempool/dpaa2: support saving context of buffer pool Hemant Agrawal
                   ` (4 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

The DPAA2 hw can support a special offset based
configuration to program distribution on hash.
This is for all cases, which are not directly supported.

e.g. HASH based distribution on inner ip header
of a GRE tunnel.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c      | 52 ++++++++++++++++++++-
 drivers/net/dpaa2/rte_pmd_dpaa2.h           | 28 +++++++++++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |  1 +
 3 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
index a6f86df8c..11f14931e 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016 NXP
+ *   Copyright 2016-2018 NXP
  *
  */
 
@@ -28,6 +28,56 @@ dpaa2_distset_to_dpkg_profile_cfg(
 		uint64_t req_dist_set,
 		struct dpkg_profile_cfg *kg_cfg);
 
+int
+rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
+			      uint16_t offset,
+			      uint8_t size)
+{
+	struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
+	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
+	struct fsl_mc_io *dpni = priv->hw;
+	struct dpni_rx_tc_dist_cfg tc_cfg;
+	struct dpkg_profile_cfg kg_cfg;
+	void *p_params;
+	int ret, tc_index = 0;
+
+	p_params = rte_zmalloc(
+		NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
+	if (!p_params) {
+		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
+		return -ENOMEM;
+	}
+
+	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_DATA;
+	kg_cfg.extracts[0].extract.from_data.offset = offset;
+	kg_cfg.extracts[0].extract.from_data.size = size;
+	kg_cfg.num_extracts = 1;
+
+	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to prepare extract parameters");
+		rte_free(p_params);
+		return ret;
+	}
+
+	memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
+	tc_cfg.key_cfg_iova = (size_t)(DPAA2_VADDR_TO_IOVA(p_params));
+	tc_cfg.dist_size = eth_dev->data->nb_rx_queues;
+	tc_cfg.dist_mode = DPNI_DIST_MODE_HASH;
+
+	ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index,
+				  &tc_cfg);
+	rte_free(p_params);
+	if (ret) {
+		DPAA2_PMD_ERR(
+			     "Setting distribution for Rx failed with err: %d",
+			     ret);
+		return ret;
+	}
+
+	return 0;
+}
+
 int
 dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
 		      uint64_t req_dist_set)
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
index 57de27f21..7052d9da9 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2.h
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -59,4 +59,32 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
 			      struct rte_flow_item *pattern[],
 			      struct rte_flow_action *actions[]);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Create a custom hash key on basis of offset of start of packet and size.
+ * for e.g. if we need GRE packets (non-vlan and without any extra headers)
+ * to be hashed on basis of inner IP header, we will provide offset as:
+ * 14 (eth) + 20 (IP) + 4 (GRE) + 12 (Inner Src offset) = 50 and size
+ * as 8 bytes.
+ *
+ * @param port_id
+ *    The port identifier of the Ethernet device.
+ * @param offset
+ *    Offset from the start of packet which needs to be included to
+ *    calculate hash
+ * @param size
+ *    Size of the hash input key
+ *
+ * @return
+ *   - 0 if successful.
+ *   - Negative in case of failure.
+ */
+__rte_experimental
+int
+rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
+			      uint16_t offset,
+			      uint8_t size);
+
 #endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index 1661c5fb5..d1b4cdb23 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -15,5 +15,6 @@ EXPERIMENTAL {
 	global:
 
 	rte_pmd_dpaa2_mux_flow_create;
+	rte_pmd_dpaa2_set_custom_hash;
 	rte_pmd_dpaa2_set_timestamp;
 } DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 17/20] mempool/dpaa2: support saving context of buffer pool
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (15 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 16/20] net/dpaa2: add API to support custom hash key Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 18/20] net/dpaa2: change ref of device to private device Hemant Agrawal
                   ` (3 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

From: Shreyansh Jain <shreyansh.jain@nxp.com>

Initial design was to have the buffer pool per process where a
global static array stores the bpids. But, in case of secondary
processes, this would not allow the I/O threads to translate the
bpid in Rx'd packets.

This patch moves the array to a global area (rte_malloc) and in
case of Rx thread not containing a valid reference to the array,
reference is build using the handle avaialble in the dpaa2_queue.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h  |  1 +
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 12 +++++++++++-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.h |  2 +-
 drivers/net/dpaa2/dpaa2_ethdev.c         |  1 +
 drivers/net/dpaa2/dpaa2_rxtx.c           |  5 +++++
 5 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
index efbeebef9..20c606dbe 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
@@ -141,6 +141,7 @@ struct dpaa2_queue {
 	};
 	struct rte_event ev;
 	dpaa2_queue_cb_dqrr_t *cb;
+	struct dpaa2_bp_info *bp_array;
 };
 
 struct swp_active_dqs {
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index 790cded80..335eae40e 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -32,7 +32,7 @@
 
 #include <dpaax_iova_table.h>
 
-struct dpaa2_bp_info rte_dpaa2_bpid_info[MAX_BPID];
+struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
 /* Dynamic logging identified for mempool */
@@ -50,6 +50,16 @@ rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 
 	avail_dpbp = dpaa2_alloc_dpbp_dev();
 
+	if (rte_dpaa2_bpid_info == NULL) {
+		rte_dpaa2_bpid_info = (struct dpaa2_bp_info *)rte_malloc(NULL,
+				      sizeof(struct dpaa2_bp_info) * MAX_BPID,
+				      RTE_CACHE_LINE_SIZE);
+		if (rte_dpaa2_bpid_info == NULL)
+			return -ENOMEM;
+		memset(rte_dpaa2_bpid_info, 0,
+		       sizeof(struct dpaa2_bp_info) * MAX_BPID);
+	}
+
 	if (!avail_dpbp) {
 		DPAA2_MEMPOOL_ERR("DPAA2 pool not available!");
 		return -ENOENT;
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.h b/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
index 4d3468746..93694616e 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
@@ -59,7 +59,7 @@ struct dpaa2_bp_info {
 #define mempool_to_bpinfo(mp) ((struct dpaa2_bp_info *)(mp)->pool_data)
 #define mempool_to_bpid(mp) ((mempool_to_bpinfo(mp))->bpid)
 
-extern struct dpaa2_bp_info rte_dpaa2_bpid_info[MAX_BPID];
+extern struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 
 int rte_dpaa2_mbuf_alloc_bulk(struct rte_mempool *pool,
 		       void **obj_table, unsigned int count);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 861fbcd90..3a20158da 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -485,6 +485,7 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	}
 	dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[rx_queue_id];
 	dpaa2_q->mb_pool = mb_pool; /**< mbuf pool to populate RX ring. */
+	dpaa2_q->bp_array = rte_dpaa2_bpid_info;
 
 	/*Get the flow id from given VQ id*/
 	flow_id = rx_queue_id % priv->nb_rx_queues;
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index 816ea00fd..6e2e8abd7 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -518,6 +518,11 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			return 0;
 		}
 	}
+
+	if (unlikely(!rte_dpaa2_bpid_info &&
+		     rte_eal_process_type() == RTE_PROC_SECONDARY))
+		rte_dpaa2_bpid_info = dpaa2_q->bp_array;
+
 	swp = DPAA2_PER_LCORE_ETHRX_PORTAL;
 	pull_size = (nb_pkts > dpaa2_dqrr_size) ? dpaa2_dqrr_size : nb_pkts;
 	if (unlikely(!q_storage->active_dqs)) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 18/20] net/dpaa2: change ref of device to private device
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (16 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 17/20] mempool/dpaa2: support saving context of buffer pool Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 19/20] bus/fslmc: add support for secondary processes Hemant Agrawal
                   ` (2 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

From: Shreyansh Jain <shreyansh.jain@nxp.com>

The I/O threads for DPAA2 take their reference for bpool ID, the
port ID and other info like qdid, from the rte_eth_dev. Further,
to get this data during I/O operation, a reference of the RTE
device is kept in the queue structure (dpaa2_queue).

In case of secondary processes, rte_eth_dev is not same as the
primary process. Thus, the reference goes invalid.

This patch changes the implementation to use the dev_private
rather than the rte_eth_dev as that is shared area across
all the processes.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h |  5 ++++-
 drivers/net/dpaa2/dpaa2_ethdev.c        |  4 ++--
 drivers/net/dpaa2/dpaa2_rxtx.c          | 18 ++++++++++--------
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
index 20c606dbe..626fcbbca 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
@@ -127,7 +127,10 @@ typedef void (dpaa2_queue_cb_dqrr_t)(struct qbman_swp *swp,
 
 struct dpaa2_queue {
 	struct rte_mempool *mb_pool; /**< mbuf pool to populate RX ring. */
-	void *dev;
+	union {
+		struct rte_eth_dev_data *eth_data;
+		void *dev;
+	};
 	int32_t eventfd;	/*!< Event Fd of this queue */
 	uint32_t fqid;		/*!< Unique ID of this queue */
 	uint8_t tc_index;	/*!< traffic class identifier */
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 3a20158da..2b90f4021 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -244,7 +244,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 	}
 
 	for (i = 0; i < priv->nb_rx_queues; i++) {
-		mc_q->dev = dev;
+		mc_q->eth_data = dev->data;
 		priv->rx_vq[i] = mc_q++;
 		dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
 		dpaa2_q->q_storage = rte_malloc("dq_storage",
@@ -260,7 +260,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 	}
 
 	for (i = 0; i < priv->nb_tx_queues; i++) {
-		mc_q->dev = dev;
+		mc_q->eth_data = dev->data;
 		mc_q->flow_id = 0xffff;
 		priv->tx_vq[i] = mc_q++;
 		dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index 6e2e8abd7..2d4b9ef14 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -509,7 +509,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	const struct qbman_fd *fd, *next_fd;
 	struct qbman_pull_desc pulldesc;
 	struct queue_storage_info_t *q_storage = dpaa2_q->q_storage;
-	struct rte_eth_dev *dev = dpaa2_q->dev;
+	struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
 
 	if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) {
 		ret = dpaa2_affine_qbman_ethrx_swp();
@@ -613,9 +613,10 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			bufs[num_rx] = eth_sg_fd_to_mbuf(fd);
 		else
 			bufs[num_rx] = eth_fd_to_mbuf(fd);
-		bufs[num_rx]->port = dev->data->port_id;
+		bufs[num_rx]->port = eth_data->port_id;
 
-		if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
+		if (eth_data->dev_conf.rxmode.offloads &
+				DEV_RX_OFFLOAD_VLAN_STRIP)
 			rte_vlan_strip(bufs[num_rx]);
 
 		dq_storage++;
@@ -716,8 +717,8 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	struct qbman_swp *swp;
 	uint16_t num_tx = 0;
 	uint16_t bpid;
-	struct rte_eth_dev *dev = dpaa2_q->dev;
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
+	struct dpaa2_dev_priv *priv = eth_data->dev_private;
 	uint32_t flags[MAX_TX_RING_SLOTS] = {0};
 
 	if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
@@ -729,7 +730,8 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	}
 	swp = DPAA2_PER_LCORE_PORTAL;
 
-	DPAA2_PMD_DP_DEBUG("===> dev =%p, fqid =%d\n", dev, dpaa2_q->fqid);
+	DPAA2_PMD_DP_DEBUG("===> eth_data =%p, fqid =%d\n",
+			eth_data, dpaa2_q->fqid);
 
 	/*Prepare enqueue descriptor*/
 	qbman_eq_desc_clear(&eqdesc);
@@ -772,7 +774,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 				    rte_mbuf_refcnt_read((*bufs)) == 1)) {
 					if (unlikely(((*bufs)->ol_flags
 						& PKT_TX_VLAN_PKT) ||
-						(dev->data->dev_conf.txmode.offloads
+						(eth_data->dev_conf.txmode.offloads
 						& DEV_TX_OFFLOAD_VLAN_INSERT))) {
 						ret = rte_vlan_insert(bufs);
 						if (ret)
@@ -794,7 +796,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			}
 
 			if (unlikely(((*bufs)->ol_flags & PKT_TX_VLAN_PKT) ||
-				(dev->data->dev_conf.txmode.offloads
+				(eth_data->dev_conf.txmode.offloads
 				& DEV_TX_OFFLOAD_VLAN_INSERT))) {
 				int ret = rte_vlan_insert(bufs);
 				if (ret)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 19/20] bus/fslmc: add support for secondary processes
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (17 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 18/20] net/dpaa2: change ref of device to private device Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO Hemant Agrawal
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
  20 siblings, 0 replies; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

From: Shreyansh Jain <shreyansh.jain@nxp.com>

Previously FSLMC bus only supported blacklisting of DPNI (eth),
DPSECI (crypto) devices. With this patch, devices like DPIO,
DPMCP, and other DP* can also be blacklisted/whitelisted.

This is a required condition for secondary processes where the
secondary needs to be passed a mutually exclusive list of
resources as compared the primary and all other secondaries.

This patch also moves the DPIO memory from malloc to hugepage so
that in future in case the DPIO list can be shared, it can be
accessed in secondaries.

Once this patch is done, multi-process cases can be executed by
whitelisting/blacklisting devices in each instance.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c           | 51 ++++++++++++++++++++----
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 24 +++++++++--
 2 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 98768a46c..1aae56fa9 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016 NXP
+ *   Copyright 2016-2018 NXP
  *
  */
 
@@ -610,6 +610,15 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
 
 	/* check the MC version compatibility */
 	dpmng.regs = (void *)v_addr;
+
+	/* In case of secondary processes, MC version check is no longer
+	 * required.
+	 */
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		rte_mcp_ptr_list[0] = (void *)v_addr;
+		return 0;
+	}
+
 	if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info)) {
 		DPAA2_BUS_ERR("Unable to obtain MC version");
 		ret = -1;
@@ -653,6 +662,15 @@ fslmc_vfio_process_group(void)
 	/* Search the MCP as that should be initialized first. */
 	TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_temp) {
 		if (dev->dev_type == DPAA2_MPORTAL) {
+			if (dev->device.devargs &&
+			    dev->device.devargs->policy == RTE_DEV_BLACKLISTED) {
+				DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
+					      dev->device.name);
+				TAILQ_REMOVE(&rte_fslmc_bus.device_list,
+						dev, next);
+				continue;
+			}
+
 			ret = fslmc_process_mcp(dev);
 			if (ret) {
 				DPAA2_BUS_ERR("Unable to map MC Portal");
@@ -677,6 +695,13 @@ fslmc_vfio_process_group(void)
 	}
 
 	TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_temp) {
+		if (dev->device.devargs &&
+		    dev->device.devargs->policy == RTE_DEV_BLACKLISTED) {
+			DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
+				      dev->device.name);
+			TAILQ_REMOVE(&rte_fslmc_bus.device_list, dev, next);
+			continue;
+		}
 		switch (dev->dev_type) {
 		case DPAA2_ETH:
 		case DPAA2_CRYPTO:
@@ -689,10 +714,17 @@ fslmc_vfio_process_group(void)
 			}
 			break;
 		case DPAA2_CON:
-		case DPAA2_IO:
 		case DPAA2_CI:
 		case DPAA2_BPOOL:
 		case DPAA2_MUX:
+			/* IN case of secondary processes, all control objects
+			 * like dpbp, dpcon, dpci are not initialized/required
+			 * - all of these are assumed to be initialized and made
+			 *   available by primary.
+			 */
+			if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+				continue;
+
 			/* Call the object creation routine and remove the
 			 * device entry from device list
 			 */
@@ -703,12 +735,15 @@ fslmc_vfio_process_group(void)
 				return -1;
 			}
 
-			/* This device is not required to be in the DPDK
-			 * exposed device list.
-			 */
-			TAILQ_REMOVE(&rte_fslmc_bus.device_list, dev, next);
-			free(dev);
-			dev = NULL;
+			break;
+		case DPAA2_IO:
+			ret = fslmc_process_iodevices(dev);
+			if (ret) {
+				DPAA2_BUS_DEBUG("Dev (%s) init failed",
+						dev->device.name);
+				return -1;
+			}
+
 			break;
 		case DPAA2_UNKNOWN:
 		default:
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index cd28441f3..f377f24ae 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -418,9 +418,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 			goto err;
 	}
 
-	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
-	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
-
+	dpio_dev->dpio = rte_zmalloc(NULL, sizeof(struct fsl_mc_io),
+				     RTE_CACHE_LINE_SIZE);
 	if (!dpio_dev->dpio) {
 		DPAA2_BUS_ERR("Memory allocation failure");
 		goto err;
@@ -535,9 +534,26 @@ dpaa2_create_dpio_device(int vdev_fd,
 	if (dpio_dev->dpio) {
 		dpio_disable(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
 		dpio_close(dpio_dev->dpio, CMD_PRI_LOW,  dpio_dev->token);
-		free(dpio_dev->dpio);
+		rte_free(dpio_dev->dpio);
 	}
+
 	rte_free(dpio_dev);
+
+	/* For each element in the list, cleanup */
+	TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {
+		if (dpio_dev->dpio) {
+			dpio_disable(dpio_dev->dpio, CMD_PRI_LOW,
+				dpio_dev->token);
+			dpio_close(dpio_dev->dpio, CMD_PRI_LOW,
+				dpio_dev->token);
+			rte_free(dpio_dev->dpio);
+		}
+		rte_free(dpio_dev);
+	}
+
+	/* Preventing re-use of the list with old entries */
+	TAILQ_INIT(&dpio_dev_list);
+
 	return -1;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (18 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 19/20] bus/fslmc: add support for secondary processes Hemant Agrawal
@ 2018-12-27  6:23 ` Hemant Agrawal
  2019-01-08 14:10   ` Ferruh Yigit
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
  20 siblings, 1 reply; 70+ messages in thread
From: Hemant Agrawal @ 2018-12-27  6:23 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Pankaj Chauhan, M.h. Lian

From: Pankaj Chauhan <pankaj.chauhan@nxp.com>

This is required to map any accelerator memory
and PCI address to VFIO using QDMA.

Signed-off-by: Minghuan Lian <Minghuan.Lian@nxp.com>
Signed-off-by: Pankaj Chauhan <pankaj.chauhan@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c              | 42 +++++++++++++++++++++
 drivers/bus/fslmc/fslmc_vfio.h              |  1 +
 drivers/bus/fslmc/rte_bus_fslmc_version.map |  7 ++++
 3 files changed, 50 insertions(+)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1aae56fa9..9befc8087 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -50,6 +50,7 @@ static struct fslmc_vfio_group vfio_group;
 static struct fslmc_vfio_container vfio_container;
 static int container_device_fd;
 static char *g_container;
+static int fslmc_iommu_type;
 static uint32_t *msi_intr_vaddr;
 void *(*rte_mcp_ptr_list);
 
@@ -90,6 +91,9 @@ fslmc_get_container_group(int *groupid)
 		}
 	}
 
+	fslmc_iommu_type = (rte_vfio_noiommu_is_enabled() == 1) ?
+		RTE_VFIO_NOIOMMU : VFIO_TYPE1_IOMMU;
+
 	/* get group number */
 	ret = rte_vfio_get_group_num(SYSFS_FSL_MC_DEVICES,
 				     g_container, groupid);
@@ -344,6 +348,44 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
 	return ret;
 }
 
+int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size)
+{
+	int ret;
+	struct fslmc_vfio_group *group;
+	struct vfio_iommu_type1_dma_map dma_map = {
+		.argsz = sizeof(struct vfio_iommu_type1_dma_map),
+		.flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
+	};
+
+	if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) {
+		DPAA2_BUS_DEBUG("Running in NOIOMMU mode");
+		return 0;
+	}
+
+	/* SET DMA MAP for IOMMU */
+	group = &vfio_group;
+	if (!group->container) {
+		DPAA2_BUS_ERR("Container is not connected");
+		return -1;
+	}
+
+	dma_map.size = size;
+	dma_map.vaddr = vaddr;
+	dma_map.iova = iova;
+
+	printf("PCIe vfio map 0x%llx:0x%llx, size 0x%llx\n", dma_map.vaddr,
+		dma_map.iova, dma_map.size);
+	ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA,
+		    &dma_map);
+	if (ret) {
+		printf("Unable to map DMA address (errno = %d)\n",
+			errno);
+		return ret;
+	}
+
+	return 0;
+}
+
 int rte_fslmc_vfio_dmamap(void)
 {
 	int i = 0, ret;
diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h
index 9e2c4feef..4e750d623 100644
--- a/drivers/bus/fslmc/fslmc_vfio.h
+++ b/drivers/bus/fslmc/fslmc_vfio.h
@@ -50,5 +50,6 @@ int fslmc_vfio_process_group(void);
 char *fslmc_get_container(void);
 int fslmc_get_container_group(int *gropuid);
 int rte_fslmc_vfio_dmamap(void);
+int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size);
 
 #endif /* _FSLMC_VFIO_H_ */
diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map
index dcc4e082e..c4192d978 100644
--- a/drivers/bus/fslmc/rte_bus_fslmc_version.map
+++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map
@@ -129,3 +129,10 @@ DPDK_18.11 {
 	dpci_set_opr;
 
 } DPDK_18.05;
+
+DPDK_19.02 {
+	global:
+
+	rte_fslmc_vfio_mem_dmamap;
+
+} DPDK_18.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO Hemant Agrawal
@ 2019-01-08 14:10   ` Ferruh Yigit
  2019-01-10  9:58     ` Shreyansh Jain
  0 siblings, 1 reply; 70+ messages in thread
From: Ferruh Yigit @ 2019-01-08 14:10 UTC (permalink / raw)
  To: Hemant Agrawal, dev; +Cc: Shreyansh Jain, Pankaj Chauhan, M.h. Lian

On 12/27/2018 6:23 AM, Hemant Agrawal wrote:
> From: Pankaj Chauhan <pankaj.chauhan@nxp.com>
> 
> This is required to map any accelerator memory
> and PCI address to VFIO using QDMA.
> 
> Signed-off-by: Minghuan Lian <Minghuan.Lian@nxp.com>
> Signed-off-by: Pankaj Chauhan <pankaj.chauhan@nxp.com>

This requires either sign-off or ack from 'bus/fslmc' maintainers, which are:
	M: Hemant Agrawal <hemant.agrawal@nxp.com>



	M: Shreyansh Jain <shreyansh.jain@nxp.com>

I think Hemant sending the patchset implies that this has been reviewed by him
but this information get lost in git, so better to explicitly provide review/ack
tags whenever appropriate.

<...>

> +	printf("PCIe vfio map 0x%llx:0x%llx, size 0x%llx\n", dma_map.vaddr,
> +		dma_map.iova, dma_map.size);

This is causing build error [1], but why at first place using 'printf()' instead
of logging macros?

[1]
.../drivers/bus/fslmc/fslmc_vfio.c: In function ‘rte_fslmc_vfio_mem_dmamap’:
.../drivers/bus/fslmc/fslmc_vfio.c:376:29: error: format ‘%llx’ expects argument
of type ‘long long unsigned int’, but argument 2 has type ‘__u64’ {aka ‘long
unsigned int’} [-Werror=format=]
  printf("PCIe vfio map 0x%llx:0x%llx, size 0x%llx\n", dma_map.vaddr,
                          ~~~^                         ~~~~~~~~~~~~~
                          %lx

<...>

> +DPDK_19.02 {
> +	global:
> +
> +	rte_fslmc_vfio_mem_dmamap;

Is this need to be an API? Who is the consumer of this API, I don't see anyone
calls this function?

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO
  2019-01-08 14:10   ` Ferruh Yigit
@ 2019-01-10  9:58     ` Shreyansh Jain
  2019-01-11 11:58       ` Ferruh Yigit
  0 siblings, 1 reply; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-10  9:58 UTC (permalink / raw)
  To: Ferruh Yigit, Hemant Agrawal, dev; +Cc: Pankaj Chauhan, M.h. Lian

Hello Ferruh,

Replying on behalf of Hemant...

On 08/01/19 7:40 PM, Ferruh Yigit wrote:
> On 12/27/2018 6:23 AM, Hemant Agrawal wrote:
>> From: Pankaj Chauhan <pankaj.chauhan@nxp.com>
>>
>> This is required to map any accelerator memory
>> and PCI address to VFIO using QDMA.
>>
>> Signed-off-by: Minghuan Lian <Minghuan.Lian@nxp.com>
>> Signed-off-by: Pankaj Chauhan <pankaj.chauhan@nxp.com>
> 
> This requires either sign-off or ack from 'bus/fslmc' maintainers, which are:
> 	M: Hemant Agrawal <hemant.agrawal@nxp.com>
> 
> 
> 
> 	M: Shreyansh Jain <shreyansh.jain@nxp.com>
> 
> I think Hemant sending the patchset implies that this has been reviewed by him
> but this information get lost in git, so better to explicitly provide review/ack
> tags whenever appropriate.

What I will do is, re-spin the complete series (with error below 
fixed...) and send again. All the patches are on FSLMC/DPAA2 drivers 
only so probably Hemant's or my Acks would work directly.

> 
> <...>
> 
>> +	printf("PCIe vfio map 0x%llx:0x%llx, size 0x%llx\n", dma_map.vaddr,
>> +		dma_map.iova, dma_map.size);
> 
> This is causing build error [1], but why at first place using 'printf()' instead
> of logging macros?

I will fix this.

> 
> [1]
> .../drivers/bus/fslmc/fslmc_vfio.c: In function ‘rte_fslmc_vfio_mem_dmamap’:
> .../drivers/bus/fslmc/fslmc_vfio.c:376:29: error: format ‘%llx’ expects argument
> of type ‘long long unsigned int’, but argument 2 has type ‘__u64’ {aka ‘long
> unsigned int’} [-Werror=format=]
>    printf("PCIe vfio map 0x%llx:0x%llx, size 0x%llx\n", dma_map.vaddr,
>                            ~~~^                         ~~~~~~~~~~~~~
>                            %lx
> 
> <...>
> 
>> +DPDK_19.02 {
>> +	global:
>> +
>> +	rte_fslmc_vfio_mem_dmamap;
> 
> Is this need to be an API? Who is the consumer of this API, I don't see anyone
> calls this function?
> 

This API (internal to FSLMC) was added for one of NXP's internal 
software stack over DPDK. As this is an internal API, I don't think it 
would pollute the outer namespace - isn't it? And, I think its consumers 
won't necessarily be within DPDK stack.

Or, if this is conflicting case, I will remove this patch (it is 
independent) and send again. Let me know your reservation.

-
Shreyansh


^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements
  2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
                   ` (19 preceding siblings ...)
  2018-12-27  6:23 ` [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO Hemant Agrawal
@ 2019-01-11 11:57 ` Shreyansh Jain
  2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 01/20] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
                     ` (20 more replies)
  20 siblings, 21 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:57 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

(N: Original series was by Hemant - due to RC window timeline and
    his unavailability, respining on his behalf)

This patch set covers following:

1. Fixes in the existing NXP DPAA2 bus and net pmd
2. New object (DPDMUX) support in NIC driver for better classification
3. Improvements to support secondary process
4. Upgrade the low level QBMAN HW lib

History:
v1->v2:
 - Fix warning on Patch 20/20 - moved printfs to logging macro
   and PRIx changes
 - reset author of 07/20 as the signoff and author didn't match
 - Validate over master (a958a5c07f4b5e)
 - Reword patch headline/commit based on check-git-log script

Akhil Goyal (1):
  net/dpaa2: enable optional timestamp in mbuf

Hemant Agrawal (7):
  bus/fslmc: fix to use correct physical core for logical core
  net/dpaa2: fix bad check for not-null
  bus/fslmc: fix to convert error msg to warning
  bus/fslmc: upgrade to latest qbman library
  bus/fslmc: add dynamic config for memback portal mode
  bus/fslmc: rename portal pi index to consumer index
  bus/fslmc: make portal func static

Nipun Gupta (4):
  net/dpaa2: add dpdmux mc flib
  bus/fslmc: add support for scanning DPDMUX object
  net/dpaa2: add dpdmux initialization and configuration
  net/dpaa2: add API to support custom hash key

Pankaj Chauhan (1):
  bus/fslmc: add function to map any addr via VFIO

Sachin Saxena (1):
  bus/fslmc: fix to reset portal memory before use

Shreyansh Jain (5):
  bus/fslmc: fix parse method for bus devices
  net/dpaa2: fix device init for secondary process
  mempool/dpaa2: support saving context of buffer pool
  net/dpaa2: change reference to private device
  bus/fslmc: add support for secondary processes

Youri Querry (1):
  bus/fslmc: fix the ring mode to use correct cache settings

 doc/api/doxy-api-index.md                     |   1 +
 doc/api/doxy-api.conf.in                      |   1 +
 drivers/bus/fslmc/fslmc_bus.c                 |  38 +-
 drivers/bus/fslmc/fslmc_vfio.c                |  98 +-
 drivers/bus/fslmc/fslmc_vfio.h                |   1 +
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      | 100 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h      |   2 -
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h       |   6 +-
 .../bus/fslmc/qbman/include/fsl_qbman_base.h  |  11 +-
 drivers/bus/fslmc/qbman/qbman_portal.c        | 123 ++-
 drivers/bus/fslmc/qbman/qbman_portal.h        |   2 +-
 drivers/bus/fslmc/qbman/qbman_sys.h           |  34 +-
 drivers/bus/fslmc/rte_bus_fslmc_version.map   |   7 +
 drivers/bus/fslmc/rte_fslmc.h                 |   1 +
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      |  12 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.h      |   2 +-
 drivers/net/dpaa2/Makefile                    |   4 +
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c        |  54 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  26 +-
 drivers/net/dpaa2/dpaa2_ethdev.h              |   6 +
 drivers/net/dpaa2/dpaa2_mux.c                 | 222 +++++
 drivers/net/dpaa2/dpaa2_rxtx.c                |  41 +-
 drivers/net/dpaa2/mc/dpdmux.c                 | 929 ++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux.h             | 410 ++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h         | 221 +++++
 drivers/net/dpaa2/meson.build                 |   4 +
 drivers/net/dpaa2/rte_pmd_dpaa2.h             |  90 ++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map   |   8 +
 28 files changed, 2318 insertions(+), 136 deletions(-)
 create mode 100644 drivers/net/dpaa2/dpaa2_mux.c
 create mode 100644 drivers/net/dpaa2/mc/dpdmux.c
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux.h
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
 create mode 100644 drivers/net/dpaa2/rte_pmd_dpaa2.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 01/20] bus/fslmc: fix to reset portal memory before use
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
@ 2019-01-11 11:57   ` Shreyansh Jain
  2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 02/20] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
                     ` (19 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:57 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Sachin Saxena, stable

From: Sachin Saxena <sachin.saxena@nxp.com>

Uninitialized portal memory is causing unwanted issues.

Fixes: 293c0ca94c36 ("bus/fslmc: support memory backed portals with QBMAN 5.0")
Cc: stable@dpdk.org

Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index ce0699842..4fc6efec5 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -369,6 +369,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 	dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX];
 
 	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
+	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
+
 	if (!dpio_dev->dpio) {
 		DPAA2_BUS_ERR("Memory allocation failure");
 		goto err;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 02/20] bus/fslmc: fix the ring mode to use correct cache settings
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
  2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 01/20] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
@ 2019-01-11 11:57   ` Shreyansh Jain
  2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 03/20] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
                     ` (18 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:57 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Youri Querry, stable

From: Youri Querry <youri.querry_1@nxp.com>

The code was incorrectly using the cache inhibited access.
It shall use cached enabled access for better performance.

Fixes: 293c0ca94c36 ("bus/fslmc: support memory backed portals with QBMAN 5.0")
Cc: stable@dpdk.org

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c | 12 ++++++------
 drivers/bus/fslmc/qbman/qbman_sys.h    |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 3380e54f5..bbea37efc 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -683,8 +683,8 @@ static int qbman_swp_enqueue_ring_mode_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 				eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
@@ -809,8 +809,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 					eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
@@ -941,8 +941,8 @@ static int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 					eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index d41af8358..0571097ab 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -55,6 +55,7 @@
 #define QBMAN_CENA_SWP_RR(vb)  (0x700 + ((uint32_t)(vb) >> 1))
 #define QBMAN_CENA_SWP_VDQCR   0x780
 #define QBMAN_CENA_SWP_EQCR_CI 0x840
+#define QBMAN_CENA_SWP_EQCR_CI_MEMBACK 0x1840
 
 /* CENA register offsets in memory-backed mode */
 #define QBMAN_CENA_SWP_DQRR_MEM(n)  (0x800 + ((uint32_t)(n) << 6))
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 03/20] bus/fslmc: fix to use correct physical core for logical core
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
  2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 01/20] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
  2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 02/20] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
@ 2019-01-11 11:57   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 04/20] net/dpaa2: fix bad check for not-null Shreyansh Jain
                     ` (17 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:57 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, stable

From: Hemant Agrawal <hemant.agrawal@nxp.com>

Existing code is using the lcore id as the physical core
id. Add code to get the right physical id.

Also, dpaa2 can not support one lcore mapping to multiple cpus,
print err on such cases.

Fixes: ce9efbf5bb09 ("bus/fslmc: support dynamic logging")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 76 ++++++++++++++++++++----
 1 file changed, 63 insertions(+), 13 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 4fc6efec5..ba2e28ce1 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -53,6 +53,10 @@ static uint32_t io_space_count;
 /* Variable to store DPAA2 platform type */
 uint32_t dpaa2_svr_family;
 
+/* Physical core id for lcores running on dpaa2. */
+/* DPAA2 only support 1 lcore to 1 phy cpu mapping */
+static unsigned int dpaa2_cpu[RTE_MAX_LCORE];
+
 /* Variable to store DPAA2 DQRR size */
 uint8_t dpaa2_dqrr_size;
 /* Variable to store DPAA2 EQCR size */
@@ -92,7 +96,8 @@ dpaa2_core_cluster_sdest(int cpu_id)
 }
 
 #ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
-static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
+static void
+dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, int lcoreid)
 {
 #define STRING_LEN	28
 #define COMMAND_LEN	50
@@ -125,7 +130,7 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
 		return;
 	}
 
-	cpu_mask = cpu_mask << rte_lcore_id();
+	cpu_mask = cpu_mask << dpaa2_cpu[lcoreid];
 	snprintf(command, COMMAND_LEN, "echo %X > /proc/irq/%s/smp_affinity",
 		 cpu_mask, token);
 	ret = system(command);
@@ -139,7 +144,7 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
 	fclose(file);
 }
 
-static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
+static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 {
 	struct epoll_event epoll_ev;
 	int eventfd, dpio_epoll_fd, ret;
@@ -176,32 +181,36 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
 	}
 	dpio_dev->epoll_fd = dpio_epoll_fd;
 
-	dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id);
+	dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id, lcoreid);
 
 	return 0;
 }
 #endif
 
 static int
-dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
+dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 {
 	int sdest, ret;
+	int cpu_id;
 
 	/* Set the Stashing Destination */
-	if (cpu_id < 0) {
-		cpu_id = rte_get_master_lcore();
-		if (cpu_id < 0) {
+	if (lcoreid < 0) {
+		lcoreid = rte_get_master_lcore();
+		if (lcoreid < 0) {
 			DPAA2_BUS_ERR("Getting CPU Index failed");
 			return -1;
 		}
 	}
+
+	cpu_id = dpaa2_cpu[lcoreid];
+
 	/* Set the STASH Destination depending on Current CPU ID.
 	 * Valid values of SDEST are 4,5,6,7. Where,
 	 */
 
 	sdest = dpaa2_core_cluster_sdest(cpu_id);
-	DPAA2_BUS_DEBUG("Portal= %d  CPU= %u SDEST= %d",
-			dpio_dev->index, cpu_id, sdest);
+	DPAA2_BUS_DEBUG("Portal= %d  CPU= %u lcore id =%u SDEST= %d",
+			dpio_dev->index, cpu_id, lcoreid, sdest);
 
 	ret = dpio_set_stashing_destination(dpio_dev->dpio, CMD_PRI_LOW,
 					    dpio_dev->token, sdest);
@@ -211,7 +220,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
 	}
 
 #ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
-	if (dpaa2_dpio_intr_init(dpio_dev)) {
+	if (dpaa2_dpio_intr_init(dpio_dev, lcoreid)) {
 		DPAA2_BUS_ERR("Interrupt registration failed for dpio");
 		return -1;
 	}
@@ -220,7 +229,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
 	return 0;
 }
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id)
+struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
 	int ret;
@@ -236,7 +245,7 @@ struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id)
 	DPAA2_BUS_DEBUG("New Portal %p (%d) affined thread - %lu",
 			dpio_dev, dpio_dev->index, syscall(SYS_gettid));
 
-	ret = dpaa2_configure_stashing(dpio_dev, cpu_id);
+	ret = dpaa2_configure_stashing(dpio_dev, lcoreid);
 	if (ret)
 		DPAA2_BUS_ERR("dpaa2_configure_stashing failed");
 
@@ -340,6 +349,39 @@ dpaa2_affine_qbman_ethrx_swp(void)
 	}
 }
 
+/*
+ * This checks for not supported lcore mappings as well as get the physical
+ * cpuid for the lcore.
+ * one lcore can only map to 1 cpu i.e. 1@10-14 not supported.
+ * one cpu can be mapped to more than one lcores.
+ */
+static int
+dpaa2_check_lcore_cpuset(void)
+{
+	unsigned int lcore_id, i;
+	int ret = 0;
+
+	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
+		dpaa2_cpu[lcore_id] = 0xffffffff;
+
+	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
+		for (i = 0; i < RTE_MAX_LCORE; i++) {
+			if (CPU_ISSET(i, &lcore_config[lcore_id].cpuset)) {
+				RTE_LOG(DEBUG, EAL, "lcore id = %u cpu=%u\n",
+					lcore_id, i);
+				if (dpaa2_cpu[lcore_id] != 0xffffffff) {
+					DPAA2_BUS_ERR(
+				    "ERR:lcore map to multi-cpu not supported");
+					ret = -1;
+				} else  {
+					dpaa2_cpu[lcore_id] = i;
+				}
+			}
+		}
+	}
+	return ret;
+}
+
 static int
 dpaa2_create_dpio_device(int vdev_fd,
 			 struct vfio_device_info *obj_info,
@@ -349,6 +391,7 @@ dpaa2_create_dpio_device(int vdev_fd,
 	struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)};
 	struct qbman_swp_desc p_des;
 	struct dpio_attr attr;
+	static int check_lcore_cpuset;
 
 	if (obj_info->num_regions < NUM_DPIO_REGIONS) {
 		DPAA2_BUS_ERR("Not sufficient number of DPIO regions");
@@ -368,6 +411,13 @@ dpaa2_create_dpio_device(int vdev_fd,
 	/* Using single portal  for all devices */
 	dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX];
 
+	if (!check_lcore_cpuset) {
+		check_lcore_cpuset = 1;
+
+		if (dpaa2_check_lcore_cpuset() < 0)
+			goto err;
+	}
+
 	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
 	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 04/20] net/dpaa2: fix bad check for not-null
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (2 preceding siblings ...)
  2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 03/20] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 05/20] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
                     ` (16 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, stable

From: Hemant Agrawal <hemant.agrawal@nxp.com>

The check !dpaa2->cscn is not correct to check non-null value.

Fixes: 5d9a1e4d23fe ("net/dpaa2: enhance queue memory cleanup")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index fa71807e6..8d4ea1bca 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -311,8 +311,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
 		/* cleanup tx queue cscn */
 		for (i = 0; i < priv->nb_tx_queues; i++) {
 			dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
-			if (!dpaa2_q->cscn)
-				rte_free(dpaa2_q->cscn);
+			rte_free(dpaa2_q->cscn);
 		}
 		/*free memory for all queues (RX+TX) */
 		rte_free(priv->rx_vq[0]);
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 05/20] bus/fslmc: fix to convert error msg to warning
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (3 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 04/20] net/dpaa2: fix bad check for not-null Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 06/20] bus/fslmc: fix parse method for bus devices Shreyansh Jain
                     ` (15 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, stable

From: Hemant Agrawal <hemant.agrawal@nxp.com>

This is just a information. No need to print
it as a error.

Fixes: ce9efbf5bb09 ("bus/fslmc: support dynamic logging")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 493b6e5be..ce82a99f6 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -176,7 +176,7 @@ static int vfio_map_irq_region(struct fslmc_vfio_group *group)
 	vaddr = (unsigned long *)mmap(NULL, 0x1000, PROT_WRITE |
 		PROT_READ, MAP_SHARED, container_device_fd, 0x6030000);
 	if (vaddr == MAP_FAILED) {
-		DPAA2_BUS_ERR("Unable to map region (errno = %d)", errno);
+		DPAA2_BUS_INFO("Unable to map region (errno = %d)", errno);
 		return -errno;
 	}
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 06/20] bus/fslmc: fix parse method for bus devices
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (4 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 05/20] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 07/20] net/dpaa2: fix device init for secondary process Shreyansh Jain
                     ` (14 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

Current code expects that bus->parse() would get a string containing
the name of the bus. That is incorrect. bus->parse() is expected
to have strings like:
  dpni.1,key=val
  dpio.2,key=val

when user passed:
  -b fslmc:dpni.1,key=val

This commit fixes this behavior.

Fixes: 50245be05d1a ("bus/fslmc: support device blacklisting")
Cc: stable@dpdk.org

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 89af9385a..565e0148f 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- *   Copyright 2016 NXP
+ *   Copyright 2016,2018 NXP
  *
  */
 
@@ -227,20 +227,16 @@ static int
 rte_fslmc_parse(const char *name, void *addr)
 {
 	uint16_t dev_id;
-	char *t_ptr;
-	char *sep = strchr(name, ':');
+	char *t_ptr = NULL, *dname = NULL;
 
-	if (strncmp(name, RTE_STR(FSLMC_BUS_NAME),
-		strlen(RTE_STR(FSLMC_BUS_NAME)))) {
-		return -EINVAL;
-	}
+	/* 'name' is expected to contain name of device, for example, dpio.1,
+	 * dpni.2, etc.
+	 */
 
-	if (!sep) {
-		DPAA2_BUS_ERR("Incorrect device name observed");
+	dname = strdup(name);
+	if (!dname)
 		return -EINVAL;
-	}
-
-	t_ptr = (char *)(sep + 1);
+	t_ptr = dname;
 
 	if (strncmp("dpni", t_ptr, 4) &&
 	    strncmp("dpseci", t_ptr, 6) &&
@@ -251,24 +247,29 @@ rte_fslmc_parse(const char *name, void *addr)
 	    strncmp("dpmcp", t_ptr, 5) &&
 	    strncmp("dpdmai", t_ptr, 6)) {
 		DPAA2_BUS_ERR("Unknown or unsupported device");
-		return -EINVAL;
+		goto err_out;
 	}
 
 	t_ptr = strchr(name, '.');
 	if (!t_ptr) {
 		DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
-		return -EINVAL;
+		goto err_out;
 	}
 
 	t_ptr = (char *)(t_ptr + 1);
 	if (sscanf(t_ptr, "%hu", &dev_id) <= 0) {
 		DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
-		return -EINVAL;
+		goto err_out;
 	}
+	free(dname);
 
 	if (addr)
-		strcpy(addr, (char *)(sep + 1));
+		strcpy(addr, name);
+
 	return 0;
+err_out:
+	free(dname);
+	return -EINVAL;
 }
 
 static int
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 07/20] net/dpaa2: fix device init for secondary process
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (5 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 06/20] bus/fslmc: fix parse method for bus devices Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 08/20] net/dpaa2: enable optional timestamp in mbuf Shreyansh Jain
                     ` (13 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

In order to support I/O from secondary process, the
burst APIs and OPS APIs shall be mapped/plugged.

Fixes: c147eae01cb3 ("net/dpaa2: introduce NXP DPAA2 driver")
Cc: stable@dpdk.org

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 8d4ea1bca..39f85ae7b 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1918,8 +1918,15 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* For secondary processes, the primary has done all the work */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		/* In case of secondary, only burst and ops API need to be
+		 * plugged.
+		 */
+		eth_dev->dev_ops = &dpaa2_ethdev_ops;
+		eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
+		eth_dev->tx_pkt_burst = dpaa2_dev_tx;
 		return 0;
+	}
 
 	dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 08/20] net/dpaa2: enable optional timestamp in mbuf
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (6 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 07/20] net/dpaa2: fix device init for secondary process Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 09/20] bus/fslmc: upgrade to latest qbman library Shreyansh Jain
                     ` (12 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Akhil Goyal

From: Akhil Goyal <akhil.goyal@nxp.com>

This patch enables the population of timestamp field
in mbuf on packet receive.
It may give performance impact on LX2xxx platforms.
So, it has been made optional for Lx2xxx platform.
One shall call, rte_dpaa2_enable_ts() to enable it.

Nothing is required for LS2 and LS1088 platforms.

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
 doc/api/doxy-api-index.md                   |  1 +
 doc/api/doxy-api.conf.in                    |  1 +
 drivers/net/dpaa2/Makefile                  |  2 ++
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c      |  2 ++
 drivers/net/dpaa2/dpaa2_ethdev.c            |  9 +++++
 drivers/net/dpaa2/dpaa2_ethdev.h            |  4 +++
 drivers/net/dpaa2/dpaa2_rxtx.c              | 18 ++++++++++
 drivers/net/dpaa2/meson.build               |  2 ++
 drivers/net/dpaa2/rte_pmd_dpaa2.h           | 39 +++++++++++++++++++++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |  6 ++++
 10 files changed, 84 insertions(+)
 create mode 100644 drivers/net/dpaa2/rte_pmd_dpaa2.h

diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index e27874c5a..d95ad566c 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -43,6 +43,7 @@ The public API headers are grouped by topics:
   [i40e]               (@ref rte_pmd_i40e.h),
   [bnxt]               (@ref rte_pmd_bnxt.h),
   [dpaa]               (@ref rte_pmd_dpaa.h),
+  [dpaa2]              (@ref rte_pmd_dpaa2.h),
   [dpaa2_mempool]      (@ref rte_dpaa2_mempool.h),
   [dpaa2_cmdif]        (@ref rte_pmd_dpaa2_cmdif.h),
   [dpaa2_qdma]         (@ref rte_pmd_dpaa2_qdma.h),
diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index 77ba327a8..bef9320c0 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -9,6 +9,7 @@ INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \
                           @TOPDIR@/drivers/net/bnxt \
                           @TOPDIR@/drivers/net/bonding \
                           @TOPDIR@/drivers/net/dpaa \
+                          @TOPDIR@/drivers/net/dpaa2 \
                           @TOPDIR@/drivers/net/i40e \
                           @TOPDIR@/drivers/net/ixgbe \
                           @TOPDIR@/drivers/net/softnic \
diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index ca5f7a336..2b9c011d6 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -42,4 +42,6 @@ LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
 LDLIBS += -lrte_common_dpaax
 
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_DPAA2_PMD)-include := rte_pmd_dpaa2.h
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
index 713a41bf3..a6f86df8c 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
@@ -296,8 +296,10 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
 			 DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
 			 DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
 			 DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
+			 DPNI_BUF_LAYOUT_OPT_TIMESTAMP |
 			 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
 
+	layout.pass_timestamp = true;
 	layout.pass_frame_status = 1;
 	layout.private_data_size = DPAA2_FD_PTA_SIZE;
 	layout.pass_parser_result = 1;
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 39f85ae7b..861fbcd90 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -56,6 +56,9 @@ static uint64_t dev_tx_offloads_nodis =
 		DEV_TX_OFFLOAD_MT_LOCKFREE |
 		DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+/* enable timestamp in mbuf */
+enum pmd_dpaa2_ts dpaa2_enable_ts;
+
 struct rte_dpaa2_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	uint8_t page_id; /* dpni statistics page id */
@@ -88,6 +91,12 @@ static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 int dpaa2_logtype_pmd;
 
+__rte_experimental void
+rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable)
+{
+	dpaa2_enable_ts = enable;
+}
+
 static int
 dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 {
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index bd69f523d..7cf6e4191 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -9,6 +9,7 @@
 #define _DPAA2_ETHDEV_H
 
 #include <rte_event_eth_rx_adapter.h>
+#include <rte_pmd_dpaa2.h>
 
 #include <mc/fsl_dpni.h>
 #include <mc/fsl_mc_sys.h>
@@ -83,6 +84,9 @@
 #define DPAA2_PKT_TYPE_VLAN_1		0x0160
 #define DPAA2_PKT_TYPE_VLAN_2		0x0260
 
+/* enable timestamp in mbuf*/
+extern enum pmd_dpaa2_ts dpaa2_enable_ts;
+
 struct dpaa2_dev_priv {
 	void *hw;
 	int32_t hw_id;
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index eab943dcf..816ea00fd 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -42,6 +42,7 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf,
 static inline void __attribute__((hot))
 dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd)
 {
+	struct dpaa2_annot_hdr *annotation;
 	uint16_t frc = DPAA2_GET_FD_FRC_PARSE_SUM(fd);
 
 	m->packet_type = RTE_PTYPE_UNKNOWN;
@@ -104,6 +105,19 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd)
 	}
 	m->hash.rss = fd->simple.flc_hi;
 	m->ol_flags |= PKT_RX_RSS_HASH;
+
+	if (dpaa2_enable_ts == PMD_DPAA2_ENABLE_TS) {
+		annotation = (struct dpaa2_annot_hdr *)
+			((size_t)DPAA2_IOVA_TO_VADDR(
+			DPAA2_GET_FD_ADDR(fd)) + DPAA2_FD_PTA_SIZE);
+		m->timestamp = annotation->word2;
+		m->ol_flags |= PKT_RX_TIMESTAMP;
+		DPAA2_PMD_DP_DEBUG("pkt timestamp:0x%" PRIx64 "", m->timestamp);
+	}
+
+	DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
+		"ol_flags =0x%" PRIx64 "",
+		frc, m->packet_type, m->ol_flags);
 }
 
 static inline uint32_t __attribute__((hot))
@@ -205,6 +219,10 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)
 	else if (BIT_ISSET_AT_POS(annotation->word8, DPAA2_ETH_FAS_L4CE))
 		mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
+	mbuf->ol_flags |= PKT_RX_TIMESTAMP;
+	mbuf->timestamp = annotation->word2;
+	DPAA2_PMD_DP_DEBUG("pkt timestamp: 0x%" PRIx64 "", mbuf->timestamp);
+
 	/* Check detailed parsing requirement */
 	if (annotation->word3 & 0x7FFFFC3FFFF)
 		return dpaa2_dev_rx_parse_slow(mbuf, annotation);
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index b34595258..07aada87c 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -18,3 +18,5 @@ includes += include_directories('base', 'mc')
 
 # depends on fslmc bus which uses experimental API
 allow_experimental_apis = true
+
+install_headers('rte_pmd_dpaa2.h')
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
new file mode 100644
index 000000000..f9303acad
--- /dev/null
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#ifndef _RTE_PMD_DPAA2_H
+#define _RTE_PMD_DPAA2_H
+
+/**
+ * @file rte_pmd_dpaa2.h
+ *
+ * NXP dpaa2 PMD specific functions.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ */
+
+#include <rte_flow.h>
+
+enum pmd_dpaa2_ts {
+	PMD_DPAA2_DISABLE_TS,
+	PMD_DPAA2_ENABLE_TS
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Enable/Disable timestamping update in mbuf for LX2160 kind of devices.
+ * For LS2088/LS1088 devices, timestamping will be updated in mbuf without
+ * calling this API.
+ *
+ * @param pmd_dpaa2_ts
+ *    Enum to enable/disable timestamp update in mbuf for LX2160 devices.
+ */
+__rte_experimental
+void rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts);
+
+#endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index 09f4364bc..de95a03cd 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -10,3 +10,9 @@ DPDK_17.11 {
 	dpaa2_eth_eventq_detach;
 
 } DPDK_17.05;
+
+EXPERIMENTAL {
+	global:
+
+	rte_pmd_dpaa2_set_timestamp;
+} DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 09/20] bus/fslmc: upgrade to latest qbman library
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (7 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 08/20] net/dpaa2: enable optional timestamp in mbuf Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 10/20] bus/fslmc: add dynamic config for memback portal mode Shreyansh Jain
                     ` (11 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, Youri Querry, Nipun Gupta

From: Hemant Agrawal <hemant.agrawal@nxp.com>

This patch upgrades and sync the dpdk based qbman code
with new version of qbman flib.

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c |  8 ++++----
 drivers/bus/fslmc/qbman/qbman_sys.h    | 17 +++++++++++------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index bbea37efc..2f572a08b 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -201,7 +201,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	p->vdq.valid_bit = QB_VALID_BIT;
 	p->dqrr.valid_bit = QB_VALID_BIT;
 	qman_version = p->desc.qman_version;
-	if ((qman_version & 0xFFFF0000) < QMAN_REV_4100) {
+	if ((qman_version & QMAN_REV_MASK) < QMAN_REV_4100) {
 		p->dqrr.dqrr_size = 4;
 		p->dqrr.reset_bug = 1;
 	} else {
@@ -1315,9 +1315,9 @@ const struct qbman_result *qbman_swp_dqrr_next_mem_back(struct qbman_swp *s)
 	 */
 	flags = p->dq.stat;
 	response_verb = verb & QBMAN_RESPONSE_VERB_MASK;
-	if ((response_verb == QBMAN_RESULT_DQ) &&
-	    (flags & QBMAN_DQ_STAT_VOLATILE) &&
-	    (flags & QBMAN_DQ_STAT_EXPIRED))
+	if ((response_verb == QBMAN_RESULT_DQ)
+			&& (flags & QBMAN_DQ_STAT_VOLATILE)
+			&& (flags & QBMAN_DQ_STAT_EXPIRED))
 		atomic_inc(&s->vdq.busy);
 	return p;
 }
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index 0571097ab..e3bd1c5e6 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -387,6 +387,10 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 {
 	uint32_t reg;
 	int i;
+	int cena_region_size = 4*1024;
+
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+		cena_region_size = 64*1024;
 #ifdef RTE_ARCH_64
 	uint8_t wn = CENA_WRITE_ENABLE;
 #else
@@ -396,7 +400,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	s->addr_cena = d->cena_bar;
 	s->addr_cinh = d->cinh_bar;
 	s->idx = (uint32_t)d->idx;
-	s->cena = malloc(64*1024);
+	s->cena = malloc(cena_region_size);
+
 	if (!s->cena) {
 		pr_err("Could not allocate page for cena shadow\n");
 		return -1;
@@ -412,12 +417,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	QBMAN_BUG_ON(reg);
 #endif
 	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
-		memset(s->addr_cena, 0, 64*1024);
+		memset(s->addr_cena, 0, cena_region_size);
 	else {
 		/* Invalidate the portal memory.
 		 * This ensures no stale cache lines
 		 */
-		for (i = 0; i < 0x1000; i += 64)
+		for (i = 0; i < cena_region_size; i += 64)
 			dccivac(s->addr_cena + i);
 	}
 
@@ -425,12 +430,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 		reg = qbman_set_swp_cfg(dqrr_size, wn,
 					0, 3, 2, 3, 1, 1, 1, 1, 1, 1);
 	else {
-		if ((d->qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
+		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
-						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
+						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
 		else
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
-						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
+						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
 	}
 
 	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 10/20] bus/fslmc: add dynamic config for memback portal mode
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (8 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 09/20] bus/fslmc: upgrade to latest qbman library Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 11/20] bus/fslmc: rename portal pi index to consumer index Shreyansh Jain
                     ` (10 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, Roy Pledge, Youri Querry

From: Hemant Agrawal <hemant.agrawal@nxp.com>

Add flag in portal init to adjust the qbman memory type,
to decide between legacy portal mode or newly introduced
memory backed portals.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |  2 +
 .../bus/fslmc/qbman/include/fsl_qbman_base.h  | 11 +++-
 drivers/bus/fslmc/qbman/qbman_portal.c        | 52 +++++++++++--------
 drivers/bus/fslmc/qbman/qbman_sys.h           | 20 ++++---
 4 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index ba2e28ce1..37723a094 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -509,6 +509,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 	p_des.cinh_bar = (void *)(dpio_dev->qbman_portal_ci_paddr);
 	p_des.irq = -1;
 	p_des.qman_version = attr.qbman_version;
+	p_des.eqcr_mode = qman_eqcr_vb_ring;
+	p_des.cena_access_mode = qman_cena_fastest_access;
 
 	dpio_dev->sw_portal = qbman_swp_init(&p_des);
 	if (dpio_dev->sw_portal == NULL) {
diff --git a/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h b/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
index bb60a98f9..48bdaafa4 100644
--- a/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
+++ b/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Copyright 2017-2018 NXP
  *
  */
 #ifndef _FSL_QBMAN_BASE_H
@@ -33,7 +34,12 @@ struct qbman_block_desc {
 
 enum qbman_eqcr_mode {
 	qman_eqcr_vb_ring = 2, /* Valid bit, with eqcr in ring mode */
-	qman_eqcr_vb_array, /* Valid bit, with eqcr in array mode */
+	qman_eqcr_vb_array,    /* Valid bit, with eqcr in array mode */
+};
+
+enum qbman_cena_access_mode {
+	qman_cena_fastest_access = 0, /* Use memory backed node if available */
+	qman_cena_direct_access,      /* Use direct access to the CENA region */
 };
 
 /**
@@ -46,6 +52,8 @@ enum qbman_eqcr_mode {
  * @qman_version: the qman version.
  * @eqcr_mode: Select the eqcr mode, currently only valid bit ring mode and
  * valid bit array mode are supported.
+ * @cena_access_mode: Mode used to access the CENA region, direct
+ *                    or memory backed.
  *
  * Descriptor for a QBMan software portal, expressed in terms that make sense to
  * the user context. Ie. on MC, this information is likely to be true-physical,
@@ -62,6 +70,7 @@ struct qbman_swp_desc {
 	int idx;
 	uint32_t qman_version;
 	enum qbman_eqcr_mode eqcr_mode;
+	enum qbman_cena_access_mode cena_access_mode;
 };
 
 /* Driver object for managing a QBMan portal */
diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 2f572a08b..08bfdc9f8 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -194,7 +194,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	p->sdq |= qbman_sdqcr_dct_prio_ics << QB_SDQCR_DCT_SHIFT;
 	p->sdq |= qbman_sdqcr_fc_up_to_3 << QB_SDQCR_FC_SHIFT;
 	p->sdq |= QMAN_SDQCR_TOKEN << QB_SDQCR_TOK_SHIFT;
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		p->mr.valid_bit = QB_VALID_BIT;
 
 	atomic_set(&p->vdq.busy, 1);
@@ -233,7 +234,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_SDQCR, 0);
 
 	p->eqcr.pi_ring_size = 8;
-	if ((qman_version & 0xFFFF0000) >= QMAN_REV_5000) {
+	if ((qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access)) {
 		p->eqcr.pi_ring_size = 32;
 		qbman_swp_enqueue_array_mode_ptr =
 				qbman_swp_enqueue_array_mode_mem_back;
@@ -253,7 +255,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	eqcr_pi = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI);
 	p->eqcr.pi = eqcr_pi & p->eqcr.pi_mask;
 	p->eqcr.pi_vb = eqcr_pi & QB_VALID_BIT;
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		p->eqcr.ci = qbman_cinh_read(&p->sys,
 				QBMAN_CINH_SWP_EQCR_CI) & p->eqcr.pi_mask;
 	else
@@ -362,10 +365,11 @@ void *qbman_swp_mc_start(struct qbman_swp *p)
 #ifdef QBMAN_CHECKING
 	QBMAN_BUG_ON(p->mc.check != swp_mc_can_start);
 #endif
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
-		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR);
-	else
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		    && (p->desc.cena_access_mode == qman_cena_fastest_access))
 		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR_MEM);
+	else
+		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR);
 #ifdef QBMAN_CHECKING
 	if (!ret)
 		p->mc.check = swp_mc_can_submit;
@@ -385,16 +389,17 @@ void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint8_t cmd_verb)
 	 * caller wants to OR but has forgotten to do so.
 	 */
 	QBMAN_BUG_ON((*v & cmd_verb) != *v);
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000) {
-		dma_wmb();
-		*v = cmd_verb | p->mc.valid_bit;
-		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR, cmd);
-		clean(cmd);
-	} else {
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		    && (p->desc.cena_access_mode == qman_cena_fastest_access)) {
 		*v = cmd_verb | p->mr.valid_bit;
 		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR_MEM, cmd);
 		dma_wmb();
 		qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_CR_RT, QMAN_RT_MODE);
+	} else {
+		dma_wmb();
+		*v = cmd_verb | p->mc.valid_bit;
+		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR, cmd);
+		clean(cmd);
 	}
 #ifdef QBMAN_CHECKING
 	p->mc.check = swp_mc_can_poll;
@@ -407,30 +412,31 @@ void *qbman_swp_mc_result(struct qbman_swp *p)
 #ifdef QBMAN_CHECKING
 	QBMAN_BUG_ON(p->mc.check != swp_mc_can_poll);
 #endif
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000) {
-		qbman_cena_invalidate_prefetch(&p->sys,
-				QBMAN_CENA_SWP_RR(p->mc.valid_bit));
-		ret = qbman_cena_read(&p->sys,
-				QBMAN_CENA_SWP_RR(p->mc.valid_bit));
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		&& (p->desc.cena_access_mode == qman_cena_fastest_access)) {
+		ret = qbman_cena_read(&p->sys, QBMAN_CENA_SWP_RR_MEM);
+		/* Command completed if the valid bit is toggled */
+		if (p->mr.valid_bit != (ret[0] & QB_VALID_BIT))
+			return NULL;
 		/* Remove the valid-bit -
 		 * command completed iff the rest is non-zero
 		 */
 		verb = ret[0] & ~QB_VALID_BIT;
 		if (!verb)
 			return NULL;
-		p->mc.valid_bit ^= QB_VALID_BIT;
+		p->mr.valid_bit ^= QB_VALID_BIT;
 	} else {
-		ret = qbman_cena_read(&p->sys, QBMAN_CENA_SWP_RR_MEM);
-		/* Command completed if the valid bit is toggled */
-		if (p->mr.valid_bit != (ret[0] & QB_VALID_BIT))
-			return NULL;
+		qbman_cena_invalidate_prefetch(&p->sys,
+			QBMAN_CENA_SWP_RR(p->mc.valid_bit));
+		ret = qbman_cena_read(&p->sys,
+				      QBMAN_CENA_SWP_RR(p->mc.valid_bit));
 		/* Remove the valid-bit -
 		 * command completed iff the rest is non-zero
 		 */
 		verb = ret[0] & ~QB_VALID_BIT;
 		if (!verb)
 			return NULL;
-		p->mr.valid_bit ^= QB_VALID_BIT;
+		p->mc.valid_bit ^= QB_VALID_BIT;
 	}
 #ifdef QBMAN_CHECKING
 	p->mc.check = swp_mc_can_start;
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index e3bd1c5e6..71f7a6782 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -389,7 +389,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	int i;
 	int cena_region_size = 4*1024;
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		cena_region_size = 64*1024;
 #ifdef RTE_ARCH_64
 	uint8_t wn = CENA_WRITE_ENABLE;
@@ -416,7 +417,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
 	QBMAN_BUG_ON(reg);
 #endif
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		memset(s->addr_cena, 0, cena_region_size);
 	else {
 		/* Invalidate the portal memory.
@@ -426,11 +428,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 			dccivac(s->addr_cena + i);
 	}
 
-	if (s->eqcr_mode == qman_eqcr_vb_array)
+	if (s->eqcr_mode == qman_eqcr_vb_array) {
 		reg = qbman_set_swp_cfg(dqrr_size, wn,
 					0, 3, 2, 3, 1, 1, 1, 1, 1, 1);
-	else {
-		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	} else {
+		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000 &&
+			    (d->cena_access_mode == qman_cena_fastest_access))
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
 						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
 		else
@@ -438,11 +441,11 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
 	}
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		reg |= 1 << SWP_CFG_CPBS_SHIFT | /* memory-backed mode */
 		       1 << SWP_CFG_VPM_SHIFT |  /* VDQCR read triggered mode */
 		       1 << SWP_CFG_CPM_SHIFT;   /* CR read triggered mode */
-	}
 
 	qbman_cinh_write(s, QBMAN_CINH_SWP_CFG, reg);
 	reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
@@ -452,7 +455,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 		return -1;
 	}
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access)) {
 		qbman_cinh_write(s, QBMAN_CINH_SWP_EQCR_PI, QMAN_RT_MODE);
 		qbman_cinh_write(s, QBMAN_CINH_SWP_RCR_PI, QMAN_RT_MODE);
 	}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 11/20] bus/fslmc: rename portal pi index to consumer index
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (9 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 10/20] bus/fslmc: add dynamic config for memback portal mode Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 12/20] bus/fslmc: make portal func static Shreyansh Jain
                     ` (9 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, Youri Querry

From: Hemant Agrawal <hemant.agrawal@nxp.com>

This is to align with the latest qbman hw library

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c | 51 +++++++++++---------------
 drivers/bus/fslmc/qbman/qbman_portal.h |  2 +-
 2 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 08bfdc9f8..14f4b0344 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -251,21 +251,21 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	}
 
 	for (mask_size = p->eqcr.pi_ring_size; mask_size > 0; mask_size >>= 1)
-		p->eqcr.pi_mask = (p->eqcr.pi_mask<<1) + 1;
+		p->eqcr.pi_ci_mask = (p->eqcr.pi_ci_mask<<1) + 1;
 	eqcr_pi = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI);
-	p->eqcr.pi = eqcr_pi & p->eqcr.pi_mask;
+	p->eqcr.pi = eqcr_pi & p->eqcr.pi_ci_mask;
 	p->eqcr.pi_vb = eqcr_pi & QB_VALID_BIT;
 	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
 			&& (d->cena_access_mode == qman_cena_fastest_access))
-		p->eqcr.ci = qbman_cinh_read(&p->sys,
-				QBMAN_CINH_SWP_EQCR_CI) & p->eqcr.pi_mask;
+		p->eqcr.ci = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI)
+					     & p->eqcr.pi_ci_mask;
 	else
-		p->eqcr.ci = qbman_cinh_read(&p->sys,
-				QBMAN_CINH_SWP_EQCR_PI) & p->eqcr.pi_mask;
+		p->eqcr.ci = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_CI)
+					     & p->eqcr.pi_ci_mask;
 	p->eqcr.available = p->eqcr.pi_ring_size -
 				qm_cyc_diff(p->eqcr.pi_ring_size,
-				p->eqcr.ci & (p->eqcr.pi_mask<<1),
-				p->eqcr.pi & (p->eqcr.pi_mask<<1));
+				p->eqcr.ci & (p->eqcr.pi_ci_mask<<1),
+				p->eqcr.pi & (p->eqcr.pi_ci_mask<<1));
 
 	portal_idx_map[p->desc.idx] = p;
 	return p;
@@ -646,8 +646,8 @@ static int qbman_swp_enqueue_ring_mode_direct(struct qbman_swp *s,
 	const uint32_t *cl = qb_cl(d);
 	uint32_t eqcr_ci, full_mask, half_mask;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -685,8 +685,8 @@ static int qbman_swp_enqueue_ring_mode_mem_back(struct qbman_swp *s,
 	const uint32_t *cl = qb_cl(d);
 	uint32_t eqcr_ci, full_mask, half_mask;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -743,8 +743,8 @@ static int qbman_swp_enqueue_multiple_direct(struct qbman_swp *s,
 	int i, num_enqueued = 0;
 	uint64_t addr_cena;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -811,8 +811,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 	uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask;
 	int i, num_enqueued = 0;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -833,15 +833,6 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 				QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask));
 		memcpy(&p[1], &cl[1], 28);
 		memcpy(&p[8], &fd[i], sizeof(*fd));
-		eqcr_pi++;
-	}
-
-	/* Set the verb byte, have to substitute in the valid-bit */
-	eqcr_pi = s->eqcr.pi;
-	for (i = 0; i < num_enqueued; i++) {
-		p = qbman_cena_write_start_wo_shadow(&s->sys,
-				QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask));
-		p[0] = cl[0] | s->eqcr.pi_vb;
 		if (flags && (flags[i] & QBMAN_ENQUEUE_FLAG_DCA)) {
 			struct qbman_eq_desc *d = (struct qbman_eq_desc *)p;
 
@@ -849,6 +840,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 				((flags[i]) & QBMAN_EQCR_DCA_IDXMASK);
 		}
 		eqcr_pi++;
+		p[0] = cl[0] | s->eqcr.pi_vb;
+
 		if (!(eqcr_pi & half_mask))
 			s->eqcr.pi_vb ^= QB_VALID_BIT;
 	}
@@ -880,8 +873,8 @@ static int qbman_swp_enqueue_multiple_desc_direct(struct qbman_swp *s,
 	int i, num_enqueued = 0;
 	uint64_t addr_cena;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -943,8 +936,8 @@ static int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s,
 	uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask;
 	int i, num_enqueued = 0;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
diff --git a/drivers/bus/fslmc/qbman/qbman_portal.h b/drivers/bus/fslmc/qbman/qbman_portal.h
index 3b0fc540b..e54f2661c 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.h
+++ b/drivers/bus/fslmc/qbman/qbman_portal.h
@@ -98,7 +98,7 @@ struct qbman_swp {
 		uint32_t pi;
 		uint32_t pi_vb;
 		uint32_t pi_ring_size;
-		uint32_t pi_mask;
+		uint32_t pi_ci_mask;
 		uint32_t ci;
 		int available;
 	} eqcr;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 12/20] bus/fslmc: make portal func static
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (10 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 11/20] bus/fslmc: rename portal pi index to consumer index Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 13/20] net/dpaa2: add dpdmux mc flib Shreyansh Jain
                     ` (8 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal

From: Hemant Agrawal <hemant.agrawal@nxp.com>

Change QBMAN portal function to static as it is not exposed outside
this file context.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 37723a094..cd28441f3 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -229,7 +229,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 	return 0;
 }
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
+static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
 	int ret;
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
index 462501a2e..4354c76de 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
@@ -37,8 +37,6 @@ extern uint8_t dpaa2_eqcr_size;
 
 extern struct dpaa2_io_portal_t dpaa2_io_portal[RTE_MAX_LCORE];
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id);
-
 /* Affine a DPIO portal to current processing thread */
 int dpaa2_affine_qbman_swp(void);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 13/20] net/dpaa2: add dpdmux mc flib
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (11 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 12/20] bus/fslmc: make portal func static Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 14/20] bus/fslmc: add support for scanning DPDMUX object Shreyansh Jain
                     ` (7 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

dpdmux object is added as a part of net driver as it is used to
de-multiplex packets to separate interfaces on basis of specific rules.
These rules can be configured from the software

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/Makefile            |   1 +
 drivers/net/dpaa2/mc/dpdmux.c         | 929 ++++++++++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux.h     | 410 ++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h | 221 ++++++
 drivers/net/dpaa2/meson.build         |   1 +
 5 files changed, 1562 insertions(+)
 create mode 100644 drivers/net/dpaa2/mc/dpdmux.c
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux.h
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h

diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index 2b9c011d6..c58a39725 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -35,6 +35,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpkg.c
+SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpdmux.c
 
 LDLIBS += -lrte_bus_fslmc
 LDLIBS += -lrte_mempool_dpaa2
diff --git a/drivers/net/dpaa2/mc/dpdmux.c b/drivers/net/dpaa2/mc/dpdmux.c
new file mode 100644
index 000000000..7962213b7
--- /dev/null
+++ b/drivers/net/dpaa2/mc/dpdmux.c
@@ -0,0 +1,929 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#include <fsl_mc_sys.h>
+#include <fsl_mc_cmd.h>
+#include <fsl_dpdmux.h>
+#include <fsl_dpdmux_cmd.h>
+
+/** @addtogroup dpdmux
+ * @{
+ */
+
+/**
+ * dpdmux_open() - Open a control session for the specified object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @dpdmux_id:		DPDMUX unique ID
+ * @token:		Returned token; use in subsequent API calls
+ *
+ * This function can be used to open a control session for an
+ * already created object; an object may have been declared in
+ * the DPL or by calling the dpdmux_create() function.
+ * This function returns a unique authentication token,
+ * associated with the specific object ID and the specific MC
+ * portal; this token must be used in all subsequent commands for
+ * this specific object.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_open(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		int dpdmux_id,
+		uint16_t *token)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_open *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_OPEN,
+					  cmd_flags,
+					  0);
+	cmd_params = (struct dpdmux_cmd_open *)cmd.params;
+	cmd_params->dpdmux_id = cpu_to_le32(dpdmux_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*token = mc_cmd_hdr_read_token(&cmd);
+
+	return 0;
+}
+
+/**
+ * dpdmux_close() - Close the control session of the object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPDMUX object
+ *
+ * After this function is called, no further operations are
+ * allowed on the object without opening a new control session.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_close(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CLOSE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_create() - Create the DPDMUX object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @dprc_token:	Parent container token; '0' for default container
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @cfg:	Configuration structure
+ * @obj_id: returned object id
+ *
+ * Create the DPDMUX object, allocate required resources and
+ * perform required initialization.
+ *
+ * The object can be created either by declaring it in the
+ * DPL file, or by calling this function.
+ *
+ * The function accepts an authentication token of a parent
+ * container that this object should be assigned to. The token
+ * can be '0' so the object will be assigned to the default container.
+ * The newly created object can be opened with the returned
+ * object id and using the container's associated tokens and MC portals.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_create(struct fsl_mc_io *mc_io,
+		  uint16_t dprc_token,
+		  uint32_t cmd_flags,
+		  const struct dpdmux_cfg	*cfg,
+		  uint32_t *obj_id)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_create *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CREATE,
+					  cmd_flags,
+					  dprc_token);
+	cmd_params = (struct dpdmux_cmd_create *)cmd.params;
+	cmd_params->method = cfg->method;
+	cmd_params->manip = cfg->manip;
+	cmd_params->num_ifs = cpu_to_le16(cfg->num_ifs);
+	cmd_params->adv_max_dmat_entries =
+			cpu_to_le16(cfg->adv.max_dmat_entries);
+	cmd_params->adv_max_mc_groups = cpu_to_le16(cfg->adv.max_mc_groups);
+	cmd_params->adv_max_vlan_ids = cpu_to_le16(cfg->adv.max_vlan_ids);
+	cmd_params->options = cpu_to_le64(cfg->adv.options);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*obj_id = mc_cmd_read_object_id(&cmd);
+
+	return 0;
+}
+
+/**
+ * dpdmux_destroy() - Destroy the DPDMUX object and release all its resources.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @dprc_token: Parent container token; '0' for default container
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @object_id:	The object id; it must be a valid id within the container that
+ * created this object;
+ *
+ * The function accepts the authentication token of the parent container that
+ * created the object (not the one that currently owns the object). The object
+ * is searched within parent using the provided 'object_id'.
+ * All tokens to the object must be closed before calling destroy.
+ *
+ * Return:	'0' on Success; error code otherwise.
+ */
+int dpdmux_destroy(struct fsl_mc_io *mc_io,
+		   uint16_t dprc_token,
+		   uint32_t cmd_flags,
+		   uint32_t object_id)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_destroy *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_DESTROY,
+					  cmd_flags,
+					  dprc_token);
+	cmd_params = (struct dpdmux_cmd_destroy *)cmd.params;
+	cmd_params->dpdmux_id = cpu_to_le32(object_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_enable() - Enable DPDMUX functionality
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_enable(struct fsl_mc_io *mc_io,
+		  uint32_t cmd_flags,
+		  uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_ENABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_disable() - Disable DPDMUX functionality
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_disable(struct fsl_mc_io *mc_io,
+		   uint32_t cmd_flags,
+		   uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_DISABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_is_enabled() - Check if the DPDMUX is enabled.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @en:		Returns '1' if object is enabled; '0' otherwise
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      int *en)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_is_enabled *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IS_ENABLED,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_is_enabled *)cmd.params;
+	*en = dpdmux_get_field(rsp_params->en, ENABLE);
+
+	return 0;
+}
+
+/**
+ * dpdmux_reset() - Reset the DPDMUX, returns the object to initial state.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_reset(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_RESET,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_get_attributes() - Retrieve DPDMUX attributes
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @attr:	Returned object's attributes
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  struct dpdmux_attr *attr)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_get_attr *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_ATTR,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_get_attr *)cmd.params;
+	attr->id = le32_to_cpu(rsp_params->id);
+	attr->options = le64_to_cpu(rsp_params->options);
+	attr->method = rsp_params->method;
+	attr->manip = rsp_params->manip;
+	attr->num_ifs = le16_to_cpu(rsp_params->num_ifs);
+	attr->mem_size = le16_to_cpu(rsp_params->mem_size);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_enable() - Enable Interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface Identifier
+ *
+ * Return:	Completion status. '0' on Success; Error code otherwise.
+ */
+int dpdmux_if_enable(struct fsl_mc_io *mc_io,
+		     uint32_t cmd_flags,
+		     uint16_t token,
+		     uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_ENABLE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_disable() - Disable Interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface Identifier
+ *
+ * Return:	Completion status. '0' on Success; Error code otherwise.
+ */
+int dpdmux_if_disable(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_DISABLE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_set_max_frame_length() - Set the maximum frame length in DPDMUX
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPDMUX object
+ * @max_frame_length:	The required maximum frame length
+ *
+ * Update the maximum frame length on all DMUX interfaces.
+ * In case of VEPA, the maximum frame length on all dmux interfaces
+ * will be updated with the minimum value of the mfls of the connected
+ * dpnis and the actual value of dmux mfl.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
+				uint32_t cmd_flags,
+				uint16_t token,
+				uint16_t max_frame_length)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_set_max_frame_length *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_MAX_FRAME_LENGTH,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_set_max_frame_length *)cmd.params;
+	cmd_params->max_frame_length = cpu_to_le16(max_frame_length);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_ul_reset_counters() - Function resets the uplink counter
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_UL_RESET_COUNTERS,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_set_accepted_frames() - Set the accepted frame types
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface ID (0 for uplink, or 1-num_ifs);
+ * @cfg:	Frame types configuration
+ *
+ * if 'DPDMUX_ADMIT_ONLY_VLAN_TAGGED' is set - untagged frames or
+ * priority-tagged frames are discarded.
+ * if 'DPDMUX_ADMIT_ONLY_UNTAGGED' is set - untagged frames or
+ * priority-tagged frames are accepted.
+ * if 'DPDMUX_ADMIT_ALL' is set (default mode) - all VLAN tagged,
+ * untagged and priority-tagged frame are accepted;
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint16_t if_id,
+				  const struct dpdmux_accepted_frames *cfg)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_set_accepted_frames *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_ACCEPTED_FRAMES,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_set_accepted_frames *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	dpdmux_set_field(cmd_params->frames_options,
+			 ACCEPTED_FRAMES_TYPE,
+			 cfg->type);
+	dpdmux_set_field(cmd_params->frames_options,
+			 UNACCEPTED_FRAMES_ACTION,
+			 cfg->unaccept_act);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_attributes() - Obtain DPDMUX interface attributes
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface ID (0 for uplink, or 1-num_ifs);
+ * @attr:	Interface attributes
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_if_attr *attr)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if *cmd_params;
+	struct dpdmux_rsp_if_get_attr *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_ATTR,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_attr *)cmd.params;
+	attr->rate = le32_to_cpu(rsp_params->rate);
+	attr->enabled = dpdmux_get_field(rsp_params->enabled, ENABLE);
+	attr->is_default = dpdmux_get_field(rsp_params->enabled, IS_DEFAULT);
+	attr->accept_frame_type = dpdmux_get_field(
+				  rsp_params->accepted_frames_type,
+				  ACCEPTED_FRAMES_TYPE);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_remove_l2_rule() - Remove L2 rule from DPDMUX table
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Destination interface ID
+ * @rule:	L2 rule
+ *
+ * Function removes a L2 rule from DPDMUX table
+ * or adds an interface to an existing multicast address
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     const struct dpdmux_l2_rule *rule)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_l2_rule *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_REMOVE_L2_RULE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_l2_rule *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->vlan_id = cpu_to_le16(rule->vlan_id);
+	cmd_params->mac_addr5 = rule->mac_addr[5];
+	cmd_params->mac_addr4 = rule->mac_addr[4];
+	cmd_params->mac_addr3 = rule->mac_addr[3];
+	cmd_params->mac_addr2 = rule->mac_addr[2];
+	cmd_params->mac_addr1 = rule->mac_addr[1];
+	cmd_params->mac_addr0 = rule->mac_addr[0];
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_add_l2_rule() - Add L2 rule into DPDMUX table
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Destination interface ID
+ * @rule:	L2 rule
+ *
+ * Function adds a L2 rule into DPDMUX table
+ * or adds an interface to an existing multicast address
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  const struct dpdmux_l2_rule *rule)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_l2_rule *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_ADD_L2_RULE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_l2_rule *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->vlan_id = cpu_to_le16(rule->vlan_id);
+	cmd_params->mac_addr5 = rule->mac_addr[5];
+	cmd_params->mac_addr4 = rule->mac_addr[4];
+	cmd_params->mac_addr3 = rule->mac_addr[3];
+	cmd_params->mac_addr2 = rule->mac_addr[2];
+	cmd_params->mac_addr1 = rule->mac_addr[1];
+	cmd_params->mac_addr0 = rule->mac_addr[0];
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_counter() - Functions obtains specific counter of an interface
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPDMUX object
+ * @if_id:  Interface Id
+ * @counter_type: counter type
+ * @counter: Returned specific counter information
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  enum dpdmux_counter_type counter_type,
+			  uint64_t *counter)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_get_counter *cmd_params;
+	struct dpdmux_rsp_if_get_counter *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_COUNTER,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_get_counter *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->counter_type = counter_type;
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_counter *)cmd.params;
+	*counter = le64_to_cpu(rsp_params->counter);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_set_link_cfg() - set the link configuration.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ * @cfg: Link configuration
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t token,
+			   uint16_t if_id,
+			   struct dpdmux_link_cfg *cfg)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_set_link_cfg *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_LINK_CFG,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_set_link_cfg *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->rate = cpu_to_le32(cfg->rate);
+	cmd_params->options = cpu_to_le64(cfg->options);
+	cmd_params->advertising = cpu_to_le64(cfg->advertising);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_link_state - Return the link state
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ * @state: link state
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_link_state *state)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_get_link_state *cmd_params;
+	struct dpdmux_rsp_if_get_link_state *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_LINK_STATE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_get_link_state *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_link_state *)cmd.params;
+	state->rate = le32_to_cpu(rsp_params->rate);
+	state->options = le64_to_cpu(rsp_params->options);
+	state->up = dpdmux_get_field(rsp_params->up, UP);
+	state->state_valid = dpdmux_get_field(rsp_params->up, STATE_VALID);
+	state->supported = le64_to_cpu(rsp_params->supported);
+	state->advertising = le64_to_cpu(rsp_params->advertising);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_set_default - Set default interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_DEFAULT,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_default - Get default interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t *if_id)
+{
+	struct dpdmux_cmd_if *rsp_params;
+	struct mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_DEFAULT,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_cmd_if *)cmd.params;
+	*if_id = le16_to_cpu(rsp_params->if_id);
+
+	return 0;
+}
+
+/**
+ * dpdmux_set_custom_key - Set a custom classification key.
+ *
+ * This API is only available for DPDMUX instance created with
+ * DPDMUX_METHOD_CUSTOM.  This API must be called before populating the
+ * classification table using dpdmux_add_custom_cls_entry.
+ *
+ * Calls to dpdmux_set_custom_key remove all existing classification entries
+ * that may have been added previously using dpdmux_add_custom_cls_entry.
+ *
+ * @mc_io:		Pointer to MC portal's I/O object
+ * @cmd_flags:		Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPSW object
+ * @if_id:		Interface id
+ * @key_cfg_iova:	DMA address of a configuration structure set up using
+ *			dpkg_prepare_key_cfg. Maximum key size is 24 bytes
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
+			uint32_t cmd_flags,
+			uint16_t token,
+			uint64_t key_cfg_iova)
+{
+	struct dpdmux_set_custom_key *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_CUSTOM_KEY,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_set_custom_key *)cmd.params;
+	cmd_params->key_cfg_iova = cpu_to_le64(key_cfg_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_add_custom_cls_entry - Adds a custom classification entry.
+ *
+ * This API is only available for DPDMUX instances created with
+ * DPDMUX_METHOD_CUSTOM.  Before calling this function a classification key
+ * composition rule must be set up using dpdmux_set_custom_key.
+ *
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @rule: Classification rule to insert.  Rules cannot be duplicated, if a
+ *	matching rule already exists, the action will be replaced.
+ * @action: Action to perform for matching traffic.
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule,
+		struct dpdmux_cls_action *action)
+{
+	struct dpdmux_cmd_add_custom_cls_entry *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_ADD_CUSTOM_CLS_ENTRY,
+					  cmd_flags,
+					  token);
+
+	cmd_params = (struct dpdmux_cmd_add_custom_cls_entry *)cmd.params;
+	cmd_params->key_size = rule->key_size;
+	cmd_params->dest_if = cpu_to_le16(action->dest_if);
+	cmd_params->key_iova = cpu_to_le64(rule->key_iova);
+	cmd_params->mask_iova = cpu_to_le64(rule->mask_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_remove_custom_cls_entry - Removes a custom classification entry.
+ *
+ * This API is only available for DPDMUX instances created with
+ * DPDMUX_METHOD_CUSTOM.  The API can be used to remove classification
+ * entries previously inserted using dpdmux_add_custom_cls_entry.
+ *
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @rule: Classification rule to remove
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule)
+{
+	struct dpdmux_cmd_remove_custom_cls_entry *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_REMOVE_CUSTOM_CLS_ENTRY,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_remove_custom_cls_entry *)cmd.params;
+	cmd_params->key_size = rule->key_size;
+	cmd_params->key_iova = cpu_to_le64(rule->key_iova);
+	cmd_params->mask_iova = cpu_to_le64(rule->mask_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_get_api_version() - Get Data Path Demux API version
+ * @mc_io:  Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @major_ver:	Major version of data path demux API
+ * @minor_ver:	Minor version of data path demux API
+ *
+ * Return:  '0' on Success; Error code otherwise.
+ */
+int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t *major_ver,
+			   uint16_t *minor_ver)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_get_api_version *rsp_params;
+	int err;
+
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_API_VERSION,
+					cmd_flags,
+					0);
+
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	rsp_params = (struct dpdmux_rsp_get_api_version *)cmd.params;
+	*major_ver = le16_to_cpu(rsp_params->major);
+	*minor_ver = le16_to_cpu(rsp_params->minor);
+
+	return 0;
+}
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux.h b/drivers/net/dpaa2/mc/fsl_dpdmux.h
new file mode 100644
index 000000000..c69cb7aab
--- /dev/null
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux.h
@@ -0,0 +1,410 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#ifndef __FSL_DPDMUX_H
+#define __FSL_DPDMUX_H
+
+#include <fsl_net.h>
+
+struct fsl_mc_io;
+
+/** @addtogroup dpdmux Data Path Demux API
+ * Contains API for handling DPDMUX topology and functionality
+ * @{
+ */
+
+int dpdmux_open(struct fsl_mc_io *mc_io,
+		uint32_t  cmd_flags,
+		int  dpdmux_id,
+		uint16_t  *token);
+
+int dpdmux_close(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token);
+
+/**
+ * DPDMUX general options
+ */
+
+/**
+ * Enable bridging between internal interfaces
+ */
+#define DPDMUX_OPT_BRIDGE_EN	0x0000000000000002ULL
+
+/**
+ * Mask support for classification
+ */
+#define DPDMUX_OPT_CLS_MASK_SUPPORT		0x0000000000000020ULL
+
+#define DPDMUX_IRQ_INDEX_IF	0x0000
+#define DPDMUX_IRQ_INDEX	0x0001
+
+/**
+ * IRQ event - Indicates that the link state changed
+ */
+#define DPDMUX_IRQ_EVENT_LINK_CHANGED	0x0001
+
+/**
+ * enum dpdmux_manip - DPDMUX manipulation operations
+ * @DPDMUX_MANIP_NONE:	No manipulation on frames
+ * @DPDMUX_MANIP_ADD_REMOVE_S_VLAN: Add S-VLAN on egress, remove it on ingress
+ */
+enum dpdmux_manip {
+	DPDMUX_MANIP_NONE = 0x0,
+	DPDMUX_MANIP_ADD_REMOVE_S_VLAN = 0x1
+};
+
+/**
+ * enum dpdmux_method - DPDMUX method options
+ * @DPDMUX_METHOD_NONE: no DPDMUX method
+ * @DPDMUX_METHOD_C_VLAN_MAC: DPDMUX based on C-VLAN and MAC address
+ * @DPDMUX_METHOD_MAC: DPDMUX based on MAC address
+ * @DPDMUX_METHOD_C_VLAN: DPDMUX based on C-VLAN
+ * @DPDMUX_METHOD_S_VLAN: DPDMUX based on S-VLAN
+ */
+enum dpdmux_method {
+	DPDMUX_METHOD_NONE = 0x0,
+	DPDMUX_METHOD_C_VLAN_MAC = 0x1,
+	DPDMUX_METHOD_MAC = 0x2,
+	DPDMUX_METHOD_C_VLAN = 0x3,
+	DPDMUX_METHOD_S_VLAN = 0x4,
+	DPDMUX_METHOD_CUSTOM = 0x5,
+};
+
+/**
+ * struct dpdmux_cfg - DPDMUX configuration parameters
+ * @method: Defines the operation method for the DPDMUX address table
+ * @manip: Required manipulation operation
+ * @num_ifs: Number of interfaces (excluding the uplink interface)
+ * @adv: Advanced parameters; default is all zeros;
+ *	use this structure to change default settings
+ * @adv.options: DPDMUX options - combination of 'DPDMUX_OPT_<X>' flags.
+ * @adv.max_dmat_entries: Maximum entries in DPDMUX address table
+ *	0 - indicates default: 64 entries per interface.
+ * @adv.max_mc_groups: Number of multicast groups in DPDMUX table
+ *	0 - indicates default: 32 multicast groups.
+ * @adv.max_vlan_ids: Maximum vlan ids allowed in the system -
+ *	relevant only case of working in mac+vlan method.
+ *	0 - indicates default 16 vlan ids.
+ */
+struct dpdmux_cfg {
+	enum dpdmux_method method;
+	enum dpdmux_manip manip;
+	uint16_t num_ifs;
+	struct {
+		uint64_t options;
+		uint16_t max_dmat_entries;
+		uint16_t max_mc_groups;
+		uint16_t max_vlan_ids;
+	} adv;
+};
+
+int dpdmux_create(struct fsl_mc_io *mc_io,
+		  uint16_t dprc_token,
+		  uint32_t cmd_flags,
+		  const struct dpdmux_cfg *cfg,
+		  uint32_t *obj_id);
+
+int dpdmux_destroy(struct fsl_mc_io *mc_io,
+		   uint16_t dprc_token,
+		   uint32_t cmd_flags,
+		   uint32_t object_id);
+
+int dpdmux_enable(struct fsl_mc_io *mc_io,
+		  uint32_t cmd_flags,
+		  uint16_t token);
+
+int dpdmux_disable(struct fsl_mc_io *mc_io,
+		   uint32_t cmd_flags,
+		   uint16_t token);
+
+int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      int *en);
+
+int dpdmux_reset(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token);
+
+/**
+ * struct dpdmux_attr - Structure representing DPDMUX attributes
+ * @id: DPDMUX object ID
+ * @options: Configuration options (bitmap)
+ * @method: DPDMUX address table method
+ * @manip: DPDMUX manipulation type
+ * @num_ifs: Number of interfaces (excluding the uplink interface)
+ * @mem_size: DPDMUX frame storage memory size
+ */
+struct dpdmux_attr {
+	int id;
+	uint64_t options;
+	enum dpdmux_method method;
+	enum dpdmux_manip manip;
+	uint16_t num_ifs;
+	uint16_t mem_size;
+};
+
+int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  struct dpdmux_attr *attr);
+
+int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
+				uint32_t cmd_flags,
+				uint16_t token,
+				uint16_t max_frame_length);
+
+/**
+ * enum dpdmux_counter_type - Counter types
+ * @DPDMUX_CNT_ING_FRAME: Counts ingress frames
+ * @DPDMUX_CNT_ING_BYTE: Counts ingress bytes
+ * @DPDMUX_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
+ * @DPDMUX_CNT_ING_FRAME_DISCARD: Counts discarded ingress frames
+ * @DPDMUX_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
+ * @DPDMUX_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
+ * @DPDMUX_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
+ * @DPDMUX_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
+ * @DPDMUX_CNT_EGR_FRAME: Counts egress frames
+ * @DPDMUX_CNT_EGR_BYTE: Counts egress bytes
+ * @DPDMUX_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
+ */
+enum dpdmux_counter_type {
+	DPDMUX_CNT_ING_FRAME = 0x0,
+	DPDMUX_CNT_ING_BYTE = 0x1,
+	DPDMUX_CNT_ING_FLTR_FRAME = 0x2,
+	DPDMUX_CNT_ING_FRAME_DISCARD = 0x3,
+	DPDMUX_CNT_ING_MCAST_FRAME = 0x4,
+	DPDMUX_CNT_ING_MCAST_BYTE = 0x5,
+	DPDMUX_CNT_ING_BCAST_FRAME = 0x6,
+	DPDMUX_CNT_ING_BCAST_BYTES = 0x7,
+	DPDMUX_CNT_EGR_FRAME = 0x8,
+	DPDMUX_CNT_EGR_BYTE = 0x9,
+	DPDMUX_CNT_EGR_FRAME_DISCARD = 0xa
+};
+
+/**
+ * enum dpdmux_accepted_frames_type - DPDMUX frame types
+ * @DPDMUX_ADMIT_ALL: The device accepts VLAN tagged, untagged and
+ *			priority-tagged frames
+ * @DPDMUX_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
+ *				priority-tagged frames that are received on this
+ *				interface
+ * @DPDMUX_ADMIT_ONLY_UNTAGGED: Untagged frames or priority-tagged frames
+ *				received on this interface are accepted
+ */
+enum dpdmux_accepted_frames_type {
+	DPDMUX_ADMIT_ALL = 0,
+	DPDMUX_ADMIT_ONLY_VLAN_TAGGED = 1,
+	DPDMUX_ADMIT_ONLY_UNTAGGED = 2
+};
+
+/**
+ * enum dpdmux_action - DPDMUX action for un-accepted frames
+ * @DPDMUX_ACTION_DROP: Drop un-accepted frames
+ * @DPDMUX_ACTION_REDIRECT_TO_CTRL: Redirect un-accepted frames to the
+ *					control interface
+ */
+enum dpdmux_action {
+	DPDMUX_ACTION_DROP = 0,
+	DPDMUX_ACTION_REDIRECT_TO_CTRL = 1
+};
+
+/**
+ * struct dpdmux_accepted_frames - Frame types configuration
+ * @type: Defines ingress accepted frames
+ * @unaccept_act: Defines action on frames not accepted
+ */
+struct dpdmux_accepted_frames {
+	enum dpdmux_accepted_frames_type type;
+	enum dpdmux_action unaccept_act;
+};
+
+int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint16_t if_id,
+				  const struct dpdmux_accepted_frames *cfg);
+
+/**
+ * struct dpdmux_if_attr - Structure representing frame types configuration
+ * @rate: Configured interface rate (in bits per second)
+ * @enabled: Indicates if interface is enabled
+ * @accept_frame_type: Indicates type of accepted frames for the interface
+ */
+struct dpdmux_if_attr {
+	uint32_t rate;
+	int enabled;
+	int is_default;
+	enum dpdmux_accepted_frames_type accept_frame_type;
+};
+
+int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_if_attr *attr);
+
+int dpdmux_if_enable(struct fsl_mc_io *mc_io,
+		     uint32_t cmd_flags,
+		     uint16_t token,
+		     uint16_t if_id);
+
+int dpdmux_if_disable(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      uint16_t if_id);
+
+/**
+ * struct dpdmux_l2_rule - Structure representing L2 rule
+ * @mac_addr: MAC address
+ * @vlan_id: VLAN ID
+ */
+struct dpdmux_l2_rule {
+	uint8_t mac_addr[6];
+	uint16_t vlan_id;
+};
+
+int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     const struct dpdmux_l2_rule *rule);
+
+int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  const struct dpdmux_l2_rule *rule);
+
+int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  enum dpdmux_counter_type counter_type,
+			  uint64_t *counter);
+
+int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token);
+
+/**
+ * Enable auto-negotiation
+ */
+#define DPDMUX_LINK_OPT_AUTONEG		0x0000000000000001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPDMUX_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
+/**
+ * Enable pause frames
+ */
+#define DPDMUX_LINK_OPT_PAUSE		0x0000000000000004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPDMUX_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
+
+/**
+ * struct dpdmux_link_cfg - Structure representing DPDMUX link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
+ */
+struct dpdmux_link_cfg {
+	uint32_t rate;
+	uint64_t options;
+	uint64_t advertising;
+};
+
+int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t token,
+			   uint16_t if_id,
+			   struct dpdmux_link_cfg *cfg);
+/**
+ * struct dpdmux_link_state - Structure representing DPDMUX link state
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
+ * @up: 0 - down, 1 - up
+ * @state_valid: Ignore/Update the state of the link
+ * @supported: Speeds capability of the phy (bitmap)
+ * @advertising: Speeds that are advertised for autoneg (bitmap)
+ */
+struct dpdmux_link_state {
+	uint32_t rate;
+	uint64_t options;
+	int      up;
+	int      state_valid;
+	uint64_t supported;
+	uint64_t advertising;
+};
+
+int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_link_state *state);
+
+int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t if_id);
+
+int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t *if_id);
+
+int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
+			uint32_t cmd_flags,
+			uint16_t token,
+			uint64_t key_cfg_iova);
+
+/**
+ * struct dpdmux_rule_cfg - Custom classification rule.
+ *
+ * @key_iova: DMA address of buffer storing the look-up value
+ * @mask_iova: DMA address of the mask used for TCAM classification
+ * @key_size: size, in bytes, of the look-up value. This must match the size
+ *	of the look-up key defined using dpdmux_set_custom_key, otherwise the
+ *	entry will never be hit
+ */
+struct dpdmux_rule_cfg {
+	uint64_t key_iova;
+	uint64_t mask_iova;
+	uint8_t key_size;
+};
+
+/**
+ * struct dpdmux_cls_action - Action to execute for frames matching the
+ *	classification entry
+ *
+ * @dest_if: Interface to forward the frames to. Port numbering is similar to
+ *	the one used to connect interfaces:
+ *	- 0 is the uplink port,
+ *	- all others are downlink ports.
+ */
+struct dpdmux_cls_action {
+	uint16_t dest_if;
+};
+
+int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule,
+		struct dpdmux_cls_action *action);
+
+int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule);
+
+int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t *major_ver,
+			   uint16_t *minor_ver);
+
+#endif /* __FSL_DPDMUX_H */
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
new file mode 100644
index 000000000..a36349feb
--- /dev/null
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
@@ -0,0 +1,221 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#ifndef _FSL_DPDMUX_CMD_H
+#define _FSL_DPDMUX_CMD_H
+
+/* DPDMUX Version */
+#define DPDMUX_VER_MAJOR		6
+#define DPDMUX_VER_MINOR		3
+
+#define DPDMUX_CMD_BASE_VERSION		1
+#define DPDMUX_CMD_VERSION_2		2
+#define DPDMUX_CMD_ID_OFFSET		4
+
+#define DPDMUX_CMD(id)	(((id) << DPDMUX_CMD_ID_OFFSET) |\
+				DPDMUX_CMD_BASE_VERSION)
+#define DPDMUX_CMD_V2(id) (((id) << DPDMUX_CMD_ID_OFFSET) | \
+				DPDMUX_CMD_VERSION_2)
+
+/* Command IDs */
+#define DPDMUX_CMDID_CLOSE			DPDMUX_CMD(0x800)
+#define DPDMUX_CMDID_OPEN			DPDMUX_CMD(0x806)
+#define DPDMUX_CMDID_CREATE			DPDMUX_CMD(0x906)
+#define DPDMUX_CMDID_DESTROY			DPDMUX_CMD(0x986)
+#define DPDMUX_CMDID_GET_API_VERSION		DPDMUX_CMD(0xa06)
+
+#define DPDMUX_CMDID_ENABLE			DPDMUX_CMD(0x002)
+#define DPDMUX_CMDID_DISABLE			DPDMUX_CMD(0x003)
+#define DPDMUX_CMDID_GET_ATTR			DPDMUX_CMD(0x004)
+#define DPDMUX_CMDID_RESET			DPDMUX_CMD(0x005)
+#define DPDMUX_CMDID_IS_ENABLED			DPDMUX_CMD(0x006)
+
+#define DPDMUX_CMDID_SET_MAX_FRAME_LENGTH	DPDMUX_CMD(0x0a1)
+
+#define DPDMUX_CMDID_UL_RESET_COUNTERS		DPDMUX_CMD(0x0a3)
+
+#define DPDMUX_CMDID_IF_SET_ACCEPTED_FRAMES	DPDMUX_CMD(0x0a7)
+#define DPDMUX_CMDID_IF_GET_ATTR		DPDMUX_CMD(0x0a8)
+#define DPDMUX_CMDID_IF_ENABLE			DPDMUX_CMD(0x0a9)
+#define DPDMUX_CMDID_IF_DISABLE			DPDMUX_CMD(0x0aa)
+
+#define DPDMUX_CMDID_IF_ADD_L2_RULE		DPDMUX_CMD(0x0b0)
+#define DPDMUX_CMDID_IF_REMOVE_L2_RULE		DPDMUX_CMD(0x0b1)
+#define DPDMUX_CMDID_IF_GET_COUNTER		DPDMUX_CMD(0x0b2)
+#define DPDMUX_CMDID_IF_SET_LINK_CFG		DPDMUX_CMD_V2(0x0b3)
+#define DPDMUX_CMDID_IF_GET_LINK_STATE		DPDMUX_CMD_V2(0x0b4)
+
+#define DPDMUX_CMDID_SET_CUSTOM_KEY		DPDMUX_CMD(0x0b5)
+#define DPDMUX_CMDID_ADD_CUSTOM_CLS_ENTRY	DPDMUX_CMD(0x0b6)
+#define DPDMUX_CMDID_REMOVE_CUSTOM_CLS_ENTRY	DPDMUX_CMD(0x0b7)
+
+#define DPDMUX_CMDID_IF_SET_DEFAULT		DPDMUX_CMD(0x0b8)
+#define DPDMUX_CMDID_IF_GET_DEFAULT		DPDMUX_CMD(0x0b9)
+
+#define DPDMUX_MASK(field)        \
+	GENMASK(DPDMUX_##field##_SHIFT + DPDMUX_##field##_SIZE - 1, \
+		DPDMUX_##field##_SHIFT)
+#define dpdmux_set_field(var, field, val) \
+	((var) |= (((val) << DPDMUX_##field##_SHIFT) & DPDMUX_MASK(field)))
+#define dpdmux_get_field(var, field)      \
+	(((var) & DPDMUX_MASK(field)) >> DPDMUX_##field##_SHIFT)
+
+#pragma pack(push, 1)
+struct dpdmux_cmd_open {
+	uint32_t dpdmux_id;
+};
+
+struct dpdmux_cmd_create {
+	uint8_t method;
+	uint8_t manip;
+	uint16_t num_ifs;
+	uint32_t pad;
+
+	uint16_t adv_max_dmat_entries;
+	uint16_t adv_max_mc_groups;
+	uint16_t adv_max_vlan_ids;
+	uint16_t pad1;
+
+	uint64_t options;
+};
+
+struct dpdmux_cmd_destroy {
+	uint32_t dpdmux_id;
+};
+
+#define DPDMUX_ENABLE_SHIFT	0
+#define DPDMUX_ENABLE_SIZE	1
+#define DPDMUX_IS_DEFAULT_SHIFT		1
+#define DPDMUX_IS_DEFAULT_SIZE		1
+
+struct dpdmux_rsp_is_enabled {
+	uint8_t en;
+};
+
+struct dpdmux_rsp_get_attr {
+	uint8_t method;
+	uint8_t manip;
+	uint16_t num_ifs;
+	uint16_t mem_size;
+	uint16_t pad;
+
+	uint64_t pad1;
+
+	uint32_t id;
+	uint32_t pad2;
+
+	uint64_t options;
+};
+
+struct dpdmux_cmd_set_max_frame_length {
+	uint16_t max_frame_length;
+};
+
+#define DPDMUX_ACCEPTED_FRAMES_TYPE_SHIFT	0
+#define DPDMUX_ACCEPTED_FRAMES_TYPE_SIZE	4
+#define DPDMUX_UNACCEPTED_FRAMES_ACTION_SHIFT	4
+#define DPDMUX_UNACCEPTED_FRAMES_ACTION_SIZE	4
+
+struct dpdmux_cmd_if_set_accepted_frames {
+	uint16_t if_id;
+	uint8_t frames_options;
+};
+
+struct dpdmux_cmd_if {
+	uint16_t if_id;
+};
+
+struct dpdmux_rsp_if_get_attr {
+	uint8_t pad[3];
+	uint8_t enabled;
+	uint8_t pad1[3];
+	uint8_t accepted_frames_type;
+	uint32_t rate;
+};
+
+struct dpdmux_cmd_if_l2_rule {
+	uint16_t if_id;
+	uint8_t mac_addr5;
+	uint8_t mac_addr4;
+	uint8_t mac_addr3;
+	uint8_t mac_addr2;
+	uint8_t mac_addr1;
+	uint8_t mac_addr0;
+
+	uint32_t pad;
+	uint16_t vlan_id;
+};
+
+struct dpdmux_cmd_if_get_counter {
+	uint16_t if_id;
+	uint8_t counter_type;
+};
+
+struct dpdmux_rsp_if_get_counter {
+	uint64_t pad;
+	uint64_t counter;
+};
+
+struct dpdmux_cmd_if_set_link_cfg {
+	uint16_t if_id;
+	uint16_t pad[3];
+
+	uint32_t rate;
+	uint32_t pad1;
+
+	uint64_t options;
+	uint64_t advertising;
+};
+
+struct dpdmux_cmd_if_get_link_state {
+	uint16_t if_id;
+};
+
+#define DPDMUX_UP_SHIFT				0
+#define DPDMUX_UP_SIZE				1
+#define DPDMUX_STATE_VALID_SHIFT	1
+#define DPDMUX_STATE_VALID_SIZE		1
+struct dpdmux_rsp_if_get_link_state {
+	uint32_t pad;
+	uint8_t up;
+	uint8_t pad1[3];
+
+	uint32_t rate;
+	uint32_t pad2;
+
+	uint64_t options;
+	uint64_t supported;
+	uint64_t advertising;
+};
+
+struct dpdmux_rsp_get_api_version {
+	uint16_t major;
+	uint16_t minor;
+};
+
+struct dpdmux_set_custom_key {
+	uint64_t pad[6];
+	uint64_t key_cfg_iova;
+};
+
+struct dpdmux_cmd_add_custom_cls_entry {
+	uint8_t pad[3];
+	uint8_t key_size;
+	uint16_t pad1;
+	uint16_t dest_if;
+	uint64_t key_iova;
+	uint64_t mask_iova;
+};
+
+struct dpdmux_cmd_remove_custom_cls_entry {
+	uint8_t pad[3];
+	uint8_t key_size;
+	uint32_t pad1;
+	uint64_t key_iova;
+	uint64_t mask_iova;
+};
+#pragma pack(pop)
+#endif /* _FSL_DPDMUX_CMD_H */
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index 07aada87c..c7c2df417 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -12,6 +12,7 @@ sources = files('base/dpaa2_hw_dpni.c',
 		'dpaa2_ethdev.c',
 		'dpaa2_rxtx.c',
 		'mc/dpkg.c',
+		'mc/dpdmux.c',
 		'mc/dpni.c')
 
 includes += include_directories('base', 'mc')
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 14/20] bus/fslmc: add support for scanning DPDMUX object
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (12 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 13/20] net/dpaa2: add dpdmux mc flib Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 15/20] net/dpaa2: add dpdmux initialization and configuration Shreyansh Jain
                     ` (6 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

Add support in bus and vfio to scan dpdmux type of objects

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c  | 5 ++++-
 drivers/bus/fslmc/fslmc_vfio.c | 2 ++
 drivers/bus/fslmc/rte_fslmc.h  | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 565e0148f..fa1505377 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -187,6 +187,8 @@ scan_one_fslmc_device(char *dev_name)
 		dev->dev_type = DPAA2_MPORTAL;
 	else if (!strncmp("dpdmai", t_ptr, 6))
 		dev->dev_type = DPAA2_QDMA;
+	else if (!strncmp("dpdmux", t_ptr, 6))
+		dev->dev_type = DPAA2_MUX;
 	else
 		dev->dev_type = DPAA2_UNKNOWN;
 
@@ -245,7 +247,8 @@ rte_fslmc_parse(const char *name, void *addr)
 	    strncmp("dpio", t_ptr, 4) &&
 	    strncmp("dpci", t_ptr, 4) &&
 	    strncmp("dpmcp", t_ptr, 5) &&
-	    strncmp("dpdmai", t_ptr, 6)) {
+	    strncmp("dpdmai", t_ptr, 6) &&
+	    strncmp("dpdmux", t_ptr, 6)) {
 		DPAA2_BUS_ERR("Unknown or unsupported device");
 		goto err_out;
 	}
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index ce82a99f6..98768a46c 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -560,6 +560,7 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev)
 	case DPAA2_IO:
 	case DPAA2_CI:
 	case DPAA2_BPOOL:
+	case DPAA2_MUX:
 		TAILQ_FOREACH(object, &dpaa2_obj_list, next) {
 			if (dev->dev_type == object->dev_type)
 				object->create(dev_fd, &device_info,
@@ -691,6 +692,7 @@ fslmc_vfio_process_group(void)
 		case DPAA2_IO:
 		case DPAA2_CI:
 		case DPAA2_BPOOL:
+		case DPAA2_MUX:
 			/* Call the object creation routine and remove the
 			 * device entry from device list
 			 */
diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h
index cea5b78f9..5cfb24505 100644
--- a/drivers/bus/fslmc/rte_fslmc.h
+++ b/drivers/bus/fslmc/rte_fslmc.h
@@ -66,6 +66,7 @@ enum rte_dpaa2_dev_type {
 	DPAA2_CI,	/**< DPCI type device */
 	DPAA2_MPORTAL,  /**< DPMCP type device */
 	DPAA2_QDMA,     /**< DPDMAI type device */
+	DPAA2_MUX,	/**< DPDMUX type device */
 	/* Unknown device placeholder */
 	DPAA2_UNKNOWN,
 	DPAA2_DEVTYPE_MAX,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 15/20] net/dpaa2: add dpdmux initialization and configuration
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (13 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 14/20] bus/fslmc: add support for scanning DPDMUX object Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 16/20] net/dpaa2: add API to support custom hash key Shreyansh Jain
                     ` (5 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

This patch introduces an rte pmd API to configure dpdmux from
the application.
dpdmux can work in association with dpni as an additional
distribution capability on the NIC.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/Makefile                  |   1 +
 drivers/net/dpaa2/dpaa2_ethdev.h            |   2 +
 drivers/net/dpaa2/dpaa2_mux.c               | 222 ++++++++++++++++++++
 drivers/net/dpaa2/meson.build               |   1 +
 drivers/net/dpaa2/rte_pmd_dpaa2.h           |  23 ++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |   1 +
 6 files changed, 250 insertions(+)
 create mode 100644 drivers/net/dpaa2/dpaa2_mux.c

diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index c58a39725..562551175 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -33,6 +33,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += base/dpaa2_hw_dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_mux.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpkg.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpdmux.c
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index 7cf6e4191..420ad6446 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -11,6 +11,8 @@
 #include <rte_event_eth_rx_adapter.h>
 #include <rte_pmd_dpaa2.h>
 
+#include <dpaa2_hw_pvt.h>
+
 #include <mc/fsl_dpni.h>
 #include <mc/fsl_mc_sys.h>
 
diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
new file mode 100644
index 000000000..1d043dcdc
--- /dev/null
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -0,0 +1,222 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#include <sys/queue.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#include <rte_ethdev.h>
+#include <rte_log.h>
+#include <rte_eth_ctrl.h>
+#include <rte_malloc.h>
+#include <rte_flow_driver.h>
+#include <rte_tailq.h>
+
+#include <rte_fslmc.h>
+#include <fsl_dpdmux.h>
+#include <fsl_dpkg.h>
+
+#include <dpaa2_ethdev.h>
+#include <dpaa2_pmd_logs.h>
+
+struct dpaa2_dpdmux_dev {
+	TAILQ_ENTRY(dpaa2_dpdmux_dev) next;
+		/**< Pointer to Next device instance */
+	struct fsl_mc_io dpdmux;  /** handle to DPDMUX portal object */
+	uint16_t token;
+	uint32_t dpdmux_id; /*HW ID for DPDMUX object */
+	uint8_t num_ifs;   /* Number of interfaces in DPDMUX */
+};
+
+struct rte_flow {
+	struct dpdmux_rule_cfg rule;
+};
+
+TAILQ_HEAD(dpdmux_dev_list, dpaa2_dpdmux_dev);
+static struct dpdmux_dev_list dpdmux_dev_list =
+	TAILQ_HEAD_INITIALIZER(dpdmux_dev_list); /*!< DPDMUX device list */
+
+static struct dpaa2_dpdmux_dev *get_dpdmux_from_id(uint32_t dpdmux_id)
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev = NULL;
+
+	/* Get DPBP dev handle from list using index */
+	TAILQ_FOREACH(dpdmux_dev, &dpdmux_dev_list, next) {
+		if (dpdmux_dev->dpdmux_id == dpdmux_id)
+			break;
+	}
+
+	return dpdmux_dev;
+}
+
+struct rte_flow *
+rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
+			      struct rte_flow_item *pattern[],
+			      struct rte_flow_action *actions[])
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev;
+	struct dpkg_profile_cfg kg_cfg;
+	const struct rte_flow_item_ipv4 *spec;
+	const struct rte_flow_action_vf *vf_conf;
+	struct dpdmux_cls_action dpdmux_action;
+	struct rte_flow *flow = NULL;
+	void *key_iova, *mask_iova, *key_cfg_iova = NULL;
+	int ret;
+
+	if (pattern[0]->type != RTE_FLOW_ITEM_TYPE_IPV4) {
+		DPAA2_PMD_ERR("Not supported pattern type: %d",
+			      pattern[0]->type);
+		return NULL;
+	}
+
+	/* Find the DPDMUX from dpdmux_id in our list */
+	dpdmux_dev = get_dpdmux_from_id(dpdmux_id);
+	if (!dpdmux_dev) {
+		DPAA2_PMD_ERR("Invalid dpdmux_id: %d", dpdmux_id);
+		return NULL;
+	}
+
+	key_cfg_iova = rte_zmalloc(NULL, DIST_PARAM_IOVA_SIZE,
+				   RTE_CACHE_LINE_SIZE);
+	if (!key_cfg_iova) {
+		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
+		return NULL;
+	}
+
+	/* Currently taking only IP protocol as an extract type.
+	 * This can be exended to other fields using pattern->type.
+	 */
+	memset(&kg_cfg, 0, sizeof(struct dpkg_profile_cfg));
+	kg_cfg.extracts[0].extract.from_hdr.prot = NET_PROT_IP;
+	kg_cfg.extracts[0].extract.from_hdr.field = NH_FLD_IP_PROTO;
+	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_HDR;
+	kg_cfg.extracts[0].extract.from_hdr.type = DPKG_FULL_FIELD;
+	kg_cfg.num_extracts = 1;
+
+	ret = dpkg_prepare_key_cfg(&kg_cfg, key_cfg_iova);
+	if (ret) {
+		DPAA2_PMD_ERR("dpkg_prepare_key_cfg failed: err(%d)", ret);
+		goto creation_error;
+	}
+
+	ret = dpdmux_set_custom_key(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token,
+			(uint64_t)(DPAA2_VADDR_TO_IOVA(key_cfg_iova)));
+	if (ret) {
+		DPAA2_PMD_ERR("dpdmux_set_custom_key failed: err(%d)", ret);
+		goto creation_error;
+	}
+
+	/* As now our key extract parameters are set, let us configure
+	 * the rule.
+	 */
+	flow = rte_zmalloc(NULL, sizeof(struct rte_flow) +
+			   (2 * DIST_PARAM_IOVA_SIZE), RTE_CACHE_LINE_SIZE);
+	if (!flow) {
+		DPAA2_PMD_ERR(
+			"Memory allocation failure for rule configration\n");
+		goto creation_error;
+	}
+	key_iova = (void *)((size_t)flow + sizeof(struct rte_flow));
+	mask_iova = (void *)((size_t)key_iova + DIST_PARAM_IOVA_SIZE);
+
+	spec = (const struct rte_flow_item_ipv4 *)pattern[0]->spec;
+	memcpy(key_iova, (const void *)&spec->hdr.next_proto_id,
+	       sizeof(uint8_t));
+	memcpy(mask_iova, pattern[0]->mask, sizeof(uint8_t));
+
+	flow->rule.key_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(key_iova));
+	flow->rule.mask_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(mask_iova));
+	flow->rule.key_size = sizeof(uint8_t);
+
+	vf_conf = (const struct rte_flow_action_vf *)(actions[0]->conf);
+	if (vf_conf->id == 0 || vf_conf->id > dpdmux_dev->num_ifs) {
+		DPAA2_PMD_ERR("Invalid destination id\n");
+		goto creation_error;
+	}
+	dpdmux_action.dest_if = vf_conf->id;
+
+	ret = dpdmux_add_custom_cls_entry(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+					  dpdmux_dev->token, &flow->rule,
+					  &dpdmux_action);
+	if (ret) {
+		DPAA2_PMD_ERR("dpdmux_add_custom_cls_entry failed: err(%d)",
+			      ret);
+		goto creation_error;
+	}
+
+	return flow;
+
+creation_error:
+	rte_free((void *)key_cfg_iova);
+	rte_free((void *)flow);
+	return NULL;
+}
+
+static int
+dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
+			   struct vfio_device_info *obj_info __rte_unused,
+			   int dpdmux_id)
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev;
+	struct dpdmux_attr attr;
+	int ret;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* Allocate DPAA2 dpdmux handle */
+	dpdmux_dev = rte_malloc(NULL, sizeof(struct dpaa2_dpdmux_dev), 0);
+	if (!dpdmux_dev) {
+		DPAA2_PMD_ERR("Memory allocation failed for DPDMUX Device");
+		return -1;
+	}
+
+	/* Open the dpdmux object */
+	dpdmux_dev->dpdmux.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+	ret = dpdmux_open(&dpdmux_dev->dpdmux, CMD_PRI_LOW, dpdmux_id,
+			  &dpdmux_dev->token);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to open dpdmux object: err(%d)", ret);
+		goto init_err;
+	}
+
+	ret = dpdmux_get_attributes(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token, &attr);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to get dpdmux attr: err(%d)", ret);
+		goto init_err;
+	}
+
+	ret = dpdmux_if_set_default(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token, 1);
+	if (ret) {
+		DPAA2_PMD_ERR("setting default interface failed in %s",
+			      __func__);
+		goto init_err;
+	}
+
+	dpdmux_dev->dpdmux_id = dpdmux_id;
+	dpdmux_dev->num_ifs = attr.num_ifs;
+
+	TAILQ_INSERT_TAIL(&dpdmux_dev_list, dpdmux_dev, next);
+
+	return 0;
+
+init_err:
+	if (dpdmux_dev)
+		rte_free(dpdmux_dev);
+
+	return -1;
+}
+
+static struct rte_dpaa2_object rte_dpaa2_dpdmux_obj = {
+	.dev_type = DPAA2_MUX,
+	.create = dpaa2_create_dpdmux_device,
+};
+
+RTE_PMD_REGISTER_DPAA2_OBJECT(dpdmux, rte_dpaa2_dpdmux_obj);
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index c7c2df417..801cbf5d7 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -9,6 +9,7 @@ endif
 
 deps += ['mempool_dpaa2']
 sources = files('base/dpaa2_hw_dpni.c',
+		'dpaa2_mux.c',
 		'dpaa2_ethdev.c',
 		'dpaa2_rxtx.c',
 		'mc/dpkg.c',
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
index f9303acad..57de27f21 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2.h
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -36,4 +36,27 @@ enum pmd_dpaa2_ts {
 __rte_experimental
 void rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Create a flow rule to demultiplex ethernet traffic to separate network
+ * interfaces.
+ *
+ * @param dpdmux_id
+ *    ID of the DPDMUX MC object.
+ * @param[in] pattern
+ *    Pattern specification.
+ * @param[in] actions
+ *    Associated actions.
+ *
+ * @return
+ *    A valid handle in case of success, NULL otherwise.
+ */
+__rte_experimental
+struct rte_flow *
+rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
+			      struct rte_flow_item *pattern[],
+			      struct rte_flow_action *actions[]);
+
 #endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index de95a03cd..1661c5fb5 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -14,5 +14,6 @@ DPDK_17.11 {
 EXPERIMENTAL {
 	global:
 
+	rte_pmd_dpaa2_mux_flow_create;
 	rte_pmd_dpaa2_set_timestamp;
 } DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 16/20] net/dpaa2: add API to support custom hash key
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (14 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 15/20] net/dpaa2: add dpdmux initialization and configuration Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 17/20] mempool/dpaa2: support saving context of buffer pool Shreyansh Jain
                     ` (4 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

The DPAA2 hw can support a special offset based
configuration to program distribution on hash.
This is for all cases, which are not directly supported.

e.g. HASH based distribution on inner ip header
of a GRE tunnel.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c      | 52 ++++++++++++++++++++-
 drivers/net/dpaa2/rte_pmd_dpaa2.h           | 28 +++++++++++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |  1 +
 3 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
index a6f86df8c..11f14931e 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016 NXP
+ *   Copyright 2016-2018 NXP
  *
  */
 
@@ -28,6 +28,56 @@ dpaa2_distset_to_dpkg_profile_cfg(
 		uint64_t req_dist_set,
 		struct dpkg_profile_cfg *kg_cfg);
 
+int
+rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
+			      uint16_t offset,
+			      uint8_t size)
+{
+	struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
+	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
+	struct fsl_mc_io *dpni = priv->hw;
+	struct dpni_rx_tc_dist_cfg tc_cfg;
+	struct dpkg_profile_cfg kg_cfg;
+	void *p_params;
+	int ret, tc_index = 0;
+
+	p_params = rte_zmalloc(
+		NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
+	if (!p_params) {
+		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
+		return -ENOMEM;
+	}
+
+	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_DATA;
+	kg_cfg.extracts[0].extract.from_data.offset = offset;
+	kg_cfg.extracts[0].extract.from_data.size = size;
+	kg_cfg.num_extracts = 1;
+
+	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to prepare extract parameters");
+		rte_free(p_params);
+		return ret;
+	}
+
+	memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
+	tc_cfg.key_cfg_iova = (size_t)(DPAA2_VADDR_TO_IOVA(p_params));
+	tc_cfg.dist_size = eth_dev->data->nb_rx_queues;
+	tc_cfg.dist_mode = DPNI_DIST_MODE_HASH;
+
+	ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index,
+				  &tc_cfg);
+	rte_free(p_params);
+	if (ret) {
+		DPAA2_PMD_ERR(
+			     "Setting distribution for Rx failed with err: %d",
+			     ret);
+		return ret;
+	}
+
+	return 0;
+}
+
 int
 dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
 		      uint64_t req_dist_set)
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
index 57de27f21..7052d9da9 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2.h
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -59,4 +59,32 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
 			      struct rte_flow_item *pattern[],
 			      struct rte_flow_action *actions[]);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Create a custom hash key on basis of offset of start of packet and size.
+ * for e.g. if we need GRE packets (non-vlan and without any extra headers)
+ * to be hashed on basis of inner IP header, we will provide offset as:
+ * 14 (eth) + 20 (IP) + 4 (GRE) + 12 (Inner Src offset) = 50 and size
+ * as 8 bytes.
+ *
+ * @param port_id
+ *    The port identifier of the Ethernet device.
+ * @param offset
+ *    Offset from the start of packet which needs to be included to
+ *    calculate hash
+ * @param size
+ *    Size of the hash input key
+ *
+ * @return
+ *   - 0 if successful.
+ *   - Negative in case of failure.
+ */
+__rte_experimental
+int
+rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
+			      uint16_t offset,
+			      uint8_t size);
+
 #endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index 1661c5fb5..d1b4cdb23 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -15,5 +15,6 @@ EXPERIMENTAL {
 	global:
 
 	rte_pmd_dpaa2_mux_flow_create;
+	rte_pmd_dpaa2_set_custom_hash;
 	rte_pmd_dpaa2_set_timestamp;
 } DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 17/20] mempool/dpaa2: support saving context of buffer pool
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (15 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 16/20] net/dpaa2: add API to support custom hash key Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 18/20] net/dpaa2: change reference to private device Shreyansh Jain
                     ` (3 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

Initial design was to have the buffer pool per process where a
global static array stores the bpids. But, in case of secondary
processes, this would not allow the I/O threads to translate the
bpid in Rx'd packets.

This patch moves the array to a global area (rte_malloc) and in
case of Rx thread not containing a valid reference to the array,
reference is build using the handle avaialble in the dpaa2_queue.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h  |  1 +
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 12 +++++++++++-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.h |  2 +-
 drivers/net/dpaa2/dpaa2_ethdev.c         |  1 +
 drivers/net/dpaa2/dpaa2_rxtx.c           |  5 +++++
 5 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
index efbeebef9..20c606dbe 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
@@ -141,6 +141,7 @@ struct dpaa2_queue {
 	};
 	struct rte_event ev;
 	dpaa2_queue_cb_dqrr_t *cb;
+	struct dpaa2_bp_info *bp_array;
 };
 
 struct swp_active_dqs {
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index 790cded80..335eae40e 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -32,7 +32,7 @@
 
 #include <dpaax_iova_table.h>
 
-struct dpaa2_bp_info rte_dpaa2_bpid_info[MAX_BPID];
+struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
 /* Dynamic logging identified for mempool */
@@ -50,6 +50,16 @@ rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 
 	avail_dpbp = dpaa2_alloc_dpbp_dev();
 
+	if (rte_dpaa2_bpid_info == NULL) {
+		rte_dpaa2_bpid_info = (struct dpaa2_bp_info *)rte_malloc(NULL,
+				      sizeof(struct dpaa2_bp_info) * MAX_BPID,
+				      RTE_CACHE_LINE_SIZE);
+		if (rte_dpaa2_bpid_info == NULL)
+			return -ENOMEM;
+		memset(rte_dpaa2_bpid_info, 0,
+		       sizeof(struct dpaa2_bp_info) * MAX_BPID);
+	}
+
 	if (!avail_dpbp) {
 		DPAA2_MEMPOOL_ERR("DPAA2 pool not available!");
 		return -ENOENT;
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.h b/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
index 4d3468746..93694616e 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
@@ -59,7 +59,7 @@ struct dpaa2_bp_info {
 #define mempool_to_bpinfo(mp) ((struct dpaa2_bp_info *)(mp)->pool_data)
 #define mempool_to_bpid(mp) ((mempool_to_bpinfo(mp))->bpid)
 
-extern struct dpaa2_bp_info rte_dpaa2_bpid_info[MAX_BPID];
+extern struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 
 int rte_dpaa2_mbuf_alloc_bulk(struct rte_mempool *pool,
 		       void **obj_table, unsigned int count);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 861fbcd90..3a20158da 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -485,6 +485,7 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	}
 	dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[rx_queue_id];
 	dpaa2_q->mb_pool = mb_pool; /**< mbuf pool to populate RX ring. */
+	dpaa2_q->bp_array = rte_dpaa2_bpid_info;
 
 	/*Get the flow id from given VQ id*/
 	flow_id = rx_queue_id % priv->nb_rx_queues;
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index 816ea00fd..6e2e8abd7 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -518,6 +518,11 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			return 0;
 		}
 	}
+
+	if (unlikely(!rte_dpaa2_bpid_info &&
+		     rte_eal_process_type() == RTE_PROC_SECONDARY))
+		rte_dpaa2_bpid_info = dpaa2_q->bp_array;
+
 	swp = DPAA2_PER_LCORE_ETHRX_PORTAL;
 	pull_size = (nb_pkts > dpaa2_dqrr_size) ? dpaa2_dqrr_size : nb_pkts;
 	if (unlikely(!q_storage->active_dqs)) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 18/20] net/dpaa2: change reference to private device
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (16 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 17/20] mempool/dpaa2: support saving context of buffer pool Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 19/20] bus/fslmc: add support for secondary processes Shreyansh Jain
                     ` (2 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

The I/O threads for DPAA2 take their reference for bpool ID, the
port ID and other info like qdid, from the rte_eth_dev. Further,
to get this data during I/O operation, a reference of the RTE
device is kept in the queue structure (dpaa2_queue).

In case of secondary processes, rte_eth_dev is not same as the
primary process. Thus, the reference goes invalid.

This patch changes the implementation to use the dev_private
rather than the rte_eth_dev as that is shared area across
all the processes.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h |  5 ++++-
 drivers/net/dpaa2/dpaa2_ethdev.c        |  4 ++--
 drivers/net/dpaa2/dpaa2_rxtx.c          | 18 ++++++++++--------
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
index 20c606dbe..626fcbbca 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
@@ -127,7 +127,10 @@ typedef void (dpaa2_queue_cb_dqrr_t)(struct qbman_swp *swp,
 
 struct dpaa2_queue {
 	struct rte_mempool *mb_pool; /**< mbuf pool to populate RX ring. */
-	void *dev;
+	union {
+		struct rte_eth_dev_data *eth_data;
+		void *dev;
+	};
 	int32_t eventfd;	/*!< Event Fd of this queue */
 	uint32_t fqid;		/*!< Unique ID of this queue */
 	uint8_t tc_index;	/*!< traffic class identifier */
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 3a20158da..2b90f4021 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -244,7 +244,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 	}
 
 	for (i = 0; i < priv->nb_rx_queues; i++) {
-		mc_q->dev = dev;
+		mc_q->eth_data = dev->data;
 		priv->rx_vq[i] = mc_q++;
 		dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
 		dpaa2_q->q_storage = rte_malloc("dq_storage",
@@ -260,7 +260,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 	}
 
 	for (i = 0; i < priv->nb_tx_queues; i++) {
-		mc_q->dev = dev;
+		mc_q->eth_data = dev->data;
 		mc_q->flow_id = 0xffff;
 		priv->tx_vq[i] = mc_q++;
 		dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index 6e2e8abd7..2d4b9ef14 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -509,7 +509,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	const struct qbman_fd *fd, *next_fd;
 	struct qbman_pull_desc pulldesc;
 	struct queue_storage_info_t *q_storage = dpaa2_q->q_storage;
-	struct rte_eth_dev *dev = dpaa2_q->dev;
+	struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
 
 	if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) {
 		ret = dpaa2_affine_qbman_ethrx_swp();
@@ -613,9 +613,10 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			bufs[num_rx] = eth_sg_fd_to_mbuf(fd);
 		else
 			bufs[num_rx] = eth_fd_to_mbuf(fd);
-		bufs[num_rx]->port = dev->data->port_id;
+		bufs[num_rx]->port = eth_data->port_id;
 
-		if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
+		if (eth_data->dev_conf.rxmode.offloads &
+				DEV_RX_OFFLOAD_VLAN_STRIP)
 			rte_vlan_strip(bufs[num_rx]);
 
 		dq_storage++;
@@ -716,8 +717,8 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	struct qbman_swp *swp;
 	uint16_t num_tx = 0;
 	uint16_t bpid;
-	struct rte_eth_dev *dev = dpaa2_q->dev;
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
+	struct dpaa2_dev_priv *priv = eth_data->dev_private;
 	uint32_t flags[MAX_TX_RING_SLOTS] = {0};
 
 	if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
@@ -729,7 +730,8 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	}
 	swp = DPAA2_PER_LCORE_PORTAL;
 
-	DPAA2_PMD_DP_DEBUG("===> dev =%p, fqid =%d\n", dev, dpaa2_q->fqid);
+	DPAA2_PMD_DP_DEBUG("===> eth_data =%p, fqid =%d\n",
+			eth_data, dpaa2_q->fqid);
 
 	/*Prepare enqueue descriptor*/
 	qbman_eq_desc_clear(&eqdesc);
@@ -772,7 +774,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 				    rte_mbuf_refcnt_read((*bufs)) == 1)) {
 					if (unlikely(((*bufs)->ol_flags
 						& PKT_TX_VLAN_PKT) ||
-						(dev->data->dev_conf.txmode.offloads
+						(eth_data->dev_conf.txmode.offloads
 						& DEV_TX_OFFLOAD_VLAN_INSERT))) {
 						ret = rte_vlan_insert(bufs);
 						if (ret)
@@ -794,7 +796,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			}
 
 			if (unlikely(((*bufs)->ol_flags & PKT_TX_VLAN_PKT) ||
-				(dev->data->dev_conf.txmode.offloads
+				(eth_data->dev_conf.txmode.offloads
 				& DEV_TX_OFFLOAD_VLAN_INSERT))) {
 				int ret = rte_vlan_insert(bufs);
 				if (ret)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 19/20] bus/fslmc: add support for secondary processes
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (17 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 18/20] net/dpaa2: change reference to private device Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 20/20] bus/fslmc: add function to map any addr via VFIO Shreyansh Jain
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

Previously FSLMC bus only supported blacklisting of DPNI (eth),
DPSECI (crypto) devices. With this patch, devices like DPIO,
DPMCP, and other DP* can also be blacklisted/whitelisted.

This is a required condition for secondary processes where the
secondary needs to be passed a mutually exclusive list of
resources as compared the primary and all other secondaries.

This patch also moves the DPIO memory from malloc to hugepage so
that in future in case the DPIO list can be shared, it can be
accessed in secondaries.

Once this patch is done, multi-process cases can be executed by
whitelisting/blacklisting devices in each instance.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c           | 51 ++++++++++++++++++++----
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 24 +++++++++--
 2 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 98768a46c..1aae56fa9 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016 NXP
+ *   Copyright 2016-2018 NXP
  *
  */
 
@@ -610,6 +610,15 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
 
 	/* check the MC version compatibility */
 	dpmng.regs = (void *)v_addr;
+
+	/* In case of secondary processes, MC version check is no longer
+	 * required.
+	 */
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		rte_mcp_ptr_list[0] = (void *)v_addr;
+		return 0;
+	}
+
 	if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info)) {
 		DPAA2_BUS_ERR("Unable to obtain MC version");
 		ret = -1;
@@ -653,6 +662,15 @@ fslmc_vfio_process_group(void)
 	/* Search the MCP as that should be initialized first. */
 	TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_temp) {
 		if (dev->dev_type == DPAA2_MPORTAL) {
+			if (dev->device.devargs &&
+			    dev->device.devargs->policy == RTE_DEV_BLACKLISTED) {
+				DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
+					      dev->device.name);
+				TAILQ_REMOVE(&rte_fslmc_bus.device_list,
+						dev, next);
+				continue;
+			}
+
 			ret = fslmc_process_mcp(dev);
 			if (ret) {
 				DPAA2_BUS_ERR("Unable to map MC Portal");
@@ -677,6 +695,13 @@ fslmc_vfio_process_group(void)
 	}
 
 	TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_temp) {
+		if (dev->device.devargs &&
+		    dev->device.devargs->policy == RTE_DEV_BLACKLISTED) {
+			DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
+				      dev->device.name);
+			TAILQ_REMOVE(&rte_fslmc_bus.device_list, dev, next);
+			continue;
+		}
 		switch (dev->dev_type) {
 		case DPAA2_ETH:
 		case DPAA2_CRYPTO:
@@ -689,10 +714,17 @@ fslmc_vfio_process_group(void)
 			}
 			break;
 		case DPAA2_CON:
-		case DPAA2_IO:
 		case DPAA2_CI:
 		case DPAA2_BPOOL:
 		case DPAA2_MUX:
+			/* IN case of secondary processes, all control objects
+			 * like dpbp, dpcon, dpci are not initialized/required
+			 * - all of these are assumed to be initialized and made
+			 *   available by primary.
+			 */
+			if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+				continue;
+
 			/* Call the object creation routine and remove the
 			 * device entry from device list
 			 */
@@ -703,12 +735,15 @@ fslmc_vfio_process_group(void)
 				return -1;
 			}
 
-			/* This device is not required to be in the DPDK
-			 * exposed device list.
-			 */
-			TAILQ_REMOVE(&rte_fslmc_bus.device_list, dev, next);
-			free(dev);
-			dev = NULL;
+			break;
+		case DPAA2_IO:
+			ret = fslmc_process_iodevices(dev);
+			if (ret) {
+				DPAA2_BUS_DEBUG("Dev (%s) init failed",
+						dev->device.name);
+				return -1;
+			}
+
 			break;
 		case DPAA2_UNKNOWN:
 		default:
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index cd28441f3..f377f24ae 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -418,9 +418,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 			goto err;
 	}
 
-	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
-	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
-
+	dpio_dev->dpio = rte_zmalloc(NULL, sizeof(struct fsl_mc_io),
+				     RTE_CACHE_LINE_SIZE);
 	if (!dpio_dev->dpio) {
 		DPAA2_BUS_ERR("Memory allocation failure");
 		goto err;
@@ -535,9 +534,26 @@ dpaa2_create_dpio_device(int vdev_fd,
 	if (dpio_dev->dpio) {
 		dpio_disable(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
 		dpio_close(dpio_dev->dpio, CMD_PRI_LOW,  dpio_dev->token);
-		free(dpio_dev->dpio);
+		rte_free(dpio_dev->dpio);
 	}
+
 	rte_free(dpio_dev);
+
+	/* For each element in the list, cleanup */
+	TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {
+		if (dpio_dev->dpio) {
+			dpio_disable(dpio_dev->dpio, CMD_PRI_LOW,
+				dpio_dev->token);
+			dpio_close(dpio_dev->dpio, CMD_PRI_LOW,
+				dpio_dev->token);
+			rte_free(dpio_dev->dpio);
+		}
+		rte_free(dpio_dev);
+	}
+
+	/* Preventing re-use of the list with old entries */
+	TAILQ_INIT(&dpio_dev_list);
+
 	return -1;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO
  2019-01-10  9:58     ` Shreyansh Jain
@ 2019-01-11 11:58       ` Ferruh Yigit
  2019-01-11 12:16         ` Shreyansh Jain
  0 siblings, 1 reply; 70+ messages in thread
From: Ferruh Yigit @ 2019-01-11 11:58 UTC (permalink / raw)
  To: Shreyansh Jain, Hemant Agrawal, dev; +Cc: Pankaj Chauhan, M.h. Lian

On 1/10/2019 9:58 AM, Shreyansh Jain wrote:
> Hello Ferruh,
> 
> Replying on behalf of Hemant...
> 
> On 08/01/19 7:40 PM, Ferruh Yigit wrote:
>> On 12/27/2018 6:23 AM, Hemant Agrawal wrote:
>>> From: Pankaj Chauhan <pankaj.chauhan@nxp.com>
>>>
>>> This is required to map any accelerator memory
>>> and PCI address to VFIO using QDMA.
>>>
>>> Signed-off-by: Minghuan Lian <Minghuan.Lian@nxp.com>
>>> Signed-off-by: Pankaj Chauhan <pankaj.chauhan@nxp.com>
>>
>> This requires either sign-off or ack from 'bus/fslmc' maintainers, which are:
>> 	M: Hemant Agrawal <hemant.agrawal@nxp.com>
>>
>>
>>
>> 	M: Shreyansh Jain <shreyansh.jain@nxp.com>
>>
>> I think Hemant sending the patchset implies that this has been reviewed by him
>> but this information get lost in git, so better to explicitly provide review/ack
>> tags whenever appropriate.
> 
> What I will do is, re-spin the complete series (with error below 
> fixed...) and send again. All the patches are on FSLMC/DPAA2 drivers 
> only so probably Hemant's or my Acks would work directly.
> 
>>
>> <...>
>>
>>> +	printf("PCIe vfio map 0x%llx:0x%llx, size 0x%llx\n", dma_map.vaddr,
>>> +		dma_map.iova, dma_map.size);
>>
>> This is causing build error [1], but why at first place using 'printf()' instead
>> of logging macros?
> 
> I will fix this.
> 
>>
>> [1]
>> .../drivers/bus/fslmc/fslmc_vfio.c: In function ‘rte_fslmc_vfio_mem_dmamap’:
>> .../drivers/bus/fslmc/fslmc_vfio.c:376:29: error: format ‘%llx’ expects argument
>> of type ‘long long unsigned int’, but argument 2 has type ‘__u64’ {aka ‘long
>> unsigned int’} [-Werror=format=]
>>    printf("PCIe vfio map 0x%llx:0x%llx, size 0x%llx\n", dma_map.vaddr,
>>                            ~~~^                         ~~~~~~~~~~~~~
>>                            %lx
>>
>> <...>
>>
>>> +DPDK_19.02 {
>>> +	global:
>>> +
>>> +	rte_fslmc_vfio_mem_dmamap;
>>
>> Is this need to be an API? Who is the consumer of this API, I don't see anyone
>> calls this function?
>>
> 
> This API (internal to FSLMC) was added for one of NXP's internal 
> software stack over DPDK. As this is an internal API, I don't think it 
> would pollute the outer namespace - isn't it? And, I think its consumers 
> won't necessarily be within DPDK stack.
> 
> Or, if this is conflicting case, I will remove this patch (it is 
> independent) and send again. Let me know your reservation.

API consumers doesn't have to be in DPDK but than it is not an internal API.

And for API we recently decided to have an implementation for new APIs, it can
be unit test, sample application, or app like testpmd, so that we can detect
when it is broken.

Perhaps it can be good idea to separate patch, as you suggested, to not block
the rest of the patchset.

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v2 20/20] bus/fslmc: add function to map any addr via VFIO
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (18 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 19/20] bus/fslmc: add support for secondary processes Shreyansh Jain
@ 2019-01-11 11:58   ` Shreyansh Jain
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 11:58 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Pankaj Chauhan, M.h. Lian

From: Pankaj Chauhan <pankaj.chauhan@nxp.com>

This is required to map any accelerator memory
and PCI address to VFIO using QDMA.

Signed-off-by: Minghuan Lian <Minghuan.Lian@nxp.com>
Signed-off-by: Pankaj Chauhan <pankaj.chauhan@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c              | 43 +++++++++++++++++++++
 drivers/bus/fslmc/fslmc_vfio.h              |  1 +
 drivers/bus/fslmc/rte_bus_fslmc_version.map |  7 ++++
 3 files changed, 51 insertions(+)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 1aae56fa9..786089334 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -50,6 +50,7 @@ static struct fslmc_vfio_group vfio_group;
 static struct fslmc_vfio_container vfio_container;
 static int container_device_fd;
 static char *g_container;
+static int fslmc_iommu_type;
 static uint32_t *msi_intr_vaddr;
 void *(*rte_mcp_ptr_list);
 
@@ -90,6 +91,9 @@ fslmc_get_container_group(int *groupid)
 		}
 	}
 
+	fslmc_iommu_type = (rte_vfio_noiommu_is_enabled() == 1) ?
+		RTE_VFIO_NOIOMMU : VFIO_TYPE1_IOMMU;
+
 	/* get group number */
 	ret = rte_vfio_get_group_num(SYSFS_FSL_MC_DEVICES,
 				     g_container, groupid);
@@ -344,6 +348,45 @@ fslmc_dmamap_seg(const struct rte_memseg_list *msl __rte_unused,
 	return ret;
 }
 
+int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size)
+{
+	int ret;
+	struct fslmc_vfio_group *group;
+	struct vfio_iommu_type1_dma_map dma_map = {
+		.argsz = sizeof(struct vfio_iommu_type1_dma_map),
+		.flags = VFIO_DMA_MAP_FLAG_READ | VFIO_DMA_MAP_FLAG_WRITE,
+	};
+
+	if (fslmc_iommu_type == RTE_VFIO_NOIOMMU) {
+		DPAA2_BUS_DEBUG("Running in NOIOMMU mode");
+		return 0;
+	}
+
+	/* SET DMA MAP for IOMMU */
+	group = &vfio_group;
+	if (!group->container) {
+		DPAA2_BUS_ERR("Container is not connected");
+		return -1;
+	}
+
+	dma_map.size = size;
+	dma_map.vaddr = vaddr;
+	dma_map.iova = iova;
+
+	DPAA2_BUS_DEBUG("FSLMC VFIO dmamap 0x%"PRIx64":0x%"PRIx64","
+			" size 0x%"PRIx64"", (uint64_t)dma_map.vaddr,
+			(uint64_t)dma_map.iova, (uint64_t)dma_map.size);
+	ret = ioctl(group->container->fd, VFIO_IOMMU_MAP_DMA,
+		    &dma_map);
+	if (ret) {
+		DPAA2_BUS_ERR("Unable to map DMA address (errno = %d)",
+			      errno);
+		return ret;
+	}
+
+	return 0;
+}
+
 int rte_fslmc_vfio_dmamap(void)
 {
 	int i = 0, ret;
diff --git a/drivers/bus/fslmc/fslmc_vfio.h b/drivers/bus/fslmc/fslmc_vfio.h
index 9e2c4feef..4e750d623 100644
--- a/drivers/bus/fslmc/fslmc_vfio.h
+++ b/drivers/bus/fslmc/fslmc_vfio.h
@@ -50,5 +50,6 @@ int fslmc_vfio_process_group(void);
 char *fslmc_get_container(void);
 int fslmc_get_container_group(int *gropuid);
 int rte_fslmc_vfio_dmamap(void);
+int rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size);
 
 #endif /* _FSLMC_VFIO_H_ */
diff --git a/drivers/bus/fslmc/rte_bus_fslmc_version.map b/drivers/bus/fslmc/rte_bus_fslmc_version.map
index dcc4e082e..c4192d978 100644
--- a/drivers/bus/fslmc/rte_bus_fslmc_version.map
+++ b/drivers/bus/fslmc/rte_bus_fslmc_version.map
@@ -129,3 +129,10 @@ DPDK_18.11 {
 	dpci_set_opr;
 
 } DPDK_18.05;
+
+DPDK_19.02 {
+	global:
+
+	rte_fslmc_vfio_mem_dmamap;
+
+} DPDK_18.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO
  2019-01-11 11:58       ` Ferruh Yigit
@ 2019-01-11 12:16         ` Shreyansh Jain
  0 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:16 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: Hemant Agrawal, dev, Pankaj Chauhan, M.h. Lian

On 11/01/19 5:28 PM, Ferruh Yigit wrote:
> On 1/10/2019 9:58 AM, Shreyansh Jain wrote:
>> Hello Ferruh,
>>
>> Replying on behalf of Hemant...
>>
>> On 08/01/19 7:40 PM, Ferruh Yigit wrote:
>>> On 12/27/2018 6:23 AM, Hemant Agrawal wrote:
>>>> From: Pankaj Chauhan <pankaj.chauhan@nxp.com>

[...]

>>>> +DPDK_19.02 {
>>>> +	global:
>>>> +
>>>> +	rte_fslmc_vfio_mem_dmamap;
>>>
>>> Is this need to be an API? Who is the consumer of this API, I don't see anyone
>>> calls this function?
>>>
>>
>> This API (internal to FSLMC) was added for one of NXP's internal
>> software stack over DPDK. As this is an internal API, I don't think it
>> would pollute the outer namespace - isn't it? And, I think its consumers
>> won't necessarily be within DPDK stack.
>>
>> Or, if this is conflicting case, I will remove this patch (it is
>> independent) and send again. Let me know your reservation.
> 
> API consumers doesn't have to be in DPDK but than it is not an internal API.
> 
> And for API we recently decided to have an implementation for new APIs, it can
> be unit test, sample application, or app like testpmd, so that we can detect
> when it is broken.
> 
> Perhaps it can be good idea to separate patch, as you suggested, to not block
> the rest of the patchset.
> 

Oops, I think I sent my series just about the time you wrote this.
I will send it again (v3) without the last patch. I am OK with that API 
not making it in right now.

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements
  2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                     ` (19 preceding siblings ...)
  2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 20/20] bus/fslmc: add function to map any addr via VFIO Shreyansh Jain
@ 2019-01-11 12:24   ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 01/19] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
                       ` (20 more replies)
  20 siblings, 21 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

(N: Original series was by Hemant - due to RC window timeline and
    his unavailability, respining on his behalf)

This patch set covers following:

1. Fixes in the existing NXP DPAA2 bus and net pmd
2. New object (DPDMUX) support in NIC driver for better classification
3. Improvements to support secondary process
4. Upgrade the low level QBMAN HW lib

History:
v1->v2:
 - Fix warning on Patch 20/20 - moved printfs to logging macro
   and PRIx changes
 - reset author of 07/20 as the signoff and author didn't match
 - Validate over master (a958a5c07f4b5e)
 - Reword patch headline/commit based on check-git-log script

v2->v3:
 - Remove last (20/20) patch which was introducing a new API
   within FSLMC layer

Akhil Goyal (1):
  net/dpaa2: enable optional timestamp in mbuf

Hemant Agrawal (7):
  bus/fslmc: fix to use correct physical core for logical core
  net/dpaa2: fix bad check for not-null
  bus/fslmc: fix to convert error msg to warning
  bus/fslmc: upgrade to latest qbman library
  bus/fslmc: add dynamic config for memback portal mode
  bus/fslmc: rename portal pi index to consumer index
  bus/fslmc: make portal func static

Nipun Gupta (4):
  net/dpaa2: add dpdmux mc flib
  bus/fslmc: add support for scanning DPDMUX object
  net/dpaa2: add dpdmux initialization and configuration
  net/dpaa2: add API to support custom hash key

Sachin Saxena (1):
  bus/fslmc: fix to reset portal memory before use

Shreyansh Jain (5):
  bus/fslmc: fix parse method for bus devices
  net/dpaa2: fix device init for secondary process
  mempool/dpaa2: support saving context of buffer pool
  net/dpaa2: change reference to private device
  bus/fslmc: add support for secondary processes

Youri Querry (1):
  bus/fslmc: fix the ring mode to use correct cache settings

 doc/api/doxy-api-index.md                     |   1 +
 doc/api/doxy-api.conf.in                      |   1 +
 drivers/bus/fslmc/fslmc_bus.c                 |  38 +-
 drivers/bus/fslmc/fslmc_vfio.c                |  55 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      | 100 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h      |   2 -
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h       |   6 +-
 .../bus/fslmc/qbman/include/fsl_qbman_base.h  |  11 +-
 drivers/bus/fslmc/qbman/qbman_portal.c        | 123 ++-
 drivers/bus/fslmc/qbman/qbman_portal.h        |   2 +-
 drivers/bus/fslmc/qbman/qbman_sys.h           |  34 +-
 drivers/bus/fslmc/rte_fslmc.h                 |   1 +
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c      |  12 +-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.h      |   2 +-
 drivers/net/dpaa2/Makefile                    |   4 +
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c        |  54 +-
 drivers/net/dpaa2/dpaa2_ethdev.c              |  26 +-
 drivers/net/dpaa2/dpaa2_ethdev.h              |   6 +
 drivers/net/dpaa2/dpaa2_mux.c                 | 222 +++++
 drivers/net/dpaa2/dpaa2_rxtx.c                |  41 +-
 drivers/net/dpaa2/mc/dpdmux.c                 | 929 ++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux.h             | 410 ++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h         | 221 +++++
 drivers/net/dpaa2/meson.build                 |   4 +
 drivers/net/dpaa2/rte_pmd_dpaa2.h             |  90 ++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map   |   8 +
 26 files changed, 2267 insertions(+), 136 deletions(-)
 create mode 100644 drivers/net/dpaa2/dpaa2_mux.c
 create mode 100644 drivers/net/dpaa2/mc/dpdmux.c
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux.h
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
 create mode 100644 drivers/net/dpaa2/rte_pmd_dpaa2.h

-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 01/19] bus/fslmc: fix to reset portal memory before use
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 02/19] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
                       ` (19 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Sachin Saxena, stable

From: Sachin Saxena <sachin.saxena@nxp.com>

Uninitialized portal memory is causing unwanted issues.

Fixes: 293c0ca94c36 ("bus/fslmc: support memory backed portals with QBMAN 5.0")
Cc: stable@dpdk.org

Signed-off-by: Sachin Saxena <sachin.saxena@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index ce0699842..4fc6efec5 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -369,6 +369,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 	dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX];
 
 	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
+	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
+
 	if (!dpio_dev->dpio) {
 		DPAA2_BUS_ERR("Memory allocation failure");
 		goto err;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 02/19] bus/fslmc: fix the ring mode to use correct cache settings
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 01/19] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 03/19] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
                       ` (18 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Youri Querry, stable

From: Youri Querry <youri.querry_1@nxp.com>

The code was incorrectly using the cache inhibited access.
It shall use cached enabled access for better performance.

Fixes: 293c0ca94c36 ("bus/fslmc: support memory backed portals with QBMAN 5.0")
Cc: stable@dpdk.org

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c | 12 ++++++------
 drivers/bus/fslmc/qbman/qbman_sys.h    |  1 +
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 3380e54f5..bbea37efc 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -683,8 +683,8 @@ static int qbman_swp_enqueue_ring_mode_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 				eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
@@ -809,8 +809,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 					eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
@@ -941,8 +941,8 @@ static int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s,
 	full_mask = s->eqcr.pi_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
-		s->eqcr.ci = qbman_cinh_read(&s->sys,
-				QBMAN_CENA_SWP_EQCR_CI) & full_mask;
+		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
+				QBMAN_CENA_SWP_EQCR_CI_MEMBACK) & full_mask;
 		s->eqcr.available = qm_cyc_diff(s->eqcr.pi_ring_size,
 					eqcr_ci, s->eqcr.ci);
 		if (!s->eqcr.available)
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index d41af8358..0571097ab 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -55,6 +55,7 @@
 #define QBMAN_CENA_SWP_RR(vb)  (0x700 + ((uint32_t)(vb) >> 1))
 #define QBMAN_CENA_SWP_VDQCR   0x780
 #define QBMAN_CENA_SWP_EQCR_CI 0x840
+#define QBMAN_CENA_SWP_EQCR_CI_MEMBACK 0x1840
 
 /* CENA register offsets in memory-backed mode */
 #define QBMAN_CENA_SWP_DQRR_MEM(n)  (0x800 + ((uint32_t)(n) << 6))
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 03/19] bus/fslmc: fix to use correct physical core for logical core
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 01/19] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 02/19] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 04/19] net/dpaa2: fix bad check for not-null Shreyansh Jain
                       ` (17 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, stable

From: Hemant Agrawal <hemant.agrawal@nxp.com>

Existing code is using the lcore id as the physical core
id. Add code to get the right physical id.

Also, dpaa2 can not support one lcore mapping to multiple cpus,
print err on such cases.

Fixes: ce9efbf5bb09 ("bus/fslmc: support dynamic logging")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 76 ++++++++++++++++++++----
 1 file changed, 63 insertions(+), 13 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 4fc6efec5..ba2e28ce1 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -53,6 +53,10 @@ static uint32_t io_space_count;
 /* Variable to store DPAA2 platform type */
 uint32_t dpaa2_svr_family;
 
+/* Physical core id for lcores running on dpaa2. */
+/* DPAA2 only support 1 lcore to 1 phy cpu mapping */
+static unsigned int dpaa2_cpu[RTE_MAX_LCORE];
+
 /* Variable to store DPAA2 DQRR size */
 uint8_t dpaa2_dqrr_size;
 /* Variable to store DPAA2 EQCR size */
@@ -92,7 +96,8 @@ dpaa2_core_cluster_sdest(int cpu_id)
 }
 
 #ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
-static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
+static void
+dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id, int lcoreid)
 {
 #define STRING_LEN	28
 #define COMMAND_LEN	50
@@ -125,7 +130,7 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
 		return;
 	}
 
-	cpu_mask = cpu_mask << rte_lcore_id();
+	cpu_mask = cpu_mask << dpaa2_cpu[lcoreid];
 	snprintf(command, COMMAND_LEN, "echo %X > /proc/irq/%s/smp_affinity",
 		 cpu_mask, token);
 	ret = system(command);
@@ -139,7 +144,7 @@ static void dpaa2_affine_dpio_intr_to_respective_core(int32_t dpio_id)
 	fclose(file);
 }
 
-static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
+static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 {
 	struct epoll_event epoll_ev;
 	int eventfd, dpio_epoll_fd, ret;
@@ -176,32 +181,36 @@ static int dpaa2_dpio_intr_init(struct dpaa2_dpio_dev *dpio_dev)
 	}
 	dpio_dev->epoll_fd = dpio_epoll_fd;
 
-	dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id);
+	dpaa2_affine_dpio_intr_to_respective_core(dpio_dev->hw_id, lcoreid);
 
 	return 0;
 }
 #endif
 
 static int
-dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
+dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 {
 	int sdest, ret;
+	int cpu_id;
 
 	/* Set the Stashing Destination */
-	if (cpu_id < 0) {
-		cpu_id = rte_get_master_lcore();
-		if (cpu_id < 0) {
+	if (lcoreid < 0) {
+		lcoreid = rte_get_master_lcore();
+		if (lcoreid < 0) {
 			DPAA2_BUS_ERR("Getting CPU Index failed");
 			return -1;
 		}
 	}
+
+	cpu_id = dpaa2_cpu[lcoreid];
+
 	/* Set the STASH Destination depending on Current CPU ID.
 	 * Valid values of SDEST are 4,5,6,7. Where,
 	 */
 
 	sdest = dpaa2_core_cluster_sdest(cpu_id);
-	DPAA2_BUS_DEBUG("Portal= %d  CPU= %u SDEST= %d",
-			dpio_dev->index, cpu_id, sdest);
+	DPAA2_BUS_DEBUG("Portal= %d  CPU= %u lcore id =%u SDEST= %d",
+			dpio_dev->index, cpu_id, lcoreid, sdest);
 
 	ret = dpio_set_stashing_destination(dpio_dev->dpio, CMD_PRI_LOW,
 					    dpio_dev->token, sdest);
@@ -211,7 +220,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
 	}
 
 #ifdef RTE_LIBRTE_PMD_DPAA2_EVENTDEV
-	if (dpaa2_dpio_intr_init(dpio_dev)) {
+	if (dpaa2_dpio_intr_init(dpio_dev, lcoreid)) {
 		DPAA2_BUS_ERR("Interrupt registration failed for dpio");
 		return -1;
 	}
@@ -220,7 +229,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int cpu_id)
 	return 0;
 }
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id)
+struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
 	int ret;
@@ -236,7 +245,7 @@ struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id)
 	DPAA2_BUS_DEBUG("New Portal %p (%d) affined thread - %lu",
 			dpio_dev, dpio_dev->index, syscall(SYS_gettid));
 
-	ret = dpaa2_configure_stashing(dpio_dev, cpu_id);
+	ret = dpaa2_configure_stashing(dpio_dev, lcoreid);
 	if (ret)
 		DPAA2_BUS_ERR("dpaa2_configure_stashing failed");
 
@@ -340,6 +349,39 @@ dpaa2_affine_qbman_ethrx_swp(void)
 	}
 }
 
+/*
+ * This checks for not supported lcore mappings as well as get the physical
+ * cpuid for the lcore.
+ * one lcore can only map to 1 cpu i.e. 1@10-14 not supported.
+ * one cpu can be mapped to more than one lcores.
+ */
+static int
+dpaa2_check_lcore_cpuset(void)
+{
+	unsigned int lcore_id, i;
+	int ret = 0;
+
+	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++)
+		dpaa2_cpu[lcore_id] = 0xffffffff;
+
+	for (lcore_id = 0; lcore_id < RTE_MAX_LCORE; lcore_id++) {
+		for (i = 0; i < RTE_MAX_LCORE; i++) {
+			if (CPU_ISSET(i, &lcore_config[lcore_id].cpuset)) {
+				RTE_LOG(DEBUG, EAL, "lcore id = %u cpu=%u\n",
+					lcore_id, i);
+				if (dpaa2_cpu[lcore_id] != 0xffffffff) {
+					DPAA2_BUS_ERR(
+				    "ERR:lcore map to multi-cpu not supported");
+					ret = -1;
+				} else  {
+					dpaa2_cpu[lcore_id] = i;
+				}
+			}
+		}
+	}
+	return ret;
+}
+
 static int
 dpaa2_create_dpio_device(int vdev_fd,
 			 struct vfio_device_info *obj_info,
@@ -349,6 +391,7 @@ dpaa2_create_dpio_device(int vdev_fd,
 	struct vfio_region_info reg_info = { .argsz = sizeof(reg_info)};
 	struct qbman_swp_desc p_des;
 	struct dpio_attr attr;
+	static int check_lcore_cpuset;
 
 	if (obj_info->num_regions < NUM_DPIO_REGIONS) {
 		DPAA2_BUS_ERR("Not sufficient number of DPIO regions");
@@ -368,6 +411,13 @@ dpaa2_create_dpio_device(int vdev_fd,
 	/* Using single portal  for all devices */
 	dpio_dev->mc_portal = rte_mcp_ptr_list[MC_PORTAL_INDEX];
 
+	if (!check_lcore_cpuset) {
+		check_lcore_cpuset = 1;
+
+		if (dpaa2_check_lcore_cpuset() < 0)
+			goto err;
+	}
+
 	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
 	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 04/19] net/dpaa2: fix bad check for not-null
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (2 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 03/19] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 05/19] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
                       ` (16 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, stable

From: Hemant Agrawal <hemant.agrawal@nxp.com>

The check !dpaa2->cscn is not correct to check non-null value.

Fixes: 5d9a1e4d23fe ("net/dpaa2: enhance queue memory cleanup")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index fa71807e6..8d4ea1bca 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -311,8 +311,7 @@ dpaa2_free_rx_tx_queues(struct rte_eth_dev *dev)
 		/* cleanup tx queue cscn */
 		for (i = 0; i < priv->nb_tx_queues; i++) {
 			dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
-			if (!dpaa2_q->cscn)
-				rte_free(dpaa2_q->cscn);
+			rte_free(dpaa2_q->cscn);
 		}
 		/*free memory for all queues (RX+TX) */
 		rte_free(priv->rx_vq[0]);
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 05/19] bus/fslmc: fix to convert error msg to warning
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (3 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 04/19] net/dpaa2: fix bad check for not-null Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 06/19] bus/fslmc: fix parse method for bus devices Shreyansh Jain
                       ` (15 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, stable

From: Hemant Agrawal <hemant.agrawal@nxp.com>

This is just a information. No need to print
it as a error.

Fixes: ce9efbf5bb09 ("bus/fslmc: support dynamic logging")
Cc: stable@dpdk.org

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 493b6e5be..ce82a99f6 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -176,7 +176,7 @@ static int vfio_map_irq_region(struct fslmc_vfio_group *group)
 	vaddr = (unsigned long *)mmap(NULL, 0x1000, PROT_WRITE |
 		PROT_READ, MAP_SHARED, container_device_fd, 0x6030000);
 	if (vaddr == MAP_FAILED) {
-		DPAA2_BUS_ERR("Unable to map region (errno = %d)", errno);
+		DPAA2_BUS_INFO("Unable to map region (errno = %d)", errno);
 		return -errno;
 	}
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 06/19] bus/fslmc: fix parse method for bus devices
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (4 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 05/19] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 07/19] net/dpaa2: fix device init for secondary process Shreyansh Jain
                       ` (14 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

Current code expects that bus->parse() would get a string containing
the name of the bus. That is incorrect. bus->parse() is expected
to have strings like:
  dpni.1,key=val
  dpio.2,key=val

when user passed:
  -b fslmc:dpni.1,key=val

This commit fixes this behavior.

Fixes: 50245be05d1a ("bus/fslmc: support device blacklisting")
Cc: stable@dpdk.org

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 89af9385a..565e0148f 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -1,6 +1,6 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
- *   Copyright 2016 NXP
+ *   Copyright 2016,2018 NXP
  *
  */
 
@@ -227,20 +227,16 @@ static int
 rte_fslmc_parse(const char *name, void *addr)
 {
 	uint16_t dev_id;
-	char *t_ptr;
-	char *sep = strchr(name, ':');
+	char *t_ptr = NULL, *dname = NULL;
 
-	if (strncmp(name, RTE_STR(FSLMC_BUS_NAME),
-		strlen(RTE_STR(FSLMC_BUS_NAME)))) {
-		return -EINVAL;
-	}
+	/* 'name' is expected to contain name of device, for example, dpio.1,
+	 * dpni.2, etc.
+	 */
 
-	if (!sep) {
-		DPAA2_BUS_ERR("Incorrect device name observed");
+	dname = strdup(name);
+	if (!dname)
 		return -EINVAL;
-	}
-
-	t_ptr = (char *)(sep + 1);
+	t_ptr = dname;
 
 	if (strncmp("dpni", t_ptr, 4) &&
 	    strncmp("dpseci", t_ptr, 6) &&
@@ -251,24 +247,29 @@ rte_fslmc_parse(const char *name, void *addr)
 	    strncmp("dpmcp", t_ptr, 5) &&
 	    strncmp("dpdmai", t_ptr, 6)) {
 		DPAA2_BUS_ERR("Unknown or unsupported device");
-		return -EINVAL;
+		goto err_out;
 	}
 
 	t_ptr = strchr(name, '.');
 	if (!t_ptr) {
 		DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
-		return -EINVAL;
+		goto err_out;
 	}
 
 	t_ptr = (char *)(t_ptr + 1);
 	if (sscanf(t_ptr, "%hu", &dev_id) <= 0) {
 		DPAA2_BUS_ERR("Incorrect device string observed (%s)", t_ptr);
-		return -EINVAL;
+		goto err_out;
 	}
+	free(dname);
 
 	if (addr)
-		strcpy(addr, (char *)(sep + 1));
+		strcpy(addr, name);
+
 	return 0;
+err_out:
+	free(dname);
+	return -EINVAL;
 }
 
 static int
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 07/19] net/dpaa2: fix device init for secondary process
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (5 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 06/19] bus/fslmc: fix parse method for bus devices Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 08/19] net/dpaa2: enable optional timestamp in mbuf Shreyansh Jain
                       ` (13 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain, stable

In order to support I/O from secondary process, the
burst APIs and OPS APIs shall be mapped/plugged.

Fixes: c147eae01cb3 ("net/dpaa2: introduce NXP DPAA2 driver")
Cc: stable@dpdk.org

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/net/dpaa2/dpaa2_ethdev.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 8d4ea1bca..39f85ae7b 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -1918,8 +1918,15 @@ dpaa2_dev_init(struct rte_eth_dev *eth_dev)
 	PMD_INIT_FUNC_TRACE();
 
 	/* For secondary processes, the primary has done all the work */
-	if (rte_eal_process_type() != RTE_PROC_PRIMARY)
+	if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
+		/* In case of secondary, only burst and ops API need to be
+		 * plugged.
+		 */
+		eth_dev->dev_ops = &dpaa2_ethdev_ops;
+		eth_dev->rx_pkt_burst = dpaa2_dev_prefetch_rx;
+		eth_dev->tx_pkt_burst = dpaa2_dev_tx;
 		return 0;
+	}
 
 	dpaa2_dev = container_of(dev, struct rte_dpaa2_device, device);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 08/19] net/dpaa2: enable optional timestamp in mbuf
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (6 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 07/19] net/dpaa2: fix device init for secondary process Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 09/19] bus/fslmc: upgrade to latest qbman library Shreyansh Jain
                       ` (12 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Akhil Goyal

From: Akhil Goyal <akhil.goyal@nxp.com>

This patch enables the population of timestamp field
in mbuf on packet receive.
It may give performance impact on LX2xxx platforms.
So, it has been made optional for Lx2xxx platform.
One shall call, rte_dpaa2_enable_ts() to enable it.

Nothing is required for LS2 and LS1088 platforms.

Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
 doc/api/doxy-api-index.md                   |  1 +
 doc/api/doxy-api.conf.in                    |  1 +
 drivers/net/dpaa2/Makefile                  |  2 ++
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c      |  2 ++
 drivers/net/dpaa2/dpaa2_ethdev.c            |  9 +++++
 drivers/net/dpaa2/dpaa2_ethdev.h            |  4 +++
 drivers/net/dpaa2/dpaa2_rxtx.c              | 18 ++++++++++
 drivers/net/dpaa2/meson.build               |  2 ++
 drivers/net/dpaa2/rte_pmd_dpaa2.h           | 39 +++++++++++++++++++++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |  6 ++++
 10 files changed, 84 insertions(+)
 create mode 100644 drivers/net/dpaa2/rte_pmd_dpaa2.h

diff --git a/doc/api/doxy-api-index.md b/doc/api/doxy-api-index.md
index e27874c5a..d95ad566c 100644
--- a/doc/api/doxy-api-index.md
+++ b/doc/api/doxy-api-index.md
@@ -43,6 +43,7 @@ The public API headers are grouped by topics:
   [i40e]               (@ref rte_pmd_i40e.h),
   [bnxt]               (@ref rte_pmd_bnxt.h),
   [dpaa]               (@ref rte_pmd_dpaa.h),
+  [dpaa2]              (@ref rte_pmd_dpaa2.h),
   [dpaa2_mempool]      (@ref rte_dpaa2_mempool.h),
   [dpaa2_cmdif]        (@ref rte_pmd_dpaa2_cmdif.h),
   [dpaa2_qdma]         (@ref rte_pmd_dpaa2_qdma.h),
diff --git a/doc/api/doxy-api.conf.in b/doc/api/doxy-api.conf.in
index 77ba327a8..bef9320c0 100644
--- a/doc/api/doxy-api.conf.in
+++ b/doc/api/doxy-api.conf.in
@@ -9,6 +9,7 @@ INPUT                   = @TOPDIR@/doc/api/doxy-api-index.md \
                           @TOPDIR@/drivers/net/bnxt \
                           @TOPDIR@/drivers/net/bonding \
                           @TOPDIR@/drivers/net/dpaa \
+                          @TOPDIR@/drivers/net/dpaa2 \
                           @TOPDIR@/drivers/net/i40e \
                           @TOPDIR@/drivers/net/ixgbe \
                           @TOPDIR@/drivers/net/softnic \
diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index ca5f7a336..2b9c011d6 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -42,4 +42,6 @@ LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring
 LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs
 LDLIBS += -lrte_common_dpaax
 
+# install this header file
+SYMLINK-$(CONFIG_RTE_LIBRTE_DPAA2_PMD)-include := rte_pmd_dpaa2.h
 include $(RTE_SDK)/mk/rte.lib.mk
diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
index 713a41bf3..a6f86df8c 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
@@ -296,8 +296,10 @@ dpaa2_attach_bp_list(struct dpaa2_dev_priv *priv,
 			 DPNI_BUF_LAYOUT_OPT_FRAME_STATUS |
 			 DPNI_BUF_LAYOUT_OPT_PARSER_RESULT |
 			 DPNI_BUF_LAYOUT_OPT_DATA_ALIGN |
+			 DPNI_BUF_LAYOUT_OPT_TIMESTAMP |
 			 DPNI_BUF_LAYOUT_OPT_PRIVATE_DATA_SIZE;
 
+	layout.pass_timestamp = true;
 	layout.pass_frame_status = 1;
 	layout.private_data_size = DPAA2_FD_PTA_SIZE;
 	layout.pass_parser_result = 1;
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 39f85ae7b..861fbcd90 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -56,6 +56,9 @@ static uint64_t dev_tx_offloads_nodis =
 		DEV_TX_OFFLOAD_MT_LOCKFREE |
 		DEV_TX_OFFLOAD_MBUF_FAST_FREE;
 
+/* enable timestamp in mbuf */
+enum pmd_dpaa2_ts dpaa2_enable_ts;
+
 struct rte_dpaa2_xstats_name_off {
 	char name[RTE_ETH_XSTATS_NAME_SIZE];
 	uint8_t page_id; /* dpni statistics page id */
@@ -88,6 +91,12 @@ static int dpaa2_dev_mtu_set(struct rte_eth_dev *dev, uint16_t mtu);
 
 int dpaa2_logtype_pmd;
 
+__rte_experimental void
+rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts enable)
+{
+	dpaa2_enable_ts = enable;
+}
+
 static int
 dpaa2_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
 {
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index bd69f523d..7cf6e4191 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -9,6 +9,7 @@
 #define _DPAA2_ETHDEV_H
 
 #include <rte_event_eth_rx_adapter.h>
+#include <rte_pmd_dpaa2.h>
 
 #include <mc/fsl_dpni.h>
 #include <mc/fsl_mc_sys.h>
@@ -83,6 +84,9 @@
 #define DPAA2_PKT_TYPE_VLAN_1		0x0160
 #define DPAA2_PKT_TYPE_VLAN_2		0x0260
 
+/* enable timestamp in mbuf*/
+extern enum pmd_dpaa2_ts dpaa2_enable_ts;
+
 struct dpaa2_dev_priv {
 	void *hw;
 	int32_t hw_id;
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index eab943dcf..816ea00fd 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -42,6 +42,7 @@ dpaa2_dev_rx_parse_slow(struct rte_mbuf *mbuf,
 static inline void __attribute__((hot))
 dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd)
 {
+	struct dpaa2_annot_hdr *annotation;
 	uint16_t frc = DPAA2_GET_FD_FRC_PARSE_SUM(fd);
 
 	m->packet_type = RTE_PTYPE_UNKNOWN;
@@ -104,6 +105,19 @@ dpaa2_dev_rx_parse_new(struct rte_mbuf *m, const struct qbman_fd *fd)
 	}
 	m->hash.rss = fd->simple.flc_hi;
 	m->ol_flags |= PKT_RX_RSS_HASH;
+
+	if (dpaa2_enable_ts == PMD_DPAA2_ENABLE_TS) {
+		annotation = (struct dpaa2_annot_hdr *)
+			((size_t)DPAA2_IOVA_TO_VADDR(
+			DPAA2_GET_FD_ADDR(fd)) + DPAA2_FD_PTA_SIZE);
+		m->timestamp = annotation->word2;
+		m->ol_flags |= PKT_RX_TIMESTAMP;
+		DPAA2_PMD_DP_DEBUG("pkt timestamp:0x%" PRIx64 "", m->timestamp);
+	}
+
+	DPAA2_PMD_DP_DEBUG("HW frc = 0x%x\t packet type =0x%x "
+		"ol_flags =0x%" PRIx64 "",
+		frc, m->packet_type, m->ol_flags);
 }
 
 static inline uint32_t __attribute__((hot))
@@ -205,6 +219,10 @@ dpaa2_dev_rx_parse(struct rte_mbuf *mbuf, void *hw_annot_addr)
 	else if (BIT_ISSET_AT_POS(annotation->word8, DPAA2_ETH_FAS_L4CE))
 		mbuf->ol_flags |= PKT_RX_L4_CKSUM_BAD;
 
+	mbuf->ol_flags |= PKT_RX_TIMESTAMP;
+	mbuf->timestamp = annotation->word2;
+	DPAA2_PMD_DP_DEBUG("pkt timestamp: 0x%" PRIx64 "", mbuf->timestamp);
+
 	/* Check detailed parsing requirement */
 	if (annotation->word3 & 0x7FFFFC3FFFF)
 		return dpaa2_dev_rx_parse_slow(mbuf, annotation);
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index b34595258..07aada87c 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -18,3 +18,5 @@ includes += include_directories('base', 'mc')
 
 # depends on fslmc bus which uses experimental API
 allow_experimental_apis = true
+
+install_headers('rte_pmd_dpaa2.h')
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
new file mode 100644
index 000000000..f9303acad
--- /dev/null
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -0,0 +1,39 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#ifndef _RTE_PMD_DPAA2_H
+#define _RTE_PMD_DPAA2_H
+
+/**
+ * @file rte_pmd_dpaa2.h
+ *
+ * NXP dpaa2 PMD specific functions.
+ *
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ */
+
+#include <rte_flow.h>
+
+enum pmd_dpaa2_ts {
+	PMD_DPAA2_DISABLE_TS,
+	PMD_DPAA2_ENABLE_TS
+};
+
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Enable/Disable timestamping update in mbuf for LX2160 kind of devices.
+ * For LS2088/LS1088 devices, timestamping will be updated in mbuf without
+ * calling this API.
+ *
+ * @param pmd_dpaa2_ts
+ *    Enum to enable/disable timestamp update in mbuf for LX2160 devices.
+ */
+__rte_experimental
+void rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts);
+
+#endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index 09f4364bc..de95a03cd 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -10,3 +10,9 @@ DPDK_17.11 {
 	dpaa2_eth_eventq_detach;
 
 } DPDK_17.05;
+
+EXPERIMENTAL {
+	global:
+
+	rte_pmd_dpaa2_set_timestamp;
+} DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 09/19] bus/fslmc: upgrade to latest qbman library
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (7 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 08/19] net/dpaa2: enable optional timestamp in mbuf Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 10/19] bus/fslmc: add dynamic config for memback portal mode Shreyansh Jain
                       ` (11 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, Youri Querry, Nipun Gupta

From: Hemant Agrawal <hemant.agrawal@nxp.com>

This patch upgrades and sync the dpdk based qbman code
with new version of qbman flib.

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c |  8 ++++----
 drivers/bus/fslmc/qbman/qbman_sys.h    | 17 +++++++++++------
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index bbea37efc..2f572a08b 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -201,7 +201,7 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	p->vdq.valid_bit = QB_VALID_BIT;
 	p->dqrr.valid_bit = QB_VALID_BIT;
 	qman_version = p->desc.qman_version;
-	if ((qman_version & 0xFFFF0000) < QMAN_REV_4100) {
+	if ((qman_version & QMAN_REV_MASK) < QMAN_REV_4100) {
 		p->dqrr.dqrr_size = 4;
 		p->dqrr.reset_bug = 1;
 	} else {
@@ -1315,9 +1315,9 @@ const struct qbman_result *qbman_swp_dqrr_next_mem_back(struct qbman_swp *s)
 	 */
 	flags = p->dq.stat;
 	response_verb = verb & QBMAN_RESPONSE_VERB_MASK;
-	if ((response_verb == QBMAN_RESULT_DQ) &&
-	    (flags & QBMAN_DQ_STAT_VOLATILE) &&
-	    (flags & QBMAN_DQ_STAT_EXPIRED))
+	if ((response_verb == QBMAN_RESULT_DQ)
+			&& (flags & QBMAN_DQ_STAT_VOLATILE)
+			&& (flags & QBMAN_DQ_STAT_EXPIRED))
 		atomic_inc(&s->vdq.busy);
 	return p;
 }
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index 0571097ab..e3bd1c5e6 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -387,6 +387,10 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 {
 	uint32_t reg;
 	int i;
+	int cena_region_size = 4*1024;
+
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+		cena_region_size = 64*1024;
 #ifdef RTE_ARCH_64
 	uint8_t wn = CENA_WRITE_ENABLE;
 #else
@@ -396,7 +400,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	s->addr_cena = d->cena_bar;
 	s->addr_cinh = d->cinh_bar;
 	s->idx = (uint32_t)d->idx;
-	s->cena = malloc(64*1024);
+	s->cena = malloc(cena_region_size);
+
 	if (!s->cena) {
 		pr_err("Could not allocate page for cena shadow\n");
 		return -1;
@@ -412,12 +417,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	QBMAN_BUG_ON(reg);
 #endif
 	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
-		memset(s->addr_cena, 0, 64*1024);
+		memset(s->addr_cena, 0, cena_region_size);
 	else {
 		/* Invalidate the portal memory.
 		 * This ensures no stale cache lines
 		 */
-		for (i = 0; i < 0x1000; i += 64)
+		for (i = 0; i < cena_region_size; i += 64)
 			dccivac(s->addr_cena + i);
 	}
 
@@ -425,12 +430,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 		reg = qbman_set_swp_cfg(dqrr_size, wn,
 					0, 3, 2, 3, 1, 1, 1, 1, 1, 1);
 	else {
-		if ((d->qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
+		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
-						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
+						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
 		else
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
-						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
+						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
 	}
 
 	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 10/19] bus/fslmc: add dynamic config for memback portal mode
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (8 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 09/19] bus/fslmc: upgrade to latest qbman library Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 11/19] bus/fslmc: rename portal pi index to consumer index Shreyansh Jain
                       ` (10 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, Roy Pledge, Youri Querry

From: Hemant Agrawal <hemant.agrawal@nxp.com>

Add flag in portal init to adjust the qbman memory type,
to decide between legacy portal mode or newly introduced
memory backed portals.

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c      |  2 +
 .../bus/fslmc/qbman/include/fsl_qbman_base.h  | 11 +++-
 drivers/bus/fslmc/qbman/qbman_portal.c        | 52 +++++++++++--------
 drivers/bus/fslmc/qbman/qbman_sys.h           | 20 ++++---
 4 files changed, 53 insertions(+), 32 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index ba2e28ce1..37723a094 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -509,6 +509,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 	p_des.cinh_bar = (void *)(dpio_dev->qbman_portal_ci_paddr);
 	p_des.irq = -1;
 	p_des.qman_version = attr.qbman_version;
+	p_des.eqcr_mode = qman_eqcr_vb_ring;
+	p_des.cena_access_mode = qman_cena_fastest_access;
 
 	dpio_dev->sw_portal = qbman_swp_init(&p_des);
 	if (dpio_dev->sw_portal == NULL) {
diff --git a/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h b/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
index bb60a98f9..48bdaafa4 100644
--- a/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
+++ b/drivers/bus/fslmc/qbman/include/fsl_qbman_base.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  * Copyright (C) 2014 Freescale Semiconductor, Inc.
+ * Copyright 2017-2018 NXP
  *
  */
 #ifndef _FSL_QBMAN_BASE_H
@@ -33,7 +34,12 @@ struct qbman_block_desc {
 
 enum qbman_eqcr_mode {
 	qman_eqcr_vb_ring = 2, /* Valid bit, with eqcr in ring mode */
-	qman_eqcr_vb_array, /* Valid bit, with eqcr in array mode */
+	qman_eqcr_vb_array,    /* Valid bit, with eqcr in array mode */
+};
+
+enum qbman_cena_access_mode {
+	qman_cena_fastest_access = 0, /* Use memory backed node if available */
+	qman_cena_direct_access,      /* Use direct access to the CENA region */
 };
 
 /**
@@ -46,6 +52,8 @@ enum qbman_eqcr_mode {
  * @qman_version: the qman version.
  * @eqcr_mode: Select the eqcr mode, currently only valid bit ring mode and
  * valid bit array mode are supported.
+ * @cena_access_mode: Mode used to access the CENA region, direct
+ *                    or memory backed.
  *
  * Descriptor for a QBMan software portal, expressed in terms that make sense to
  * the user context. Ie. on MC, this information is likely to be true-physical,
@@ -62,6 +70,7 @@ struct qbman_swp_desc {
 	int idx;
 	uint32_t qman_version;
 	enum qbman_eqcr_mode eqcr_mode;
+	enum qbman_cena_access_mode cena_access_mode;
 };
 
 /* Driver object for managing a QBMan portal */
diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 2f572a08b..08bfdc9f8 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -194,7 +194,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	p->sdq |= qbman_sdqcr_dct_prio_ics << QB_SDQCR_DCT_SHIFT;
 	p->sdq |= qbman_sdqcr_fc_up_to_3 << QB_SDQCR_FC_SHIFT;
 	p->sdq |= QMAN_SDQCR_TOKEN << QB_SDQCR_TOK_SHIFT;
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		p->mr.valid_bit = QB_VALID_BIT;
 
 	atomic_set(&p->vdq.busy, 1);
@@ -233,7 +234,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_SDQCR, 0);
 
 	p->eqcr.pi_ring_size = 8;
-	if ((qman_version & 0xFFFF0000) >= QMAN_REV_5000) {
+	if ((qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access)) {
 		p->eqcr.pi_ring_size = 32;
 		qbman_swp_enqueue_array_mode_ptr =
 				qbman_swp_enqueue_array_mode_mem_back;
@@ -253,7 +255,8 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	eqcr_pi = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI);
 	p->eqcr.pi = eqcr_pi & p->eqcr.pi_mask;
 	p->eqcr.pi_vb = eqcr_pi & QB_VALID_BIT;
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		p->eqcr.ci = qbman_cinh_read(&p->sys,
 				QBMAN_CINH_SWP_EQCR_CI) & p->eqcr.pi_mask;
 	else
@@ -362,10 +365,11 @@ void *qbman_swp_mc_start(struct qbman_swp *p)
 #ifdef QBMAN_CHECKING
 	QBMAN_BUG_ON(p->mc.check != swp_mc_can_start);
 #endif
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000)
-		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR);
-	else
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		    && (p->desc.cena_access_mode == qman_cena_fastest_access))
 		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR_MEM);
+	else
+		ret = qbman_cena_write_start(&p->sys, QBMAN_CENA_SWP_CR);
 #ifdef QBMAN_CHECKING
 	if (!ret)
 		p->mc.check = swp_mc_can_submit;
@@ -385,16 +389,17 @@ void qbman_swp_mc_submit(struct qbman_swp *p, void *cmd, uint8_t cmd_verb)
 	 * caller wants to OR but has forgotten to do so.
 	 */
 	QBMAN_BUG_ON((*v & cmd_verb) != *v);
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000) {
-		dma_wmb();
-		*v = cmd_verb | p->mc.valid_bit;
-		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR, cmd);
-		clean(cmd);
-	} else {
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		    && (p->desc.cena_access_mode == qman_cena_fastest_access)) {
 		*v = cmd_verb | p->mr.valid_bit;
 		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR_MEM, cmd);
 		dma_wmb();
 		qbman_cinh_write(&p->sys, QBMAN_CINH_SWP_CR_RT, QMAN_RT_MODE);
+	} else {
+		dma_wmb();
+		*v = cmd_verb | p->mc.valid_bit;
+		qbman_cena_write_complete(&p->sys, QBMAN_CENA_SWP_CR, cmd);
+		clean(cmd);
 	}
 #ifdef QBMAN_CHECKING
 	p->mc.check = swp_mc_can_poll;
@@ -407,30 +412,31 @@ void *qbman_swp_mc_result(struct qbman_swp *p)
 #ifdef QBMAN_CHECKING
 	QBMAN_BUG_ON(p->mc.check != swp_mc_can_poll);
 #endif
-	if ((p->desc.qman_version & QMAN_REV_MASK) < QMAN_REV_5000) {
-		qbman_cena_invalidate_prefetch(&p->sys,
-				QBMAN_CENA_SWP_RR(p->mc.valid_bit));
-		ret = qbman_cena_read(&p->sys,
-				QBMAN_CENA_SWP_RR(p->mc.valid_bit));
+	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+		&& (p->desc.cena_access_mode == qman_cena_fastest_access)) {
+		ret = qbman_cena_read(&p->sys, QBMAN_CENA_SWP_RR_MEM);
+		/* Command completed if the valid bit is toggled */
+		if (p->mr.valid_bit != (ret[0] & QB_VALID_BIT))
+			return NULL;
 		/* Remove the valid-bit -
 		 * command completed iff the rest is non-zero
 		 */
 		verb = ret[0] & ~QB_VALID_BIT;
 		if (!verb)
 			return NULL;
-		p->mc.valid_bit ^= QB_VALID_BIT;
+		p->mr.valid_bit ^= QB_VALID_BIT;
 	} else {
-		ret = qbman_cena_read(&p->sys, QBMAN_CENA_SWP_RR_MEM);
-		/* Command completed if the valid bit is toggled */
-		if (p->mr.valid_bit != (ret[0] & QB_VALID_BIT))
-			return NULL;
+		qbman_cena_invalidate_prefetch(&p->sys,
+			QBMAN_CENA_SWP_RR(p->mc.valid_bit));
+		ret = qbman_cena_read(&p->sys,
+				      QBMAN_CENA_SWP_RR(p->mc.valid_bit));
 		/* Remove the valid-bit -
 		 * command completed iff the rest is non-zero
 		 */
 		verb = ret[0] & ~QB_VALID_BIT;
 		if (!verb)
 			return NULL;
-		p->mr.valid_bit ^= QB_VALID_BIT;
+		p->mc.valid_bit ^= QB_VALID_BIT;
 	}
 #ifdef QBMAN_CHECKING
 	p->mc.check = swp_mc_can_start;
diff --git a/drivers/bus/fslmc/qbman/qbman_sys.h b/drivers/bus/fslmc/qbman/qbman_sys.h
index e3bd1c5e6..71f7a6782 100644
--- a/drivers/bus/fslmc/qbman/qbman_sys.h
+++ b/drivers/bus/fslmc/qbman/qbman_sys.h
@@ -389,7 +389,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	int i;
 	int cena_region_size = 4*1024;
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		cena_region_size = 64*1024;
 #ifdef RTE_ARCH_64
 	uint8_t wn = CENA_WRITE_ENABLE;
@@ -416,7 +417,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 	reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
 	QBMAN_BUG_ON(reg);
 #endif
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		memset(s->addr_cena, 0, cena_region_size);
 	else {
 		/* Invalidate the portal memory.
@@ -426,11 +428,12 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 			dccivac(s->addr_cena + i);
 	}
 
-	if (s->eqcr_mode == qman_eqcr_vb_array)
+	if (s->eqcr_mode == qman_eqcr_vb_array) {
 		reg = qbman_set_swp_cfg(dqrr_size, wn,
 					0, 3, 2, 3, 1, 1, 1, 1, 1, 1);
-	else {
-		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000)
+	} else {
+		if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000 &&
+			    (d->cena_access_mode == qman_cena_fastest_access))
 			reg = qbman_set_swp_cfg(dqrr_size, wn,
 						1, 3, 2, 0, 1, 1, 1, 1, 1, 1);
 		else
@@ -438,11 +441,11 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 						1, 3, 2, 2, 1, 1, 1, 1, 1, 1);
 	}
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access))
 		reg |= 1 << SWP_CFG_CPBS_SHIFT | /* memory-backed mode */
 		       1 << SWP_CFG_VPM_SHIFT |  /* VDQCR read triggered mode */
 		       1 << SWP_CFG_CPM_SHIFT;   /* CR read triggered mode */
-	}
 
 	qbman_cinh_write(s, QBMAN_CINH_SWP_CFG, reg);
 	reg = qbman_cinh_read(s, QBMAN_CINH_SWP_CFG);
@@ -452,7 +455,8 @@ static inline int qbman_swp_sys_init(struct qbman_swp_sys *s,
 		return -1;
 	}
 
-	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000) {
+	if ((d->qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
+			&& (d->cena_access_mode == qman_cena_fastest_access)) {
 		qbman_cinh_write(s, QBMAN_CINH_SWP_EQCR_PI, QMAN_RT_MODE);
 		qbman_cinh_write(s, QBMAN_CINH_SWP_RCR_PI, QMAN_RT_MODE);
 	}
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 11/19] bus/fslmc: rename portal pi index to consumer index
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (9 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 10/19] bus/fslmc: add dynamic config for memback portal mode Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 12/19] bus/fslmc: make portal func static Shreyansh Jain
                       ` (9 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal, Youri Querry

From: Hemant Agrawal <hemant.agrawal@nxp.com>

This is to align with the latest qbman hw library

Signed-off-by: Youri Querry <youri.querry_1@nxp.com>
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/qbman/qbman_portal.c | 51 +++++++++++---------------
 drivers/bus/fslmc/qbman/qbman_portal.h |  2 +-
 2 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/drivers/bus/fslmc/qbman/qbman_portal.c b/drivers/bus/fslmc/qbman/qbman_portal.c
index 08bfdc9f8..14f4b0344 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.c
+++ b/drivers/bus/fslmc/qbman/qbman_portal.c
@@ -251,21 +251,21 @@ struct qbman_swp *qbman_swp_init(const struct qbman_swp_desc *d)
 	}
 
 	for (mask_size = p->eqcr.pi_ring_size; mask_size > 0; mask_size >>= 1)
-		p->eqcr.pi_mask = (p->eqcr.pi_mask<<1) + 1;
+		p->eqcr.pi_ci_mask = (p->eqcr.pi_ci_mask<<1) + 1;
 	eqcr_pi = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI);
-	p->eqcr.pi = eqcr_pi & p->eqcr.pi_mask;
+	p->eqcr.pi = eqcr_pi & p->eqcr.pi_ci_mask;
 	p->eqcr.pi_vb = eqcr_pi & QB_VALID_BIT;
 	if ((p->desc.qman_version & QMAN_REV_MASK) >= QMAN_REV_5000
 			&& (d->cena_access_mode == qman_cena_fastest_access))
-		p->eqcr.ci = qbman_cinh_read(&p->sys,
-				QBMAN_CINH_SWP_EQCR_CI) & p->eqcr.pi_mask;
+		p->eqcr.ci = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_PI)
+					     & p->eqcr.pi_ci_mask;
 	else
-		p->eqcr.ci = qbman_cinh_read(&p->sys,
-				QBMAN_CINH_SWP_EQCR_PI) & p->eqcr.pi_mask;
+		p->eqcr.ci = qbman_cinh_read(&p->sys, QBMAN_CINH_SWP_EQCR_CI)
+					     & p->eqcr.pi_ci_mask;
 	p->eqcr.available = p->eqcr.pi_ring_size -
 				qm_cyc_diff(p->eqcr.pi_ring_size,
-				p->eqcr.ci & (p->eqcr.pi_mask<<1),
-				p->eqcr.pi & (p->eqcr.pi_mask<<1));
+				p->eqcr.ci & (p->eqcr.pi_ci_mask<<1),
+				p->eqcr.pi & (p->eqcr.pi_ci_mask<<1));
 
 	portal_idx_map[p->desc.idx] = p;
 	return p;
@@ -646,8 +646,8 @@ static int qbman_swp_enqueue_ring_mode_direct(struct qbman_swp *s,
 	const uint32_t *cl = qb_cl(d);
 	uint32_t eqcr_ci, full_mask, half_mask;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -685,8 +685,8 @@ static int qbman_swp_enqueue_ring_mode_mem_back(struct qbman_swp *s,
 	const uint32_t *cl = qb_cl(d);
 	uint32_t eqcr_ci, full_mask, half_mask;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -743,8 +743,8 @@ static int qbman_swp_enqueue_multiple_direct(struct qbman_swp *s,
 	int i, num_enqueued = 0;
 	uint64_t addr_cena;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -811,8 +811,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 	uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask;
 	int i, num_enqueued = 0;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -833,15 +833,6 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 				QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask));
 		memcpy(&p[1], &cl[1], 28);
 		memcpy(&p[8], &fd[i], sizeof(*fd));
-		eqcr_pi++;
-	}
-
-	/* Set the verb byte, have to substitute in the valid-bit */
-	eqcr_pi = s->eqcr.pi;
-	for (i = 0; i < num_enqueued; i++) {
-		p = qbman_cena_write_start_wo_shadow(&s->sys,
-				QBMAN_CENA_SWP_EQCR(eqcr_pi & half_mask));
-		p[0] = cl[0] | s->eqcr.pi_vb;
 		if (flags && (flags[i] & QBMAN_ENQUEUE_FLAG_DCA)) {
 			struct qbman_eq_desc *d = (struct qbman_eq_desc *)p;
 
@@ -849,6 +840,8 @@ static int qbman_swp_enqueue_multiple_mem_back(struct qbman_swp *s,
 				((flags[i]) & QBMAN_EQCR_DCA_IDXMASK);
 		}
 		eqcr_pi++;
+		p[0] = cl[0] | s->eqcr.pi_vb;
+
 		if (!(eqcr_pi & half_mask))
 			s->eqcr.pi_vb ^= QB_VALID_BIT;
 	}
@@ -880,8 +873,8 @@ static int qbman_swp_enqueue_multiple_desc_direct(struct qbman_swp *s,
 	int i, num_enqueued = 0;
 	uint64_t addr_cena;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
@@ -943,8 +936,8 @@ static int qbman_swp_enqueue_multiple_desc_mem_back(struct qbman_swp *s,
 	uint32_t eqcr_ci, eqcr_pi, half_mask, full_mask;
 	int i, num_enqueued = 0;
 
-	half_mask = (s->eqcr.pi_mask>>1);
-	full_mask = s->eqcr.pi_mask;
+	half_mask = (s->eqcr.pi_ci_mask>>1);
+	full_mask = s->eqcr.pi_ci_mask;
 	if (!s->eqcr.available) {
 		eqcr_ci = s->eqcr.ci;
 		s->eqcr.ci = qbman_cena_read_reg(&s->sys,
diff --git a/drivers/bus/fslmc/qbman/qbman_portal.h b/drivers/bus/fslmc/qbman/qbman_portal.h
index 3b0fc540b..e54f2661c 100644
--- a/drivers/bus/fslmc/qbman/qbman_portal.h
+++ b/drivers/bus/fslmc/qbman/qbman_portal.h
@@ -98,7 +98,7 @@ struct qbman_swp {
 		uint32_t pi;
 		uint32_t pi_vb;
 		uint32_t pi_ring_size;
-		uint32_t pi_mask;
+		uint32_t pi_ci_mask;
 		uint32_t ci;
 		int available;
 	} eqcr;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 12/19] bus/fslmc: make portal func static
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (10 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 11/19] bus/fslmc: rename portal pi index to consumer index Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 13/19] net/dpaa2: add dpdmux mc flib Shreyansh Jain
                       ` (8 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Hemant Agrawal

From: Hemant Agrawal <hemant.agrawal@nxp.com>

Change QBMAN portal function to static as it is not exposed outside
this file context.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 2 +-
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.h | 2 --
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index 37723a094..cd28441f3 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -229,7 +229,7 @@ dpaa2_configure_stashing(struct dpaa2_dpio_dev *dpio_dev, int lcoreid)
 	return 0;
 }
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
+static struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int lcoreid)
 {
 	struct dpaa2_dpio_dev *dpio_dev = NULL;
 	int ret;
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
index 462501a2e..4354c76de 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.h
@@ -37,8 +37,6 @@ extern uint8_t dpaa2_eqcr_size;
 
 extern struct dpaa2_io_portal_t dpaa2_io_portal[RTE_MAX_LCORE];
 
-struct dpaa2_dpio_dev *dpaa2_get_qbman_swp(int cpu_id);
-
 /* Affine a DPIO portal to current processing thread */
 int dpaa2_affine_qbman_swp(void);
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 13/19] net/dpaa2: add dpdmux mc flib
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (11 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 12/19] bus/fslmc: make portal func static Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 14/19] bus/fslmc: add support for scanning DPDMUX object Shreyansh Jain
                       ` (7 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

dpdmux object is added as a part of net driver as it is used to
de-multiplex packets to separate interfaces on basis of specific rules.
These rules can be configured from the software

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/Makefile            |   1 +
 drivers/net/dpaa2/mc/dpdmux.c         | 929 ++++++++++++++++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux.h     | 410 ++++++++++++
 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h | 221 ++++++
 drivers/net/dpaa2/meson.build         |   1 +
 5 files changed, 1562 insertions(+)
 create mode 100644 drivers/net/dpaa2/mc/dpdmux.c
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux.h
 create mode 100644 drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h

diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index 2b9c011d6..c58a39725 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -35,6 +35,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpkg.c
+SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpdmux.c
 
 LDLIBS += -lrte_bus_fslmc
 LDLIBS += -lrte_mempool_dpaa2
diff --git a/drivers/net/dpaa2/mc/dpdmux.c b/drivers/net/dpaa2/mc/dpdmux.c
new file mode 100644
index 000000000..7962213b7
--- /dev/null
+++ b/drivers/net/dpaa2/mc/dpdmux.c
@@ -0,0 +1,929 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#include <fsl_mc_sys.h>
+#include <fsl_mc_cmd.h>
+#include <fsl_dpdmux.h>
+#include <fsl_dpdmux_cmd.h>
+
+/** @addtogroup dpdmux
+ * @{
+ */
+
+/**
+ * dpdmux_open() - Open a control session for the specified object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @dpdmux_id:		DPDMUX unique ID
+ * @token:		Returned token; use in subsequent API calls
+ *
+ * This function can be used to open a control session for an
+ * already created object; an object may have been declared in
+ * the DPL or by calling the dpdmux_create() function.
+ * This function returns a unique authentication token,
+ * associated with the specific object ID and the specific MC
+ * portal; this token must be used in all subsequent commands for
+ * this specific object.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_open(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		int dpdmux_id,
+		uint16_t *token)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_open *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_OPEN,
+					  cmd_flags,
+					  0);
+	cmd_params = (struct dpdmux_cmd_open *)cmd.params;
+	cmd_params->dpdmux_id = cpu_to_le32(dpdmux_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*token = mc_cmd_hdr_read_token(&cmd);
+
+	return 0;
+}
+
+/**
+ * dpdmux_close() - Close the control session of the object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPDMUX object
+ *
+ * After this function is called, no further operations are
+ * allowed on the object without opening a new control session.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_close(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CLOSE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_create() - Create the DPDMUX object
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @dprc_token:	Parent container token; '0' for default container
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @cfg:	Configuration structure
+ * @obj_id: returned object id
+ *
+ * Create the DPDMUX object, allocate required resources and
+ * perform required initialization.
+ *
+ * The object can be created either by declaring it in the
+ * DPL file, or by calling this function.
+ *
+ * The function accepts an authentication token of a parent
+ * container that this object should be assigned to. The token
+ * can be '0' so the object will be assigned to the default container.
+ * The newly created object can be opened with the returned
+ * object id and using the container's associated tokens and MC portals.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_create(struct fsl_mc_io *mc_io,
+		  uint16_t dprc_token,
+		  uint32_t cmd_flags,
+		  const struct dpdmux_cfg	*cfg,
+		  uint32_t *obj_id)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_create *cmd_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_CREATE,
+					  cmd_flags,
+					  dprc_token);
+	cmd_params = (struct dpdmux_cmd_create *)cmd.params;
+	cmd_params->method = cfg->method;
+	cmd_params->manip = cfg->manip;
+	cmd_params->num_ifs = cpu_to_le16(cfg->num_ifs);
+	cmd_params->adv_max_dmat_entries =
+			cpu_to_le16(cfg->adv.max_dmat_entries);
+	cmd_params->adv_max_mc_groups = cpu_to_le16(cfg->adv.max_mc_groups);
+	cmd_params->adv_max_vlan_ids = cpu_to_le16(cfg->adv.max_vlan_ids);
+	cmd_params->options = cpu_to_le64(cfg->adv.options);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	*obj_id = mc_cmd_read_object_id(&cmd);
+
+	return 0;
+}
+
+/**
+ * dpdmux_destroy() - Destroy the DPDMUX object and release all its resources.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @dprc_token: Parent container token; '0' for default container
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @object_id:	The object id; it must be a valid id within the container that
+ * created this object;
+ *
+ * The function accepts the authentication token of the parent container that
+ * created the object (not the one that currently owns the object). The object
+ * is searched within parent using the provided 'object_id'.
+ * All tokens to the object must be closed before calling destroy.
+ *
+ * Return:	'0' on Success; error code otherwise.
+ */
+int dpdmux_destroy(struct fsl_mc_io *mc_io,
+		   uint16_t dprc_token,
+		   uint32_t cmd_flags,
+		   uint32_t object_id)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_destroy *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_DESTROY,
+					  cmd_flags,
+					  dprc_token);
+	cmd_params = (struct dpdmux_cmd_destroy *)cmd.params;
+	cmd_params->dpdmux_id = cpu_to_le32(object_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_enable() - Enable DPDMUX functionality
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_enable(struct fsl_mc_io *mc_io,
+		  uint32_t cmd_flags,
+		  uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_ENABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_disable() - Disable DPDMUX functionality
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_disable(struct fsl_mc_io *mc_io,
+		   uint32_t cmd_flags,
+		   uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_DISABLE,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_is_enabled() - Check if the DPDMUX is enabled.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @en:		Returns '1' if object is enabled; '0' otherwise
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      int *en)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_is_enabled *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IS_ENABLED,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_is_enabled *)cmd.params;
+	*en = dpdmux_get_field(rsp_params->en, ENABLE);
+
+	return 0;
+}
+
+/**
+ * dpdmux_reset() - Reset the DPDMUX, returns the object to initial state.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_reset(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_RESET,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_get_attributes() - Retrieve DPDMUX attributes
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @attr:	Returned object's attributes
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  struct dpdmux_attr *attr)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_get_attr *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_ATTR,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_get_attr *)cmd.params;
+	attr->id = le32_to_cpu(rsp_params->id);
+	attr->options = le64_to_cpu(rsp_params->options);
+	attr->method = rsp_params->method;
+	attr->manip = rsp_params->manip;
+	attr->num_ifs = le16_to_cpu(rsp_params->num_ifs);
+	attr->mem_size = le16_to_cpu(rsp_params->mem_size);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_enable() - Enable Interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface Identifier
+ *
+ * Return:	Completion status. '0' on Success; Error code otherwise.
+ */
+int dpdmux_if_enable(struct fsl_mc_io *mc_io,
+		     uint32_t cmd_flags,
+		     uint16_t token,
+		     uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_ENABLE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_disable() - Disable Interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface Identifier
+ *
+ * Return:	Completion status. '0' on Success; Error code otherwise.
+ */
+int dpdmux_if_disable(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_DISABLE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_set_max_frame_length() - Set the maximum frame length in DPDMUX
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPDMUX object
+ * @max_frame_length:	The required maximum frame length
+ *
+ * Update the maximum frame length on all DMUX interfaces.
+ * In case of VEPA, the maximum frame length on all dmux interfaces
+ * will be updated with the minimum value of the mfls of the connected
+ * dpnis and the actual value of dmux mfl.
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
+				uint32_t cmd_flags,
+				uint16_t token,
+				uint16_t max_frame_length)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_set_max_frame_length *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_MAX_FRAME_LENGTH,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_set_max_frame_length *)cmd.params;
+	cmd_params->max_frame_length = cpu_to_le16(max_frame_length);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_ul_reset_counters() - Function resets the uplink counter
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token)
+{
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_UL_RESET_COUNTERS,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_set_accepted_frames() - Set the accepted frame types
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface ID (0 for uplink, or 1-num_ifs);
+ * @cfg:	Frame types configuration
+ *
+ * if 'DPDMUX_ADMIT_ONLY_VLAN_TAGGED' is set - untagged frames or
+ * priority-tagged frames are discarded.
+ * if 'DPDMUX_ADMIT_ONLY_UNTAGGED' is set - untagged frames or
+ * priority-tagged frames are accepted.
+ * if 'DPDMUX_ADMIT_ALL' is set (default mode) - all VLAN tagged,
+ * untagged and priority-tagged frame are accepted;
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint16_t if_id,
+				  const struct dpdmux_accepted_frames *cfg)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_set_accepted_frames *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_ACCEPTED_FRAMES,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_set_accepted_frames *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	dpdmux_set_field(cmd_params->frames_options,
+			 ACCEPTED_FRAMES_TYPE,
+			 cfg->type);
+	dpdmux_set_field(cmd_params->frames_options,
+			 UNACCEPTED_FRAMES_ACTION,
+			 cfg->unaccept_act);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_attributes() - Obtain DPDMUX interface attributes
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Interface ID (0 for uplink, or 1-num_ifs);
+ * @attr:	Interface attributes
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_if_attr *attr)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if *cmd_params;
+	struct dpdmux_rsp_if_get_attr *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_ATTR,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_attr *)cmd.params;
+	attr->rate = le32_to_cpu(rsp_params->rate);
+	attr->enabled = dpdmux_get_field(rsp_params->enabled, ENABLE);
+	attr->is_default = dpdmux_get_field(rsp_params->enabled, IS_DEFAULT);
+	attr->accept_frame_type = dpdmux_get_field(
+				  rsp_params->accepted_frames_type,
+				  ACCEPTED_FRAMES_TYPE);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_remove_l2_rule() - Remove L2 rule from DPDMUX table
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Destination interface ID
+ * @rule:	L2 rule
+ *
+ * Function removes a L2 rule from DPDMUX table
+ * or adds an interface to an existing multicast address
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     const struct dpdmux_l2_rule *rule)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_l2_rule *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_REMOVE_L2_RULE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_l2_rule *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->vlan_id = cpu_to_le16(rule->vlan_id);
+	cmd_params->mac_addr5 = rule->mac_addr[5];
+	cmd_params->mac_addr4 = rule->mac_addr[4];
+	cmd_params->mac_addr3 = rule->mac_addr[3];
+	cmd_params->mac_addr2 = rule->mac_addr[2];
+	cmd_params->mac_addr1 = rule->mac_addr[1];
+	cmd_params->mac_addr0 = rule->mac_addr[0];
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_add_l2_rule() - Add L2 rule into DPDMUX table
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:	Token of DPDMUX object
+ * @if_id:	Destination interface ID
+ * @rule:	L2 rule
+ *
+ * Function adds a L2 rule into DPDMUX table
+ * or adds an interface to an existing multicast address
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  const struct dpdmux_l2_rule *rule)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_l2_rule *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_ADD_L2_RULE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_l2_rule *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->vlan_id = cpu_to_le16(rule->vlan_id);
+	cmd_params->mac_addr5 = rule->mac_addr[5];
+	cmd_params->mac_addr4 = rule->mac_addr[4];
+	cmd_params->mac_addr3 = rule->mac_addr[3];
+	cmd_params->mac_addr2 = rule->mac_addr[2];
+	cmd_params->mac_addr1 = rule->mac_addr[1];
+	cmd_params->mac_addr0 = rule->mac_addr[0];
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_counter() - Functions obtains specific counter of an interface
+ * @mc_io: Pointer to MC portal's I/O object
+ * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPDMUX object
+ * @if_id:  Interface Id
+ * @counter_type: counter type
+ * @counter: Returned specific counter information
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  enum dpdmux_counter_type counter_type,
+			  uint64_t *counter)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_get_counter *cmd_params;
+	struct dpdmux_rsp_if_get_counter *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_COUNTER,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_get_counter *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->counter_type = counter_type;
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_counter *)cmd.params;
+	*counter = le64_to_cpu(rsp_params->counter);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_set_link_cfg() - set the link configuration.
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ * @cfg: Link configuration
+ *
+ * Return:	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t token,
+			   uint16_t if_id,
+			   struct dpdmux_link_cfg *cfg)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_set_link_cfg *cmd_params;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_LINK_CFG,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_set_link_cfg *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+	cmd_params->rate = cpu_to_le32(cfg->rate);
+	cmd_params->options = cpu_to_le64(cfg->options);
+	cmd_params->advertising = cpu_to_le64(cfg->advertising);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_link_state - Return the link state
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ * @state: link state
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_link_state *state)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_cmd_if_get_link_state *cmd_params;
+	struct dpdmux_rsp_if_get_link_state *rsp_params;
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_LINK_STATE,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if_get_link_state *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_rsp_if_get_link_state *)cmd.params;
+	state->rate = le32_to_cpu(rsp_params->rate);
+	state->options = le64_to_cpu(rsp_params->options);
+	state->up = dpdmux_get_field(rsp_params->up, UP);
+	state->state_valid = dpdmux_get_field(rsp_params->up, STATE_VALID);
+	state->supported = le64_to_cpu(rsp_params->supported);
+	state->advertising = le64_to_cpu(rsp_params->advertising);
+
+	return 0;
+}
+
+/**
+ * dpdmux_if_set_default - Set default interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t if_id)
+{
+	struct dpdmux_cmd_if *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_SET_DEFAULT,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_if *)cmd.params;
+	cmd_params->if_id = cpu_to_le16(if_id);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_if_get_default - Get default interface
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @if_id: interface id
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t *if_id)
+{
+	struct dpdmux_cmd_if *rsp_params;
+	struct mc_command cmd = { 0 };
+	int err;
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_IF_GET_DEFAULT,
+					  cmd_flags,
+					  token);
+
+	/* send command to mc*/
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	/* retrieve response parameters */
+	rsp_params = (struct dpdmux_cmd_if *)cmd.params;
+	*if_id = le16_to_cpu(rsp_params->if_id);
+
+	return 0;
+}
+
+/**
+ * dpdmux_set_custom_key - Set a custom classification key.
+ *
+ * This API is only available for DPDMUX instance created with
+ * DPDMUX_METHOD_CUSTOM.  This API must be called before populating the
+ * classification table using dpdmux_add_custom_cls_entry.
+ *
+ * Calls to dpdmux_set_custom_key remove all existing classification entries
+ * that may have been added previously using dpdmux_add_custom_cls_entry.
+ *
+ * @mc_io:		Pointer to MC portal's I/O object
+ * @cmd_flags:		Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token:		Token of DPSW object
+ * @if_id:		Interface id
+ * @key_cfg_iova:	DMA address of a configuration structure set up using
+ *			dpkg_prepare_key_cfg. Maximum key size is 24 bytes
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
+			uint32_t cmd_flags,
+			uint16_t token,
+			uint64_t key_cfg_iova)
+{
+	struct dpdmux_set_custom_key *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_SET_CUSTOM_KEY,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_set_custom_key *)cmd.params;
+	cmd_params->key_cfg_iova = cpu_to_le64(key_cfg_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_add_custom_cls_entry - Adds a custom classification entry.
+ *
+ * This API is only available for DPDMUX instances created with
+ * DPDMUX_METHOD_CUSTOM.  Before calling this function a classification key
+ * composition rule must be set up using dpdmux_set_custom_key.
+ *
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @rule: Classification rule to insert.  Rules cannot be duplicated, if a
+ *	matching rule already exists, the action will be replaced.
+ * @action: Action to perform for matching traffic.
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule,
+		struct dpdmux_cls_action *action)
+{
+	struct dpdmux_cmd_add_custom_cls_entry *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_ADD_CUSTOM_CLS_ENTRY,
+					  cmd_flags,
+					  token);
+
+	cmd_params = (struct dpdmux_cmd_add_custom_cls_entry *)cmd.params;
+	cmd_params->key_size = rule->key_size;
+	cmd_params->dest_if = cpu_to_le16(action->dest_if);
+	cmd_params->key_iova = cpu_to_le64(rule->key_iova);
+	cmd_params->mask_iova = cpu_to_le64(rule->mask_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_remove_custom_cls_entry - Removes a custom classification entry.
+ *
+ * This API is only available for DPDMUX instances created with
+ * DPDMUX_METHOD_CUSTOM.  The API can be used to remove classification
+ * entries previously inserted using dpdmux_add_custom_cls_entry.
+ *
+ * @mc_io:	Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @token: Token of DPSW object
+ * @rule: Classification rule to remove
+ *
+ * @returns	'0' on Success; Error code otherwise.
+ */
+int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule)
+{
+	struct dpdmux_cmd_remove_custom_cls_entry *cmd_params;
+	struct mc_command cmd = { 0 };
+
+	/* prepare command */
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_REMOVE_CUSTOM_CLS_ENTRY,
+					  cmd_flags,
+					  token);
+	cmd_params = (struct dpdmux_cmd_remove_custom_cls_entry *)cmd.params;
+	cmd_params->key_size = rule->key_size;
+	cmd_params->key_iova = cpu_to_le64(rule->key_iova);
+	cmd_params->mask_iova = cpu_to_le64(rule->mask_iova);
+
+	/* send command to mc*/
+	return mc_send_command(mc_io, &cmd);
+}
+
+/**
+ * dpdmux_get_api_version() - Get Data Path Demux API version
+ * @mc_io:  Pointer to MC portal's I/O object
+ * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
+ * @major_ver:	Major version of data path demux API
+ * @minor_ver:	Minor version of data path demux API
+ *
+ * Return:  '0' on Success; Error code otherwise.
+ */
+int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t *major_ver,
+			   uint16_t *minor_ver)
+{
+	struct mc_command cmd = { 0 };
+	struct dpdmux_rsp_get_api_version *rsp_params;
+	int err;
+
+	cmd.header = mc_encode_cmd_header(DPDMUX_CMDID_GET_API_VERSION,
+					cmd_flags,
+					0);
+
+	err = mc_send_command(mc_io, &cmd);
+	if (err)
+		return err;
+
+	rsp_params = (struct dpdmux_rsp_get_api_version *)cmd.params;
+	*major_ver = le16_to_cpu(rsp_params->major);
+	*minor_ver = le16_to_cpu(rsp_params->minor);
+
+	return 0;
+}
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux.h b/drivers/net/dpaa2/mc/fsl_dpdmux.h
new file mode 100644
index 000000000..c69cb7aab
--- /dev/null
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux.h
@@ -0,0 +1,410 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#ifndef __FSL_DPDMUX_H
+#define __FSL_DPDMUX_H
+
+#include <fsl_net.h>
+
+struct fsl_mc_io;
+
+/** @addtogroup dpdmux Data Path Demux API
+ * Contains API for handling DPDMUX topology and functionality
+ * @{
+ */
+
+int dpdmux_open(struct fsl_mc_io *mc_io,
+		uint32_t  cmd_flags,
+		int  dpdmux_id,
+		uint16_t  *token);
+
+int dpdmux_close(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token);
+
+/**
+ * DPDMUX general options
+ */
+
+/**
+ * Enable bridging between internal interfaces
+ */
+#define DPDMUX_OPT_BRIDGE_EN	0x0000000000000002ULL
+
+/**
+ * Mask support for classification
+ */
+#define DPDMUX_OPT_CLS_MASK_SUPPORT		0x0000000000000020ULL
+
+#define DPDMUX_IRQ_INDEX_IF	0x0000
+#define DPDMUX_IRQ_INDEX	0x0001
+
+/**
+ * IRQ event - Indicates that the link state changed
+ */
+#define DPDMUX_IRQ_EVENT_LINK_CHANGED	0x0001
+
+/**
+ * enum dpdmux_manip - DPDMUX manipulation operations
+ * @DPDMUX_MANIP_NONE:	No manipulation on frames
+ * @DPDMUX_MANIP_ADD_REMOVE_S_VLAN: Add S-VLAN on egress, remove it on ingress
+ */
+enum dpdmux_manip {
+	DPDMUX_MANIP_NONE = 0x0,
+	DPDMUX_MANIP_ADD_REMOVE_S_VLAN = 0x1
+};
+
+/**
+ * enum dpdmux_method - DPDMUX method options
+ * @DPDMUX_METHOD_NONE: no DPDMUX method
+ * @DPDMUX_METHOD_C_VLAN_MAC: DPDMUX based on C-VLAN and MAC address
+ * @DPDMUX_METHOD_MAC: DPDMUX based on MAC address
+ * @DPDMUX_METHOD_C_VLAN: DPDMUX based on C-VLAN
+ * @DPDMUX_METHOD_S_VLAN: DPDMUX based on S-VLAN
+ */
+enum dpdmux_method {
+	DPDMUX_METHOD_NONE = 0x0,
+	DPDMUX_METHOD_C_VLAN_MAC = 0x1,
+	DPDMUX_METHOD_MAC = 0x2,
+	DPDMUX_METHOD_C_VLAN = 0x3,
+	DPDMUX_METHOD_S_VLAN = 0x4,
+	DPDMUX_METHOD_CUSTOM = 0x5,
+};
+
+/**
+ * struct dpdmux_cfg - DPDMUX configuration parameters
+ * @method: Defines the operation method for the DPDMUX address table
+ * @manip: Required manipulation operation
+ * @num_ifs: Number of interfaces (excluding the uplink interface)
+ * @adv: Advanced parameters; default is all zeros;
+ *	use this structure to change default settings
+ * @adv.options: DPDMUX options - combination of 'DPDMUX_OPT_<X>' flags.
+ * @adv.max_dmat_entries: Maximum entries in DPDMUX address table
+ *	0 - indicates default: 64 entries per interface.
+ * @adv.max_mc_groups: Number of multicast groups in DPDMUX table
+ *	0 - indicates default: 32 multicast groups.
+ * @adv.max_vlan_ids: Maximum vlan ids allowed in the system -
+ *	relevant only case of working in mac+vlan method.
+ *	0 - indicates default 16 vlan ids.
+ */
+struct dpdmux_cfg {
+	enum dpdmux_method method;
+	enum dpdmux_manip manip;
+	uint16_t num_ifs;
+	struct {
+		uint64_t options;
+		uint16_t max_dmat_entries;
+		uint16_t max_mc_groups;
+		uint16_t max_vlan_ids;
+	} adv;
+};
+
+int dpdmux_create(struct fsl_mc_io *mc_io,
+		  uint16_t dprc_token,
+		  uint32_t cmd_flags,
+		  const struct dpdmux_cfg *cfg,
+		  uint32_t *obj_id);
+
+int dpdmux_destroy(struct fsl_mc_io *mc_io,
+		   uint16_t dprc_token,
+		   uint32_t cmd_flags,
+		   uint32_t object_id);
+
+int dpdmux_enable(struct fsl_mc_io *mc_io,
+		  uint32_t cmd_flags,
+		  uint16_t token);
+
+int dpdmux_disable(struct fsl_mc_io *mc_io,
+		   uint32_t cmd_flags,
+		   uint16_t token);
+
+int dpdmux_is_enabled(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      int *en);
+
+int dpdmux_reset(struct fsl_mc_io *mc_io,
+		 uint32_t cmd_flags,
+		 uint16_t token);
+
+/**
+ * struct dpdmux_attr - Structure representing DPDMUX attributes
+ * @id: DPDMUX object ID
+ * @options: Configuration options (bitmap)
+ * @method: DPDMUX address table method
+ * @manip: DPDMUX manipulation type
+ * @num_ifs: Number of interfaces (excluding the uplink interface)
+ * @mem_size: DPDMUX frame storage memory size
+ */
+struct dpdmux_attr {
+	int id;
+	uint64_t options;
+	enum dpdmux_method method;
+	enum dpdmux_manip manip;
+	uint16_t num_ifs;
+	uint16_t mem_size;
+};
+
+int dpdmux_get_attributes(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  struct dpdmux_attr *attr);
+
+int dpdmux_set_max_frame_length(struct fsl_mc_io *mc_io,
+				uint32_t cmd_flags,
+				uint16_t token,
+				uint16_t max_frame_length);
+
+/**
+ * enum dpdmux_counter_type - Counter types
+ * @DPDMUX_CNT_ING_FRAME: Counts ingress frames
+ * @DPDMUX_CNT_ING_BYTE: Counts ingress bytes
+ * @DPDMUX_CNT_ING_FLTR_FRAME: Counts filtered ingress frames
+ * @DPDMUX_CNT_ING_FRAME_DISCARD: Counts discarded ingress frames
+ * @DPDMUX_CNT_ING_MCAST_FRAME: Counts ingress multicast frames
+ * @DPDMUX_CNT_ING_MCAST_BYTE: Counts ingress multicast bytes
+ * @DPDMUX_CNT_ING_BCAST_FRAME: Counts ingress broadcast frames
+ * @DPDMUX_CNT_ING_BCAST_BYTES: Counts ingress broadcast bytes
+ * @DPDMUX_CNT_EGR_FRAME: Counts egress frames
+ * @DPDMUX_CNT_EGR_BYTE: Counts egress bytes
+ * @DPDMUX_CNT_EGR_FRAME_DISCARD: Counts discarded egress frames
+ */
+enum dpdmux_counter_type {
+	DPDMUX_CNT_ING_FRAME = 0x0,
+	DPDMUX_CNT_ING_BYTE = 0x1,
+	DPDMUX_CNT_ING_FLTR_FRAME = 0x2,
+	DPDMUX_CNT_ING_FRAME_DISCARD = 0x3,
+	DPDMUX_CNT_ING_MCAST_FRAME = 0x4,
+	DPDMUX_CNT_ING_MCAST_BYTE = 0x5,
+	DPDMUX_CNT_ING_BCAST_FRAME = 0x6,
+	DPDMUX_CNT_ING_BCAST_BYTES = 0x7,
+	DPDMUX_CNT_EGR_FRAME = 0x8,
+	DPDMUX_CNT_EGR_BYTE = 0x9,
+	DPDMUX_CNT_EGR_FRAME_DISCARD = 0xa
+};
+
+/**
+ * enum dpdmux_accepted_frames_type - DPDMUX frame types
+ * @DPDMUX_ADMIT_ALL: The device accepts VLAN tagged, untagged and
+ *			priority-tagged frames
+ * @DPDMUX_ADMIT_ONLY_VLAN_TAGGED: The device discards untagged frames or
+ *				priority-tagged frames that are received on this
+ *				interface
+ * @DPDMUX_ADMIT_ONLY_UNTAGGED: Untagged frames or priority-tagged frames
+ *				received on this interface are accepted
+ */
+enum dpdmux_accepted_frames_type {
+	DPDMUX_ADMIT_ALL = 0,
+	DPDMUX_ADMIT_ONLY_VLAN_TAGGED = 1,
+	DPDMUX_ADMIT_ONLY_UNTAGGED = 2
+};
+
+/**
+ * enum dpdmux_action - DPDMUX action for un-accepted frames
+ * @DPDMUX_ACTION_DROP: Drop un-accepted frames
+ * @DPDMUX_ACTION_REDIRECT_TO_CTRL: Redirect un-accepted frames to the
+ *					control interface
+ */
+enum dpdmux_action {
+	DPDMUX_ACTION_DROP = 0,
+	DPDMUX_ACTION_REDIRECT_TO_CTRL = 1
+};
+
+/**
+ * struct dpdmux_accepted_frames - Frame types configuration
+ * @type: Defines ingress accepted frames
+ * @unaccept_act: Defines action on frames not accepted
+ */
+struct dpdmux_accepted_frames {
+	enum dpdmux_accepted_frames_type type;
+	enum dpdmux_action unaccept_act;
+};
+
+int dpdmux_if_set_accepted_frames(struct fsl_mc_io *mc_io,
+				  uint32_t cmd_flags,
+				  uint16_t token,
+				  uint16_t if_id,
+				  const struct dpdmux_accepted_frames *cfg);
+
+/**
+ * struct dpdmux_if_attr - Structure representing frame types configuration
+ * @rate: Configured interface rate (in bits per second)
+ * @enabled: Indicates if interface is enabled
+ * @accept_frame_type: Indicates type of accepted frames for the interface
+ */
+struct dpdmux_if_attr {
+	uint32_t rate;
+	int enabled;
+	int is_default;
+	enum dpdmux_accepted_frames_type accept_frame_type;
+};
+
+int dpdmux_if_get_attributes(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_if_attr *attr);
+
+int dpdmux_if_enable(struct fsl_mc_io *mc_io,
+		     uint32_t cmd_flags,
+		     uint16_t token,
+		     uint16_t if_id);
+
+int dpdmux_if_disable(struct fsl_mc_io *mc_io,
+		      uint32_t cmd_flags,
+		      uint16_t token,
+		      uint16_t if_id);
+
+/**
+ * struct dpdmux_l2_rule - Structure representing L2 rule
+ * @mac_addr: MAC address
+ * @vlan_id: VLAN ID
+ */
+struct dpdmux_l2_rule {
+	uint8_t mac_addr[6];
+	uint16_t vlan_id;
+};
+
+int dpdmux_if_remove_l2_rule(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     const struct dpdmux_l2_rule *rule);
+
+int dpdmux_if_add_l2_rule(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  const struct dpdmux_l2_rule *rule);
+
+int dpdmux_if_get_counter(struct fsl_mc_io *mc_io,
+			  uint32_t cmd_flags,
+			  uint16_t token,
+			  uint16_t if_id,
+			  enum dpdmux_counter_type counter_type,
+			  uint64_t *counter);
+
+int dpdmux_ul_reset_counters(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token);
+
+/**
+ * Enable auto-negotiation
+ */
+#define DPDMUX_LINK_OPT_AUTONEG		0x0000000000000001ULL
+/**
+ * Enable half-duplex mode
+ */
+#define DPDMUX_LINK_OPT_HALF_DUPLEX	0x0000000000000002ULL
+/**
+ * Enable pause frames
+ */
+#define DPDMUX_LINK_OPT_PAUSE		0x0000000000000004ULL
+/**
+ * Enable a-symmetric pause frames
+ */
+#define DPDMUX_LINK_OPT_ASYM_PAUSE	0x0000000000000008ULL
+
+/**
+ * struct dpdmux_link_cfg - Structure representing DPDMUX link configuration
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
+ */
+struct dpdmux_link_cfg {
+	uint32_t rate;
+	uint64_t options;
+	uint64_t advertising;
+};
+
+int dpdmux_if_set_link_cfg(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t token,
+			   uint16_t if_id,
+			   struct dpdmux_link_cfg *cfg);
+/**
+ * struct dpdmux_link_state - Structure representing DPDMUX link state
+ * @rate: Rate
+ * @options: Mask of available options; use 'DPDMUX_LINK_OPT_<X>' values
+ * @up: 0 - down, 1 - up
+ * @state_valid: Ignore/Update the state of the link
+ * @supported: Speeds capability of the phy (bitmap)
+ * @advertising: Speeds that are advertised for autoneg (bitmap)
+ */
+struct dpdmux_link_state {
+	uint32_t rate;
+	uint64_t options;
+	int      up;
+	int      state_valid;
+	uint64_t supported;
+	uint64_t advertising;
+};
+
+int dpdmux_if_get_link_state(struct fsl_mc_io *mc_io,
+			     uint32_t cmd_flags,
+			     uint16_t token,
+			     uint16_t if_id,
+			     struct dpdmux_link_state *state);
+
+int dpdmux_if_set_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t if_id);
+
+int dpdmux_if_get_default(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		uint16_t *if_id);
+
+int dpdmux_set_custom_key(struct fsl_mc_io *mc_io,
+			uint32_t cmd_flags,
+			uint16_t token,
+			uint64_t key_cfg_iova);
+
+/**
+ * struct dpdmux_rule_cfg - Custom classification rule.
+ *
+ * @key_iova: DMA address of buffer storing the look-up value
+ * @mask_iova: DMA address of the mask used for TCAM classification
+ * @key_size: size, in bytes, of the look-up value. This must match the size
+ *	of the look-up key defined using dpdmux_set_custom_key, otherwise the
+ *	entry will never be hit
+ */
+struct dpdmux_rule_cfg {
+	uint64_t key_iova;
+	uint64_t mask_iova;
+	uint8_t key_size;
+};
+
+/**
+ * struct dpdmux_cls_action - Action to execute for frames matching the
+ *	classification entry
+ *
+ * @dest_if: Interface to forward the frames to. Port numbering is similar to
+ *	the one used to connect interfaces:
+ *	- 0 is the uplink port,
+ *	- all others are downlink ports.
+ */
+struct dpdmux_cls_action {
+	uint16_t dest_if;
+};
+
+int dpdmux_add_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule,
+		struct dpdmux_cls_action *action);
+
+int dpdmux_remove_custom_cls_entry(struct fsl_mc_io *mc_io,
+		uint32_t cmd_flags,
+		uint16_t token,
+		struct dpdmux_rule_cfg *rule);
+
+int dpdmux_get_api_version(struct fsl_mc_io *mc_io,
+			   uint32_t cmd_flags,
+			   uint16_t *major_ver,
+			   uint16_t *minor_ver);
+
+#endif /* __FSL_DPDMUX_H */
diff --git a/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
new file mode 100644
index 000000000..a36349feb
--- /dev/null
+++ b/drivers/net/dpaa2/mc/fsl_dpdmux_cmd.h
@@ -0,0 +1,221 @@
+/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
+ *
+ * Copyright 2013-2016 Freescale Semiconductor Inc.
+ * Copyright 2018 NXP
+ *
+ */
+#ifndef _FSL_DPDMUX_CMD_H
+#define _FSL_DPDMUX_CMD_H
+
+/* DPDMUX Version */
+#define DPDMUX_VER_MAJOR		6
+#define DPDMUX_VER_MINOR		3
+
+#define DPDMUX_CMD_BASE_VERSION		1
+#define DPDMUX_CMD_VERSION_2		2
+#define DPDMUX_CMD_ID_OFFSET		4
+
+#define DPDMUX_CMD(id)	(((id) << DPDMUX_CMD_ID_OFFSET) |\
+				DPDMUX_CMD_BASE_VERSION)
+#define DPDMUX_CMD_V2(id) (((id) << DPDMUX_CMD_ID_OFFSET) | \
+				DPDMUX_CMD_VERSION_2)
+
+/* Command IDs */
+#define DPDMUX_CMDID_CLOSE			DPDMUX_CMD(0x800)
+#define DPDMUX_CMDID_OPEN			DPDMUX_CMD(0x806)
+#define DPDMUX_CMDID_CREATE			DPDMUX_CMD(0x906)
+#define DPDMUX_CMDID_DESTROY			DPDMUX_CMD(0x986)
+#define DPDMUX_CMDID_GET_API_VERSION		DPDMUX_CMD(0xa06)
+
+#define DPDMUX_CMDID_ENABLE			DPDMUX_CMD(0x002)
+#define DPDMUX_CMDID_DISABLE			DPDMUX_CMD(0x003)
+#define DPDMUX_CMDID_GET_ATTR			DPDMUX_CMD(0x004)
+#define DPDMUX_CMDID_RESET			DPDMUX_CMD(0x005)
+#define DPDMUX_CMDID_IS_ENABLED			DPDMUX_CMD(0x006)
+
+#define DPDMUX_CMDID_SET_MAX_FRAME_LENGTH	DPDMUX_CMD(0x0a1)
+
+#define DPDMUX_CMDID_UL_RESET_COUNTERS		DPDMUX_CMD(0x0a3)
+
+#define DPDMUX_CMDID_IF_SET_ACCEPTED_FRAMES	DPDMUX_CMD(0x0a7)
+#define DPDMUX_CMDID_IF_GET_ATTR		DPDMUX_CMD(0x0a8)
+#define DPDMUX_CMDID_IF_ENABLE			DPDMUX_CMD(0x0a9)
+#define DPDMUX_CMDID_IF_DISABLE			DPDMUX_CMD(0x0aa)
+
+#define DPDMUX_CMDID_IF_ADD_L2_RULE		DPDMUX_CMD(0x0b0)
+#define DPDMUX_CMDID_IF_REMOVE_L2_RULE		DPDMUX_CMD(0x0b1)
+#define DPDMUX_CMDID_IF_GET_COUNTER		DPDMUX_CMD(0x0b2)
+#define DPDMUX_CMDID_IF_SET_LINK_CFG		DPDMUX_CMD_V2(0x0b3)
+#define DPDMUX_CMDID_IF_GET_LINK_STATE		DPDMUX_CMD_V2(0x0b4)
+
+#define DPDMUX_CMDID_SET_CUSTOM_KEY		DPDMUX_CMD(0x0b5)
+#define DPDMUX_CMDID_ADD_CUSTOM_CLS_ENTRY	DPDMUX_CMD(0x0b6)
+#define DPDMUX_CMDID_REMOVE_CUSTOM_CLS_ENTRY	DPDMUX_CMD(0x0b7)
+
+#define DPDMUX_CMDID_IF_SET_DEFAULT		DPDMUX_CMD(0x0b8)
+#define DPDMUX_CMDID_IF_GET_DEFAULT		DPDMUX_CMD(0x0b9)
+
+#define DPDMUX_MASK(field)        \
+	GENMASK(DPDMUX_##field##_SHIFT + DPDMUX_##field##_SIZE - 1, \
+		DPDMUX_##field##_SHIFT)
+#define dpdmux_set_field(var, field, val) \
+	((var) |= (((val) << DPDMUX_##field##_SHIFT) & DPDMUX_MASK(field)))
+#define dpdmux_get_field(var, field)      \
+	(((var) & DPDMUX_MASK(field)) >> DPDMUX_##field##_SHIFT)
+
+#pragma pack(push, 1)
+struct dpdmux_cmd_open {
+	uint32_t dpdmux_id;
+};
+
+struct dpdmux_cmd_create {
+	uint8_t method;
+	uint8_t manip;
+	uint16_t num_ifs;
+	uint32_t pad;
+
+	uint16_t adv_max_dmat_entries;
+	uint16_t adv_max_mc_groups;
+	uint16_t adv_max_vlan_ids;
+	uint16_t pad1;
+
+	uint64_t options;
+};
+
+struct dpdmux_cmd_destroy {
+	uint32_t dpdmux_id;
+};
+
+#define DPDMUX_ENABLE_SHIFT	0
+#define DPDMUX_ENABLE_SIZE	1
+#define DPDMUX_IS_DEFAULT_SHIFT		1
+#define DPDMUX_IS_DEFAULT_SIZE		1
+
+struct dpdmux_rsp_is_enabled {
+	uint8_t en;
+};
+
+struct dpdmux_rsp_get_attr {
+	uint8_t method;
+	uint8_t manip;
+	uint16_t num_ifs;
+	uint16_t mem_size;
+	uint16_t pad;
+
+	uint64_t pad1;
+
+	uint32_t id;
+	uint32_t pad2;
+
+	uint64_t options;
+};
+
+struct dpdmux_cmd_set_max_frame_length {
+	uint16_t max_frame_length;
+};
+
+#define DPDMUX_ACCEPTED_FRAMES_TYPE_SHIFT	0
+#define DPDMUX_ACCEPTED_FRAMES_TYPE_SIZE	4
+#define DPDMUX_UNACCEPTED_FRAMES_ACTION_SHIFT	4
+#define DPDMUX_UNACCEPTED_FRAMES_ACTION_SIZE	4
+
+struct dpdmux_cmd_if_set_accepted_frames {
+	uint16_t if_id;
+	uint8_t frames_options;
+};
+
+struct dpdmux_cmd_if {
+	uint16_t if_id;
+};
+
+struct dpdmux_rsp_if_get_attr {
+	uint8_t pad[3];
+	uint8_t enabled;
+	uint8_t pad1[3];
+	uint8_t accepted_frames_type;
+	uint32_t rate;
+};
+
+struct dpdmux_cmd_if_l2_rule {
+	uint16_t if_id;
+	uint8_t mac_addr5;
+	uint8_t mac_addr4;
+	uint8_t mac_addr3;
+	uint8_t mac_addr2;
+	uint8_t mac_addr1;
+	uint8_t mac_addr0;
+
+	uint32_t pad;
+	uint16_t vlan_id;
+};
+
+struct dpdmux_cmd_if_get_counter {
+	uint16_t if_id;
+	uint8_t counter_type;
+};
+
+struct dpdmux_rsp_if_get_counter {
+	uint64_t pad;
+	uint64_t counter;
+};
+
+struct dpdmux_cmd_if_set_link_cfg {
+	uint16_t if_id;
+	uint16_t pad[3];
+
+	uint32_t rate;
+	uint32_t pad1;
+
+	uint64_t options;
+	uint64_t advertising;
+};
+
+struct dpdmux_cmd_if_get_link_state {
+	uint16_t if_id;
+};
+
+#define DPDMUX_UP_SHIFT				0
+#define DPDMUX_UP_SIZE				1
+#define DPDMUX_STATE_VALID_SHIFT	1
+#define DPDMUX_STATE_VALID_SIZE		1
+struct dpdmux_rsp_if_get_link_state {
+	uint32_t pad;
+	uint8_t up;
+	uint8_t pad1[3];
+
+	uint32_t rate;
+	uint32_t pad2;
+
+	uint64_t options;
+	uint64_t supported;
+	uint64_t advertising;
+};
+
+struct dpdmux_rsp_get_api_version {
+	uint16_t major;
+	uint16_t minor;
+};
+
+struct dpdmux_set_custom_key {
+	uint64_t pad[6];
+	uint64_t key_cfg_iova;
+};
+
+struct dpdmux_cmd_add_custom_cls_entry {
+	uint8_t pad[3];
+	uint8_t key_size;
+	uint16_t pad1;
+	uint16_t dest_if;
+	uint64_t key_iova;
+	uint64_t mask_iova;
+};
+
+struct dpdmux_cmd_remove_custom_cls_entry {
+	uint8_t pad[3];
+	uint8_t key_size;
+	uint32_t pad1;
+	uint64_t key_iova;
+	uint64_t mask_iova;
+};
+#pragma pack(pop)
+#endif /* _FSL_DPDMUX_CMD_H */
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index 07aada87c..c7c2df417 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -12,6 +12,7 @@ sources = files('base/dpaa2_hw_dpni.c',
 		'dpaa2_ethdev.c',
 		'dpaa2_rxtx.c',
 		'mc/dpkg.c',
+		'mc/dpdmux.c',
 		'mc/dpni.c')
 
 includes += include_directories('base', 'mc')
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 14/19] bus/fslmc: add support for scanning DPDMUX object
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (12 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 13/19] net/dpaa2: add dpdmux mc flib Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 15/19] net/dpaa2: add dpdmux initialization and configuration Shreyansh Jain
                       ` (6 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

Add support in bus and vfio to scan dpdmux type of objects

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/bus/fslmc/fslmc_bus.c  | 5 ++++-
 drivers/bus/fslmc/fslmc_vfio.c | 2 ++
 drivers/bus/fslmc/rte_fslmc.h  | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/bus/fslmc/fslmc_bus.c b/drivers/bus/fslmc/fslmc_bus.c
index 565e0148f..fa1505377 100644
--- a/drivers/bus/fslmc/fslmc_bus.c
+++ b/drivers/bus/fslmc/fslmc_bus.c
@@ -187,6 +187,8 @@ scan_one_fslmc_device(char *dev_name)
 		dev->dev_type = DPAA2_MPORTAL;
 	else if (!strncmp("dpdmai", t_ptr, 6))
 		dev->dev_type = DPAA2_QDMA;
+	else if (!strncmp("dpdmux", t_ptr, 6))
+		dev->dev_type = DPAA2_MUX;
 	else
 		dev->dev_type = DPAA2_UNKNOWN;
 
@@ -245,7 +247,8 @@ rte_fslmc_parse(const char *name, void *addr)
 	    strncmp("dpio", t_ptr, 4) &&
 	    strncmp("dpci", t_ptr, 4) &&
 	    strncmp("dpmcp", t_ptr, 5) &&
-	    strncmp("dpdmai", t_ptr, 6)) {
+	    strncmp("dpdmai", t_ptr, 6) &&
+	    strncmp("dpdmux", t_ptr, 6)) {
 		DPAA2_BUS_ERR("Unknown or unsupported device");
 		goto err_out;
 	}
diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index ce82a99f6..98768a46c 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -560,6 +560,7 @@ fslmc_process_iodevices(struct rte_dpaa2_device *dev)
 	case DPAA2_IO:
 	case DPAA2_CI:
 	case DPAA2_BPOOL:
+	case DPAA2_MUX:
 		TAILQ_FOREACH(object, &dpaa2_obj_list, next) {
 			if (dev->dev_type == object->dev_type)
 				object->create(dev_fd, &device_info,
@@ -691,6 +692,7 @@ fslmc_vfio_process_group(void)
 		case DPAA2_IO:
 		case DPAA2_CI:
 		case DPAA2_BPOOL:
+		case DPAA2_MUX:
 			/* Call the object creation routine and remove the
 			 * device entry from device list
 			 */
diff --git a/drivers/bus/fslmc/rte_fslmc.h b/drivers/bus/fslmc/rte_fslmc.h
index cea5b78f9..5cfb24505 100644
--- a/drivers/bus/fslmc/rte_fslmc.h
+++ b/drivers/bus/fslmc/rte_fslmc.h
@@ -66,6 +66,7 @@ enum rte_dpaa2_dev_type {
 	DPAA2_CI,	/**< DPCI type device */
 	DPAA2_MPORTAL,  /**< DPMCP type device */
 	DPAA2_QDMA,     /**< DPDMAI type device */
+	DPAA2_MUX,	/**< DPDMUX type device */
 	/* Unknown device placeholder */
 	DPAA2_UNKNOWN,
 	DPAA2_DEVTYPE_MAX,
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 15/19] net/dpaa2: add dpdmux initialization and configuration
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (13 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 14/19] bus/fslmc: add support for scanning DPDMUX object Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 16/19] net/dpaa2: add API to support custom hash key Shreyansh Jain
                       ` (5 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

This patch introduces an rte pmd API to configure dpdmux from
the application.
dpdmux can work in association with dpni as an additional
distribution capability on the NIC.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/Makefile                  |   1 +
 drivers/net/dpaa2/dpaa2_ethdev.h            |   2 +
 drivers/net/dpaa2/dpaa2_mux.c               | 222 ++++++++++++++++++++
 drivers/net/dpaa2/meson.build               |   1 +
 drivers/net/dpaa2/rte_pmd_dpaa2.h           |  23 ++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |   1 +
 6 files changed, 250 insertions(+)
 create mode 100644 drivers/net/dpaa2/dpaa2_mux.c

diff --git a/drivers/net/dpaa2/Makefile b/drivers/net/dpaa2/Makefile
index c58a39725..562551175 100644
--- a/drivers/net/dpaa2/Makefile
+++ b/drivers/net/dpaa2/Makefile
@@ -33,6 +33,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += base/dpaa2_hw_dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_rxtx.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_ethdev.c
+SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += dpaa2_mux.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpni.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpkg.c
 SRCS-$(CONFIG_RTE_LIBRTE_DPAA2_PMD) += mc/dpdmux.c
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index 7cf6e4191..420ad6446 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -11,6 +11,8 @@
 #include <rte_event_eth_rx_adapter.h>
 #include <rte_pmd_dpaa2.h>
 
+#include <dpaa2_hw_pvt.h>
+
 #include <mc/fsl_dpni.h>
 #include <mc/fsl_mc_sys.h>
 
diff --git a/drivers/net/dpaa2/dpaa2_mux.c b/drivers/net/dpaa2/dpaa2_mux.c
new file mode 100644
index 000000000..1d043dcdc
--- /dev/null
+++ b/drivers/net/dpaa2/dpaa2_mux.c
@@ -0,0 +1,222 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright 2018 NXP
+ */
+
+#include <sys/queue.h>
+#include <stdio.h>
+#include <errno.h>
+#include <stdint.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdarg.h>
+
+#include <rte_ethdev.h>
+#include <rte_log.h>
+#include <rte_eth_ctrl.h>
+#include <rte_malloc.h>
+#include <rte_flow_driver.h>
+#include <rte_tailq.h>
+
+#include <rte_fslmc.h>
+#include <fsl_dpdmux.h>
+#include <fsl_dpkg.h>
+
+#include <dpaa2_ethdev.h>
+#include <dpaa2_pmd_logs.h>
+
+struct dpaa2_dpdmux_dev {
+	TAILQ_ENTRY(dpaa2_dpdmux_dev) next;
+		/**< Pointer to Next device instance */
+	struct fsl_mc_io dpdmux;  /** handle to DPDMUX portal object */
+	uint16_t token;
+	uint32_t dpdmux_id; /*HW ID for DPDMUX object */
+	uint8_t num_ifs;   /* Number of interfaces in DPDMUX */
+};
+
+struct rte_flow {
+	struct dpdmux_rule_cfg rule;
+};
+
+TAILQ_HEAD(dpdmux_dev_list, dpaa2_dpdmux_dev);
+static struct dpdmux_dev_list dpdmux_dev_list =
+	TAILQ_HEAD_INITIALIZER(dpdmux_dev_list); /*!< DPDMUX device list */
+
+static struct dpaa2_dpdmux_dev *get_dpdmux_from_id(uint32_t dpdmux_id)
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev = NULL;
+
+	/* Get DPBP dev handle from list using index */
+	TAILQ_FOREACH(dpdmux_dev, &dpdmux_dev_list, next) {
+		if (dpdmux_dev->dpdmux_id == dpdmux_id)
+			break;
+	}
+
+	return dpdmux_dev;
+}
+
+struct rte_flow *
+rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
+			      struct rte_flow_item *pattern[],
+			      struct rte_flow_action *actions[])
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev;
+	struct dpkg_profile_cfg kg_cfg;
+	const struct rte_flow_item_ipv4 *spec;
+	const struct rte_flow_action_vf *vf_conf;
+	struct dpdmux_cls_action dpdmux_action;
+	struct rte_flow *flow = NULL;
+	void *key_iova, *mask_iova, *key_cfg_iova = NULL;
+	int ret;
+
+	if (pattern[0]->type != RTE_FLOW_ITEM_TYPE_IPV4) {
+		DPAA2_PMD_ERR("Not supported pattern type: %d",
+			      pattern[0]->type);
+		return NULL;
+	}
+
+	/* Find the DPDMUX from dpdmux_id in our list */
+	dpdmux_dev = get_dpdmux_from_id(dpdmux_id);
+	if (!dpdmux_dev) {
+		DPAA2_PMD_ERR("Invalid dpdmux_id: %d", dpdmux_id);
+		return NULL;
+	}
+
+	key_cfg_iova = rte_zmalloc(NULL, DIST_PARAM_IOVA_SIZE,
+				   RTE_CACHE_LINE_SIZE);
+	if (!key_cfg_iova) {
+		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
+		return NULL;
+	}
+
+	/* Currently taking only IP protocol as an extract type.
+	 * This can be exended to other fields using pattern->type.
+	 */
+	memset(&kg_cfg, 0, sizeof(struct dpkg_profile_cfg));
+	kg_cfg.extracts[0].extract.from_hdr.prot = NET_PROT_IP;
+	kg_cfg.extracts[0].extract.from_hdr.field = NH_FLD_IP_PROTO;
+	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_HDR;
+	kg_cfg.extracts[0].extract.from_hdr.type = DPKG_FULL_FIELD;
+	kg_cfg.num_extracts = 1;
+
+	ret = dpkg_prepare_key_cfg(&kg_cfg, key_cfg_iova);
+	if (ret) {
+		DPAA2_PMD_ERR("dpkg_prepare_key_cfg failed: err(%d)", ret);
+		goto creation_error;
+	}
+
+	ret = dpdmux_set_custom_key(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token,
+			(uint64_t)(DPAA2_VADDR_TO_IOVA(key_cfg_iova)));
+	if (ret) {
+		DPAA2_PMD_ERR("dpdmux_set_custom_key failed: err(%d)", ret);
+		goto creation_error;
+	}
+
+	/* As now our key extract parameters are set, let us configure
+	 * the rule.
+	 */
+	flow = rte_zmalloc(NULL, sizeof(struct rte_flow) +
+			   (2 * DIST_PARAM_IOVA_SIZE), RTE_CACHE_LINE_SIZE);
+	if (!flow) {
+		DPAA2_PMD_ERR(
+			"Memory allocation failure for rule configration\n");
+		goto creation_error;
+	}
+	key_iova = (void *)((size_t)flow + sizeof(struct rte_flow));
+	mask_iova = (void *)((size_t)key_iova + DIST_PARAM_IOVA_SIZE);
+
+	spec = (const struct rte_flow_item_ipv4 *)pattern[0]->spec;
+	memcpy(key_iova, (const void *)&spec->hdr.next_proto_id,
+	       sizeof(uint8_t));
+	memcpy(mask_iova, pattern[0]->mask, sizeof(uint8_t));
+
+	flow->rule.key_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(key_iova));
+	flow->rule.mask_iova = (uint64_t)(DPAA2_VADDR_TO_IOVA(mask_iova));
+	flow->rule.key_size = sizeof(uint8_t);
+
+	vf_conf = (const struct rte_flow_action_vf *)(actions[0]->conf);
+	if (vf_conf->id == 0 || vf_conf->id > dpdmux_dev->num_ifs) {
+		DPAA2_PMD_ERR("Invalid destination id\n");
+		goto creation_error;
+	}
+	dpdmux_action.dest_if = vf_conf->id;
+
+	ret = dpdmux_add_custom_cls_entry(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+					  dpdmux_dev->token, &flow->rule,
+					  &dpdmux_action);
+	if (ret) {
+		DPAA2_PMD_ERR("dpdmux_add_custom_cls_entry failed: err(%d)",
+			      ret);
+		goto creation_error;
+	}
+
+	return flow;
+
+creation_error:
+	rte_free((void *)key_cfg_iova);
+	rte_free((void *)flow);
+	return NULL;
+}
+
+static int
+dpaa2_create_dpdmux_device(int vdev_fd __rte_unused,
+			   struct vfio_device_info *obj_info __rte_unused,
+			   int dpdmux_id)
+{
+	struct dpaa2_dpdmux_dev *dpdmux_dev;
+	struct dpdmux_attr attr;
+	int ret;
+
+	PMD_INIT_FUNC_TRACE();
+
+	/* Allocate DPAA2 dpdmux handle */
+	dpdmux_dev = rte_malloc(NULL, sizeof(struct dpaa2_dpdmux_dev), 0);
+	if (!dpdmux_dev) {
+		DPAA2_PMD_ERR("Memory allocation failed for DPDMUX Device");
+		return -1;
+	}
+
+	/* Open the dpdmux object */
+	dpdmux_dev->dpdmux.regs = rte_mcp_ptr_list[MC_PORTAL_INDEX];
+	ret = dpdmux_open(&dpdmux_dev->dpdmux, CMD_PRI_LOW, dpdmux_id,
+			  &dpdmux_dev->token);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to open dpdmux object: err(%d)", ret);
+		goto init_err;
+	}
+
+	ret = dpdmux_get_attributes(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token, &attr);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to get dpdmux attr: err(%d)", ret);
+		goto init_err;
+	}
+
+	ret = dpdmux_if_set_default(&dpdmux_dev->dpdmux, CMD_PRI_LOW,
+				    dpdmux_dev->token, 1);
+	if (ret) {
+		DPAA2_PMD_ERR("setting default interface failed in %s",
+			      __func__);
+		goto init_err;
+	}
+
+	dpdmux_dev->dpdmux_id = dpdmux_id;
+	dpdmux_dev->num_ifs = attr.num_ifs;
+
+	TAILQ_INSERT_TAIL(&dpdmux_dev_list, dpdmux_dev, next);
+
+	return 0;
+
+init_err:
+	if (dpdmux_dev)
+		rte_free(dpdmux_dev);
+
+	return -1;
+}
+
+static struct rte_dpaa2_object rte_dpaa2_dpdmux_obj = {
+	.dev_type = DPAA2_MUX,
+	.create = dpaa2_create_dpdmux_device,
+};
+
+RTE_PMD_REGISTER_DPAA2_OBJECT(dpdmux, rte_dpaa2_dpdmux_obj);
diff --git a/drivers/net/dpaa2/meson.build b/drivers/net/dpaa2/meson.build
index c7c2df417..801cbf5d7 100644
--- a/drivers/net/dpaa2/meson.build
+++ b/drivers/net/dpaa2/meson.build
@@ -9,6 +9,7 @@ endif
 
 deps += ['mempool_dpaa2']
 sources = files('base/dpaa2_hw_dpni.c',
+		'dpaa2_mux.c',
 		'dpaa2_ethdev.c',
 		'dpaa2_rxtx.c',
 		'mc/dpkg.c',
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
index f9303acad..57de27f21 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2.h
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -36,4 +36,27 @@ enum pmd_dpaa2_ts {
 __rte_experimental
 void rte_pmd_dpaa2_set_timestamp(enum pmd_dpaa2_ts);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Create a flow rule to demultiplex ethernet traffic to separate network
+ * interfaces.
+ *
+ * @param dpdmux_id
+ *    ID of the DPDMUX MC object.
+ * @param[in] pattern
+ *    Pattern specification.
+ * @param[in] actions
+ *    Associated actions.
+ *
+ * @return
+ *    A valid handle in case of success, NULL otherwise.
+ */
+__rte_experimental
+struct rte_flow *
+rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
+			      struct rte_flow_item *pattern[],
+			      struct rte_flow_action *actions[]);
+
 #endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index de95a03cd..1661c5fb5 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -14,5 +14,6 @@ DPDK_17.11 {
 EXPERIMENTAL {
 	global:
 
+	rte_pmd_dpaa2_mux_flow_create;
 	rte_pmd_dpaa2_set_timestamp;
 } DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 16/19] net/dpaa2: add API to support custom hash key
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (14 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 15/19] net/dpaa2: add dpdmux initialization and configuration Shreyansh Jain
@ 2019-01-11 12:24     ` Shreyansh Jain
  2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 17/19] mempool/dpaa2: support saving context of buffer pool Shreyansh Jain
                       ` (4 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:24 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Nipun Gupta

From: Nipun Gupta <nipun.gupta@nxp.com>

The DPAA2 hw can support a special offset based
configuration to program distribution on hash.
This is for all cases, which are not directly supported.

e.g. HASH based distribution on inner ip header
of a GRE tunnel.

Signed-off-by: Nipun Gupta <nipun.gupta@nxp.com>
---
 drivers/net/dpaa2/base/dpaa2_hw_dpni.c      | 52 ++++++++++++++++++++-
 drivers/net/dpaa2/rte_pmd_dpaa2.h           | 28 +++++++++++
 drivers/net/dpaa2/rte_pmd_dpaa2_version.map |  1 +
 3 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
index a6f86df8c..11f14931e 100644
--- a/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
+++ b/drivers/net/dpaa2/base/dpaa2_hw_dpni.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016 NXP
+ *   Copyright 2016-2018 NXP
  *
  */
 
@@ -28,6 +28,56 @@ dpaa2_distset_to_dpkg_profile_cfg(
 		uint64_t req_dist_set,
 		struct dpkg_profile_cfg *kg_cfg);
 
+int
+rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
+			      uint16_t offset,
+			      uint8_t size)
+{
+	struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
+	struct dpaa2_dev_priv *priv = eth_dev->data->dev_private;
+	struct fsl_mc_io *dpni = priv->hw;
+	struct dpni_rx_tc_dist_cfg tc_cfg;
+	struct dpkg_profile_cfg kg_cfg;
+	void *p_params;
+	int ret, tc_index = 0;
+
+	p_params = rte_zmalloc(
+		NULL, DIST_PARAM_IOVA_SIZE, RTE_CACHE_LINE_SIZE);
+	if (!p_params) {
+		DPAA2_PMD_ERR("Unable to allocate flow-dist parameters");
+		return -ENOMEM;
+	}
+
+	kg_cfg.extracts[0].type = DPKG_EXTRACT_FROM_DATA;
+	kg_cfg.extracts[0].extract.from_data.offset = offset;
+	kg_cfg.extracts[0].extract.from_data.size = size;
+	kg_cfg.num_extracts = 1;
+
+	ret = dpkg_prepare_key_cfg(&kg_cfg, p_params);
+	if (ret) {
+		DPAA2_PMD_ERR("Unable to prepare extract parameters");
+		rte_free(p_params);
+		return ret;
+	}
+
+	memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
+	tc_cfg.key_cfg_iova = (size_t)(DPAA2_VADDR_TO_IOVA(p_params));
+	tc_cfg.dist_size = eth_dev->data->nb_rx_queues;
+	tc_cfg.dist_mode = DPNI_DIST_MODE_HASH;
+
+	ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token, tc_index,
+				  &tc_cfg);
+	rte_free(p_params);
+	if (ret) {
+		DPAA2_PMD_ERR(
+			     "Setting distribution for Rx failed with err: %d",
+			     ret);
+		return ret;
+	}
+
+	return 0;
+}
+
 int
 dpaa2_setup_flow_dist(struct rte_eth_dev *eth_dev,
 		      uint64_t req_dist_set)
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2.h b/drivers/net/dpaa2/rte_pmd_dpaa2.h
index 57de27f21..7052d9da9 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2.h
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2.h
@@ -59,4 +59,32 @@ rte_pmd_dpaa2_mux_flow_create(uint32_t dpdmux_id,
 			      struct rte_flow_item *pattern[],
 			      struct rte_flow_action *actions[]);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change, or be removed, without prior notice
+ *
+ * Create a custom hash key on basis of offset of start of packet and size.
+ * for e.g. if we need GRE packets (non-vlan and without any extra headers)
+ * to be hashed on basis of inner IP header, we will provide offset as:
+ * 14 (eth) + 20 (IP) + 4 (GRE) + 12 (Inner Src offset) = 50 and size
+ * as 8 bytes.
+ *
+ * @param port_id
+ *    The port identifier of the Ethernet device.
+ * @param offset
+ *    Offset from the start of packet which needs to be included to
+ *    calculate hash
+ * @param size
+ *    Size of the hash input key
+ *
+ * @return
+ *   - 0 if successful.
+ *   - Negative in case of failure.
+ */
+__rte_experimental
+int
+rte_pmd_dpaa2_set_custom_hash(uint16_t port_id,
+			      uint16_t offset,
+			      uint8_t size);
+
 #endif /* _RTE_PMD_DPAA2_H */
diff --git a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
index 1661c5fb5..d1b4cdb23 100644
--- a/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
+++ b/drivers/net/dpaa2/rte_pmd_dpaa2_version.map
@@ -15,5 +15,6 @@ EXPERIMENTAL {
 	global:
 
 	rte_pmd_dpaa2_mux_flow_create;
+	rte_pmd_dpaa2_set_custom_hash;
 	rte_pmd_dpaa2_set_timestamp;
 } DPDK_17.11;
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 17/19] mempool/dpaa2: support saving context of buffer pool
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (15 preceding siblings ...)
  2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 16/19] net/dpaa2: add API to support custom hash key Shreyansh Jain
@ 2019-01-11 12:25     ` Shreyansh Jain
  2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 18/19] net/dpaa2: change reference to private device Shreyansh Jain
                       ` (3 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:25 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

Initial design was to have the buffer pool per process where a
global static array stores the bpids. But, in case of secondary
processes, this would not allow the I/O threads to translate the
bpid in Rx'd packets.

This patch moves the array to a global area (rte_malloc) and in
case of Rx thread not containing a valid reference to the array,
reference is build using the handle avaialble in the dpaa2_queue.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h  |  1 +
 drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 12 +++++++++++-
 drivers/mempool/dpaa2/dpaa2_hw_mempool.h |  2 +-
 drivers/net/dpaa2/dpaa2_ethdev.c         |  1 +
 drivers/net/dpaa2/dpaa2_rxtx.c           |  5 +++++
 5 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
index efbeebef9..20c606dbe 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
@@ -141,6 +141,7 @@ struct dpaa2_queue {
 	};
 	struct rte_event ev;
 	dpaa2_queue_cb_dqrr_t *cb;
+	struct dpaa2_bp_info *bp_array;
 };
 
 struct swp_active_dqs {
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
index 790cded80..335eae40e 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c
@@ -32,7 +32,7 @@
 
 #include <dpaax_iova_table.h>
 
-struct dpaa2_bp_info rte_dpaa2_bpid_info[MAX_BPID];
+struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 static struct dpaa2_bp_list *h_bp_list;
 
 /* Dynamic logging identified for mempool */
@@ -50,6 +50,16 @@ rte_hw_mbuf_create_pool(struct rte_mempool *mp)
 
 	avail_dpbp = dpaa2_alloc_dpbp_dev();
 
+	if (rte_dpaa2_bpid_info == NULL) {
+		rte_dpaa2_bpid_info = (struct dpaa2_bp_info *)rte_malloc(NULL,
+				      sizeof(struct dpaa2_bp_info) * MAX_BPID,
+				      RTE_CACHE_LINE_SIZE);
+		if (rte_dpaa2_bpid_info == NULL)
+			return -ENOMEM;
+		memset(rte_dpaa2_bpid_info, 0,
+		       sizeof(struct dpaa2_bp_info) * MAX_BPID);
+	}
+
 	if (!avail_dpbp) {
 		DPAA2_MEMPOOL_ERR("DPAA2 pool not available!");
 		return -ENOENT;
diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.h b/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
index 4d3468746..93694616e 100644
--- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
+++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.h
@@ -59,7 +59,7 @@ struct dpaa2_bp_info {
 #define mempool_to_bpinfo(mp) ((struct dpaa2_bp_info *)(mp)->pool_data)
 #define mempool_to_bpid(mp) ((mempool_to_bpinfo(mp))->bpid)
 
-extern struct dpaa2_bp_info rte_dpaa2_bpid_info[MAX_BPID];
+extern struct dpaa2_bp_info *rte_dpaa2_bpid_info;
 
 int rte_dpaa2_mbuf_alloc_bulk(struct rte_mempool *pool,
 		       void **obj_table, unsigned int count);
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 861fbcd90..3a20158da 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -485,6 +485,7 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
 	}
 	dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[rx_queue_id];
 	dpaa2_q->mb_pool = mb_pool; /**< mbuf pool to populate RX ring. */
+	dpaa2_q->bp_array = rte_dpaa2_bpid_info;
 
 	/*Get the flow id from given VQ id*/
 	flow_id = rx_queue_id % priv->nb_rx_queues;
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index 816ea00fd..6e2e8abd7 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -518,6 +518,11 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			return 0;
 		}
 	}
+
+	if (unlikely(!rte_dpaa2_bpid_info &&
+		     rte_eal_process_type() == RTE_PROC_SECONDARY))
+		rte_dpaa2_bpid_info = dpaa2_q->bp_array;
+
 	swp = DPAA2_PER_LCORE_ETHRX_PORTAL;
 	pull_size = (nb_pkts > dpaa2_dqrr_size) ? dpaa2_dqrr_size : nb_pkts;
 	if (unlikely(!q_storage->active_dqs)) {
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 18/19] net/dpaa2: change reference to private device
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (16 preceding siblings ...)
  2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 17/19] mempool/dpaa2: support saving context of buffer pool Shreyansh Jain
@ 2019-01-11 12:25     ` Shreyansh Jain
  2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 19/19] bus/fslmc: add support for secondary processes Shreyansh Jain
                       ` (2 subsequent siblings)
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:25 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

The I/O threads for DPAA2 take their reference for bpool ID, the
port ID and other info like qdid, from the rte_eth_dev. Further,
to get this data during I/O operation, a reference of the RTE
device is kept in the queue structure (dpaa2_queue).

In case of secondary processes, rte_eth_dev is not same as the
primary process. Thus, the reference goes invalid.

This patch changes the implementation to use the dev_private
rather than the rte_eth_dev as that is shared area across
all the processes.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/portal/dpaa2_hw_pvt.h |  5 ++++-
 drivers/net/dpaa2/dpaa2_ethdev.c        |  4 ++--
 drivers/net/dpaa2/dpaa2_rxtx.c          | 18 ++++++++++--------
 3 files changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
index 20c606dbe..626fcbbca 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_pvt.h
@@ -127,7 +127,10 @@ typedef void (dpaa2_queue_cb_dqrr_t)(struct qbman_swp *swp,
 
 struct dpaa2_queue {
 	struct rte_mempool *mb_pool; /**< mbuf pool to populate RX ring. */
-	void *dev;
+	union {
+		struct rte_eth_dev_data *eth_data;
+		void *dev;
+	};
 	int32_t eventfd;	/*!< Event Fd of this queue */
 	uint32_t fqid;		/*!< Unique ID of this queue */
 	uint8_t tc_index;	/*!< traffic class identifier */
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index 3a20158da..2b90f4021 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -244,7 +244,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 	}
 
 	for (i = 0; i < priv->nb_rx_queues; i++) {
-		mc_q->dev = dev;
+		mc_q->eth_data = dev->data;
 		priv->rx_vq[i] = mc_q++;
 		dpaa2_q = (struct dpaa2_queue *)priv->rx_vq[i];
 		dpaa2_q->q_storage = rte_malloc("dq_storage",
@@ -260,7 +260,7 @@ dpaa2_alloc_rx_tx_queues(struct rte_eth_dev *dev)
 	}
 
 	for (i = 0; i < priv->nb_tx_queues; i++) {
-		mc_q->dev = dev;
+		mc_q->eth_data = dev->data;
 		mc_q->flow_id = 0xffff;
 		priv->tx_vq[i] = mc_q++;
 		dpaa2_q = (struct dpaa2_queue *)priv->tx_vq[i];
diff --git a/drivers/net/dpaa2/dpaa2_rxtx.c b/drivers/net/dpaa2/dpaa2_rxtx.c
index 6e2e8abd7..2d4b9ef14 100644
--- a/drivers/net/dpaa2/dpaa2_rxtx.c
+++ b/drivers/net/dpaa2/dpaa2_rxtx.c
@@ -509,7 +509,7 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	const struct qbman_fd *fd, *next_fd;
 	struct qbman_pull_desc pulldesc;
 	struct queue_storage_info_t *q_storage = dpaa2_q->q_storage;
-	struct rte_eth_dev *dev = dpaa2_q->dev;
+	struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
 
 	if (unlikely(!DPAA2_PER_LCORE_ETHRX_DPIO)) {
 		ret = dpaa2_affine_qbman_ethrx_swp();
@@ -613,9 +613,10 @@ dpaa2_dev_prefetch_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			bufs[num_rx] = eth_sg_fd_to_mbuf(fd);
 		else
 			bufs[num_rx] = eth_fd_to_mbuf(fd);
-		bufs[num_rx]->port = dev->data->port_id;
+		bufs[num_rx]->port = eth_data->port_id;
 
-		if (dev->data->dev_conf.rxmode.offloads & DEV_RX_OFFLOAD_VLAN_STRIP)
+		if (eth_data->dev_conf.rxmode.offloads &
+				DEV_RX_OFFLOAD_VLAN_STRIP)
 			rte_vlan_strip(bufs[num_rx]);
 
 		dq_storage++;
@@ -716,8 +717,8 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	struct qbman_swp *swp;
 	uint16_t num_tx = 0;
 	uint16_t bpid;
-	struct rte_eth_dev *dev = dpaa2_q->dev;
-	struct dpaa2_dev_priv *priv = dev->data->dev_private;
+	struct rte_eth_dev_data *eth_data = dpaa2_q->eth_data;
+	struct dpaa2_dev_priv *priv = eth_data->dev_private;
 	uint32_t flags[MAX_TX_RING_SLOTS] = {0};
 
 	if (unlikely(!DPAA2_PER_LCORE_DPIO)) {
@@ -729,7 +730,8 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	}
 	swp = DPAA2_PER_LCORE_PORTAL;
 
-	DPAA2_PMD_DP_DEBUG("===> dev =%p, fqid =%d\n", dev, dpaa2_q->fqid);
+	DPAA2_PMD_DP_DEBUG("===> eth_data =%p, fqid =%d\n",
+			eth_data, dpaa2_q->fqid);
 
 	/*Prepare enqueue descriptor*/
 	qbman_eq_desc_clear(&eqdesc);
@@ -772,7 +774,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 				    rte_mbuf_refcnt_read((*bufs)) == 1)) {
 					if (unlikely(((*bufs)->ol_flags
 						& PKT_TX_VLAN_PKT) ||
-						(dev->data->dev_conf.txmode.offloads
+						(eth_data->dev_conf.txmode.offloads
 						& DEV_TX_OFFLOAD_VLAN_INSERT))) {
 						ret = rte_vlan_insert(bufs);
 						if (ret)
@@ -794,7 +796,7 @@ dpaa2_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			}
 
 			if (unlikely(((*bufs)->ol_flags & PKT_TX_VLAN_PKT) ||
-				(dev->data->dev_conf.txmode.offloads
+				(eth_data->dev_conf.txmode.offloads
 				& DEV_TX_OFFLOAD_VLAN_INSERT))) {
 				int ret = rte_vlan_insert(bufs);
 				if (ret)
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* [dpdk-dev] [PATCH v3 19/19] bus/fslmc: add support for secondary processes
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (17 preceding siblings ...)
  2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 18/19] net/dpaa2: change reference to private device Shreyansh Jain
@ 2019-01-11 12:25     ` Shreyansh Jain
  2019-01-11 15:51     ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Ferruh Yigit
  2019-01-14  5:19     ` Shreyansh Jain
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-11 12:25 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, Shreyansh Jain

Previously FSLMC bus only supported blacklisting of DPNI (eth),
DPSECI (crypto) devices. With this patch, devices like DPIO,
DPMCP, and other DP* can also be blacklisted/whitelisted.

This is a required condition for secondary processes where the
secondary needs to be passed a mutually exclusive list of
resources as compared the primary and all other secondaries.

This patch also moves the DPIO memory from malloc to hugepage so
that in future in case the DPIO list can be shared, it can be
accessed in secondaries.

Once this patch is done, multi-process cases can be executed by
whitelisting/blacklisting devices in each instance.

Signed-off-by: Shreyansh Jain <shreyansh.jain@nxp.com>
---
 drivers/bus/fslmc/fslmc_vfio.c           | 51 ++++++++++++++++++++----
 drivers/bus/fslmc/portal/dpaa2_hw_dpio.c | 24 +++++++++--
 2 files changed, 63 insertions(+), 12 deletions(-)

diff --git a/drivers/bus/fslmc/fslmc_vfio.c b/drivers/bus/fslmc/fslmc_vfio.c
index 98768a46c..1aae56fa9 100644
--- a/drivers/bus/fslmc/fslmc_vfio.c
+++ b/drivers/bus/fslmc/fslmc_vfio.c
@@ -1,7 +1,7 @@
 /* SPDX-License-Identifier: BSD-3-Clause
  *
  *   Copyright (c) 2015-2016 Freescale Semiconductor, Inc. All rights reserved.
- *   Copyright 2016 NXP
+ *   Copyright 2016-2018 NXP
  *
  */
 
@@ -610,6 +610,15 @@ fslmc_process_mcp(struct rte_dpaa2_device *dev)
 
 	/* check the MC version compatibility */
 	dpmng.regs = (void *)v_addr;
+
+	/* In case of secondary processes, MC version check is no longer
+	 * required.
+	 */
+	if (rte_eal_process_type() == RTE_PROC_SECONDARY) {
+		rte_mcp_ptr_list[0] = (void *)v_addr;
+		return 0;
+	}
+
 	if (mc_get_version(&dpmng, CMD_PRI_LOW, &mc_ver_info)) {
 		DPAA2_BUS_ERR("Unable to obtain MC version");
 		ret = -1;
@@ -653,6 +662,15 @@ fslmc_vfio_process_group(void)
 	/* Search the MCP as that should be initialized first. */
 	TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_temp) {
 		if (dev->dev_type == DPAA2_MPORTAL) {
+			if (dev->device.devargs &&
+			    dev->device.devargs->policy == RTE_DEV_BLACKLISTED) {
+				DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
+					      dev->device.name);
+				TAILQ_REMOVE(&rte_fslmc_bus.device_list,
+						dev, next);
+				continue;
+			}
+
 			ret = fslmc_process_mcp(dev);
 			if (ret) {
 				DPAA2_BUS_ERR("Unable to map MC Portal");
@@ -677,6 +695,13 @@ fslmc_vfio_process_group(void)
 	}
 
 	TAILQ_FOREACH_SAFE(dev, &rte_fslmc_bus.device_list, next, dev_temp) {
+		if (dev->device.devargs &&
+		    dev->device.devargs->policy == RTE_DEV_BLACKLISTED) {
+			DPAA2_BUS_LOG(DEBUG, "%s Blacklisted, skipping",
+				      dev->device.name);
+			TAILQ_REMOVE(&rte_fslmc_bus.device_list, dev, next);
+			continue;
+		}
 		switch (dev->dev_type) {
 		case DPAA2_ETH:
 		case DPAA2_CRYPTO:
@@ -689,10 +714,17 @@ fslmc_vfio_process_group(void)
 			}
 			break;
 		case DPAA2_CON:
-		case DPAA2_IO:
 		case DPAA2_CI:
 		case DPAA2_BPOOL:
 		case DPAA2_MUX:
+			/* IN case of secondary processes, all control objects
+			 * like dpbp, dpcon, dpci are not initialized/required
+			 * - all of these are assumed to be initialized and made
+			 *   available by primary.
+			 */
+			if (rte_eal_process_type() == RTE_PROC_SECONDARY)
+				continue;
+
 			/* Call the object creation routine and remove the
 			 * device entry from device list
 			 */
@@ -703,12 +735,15 @@ fslmc_vfio_process_group(void)
 				return -1;
 			}
 
-			/* This device is not required to be in the DPDK
-			 * exposed device list.
-			 */
-			TAILQ_REMOVE(&rte_fslmc_bus.device_list, dev, next);
-			free(dev);
-			dev = NULL;
+			break;
+		case DPAA2_IO:
+			ret = fslmc_process_iodevices(dev);
+			if (ret) {
+				DPAA2_BUS_DEBUG("Dev (%s) init failed",
+						dev->device.name);
+				return -1;
+			}
+
 			break;
 		case DPAA2_UNKNOWN:
 		default:
diff --git a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
index cd28441f3..f377f24ae 100644
--- a/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
+++ b/drivers/bus/fslmc/portal/dpaa2_hw_dpio.c
@@ -418,9 +418,8 @@ dpaa2_create_dpio_device(int vdev_fd,
 			goto err;
 	}
 
-	dpio_dev->dpio = malloc(sizeof(struct fsl_mc_io));
-	memset(dpio_dev->dpio, 0, sizeof(struct fsl_mc_io));
-
+	dpio_dev->dpio = rte_zmalloc(NULL, sizeof(struct fsl_mc_io),
+				     RTE_CACHE_LINE_SIZE);
 	if (!dpio_dev->dpio) {
 		DPAA2_BUS_ERR("Memory allocation failure");
 		goto err;
@@ -535,9 +534,26 @@ dpaa2_create_dpio_device(int vdev_fd,
 	if (dpio_dev->dpio) {
 		dpio_disable(dpio_dev->dpio, CMD_PRI_LOW, dpio_dev->token);
 		dpio_close(dpio_dev->dpio, CMD_PRI_LOW,  dpio_dev->token);
-		free(dpio_dev->dpio);
+		rte_free(dpio_dev->dpio);
 	}
+
 	rte_free(dpio_dev);
+
+	/* For each element in the list, cleanup */
+	TAILQ_FOREACH(dpio_dev, &dpio_dev_list, next) {
+		if (dpio_dev->dpio) {
+			dpio_disable(dpio_dev->dpio, CMD_PRI_LOW,
+				dpio_dev->token);
+			dpio_close(dpio_dev->dpio, CMD_PRI_LOW,
+				dpio_dev->token);
+			rte_free(dpio_dev->dpio);
+		}
+		rte_free(dpio_dev);
+	}
+
+	/* Preventing re-use of the list with old entries */
+	TAILQ_INIT(&dpio_dev_list);
+
 	return -1;
 }
 
-- 
2.17.1

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (18 preceding siblings ...)
  2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 19/19] bus/fslmc: add support for secondary processes Shreyansh Jain
@ 2019-01-11 15:51     ` Ferruh Yigit
  2019-01-11 16:12       ` Ferruh Yigit
  2019-01-14  5:19     ` Shreyansh Jain
  20 siblings, 1 reply; 70+ messages in thread
From: Ferruh Yigit @ 2019-01-11 15:51 UTC (permalink / raw)
  To: Shreyansh Jain, dev

On 1/11/2019 12:24 PM, Shreyansh Jain wrote:
> (N: Original series was by Hemant - due to RC window timeline and
>     his unavailability, respining on his behalf)
> 
> This patch set covers following:
> 
> 1. Fixes in the existing NXP DPAA2 bus and net pmd
> 2. New object (DPDMUX) support in NIC driver for better classification
> 3. Improvements to support secondary process
> 4. Upgrade the low level QBMAN HW lib
> 
> History:
> v1->v2:
>  - Fix warning on Patch 20/20 - moved printfs to logging macro
>    and PRIx changes
>  - reset author of 07/20 as the signoff and author didn't match
>  - Validate over master (a958a5c07f4b5e)
>  - Reword patch headline/commit based on check-git-log script
> 
> v2->v3:
>  - Remove last (20/20) patch which was introducing a new API
>    within FSLMC layer
> 
> Akhil Goyal (1):
>   net/dpaa2: enable optional timestamp in mbuf
> 
> Hemant Agrawal (7):
>   bus/fslmc: fix to use correct physical core for logical core
>   net/dpaa2: fix bad check for not-null
>   bus/fslmc: fix to convert error msg to warning
>   bus/fslmc: upgrade to latest qbman library
>   bus/fslmc: add dynamic config for memback portal mode
>   bus/fslmc: rename portal pi index to consumer index
>   bus/fslmc: make portal func static
> 
> Nipun Gupta (4):
>   net/dpaa2: add dpdmux mc flib
>   bus/fslmc: add support for scanning DPDMUX object
>   net/dpaa2: add dpdmux initialization and configuration
>   net/dpaa2: add API to support custom hash key
> 
> Sachin Saxena (1):
>   bus/fslmc: fix to reset portal memory before use
> 
> Shreyansh Jain (5):
>   bus/fslmc: fix parse method for bus devices
>   net/dpaa2: fix device init for secondary process
>   mempool/dpaa2: support saving context of buffer pool
>   net/dpaa2: change reference to private device
>   bus/fslmc: add support for secondary processes
> 
> Youri Querry (1):
>   bus/fslmc: fix the ring mode to use correct cache settings

Hi Shreyansh,

Can I add your explicit ack to the series?

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements
  2019-01-11 15:51     ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Ferruh Yigit
@ 2019-01-11 16:12       ` Ferruh Yigit
  2019-01-14  5:20         ` Shreyansh Jain
  0 siblings, 1 reply; 70+ messages in thread
From: Ferruh Yigit @ 2019-01-11 16:12 UTC (permalink / raw)
  To: Shreyansh Jain, dev

On 1/11/2019 3:51 PM, Ferruh Yigit wrote:
> On 1/11/2019 12:24 PM, Shreyansh Jain wrote:
>> (N: Original series was by Hemant - due to RC window timeline and
>>     his unavailability, respining on his behalf)
>>
>> This patch set covers following:
>>
>> 1. Fixes in the existing NXP DPAA2 bus and net pmd
>> 2. New object (DPDMUX) support in NIC driver for better classification
>> 3. Improvements to support secondary process
>> 4. Upgrade the low level QBMAN HW lib
>>
>> History:
>> v1->v2:
>>  - Fix warning on Patch 20/20 - moved printfs to logging macro
>>    and PRIx changes
>>  - reset author of 07/20 as the signoff and author didn't match
>>  - Validate over master (a958a5c07f4b5e)
>>  - Reword patch headline/commit based on check-git-log script
>>
>> v2->v3:
>>  - Remove last (20/20) patch which was introducing a new API
>>    within FSLMC layer
>>
>> Akhil Goyal (1):
>>   net/dpaa2: enable optional timestamp in mbuf
>>
>> Hemant Agrawal (7):
>>   bus/fslmc: fix to use correct physical core for logical core
>>   net/dpaa2: fix bad check for not-null
>>   bus/fslmc: fix to convert error msg to warning
>>   bus/fslmc: upgrade to latest qbman library
>>   bus/fslmc: add dynamic config for memback portal mode
>>   bus/fslmc: rename portal pi index to consumer index
>>   bus/fslmc: make portal func static
>>
>> Nipun Gupta (4):
>>   net/dpaa2: add dpdmux mc flib
>>   bus/fslmc: add support for scanning DPDMUX object
>>   net/dpaa2: add dpdmux initialization and configuration
>>   net/dpaa2: add API to support custom hash key
>>
>> Sachin Saxena (1):
>>   bus/fslmc: fix to reset portal memory before use
>>
>> Shreyansh Jain (5):
>>   bus/fslmc: fix parse method for bus devices
>>   net/dpaa2: fix device init for secondary process
>>   mempool/dpaa2: support saving context of buffer pool
>>   net/dpaa2: change reference to private device
>>   bus/fslmc: add support for secondary processes
>>
>> Youri Querry (1):
>>   bus/fslmc: fix the ring mode to use correct cache settings
> 
> Hi Shreyansh,
> 
> Can I add your explicit ack to the series?

Series applied to dpdk-next-net/master, thanks.

(For ones from non-maintainers, Shreyansh's ack added)

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements
  2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
                       ` (19 preceding siblings ...)
  2019-01-11 15:51     ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Ferruh Yigit
@ 2019-01-14  5:19     ` Shreyansh Jain
  20 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-14  5:19 UTC (permalink / raw)
  To: ferruh.yigit; +Cc: dev

On 11/01/19 5:54 PM, Shreyansh Jain wrote:
> (N: Original series was by Hemant - due to RC window timeline and
>      his unavailability, respining on his behalf)
> 
> This patch set covers following:
> 
> 1. Fixes in the existing NXP DPAA2 bus and net pmd
> 2. New object (DPDMUX) support in NIC driver for better classification
> 3. Improvements to support secondary process
> 4. Upgrade the low level QBMAN HW lib
> 
> History:
> v1->v2:
>   - Fix warning on Patch 20/20 - moved printfs to logging macro
>     and PRIx changes
>   - reset author of 07/20 as the signoff and author didn't match
>   - Validate over master (a958a5c07f4b5e)
>   - Reword patch headline/commit based on check-git-log script
> 
> v2->v3:
>   - Remove last (20/20) patch which was introducing a new API
>     within FSLMC layer
> 
> Akhil Goyal (1):
>    net/dpaa2: enable optional timestamp in mbuf
> 
> Hemant Agrawal (7):
>    bus/fslmc: fix to use correct physical core for logical core
>    net/dpaa2: fix bad check for not-null
>    bus/fslmc: fix to convert error msg to warning
>    bus/fslmc: upgrade to latest qbman library
>    bus/fslmc: add dynamic config for memback portal mode
>    bus/fslmc: rename portal pi index to consumer index
>    bus/fslmc: make portal func static
> 
> Nipun Gupta (4):
>    net/dpaa2: add dpdmux mc flib
>    bus/fslmc: add support for scanning DPDMUX object
>    net/dpaa2: add dpdmux initialization and configuration
>    net/dpaa2: add API to support custom hash key
> 
> Sachin Saxena (1):
>    bus/fslmc: fix to reset portal memory before use
> 
> Shreyansh Jain (5):
>    bus/fslmc: fix parse method for bus devices
>    net/dpaa2: fix device init for secondary process
>    mempool/dpaa2: support saving context of buffer pool
>    net/dpaa2: change reference to private device
>    bus/fslmc: add support for secondary processes
> 
> Youri Querry (1):
>    bus/fslmc: fix the ring mode to use correct cache settings

Though the patches have already been applied, just for record, I am 
formally Ack'ing the series.

Series-Acked-by: Shreyansh Jain <shreyansh.jain@nxp.com>

^ permalink raw reply	[flat|nested] 70+ messages in thread

* Re: [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements
  2019-01-11 16:12       ` Ferruh Yigit
@ 2019-01-14  5:20         ` Shreyansh Jain
  0 siblings, 0 replies; 70+ messages in thread
From: Shreyansh Jain @ 2019-01-14  5:20 UTC (permalink / raw)
  To: Ferruh Yigit, dev

On 11/01/19 9:42 PM, Ferruh Yigit wrote:
> On 1/11/2019 3:51 PM, Ferruh Yigit wrote:
>> On 1/11/2019 12:24 PM, Shreyansh Jain wrote:
>>> (N: Original series was by Hemant - due to RC window timeline and
>>>      his unavailability, respining on his behalf)
>>>
>>> This patch set covers following:
>>>
>>> 1. Fixes in the existing NXP DPAA2 bus and net pmd
>>> 2. New object (DPDMUX) support in NIC driver for better classification
>>> 3. Improvements to support secondary process
>>> 4. Upgrade the low level QBMAN HW lib
>>>
>>> History:
>>> v1->v2:
>>>   - Fix warning on Patch 20/20 - moved printfs to logging macro
>>>     and PRIx changes
>>>   - reset author of 07/20 as the signoff and author didn't match
>>>   - Validate over master (a958a5c07f4b5e)
>>>   - Reword patch headline/commit based on check-git-log script
>>>
>>> v2->v3:
>>>   - Remove last (20/20) patch which was introducing a new API
>>>     within FSLMC layer
>>>
>>> Akhil Goyal (1):
>>>    net/dpaa2: enable optional timestamp in mbuf
>>>
>>> Hemant Agrawal (7):
>>>    bus/fslmc: fix to use correct physical core for logical core
>>>    net/dpaa2: fix bad check for not-null
>>>    bus/fslmc: fix to convert error msg to warning
>>>    bus/fslmc: upgrade to latest qbman library
>>>    bus/fslmc: add dynamic config for memback portal mode
>>>    bus/fslmc: rename portal pi index to consumer index
>>>    bus/fslmc: make portal func static
>>>
>>> Nipun Gupta (4):
>>>    net/dpaa2: add dpdmux mc flib
>>>    bus/fslmc: add support for scanning DPDMUX object
>>>    net/dpaa2: add dpdmux initialization and configuration
>>>    net/dpaa2: add API to support custom hash key
>>>
>>> Sachin Saxena (1):
>>>    bus/fslmc: fix to reset portal memory before use
>>>
>>> Shreyansh Jain (5):
>>>    bus/fslmc: fix parse method for bus devices
>>>    net/dpaa2: fix device init for secondary process
>>>    mempool/dpaa2: support saving context of buffer pool
>>>    net/dpaa2: change reference to private device
>>>    bus/fslmc: add support for secondary processes
>>>
>>> Youri Querry (1):
>>>    bus/fslmc: fix the ring mode to use correct cache settings
>>
>> Hi Shreyansh,
>>
>> Can I add your explicit ack to the series?
> 
> Series applied to dpdk-next-net/master, thanks.
> 
> (For ones from non-maintainers, Shreyansh's ack added)
> 

Hi Ferruh,

Apologies - I didn't notice this email earlier. I am OK with ACK you 
have applied and I have also replied back with a formal ACK to V3.

-
Shreyansh

^ permalink raw reply	[flat|nested] 70+ messages in thread

end of thread, other threads:[~2019-01-14  5:20 UTC | newest]

Thread overview: 70+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-27  6:22 [dpdk-dev] [PATCH 00/20] NXP DPAA2 fixes and enhancements Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 01/20] bus/fslmc: fix to reset portal memory before use Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 02/20] bus/fslmc: fix the ring mode to use correct cache settings Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 03/20] bus/fslmc: fix to use correct physical core for logical core Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 04/20] net/dpaa2: fix bad check for not-null Hemant Agrawal
2018-12-27  6:22 ` [dpdk-dev] [PATCH 05/20] bus/fslmc: fix to convert error msg to warning Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 06/20] bus/fslmc: fix parse method for bus devices Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 07/20] net/dpaa2: fix device init for secondary process Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 08/20] net/dpaa2: enable optional timestamp in mbuf Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 09/20] bus/fslmc: upgrade to latest qbman library Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 10/20] bus/fslmc: add dynamic config for memback portal mode Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 11/20] bus/fslmc: rename portal pi index to consumer index Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 12/20] bus/fslmc: make portal func static Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 13/20] net/dpaa2: add dpdmux mc flib Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 14/20] bus/fslmc: add support for scanning DPDMUX object Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 15/20] net/dpaa2: add dpdmux initialization and configuration Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 16/20] net/dpaa2: add API to support custom hash key Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 17/20] mempool/dpaa2: support saving context of buffer pool Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 18/20] net/dpaa2: change ref of device to private device Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 19/20] bus/fslmc: add support for secondary processes Hemant Agrawal
2018-12-27  6:23 ` [dpdk-dev] [PATCH 20/20] bus/fslmc: add function to map any addr via VFIO Hemant Agrawal
2019-01-08 14:10   ` Ferruh Yigit
2019-01-10  9:58     ` Shreyansh Jain
2019-01-11 11:58       ` Ferruh Yigit
2019-01-11 12:16         ` Shreyansh Jain
2019-01-11 11:57 ` [dpdk-dev] [PATCH v2 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 01/20] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 02/20] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
2019-01-11 11:57   ` [dpdk-dev] [PATCH v2 03/20] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 04/20] net/dpaa2: fix bad check for not-null Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 05/20] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 06/20] bus/fslmc: fix parse method for bus devices Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 07/20] net/dpaa2: fix device init for secondary process Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 08/20] net/dpaa2: enable optional timestamp in mbuf Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 09/20] bus/fslmc: upgrade to latest qbman library Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 10/20] bus/fslmc: add dynamic config for memback portal mode Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 11/20] bus/fslmc: rename portal pi index to consumer index Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 12/20] bus/fslmc: make portal func static Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 13/20] net/dpaa2: add dpdmux mc flib Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 14/20] bus/fslmc: add support for scanning DPDMUX object Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 15/20] net/dpaa2: add dpdmux initialization and configuration Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 16/20] net/dpaa2: add API to support custom hash key Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 17/20] mempool/dpaa2: support saving context of buffer pool Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 18/20] net/dpaa2: change reference to private device Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 19/20] bus/fslmc: add support for secondary processes Shreyansh Jain
2019-01-11 11:58   ` [dpdk-dev] [PATCH v2 20/20] bus/fslmc: add function to map any addr via VFIO Shreyansh Jain
2019-01-11 12:24   ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 01/19] bus/fslmc: fix to reset portal memory before use Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 02/19] bus/fslmc: fix the ring mode to use correct cache settings Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 03/19] bus/fslmc: fix to use correct physical core for logical core Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 04/19] net/dpaa2: fix bad check for not-null Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 05/19] bus/fslmc: fix to convert error msg to warning Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 06/19] bus/fslmc: fix parse method for bus devices Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 07/19] net/dpaa2: fix device init for secondary process Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 08/19] net/dpaa2: enable optional timestamp in mbuf Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 09/19] bus/fslmc: upgrade to latest qbman library Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 10/19] bus/fslmc: add dynamic config for memback portal mode Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 11/19] bus/fslmc: rename portal pi index to consumer index Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 12/19] bus/fslmc: make portal func static Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 13/19] net/dpaa2: add dpdmux mc flib Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 14/19] bus/fslmc: add support for scanning DPDMUX object Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 15/19] net/dpaa2: add dpdmux initialization and configuration Shreyansh Jain
2019-01-11 12:24     ` [dpdk-dev] [PATCH v3 16/19] net/dpaa2: add API to support custom hash key Shreyansh Jain
2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 17/19] mempool/dpaa2: support saving context of buffer pool Shreyansh Jain
2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 18/19] net/dpaa2: change reference to private device Shreyansh Jain
2019-01-11 12:25     ` [dpdk-dev] [PATCH v3 19/19] bus/fslmc: add support for secondary processes Shreyansh Jain
2019-01-11 15:51     ` [dpdk-dev] [PATCH v3 00/20] NXP DPAA2 fixes and enhancements Ferruh Yigit
2019-01-11 16:12       ` Ferruh Yigit
2019-01-14  5:20         ` Shreyansh Jain
2019-01-14  5:19     ` Shreyansh Jain

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git