[v5,1/6] examples/l3fwd: fix lcore ID restriction

Message ID 20240318173146.24303-2-sivaprasad.tummala@amd.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series fix lcore ID restriction |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Sivaprasad Tummala March 18, 2024, 5:31 p.m. UTC
  Currently the config option allows lcore IDs up to 255,
irrespective of RTE_MAX_LCORES and needs to be fixed.

The patch allows config options based on DPDK config.

Fixes: af75078fece3 ("first public release")
Cc: stable@dpdk.org

Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
---
 examples/l3fwd/l3fwd.h       |  2 +-
 examples/l3fwd/l3fwd_acl.c   |  4 ++--
 examples/l3fwd/l3fwd_em.c    |  4 ++--
 examples/l3fwd/l3fwd_event.h |  2 +-
 examples/l3fwd/l3fwd_fib.c   |  4 ++--
 examples/l3fwd/l3fwd_lpm.c   |  5 ++---
 examples/l3fwd/main.c        | 40 ++++++++++++++++++++----------------
 7 files changed, 32 insertions(+), 29 deletions(-)
  

Comments

Morten Brørup March 19, 2024, 7:24 a.m. UTC | #1
> From: Sivaprasad Tummala [mailto:sivaprasad.tummala@amd.com]
> Sent: Monday, 18 March 2024 18.32
> 
> Currently the config option allows lcore IDs up to 255,
> irrespective of RTE_MAX_LCORES and needs to be fixed.
> 
> The patch allows config options based on DPDK config.
> 
> Fixes: af75078fece3 ("first public release")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
> Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> ---

I suggest you update the description of the individual patches too, like you did for patch 0/6.

E.g. this patch not only fixes the lcore_id, but also the queue_id type size.


For the series,
Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
Thomas Monjalon March 21, 2024, 9:55 a.m. UTC | #2
19/03/2024 08:24, Morten Brørup:
> > From: Sivaprasad Tummala [mailto:sivaprasad.tummala@amd.com]
> > Sent: Monday, 18 March 2024 18.32
> > 
> > Currently the config option allows lcore IDs up to 255,
> > irrespective of RTE_MAX_LCORES and needs to be fixed.
> > 
> > The patch allows config options based on DPDK config.
> > 
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> > 
> > Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
> > Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> > ---
> 
> I suggest you update the description of the individual patches too, like you did for patch 0/6.
> 
> E.g. this patch not only fixes the lcore_id, but also the queue_id type size.
> 
> 
> For the series,
> Acked-by: Morten Brørup <mb@smartsharesystems.com>

I would recommend a separate patch for queue id as it is a separate issue.
However, there is no need to split per directory.
You can have patches changing all examples at once.
  
Sivaprasad Tummala March 21, 2024, 11:05 a.m. UTC | #3
[AMD Official Use Only - General]

Hi Morten,

> -----Original Message-----
> From: Morten Brørup <mb@smartsharesystems.com>
> Sent: Tuesday, March 19, 2024 12:54 PM
> To: Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>;
> david.hunt@intel.com; anatoly.burakov@intel.com; jerinj@marvell.com;
> radu.nicolau@intel.com; gakhil@marvell.com; cristian.dumitrescu@intel.com; Yigit,
> Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com;
> stephen@networkplumber.org; david.marchand@redhat.com
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: RE: [PATCH v5 1/6] examples/l3fwd: fix lcore ID restriction
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> > From: Sivaprasad Tummala [mailto:sivaprasad.tummala@amd.com]
> > Sent: Monday, 18 March 2024 18.32
> >
> > Currently the config option allows lcore IDs up to 255, irrespective
> > of RTE_MAX_LCORES and needs to be fixed.
> >
> > The patch allows config options based on DPDK config.
> >
> > Fixes: af75078fece3 ("first public release")
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
> > Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> > ---
>
> I suggest you update the description of the individual patches too, like you did for
> patch 0/6.
Sure, will fix this in next series.

>
> E.g. this patch not only fixes the lcore_id, but also the queue_id type size.
>
>
> For the series,
> Acked-by: Morten Brørup <mb@smartsharesystems.com>
  
Sivaprasad Tummala March 21, 2024, 11:05 a.m. UTC | #4
[AMD Official Use Only - General]

