[v7,04/14] examples/ipsec-secgw: fix queue ID restriction

Message ID 20240326125554.138840-5-sivaprasad.tummala@amd.com (mailing list archive)
State New
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 26, 2024, 12:55 p.m. UTC
  Currently application supports rx queue IDs up to 255
and max queues of 256 irrespective of device support.
This limits the number of active lcores to 256.

The patch fixes these constraints by increasing the
rx queue IDs to support up to 65535.

Signed-off-by: Sivaprasad Tummala <sivaprasad.tummala@amd.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@huawei.com>
Acked-by: Morten Brørup <mb@smartsharesystems.com>
Acked-by: Ferruh Yigit <ferruh.yigit@amd.com>
---
 examples/ipsec-secgw/ipsec-secgw.c  | 19 +++++++++----------
 examples/ipsec-secgw/ipsec.h        |  2 +-
 examples/ipsec-secgw/ipsec_worker.c | 10 ++++------
 3 files changed, 14 insertions(+), 17 deletions(-)
  

Patch

diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index 45a303850d..782535f4b5 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -220,7 +220,7 @@  static const char *cfgfile;
 
 struct lcore_params {
 	uint16_t port_id;
-	uint8_t queue_id;
+	uint16_t queue_id;
 	uint8_t lcore_id;
 } __rte_cache_aligned;
 
@@ -695,8 +695,7 @@  ipsec_poll_mode_worker(void)
 	struct rte_mbuf *pkts[MAX_PKT_BURST];
 	uint32_t lcore_id;
 	uint64_t prev_tsc, diff_tsc, cur_tsc;
-	uint16_t i, nb_rx, portid;
-	uint8_t queueid;
+	uint16_t i, nb_rx, portid, queueid;
 	struct lcore_conf *qconf;
 	int32_t rc, socket_id;
 	const uint64_t drain_tsc = (rte_get_tsc_hz() + US_PER_S - 1)
@@ -743,7 +742,7 @@  ipsec_poll_mode_worker(void)
 		portid = rxql[i].port_id;
 		queueid = rxql[i].queue_id;
 		RTE_LOG(INFO, IPSEC,
-			" -- lcoreid=%u portid=%u rxqueueid=%hhu\n",
+			" -- lcoreid=%u portid=%u rxqueueid=%" PRIu16 "\n",
 			lcore_id, portid, queueid);
 	}
 
@@ -788,8 +787,7 @@  int
 check_flow_params(uint16_t fdir_portid, uint8_t fdir_qid)
 {
 	uint16_t i;
-	uint16_t portid;
-	uint8_t queueid;
+	uint16_t portid, queueid;
 
 	for (i = 0; i < nb_lcore_params; ++i) {
 		portid = lcore_params_array[i].port_id;
@@ -851,7 +849,7 @@  check_poll_mode_params(struct eh_conf *eh_conf)
 	return 0;
 }
 
-static uint8_t
+static uint16_t
 get_port_nb_rx_queues(const uint16_t port)
 {
 	int32_t queue = -1;
@@ -862,7 +860,7 @@  get_port_nb_rx_queues(const uint16_t port)
 				lcore_params[i].queue_id > queue)
 			queue = lcore_params[i].queue_id;
 	}
-	return (uint8_t)(++queue);
+	return (uint16_t)(++queue);
 }
 
 static int32_t
@@ -1050,6 +1048,7 @@  parse_config(const char *q_arg)
 	char *str_fld[_NUM_FLD];
 	int32_t i;
 	uint32_t size;
+	uint32_t max_fld[_NUM_FLD] = {255, RTE_MAX_QUEUES_PER_PORT, 255};
 
 	nb_lcore_params = 0;
 
@@ -1070,7 +1069,7 @@  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) {
@@ -1081,7 +1080,7 @@  parse_config(const char *q_arg)
 		lcore_params_array[nb_lcore_params].port_id =
 			(uint8_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];
 		++nb_lcore_params;
diff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h
index bdcada1c40..29b9b283f0 100644
--- a/examples/ipsec-secgw/ipsec.h
+++ b/examples/ipsec-secgw/ipsec.h
@@ -285,7 +285,7 @@  struct cnt_blk {
 
 struct lcore_rx_queue {
 	uint16_t port_id;
-	uint8_t queue_id;
+	uint16_t queue_id;
 	void *sec_ctx;
 } __rte_cache_aligned;
 
diff --git a/examples/ipsec-secgw/ipsec_worker.c b/examples/ipsec-secgw/ipsec_worker.c
index 8d122e8519..c9c43ebd2b 100644
--- a/examples/ipsec-secgw/ipsec_worker.c
+++ b/examples/ipsec-secgw/ipsec_worker.c
@@ -1598,8 +1598,7 @@  ipsec_poll_mode_wrkr_inl_pr(void)
 	int32_t socket_id;
 	uint32_t lcore_id;
 	int32_t i, nb_rx;
-	uint16_t portid;
-	uint8_t queueid;
+	uint16_t portid, queueid;
 
 	prev_tsc = 0;
 	lcore_id = rte_lcore_id();
@@ -1633,7 +1632,7 @@  ipsec_poll_mode_wrkr_inl_pr(void)
 		portid = rxql[i].port_id;
 		queueid = rxql[i].queue_id;
 		RTE_LOG(INFO, IPSEC,
-			" -- lcoreid=%u portid=%u rxqueueid=%hhu\n",
+			" -- lcoreid=%u portid=%u rxqueueid=%" PRIu16 "\n",
 			lcore_id, portid, queueid);
 	}
 
@@ -1729,8 +1728,7 @@  ipsec_poll_mode_wrkr_inl_pr_ss(void)
 	uint32_t i, nb_rx, j;
 	int32_t socket_id;
 	uint32_t lcore_id;
-	uint16_t portid;
-	uint8_t queueid;
+	uint16_t portid, queueid;
 
 	prev_tsc = 0;
 	lcore_id = rte_lcore_id();
@@ -1764,7 +1762,7 @@  ipsec_poll_mode_wrkr_inl_pr_ss(void)
 		portid = rxql[i].port_id;
 		queueid = rxql[i].queue_id;
 		RTE_LOG(INFO, IPSEC,
-			" -- lcoreid=%u portid=%u rxqueueid=%hhu\n",
+			" -- lcoreid=%u portid=%u rxqueueid=%" PRIu16 "\n",
 			lcore_id, portid, queueid);
 	}