Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH 0/8] Refactor funcs for parsing port cmd
@ 2019-05-21  2:32 ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 1/8] shared/sec: rename parsing port for " ogawa.yasufumi
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This series of update is to refactor functions for parsing `port`
command of SPP workers and its comments, log messages for maintenance.

Yasufumi Ogawa (8):
  shared/sec: rename parsing port for port cmd
  shared/sec: rename parsing rx and tx
  shared/sec: rename parsing comp for port cmd
  shared/sec: rename parsing vlan operations
  shared/sec: rename func for parsing VLAN ID
  shared/sec: rename func for parsing PCP
  shared/sec: rename func for parsing MAC addr
  shared/sec: rename func to convert MAC addr type

 .../secondary/spp_worker_th/cmd_parser.c      | 131 +++++++++---------
 .../secondary/spp_worker_th/command_proc.c    |  28 ++--
 src/shared/secondary/spp_worker_th/spp_port.c |  12 +-
 src/shared/secondary/spp_worker_th/spp_proc.c |  23 +--
 src/shared/secondary/spp_worker_th/spp_proc.h |  16 +--
 5 files changed, 110 insertions(+), 100 deletions(-)

-- 
2.17.1


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

* [spp] [PATCH 1/8] shared/sec: rename parsing port for port cmd
  2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
@ 2019-05-21  2:32 ` " ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 2/8] shared/sec: rename parsing rx and tx ogawa.yasufumi
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to rename `decode_port_port_value()` to `parse_port()`.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 .../secondary/spp_worker_th/cmd_parser.c      | 26 +++++++++----------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 88b4b4f..64828ca 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -31,7 +31,7 @@ const char *CMD_ACT_LIST[] = {
  * List of classifier type. The order of items should be same as the order of
  * enum `spp_classifier_type` defined in spp_proc.h.
  */
-/* TODO(yasufum) fix sinmilar var in command_proc.c */
+/* TODO(yasufum) fix similar vars in command_proc.c */
 const char *CLS_TYPE_LIST[] = {
 	"none",
 	"mac",
@@ -297,7 +297,7 @@ parse_lcore_id(void *output, const char *arg_val)
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of action for component command */
+/* Parse given action in `component` command. */
 static int
 parse_comp_action(void *output, const char *arg_val,
 		int allow_override __attribute__ ((unused)))
@@ -324,7 +324,7 @@ parse_comp_action(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* Parse given name `arg_val` of component. */
+/* Parse given name of `arg_val` in `component` command. */
 static int
 parse_comp_name(void *output, const char *arg_val,
 		int allow_override __attribute__ ((unused)))
@@ -351,7 +351,7 @@ parse_comp_name(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* Parse given lcore ID of `arg_val` of component. */
+/* Parse given lcore ID of `arg_val` in `component` command. */
 static int
 parse_comp_lcore_id(void *output, const char *arg_val,
 				int allow_override __attribute__ ((unused)))
@@ -366,8 +366,8 @@ parse_comp_lcore_id(void *output, const char *arg_val,
 }
 
 /**
- * Parse given type of component of `arg_val`. Return OK code if succeeded, or
- * NG code.
+ * Parse given type of component of `arg_val` in `component` command.
+ * Return OK code if succeeded, or  NG code.
  */
 static int
 parse_comp_type(void *output, const char *arg_val,
@@ -392,7 +392,7 @@ parse_comp_type(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* Parse given action for port of `arg_val`. */
+/* Parse given action for port of `arg_val` in `port` command. */
 static int
 parse_port_action(void *output, const char *arg_val,
 		int allow_override __attribute__ ((unused)))
@@ -420,11 +420,11 @@ parse_port_action(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of port for port command. */
+/* Parse given port uid in port command. */
 static int
-decode_port_port_value(void *output, const char *arg_val, int allow_override)
+parse_port(void *output, const char *arg_val, int allow_override)
 {
-	int ret = SPP_RET_NG;
+	int ret;
 	struct sppwk_port_idx tmp_port;
 	struct sppwk_cmd_port *port = output;
 
@@ -432,7 +432,7 @@ decode_port_port_value(void *output, const char *arg_val, int allow_override)
 	if (ret < SPP_RET_OK)
 		return SPP_RET_NG;
 
-	/* add vlantag command check */
+	/* If action is `add`, check the port is already used for rx and tx. */
 	if (allow_override == 0) {
 		if ((port->wk_action == SPPWK_ACT_ADD) &&
 				(spp_check_used_port(tmp_port.iface_type,
@@ -442,7 +442,7 @@ decode_port_port_value(void *output, const char *arg_val, int allow_override)
 						tmp_port.iface_no,
 						SPP_PORT_RXTX_TX) >= 0)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"Port in used. (port command) val=%s\n",
+				"Port `%s` is already used.\n",
 				arg_val);
 			return SPP_RET_NG;
 		}
@@ -833,7 +833,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "port",
 			.offset = offsetof(struct spp_command, spec.port),
-			.func = decode_port_port_value
+			.func = parse_port
 		},
 		{
 			.name = "port rxtx",
-- 
2.17.1


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

* [spp] [PATCH 2/8] shared/sec: rename parsing rx and tx
  2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 1/8] shared/sec: rename parsing port for " ogawa.yasufumi
@ 2019-05-21  2:32 ` ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 3/8] shared/sec: rename parsing comp for port cmd ogawa.yasufumi
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to rename `decode_port_rxtx_value()` to
`parse_port_rxtx()`.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/shared/secondary/spp_worker_th/cmd_parser.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 64828ca..0083770 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -453,9 +453,9 @@ parse_port(void *output, const char *arg_val, int allow_override)
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of rxtx type for port command */
+/* Parse port rx and tx value. */
 static int