Hi Thomas,

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Thursday, March 21, 2024 3:25 PM
> To: Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>
> Cc: david.hunt@intel.com; anatoly.burakov@intel.com; jerinj@marvell.com;
> radu.nicolau@intel.com; gakhil@marvell.com; cristian.dumitrescu@intel.com; Yigit,
> Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com;
> stephen@networkplumber.org; david.marchand@redhat.com; dev@dpdk.org;
> stable@dpdk.org; Morten Brørup <mb@smartsharesystems.com>
> Subject: Re: [PATCH v5 1/6] examples/l3fwd: fix lcore ID restriction
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> 19/03/2024 08:24, Morten Brørup:
> > > From: Sivaprasad Tummala [mailto:sivaprasad.tummala@amd.com]
> > > Sent: Monday, 18 March 2024 18.32
> > >
> > > Currently the config option allows lcore IDs up to 255, irrespective
> > > of RTE_MAX_LCORES and needs to be fixed.
> > >
> > > The patch allows config options based on DPDK config.
> > >
> > > Fixes: af75078fece3 ("first public release")
> > > Cc: stable@dpdk.org
> > >
> > > Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
> > > Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> > > ---
> >
> > I suggest you update the description of the individual patches too, like you did
> for patch 0/6.
> >
> > E.g. this patch not only fixes the lcore_id, but also the queue_id type size.
> >
> >
> > For the series,
> > Acked-by: Morten Brørup <mb@smartsharesystems.com>
>
> I would recommend a separate patch for queue id as it is a separate issue.
> However, there is no need to split per directory.
> You can have patches changing all examples at once.
>
There's a functional dependency and queue id change is required to support
higher lcore IDs and hence it makes sense to add in the same patch.
I had split the examples to help the maintainers review the patches individually.
Please feel free to squash the git commits while merging.
  
Thomas Monjalon March 21, 2024, 11:18 a.m. UTC | #5
21/03/2024 12:05, Tummala, Sivaprasad:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 19/03/2024 08:24, Morten Brørup:
> > > > From: Sivaprasad Tummala [mailto:sivaprasad.tummala@amd.com]
> > > > Sent: Monday, 18 March 2024 18.32
> > > >
> > > > Currently the config option allows lcore IDs up to 255, irrespective
> > > > of RTE_MAX_LCORES and needs to be fixed.
> > > >
> > > > The patch allows config options based on DPDK config.
> > > >
> > > > Fixes: af75078fece3 ("first public release")
> > > > Cc: stable@dpdk.org
> > > >
> > > > Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
> > > > Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> > > > ---
> > >
> > > I suggest you update the description of the individual patches too, like you did
> > for patch 0/6.
> > >
> > > E.g. this patch not only fixes the lcore_id, but also the queue_id type size.
> > >
> > >
> > > For the series,
> > > Acked-by: Morten Brørup <mb@smartsharesystems.com>
> >
> > I would recommend a separate patch for queue id as it is a separate issue.
> > However, there is no need to split per directory.
> > You can have patches changing all examples at once.
> >
> There's a functional dependency and queue id change is required to support
> higher lcore IDs and hence it makes sense to add in the same patch.
> I had split the examples to help the maintainers review the patches individually.
> Please feel free to squash the git commits while merging.

Then if there is a dependency, please make queue id the first patch.
  
Sivaprasad Tummala March 21, 2024, 6:26 p.m. UTC | #6
[AMD Official Use Only - General]

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Thursday, March 21, 2024 4:48 PM
> To: Tummala, Sivaprasad <Sivaprasad.Tummala@amd.com>
> Cc: david.hunt@intel.com; anatoly.burakov@intel.com; jerinj@marvell.com;
> radu.nicolau@intel.com; gakhil@marvell.com; cristian.dumitrescu@intel.com; Yigit,
> Ferruh <Ferruh.Yigit@amd.com>; konstantin.ananyev@huawei.com;
> stephen@networkplumber.org; david.marchand@redhat.com; dev@dpdk.org;
> stable@dpdk.org; Morten Brørup <mb@smartsharesystems.com>
> Subject: Re: [PATCH v5 1/6] examples/l3fwd: fix lcore ID restriction
>
> Caution: This message originated from an External Source. Use proper caution
> when opening attachments, clicking links, or responding.
>
>
> 21/03/2024 12:05, Tummala, Sivaprasad:
> > From: Thomas Monjalon <thomas@monjalon.net>
> > > 19/03/2024 08:24, Morten Brørup:
> > > > > From: Sivaprasad Tummala [mailto:sivaprasad.tummala@amd.com]
> > > > > Sent: Monday, 18 March 2024 18.32
> > > > >
> > > > > Currently the config option allows lcore IDs up to 255,
> > > > > irrespective of RTE_MAX_LCORES and needs to be fixed.
> > > > >
> > > > > The patch allows config options based on DPDK config.
> > > > >
> > > > > Fixes: af75078fece3 ("first public release")
> > > > > Cc: stable@dpdk.org
> > > > >
> > > > > Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
> > > > > Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
> > > > > ---
> > > >
> > > > I suggest you update the description of the individual patches
> > > > too, like you did
> > > for patch 0/6.
> > > >
> > > > E.g. this patch not only fixes the lcore_id, but also the queue_id type size.
> > > >
> > > >
> > > > For the series,
> > > > Acked-by: Morten Brørup <mb@smartsharesystems.com>
> > >
> > > I would recommend a separate patch for queue id as it is a separate issue.
> > > However, there is no need to split per directory.
> > > You can have patches changing all examples at once.
> > >
> > There's a functional dependency and queue id change is required to
> > support higher lcore IDs and hence it makes sense to add in the same patch.
> > I had split the examples to help the maintainers review the patches individually.
> > Please feel free to squash the git commits while merging.
>
> Then if there is a dependency, please make queue id the first patch.
OK! Will split the changes into separate patches in next version.

>
  

Patch

diff --git a/examples/l3fwd/l3fwd.h b/examples/l3fwd/l3fwd.h
index e7ae0e5834..12c264cb4c 100644
--- a/examples/l3fwd/l3fwd.h
+++ b/examples/l3fwd/l3fwd.h
@@ -74,7 +74,7 @@  struct mbuf_table {
 
 struct lcore_rx_queue {
 	uint16_t port_id;
-	uint8_t queue_id;
+	uint16_t queue_id;
 } __rte_cache_aligned;
 
 struct lcore_conf {
diff --git a/examples/l3fwd/l3fwd_acl.c b/examples/l3fwd/l3fwd_acl.c
index 401692bcec..2bd63181bc 100644
--- a/examples/l3fwd/l3fwd_acl.c
+++ b/examples/l3fwd/l3fwd_acl.c
@@ -997,7 +997,7 @@  acl_main_loop(__rte_unused void *dummy)
 	uint64_t prev_tsc, diff_tsc, cur_tsc;
 	int i, nb_rx;
 	uint16_t portid;
-	uint8_t queueid;
+	uint16_t queueid;
 	struct lcore_conf *qconf;
 	int socketid;
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1)
@@ -1020,7 +1020,7 @@  acl_main_loop(__rte_unused void *dummy)
 		portid = qconf->rx_queue_list[i].port_id;
 		queueid = qconf->rx_queue_list[i].queue_id;
 		RTE_LOG(INFO, L3FWD,
-			" -- lcoreid=%u portid=%u rxqueueid=%hhu\n",
+			" -- lcoreid=%u portid=%u rxqueueid=%hu\n",
 			lcore_id, portid, queueid);
 	}
 
diff --git a/examples/l3fwd/l3fwd_em.c b/examples/l3fwd/l3fwd_em.c
index 40e102b38a..cd2bb4a4bb 100644
--- a/examples/l3fwd/l3fwd_em.c
+++ b/examples/l3fwd/l3fwd_em.c
@@ -586,7 +586,7 @@  em_main_loop(__rte_unused void *dummy)
 	unsigned lcore_id;
 	uint64_t prev_tsc, diff_tsc, cur_tsc;
 	int i, nb_rx;
-	uint8_t queueid;
+	uint16_t queueid;
 	uint16_t portid;
 	struct lcore_conf *qconf;
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /
@@ -609,7 +609,7 @@  em_main_loop(__rte_unused void *dummy)
 		portid = qconf->rx_queue_list[i].port_id;
 		queueid = qconf->rx_queue_list[i].queue_id;
 		RTE_LOG(INFO, L3FWD,
-			" -- lcoreid=%u portid=%u rxqueueid=%hhu\n",
+			" -- lcoreid=%u portid=%u rxqueueid=%hu\n",
 			lcore_id, portid, queueid);
 	}
 
