DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] app/testpmd: fix memory alloc for dscp table
@ 2018-11-05 16:22 Jasvinder Singh
  2018-11-05 16:26 ` [dpdk-dev] [PATCH v2] testpmd: " Jasvinder Singh
  0 siblings, 1 reply; 5+ messages in thread
From: Jasvinder Singh @ 2018-11-05 16:22 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, jingjing.wu, bernard.iremonger

The patch fixes the memory allocation for the meter dscp table.

Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands")

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
 app/test-pmd/cmdline_mtr.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index 63f32828f..287429d2e 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -74,7 +74,7 @@ parse_uint(uint64_t *value, const char *str)
 }
 
 static int
-parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
+parse_dscp_table_entries(char *str, enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	int i = 0;
@@ -84,23 +84,23 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 		return 0;
 
 	/* Allocate memory for dscp table */
-	dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+	*dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
 		sizeof(enum rte_mtr_color));
-	if (dscp_table == NULL)
+	if (*dscp_table== NULL)
 		return -1;
 
 	while (1) {
 		if (strcmp(token, "G") == 0 ||
 			strcmp(token, "g") == 0)
-			dscp_table[i++] = RTE_MTR_GREEN;
+			*dscp_table[i++] = RTE_MTR_GREEN;
 		else if (strcmp(token, "Y") == 0 ||
 			strcmp(token, "y") == 0)
-			dscp_table[i++] = RTE_MTR_YELLOW;
+			*dscp_table[i++] = RTE_MTR_YELLOW;
 		else if (strcmp(token, "R") == 0 ||
 			strcmp(token, "r") == 0)
-			dscp_table[i++] = RTE_MTR_RED;
+			*dscp_table[i++] = RTE_MTR_RED;
 		else {
-			free(dscp_table);
+			free(*dscp_table);
 			return -1;
 		}
 		if (i == MAX_DSCP_TABLE_ENTRIES)
@@ -108,7 +108,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 
 		token = strtok_r(str, PARSE_DELIMITER, &str);
 		if (token == NULL) {
-			free(dscp_table);
+			free(*dscp_table);
 			return -1;
 		}
 	}
@@ -117,7 +117,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 
 static int
 parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
-	enum rte_mtr_color *dscp_table)
+	enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	uint64_t previous_mtr_color = 0;
@@ -195,7 +195,7 @@ parse_policer_action_string(char *p_str, uint32_t action_mask,
 
 static int
 parse_multi_token_string(char *t_str, uint16_t *port_id,
-	uint32_t *mtr_id, enum rte_mtr_color *dscp_table)
+	uint32_t *mtr_id, enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	uint64_t val;
@@ -794,7 +794,7 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
 	params.meter_profile_id = res->profile_id;
 
 	/* Parse meter input color string params */
-	ret = parse_meter_color_str(c_str, &use_prev_meter_color, dscp_table);
+	ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
 	if (ret) {
 		printf(" Meter input color params string parse error\n");
 		return;
@@ -1141,7 +1141,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
 	int ret;
 
 	/* Parse string */
-	ret = parse_multi_token_string(t_str, &port_id, &mtr_id, dscp_table);
+	ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &dscp_table);
 	if (ret) {
 		printf(" Multi token string parse error\n");
 		return;
-- 
2.17.1

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

* [dpdk-dev] [PATCH v2] testpmd: fix memory alloc for dscp table
  2018-11-05 16:22 [dpdk-dev] [PATCH] app/testpmd: fix memory alloc for dscp table Jasvinder Singh
@ 2018-11-05 16:26 ` Jasvinder Singh
  2018-11-05 19:26   ` Ferruh Yigit
  2018-11-06 10:26   ` [dpdk-dev] [PATCH v3] app/testpmd: " Jasvinder Singh
  0 siblings, 2 replies; 5+ messages in thread
From: Jasvinder Singh @ 2018-11-05 16:26 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit, jingjing.wu, bernard.iremonger

The patch fixes the memory allocation for the meter dscp table.

Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands")

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
v2
- fix checkpatch errors

 app/test-pmd/cmdline_mtr.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index 63f32828f..846de88db 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -74,7 +74,7 @@ parse_uint(uint64_t *value, const char *str)
 }
 
 static int
-parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
+parse_dscp_table_entries(char *str, enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	int i = 0;
@@ -84,23 +84,23 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 		return 0;
 
 	/* Allocate memory for dscp table */
-	dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+	*dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
 		sizeof(enum rte_mtr_color));
