Skip to contentSkip to conversation

app/test-pmd: change a magic number to macro

PATCH New Mingxia Liu 3 participants 4 messages Mar 29, 2022 – May 20, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 app/test-pmd: change a magic number to macro

From: mingxial <[email protected]>

Add macro MIN_TOTAL_NUM_MBUFS (1024) to indicate what the value of total-num-mbufs should bigger than.

Fixes c87988187fdb ("app/testpmd: add --total-num-mbufs option")
---
 app/test-pmd/parameters.c | 5 +++--
 app/test-pmd/testpmd.h    | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
app/test-pmd/parameters.c +3 -2
index daf6a31b2b..641c9c767e 100644
@@ -940,11 +940,12 @@ launch_args_parse(int argc, char** argv)
 			}
 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
 				n = atoi(optarg);
-				if (n > 1024)
+				if (n > MIN_TOTAL_NUM_MBUFS)
 					param_total_num_mbufs = (unsigned)n;
 				else
 					rte_exit(EXIT_FAILURE,
-						 "total-num-mbufs should be > 1024\n");
+						 "total-num-mbufs should be > %d\n",
+						 MIN_TOTAL_NUM_MBUFS);
 			}
 			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
 				n = atoi(optarg);
app/test-pmd/testpmd.h +2 -0
index 31f766c965..a633f81b50 100644
@@ -72,6 +72,8 @@
 #define NUMA_NO_CONFIG 0xFF
 #define UMA_NO_CONFIG  0xFF
 
+#define MIN_TOTAL_NUM_MBUFS 1024
+
 typedef uint8_t  lcoreid_t;
 typedef uint16_t portid_t;
 typedef uint16_t queueid_t;
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/1 app/testpmd: change a magic number to macro

From: mingxial <[email protected]>

Add macro MIN_TOTAL_NUM_MBUFS (1024) to indicate what the value of total-num-mbufs should bigger than.

Fixes c87988187fdb ("app/testpmd: add --total-num-mbufs option")
---
 app/test-pmd/parameters.c | 5 +++--
 app/test-pmd/testpmd.h    | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
app/test-pmd/parameters.c +3 -2
index daf6a31b2b..641c9c767e 100644
@@ -940,11 +940,12 @@ launch_args_parse(int argc, char** argv)
 			}
 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs")) {
 				n = atoi(optarg);
-				if (n > 1024)
+				if (n > MIN_TOTAL_NUM_MBUFS)
 					param_total_num_mbufs = (unsigned)n;
 				else
 					rte_exit(EXIT_FAILURE,
-						 "total-num-mbufs should be > 1024\n");
+						 "total-num-mbufs should be > %d\n",
+						 MIN_TOTAL_NUM_MBUFS);
 			}
 			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
 				n = atoi(optarg);
app/test-pmd/testpmd.h +2 -0
index 31f766c965..a633f81b50 100644
@@ -72,6 +72,8 @@
 #define NUMA_NO_CONFIG 0xFF
 #define UMA_NO_CONFIG  0xFF
 
+#define MIN_TOTAL_NUM_MBUFS 1024
+
 typedef uint8_t  lcoreid_t;
 typedef uint16_t portid_t;
 typedef uint16_t queueid_t;
Signature · 1 line
2.25.1
Acked-by on v2 1/1
#2 lore raw

RE: [PATCH v2] app/testpmd: change a magic number to macro

Hi Mingxia,

LGTM.

Quoted 11 lines

-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Thursday, March 31, 2022 10:34 AM
To: [email protected]
Cc: Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Liu, Mingxia <[email protected]>; [email protected]
Subject: [PATCH v2] app/testpmd: change a magic number to macro

From: mingxial <[email protected]>

Quoted 7 lines

Add macro MIN_TOTAL_NUM_MBUFS (1024) to indicate what the value of total-num-mbufs should bigger than.

Fixes c87988187fdb ("app/testpmd: add --total-num-mbufs option")
Quoted 43 lines
---
 app/test-pmd/parameters.c | 5 +++--
 app/test-pmd/testpmd.h    | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
app/test-pmd/parameters.c index renamed from app/test-pmd/parameters.c +0 -0

daf6a31b2b..641c9c767e 100644

app/test-pmd/parameters.c +2 -2
@@ -940,11 +940,12 @@ launch_args_parse(int argc, char** argv)
 			}
 			if (!strcmp(lgopts[opt_idx].name, "total-num-mbufs"))
 {
 				n = atoi(optarg);
-				if (n > 1024)
+				if (n > MIN_TOTAL_NUM_MBUFS)
 					param_total_num_mbufs =
 (unsigned)n;
 				else
 					rte_exit(EXIT_FAILURE,
-						 "total-num-mbufs should be >
 1024\n");
+						 "total-num-mbufs should

be > %d\n",

app/test-pmd/parameters.c +1 -0
+						 MIN_TOTAL_NUM_MBUFS);
 			}
 			if (!strcmp(lgopts[opt_idx].name, "max-pkt-len")) {
 				n = atoi(optarg);
app/test-pmd/testpmd.h index renamed from app/test-pmd/testpmd.h +0 -0

31f766c965..a633f81b50 100644

app/test-pmd/testpmd.h +2 -1
@@ -72,6 +72,8 @@
 #define NUMA_NO_CONFIG 0xFF
 #define UMA_NO_CONFIG  0xFF
 
+#define MIN_TOTAL_NUM_MBUFS 1024
+
 typedef uint8_t  lcoreid_t;
 typedef uint16_t portid_t;
 typedef uint16_t queueid_t;
--

2.25.1

Acked-by Applied
#3 lore raw

Re: [PATCH v2] app/testpmd: change a magic number to macro

Quoted 18 lines · Yuying

Hi Mingxia,

LGTM.

Quoted 14 lines

-----Original Message-----
From: Liu, Mingxia <[email protected]>
Sent: Thursday, March 31, 2022 10:34 AM
To: [email protected]
Cc: Li, Xiaoyun <[email protected]>; Singh, Aman Deep <[email protected]>; Zhang, Yuying <[email protected]>; Liu, Mingxia <[email protected]>; [email protected]
Subject: [PATCH v2] app/testpmd: change a magic number to macro

From: mingxial <[email protected]>

Add macro MIN_TOTAL_NUM_MBUFS (1024) to indicate what the value of total-num-mbufs should bigger than.

Quoted 7 lines
Quoted 4 lines
Fixes c87988187fdb ("app/testpmd: add --total-num-mbufs option")

Updated sign off as:

Applied to dpdk-next-net/main, thanks.