* [spp] [PATCH 1/3] shared/sec: rename func for parsing cls table
2019-05-21 2:32 [spp] [PATCH 0/3] Refactor func for parsing cls cmd ogawa.yasufumi
@ 2019-05-21 2:32 ` ogawa.yasufumi
2019-05-21 2:32 ` [spp] [PATCH 2/3] shared/sec: rename func to get type idx for cls ogawa.yasufumi
2019-05-21 2:32 ` [spp] [PATCH 3/3] shared/sec: rename func for parsing VLAN ID ogawa.yasufumi
2 siblings, 0 replies; 4+ 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 function for parsing and getting index of
action `decode_classifier_action_value()` to `parse_cls_action()`,
and refactor comments and log messages.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
.../secondary/spp_worker_th/cmd_parser.c | 31 +++++++++++--------
1 file changed, 18 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 b043b4c..70cf254 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -621,27 +621,32 @@ parse_mac_addr(void *output, const char *arg_val,
return SPP_RET_OK;
}
-/* decoding procedure of action for classifier_table command */
+/**
+ * Parse given action for getting index of actions for `classifier_table`
+ * command.
+ */
static int
-decode_classifier_action_value(void *output, const char *arg_val,
- int allow_override __attribute__ ((unused)))
+parse_cls_action(void *output, const char *arg_val,
+ int allow_override __attribute__ ((unused)))
{
- int ret = SPP_RET_OK;
- ret = get_list_idx(arg_val, CMD_ACT_LIST);
- if (unlikely(ret <= 0)) {
- RTE_LOG(ERR, SPP_COMMAND_PROC, "Unknown port action. val=%s\n",
+ int idx;
+ idx = get_list_idx(arg_val, CMD_ACT_LIST);
+ if (unlikely(idx <= 0)) {
+ RTE_LOG(ERR, SPP_COMMAND_PROC,
+ "Failed to get index for action `%s`.\n",
arg_val);
return SPP_RET_NG;
}
- if (unlikely(ret != SPPWK_ACT_ADD) &&
- unlikely(ret != SPPWK_ACT_DEL)) {
- RTE_LOG(ERR, SPP_COMMAND_PROC, "Unknown port action. val=%s\n",
+ if (unlikely(idx != SPPWK_ACT_ADD) &&
+ unlikely(idx != SPPWK_ACT_DEL)) {
+ RTE_LOG(ERR, SPP_COMMAND_PROC,
+ "Unknown action `%s` for port.\n",
arg_val);
return SPP_RET_NG;
}
- *(int *)output = ret;
+ *(int *)output = idx;
return SPP_RET_OK;
}
@@ -748,7 +753,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
.name = "action",
.offset = offsetof(struct spp_command,
spec.cls_table.wk_action),
- .func = decode_classifier_action_value
+ .func = parse_cls_action
},
{
.name = "type",
@@ -775,7 +780,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
.name = "action",
.offset = offsetof(struct spp_command,
spec.cls_table.wk_action),
- .func = decode_classifier_action_value
+ .func = parse_cls_action
},
{
.name = "type",
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [spp] [PATCH 2/3] shared/sec: rename func to get type idx for cls
2019-05-21 2:32 [spp] [PATCH 0/3] Refactor func for parsing cls cmd ogawa.yasufumi
2019-05-21 2:32 ` [spp] [PATCH 1/3] shared/sec: rename func for parsing cls table ogawa.yasufumi
@ 2019-05-21 2:32 ` ogawa.yasufumi
2019-05-21 2:32 ` [spp] [PATCH 3/3] shared/sec: rename func for parsing VLAN ID ogawa.yasufumi
2 siblings, 0 replies; 4+ 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 function for parsing getting index of type of
classifier `decode_classifier_type_value()` to `parse_cls_type()`,
and refactoring.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
.../secondary/spp_worker_th/cmd_parser.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 70cf254..4cd36ca 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -650,21 +650,21 @@ parse_cls_action(void *output, const char *arg_val,
return SPP_RET_OK;
}
-/* decoding procedure of type for classifier_table command */
+/* Parse cls type and get index for classifier_table command. */
static int
-decode_classifier_type_value(void *output, const char *arg_val,
- int allow_override __attribute__ ((unused)))
+parse_cls_type(void *output, const char *arg_val,
+ int allow_override __attribute__ ((unused)))
{
- int ret = SPP_RET_OK;
- ret = get_list_idx(arg_val, CLS_TYPE_LIST);
- if (unlikely(ret <= 0)) {
+ int idx;
+ idx = get_list_idx(arg_val, CLS_TYPE_LIST);
+ if (unlikely(idx <= 0)) {
RTE_LOG(ERR, SPP_COMMAND_PROC,
"Unknown classifier type. val=%s\n",
arg_val);
return SPP_RET_NG;
}
- *(int *)output = ret;
+ *(int *)output = idx;
return SPP_RET_OK;
}
@@ -759,7 +759,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
.name = "type",
.offset = offsetof(struct spp_command,
spec.cls_table.type),
- .func = decode_classifier_type_value
+ .func = parse_cls_type
},
{
.name = "mac address",
@@ -786,7 +786,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
.name = "type",
.offset = offsetof(struct spp_command,
spec.cls_table.type),
- .func = decode_classifier_type_value
+ .func = parse_cls_type
},
{
.name = "vlan id",
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [spp] [PATCH 3/3] shared/sec: rename func for parsing VLAN ID
2019-05-21 2:32 [spp] [PATCH 0/3] Refactor func for parsing cls cmd ogawa.yasufumi
2019-05-21 2:32 ` [spp] [PATCH 1/3] shared/sec: rename func for parsing cls table ogawa.yasufumi
2019-05-21 2:32 ` [spp] [PATCH 2/3] shared/sec: rename func to get type idx for cls ogawa.yasufumi
@ 2019-05-21 2:32 ` ogawa.yasufumi
2 siblings, 0 replies; 4+ 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 function for parsing and getting VLAN ID for
classifier_table command `decode_classifier_vid_value()` to
`parse_cls_vid()` and refactoring.
Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
src/shared/secondary/spp_worker_th/cmd_parser.c | 16 ++++++++--------
1 file changed, 8 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 4cd36ca..f78664b 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -668,15 +668,15 @@ parse_cls_type(void *output, const char *arg_val,
return SPP_RET_OK;
}
-/* decoding procedure of vlan id for classifier_table command */
+/* Parse VLAN ID for classifier_table command. */
static int
-decode_classifier_vid_value(void *output, const char *arg_val,
- int allow_override __attribute__ ((unused)))
+parse_cls_vid(void *output, const char *arg_val,
+ int allow_override __attribute__ ((unused)))
{
- int ret = SPP_RET_NG;
- ret = get_int_in_range(output, arg_val, 0, ETH_VLAN_ID_MAX);
- if (unlikely(ret < SPP_RET_OK)) {
- RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad VLAN ID. val=%s\n",
+ int idx;
+ idx = get_int_in_range(output, arg_val, 0, ETH_VLAN_ID_MAX);
+ if (unlikely(idx < SPP_RET_OK)) {
+ RTE_LOG(ERR, SPP_COMMAND_PROC, "Invalid VLAN ID `%s`.\n",
arg_val);
return SPP_RET_NG;
}
@@ -792,7 +792,7 @@ cmd_ops_list[][SPPWK_MAX_PARAMS] = {
.name = "vlan id",
.offset = offsetof(struct spp_command,
spec.cls_table.vid),
- .func = decode_classifier_vid_value
+ .func = parse_cls_vid
},
{
.name = "mac address",
--
2.17.1
^ permalink raw reply [flat|nested] 4+ messages in thread