-decode_port_rxtx_value(void *output, const char *arg_val, int allow_override)
+parse_port_rxtx(void *output, const char *arg_val, int allow_override)
 {
 	int ret = SPP_RET_OK;
 	struct sppwk_cmd_port *port = output;
@@ -838,7 +838,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "port rxtx",
 			.offset = offsetof(struct spp_command, spec.port),
-			.func = decode_port_rxtx_value
+			.func = parse_port_rxtx
 		},
 		{
 			.name = "component name",
-- 
2.17.1


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

* [spp] [PATCH 3/8] shared/sec: rename parsing comp for port cmd
  2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 1/8] shared/sec: rename parsing port for " ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 2/8] shared/sec: rename parsing rx and tx ogawa.yasufumi
@ 2019-05-21  2:32 ` ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 4/8] shared/sec: rename parsing vlan operations ogawa.yasufumi
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to rename `decode_port_name_value()` to
`parse_comp_name_portcmd()`. This parsing component name is almost same
as `parse_comp_name()` and ambiguous why it is required, so it should
be confirmed later it is required or not actually.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/shared/secondary/spp_worker_th/cmd_parser.c | 14 ++++++++------
 src/shared/secondary/spp_worker_th/spp_proc.c   |  3 ++-
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 0083770..0c65018 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -334,8 +334,8 @@ parse_comp_name(void *output, const char *arg_val,
 
 	/* Parsing the name is required only for action `start`. */
 	if (component->wk_action == SPPWK_ACT_START) {
-		/* Get lcore ID as comp name, or NG code. */
-		ret = spp_get_component_id(arg_val);
+		/* Check if lcore is already used. */
+		ret = spp_get_component_id(arg_val);  /* Get lcore ID. */
 		if (unlikely(ret >= 0)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
 					"Comp name '%s' is already used.\n",
@@ -483,14 +483,16 @@ parse_port_rxtx(void *output, const char *arg_val, int allow_override)
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of component name for port command */
+/* Parse comp name for `port` command. */
+/* TODO(yasufum) confirm why parsing comp name "for port cmd" is required. */
 static int
-decode_port_name_value(void *output, const char *arg_val,
+parse_comp_name_portcmd(void *output, const char *arg_val,
 				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_OK;
 
-	ret = spp_get_component_id(arg_val);
+	/* Check if lcore is already used. */
+	ret = spp_get_component_id(arg_val);  /* Get lcore ID. */
 	if (unlikely(ret < SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Unknown component name. val=%s\n", arg_val);
@@ -843,7 +845,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "component name",
 			.offset = offsetof(struct spp_command, spec.port.name),
-			.func = decode_port_name_value
+			.func = parse_comp_name_portcmd
 		},
 		{
 			.name = "port vlan operation",
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.c b/src/shared/secondary/spp_worker_th/spp_proc.c
index e552bf1..7333e62 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.c
+++ b/src/shared/secondary/spp_worker_th/spp_proc.c
@@ -725,7 +725,8 @@ get_free_component(void)
 	return SPP_RET_NG;
 }
 
-/* Get component id for specified component name */
+/* Get lcore id for as component name. */
+/* TODO(yasufum) change the name because it's not comp ID. */
 int
 spp_get_component_id(const char *name)
 {
-- 
2.17.1


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

* [spp] [PATCH 4/8] shared/sec: rename parsing vlan operations
  2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
                   ` (2 preceding siblings ...)
  2019-05-21  2:32 ` [spp] [PATCH 3/8] shared/sec: rename parsing comp for port cmd ogawa.yasufumi
@ 2019-05-21  2:32 ` ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 5/8] shared/sec: rename func for parsing VLAN ID ogawa.yasufumi
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to rename `decode_port_vlan_operation()` to
`parse_port_vlan_ops()`, and enum `spp_port_ability_ope` to
`sppwk_port_abl_ops` and its members to be more specific.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 .../secondary/spp_worker_th/cmd_parser.c      | 28 ++++++++++---------
 .../secondary/spp_worker_th/command_proc.c    | 26 ++++++++---------
 src/shared/secondary/spp_worker_th/spp_port.c | 12 ++++----
 src/shared/secondary/spp_worker_th/spp_proc.h | 14 +++++-----
 4 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 0c65018..7f678d5 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -506,17 +506,19 @@ parse_comp_name_portcmd(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of vlan operation for port command */
+/* Parse vlan operation for port command. */
+/* TODO(yasufum) add desc for how to be used. */
+/* TODO(yasufum) add desc for what is port ability. */
 static int
-decode_port_vlan_operation(void *output, const char *arg_val,
-				int allow_override __attribute__ ((unused)))
+parse_port_vlan_ops(void *output, const char *arg_val,
+		int allow_override __attribute__ ((unused)))
 {
-	int ret = SPP_RET_OK;
+	int ret;
 	struct sppwk_cmd_port *port = output;
 	struct spp_port_ability *ability = &port->ability;
 
-	switch (ability->ope) {
-	case SPP_PORT_ABILITY_OPE_NONE:
+	switch (ability->ops) {
+	case SPPWK_PORT_ABL_OPS_NONE:
 		ret = get_list_idx(arg_val, PORT_ABILITY_LIST);
 		if (unlikely(ret <= 0)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
@@ -524,10 +526,10 @@ decode_port_vlan_operation(void *output, const char *arg_val,
 					arg_val);
 			return SPP_RET_NG;
 		}
-		ability->ope  = ret;
+		ability->ops  = ret;
 		ability->rxtx = port->rxtx;
 		break;
-	case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
+	case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
 		/* Nothing to do. */
 		break;
 	default:
@@ -547,8 +549,8 @@ decode_port_vid(void *output, const char *arg_val,
 	struct sppwk_cmd_port *port = output;
 	struct spp_port_ability *ability = &port->ability;
 
-	switch (ability->ope) {
-	case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
+	switch (ability->ops) {
+	case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
 		ret = get_int_in_range(&ability->data.vlantag.vid,
 			arg_val, 0, ETH_VLAN_ID_MAX);
 		if (unlikely(ret < SPP_RET_OK)) {
@@ -575,8 +577,8 @@ decode_port_pcp(void *output, const char *arg_val,
 	struct sppwk_cmd_port *port = output;
 	struct spp_port_ability *ability = &port->ability;
 
-	switch (ability->ope) {
-	case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
+	switch (ability->ops) {
+	case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
 		ret = get_int_in_range(&ability->data.vlantag.pcp,
 				arg_val, 0, SPP_VLAN_PCP_MAX);
 		if (unlikely(ret < SPP_RET_OK)) {
@@ -850,7 +852,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "port vlan operation",
 			.offset = offsetof(struct spp_command, spec.port),
-			.func = decode_port_vlan_operation
+			.func = parse_port_vlan_ops
 		},
 		{
 			.name = "port vid",
diff --git a/src/shared/secondary/spp_worker_th/command_proc.c b/src/shared/secondary/spp_worker_th/command_proc.c
index 19f96d7..fbc0c90 100644
--- a/src/shared/secondary/spp_worker_th/command_proc.c
+++ b/src/shared/secondary/spp_worker_th/command_proc.c
@@ -411,10 +411,10 @@ spp_update_port(enum sppwk_action wk_action,
 		/* Check whether a port has been already registered. */
 		if (ret_check >= SPP_RET_OK) {
 			/* registered */
-			if (ability->ope == SPP_PORT_ABILITY_OPE_ADD_VLANTAG) {
+			if (ability->ops == SPPWK_PORT_ABL_OPS_ADD_VLANTAG) {
 				while ((cnt < SPP_PORT_ABILITY_MAX) &&
-					    (port_info->ability[cnt].ope !=
-					    SPP_PORT_ABILITY_OPE_ADD_VLANTAG))
+					    (port_info->ability[cnt].ops !=
+					    SPPWK_PORT_ABL_OPS_ADD_VLANTAG))
 					cnt++;
 				if (cnt >= SPP_PORT_ABILITY_MAX) {
 					RTE_LOG(ERR, APP, "update VLAN tag "
@@ -436,10 +436,10 @@ spp_update_port(enum sppwk_action wk_action,
 			return SPP_RET_NG;
 		}
 
-		if (ability->ope != SPP_PORT_ABILITY_OPE_NONE) {
+		if (ability->ops != SPPWK_PORT_ABL_OPS_NONE) {
 			while ((cnt < SPP_PORT_ABILITY_MAX) &&
-					(port_info->ability[cnt].ope !=
-					SPP_PORT_ABILITY_OPE_NONE)) {
+					(port_info->ability[cnt].ops !=
+					SPPWK_PORT_ABL_OPS_NONE)) {
 				cnt++;
 			}
 			if (cnt >= SPP_PORT_ABILITY_MAX) {
@@ -460,8 +460,8 @@ spp_update_port(enum sppwk_action wk_action,
 
 	case SPPWK_ACT_DEL:
 		for (cnt = 0; cnt < SPP_PORT_ABILITY_MAX; cnt++) {
-			if (port_info->ability[cnt].ope ==
-					SPP_PORT_ABILITY_OPE_NONE)
+			if (port_info->ability[cnt].ops ==
+					SPPWK_PORT_ABL_OPS_NONE)
 				continue;
 
 			if (port_info->ability[cnt].rxtx == rxtx)
@@ -1045,10 +1045,10 @@ append_vlan_block(const char *name, char **output,
 
 	spp_port_ability_get_info(port_id, rxtx, &info);
 	for (i = 0; i < SPP_PORT_ABILITY_MAX; i++) {
-		switch (info[i].ope) {
-		case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
-		case SPP_PORT_ABILITY_OPE_DEL_VLANTAG:
-			ret = append_vlan_value(&tmp_buff, info[i].ope,
+		switch (info[i].ops) {
+		case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
+		case SPPWK_PORT_ABL_OPS_DEL_VLANTAG:
+			ret = append_vlan_value(&tmp_buff, info[i].ops,
 					info[i].data.vlantag.vid,
 					info[i].data.vlantag.pcp);
 			if (unlikely(ret < SPP_RET_OK))
@@ -1067,7 +1067,7 @@ append_vlan_block(const char *name, char **output,
 		}
 	}
 	if (i == SPP_PORT_ABILITY_MAX) {
-		ret = append_vlan_value(&tmp_buff, SPP_PORT_ABILITY_OPE_NONE,
+		ret = append_vlan_value(&tmp_buff, SPPWK_PORT_ABL_OPS_NONE,
 				0, 0);
 		if (unlikely(ret < SPP_RET_OK))
 			return SPP_RET_NG;
diff --git a/src/shared/secondary/spp_worker_th/spp_port.c b/src/shared/secondary/spp_worker_th/spp_port.c
index 9c0e109..5b02d90 100644
--- a/src/shared/secondary/spp_worker_th/spp_port.c
+++ b/src/shared/secondary/spp_worker_th/spp_port.c
@@ -284,13 +284,13 @@ port_ability_set_ability(
 		memcpy(&out_ability[out_cnt], &in_ability[in_cnt],
 				sizeof(struct spp_port_ability));
 
-		switch (out_ability[out_cnt].ope) {
-		case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
+		switch (out_ability[out_cnt].ops) {
+		case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
 			tag = &out_ability[out_cnt].data.vlantag;
 			tag->tci = rte_cpu_to_be_16(SPP_VLANTAG_CALC_TCI(
 					tag->vid, tag->pcp));
 			break;
-		case SPP_PORT_ABILITY_OPE_DEL_VLANTAG:
+		case SPPWK_PORT_ABL_OPS_DEL_VLANTAG:
 		default:
 			/* Nothing to do. */
 			break;
@@ -344,14 +344,14 @@ port_ability_each_operation(uint16_t port_id,
 	struct spp_port_ability *info = NULL;
 
 	spp_port_ability_get_info(port_id, rxtx, &info);
-	if (unlikely(info[0].ope == SPP_PORT_ABILITY_OPE_NONE))
+	if (unlikely(info[0].ops == SPPWK_PORT_ABL_OPS_NONE))
 		return nb_pkts;
 
 	for (cnt = 0; cnt < SPP_PORT_ABILITY_MAX; cnt++) {
-		if (info[cnt].ope == SPP_PORT_ABILITY_OPE_NONE)
+		if (info[cnt].ops == SPPWK_PORT_ABL_OPS_NONE)
 			break;
 
-		ok_pkts = port_ability_function_list[info[cnt].ope](
+		ok_pkts = port_ability_function_list[info[cnt].ops](
 				pkts, ok_pkts, &info->data);
 	}
 
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.h b/src/shared/secondary/spp_worker_th/spp_proc.h
index 8f9f11d..ffd8972 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.h
+++ b/src/shared/secondary/spp_worker_th/spp_proc.h
@@ -123,10 +123,10 @@ enum spp_port_rxtx {
  * Port ability operation which indicates vlan tag operation on the port
  * (e.g. add vlan tag or delete vlan tag)
  */
-enum spp_port_ability_ope {
-	SPP_PORT_ABILITY_OPE_NONE,	  /**< none */
-	SPP_PORT_ABILITY_OPE_ADD_VLANTAG, /**< add VLAN tag */
-	SPP_PORT_ABILITY_OPE_DEL_VLANTAG, /**< delete VLAN tag */
+enum sppwk_port_abl_ops {
+	SPPWK_PORT_ABL_OPS_NONE,
+	SPPWK_PORT_ABL_OPS_ADD_VLANTAG,
+	SPPWK_PORT_ABL_OPS_DEL_VLANTAG,
 };
 
 /* getopt_long return value for long option */
@@ -174,9 +174,9 @@ union spp_ability_data {
 
 /** Port ability information */
 struct spp_port_ability {
-	enum spp_port_ability_ope ope; /**< Operation */
-	enum spp_port_rxtx rxtx;       /**< rx/tx identifier */
-	union spp_ability_data data;   /**< Port ability data */
+	enum sppwk_port_abl_ops ops;  /**< Port ability Operations */
+	enum spp_port_rxtx rxtx;      /**< rx/tx identifier */
+	union spp_ability_data data;  /**< Port ability data */
 };
 
 /* Attributes for classifying . */
-- 
2.17.1


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

* [spp] [PATCH 5/8] shared/sec: rename func for parsing VLAN ID
  2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
                   ` (3 preceding siblings ...)
  2019-05-21  2:32 ` [spp] [PATCH 4/8] shared/sec: rename parsing vlan operations ogawa.yasufumi
@ 2019-05-21  2:32 ` ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 6/8] shared/sec: rename func for parsing PCP ogawa.yasufumi
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to rename `decode_port_vlan()` to `parse_port_vlan()`
and refactor the function.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/shared/secondary/spp_worker_th/cmd_parser.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 7f678d5..0fd105c 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -540,22 +540,23 @@ parse_port_vlan_ops(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of vid  for port command */
+/* Parse VLAN ID  for port command. */
 static int
-decode_port_vid(void *output, const char *arg_val,
-				int allow_override __attribute__ ((unused)))
+parse_port_vid(void *output, const char *arg_val,
+		int allow_override __attribute__ ((unused)))
 {
-	int ret = SPP_RET_OK;
+	int vlan_id;
 	struct sppwk_cmd_port *port = output;
 	struct spp_port_ability *ability = &port->ability;
 
 	switch (ability->ops) {
 	case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
-		ret = get_int_in_range(&ability->data.vlantag.vid,
+		vlan_id = get_int_in_range(&ability->data.vlantag.vid,
 			arg_val, 0, ETH_VLAN_ID_MAX);
-		if (unlikely(ret < SPP_RET_OK)) {
+		if (unlikely(vlan_id < SPP_RET_OK)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Bad VLAN ID. val=%s\n", arg_val);
+					"Invalid `%s` for parsing VLAN ID.\n",
+					arg_val);
 			return SPP_RET_NG;
 		}
 		ability->data.vlantag.pcp = -1;
@@ -857,7 +858,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "port vid",
 			.offset = offsetof(struct spp_command, spec.port),
-			.func = decode_port_vid
+			.func = parse_port_vid
 		},
 		{
 			.name = "port pcp",
-- 
2.17.1


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

* [spp] [PATCH 6/8] shared/sec: rename func for parsing PCP
  2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
                   ` (4 preceding siblings ...)
  2019-05-21  2:32 ` [spp] [PATCH 5/8] shared/sec: rename func for parsing VLAN ID ogawa.yasufumi
@ 2019-05-21  2:32 ` ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 7/8] shared/sec: rename func for parsing MAC addr ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 8/8] shared/sec: rename func to convert MAC addr type ogawa.yasufumi
  7 siblings, 0 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to rename `decode_port_pcp()` to `parse_port_pcp()`.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/shared/secondary/spp_worker_th/cmd_parser.c | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 0fd105c..fc30463 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -569,22 +569,23 @@ parse_port_vid(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of pcp for port command */
+/* Parse PCP for port command */
 static int
-decode_port_pcp(void *output, const char *arg_val,
-				int allow_override __attribute__ ((unused)))
+parse_port_pcp(void *output, const char *arg_val,
+		int allow_override __attribute__ ((unused)))
 {
-	int ret = SPP_RET_OK;
+	int pcp;
 	struct sppwk_cmd_port *port = output;
 	struct spp_port_ability *ability = &port->ability;
 
 	switch (ability->ops) {
 	case SPPWK_PORT_ABL_OPS_ADD_VLANTAG:
-		ret = get_int_in_range(&ability->data.vlantag.pcp,
+		pcp = get_int_in_range(&ability->data.vlantag.pcp,
 				arg_val, 0, SPP_VLAN_PCP_MAX);
-		if (unlikely(ret < SPP_RET_OK)) {
+		if (unlikely(pcp < SPP_RET_OK)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
-					"Bad VLAN PCP. val=%s\n", arg_val);
+					"Invalid `%s`for parsing PCP.\n",
+					arg_val);
 			return SPP_RET_NG;
 		}
 		break;
@@ -863,7 +864,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 		{
 			.name = "port pcp",
 			.offset = offsetof(struct spp_command, spec.port),
-			.func = decode_port_pcp
+			.func = parse_port_pcp
 		},
 		SPPWK_CMD_NO_PARAMS,
 	},
-- 
2.17.1


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

* [spp] [PATCH 7/8] shared/sec: rename func for parsing MAC addr
  2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
                   ` (5 preceding siblings ...)
  2019-05-21  2:32 ` [spp] [PATCH 6/8] shared/sec: rename func for parsing PCP ogawa.yasufumi
@ 2019-05-21  2:32 ` ogawa.yasufumi
  2019-05-21  2:32 ` [spp] [PATCH 8/8] shared/sec: rename func to convert MAC addr type ogawa.yasufumi
  7 siblings, 0 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to rename `decode_mac_addr_str_value()` to
`parse_mac_addr()` and refactor the function.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 .../secondary/spp_worker_th/cmd_parser.c      | 21 ++++++++++---------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index fc30463..064b18f 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -597,22 +597,23 @@ parse_port_pcp(void *output, const char *arg_val,
 	return SPP_RET_OK;
 }
 
-/* decoding procedure of mac address string */
+/* Parse mac address string. */
 static int
-decode_mac_addr_str_value(void *output, const char *arg_val,
-				int allow_override __attribute__ ((unused)))
+parse_mac_addr(void *output, const char *arg_val,
+		int allow_override __attribute__ ((unused)))
 {
-	int64_t ret = SPP_RET_OK;
+	int64_t res;
 	const char *str_val = arg_val;
 
-	/* if default specification, convert to internal dummy address */
+	/* If given value is the default, use dummy address instead. */
 	if (unlikely(strcmp(str_val, SPP_DEFAULT_CLASSIFIED_SPEC_STR) == 0))
 		str_val = SPP_DEFAULT_CLASSIFIED_DMY_ADDR_STR;
 
-	ret = spp_change_mac_str_to_int64(str_val);
-	if (unlikely(ret < SPP_RET_OK)) {
+	/* Check if the given value is valid. */
+	res = spp_change_mac_str_to_int64(str_val);
+	if (unlikely(res < SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
-				"Bad mac address string. val=%s\n", str_val);
+				"Invalid MAC address `%s`.\n", str_val);
 		return SPP_RET_NG;
 	}
 
@@ -759,7 +760,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 			.name = "mac address",
 			.offset = offsetof(struct spp_command,
 					spec.cls_table.mac),
-			.func = decode_mac_addr_str_value
+			.func = parse_mac_addr
 		},
 		{
 			.name = "port",
@@ -792,7 +793,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
 			.name = "mac address",
 			.offset = offsetof(struct spp_command,
 					spec.cls_table.mac),
-			.func = decode_mac_addr_str_value
+			.func = parse_mac_addr
 		},
 		{
 			.name = "port",
-- 
2.17.1


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

* [spp] [PATCH 8/8] shared/sec: rename func to convert MAC addr type
  2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
                   ` (6 preceding siblings ...)
  2019-05-21  2:32 ` [spp] [PATCH 7/8] shared/sec: rename func for parsing MAC addr ogawa.yasufumi
@ 2019-05-21  2:32 ` ogawa.yasufumi
  7 siblings, 0 replies; 9+ messages in thread
From: ogawa.yasufumi @ 2019-05-21  2:32 UTC (permalink / raw)
  To: spp, ferruh.yigit, ogawa.yasufumi

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is to refactor function for converting MAC address from
string to int64_t type, and revise comments and log messages for
maintenance.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 .../secondary/spp_worker_th/cmd_parser.c      |  4 ++--
 .../secondary/spp_worker_th/command_proc.c    |  2 +-
 src/shared/secondary/spp_worker_th/spp_proc.c | 20 ++++++++++---------
 src/shared/secondary/spp_worker_th/spp_proc.h |  2 +-
 4 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 064b18f..b043b4c 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -610,7 +610,7 @@ parse_mac_addr(void *output, const char *arg_val,
 		str_val = SPP_DEFAULT_CLASSIFIED_DMY_ADDR_STR;
 
 	/* Check if the given value is valid. */
-	res = spp_change_mac_str_to_int64(str_val);
+	res = sppwk_convert_mac_str_to_int64(str_val);
 	if (unlikely(res < SPP_RET_OK)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC,
 				"Invalid MAC address `%s`.\n", str_val);
@@ -710,7 +710,7 @@ parse_cls_port(void *cls_cmd_attr, const char *arg_val,
 			return SPP_RET_NG;
 		}
 	} else if (unlikely(cls_attrs->wk_action == SPPWK_ACT_DEL)) {
-		mac_addr = spp_change_mac_str_to_int64(cls_attrs->mac);
+		mac_addr = sppwk_convert_mac_str_to_int64(cls_attrs->mac);
 		if (mac_addr < 0)
 			return SPP_RET_NG;
 
diff --git a/src/shared/secondary/spp_worker_th/command_proc.c b/src/shared/secondary/spp_worker_th/command_proc.c
index fbc0c90..17d0645 100644
--- a/src/shared/secondary/spp_worker_th/command_proc.c
+++ b/src/shared/secondary/spp_worker_th/command_proc.c
@@ -145,7 +145,7 @@ spp_update_classifier_table(
 			"( type = mac, mac addr = %s, port = %d:%d )\n",
 			mac_addr_str, port->iface_type, port->iface_no);
 
-	ret_mac = spp_change_mac_str_to_int64(mac_addr_str);
+	ret_mac = sppwk_convert_mac_str_to_int64(mac_addr_str);
 	if (unlikely(ret_mac == -1)) {
 		RTE_LOG(ERR, APP, "MAC address format error. ( mac = %s )\n",
 			mac_addr_str);
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.c b/src/shared/secondary/spp_worker_th/spp_proc.c
index 7333e62..4105fb8 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.c
+++ b/src/shared/secondary/spp_worker_th/spp_proc.c
@@ -943,9 +943,9 @@ int spp_format_port_string(char *port, enum port_type iface_type, int iface_no)
 	return SPP_RET_OK;
 }
 
-/* Change mac address of 'aa:bb:cc:dd:ee:ff' to int64 and return it */
+/* Convert MAC address of 'aa:bb:cc:dd:ee:ff' to value of int64_t. */
 int64_t
-spp_change_mac_str_to_int64(const char *mac)
+sppwk_convert_mac_str_to_int64(const char *macaddr)
 {
 	int64_t ret_mac = 0;
 	int64_t token_val = 0;
@@ -955,19 +955,20 @@ spp_change_mac_str_to_int64(const char *mac)
 	char *saveptr = NULL;
 	char *endptr = NULL;
 
-	RTE_LOG(DEBUG, APP, "MAC address change. (mac = %s)\n", mac);
+	RTE_LOG(DEBUG, APP, "Try to convert MAC addr `%s`.\n", macaddr);
 
-	strcpy(tmp_mac, mac);
+	strcpy(tmp_mac, macaddr);
 	while (1) {
-		/* Split by colon(':') */
+		/* Split by colon ':'. */
 		char *ret_tok = strtok_r(str, ":", &saveptr);
 		if (unlikely(ret_tok == NULL))
 			break;
 
 		/* Check for mal-formatted address */
 		if (unlikely(token_cnt >= ETHER_ADDR_LEN)) {
-			RTE_LOG(ERR, APP, "MAC address format error. "
-					"(mac = %s)\n", mac);
+			RTE_LOG(ERR, APP,
+					"Invalid MAC address `%s`.\n",
+					macaddr);
 			return SPP_RET_NG;
 		}
 
@@ -983,8 +984,9 @@ spp_change_mac_str_to_int64(const char *mac)
 		str = NULL;
 	}
 
-	RTE_LOG(DEBUG, APP, "MAC address change. (mac = %s => 0x%08lx)\n",
-			 mac, ret_mac);
+	RTE_LOG(DEBUG, APP,
+			"Succeeded to convert MAC addr `%s` to `0x%08lx`.\n",
+			macaddr, ret_mac);
 	return ret_mac;
 }
 
diff --git a/src/shared/secondary/spp_worker_th/spp_proc.h b/src/shared/secondary/spp_worker_th/spp_proc.h
index ffd8972..dffa6a5 100644
--- a/src/shared/secondary/spp_worker_th/spp_proc.h
+++ b/src/shared/secondary/spp_worker_th/spp_proc.h
@@ -652,7 +652,7 @@ spp_format_port_string(char *port, enum port_type iface_type, int iface_no);
  * @retval 0< int64 that store mac address
  * @retval SPP_RET_NG
  */
-int64_t spp_change_mac_str_to_int64(const char *mac);
+int64_t sppwk_convert_mac_str_to_int64(const char *macaddr);
 
 /**
  * Set mange data address
-- 
2.17.1


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

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-21  2:32 [spp] [PATCH 0/8] Refactor funcs for parsing port cmd ogawa.yasufumi
2019-05-21  2:32 ` [spp] [PATCH 1/8] shared/sec: rename parsing port for " ogawa.yasufumi
2019-05-21  2:32 ` [spp] [PATCH 2/8] shared/sec: rename parsing rx and tx ogawa.yasufumi
2019-05-21  2:32 ` [spp] [PATCH 3/8] shared/sec: rename parsing comp for port cmd ogawa.yasufumi
2019-05-21  2:32 ` [spp] [PATCH 4/8] shared/sec: rename parsing vlan operations ogawa.yasufumi
2019-05-21  2:32 ` [spp] [PATCH 5/8] shared/sec: rename func for parsing VLAN ID ogawa.yasufumi
2019-05-21  2:32 ` [spp] [PATCH 6/8] shared/sec: rename func for parsing PCP ogawa.yasufumi
2019-05-21  2:32 ` [spp] [PATCH 7/8] shared/sec: rename func for parsing MAC addr ogawa.yasufumi
2019-05-21  2:32 ` [spp] [PATCH 8/8] shared/sec: rename func to convert MAC addr type ogawa.yasufumi

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox