From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id EA554A0B1F for ; Tue, 21 May 2019 04:34:52 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 878D8568A; Tue, 21 May 2019 04:34:52 +0200 (CEST) Received: from tama50.ecl.ntt.co.jp (tama50.ecl.ntt.co.jp [129.60.39.147]) by dpdk.org (Postfix) with ESMTP id 805DF4CA6 for ; Tue, 21 May 2019 04:34:50 +0200 (CEST) Received: from vc2.ecl.ntt.co.jp (vc2.ecl.ntt.co.jp [129.60.86.154]) by tama50.ecl.ntt.co.jp (8.13.8/8.13.8) with ESMTP id x4L2YnW3003221; Tue, 21 May 2019 11:34:49 +0900 Received: from vc2.ecl.ntt.co.jp (localhost [127.0.0.1]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 4E10D638742; Tue, 21 May 2019 11:34:49 +0900 (JST) Received: from localhost.localdomain (lobster.nslab.ecl.ntt.co.jp [129.60.13.95]) by vc2.ecl.ntt.co.jp (Postfix) with ESMTP id 3F51B63877B; Tue, 21 May 2019 11:34:49 +0900 (JST) From: ogawa.yasufumi@lab.ntt.co.jp To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp Date: Tue, 21 May 2019 11:32:24 +0900 Message-Id: <1558405944-8355-9-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558405944-8355-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> References: <1558405944-8355-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> X-TM-AS-MML: disable Subject: [spp] [PATCH 8/8] shared/sec: rename func to convert MAC addr type X-BeenThere: spp@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Soft Patch Panel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spp-bounces@dpdk.org Sender: "spp" From: Yasufumi Ogawa 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 --- .../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