* [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process
2019-03-26 12:01 [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Hemant Agrawal
@ 2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` [dpdk-dev] [PATCH 2/4] mempool/dpaa: bp info dynamic allocation for multiprocess Hemant Agrawal
` (3 subsequent siblings)
4 siblings, 0 replies; 10+ messages in thread
From: Hemant Agrawal @ 2019-03-26 12:01 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
A reference to qman_fq_lookup_table need to be saved in each
fq, so that it is retrieved while in running secondary process.
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
drivers/bus/dpaa/base/qbman/qman.c | 8 +++++++-
drivers/bus/dpaa/include/fsl_qman.h | 6 ++++++
drivers/bus/dpaa/rte_bus_dpaa_version.map | 7 +++++++
drivers/net/dpaa/dpaa_ethdev.c | 6 ++++++
4 files changed, 26 insertions(+), 1 deletion(-)
diff --git a/drivers/bus/dpaa/base/qbman/qman.c b/drivers/bus/dpaa/base/qbman/qman.c
index dc64d0896..c6f7d7bb3 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
*
* Copyright 2008-2016 Freescale Semiconductor Inc.
- * Copyright 2017 NXP
+ * Copyright 2017,2019 NXP
*
*/
@@ -167,6 +167,11 @@ int qman_setup_fq_lookup_table(size_t num_entries)
return 0;
}
+void qman_set_fq_lookup_table(void **fq_table)
+{
+ qman_fq_lookup_table = fq_table;
+}
+
/* global structure that maintains fq object mapping */
static DEFINE_SPINLOCK(fq_hash_table_lock);
@@ -1408,6 +1413,7 @@ int qman_create_fq(u32 fqid, u32 flags, struct qman_fq *fq)
pr_info("Find empty table entry failed\n");
return -ENOMEM;
}
+ fq->qman_fq_lookup_table = qman_fq_lookup_table;
#endif
if (!(flags & QMAN_FQ_FLAG_AS_IS) || (flags & QMAN_FQ_FLAG_NO_MODIFY))
return 0;
diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index e43841499..ef598ccff 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -1,6 +1,7 @@
/* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
*
* Copyright 2008-2012 Freescale Semiconductor, Inc.
+ * Copyright 2019 NXP
*
*/
@@ -1233,6 +1234,7 @@ struct qman_fq {
struct rb_node node;
#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ void **qman_fq_lookup_table;
u32 key;
#endif
};
@@ -1307,6 +1309,10 @@ struct qman_cgr {
#define QMAN_CGR_FLAG_USE_INIT 0x00000001
#define QMAN_CGR_MODE_FRAME 0x00000001
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+void qman_set_fq_lookup_table(void **table);
+#endif
+
/**
* qman_get_portal_index - get portal configuration index
*/
diff --git a/drivers/bus/dpaa/rte_bus_dpaa_version.map b/drivers/bus/dpaa/rte_bus_dpaa_version.map
index 70076c7ac..c88deaf7f 100644
--- a/drivers/bus/dpaa/rte_bus_dpaa_version.map
+++ b/drivers/bus/dpaa/rte_bus_dpaa_version.map
@@ -116,3 +116,10 @@ DPDK_18.11 {
local: *;
} DPDK_18.08;
+
+DPDK_19.05 {
+ global:
+ qman_set_fq_lookup_table;
+
+ local: *;
+} DPDK_18.11;
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index ba66aa2a0..d42ac6286 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1225,11 +1225,17 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
PMD_INIT_FUNC_TRACE();
+ dpaa_intf = eth_dev->data->dev_private;
/* For secondary processes, the primary has done all the work */
if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
eth_dev->dev_ops = &dpaa_devops;
/* Plugging of UCODE burst API not supported in Secondary */
eth_dev->rx_pkt_burst = dpaa_eth_queue_rx;
+ eth_dev->tx_pkt_burst = dpaa_eth_queue_tx;
+#ifdef CONFIG_FSL_QMAN_FQ_LOOKUP
+ qman_set_fq_lookup_table(
+ dpaa_intf->rx_queues->qman_fq_lookup_table);
+#endif
return 0;
}
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 2/4] mempool/dpaa: bp info dynamic allocation for multiprocess
2019-03-26 12:01 [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal
@ 2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` [dpdk-dev] [PATCH 3/4] bus/dpaa: delay fman device list to bus probe Hemant Agrawal
` (2 subsequent siblings)
4 siblings, 1 reply; 10+ messages in thread
From: Hemant Agrawal @ 2019-03-26 12:01 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
rte_dpaa_bpid_info shall be allocated with the hugepage memory
which can be shared across processes.
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
drivers/bus/dpaa/include/fsl_qman.h | 1 +
drivers/mempool/dpaa/dpaa_mempool.c | 10 +++++++++-
drivers/mempool/dpaa/dpaa_mempool.h | 4 ++--
drivers/net/dpaa/dpaa_ethdev.c | 1 +
drivers/net/dpaa/dpaa_rxtx.c | 6 +++++-
5 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index ef598ccff..e5cccbbea 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -1225,6 +1225,7 @@ struct qman_fq {
struct rte_event ev;
/* affined portal in case of static queue */
struct qman_portal *qp;
+ struct dpaa_bp_info *bp_array;
volatile unsigned long flags;
diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index 021b366fe..003081772 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -35,7 +35,7 @@
struct dpaa_memseg_list rte_dpaa_memsegs
= TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
-struct dpaa_bp_info rte_dpaa_bpid_info[DPAA_MAX_BPOOLS];
+struct dpaa_bp_info *rte_dpaa_bpid_info;
static int
dpaa_mbuf_create_pool(struct rte_mempool *mp)
@@ -74,6 +74,14 @@ dpaa_mbuf_create_pool(struct rte_mempool *mp)
DPAA_MEMPOOL_WARN("drained %u bufs from BPID %d",
num_bufs, bpid);
+ if (rte_dpaa_bpid_info == NULL) {
+ rte_dpaa_bpid_info = (struct dpaa_bp_info *)rte_zmalloc(NULL,
+ sizeof(struct dpaa_bp_info) * DPAA_MAX_BPOOLS,
+ RTE_CACHE_LINE_SIZE);
+ if (rte_dpaa_bpid_info == NULL)
+ return -ENOMEM;
+ }
+
rte_dpaa_bpid_info[bpid].mp = mp;
rte_dpaa_bpid_info[bpid].bpid = bpid;
rte_dpaa_bpid_info[bpid].size = mp->elt_size;
diff --git a/drivers/mempool/dpaa/dpaa_mempool.h b/drivers/mempool/dpaa/dpaa_mempool.h
index 533e1c6e2..f69e11f01 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.h
+++ b/drivers/mempool/dpaa/dpaa_mempool.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
- * Copyright 2017 NXP
+ * Copyright 2017,2019 NXP
*
*/
#ifndef __DPAA_MEMPOOL_H__
@@ -54,7 +54,7 @@ DPAA_MEMPOOL_PTOV(struct dpaa_bp_info *bp_info __rte_unused, uint64_t addr)
#define DPAA_MEMPOOL_TO_BPID(__mp) \
(((struct dpaa_bp_info *)__mp->pool_data)->bpid)
-extern struct dpaa_bp_info rte_dpaa_bpid_info[DPAA_MAX_BPOOLS];
+extern struct dpaa_bp_info *rte_dpaa_bpid_info;
#define DPAA_BPID_TO_POOL_INFO(__bpid) (&rte_dpaa_bpid_info[__bpid])
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index d42ac6286..d124169c5 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -673,6 +673,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
rxq->is_static = true;
}
+ rxq->bp_array = rte_dpaa_bpid_info;
dev->data->rx_queues[queue_idx] = rxq;
/* configure the CGR size as per the desc size */
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index c4471c227..a4085f47e 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2017 NXP
+ * Copyright 2017,2019 NXP
*
*/
@@ -598,6 +598,10 @@ uint16_t dpaa_eth_queue_rx(void *q,
int num_rx_bufs, ret;
uint32_t vdqcr_flags = 0;
+ if (unlikely(rte_dpaa_bpid_info == NULL &&
+ rte_eal_process_type() == RTE_PROC_SECONDARY))
+ rte_dpaa_bpid_info = fq->bp_array;
+
if (likely(fq->is_static))
return dpaa_eth_queue_portal_rx(fq, bufs, nb_bufs);
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 2/4] mempool/dpaa: bp info dynamic allocation for multiprocess
2019-03-26 12:01 ` [dpdk-dev] [PATCH 2/4] mempool/dpaa: bp info dynamic allocation for multiprocess Hemant Agrawal
@ 2019-03-26 12:01 ` Hemant Agrawal
0 siblings, 0 replies; 10+ messages in thread
From: Hemant Agrawal @ 2019-03-26 12:01 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Shreyansh Jain, Akhil Goyal
From: Akhil Goyal <akhil.goyal@nxp.com>
rte_dpaa_bpid_info shall be allocated with the hugepage memory
which can be shared across processes.
Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
---
drivers/bus/dpaa/include/fsl_qman.h | 1 +
drivers/mempool/dpaa/dpaa_mempool.c | 10 +++++++++-
drivers/mempool/dpaa/dpaa_mempool.h | 4 ++--
drivers/net/dpaa/dpaa_ethdev.c | 1 +
drivers/net/dpaa/dpaa_rxtx.c | 6 +++++-
5 files changed, 18 insertions(+), 4 deletions(-)
diff --git a/drivers/bus/dpaa/include/fsl_qman.h b/drivers/bus/dpaa/include/fsl_qman.h
index ef598ccff..e5cccbbea 100644
--- a/drivers/bus/dpaa/include/fsl_qman.h
+++ b/drivers/bus/dpaa/include/fsl_qman.h
@@ -1225,6 +1225,7 @@ struct qman_fq {
struct rte_event ev;
/* affined portal in case of static queue */
struct qman_portal *qp;
+ struct dpaa_bp_info *bp_array;
volatile unsigned long flags;
diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c
index 021b366fe..003081772 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.c
+++ b/drivers/mempool/dpaa/dpaa_mempool.c
@@ -35,7 +35,7 @@
struct dpaa_memseg_list rte_dpaa_memsegs
= TAILQ_HEAD_INITIALIZER(rte_dpaa_memsegs);
-struct dpaa_bp_info rte_dpaa_bpid_info[DPAA_MAX_BPOOLS];
+struct dpaa_bp_info *rte_dpaa_bpid_info;
static int
dpaa_mbuf_create_pool(struct rte_mempool *mp)
@@ -74,6 +74,14 @@ dpaa_mbuf_create_pool(struct rte_mempool *mp)
DPAA_MEMPOOL_WARN("drained %u bufs from BPID %d",
num_bufs, bpid);
+ if (rte_dpaa_bpid_info == NULL) {
+ rte_dpaa_bpid_info = (struct dpaa_bp_info *)rte_zmalloc(NULL,
+ sizeof(struct dpaa_bp_info) * DPAA_MAX_BPOOLS,
+ RTE_CACHE_LINE_SIZE);
+ if (rte_dpaa_bpid_info == NULL)
+ return -ENOMEM;
+ }
+
rte_dpaa_bpid_info[bpid].mp = mp;
rte_dpaa_bpid_info[bpid].bpid = bpid;
rte_dpaa_bpid_info[bpid].size = mp->elt_size;
diff --git a/drivers/mempool/dpaa/dpaa_mempool.h b/drivers/mempool/dpaa/dpaa_mempool.h
index 533e1c6e2..f69e11f01 100644
--- a/drivers/mempool/dpaa/dpaa_mempool.h
+++ b/drivers/mempool/dpaa/dpaa_mempool.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
- * Copyright 2017 NXP
+ * Copyright 2017,2019 NXP
*
*/
#ifndef __DPAA_MEMPOOL_H__
@@ -54,7 +54,7 @@ DPAA_MEMPOOL_PTOV(struct dpaa_bp_info *bp_info __rte_unused, uint64_t addr)
#define DPAA_MEMPOOL_TO_BPID(__mp) \
(((struct dpaa_bp_info *)__mp->pool_data)->bpid)
-extern struct dpaa_bp_info rte_dpaa_bpid_info[DPAA_MAX_BPOOLS];
+extern struct dpaa_bp_info *rte_dpaa_bpid_info;
#define DPAA_BPID_TO_POOL_INFO(__bpid) (&rte_dpaa_bpid_info[__bpid])
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index d42ac6286..d124169c5 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -673,6 +673,7 @@ int dpaa_eth_rx_queue_setup(struct rte_eth_dev *dev, uint16_t queue_idx,
rxq->is_static = true;
}
+ rxq->bp_array = rte_dpaa_bpid_info;
dev->data->rx_queues[queue_idx] = rxq;
/* configure the CGR size as per the desc size */
diff --git a/drivers/net/dpaa/dpaa_rxtx.c b/drivers/net/dpaa/dpaa_rxtx.c
index c4471c227..a4085f47e 100644
--- a/drivers/net/dpaa/dpaa_rxtx.c
+++ b/drivers/net/dpaa/dpaa_rxtx.c
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright 2016 Freescale Semiconductor, Inc. All rights reserved.
- * Copyright 2017 NXP
+ * Copyright 2017,2019 NXP
*
*/
@@ -598,6 +598,10 @@ uint16_t dpaa_eth_queue_rx(void *q,
int num_rx_bufs, ret;
uint32_t vdqcr_flags = 0;
+ if (unlikely(rte_dpaa_bpid_info == NULL &&
+ rte_eal_process_type() == RTE_PROC_SECONDARY))
+ rte_dpaa_bpid_info = fq->bp_array;
+
if (likely(fq->is_static))
return dpaa_eth_queue_portal_rx(fq, bufs, nb_bufs);
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 3/4] bus/dpaa: delay fman device list to bus probe
2019-03-26 12:01 [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` [dpdk-dev] [PATCH 2/4] mempool/dpaa: bp info dynamic allocation for multiprocess Hemant Agrawal
@ 2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` [dpdk-dev] [PATCH 4/4] net/dpaa2: add support for flow table flush Hemant Agrawal
2019-03-29 13:33 ` [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Thomas Monjalon
4 siblings, 1 reply; 10+ messages in thread
From: Hemant Agrawal @ 2019-03-26 12:01 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Shreyansh Jain
The fman device list need to be accessed across processes.
The hw device structures should be allocated with rte_calloc
instead of calloc. The rte_calloc is not available at the
time of bus scan, so better prepare the device list at probe.
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
drivers/bus/dpaa/base/fman/fman.c | 11 +--
drivers/bus/dpaa/base/fman/netcfg_layer.c | 6 +-
drivers/bus/dpaa/dpaa_bus.c | 83 +++++++++++++----------
drivers/bus/dpaa/rte_dpaa_bus.h | 1 +
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
5 files changed, 60 insertions(+), 43 deletions(-)
diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c
index 06762e0f4..8fa9b8cae 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -12,6 +12,7 @@
/* This header declares the driver interface we implement */
#include <fman.h>
#include <of.h>
+#include <rte_malloc.h>
#include <rte_dpaa_logs.h>
#include <rte_string_fns.h>
@@ -177,7 +178,7 @@ fman_if_init(const struct device_node *dpa_node)
mprop = "fsl,fman-mac";
/* Allocate an object for this network interface */
- __if = malloc(sizeof(*__if));
+ __if = rte_malloc(NULL, sizeof(*__if), RTE_CACHE_LINE_SIZE);
if (!__if) {
FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*__if));
goto err;
@@ -433,7 +434,7 @@ fman_if_init(const struct device_node *dpa_node)
uint64_t bpool_host[6] = {0};
const char *pname;
/* Allocate an object for the pool */
- bpool = malloc(sizeof(*bpool));
+ bpool = rte_malloc(NULL, sizeof(*bpool), RTE_CACHE_LINE_SIZE);
if (!bpool) {
FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*bpool));
goto err;
@@ -443,7 +444,7 @@ fman_if_init(const struct device_node *dpa_node)
if (!pool_node) {
FMAN_ERR(-ENXIO, "%s: bad fsl,bman-buffer-pools\n",
dname);
- free(bpool);
+ rte_free(bpool);
goto err;
}
pname = pool_node->full_name;
@@ -451,7 +452,7 @@ fman_if_init(const struct device_node *dpa_node)
prop = of_get_property(pool_node, "fsl,bpid", &proplen);
if (!prop) {
FMAN_ERR(-EINVAL, "%s: no fsl,bpid\n", pname);
- free(bpool);
+ rte_free(bpool);
goto err;
}
assert(proplen == sizeof(*prop));
@@ -574,7 +575,7 @@ fman_finish(void)
-errno, strerror(errno));
printf("Tearing down %s\n", __if->node_path);
list_del(&__if->__if.node);
- free(__if);
+ rte_free(__if);
}
close(fman_ccsr_map_fd);
diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c
index 6b5224203..bf8c77265 100644
--- a/drivers/bus/dpaa/base/fman/netcfg_layer.c
+++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c
@@ -114,7 +114,7 @@ netcfg_acquire(void)
size = sizeof(*netcfg) +
(num_ports * sizeof(struct fm_eth_port_cfg));
- netcfg = calloc(1, size);
+ netcfg = rte_calloc(NULL, 1, size, 0);
if (unlikely(netcfg == NULL)) {
DPAA_BUS_LOG(ERR, "Unable to allocat mem for netcfg");
goto error;
@@ -141,7 +141,7 @@ netcfg_acquire(void)
error:
if (netcfg) {
- free(netcfg);
+ rte_free(netcfg);
netcfg = NULL;
}
@@ -151,7 +151,7 @@ netcfg_acquire(void)
void
netcfg_release(struct netcfg_info *cfg_ptr)
{
- free(cfg_ptr);
+ rte_free(cfg_ptr);
/* Close socket for shared interfaces */
if (skfd >= 0) {
close(skfd);
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index c7da96f8d..ac20eccd5 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -442,40 +442,8 @@ rte_dpaa_bus_scan(void)
RTE_LOG(DEBUG, EAL, "DPAA Bus not present. Skipping.\n");
return 0;
}
-
- /* Load the device-tree driver */
- ret = of_init();
- if (ret) {
- DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret);
- return -1;
- }
-
- /* Get the interface configurations from device-tree */
- dpaa_netcfg = netcfg_acquire();
- if (!dpaa_netcfg) {
- DPAA_BUS_LOG(ERR, "netcfg_acquire failed");
- return -EINVAL;
- }
-
- RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n");
-
- if (!dpaa_netcfg->num_ethports) {
- DPAA_BUS_LOG(INFO, "no network interfaces available");
- /* This is not an error */
- return 0;
- }
-
-#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
- dump_netcfg(dpaa_netcfg);
-#endif
-
- DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d",
- dpaa_netcfg->num_ethports);
- ret = dpaa_create_device_list();
- if (ret) {
- DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret);
- return ret;
- }
+ /* detected DPAA devices */
+ rte_dpaa_bus.detected = 1;
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
@@ -533,6 +501,47 @@ rte_dpaa_device_match(struct rte_dpaa_driver *drv,
return -1;
}
+static int
+rte_dpaa_bus_dev_build(void)
+{
+ int ret;
+
+ /* Load the device-tree driver */
+ ret = of_init();
+ if (ret) {
+ DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret);
+ return -1;
+ }
+
+ /* Get the interface configurations from device-tree */
+ dpaa_netcfg = netcfg_acquire();
+ if (!dpaa_netcfg) {
+ DPAA_BUS_LOG(ERR, "netcfg_acquire failed");
+ return -EINVAL;
+ }
+
+ RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n");
+
+ if (!dpaa_netcfg->num_ethports) {
+ DPAA_BUS_LOG(INFO, "no network interfaces available");
+ /* This is not an error */
+ return 0;
+ }
+
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+ dump_netcfg(dpaa_netcfg);
+#endif
+
+ DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d",
+ dpaa_netcfg->num_ethports);
+ ret = dpaa_create_device_list();
+ if (ret) {
+ DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret);
+ return ret;
+ }
+ return 0;
+}
+
static int
rte_dpaa_bus_probe(void)
{
@@ -544,6 +553,12 @@ rte_dpaa_bus_probe(void)
int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST;
/* If DPAA bus is not present nothing needs to be done */
+ if (!rte_dpaa_bus.detected)
+ return 0;
+
+ rte_dpaa_bus_dev_build();
+
+ /* If no device present on DPAA bus nothing needs to be done */
if (TAILQ_EMPTY(&rte_dpaa_bus.device_list))
return 0;
diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h
index 1d580a000..72fbbfce7 100644
--- a/drivers/bus/dpaa/rte_dpaa_bus.h
+++ b/drivers/bus/dpaa/rte_dpaa_bus.h
@@ -54,6 +54,7 @@ struct rte_dpaa_bus {
struct rte_dpaa_device_list device_list;
struct rte_dpaa_driver_list driver_list;
int device_count;
+ int detected;
};
struct dpaa_device_id {
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index d124169c5..b1fac8fa7 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1354,7 +1354,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
/* reset bpool list, initialize bpool dynamically */
list_for_each_entry_safe(bp, tmp_bp, &cfg->fman_if->bpool_list, node) {
list_del(&bp->node);
- free(bp);
+ rte_free(bp);
}
/* Populate ethdev structure */
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 3/4] bus/dpaa: delay fman device list to bus probe
2019-03-26 12:01 ` [dpdk-dev] [PATCH 3/4] bus/dpaa: delay fman device list to bus probe Hemant Agrawal
@ 2019-03-26 12:01 ` Hemant Agrawal
0 siblings, 0 replies; 10+ messages in thread
From: Hemant Agrawal @ 2019-03-26 12:01 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Shreyansh Jain
The fman device list need to be accessed across processes.
The hw device structures should be allocated with rte_calloc
instead of calloc. The rte_calloc is not available at the
time of bus scan, so better prepare the device list at probe.
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
drivers/bus/dpaa/base/fman/fman.c | 11 +--
drivers/bus/dpaa/base/fman/netcfg_layer.c | 6 +-
drivers/bus/dpaa/dpaa_bus.c | 83 +++++++++++++----------
drivers/bus/dpaa/rte_dpaa_bus.h | 1 +
drivers/net/dpaa/dpaa_ethdev.c | 2 +-
5 files changed, 60 insertions(+), 43 deletions(-)
diff --git a/drivers/bus/dpaa/base/fman/fman.c b/drivers/bus/dpaa/base/fman/fman.c
index 06762e0f4..8fa9b8cae 100644
--- a/drivers/bus/dpaa/base/fman/fman.c
+++ b/drivers/bus/dpaa/base/fman/fman.c
@@ -12,6 +12,7 @@
/* This header declares the driver interface we implement */
#include <fman.h>
#include <of.h>
+#include <rte_malloc.h>
#include <rte_dpaa_logs.h>
#include <rte_string_fns.h>
@@ -177,7 +178,7 @@ fman_if_init(const struct device_node *dpa_node)
mprop = "fsl,fman-mac";
/* Allocate an object for this network interface */
- __if = malloc(sizeof(*__if));
+ __if = rte_malloc(NULL, sizeof(*__if), RTE_CACHE_LINE_SIZE);
if (!__if) {
FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*__if));
goto err;
@@ -433,7 +434,7 @@ fman_if_init(const struct device_node *dpa_node)
uint64_t bpool_host[6] = {0};
const char *pname;
/* Allocate an object for the pool */
- bpool = malloc(sizeof(*bpool));
+ bpool = rte_malloc(NULL, sizeof(*bpool), RTE_CACHE_LINE_SIZE);
if (!bpool) {
FMAN_ERR(-ENOMEM, "malloc(%zu)\n", sizeof(*bpool));
goto err;
@@ -443,7 +444,7 @@ fman_if_init(const struct device_node *dpa_node)
if (!pool_node) {
FMAN_ERR(-ENXIO, "%s: bad fsl,bman-buffer-pools\n",
dname);
- free(bpool);
+ rte_free(bpool);
goto err;
}
pname = pool_node->full_name;
@@ -451,7 +452,7 @@ fman_if_init(const struct device_node *dpa_node)
prop = of_get_property(pool_node, "fsl,bpid", &proplen);
if (!prop) {
FMAN_ERR(-EINVAL, "%s: no fsl,bpid\n", pname);
- free(bpool);
+ rte_free(bpool);
goto err;
}
assert(proplen == sizeof(*prop));
@@ -574,7 +575,7 @@ fman_finish(void)
-errno, strerror(errno));
printf("Tearing down %s\n", __if->node_path);
list_del(&__if->__if.node);
- free(__if);
+ rte_free(__if);
}
close(fman_ccsr_map_fd);
diff --git a/drivers/bus/dpaa/base/fman/netcfg_layer.c b/drivers/bus/dpaa/base/fman/netcfg_layer.c
index 6b5224203..bf8c77265 100644
--- a/drivers/bus/dpaa/base/fman/netcfg_layer.c
+++ b/drivers/bus/dpaa/base/fman/netcfg_layer.c
@@ -114,7 +114,7 @@ netcfg_acquire(void)
size = sizeof(*netcfg) +
(num_ports * sizeof(struct fm_eth_port_cfg));
- netcfg = calloc(1, size);
+ netcfg = rte_calloc(NULL, 1, size, 0);
if (unlikely(netcfg == NULL)) {
DPAA_BUS_LOG(ERR, "Unable to allocat mem for netcfg");
goto error;
@@ -141,7 +141,7 @@ netcfg_acquire(void)
error:
if (netcfg) {
- free(netcfg);
+ rte_free(netcfg);
netcfg = NULL;
}
@@ -151,7 +151,7 @@ netcfg_acquire(void)
void
netcfg_release(struct netcfg_info *cfg_ptr)
{
- free(cfg_ptr);
+ rte_free(cfg_ptr);
/* Close socket for shared interfaces */
if (skfd >= 0) {
close(skfd);
diff --git a/drivers/bus/dpaa/dpaa_bus.c b/drivers/bus/dpaa/dpaa_bus.c
index c7da96f8d..ac20eccd5 100644
--- a/drivers/bus/dpaa/dpaa_bus.c
+++ b/drivers/bus/dpaa/dpaa_bus.c
@@ -442,40 +442,8 @@ rte_dpaa_bus_scan(void)
RTE_LOG(DEBUG, EAL, "DPAA Bus not present. Skipping.\n");
return 0;
}
-
- /* Load the device-tree driver */
- ret = of_init();
- if (ret) {
- DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret);
- return -1;
- }
-
- /* Get the interface configurations from device-tree */
- dpaa_netcfg = netcfg_acquire();
- if (!dpaa_netcfg) {
- DPAA_BUS_LOG(ERR, "netcfg_acquire failed");
- return -EINVAL;
- }
-
- RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n");
-
- if (!dpaa_netcfg->num_ethports) {
- DPAA_BUS_LOG(INFO, "no network interfaces available");
- /* This is not an error */
- return 0;
- }
-
-#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
- dump_netcfg(dpaa_netcfg);
-#endif
-
- DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d",
- dpaa_netcfg->num_ethports);
- ret = dpaa_create_device_list();
- if (ret) {
- DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret);
- return ret;
- }
+ /* detected DPAA devices */
+ rte_dpaa_bus.detected = 1;
/* create the key, supplying a function that'll be invoked
* when a portal affined thread will be deleted.
@@ -533,6 +501,47 @@ rte_dpaa_device_match(struct rte_dpaa_driver *drv,
return -1;
}
+static int
+rte_dpaa_bus_dev_build(void)
+{
+ int ret;
+
+ /* Load the device-tree driver */
+ ret = of_init();
+ if (ret) {
+ DPAA_BUS_LOG(ERR, "of_init failed with ret: %d", ret);
+ return -1;
+ }
+
+ /* Get the interface configurations from device-tree */
+ dpaa_netcfg = netcfg_acquire();
+ if (!dpaa_netcfg) {
+ DPAA_BUS_LOG(ERR, "netcfg_acquire failed");
+ return -EINVAL;
+ }
+
+ RTE_LOG(NOTICE, EAL, "DPAA Bus Detected\n");
+
+ if (!dpaa_netcfg->num_ethports) {
+ DPAA_BUS_LOG(INFO, "no network interfaces available");
+ /* This is not an error */
+ return 0;
+ }
+
+#ifdef RTE_LIBRTE_DPAA_DEBUG_DRIVER
+ dump_netcfg(dpaa_netcfg);
+#endif
+
+ DPAA_BUS_LOG(DEBUG, "Number of ethernet devices = %d",
+ dpaa_netcfg->num_ethports);
+ ret = dpaa_create_device_list();
+ if (ret) {
+ DPAA_BUS_LOG(ERR, "Unable to create device list. (%d)", ret);
+ return ret;
+ }
+ return 0;
+}
+
static int
rte_dpaa_bus_probe(void)
{
@@ -544,6 +553,12 @@ rte_dpaa_bus_probe(void)
int probe_all = rte_dpaa_bus.bus.conf.scan_mode != RTE_BUS_SCAN_WHITELIST;
/* If DPAA bus is not present nothing needs to be done */
+ if (!rte_dpaa_bus.detected)
+ return 0;
+
+ rte_dpaa_bus_dev_build();
+
+ /* If no device present on DPAA bus nothing needs to be done */
if (TAILQ_EMPTY(&rte_dpaa_bus.device_list))
return 0;
diff --git a/drivers/bus/dpaa/rte_dpaa_bus.h b/drivers/bus/dpaa/rte_dpaa_bus.h
index 1d580a000..72fbbfce7 100644
--- a/drivers/bus/dpaa/rte_dpaa_bus.h
+++ b/drivers/bus/dpaa/rte_dpaa_bus.h
@@ -54,6 +54,7 @@ struct rte_dpaa_bus {
struct rte_dpaa_device_list device_list;
struct rte_dpaa_driver_list driver_list;
int device_count;
+ int detected;
};
struct dpaa_device_id {
diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c
index d124169c5..b1fac8fa7 100644
--- a/drivers/net/dpaa/dpaa_ethdev.c
+++ b/drivers/net/dpaa/dpaa_ethdev.c
@@ -1354,7 +1354,7 @@ dpaa_dev_init(struct rte_eth_dev *eth_dev)
/* reset bpool list, initialize bpool dynamically */
list_for_each_entry_safe(bp, tmp_bp, &cfg->fman_if->bpool_list, node) {
list_del(&bp->node);
- free(bp);
+ rte_free(bp);
}
/* Populate ethdev structure */
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 4/4] net/dpaa2: add support for flow table flush
2019-03-26 12:01 [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Hemant Agrawal
` (2 preceding siblings ...)
2019-03-26 12:01 ` [dpdk-dev] [PATCH 3/4] bus/dpaa: delay fman device list to bus probe Hemant Agrawal
@ 2019-03-26 12:01 ` Hemant Agrawal
2019-03-26 12:01 ` Hemant Agrawal
2019-03-29 13:33 ` [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Thomas Monjalon
4 siblings, 1 reply; 10+ messages in thread
From: Hemant Agrawal @ 2019-03-26 12:01 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Shreyansh Jain
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
drivers/net/dpaa2/dpaa2_ethdev.c | 2 +
drivers/net/dpaa2/dpaa2_ethdev.h | 2 +
drivers/net/dpaa2/dpaa2_flow.c | 118 +++++++++++++++++++++----------
3 files changed, 85 insertions(+), 37 deletions(-)
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index c92edecf3..3fbc82977 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -971,6 +971,8 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
PMD_INIT_FUNC_TRACE();
+ dpaa2_flow_clean(dev);
+
/* Clean the device first */
ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token);
if (ret) {
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index 0ef1bf368..33b1506aa 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -126,6 +126,7 @@ struct dpaa2_dev_priv {
uint64_t qos_extract_param;
uint64_t fs_extract_param[MAX_TCS];
} extract;
+ LIST_HEAD(, rte_flow) flows; /**< Configured flow rule handles. */
};
int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set,
@@ -172,5 +173,6 @@ uint16_t dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts);
uint16_t dummy_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);
void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci);
+void dpaa2_flow_clean(struct rte_eth_dev *dev);
#endif /* _DPAA2_ETHDEV_H */
diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c
index 20de3da53..c94c7ef6b 100644
--- a/drivers/net/dpaa2/dpaa2_flow.c
+++ b/drivers/net/dpaa2/dpaa2_flow.c
@@ -24,6 +24,7 @@
#include <dpaa2_pmd_logs.h>
struct rte_flow {
+ LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
struct dpni_rule_cfg rule;
uint8_t key_size;
uint8_t tc_id;
@@ -1347,6 +1348,7 @@ dpaa2_generic_flow_set(struct rte_flow *flow,
struct dpaa2_dev_priv *priv = dev->data->dev_private;
struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
size_t param;
+ struct rte_flow *curr = LIST_FIRST(&priv->flows);
/* Parse pattern list to get the matching parameters */
while (!end_of_list) {
@@ -1625,6 +1627,16 @@ dpaa2_generic_flow_set(struct rte_flow *flow,
j++;
}
+ if (!ret) {
+ /* New rules are inserted. */
+ if (!curr) {
+ LIST_INSERT_HEAD(&priv->flows, flow, next);
+ } else {
+ while (LIST_NEXT(curr, next))
+ curr = LIST_NEXT(curr, next);
+ LIST_INSERT_AFTER(curr, flow, next);
+ }
+ }
return ret;
}
@@ -1764,7 +1776,7 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
const struct rte_flow_attr *flow_attr,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
- struct rte_flow_error *error __rte_unused)
+ struct rte_flow_error *error)
{
struct dpaa2_dev_priv *priv = dev->data->dev_private;
struct dpni_attr dpni_attr;
@@ -1778,6 +1790,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
DPAA2_PMD_ERR(
"Failure to get dpni@%p attribute, err code %d\n",
dpni, ret);
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_ATTR,
+ flow_attr, "invalid");
return ret;
}
@@ -1786,6 +1801,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
if (ret < 0) {
DPAA2_PMD_ERR(
"Invalid attributes are given\n");
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_ATTR,
+ flow_attr, "invalid");
goto not_valid_params;
}
/* Verify input pattern list */
@@ -1793,6 +1811,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
if (ret < 0) {
DPAA2_PMD_ERR(
"Invalid pattern list is given\n");
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ pattern, "invalid");
goto not_valid_params;
}
/* Verify input action list */
@@ -1800,6 +1821,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
if (ret < 0) {
DPAA2_PMD_ERR(
"Invalid action list is given\n");
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_ACTION,
+ actions, "invalid");
goto not_valid_params;
}
not_valid_params:
@@ -1820,20 +1844,20 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_dev *dev,
flow = rte_malloc(NULL, sizeof(struct rte_flow), RTE_CACHE_LINE_SIZE);
if (!flow) {
DPAA2_PMD_ERR("Failure to allocate memory for flow");
- return NULL;
+ goto mem_failure;
}
/* Allocate DMA'ble memory to write the rules */
key_iova = (size_t)rte_malloc(NULL, 256, 64);
if (!key_iova) {
DPAA2_PMD_ERR(
"Memory allocation failure for rule configration\n");
- goto creation_error;
+ goto mem_failure;
}
mask_iova = (size_t)rte_malloc(NULL, 256, 64);
if (!mask_iova) {
DPAA2_PMD_ERR(
"Memory allocation failure for rule configration\n");
- goto creation_error;
+ goto mem_failure;
}
flow->rule.key_iova = key_iova;
@@ -1845,6 +1869,10 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_dev *dev,
ret = dpaa2_generic_flow_set(flow, dev, attr, pattern,
actions, error);
if (ret < 0) {
+ if (error->type > RTE_FLOW_ERROR_TYPE_ACTION)
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ attr, "unknown");
DPAA2_PMD_ERR(
"Failure to create flow, return code (%d)", ret);
goto creation_error;
@@ -1857,21 +1885,22 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_dev *dev,
}
return flow;
-
+mem_failure:
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "memory alloc");
creation_error:
- if (flow)
- rte_free((void *)flow);
- if (key_iova)
- rte_free((void *)key_iova);
- if (mask_iova)
- rte_free((void *)mask_iova);
+ rte_free((void *)flow);
+ rte_free((void *)key_iova);
+ rte_free((void *)mask_iova);
+
return NULL;
}
static
int dpaa2_flow_destroy(struct rte_eth_dev *dev,
struct rte_flow *flow,
- struct rte_flow_error *error __rte_unused)
+ struct rte_flow_error *error)
{
int ret = 0;
struct dpaa2_dev_priv *priv = dev->data->dev_private;
@@ -1913,44 +1942,40 @@ int dpaa2_flow_destroy(struct rte_eth_dev *dev,
break;
}
+ LIST_REMOVE(flow, next);
/* Now free the flow */
rte_free(flow);
error:
+ if (ret)
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "unknown");
return ret;
}
+/**
+ * Destroy user-configured flow rules.
+ *
+ * This function skips internal flows rules.
+ *
+ * @see rte_flow_flush()
+ * @see rte_flow_ops
+ */
static int
dpaa2_flow_flush(struct rte_eth_dev *dev,
- struct rte_flow_error *error __rte_unused)
+ struct rte_flow_error *error)
{
- int ret = 0, tc_id;
- struct dpni_rx_tc_dist_cfg tc_cfg;
- struct dpni_qos_tbl_cfg qos_cfg;
struct dpaa2_dev_priv *priv = dev->data->dev_private;
- struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
+ struct rte_flow *flow = LIST_FIRST(&priv->flows);
- /* Reset QoS table */
- qos_cfg.default_tc = 0;
- qos_cfg.discard_on_miss = false;
- qos_cfg.keep_entries = false;
- qos_cfg.key_cfg_iova = priv->extract.qos_extract_param;
- ret = dpni_set_qos_table(dpni, CMD_PRI_LOW, priv->token, &qos_cfg);
- if (ret < 0)
- DPAA2_PMD_ERR(
- "QoS table is not reset to default: %d\n", ret);
-
- for (tc_id = 0; tc_id < priv->num_rx_tc; tc_id++) {
- /* Reset FS table */
- memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
- ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token,
- tc_id, &tc_cfg);
- if (ret < 0)
- DPAA2_PMD_ERR(
- "Error (%d) in flushing entries for TC (%d)",
- ret, tc_id);
+ while (flow) {
+ struct rte_flow *next = LIST_NEXT(flow, next);
+
+ dpaa2_flow_destroy(dev, flow, error);
+ flow = next;
}
- return ret;
+ return 0;
}
static int
@@ -1963,6 +1988,25 @@ dpaa2_flow_query(struct rte_eth_dev *dev __rte_unused,
return 0;
}
+/**
+ * Clean up all flow rules.
+ *
+ * Unlike dpaa2_flow_flush(), this function takes care of all remaining flow
+ * rules regardless of whether they are internal or user-configured.
+ *
+ * @param priv
+ * Pointer to private structure.
+ */
+void
+dpaa2_flow_clean(struct rte_eth_dev *dev)
+{
+ struct rte_flow *flow;
+ struct dpaa2_dev_priv *priv = dev->data->dev_private;
+
+ while ((flow = LIST_FIRST(&priv->flows)))
+ dpaa2_flow_destroy(dev, flow, NULL);
+}
+
const struct rte_flow_ops dpaa2_flow_ops = {
.create = dpaa2_flow_create,
.validate = dpaa2_flow_validate,
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* [dpdk-dev] [PATCH 4/4] net/dpaa2: add support for flow table flush
2019-03-26 12:01 ` [dpdk-dev] [PATCH 4/4] net/dpaa2: add support for flow table flush Hemant Agrawal
@ 2019-03-26 12:01 ` Hemant Agrawal
0 siblings, 0 replies; 10+ messages in thread
From: Hemant Agrawal @ 2019-03-26 12:01 UTC (permalink / raw)
To: dev; +Cc: ferruh.yigit, Shreyansh Jain
Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
---
drivers/net/dpaa2/dpaa2_ethdev.c | 2 +
drivers/net/dpaa2/dpaa2_ethdev.h | 2 +
drivers/net/dpaa2/dpaa2_flow.c | 118 +++++++++++++++++++++----------
3 files changed, 85 insertions(+), 37 deletions(-)
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.c b/drivers/net/dpaa2/dpaa2_ethdev.c
index c92edecf3..3fbc82977 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.c
+++ b/drivers/net/dpaa2/dpaa2_ethdev.c
@@ -971,6 +971,8 @@ dpaa2_dev_close(struct rte_eth_dev *dev)
PMD_INIT_FUNC_TRACE();
+ dpaa2_flow_clean(dev);
+
/* Clean the device first */
ret = dpni_reset(dpni, CMD_PRI_LOW, priv->token);
if (ret) {
diff --git a/drivers/net/dpaa2/dpaa2_ethdev.h b/drivers/net/dpaa2/dpaa2_ethdev.h
index 0ef1bf368..33b1506aa 100644
--- a/drivers/net/dpaa2/dpaa2_ethdev.h
+++ b/drivers/net/dpaa2/dpaa2_ethdev.h
@@ -126,6 +126,7 @@ struct dpaa2_dev_priv {
uint64_t qos_extract_param;
uint64_t fs_extract_param[MAX_TCS];
} extract;
+ LIST_HEAD(, rte_flow) flows; /**< Configured flow rule handles. */
};
int dpaa2_distset_to_dpkg_profile_cfg(uint64_t req_dist_set,
@@ -172,5 +173,6 @@ uint16_t dpaa2_dev_tx_ordered(void *queue, struct rte_mbuf **bufs,
uint16_t nb_pkts);
uint16_t dummy_dev_tx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts);
void dpaa2_dev_free_eqresp_buf(uint16_t eqresp_ci);
+void dpaa2_flow_clean(struct rte_eth_dev *dev);
#endif /* _DPAA2_ETHDEV_H */
diff --git a/drivers/net/dpaa2/dpaa2_flow.c b/drivers/net/dpaa2/dpaa2_flow.c
index 20de3da53..c94c7ef6b 100644
--- a/drivers/net/dpaa2/dpaa2_flow.c
+++ b/drivers/net/dpaa2/dpaa2_flow.c
@@ -24,6 +24,7 @@
#include <dpaa2_pmd_logs.h>
struct rte_flow {
+ LIST_ENTRY(rte_flow) next; /**< Pointer to the next flow structure. */
struct dpni_rule_cfg rule;
uint8_t key_size;
uint8_t tc_id;
@@ -1347,6 +1348,7 @@ dpaa2_generic_flow_set(struct rte_flow *flow,
struct dpaa2_dev_priv *priv = dev->data->dev_private;
struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
size_t param;
+ struct rte_flow *curr = LIST_FIRST(&priv->flows);
/* Parse pattern list to get the matching parameters */
while (!end_of_list) {
@@ -1625,6 +1627,16 @@ dpaa2_generic_flow_set(struct rte_flow *flow,
j++;
}
+ if (!ret) {
+ /* New rules are inserted. */
+ if (!curr) {
+ LIST_INSERT_HEAD(&priv->flows, flow, next);
+ } else {
+ while (LIST_NEXT(curr, next))
+ curr = LIST_NEXT(curr, next);
+ LIST_INSERT_AFTER(curr, flow, next);
+ }
+ }
return ret;
}
@@ -1764,7 +1776,7 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
const struct rte_flow_attr *flow_attr,
const struct rte_flow_item pattern[],
const struct rte_flow_action actions[],
- struct rte_flow_error *error __rte_unused)
+ struct rte_flow_error *error)
{
struct dpaa2_dev_priv *priv = dev->data->dev_private;
struct dpni_attr dpni_attr;
@@ -1778,6 +1790,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
DPAA2_PMD_ERR(
"Failure to get dpni@%p attribute, err code %d\n",
dpni, ret);
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_ATTR,
+ flow_attr, "invalid");
return ret;
}
@@ -1786,6 +1801,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
if (ret < 0) {
DPAA2_PMD_ERR(
"Invalid attributes are given\n");
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_ATTR,
+ flow_attr, "invalid");
goto not_valid_params;
}
/* Verify input pattern list */
@@ -1793,6 +1811,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
if (ret < 0) {
DPAA2_PMD_ERR(
"Invalid pattern list is given\n");
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_ITEM,
+ pattern, "invalid");
goto not_valid_params;
}
/* Verify input action list */
@@ -1800,6 +1821,9 @@ int dpaa2_flow_validate(struct rte_eth_dev *dev,
if (ret < 0) {
DPAA2_PMD_ERR(
"Invalid action list is given\n");
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_ACTION,
+ actions, "invalid");
goto not_valid_params;
}
not_valid_params:
@@ -1820,20 +1844,20 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_dev *dev,
flow = rte_malloc(NULL, sizeof(struct rte_flow), RTE_CACHE_LINE_SIZE);
if (!flow) {
DPAA2_PMD_ERR("Failure to allocate memory for flow");
- return NULL;
+ goto mem_failure;
}
/* Allocate DMA'ble memory to write the rules */
key_iova = (size_t)rte_malloc(NULL, 256, 64);
if (!key_iova) {
DPAA2_PMD_ERR(
"Memory allocation failure for rule configration\n");
- goto creation_error;
+ goto mem_failure;
}
mask_iova = (size_t)rte_malloc(NULL, 256, 64);
if (!mask_iova) {
DPAA2_PMD_ERR(
"Memory allocation failure for rule configration\n");
- goto creation_error;
+ goto mem_failure;
}
flow->rule.key_iova = key_iova;
@@ -1845,6 +1869,10 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_dev *dev,
ret = dpaa2_generic_flow_set(flow, dev, attr, pattern,
actions, error);
if (ret < 0) {
+ if (error->type > RTE_FLOW_ERROR_TYPE_ACTION)
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ attr, "unknown");
DPAA2_PMD_ERR(
"Failure to create flow, return code (%d)", ret);
goto creation_error;
@@ -1857,21 +1885,22 @@ struct rte_flow *dpaa2_flow_create(struct rte_eth_dev *dev,
}
return flow;
-
+mem_failure:
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "memory alloc");
creation_error:
- if (flow)
- rte_free((void *)flow);
- if (key_iova)
- rte_free((void *)key_iova);
- if (mask_iova)
- rte_free((void *)mask_iova);
+ rte_free((void *)flow);
+ rte_free((void *)key_iova);
+ rte_free((void *)mask_iova);
+
return NULL;
}
static
int dpaa2_flow_destroy(struct rte_eth_dev *dev,
struct rte_flow *flow,
- struct rte_flow_error *error __rte_unused)
+ struct rte_flow_error *error)
{
int ret = 0;
struct dpaa2_dev_priv *priv = dev->data->dev_private;
@@ -1913,44 +1942,40 @@ int dpaa2_flow_destroy(struct rte_eth_dev *dev,
break;
}
+ LIST_REMOVE(flow, next);
/* Now free the flow */
rte_free(flow);
error:
+ if (ret)
+ rte_flow_error_set(error, EPERM,
+ RTE_FLOW_ERROR_TYPE_UNSPECIFIED,
+ NULL, "unknown");
return ret;
}
+/**
+ * Destroy user-configured flow rules.
+ *
+ * This function skips internal flows rules.
+ *
+ * @see rte_flow_flush()
+ * @see rte_flow_ops
+ */
static int
dpaa2_flow_flush(struct rte_eth_dev *dev,
- struct rte_flow_error *error __rte_unused)
+ struct rte_flow_error *error)
{
- int ret = 0, tc_id;
- struct dpni_rx_tc_dist_cfg tc_cfg;
- struct dpni_qos_tbl_cfg qos_cfg;
struct dpaa2_dev_priv *priv = dev->data->dev_private;
- struct fsl_mc_io *dpni = (struct fsl_mc_io *)priv->hw;
+ struct rte_flow *flow = LIST_FIRST(&priv->flows);
- /* Reset QoS table */
- qos_cfg.default_tc = 0;
- qos_cfg.discard_on_miss = false;
- qos_cfg.keep_entries = false;
- qos_cfg.key_cfg_iova = priv->extract.qos_extract_param;
- ret = dpni_set_qos_table(dpni, CMD_PRI_LOW, priv->token, &qos_cfg);
- if (ret < 0)
- DPAA2_PMD_ERR(
- "QoS table is not reset to default: %d\n", ret);
-
- for (tc_id = 0; tc_id < priv->num_rx_tc; tc_id++) {
- /* Reset FS table */
- memset(&tc_cfg, 0, sizeof(struct dpni_rx_tc_dist_cfg));
- ret = dpni_set_rx_tc_dist(dpni, CMD_PRI_LOW, priv->token,
- tc_id, &tc_cfg);
- if (ret < 0)
- DPAA2_PMD_ERR(
- "Error (%d) in flushing entries for TC (%d)",
- ret, tc_id);
+ while (flow) {
+ struct rte_flow *next = LIST_NEXT(flow, next);
+
+ dpaa2_flow_destroy(dev, flow, error);
+ flow = next;
}
- return ret;
+ return 0;
}
static int
@@ -1963,6 +1988,25 @@ dpaa2_flow_query(struct rte_eth_dev *dev __rte_unused,
return 0;
}
+/**
+ * Clean up all flow rules.
+ *
+ * Unlike dpaa2_flow_flush(), this function takes care of all remaining flow
+ * rules regardless of whether they are internal or user-configured.
+ *
+ * @param priv
+ * Pointer to private structure.
+ */
+void
+dpaa2_flow_clean(struct rte_eth_dev *dev)
+{
+ struct rte_flow *flow;
+ struct dpaa2_dev_priv *priv = dev->data->dev_private;
+
+ while ((flow = LIST_FIRST(&priv->flows)))
+ dpaa2_flow_destroy(dev, flow, NULL);
+}
+
const struct rte_flow_ops dpaa2_flow_ops = {
.create = dpaa2_flow_create,
.validate = dpaa2_flow_validate,
--
2.17.1
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process
2019-03-26 12:01 [dpdk-dev] [PATCH 1/4] bus/dpaa: fq lookup table saved for secondary process Hemant Agrawal
` (3 preceding siblings ...)
2019-03-26 12:01 ` [dpdk-dev] [PATCH 4/4] net/dpaa2: add support for flow table flush Hemant Agrawal
@ 2019-03-29 13:33 ` Thomas Monjalon
2019-03-29 13:33 ` Thomas Monjalon
4 siblings, 1 reply; 10+ messages in thread
From: Thomas Monjalon @ 2019-03-29 13:33 UTC (permalink / raw)
To: Hemant Agrawal, Akhil Goyal; +Cc: dev, ferruh.yigit, Shreyansh Jain
26/03/2019 13:01, Hemant Agrawal:
> From: Akhil Goyal <akhil.goyal@nxp.com>
>
> A reference to qman_fq_lookup_table need to be saved in each
> fq, so that it is retrieved while in running secondary process.
>
> Signed-off-by: Akhil Goyal <akhil.goyal@nxp.com>
Series applied, thanks
^ permalink raw reply [flat|nested] 10+ messages in thread