-	if (dscp_table == NULL)
+	if (*dscp_table == NULL)
 		return -1;
 
 	while (1) {
 		if (strcmp(token, "G") == 0 ||
 			strcmp(token, "g") == 0)
-			dscp_table[i++] = RTE_MTR_GREEN;
+			*dscp_table[i++] = RTE_MTR_GREEN;
 		else if (strcmp(token, "Y") == 0 ||
 			strcmp(token, "y") == 0)
-			dscp_table[i++] = RTE_MTR_YELLOW;
+			*dscp_table[i++] = RTE_MTR_YELLOW;
 		else if (strcmp(token, "R") == 0 ||
 			strcmp(token, "r") == 0)
-			dscp_table[i++] = RTE_MTR_RED;
+			*dscp_table[i++] = RTE_MTR_RED;
 		else {
-			free(dscp_table);
+			free(*dscp_table);
 			return -1;
 		}
 		if (i == MAX_DSCP_TABLE_ENTRIES)
@@ -108,7 +108,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 
 		token = strtok_r(str, PARSE_DELIMITER, &str);
 		if (token == NULL) {
-			free(dscp_table);
+			free(*dscp_table);
 			return -1;
 		}
 	}
@@ -117,7 +117,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 
 static int
 parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
-	enum rte_mtr_color *dscp_table)
+	enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	uint64_t previous_mtr_color = 0;
@@ -195,7 +195,7 @@ parse_policer_action_string(char *p_str, uint32_t action_mask,
 
 static int
 parse_multi_token_string(char *t_str, uint16_t *port_id,
-	uint32_t *mtr_id, enum rte_mtr_color *dscp_table)
+	uint32_t *mtr_id, enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	uint64_t val;
@@ -794,7 +794,7 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
 	params.meter_profile_id = res->profile_id;
 
 	/* Parse meter input color string params */
-	ret = parse_meter_color_str(c_str, &use_prev_meter_color, dscp_table);
+	ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
 	if (ret) {
 		printf(" Meter input color params string parse error\n");
 		return;
@@ -1141,7 +1141,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
 	int ret;
 
 	/* Parse string */
-	ret = parse_multi_token_string(t_str, &port_id, &mtr_id, dscp_table);
+	ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &dscp_table);
 	if (ret) {
 		printf(" Multi token string parse error\n");
 		return;
-- 
2.17.1

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

* Re: [dpdk-dev] [PATCH v2] testpmd: fix memory alloc for dscp table
  2018-11-05 16:26 ` [dpdk-dev] [PATCH v2] testpmd: " Jasvinder Singh
@ 2018-11-05 19:26   ` Ferruh Yigit
  2018-11-06 10:26   ` [dpdk-dev] [PATCH v3] app/testpmd: " Jasvinder Singh
  1 sibling, 0 replies; 5+ messages in thread
From: Ferruh Yigit @ 2018-11-05 19:26 UTC (permalink / raw)
  To: Jasvinder Singh, dev; +Cc: jingjing.wu, bernard.iremonger

On 11/5/2018 4:26 PM, Jasvinder Singh wrote:
> The patch fixes the memory allocation for the meter dscp table.
> 
> Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands")
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

- title should be: "app/testpmd: ..."
- needs stable tag: "Cc: stable@dpdk.org"

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

* [dpdk-dev] [PATCH v3] app/testpmd: fix memory alloc for dscp table
  2018-11-05 16:26 ` [dpdk-dev] [PATCH v2] testpmd: " Jasvinder Singh
  2018-11-05 19:26   ` Ferruh Yigit
@ 2018-11-06 10:26   ` Jasvinder Singh
  2018-11-12 16:43     ` Dumitrescu, Cristian
  1 sibling, 1 reply; 5+ messages in thread
From: Jasvinder Singh @ 2018-11-06 10:26 UTC (permalink / raw)
  To: dev; +Cc: stable, ferruh.yigit, jingjing.wu, bernard.iremonger

The patch fixes the memory allocation for the meter dscp table.

Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing commands")
cc: stable@dpdk.org

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
v3
- change title
- cc to stable@dpdk.org

v2
- fix checkpatch errors

 app/test-pmd/cmdline_mtr.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c
index 63f32828f..846de88db 100644
--- a/app/test-pmd/cmdline_mtr.c
+++ b/app/test-pmd/cmdline_mtr.c
@@ -74,7 +74,7 @@ parse_uint(uint64_t *value, const char *str)
 }
 
 static int
-parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
+parse_dscp_table_entries(char *str, enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	int i = 0;
@@ -84,23 +84,23 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 		return 0;
 
 	/* Allocate memory for dscp table */
-	dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
+	*dscp_table = (enum rte_mtr_color *)malloc(MAX_DSCP_TABLE_ENTRIES *
 		sizeof(enum rte_mtr_color));
-	if (dscp_table == NULL)
+	if (*dscp_table == NULL)
 		return -1;
 
 	while (1) {
 		if (strcmp(token, "G") == 0 ||
 			strcmp(token, "g") == 0)
-			dscp_table[i++] = RTE_MTR_GREEN;
+			*dscp_table[i++] = RTE_MTR_GREEN;
 		else if (strcmp(token, "Y") == 0 ||
 			strcmp(token, "y") == 0)
-			dscp_table[i++] = RTE_MTR_YELLOW;
+			*dscp_table[i++] = RTE_MTR_YELLOW;
 		else if (strcmp(token, "R") == 0 ||
 			strcmp(token, "r") == 0)
-			dscp_table[i++] = RTE_MTR_RED;
+			*dscp_table[i++] = RTE_MTR_RED;
 		else {
-			free(dscp_table);
+			free(*dscp_table);
 			return -1;
 		}
 		if (i == MAX_DSCP_TABLE_ENTRIES)
@@ -108,7 +108,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 
 		token = strtok_r(str, PARSE_DELIMITER, &str);
 		if (token == NULL) {
-			free(dscp_table);
+			free(*dscp_table);
 			return -1;
 		}
 	}
@@ -117,7 +117,7 @@ parse_dscp_table_entries(char *str, enum rte_mtr_color *dscp_table)
 
 static int
 parse_meter_color_str(char *c_str, uint32_t *use_prev_meter_color,
-	enum rte_mtr_color *dscp_table)
+	enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	uint64_t previous_mtr_color = 0;
@@ -195,7 +195,7 @@ parse_policer_action_string(char *p_str, uint32_t action_mask,
 
 static int
 parse_multi_token_string(char *t_str, uint16_t *port_id,
-	uint32_t *mtr_id, enum rte_mtr_color *dscp_table)
+	uint32_t *mtr_id, enum rte_mtr_color **dscp_table)
 {
 	char *token;
 	uint64_t val;
@@ -794,7 +794,7 @@ static void cmd_create_port_meter_parsed(void *parsed_result,
 	params.meter_profile_id = res->profile_id;
 
 	/* Parse meter input color string params */
-	ret = parse_meter_color_str(c_str, &use_prev_meter_color, dscp_table);
+	ret = parse_meter_color_str(c_str, &use_prev_meter_color, &dscp_table);
 	if (ret) {
 		printf(" Meter input color params string parse error\n");
 		return;
@@ -1141,7 +1141,7 @@ static void cmd_set_port_meter_dscp_table_parsed(void *parsed_result,
 	int ret;
 
 	/* Parse string */
-	ret = parse_multi_token_string(t_str, &port_id, &mtr_id, dscp_table);
+	ret = parse_multi_token_string(t_str, &port_id, &mtr_id, &dscp_table);
 	if (ret) {
 		printf(" Multi token string parse error\n");
 		return;
-- 
2.17.1

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

* Re: [dpdk-dev] [PATCH v3] app/testpmd: fix memory alloc for dscp table
  2018-11-06 10:26   ` [dpdk-dev] [PATCH v3] app/testpmd: " Jasvinder Singh
@ 2018-11-12 16:43     ` Dumitrescu, Cristian
  0 siblings, 0 replies; 5+ messages in thread
From: Dumitrescu, Cristian @ 2018-11-12 16:43 UTC (permalink / raw)
  To: Singh, Jasvinder, dev
  Cc: stable, Yigit, Ferruh, Wu, Jingjing, Iremonger, Bernard



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Jasvinder Singh
> Sent: Tuesday, November 6, 2018 10:27 AM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Yigit, Ferruh <ferruh.yigit@intel.com>; Wu, Jingjing
> <jingjing.wu@intel.com>; Iremonger, Bernard
> <bernard.iremonger@intel.com>
> Subject: [dpdk-dev] [PATCH v3] app/testpmd: fix memory alloc for dscp table
> 
> The patch fixes the memory allocation for the meter dscp table.
> 
> Fixes: e63b50162aa3 ("app/testpmd: clean metering and policing
> commands")
> cc: stable@dpdk.org
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> ---

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied to next-pipeline tree, thanks!

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

end of thread, other threads:[~2018-11-12 16:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-11-05 16:22 [dpdk-dev] [PATCH] app/testpmd: fix memory alloc for dscp table Jasvinder Singh
2018-11-05 16:26 ` [dpdk-dev] [PATCH v2] testpmd: " Jasvinder Singh
2018-11-05 19:26   ` Ferruh Yigit
2018-11-06 10:26   ` [dpdk-dev] [PATCH v3] app/testpmd: " Jasvinder Singh
2018-11-12 16:43     ` Dumitrescu, Cristian

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).