Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 1/6] shared/sec: refactor func for getting VLAN ID
Date: Tue, 21 May 2019 11:31:17 +0900	[thread overview]
Message-ID: <1558405882-8201-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1558405882-8201-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

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

Functions for getting VLAN ID or PCAP are named as `get_int_value()`
and `get_uint_value()`. It is not describing the feature and should be
renamed. This update is to change the names to `get_vlan_int_val()` and
`get_vlan_uint_val()`, and revise comments for the functions.

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

diff --git a/src/shared/secondary/spp_worker_th/cmd_parser.c b/src/shared/secondary/spp_worker_th/cmd_parser.c
index 1c069cc..cf7a7a6 100644
--- a/src/shared/secondary/spp_worker_th/cmd_parser.c
+++ b/src/shared/secondary/spp_worker_th/cmd_parser.c
@@ -219,36 +219,33 @@ get_arrary_index(const char *match, const char *list[])
 	return SPP_RET_NG;
 }
 
-/* Get int type value */
+/**
+ * Get VLAN ID or PCP as int from given val. It validates if the val is in the
+ * range from min to max given as third and fourth args.
+ */
 static int
-get_int_value(
-		int *output,
-		const char *arg_val,
-		int min,
-		int max)
+get_vlan_int_val(int *output, const char *arg_val, int min, int max)
 {
-	int ret = 0;
+	int ret;
 	char *endptr = NULL;
 	ret = strtol(arg_val, &endptr, 0);
 	if (unlikely(endptr == arg_val) || unlikely(*endptr != '\0'))
 		return SPP_RET_NG;
-
 	if (unlikely(ret < min) || unlikely(ret > max))
 		return SPP_RET_NG;
-
 	*output = ret;
 	return SPP_RET_OK;
 }
 
-/* Get unsigned int type value */
+/**
+ * Get VLAN ID or PCP as uint from given val. It validates if the val is in the
+ * range from min to max given as third and fourth args.
+ */
 static int
-get_uint_value(
-		unsigned int *output,
-		const char *arg_val,
-		unsigned int min,
+get_vlan_uint_val(unsigned int *output, const char *arg_val, unsigned int min,
 		unsigned int max)
 {
-	unsigned int ret = SPP_RET_OK;
+	unsigned int ret;
 	char *endptr = NULL;
 	ret = strtoul(arg_val, &endptr, 0);
 	if (unlikely(endptr == arg_val) || unlikely(*endptr != '\0'))
@@ -292,7 +289,7 @@ static int
 decode_core_value(void *output, const char *arg_val)
 {
 	int ret = SPP_RET_OK;
-	ret = get_uint_value(output, arg_val, 0, RTE_MAX_LCORE-1);
+	ret = get_vlan_uint_val(output, arg_val, 0, RTE_MAX_LCORE-1);
 	if (unlikely(ret < 0)) {
 		RTE_LOG(ERR, SPP_COMMAND_PROC, "Bad core id. val=%s\n",
 				arg_val);
@@ -537,7 +534,7 @@ decode_port_vid(void *output, const char *arg_val,
 
 	switch (ability->ope) {
 	case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
-		ret = get_int_value(&ability->data.vlantag.vid,
+		ret = get_vlan_int_val(&ability->data.vlantag.vid,
 			arg_val, 0, ETH_VLAN_ID_MAX);
 		if (unlikely(ret < SPP_RET_OK)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
@@ -565,7 +562,7 @@ decode_port_pcp(void *output, const char *arg_val,
 
 	switch (ability->ope) {
 	case SPP_PORT_ABILITY_OPE_ADD_VLANTAG:
-		ret = get_int_value(&ability->data.vlantag.pcp,
+		ret = get_vlan_int_val(&ability->data.vlantag.pcp,
 				arg_val, 0, SPP_VLAN_PCP_MAX);
 		if (unlikely(ret < SPP_RET_OK)) {
 			RTE_LOG(ERR, SPP_COMMAND_PROC,
@@ -652,7 +649,7 @@ decode_classifier_vid_value(void *output, const char *arg_val,
 				int allow_override __attribute__ ((unused)))
 {
 	int ret = SPP_RET_NG;
-	ret = get_int_value(output, arg_val, 0, ETH_VLAN_ID_MAX);
+	ret = get_vlan_int_val(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",
 				arg_val);
-- 
2.17.1


  reply	other threads:[~2019-05-21  2:33 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-21  2:31 [spp] [PATCH 0/6] Refactor parsing resource UID ogawa.yasufumi
2019-05-21  2:31 ` ogawa.yasufumi [this message]
2019-05-21  2:31 ` [spp] [PATCH 2/6] shared/sec: rename misspelled get_arrary_index ogawa.yasufumi
2019-05-21  2:31 ` [spp] [PATCH 3/6] shared/sec: remove misunderstandable validate func ogawa.yasufumi
2019-05-21  2:31 ` [spp] [PATCH 4/6] shared/sec: rename func for parsing port UID ogawa.yasufumi
2019-05-21  2:31 ` [spp] [PATCH 5/6] shared/sec: fix funcs for getting int and uint ogawa.yasufumi
2019-05-21  2:31 ` [spp] [PATCH 6/6] shared/sec: rename func for parsing lcore ID ogawa.yasufumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1558405882-8201-2-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).