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 341ECA0096 for ; Wed, 5 Jun 2019 20:11:16 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 4334D1B9EB; Wed, 5 Jun 2019 20:10:09 +0200 (CEST) Received: from mail-pl1-f196.google.com (mail-pl1-f196.google.com [209.85.214.196]) by dpdk.org (Postfix) with ESMTP id 54E9D1B9BC for ; Wed, 5 Jun 2019 20:10:03 +0200 (CEST) Received: by mail-pl1-f196.google.com with SMTP id x7so8990388plr.12 for ; Wed, 05 Jun 2019 11:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xdUsjvA+XM/A8lvdK1H1mldU1CJ2JFzy3kElJGpilZc=; b=SbmtxByho++T/git7LJLpHg6h9B8iK+L82H87gk7dQfWcaXB5wQ+qskhl29I7tR/oI CyvjOMn3vJdjmu2+3M7+rBWZ1tJlZk2pf52idh44VNJwCQAIQh0nAS89crnPYgVFAs0j +4DGSeYDb0H416stwzeE6IF3+EyyYxJrdeA6ZuVvmXXaFjXLDif3dfQ9oeYDaaPqxEsz BaOAo+UCdNu+TjdQEP8CLv4s+zir3FbomXqQhGYvcTex83Yr7rGBs4kKlTjiX/3COgAQ bBL7BI+fPkls6S+239kTuD1Crgmlu5fIkpOcSLcSycqqb57NPa6WbUl8oyuZh04V36cu jeTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xdUsjvA+XM/A8lvdK1H1mldU1CJ2JFzy3kElJGpilZc=; b=XS+5cMWjNKJ4dTML8tIzOUYoXaSXCWI9m8rsHcbFzhzb5h6MWNDvvH/5fK66WDexd5 I8wsbeDDeLxhKVWrq17J4u9yXLRtYxo0Yb60KBSi6gA20Ph/GKR5iTA05wqb7z9nlXwU N9vyWIEtSvL1a7R4cAXybjtVwjlQ/WRio5uFBwc7UFN9lESVPJv3X0Jas9pD5TVLjbVn rXrMVkLfMMUN/sWApWjW98KdtPe21ZmGLSiNm0xPErWWUdqTgi5b4jGxeL5HD7yKfR8Z HsbUnBMZ5IbQDEy+9HuYAsKiWrLxV5ya1pRbWjyyspTiC7BSrwgb6ZzDvXuH04Lv86bY E08g== X-Gm-Message-State: APjAAAXeOQRZRqESFNqE2TpiiFk8qBRhXAUwJGA/vBO+KJShETEprcTN 9mQ+elb3844WFWZdQDmsaWwMcXMTF/4= X-Google-Smtp-Source: APXvYqwjwmQN9Bf44C2eWcZEhMFpvzQAMnwe0nnFC592qnrr9C1X3lwYnIuHnxS339yPX1JpvvI4GQ== X-Received: by 2002:a17:902:20ec:: with SMTP id v41mr43147565plg.142.1559758202204; Wed, 05 Jun 2019 11:10:02 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id a7sm19081888pgj.42.2019.06.05.11.10.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Jun 2019 11:10:01 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Wed, 5 Jun 2019 11:09:48 -0700 Message-Id: <20190605180948.22414-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190605180948.22414-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190605180948.22414-1-stephen@networkplumber.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v4 8/8] app/testpmd: use rte_ether_unformat_addr X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The cmdline_parse_ether_addr does not need to be used everywhere in testpmd. Can use rte_ether_unformat_addr instead. As an added bonus it eliminates some code for copying. Signed-off-by: Stephen Hemminger --- app/test-pmd/cmdline_flow.c | 5 ++--- app/test-pmd/config.c | 10 +++------- app/test-pmd/parameters.c | 15 +++------------ 3 files changed, 8 insertions(+), 22 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 201bd9de56e0..2b02ca29b7ac 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -18,7 +18,6 @@ #include #include #include -#include #include #include "testpmd.h" @@ -4627,8 +4626,8 @@ parse_mac_addr(struct context *ctx, const struct token *token, /* Only network endian is supported. */ if (!arg->hton) goto error; - ret = cmdline_parse_etheraddr(NULL, str, &tmp, size); - if (ret < 0 || (unsigned int)ret != len) + ret = rte_ether_unformat_addr(str, &tmp); + if (ret < 0) goto error; if (!ctx->object) return len; diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index ab458c8d2837..1d804705d96c 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -49,7 +49,6 @@ #include #endif #include -#include #include #include "testpmd.h" @@ -2278,19 +2277,16 @@ pkt_fwd_config_display(struct fwd_config *cfg) void set_fwd_eth_peer(portid_t port_id, char *peer_addr) { - uint8_t c, new_peer_addr[6]; + struct rte_ether_addr new_peer_addr; if (!rte_eth_dev_is_valid_port(port_id)) { printf("Error: Invalid port number %i\n", port_id); return; } - if (cmdline_parse_etheraddr(NULL, peer_addr, &new_peer_addr, - sizeof(new_peer_addr)) < 0) { + if (rte_ether_unformat_addr(peer_addr, &new_peer_addr) < 0) { printf("Error: Invalid ethernet address: %s\n", peer_addr); return; } - for (c = 0; c < 6; c++) - peer_eth_addrs[port_id].addr_bytes[c] = - new_peer_addr[c]; + peer_eth_addrs[port_id] = new_peer_addr; } int diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c index 245b610641ee..975a97807009 100644 --- a/app/test-pmd/parameters.c +++ b/app/test-pmd/parameters.c @@ -39,10 +39,6 @@ #include #include #include -#ifdef RTE_LIBRTE_CMDLINE -#include -#include -#endif #ifdef RTE_LIBRTE_PMD_BOND #include #endif @@ -227,8 +223,7 @@ init_peer_eth_addrs(char *config_filename) if (fgets(buf, sizeof(buf), config_file) == NULL) break; - if (cmdline_parse_etheraddr(NULL, buf, &peer_eth_addrs[i], - sizeof(peer_eth_addrs[i])) < 0) { + if (rte_ether_unformat_addr(buf, &peer_eth_addrs[i]) < 0) { printf("Bad MAC address format on line %d\n", i+1); fclose(config_file); return -1; @@ -727,7 +722,6 @@ launch_args_parse(int argc, char** argv) } if (!strcmp(lgopts[opt_idx].name, "eth-peer")) { char *port_end; - uint8_t c, peer_addr[6]; errno = 0; n = strtoul(optarg, &port_end, 10); @@ -739,14 +733,11 @@ launch_args_parse(int argc, char** argv) "eth-peer: port %d >= RTE_MAX_ETHPORTS(%d)\n", n, RTE_MAX_ETHPORTS); - if (cmdline_parse_etheraddr(NULL, port_end, - &peer_addr, sizeof(peer_addr)) < 0) + if (rte_ether_unformat_addr(port_end, + &peer_eth_addrs[n]) < 0) rte_exit(EXIT_FAILURE, "Invalid ethernet address: %s\n", port_end); - for (c = 0; c < 6; c++) - peer_eth_addrs[n].addr_bytes[c] = - peer_addr[c]; nb_peer_eth_addrs++; } #endif -- 2.20.1