diff --git a/examples/l3fwd/l3fwd_event.h b/examples/l3fwd/l3fwd_event.h
index 9aad358003..c6a4a89127 100644
--- a/examples/l3fwd/l3fwd_event.h
+++ b/examples/l3fwd/l3fwd_event.h
@@ -78,8 +78,8 @@  struct l3fwd_event_resources {
 	uint8_t deq_depth;
 	uint8_t has_burst;
 	uint8_t enabled;
-	uint8_t eth_rx_queues;
 	uint8_t vector_enabled;
+	uint16_t eth_rx_queues;
 	uint16_t vector_size;
 	uint64_t vector_tmo_ns;
 };
diff --git a/examples/l3fwd/l3fwd_fib.c b/examples/l3fwd/l3fwd_fib.c
index 6a21984415..7da55f707a 100644
--- a/examples/l3fwd/l3fwd_fib.c
+++ b/examples/l3fwd/l3fwd_fib.c
@@ -186,7 +186,7 @@  fib_main_loop(__rte_unused void *dummy)
 	uint64_t prev_tsc, diff_tsc, cur_tsc;
 	int i, nb_rx;
 	uint16_t portid;
-	uint8_t queueid;
+	uint16_t queueid;
 	struct lcore_conf *qconf;
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /
 			US_PER_S * BURST_TX_DRAIN_US;
@@ -208,7 +208,7 @@  fib_main_loop(__rte_unused void *dummy)
 		portid = qconf->rx_queue_list[i].port_id;
 		queueid = qconf->rx_queue_list[i].queue_id;
 		RTE_LOG(INFO, L3FWD,
-				" -- lcoreid=%u portid=%u rxqueueid=%hhu\n",
+				" -- lcoreid=%u portid=%u rxqueueid=%hu\n",
 				lcore_id, portid, queueid);
 	}
 
diff --git a/examples/l3fwd/l3fwd_lpm.c b/examples/l3fwd/l3fwd_lpm.c
index a484a33089..01d38bc69c 100644
--- a/examples/l3fwd/l3fwd_lpm.c
+++ b/examples/l3fwd/l3fwd_lpm.c
@@ -148,8 +148,7 @@  lpm_main_loop(__rte_unused void *dummy)
 	unsigned lcore_id;
 	uint64_t prev_tsc, diff_tsc, cur_tsc;
 	int i, nb_rx;
-	uint16_t portid;
-	uint8_t queueid;
+	uint16_t portid, queueid;
 	struct lcore_conf *qconf;
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1) /
 		US_PER_S * BURST_TX_DRAIN_US;
@@ -171,7 +170,7 @@  lpm_main_loop(__rte_unused void *dummy)
 		portid = qconf->rx_queue_list[i].port_id;
 		queueid = qconf->rx_queue_list[i].queue_id;
 		RTE_LOG(INFO, L3FWD,
-			" -- lcoreid=%u portid=%u rxqueueid=%hhu\n",
+			" -- lcoreid=%u portid=%u rxqueueid=%hu\n",
 			lcore_id, portid, queueid);
 	}
 
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 8d32ae1dd5..19e4d9dfa2 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -98,8 +98,8 @@  struct parm_cfg parm_config;
 
 struct lcore_params {
 	uint16_t port_id;
-	uint8_t queue_id;
-	uint8_t lcore_id;
+	uint16_t queue_id;
+	uint32_t lcore_id;
 } __rte_cache_aligned;
 
 static struct lcore_params lcore_params_array[MAX_LCORE_PARAMS];
@@ -292,24 +292,24 @@  setup_l3fwd_lookup_tables(void)
 static int
 check_lcore_params(void)
 {
-	uint8_t queue, lcore;
-	uint16_t i;
+	uint16_t queue, i;
+	uint32_t lcore;
 	int socketid;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
 		queue = lcore_params[i].queue_id;
 		if (queue >= MAX_RX_QUEUE_PER_PORT) {
-			printf("invalid queue number: %hhu\n", queue);
+			printf("invalid queue number: %hu\n", queue);
 			return -1;
 		}
 		lcore = lcore_params[i].lcore_id;
 		if (!rte_lcore_is_enabled(lcore)) {
-			printf("error: lcore %hhu is not enabled in lcore mask\n", lcore);
+			printf("error: lcore %u is not enabled in lcore mask\n", lcore);
 			return -1;
 		}
 		if ((socketid = rte_lcore_to_socket_id(lcore) != 0) &&
 			(numa_on == 0)) {
-			printf("warning: lcore %hhu is on socket %d with numa off \n",
+			printf("warning: lcore %u is on socket %d with numa off\n",
 				lcore, socketid);
 		}
 	}
@@ -336,7 +336,7 @@  check_port_config(void)
 	return 0;
 }
 
-static uint8_t
+static uint16_t
 get_port_n_rx_queues(const uint16_t port)
 {
 	int queue = -1;
@@ -352,21 +352,21 @@  get_port_n_rx_queues(const uint16_t port)
 						lcore_params[i].port_id);
 		}
 	}
-	return (uint8_t)(++queue);
+	return (uint16_t)(++queue);
 }
 
 static int
 init_lcore_rx_queues(void)
 {
 	uint16_t i, nb_rx_queue;
-	uint8_t lcore;
+	uint32_t lcore;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
 		lcore = lcore_params[i].lcore_id;
 		nb_rx_queue = lcore_conf[lcore].n_rx_queue;
 		if (nb_rx_queue >= MAX_RX_QUEUE_PER_LCORE) {
 			printf("error: too many queues (%u) for lcore: %u\n",
-				(unsigned)nb_rx_queue + 1, (unsigned)lcore);
+				(unsigned int)nb_rx_queue + 1, lcore);
 			return -1;
 		} else {
 			lcore_conf[lcore].rx_queue_list[nb_rx_queue].port_id =
@@ -500,6 +500,8 @@  parse_config(const char *q_arg)
 	char *str_fld[_NUM_FLD];
 	int i;
 	unsigned size;
+	uint32_t max_fld[_NUM_FLD] = {RTE_MAX_ETHPORTS,
+				USHRT_MAX, RTE_MAX_LCORE};
 
 	nb_lcore_params = 0;
 
@@ -518,7 +520,8 @@  parse_config(const char *q_arg)
 		for (i = 0; i < _NUM_FLD; i++){
 			errno = 0;
 			int_fld[i] = strtoul(str_fld[i], &end, 0);
-			if (errno != 0 || end == str_fld[i] || int_fld[i] > 255)
+			if (errno != 0 || end == str_fld[i] || int_fld[i] >
+									max_fld[i])
 				return -1;
 		}
 		if (nb_lcore_params >= MAX_LCORE_PARAMS) {
@@ -527,11 +530,11 @@  parse_config(const char *q_arg)
 			return -1;
 		}
 		lcore_params_array[nb_lcore_params].port_id =
-			(uint8_t)int_fld[FLD_PORT];
+			(uint16_t)int_fld[FLD_PORT];
 		lcore_params_array[nb_lcore_params].queue_id =
-			(uint8_t)int_fld[FLD_QUEUE];
+			(uint16_t)int_fld[FLD_QUEUE];
 		lcore_params_array[nb_lcore_params].lcore_id =
-			(uint8_t)int_fld[FLD_LCORE];
+			(uint32_t)int_fld[FLD_LCORE];
 		++nb_lcore_params;
 	}
 	lcore_params = lcore_params_array;
@@ -630,7 +633,7 @@  parse_event_eth_rx_queues(const char *eth_rx_queues)
 {
 	struct l3fwd_event_resources *evt_rsrc = l3fwd_get_eventdev_rsrc();
 	char *end = NULL;
-	uint8_t num_eth_rx_queues;
+	uint16_t num_eth_rx_queues;
 
 	/* parse decimal string */
 	num_eth_rx_queues = strtoul(eth_rx_queues, &end, 10);
@@ -1211,7 +1214,8 @@  config_port_max_pkt_len(struct rte_eth_conf *conf,
 static void
 l3fwd_poll_resource_setup(void)
 {
-	uint8_t nb_rx_queue, queue, socketid;
+	uint8_t socketid;
+	uint16_t nb_rx_queue, queue;
 	struct rte_eth_dev_info dev_info;
 	uint32_t n_tx_queue, nb_lcores;
 	struct rte_eth_txconf *txconf;
@@ -1535,7 +1539,7 @@  main(int argc, char **argv)
 	struct lcore_conf *qconf;
 	uint16_t queueid, portid;
 	unsigned int lcore_id;
-	uint8_t queue;
+	uint16_t queue;
 	int ret;
 
 	/* init EAL */