From patchwork Tue Jul 2 16:50:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55896 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id BA4861B9B4; Tue, 2 Jul 2019 18:50:30 +0200 (CEST) Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by dpdk.org (Postfix) with ESMTP id 5E4C41B999 for ; Tue, 2 Jul 2019 18:50:27 +0200 (CEST) Received: by mail-pl1-f193.google.com with SMTP id bi6so659265plb.12 for ; Tue, 02 Jul 2019 09:50:27 -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=YoOvWYzczrT5avm06Uw1YHk6vrCL5G8NYOIBDXVY7YM=; b=RmZVswUZg2CMzem+8RVhEgsJuXCYvMf+mr0EdI/rE89kkRv1kEltqvbLSU3FcrVbB1 yc7ryrL62AazuwrLSsgoI/64o6+FivOdwlYVZ/tEjq5zEaxEeFL0CGo67QkwckmZRzD0 RKTQ06fDqJ3lki2HijU37fhfZxHhTOXDG1fUSEKARC6E4aWMB2tdTMGaszQSWnciaK/W Y4UQtHJnvg+V1cXNVzagxteKn6PDbYeWt9DNE0xd5ZsshKSp7Nh5MQP8lfLCvhVUWk5/ eo/M97FmQhI43Q/kUPZtZIYi4FCfwAt8cAjJBcky7icPI1vYdLIR1CBuqtpEVdjeXv7K lIwQ== 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=YoOvWYzczrT5avm06Uw1YHk6vrCL5G8NYOIBDXVY7YM=; b=aVmzCvpHBQbUOgO3ak9jwod5McxrFX/VU+WpdG3IfonorQTJdUnXzTJ5suPGIED0nu hbksiljVKucimOugTZTUwZ6x1f0n8seV8je7TfSl8rGt9WSgnCNadPJ7IbAvYlb2kqFk +QzXxGlVbiyhijL1swsIDM4wk/CE3ANeiN03zN1Q0hVDC82uOOWElpC9RKPhfpgtD+1A a9VxI9YI9AqUrSyvW9DLBppASrDJxk7UE+hIaNnkat4YkPDHwW2fSwRAH9/UqdoWhdiN dapHxwKe7/fhodgeK+9OEzod8fKxNVEgaKa78tBSM3QZVJQhcGxQdzqDNeeGG01e9fVH wSdA== X-Gm-Message-State: APjAAAXvQzGv/b11AaPSW/i8v1vPKQVeAxnLjaP/LWqMu6hXOAEbR7KC LmAS7IL3YLR0b0T7PHx300lG6E/4Kh0= X-Google-Smtp-Source: APXvYqxEayU6EOSz7cawOS37hYuNKyIjrQtEOa1eJOBg2Gu61KnMuwXYUqcsCJfohs5KGLphnemOwA== X-Received: by 2002:a17:902:f087:: with SMTP id go7mr36341097plb.330.1562086226197; Tue, 02 Jul 2019 09:50:26 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h62sm14340230pgc.54.2019.07.02.09.50.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 09:50:25 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Rami Rosen , Andrew Rybchenko Date: Tue, 2 Jul 2019 09:50:10 -0700 Message-Id: <20190702165017.3802-2-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702165017.3802-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702165017.3802-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 1/8] net/rte_ether: deinline non-critical functions 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" Formatting Ethernet address and getting a random value are not in critical path so they should not be inlined. Signed-off-by: Stephen Hemminger Acked-by: Rami Rosen Reviewed-by: Andrew Rybchenko --- drivers/net/axgbe/Makefile | 2 +- drivers/net/memif/Makefile | 2 +- lib/librte_net/Makefile | 1 + lib/librte_net/meson.build | 2 +- lib/librte_net/rte_ether.c | 29 +++++++++++++++++++++++++++++ lib/librte_net/rte_ether.h | 25 ++++--------------------- lib/librte_net/rte_net_version.map | 7 +++++++ 7 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 lib/librte_net/rte_ether.c diff --git a/drivers/net/axgbe/Makefile b/drivers/net/axgbe/Makefile index 72215aedaf55..c2d4336800c0 100644 --- a/drivers/net/axgbe/Makefile +++ b/drivers/net/axgbe/Makefile @@ -17,7 +17,7 @@ LIBABIVER := 1 LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool LDLIBS += -lrte_pci -lrte_bus_pci -LDLIBS += -lrte_ethdev +LDLIBS += -lrte_ethdev -lrte_net # # all source are stored in SRCS-y diff --git a/drivers/net/memif/Makefile b/drivers/net/memif/Makefile index fdbdf3378019..3d92b08f259b 100644 --- a/drivers/net/memif/Makefile +++ b/drivers/net/memif/Makefile @@ -21,7 +21,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API # - rte_mp_reply # - rte_mp_request_sync LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -LDLIBS += -lrte_ethdev -lrte_kvargs +LDLIBS += -lrte_ethdev -lrte_kvargs -lrte_net LDLIBS += -lrte_hash LDLIBS += -lrte_bus_vdev diff --git a/lib/librte_net/Makefile b/lib/librte_net/Makefile index c3082069ab50..1244c9fd54c9 100644 --- a/lib/librte_net/Makefile +++ b/lib/librte_net/Makefile @@ -14,6 +14,7 @@ LIBABIVER := 1 SRCS-$(CONFIG_RTE_LIBRTE_NET) := rte_net.c SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_net_crc.c +SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_ether.c SRCS-$(CONFIG_RTE_LIBRTE_NET) += rte_arp.c # install includes diff --git a/lib/librte_net/meson.build b/lib/librte_net/meson.build index 7d66f693cbf3..868a93fd6b6b 100644 --- a/lib/librte_net/meson.build +++ b/lib/librte_net/meson.build @@ -16,5 +16,5 @@ headers = files('rte_ip.h', 'rte_net_crc.h', 'rte_mpls.h') -sources = files('rte_arp.c', 'rte_net.c', 'rte_net_crc.c') +sources = files('rte_arp.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c') deps += ['mbuf'] diff --git a/lib/librte_net/rte_ether.c b/lib/librte_net/rte_ether.c new file mode 100644 index 000000000000..974fe815b335 --- /dev/null +++ b/lib/librte_net/rte_ether.c @@ -0,0 +1,29 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright(c) 2010-2014 Intel Corporation + */ + +#include + +void +rte_eth_random_addr(uint8_t *addr) +{ + uint64_t rand = rte_rand(); + uint8_t *p = (uint8_t *)&rand; + + rte_memcpy(addr, p, RTE_ETHER_ADDR_LEN); + addr[0] &= (uint8_t)~RTE_ETHER_GROUP_ADDR; /* clear multicast bit */ + addr[0] |= RTE_ETHER_LOCAL_ADMIN_ADDR; /* set local assignment bit */ +} + +void +rte_ether_format_addr(char *buf, uint16_t size, + const struct rte_ether_addr *eth_addr) +{ + snprintf(buf, size, "%02X:%02X:%02X:%02X:%02X:%02X", + eth_addr->addr_bytes[0], + eth_addr->addr_bytes[1], + eth_addr->addr_bytes[2], + eth_addr->addr_bytes[3], + eth_addr->addr_bytes[4], + eth_addr->addr_bytes[5]); +} diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 7be9b4890af7..3caae0d98f6d 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -207,15 +207,8 @@ static inline int rte_is_valid_assigned_ether_addr(const struct rte_ether_addr * * @param addr * A pointer to Ethernet address. */ -static inline void rte_eth_random_addr(uint8_t *addr) -{ - uint64_t rand = rte_rand(); - uint8_t *p = (uint8_t *)&rand; - - rte_memcpy(addr, p, RTE_ETHER_ADDR_LEN); - addr[0] &= (uint8_t)~RTE_ETHER_GROUP_ADDR; /* clear multicast bit */ - addr[0] |= RTE_ETHER_LOCAL_ADMIN_ADDR; /* set local assignment bit */ -} +void +rte_eth_random_addr(uint8_t *addr); /** * Fast copy an Ethernet address. @@ -254,19 +247,9 @@ static inline void rte_ether_addr_copy(const struct rte_ether_addr *ea_from, * @param eth_addr * A pointer to a ether_addr structure. */ -static inline void +void rte_ether_format_addr(char *buf, uint16_t size, - const struct rte_ether_addr *eth_addr) -{ - snprintf(buf, size, "%02X:%02X:%02X:%02X:%02X:%02X", - eth_addr->addr_bytes[0], - eth_addr->addr_bytes[1], - eth_addr->addr_bytes[2], - eth_addr->addr_bytes[3], - eth_addr->addr_bytes[4], - eth_addr->addr_bytes[5]); -} - + const struct rte_ether_addr *eth_addr); /** * Ethernet header: Contains the destination address, source address * and frame type. diff --git a/lib/librte_net/rte_net_version.map b/lib/librte_net/rte_net_version.map index 26c06e7c7ae7..f1e1b84ab491 100644 --- a/lib/librte_net/rte_net_version.map +++ b/lib/librte_net/rte_net_version.map @@ -13,6 +13,13 @@ DPDK_17.05 { } DPDK_16.11; +DPDK_19.08 { + global: + + rte_eth_random_addr; + rte_ether_format_addr; +} DPDK_17.05; + EXPERIMENTAL { global: From patchwork Tue Jul 2 16:50:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55897 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 33D881B9C0; Tue, 2 Jul 2019 18:50:33 +0200 (CEST) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) by dpdk.org (Postfix) with ESMTP id E585A1B9A3 for ; Tue, 2 Jul 2019 18:50:28 +0200 (CEST) Received: by mail-pf1-f177.google.com with SMTP id t16so8525333pfe.11 for ; Tue, 02 Jul 2019 09:50:28 -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=HT7fgvqo3DxGVdfkCgxmfvm3m5YXMqttimfnKXT3DRU=; b=Aqk4B0umBaFK5vxLhPf9q3zOU7i0Mq3HAItKSHJh+/jdTOCJTczyW7DW/ksmnlfydM iNLngsOfm+wfGXl/KXxb3waqRlv0yIYWZFS9weEzi7lSMWkXftq1b3xrTfaF19D/jdrH lwdQRgI3nKx5lEnODdrhT+uo6utHifRetWX0XSYnZQGxxS6SVzon5KpFrEmxBvOvIrls Rk9/qP1dYW5LFLODdYiK1utAJfmDzrx24omXRt19nQVILmzOWHen67c100HFkqWj0SMw 4/xtKG6Ggc8ku2Loo3x97XJOJ2uIEFIZIFycyA/Czx/1pIoi6ZRN+58FIwUcuAb9BWCu hNxA== 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=HT7fgvqo3DxGVdfkCgxmfvm3m5YXMqttimfnKXT3DRU=; b=NtxhXNP+lU5QE8UJmvcCwWxePsvIsRnyKkmt6M/YR8Z4DalgWU022ai7IhKW3zYUBs CZS5lxedzBqMJ13pmcRmEzYxrmMZANszgQNvHK20XQBLTiVjFq5UDsK6xER8uHOveOcG it22XGFrmEcQ/EpIXStKc2T0Xw18mK6OOsEylYYr5W1H63wuDIL0aDOv8yaGIP1/HLv1 8BRQESbxH9tNubGfy9UrNGB5UnCV+HcyVPYy+rYc6rcLd2gKFVwFFWM8SVYkgd/B/JBZ +soAE9PoTluH2U03NIu3JvJEr1P2rOfCiN8jf9QzOa0UiEuzxOaU5ur/txSSaIkVY/19 C+vw== X-Gm-Message-State: APjAAAVdxOJk+vclEcBqrs29Cik+WwH75nITRZUvg5KCCjxHJ6fHwIz3 K4ITwwdEpJ68Bts6N0whkfE1FY2jq2Y= X-Google-Smtp-Source: APXvYqzYvHLa8FINxvlvH6h3OWuCvcKzceabOwf76TzJmiALJw01Qo+oNFGnUCTn2g1uC82BqKdsUA== X-Received: by 2002:a17:90a:8a91:: with SMTP id x17mr6684094pjn.95.1562086227726; Tue, 02 Jul 2019 09:50:27 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h62sm14340230pgc.54.2019.07.02.09.50.26 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 09:50:26 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko Date: Tue, 2 Jul 2019 09:50:11 -0700 Message-Id: <20190702165017.3802-3-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702165017.3802-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702165017.3802-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 2/8] net/ether: add function to convert string to ethernet address 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" Make a function that can be used in place of eth_aton_r to convert a string to rte_ether_addr. This function allows both byte (xx:xx:xx:xx:xx:xx) and word (XXXX:XXXX:XXXX) format and has the same lack of error handling as the original. This also allows ethdev to no longer have a hard dependency on the cmdline library. Signed-off-by: Stephen Hemminger Reviewed-by: Andrew Rybchenko --- lib/librte_net/rte_ether.c | 47 ++++++++++++++++++++++++++++++ lib/librte_net/rte_ether.h | 14 +++++++++ lib/librte_net/rte_net_version.map | 1 + 3 files changed, 62 insertions(+) diff --git a/lib/librte_net/rte_ether.c b/lib/librte_net/rte_ether.c index 974fe815b335..acc8a0e938c5 100644 --- a/lib/librte_net/rte_ether.c +++ b/lib/librte_net/rte_ether.c @@ -27,3 +27,50 @@ rte_ether_format_addr(char *buf, uint16_t size, eth_addr->addr_bytes[4], eth_addr->addr_bytes[5]); } + +/* + * Like ether_aton_r but can handle either + * XX:XX:XX:XX:XX:XX or XXXX:XXXX:XXXX + */ +int +rte_ether_unformat_addr(const char *s, struct rte_ether_addr *ea) +{ + unsigned int o0, o1, o2, o3, o4, o5; + int n; + + n = sscanf(s, "%x:%x:%x:%x:%x:%x", + &o0, &o1, &o2, &o3, &o4, &o5); + + if (n == 6) { + if (o0 > UINT8_MAX || o1 > UINT8_MAX || o2 > UINT8_MAX || + o3 > UINT8_MAX || o4 > UINT8_MAX || o5 > UINT8_MAX) + return -1; + + ea->addr_bytes[0] = o0; + ea->addr_bytes[1] = o1; + ea->addr_bytes[2] = o2; + ea->addr_bytes[3] = o3; + ea->addr_bytes[4] = o4; + ea->addr_bytes[5] = o5; + + return 0; + } + + /* Support the format XXXX:XXXX:XXXX */ + n = sscanf(s, "%x:%x:%x", &o0, &o1, &o2); + if (n == 3) { + if (o0 > UINT16_MAX || o1 > UINT16_MAX || o2 > UINT16_MAX) + return -1; + + ea->addr_bytes[0] = o0 >> 8; + ea->addr_bytes[1] = o0 & 0xff; + ea->addr_bytes[2] = o1 >> 8; + ea->addr_bytes[3] = o1 & 0xff; + ea->addr_bytes[4] = o2 >> 8; + ea->addr_bytes[5] = o2 & 0xff; + return 0; + } + /* unknown format */ + + return -1; +} diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 3caae0d98f6d..8edc7e217b25 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -250,6 +250,20 @@ static inline void rte_ether_addr_copy(const struct rte_ether_addr *ea_from, void rte_ether_format_addr(char *buf, uint16_t size, const struct rte_ether_addr *eth_addr); +/** + * Convert string with Ethernet address to an ether_addr. + * + * @param str + * A pointer to buffer contains the formatted MAC address. + * @param eth_addr + * A pointer to a ether_addr structure. + * @return + * 0 if successful + * -1 and sets rte_errno if invalid string + */ +int __rte_experimental +rte_ether_unformat_addr(const char *str, struct rte_ether_addr *eth_addr); + /** * Ethernet header: Contains the destination address, source address * and frame type. diff --git a/lib/librte_net/rte_net_version.map b/lib/librte_net/rte_net_version.map index f1e1b84ab491..f4c915069d57 100644 --- a/lib/librte_net/rte_net_version.map +++ b/lib/librte_net/rte_net_version.map @@ -25,4 +25,5 @@ EXPERIMENTAL { rte_net_make_rarp_packet; rte_net_skip_ip6_ext; + rte_ether_unformat_addr; }; From patchwork Tue Jul 2 16:50:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55898 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3F8BB1B9CB; Tue, 2 Jul 2019 18:50:36 +0200 (CEST) Received: from mail-pf1-f196.google.com (mail-pf1-f196.google.com [209.85.210.196]) by dpdk.org (Postfix) with ESMTP id 027B41B9B1 for ; Tue, 2 Jul 2019 18:50:30 +0200 (CEST) Received: by mail-pf1-f196.google.com with SMTP id d126so8540803pfd.2 for ; Tue, 02 Jul 2019 09:50:29 -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=LJP5NUGKYyva7BnvgS/UxCqLM/1j8w47JpFJi1u1tNU=; b=gJl60F/Gzdf1IoQv8bqvJY9Gp/XMygrVCXSzyPujRbIzjKrUG7+4iNvjH+1HoS+oCz E9jj2h8UO9u0SaCUG1Fw1/wbGs5/YS98a8sT1VlV4wS5j/2/LWz41GtQ2QbCjzzIWB4I LGM+w+FG7jX/eK6pydG6MUES+sGDhQFG5HSJ5mYdmFsm+vc6hPrfZ4mDWpSGv6sIFoxk xDWDJ/BAVWfxUS0qm0C23qQKbW2LP5UjQZaXXk/tGOcdWjCgSITjiYbuc7nOmH7RIhFj aQmDH+If4ZvhAlbOyqior45sQe2PKjGH8LVzYdG/40YC5u8Un4anX3OpCf9TDdOub2Bi 9QCw== 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=LJP5NUGKYyva7BnvgS/UxCqLM/1j8w47JpFJi1u1tNU=; b=h6jLnlPDJZnQNm+DexTxajRH3Na6drkXg5UUuW3FczNhzUtCxSWLx8AS4kDK69Llb1 EngRar8yuYfu41TipWuQGuiWDg0eEpydH7bRELQmLWm73gqGCZhcQtRm3zEy9aQQY8F5 BrN+09l/KrOQd/OENfFEKqEP+uMKnw5ksK8YA89QyqDsnDZR8Qw/UHEv7ZpDQ2P94Zsv sDhEnzSdpb6dPX03twONxdRyQjZkbCKe7TOE1OHt7cLRQt3aj02ywzJnjb0zG+rqUTTt 0SXOkxT67BPlz6INCktCk/Yi1u2itxWSFe9VW9WbCXoucP3uA2m1U7bZODCgJ9sBD8jU jAew== X-Gm-Message-State: APjAAAV1s0CocudK3Bll7xi0foxRW6a+29SS+WqJRw6IAfQ1OV/EzFs+ xDPjVsmN5CppDspsY15PypayPNv8aeQ= X-Google-Smtp-Source: APXvYqyhTefAwyjHNt0iX7E++cgiqp1MhNjqMYiTsri11KKRXCkIMNmjx2QRgk1AC2K9FLu/6vEsdw== X-Received: by 2002:a17:90a:1b4a:: with SMTP id q68mr6652084pjq.61.1562086228978; Tue, 02 Jul 2019 09:50:28 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h62sm14340230pgc.54.2019.07.02.09.50.27 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 09:50:28 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 2 Jul 2019 09:50:12 -0700 Message-Id: <20190702165017.3802-4-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702165017.3802-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702165017.3802-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 3/8] ethdev: use new ethernet parsing function 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" Use rte_eth_unformat_addr, so that ethdev can be built and work without the cmdline library. The dependency on cmdline was an arrangement of convenience anyway. Signed-off-by: Stephen Hemminger --- lib/Makefile | 1 - lib/librte_ethdev/Makefile | 2 +- lib/librte_ethdev/meson.build | 2 +- lib/librte_ethdev/rte_class_eth.c | 9 +-------- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 791e0d9911d6..82b2c4bfa8ea 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -25,7 +25,6 @@ DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ethdev DEPDIRS-librte_ethdev := librte_net librte_eal librte_mempool librte_ring DEPDIRS-librte_ethdev += librte_mbuf DEPDIRS-librte_ethdev += librte_kvargs -DEPDIRS-librte_ethdev += librte_cmdline DEPDIRS-librte_ethdev += librte_meter DIRS-$(CONFIG_RTE_LIBRTE_BBDEV) += librte_bbdev DEPDIRS-librte_bbdev := librte_eal librte_mempool librte_mbuf diff --git a/lib/librte_ethdev/Makefile b/lib/librte_ethdev/Makefile index 8d4a02630c4f..60bcc2227878 100644 --- a/lib/librte_ethdev/Makefile +++ b/lib/librte_ethdev/Makefile @@ -12,7 +12,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_net -lrte_eal -lrte_mempool -lrte_ring -LDLIBS += -lrte_mbuf -lrte_kvargs -lrte_cmdline -lrte_meter +LDLIBS += -lrte_mbuf -lrte_kvargs -lrte_meter EXPORT_MAP := rte_ethdev_version.map diff --git a/lib/librte_ethdev/meson.build b/lib/librte_ethdev/meson.build index 8d6165b2a7dd..f75d428c96d0 100644 --- a/lib/librte_ethdev/meson.build +++ b/lib/librte_ethdev/meson.build @@ -26,4 +26,4 @@ headers = files('rte_ethdev.h', 'rte_tm.h', 'rte_tm_driver.h') -deps += ['net', 'kvargs', 'cmdline', 'meter'] +deps += ['net', 'kvargs', 'meter'] diff --git a/lib/librte_ethdev/rte_class_eth.c b/lib/librte_ethdev/rte_class_eth.c index 873a653532ad..6338355e2557 100644 --- a/lib/librte_ethdev/rte_class_eth.c +++ b/lib/librte_ethdev/rte_class_eth.c @@ -4,7 +4,6 @@ #include -#include #include #include #include @@ -43,19 +42,13 @@ static int eth_mac_cmp(const char *key __rte_unused, const char *value, void *opaque) { - int ret; struct rte_ether_addr mac; const struct rte_eth_dev_data *data = opaque; struct rte_eth_dev_info dev_info; uint32_t index; /* Parse devargs MAC address. */ - /* - * cannot use ether_aton_r(value, &mac) - * because of include conflict with rte_ether.h - */ - ret = cmdline_parse_etheraddr(NULL, value, &mac, sizeof(mac)); - if (ret < 0) + if (rte_ether_unformat_addr(value, &mac) < 0) return -1; /* invalid devargs value */ /* Return 0 if devargs MAC is matching one of the device MACs. */ From patchwork Tue Jul 2 16:50:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55899 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 619221B9D0; Tue, 2 Jul 2019 18:50:38 +0200 (CEST) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) by dpdk.org (Postfix) with ESMTP id 4A4691B9B9 for ; Tue, 2 Jul 2019 18:50:31 +0200 (CEST) Received: by mail-pg1-f196.google.com with SMTP id w10so7960792pgj.7 for ; Tue, 02 Jul 2019 09:50:31 -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=8fFcBaPZKjQQPsKQQeFeSAG72mshjjR9mGZfTCJM/8s=; b=UTnZLWi+Pk9TmMj6cTXH9dUugLhUesc+BFjdMiEAMulvGD+bgyoAzdrtI20u83fPHw zUmSkgf4Sl2ybaHh0qYMpkUcN0qOYTe+3WUFPsSo6rDMcjv5KO31YH8QCOmd8UTHJ32t hq2Vp7/FHGK8715x1VpFbH6FSS0yqbe9A3+QnnxHZRKlSReYos6+nmZ7oAUBSGC2DX3n WI2JWO7ORmVAk43SLTcQrfY0t5YKvjKCUsNmzAA9TVZTzMN2abWERWwcP0ZJiwflA2rE V3YabIwt5M0YL36LCVXXMMGgzisWI/UXqwIEeSfLE851Yip2T925IDMTb7KvCJJio2si qSLA== 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=8fFcBaPZKjQQPsKQQeFeSAG72mshjjR9mGZfTCJM/8s=; b=WoiInsVp/qflBI4TWWHh3NTR92Pg8vFSnQYWbdc0tg+xWvzBXReO8nlMLxkdOuvWki 2H/quOi5IXfYancKaSLtIjSC9XLEF1nI9dknnA5y1gxlc7bmxCzGObYGHmVL3j7iLS4R GFqa8d3HzJ/Ea9YKBT+7PBNlgeotLzpMGPJo1HR2z8eUSm8i/psXvzU/VCDfhSg3X6u3 7ZUgNz2bWsPA/RmfOKIG8dYcOl9UBrqDzNHvAxN2OyS0ewCm6w2JfOWYUdjfwIyQaaBc mUEB49fx0RQ7iSIXqxByHetVYosoaDfJQElaMxXEGCVHl/xkjanxm2+LQRndDE3MlMDJ 8d/Q== X-Gm-Message-State: APjAAAVBwyU+wwtBSq1o1FirSYVdg4TGpohTVj7/dCuMLqhswQuFDC8Q shVS3u2rWidbUQm2Jt/NLwr3zxM8 X-Google-Smtp-Source: APXvYqy1Z6YZLrsbNdb3w3c+f13YGUa41H3g09zpC2AUykBBXoWZEhuxln58uzpXdZMJQhcySWqp2A== X-Received: by 2002:a17:90a:2305:: with SMTP id f5mr7011508pje.128.1562086230209; Tue, 02 Jul 2019 09:50:30 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h62sm14340230pgc.54.2019.07.02.09.50.29 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 09:50:29 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger , Andrew Rybchenko Date: Tue, 2 Jul 2019 09:50:13 -0700 Message-Id: <20190702165017.3802-5-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702165017.3802-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702165017.3802-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 4/8] net/ether: use bitops to speedup comparison 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" Using bit operations like or and xor is faster than a loop on all architectures. Really just explicit unrolling. Similar cast to uint16 unaligned is already done in other functions here. Signed-off-by: Stephen Hemminger Reviewed-by: Andrew Rybchenko --- lib/librte_net/rte_ether.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index 8edc7e217b25..feb35a33c94b 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -81,11 +81,10 @@ struct rte_ether_addr { static inline int rte_is_same_ether_addr(const struct rte_ether_addr *ea1, const struct rte_ether_addr *ea2) { - int i; - for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) - if (ea1->addr_bytes[i] != ea2->addr_bytes[i]) - return 0; - return 1; + const unaligned_uint16_t *w1 = (const uint16_t *)ea1; + const unaligned_uint16_t *w2 = (const uint16_t *)ea2; + + return ((w1[0] ^ w2[0]) | (w1[1] ^ w2[1]) | (w1[2] ^ w2[2])) == 0; } /** @@ -100,11 +99,9 @@ static inline int rte_is_same_ether_addr(const struct rte_ether_addr *ea1, */ static inline int rte_is_zero_ether_addr(const struct rte_ether_addr *ea) { - int i; - for (i = 0; i < RTE_ETHER_ADDR_LEN; i++) - if (ea->addr_bytes[i] != 0x00) - return 0; - return 1; + const unaligned_uint16_t *w = (const uint16_t *)ea; + + return (w[0] | w[1] | w[2]) == 0; } /** From patchwork Tue Jul 2 16:50:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55900 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6710A1B9E8; Tue, 2 Jul 2019 18:50:41 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id AA1701B9BB for ; Tue, 2 Jul 2019 18:50:32 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id q4so6480723pgj.8 for ; Tue, 02 Jul 2019 09:50:32 -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=5jmpHlnhidg0ShQ7XItCpgaXpVK1xXtowoDpbYktXUk=; b=Hb4G5hPL601+iGgON0aJQ289Puxc1XaaWdrLjLUAWFGvbLb2M3FMHJE2fy+6BL8pnW tKDSuAkGrwTVPa+i029qtTcrlbzaaYIIrC4ewwwwedyxafLf7RxQidV3HhEDBD1INBTu wLYLhhqd7VzimC34eKky2wXQARmw4BaqtnCkdJ2RVQpj9ZlnGuuJJc4OnWjHOrYyS0Xv Bjb9STTkI6eITuSm4cAFzDCRkjMvkWiU4i4owWIAAWpQk6gQ01NlXxn1D/13h3zMmtWZ p2oBZaKqZyo+eP/H/tUNJX7pKYi17vMrNze+bPWN+stYgx7/4J4vJNiEvU1HDRg+AGC8 uqgQ== 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=5jmpHlnhidg0ShQ7XItCpgaXpVK1xXtowoDpbYktXUk=; b=HPekVUPzzk4zGJVBz6nvVfEMTS7sZAYM/ofQih4ln6d0yiGCW94VgLO8HHm0hT2+T1 SwRVk+sUfJHL2/g7rsJxUhS4t1URDQqiqO+ZhKvpNyxZ2Yaq+PDAFsyWnLcrJiVJ/fEk x0vI/VGCPmz4uIoOtiHPvjJmZEZiJu2hhAUOIUtg4UE4f6HSkJYlaZhlQ1SEQnsjvJuP FGq2kIdFSeXbaNsX/XlWPv8byfGrelew9lV/pGatwoyH+ickBo+J//22Ki+FUkX7qngH py2MK/xKw424l23VPKefqfW0V+1OComUBn/JA2oyYL8gyMCdOuH3w/sDgwxnHfht5LZ+ M9Ww== X-Gm-Message-State: APjAAAUf5Pd4zYkmyIX091buZ2q1LzzSSl5SphMDaEh8tSBF8wuTsxg5 ZqSeNRtfZqF29iU4JcWPswooDX1aWkI= X-Google-Smtp-Source: APXvYqzN+bWB7DFkytmiGWT8zlB1PbDV+2TC0kYlWmyGajBg5rAv3RhgoRdhex3sZ4yTGR/njdYlFA== X-Received: by 2002:a17:90a:30cf:: with SMTP id h73mr6807854pjb.42.1562086231629; Tue, 02 Jul 2019 09:50:31 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h62sm14340230pgc.54.2019.07.02.09.50.30 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 09:50:30 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Bruce Richardson , Stephen Hemminger , Andrew Rybchenko Date: Tue, 2 Jul 2019 09:50:14 -0700 Message-Id: <20190702165017.3802-6-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702165017.3802-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702165017.3802-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 5/8] net/ether: mark ethernet addresses as being 2-byte aligned 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" From: Bruce Richardson When including the rte_ether.h header in applications with warnings enabled, a warning was given because of the assumption of 2-byte alignment of ethernet addresses when processing them. .../include/rte_ether.h:149:2: warning: converting a packed ‘const struct ether_addr’ pointer (alignment 1) to a ‘unaligned_uint16_t’ {aka ‘const short unsigned int’} pointer (alignment 2) may result in an unaligned pointer value [-Waddress-of-packed-member] 149 | const unaligned_uint16_t *ea_words = (const unaligned_uint16_t *)ea; | ^~~~~ Since ethernet addresses should always be aligned on a two-byte boundary, we can just inform the compiler of this assumption to remove the warnings and allow us to always access the addresses using 16-bit operations. Signed-off-by: Bruce Richardson Signed-off-by: Stephen Hemminger Reviewed-by: Andrew Rybchenko --- lib/librte_net/rte_ether.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/librte_net/rte_ether.h b/lib/librte_net/rte_ether.h index feb35a33c94b..d7b76ddf63eb 100644 --- a/lib/librte_net/rte_ether.h +++ b/lib/librte_net/rte_ether.h @@ -58,7 +58,8 @@ extern "C" { * See http://standards.ieee.org/regauth/groupmac/tutorial.html */ struct rte_ether_addr { - uint8_t addr_bytes[RTE_ETHER_ADDR_LEN]; /**< Addr bytes in tx order */ + uint8_t addr_bytes[RTE_ETHER_ADDR_LEN] __rte_aligned(2); + /**< Addr bytes in tx order */ } __attribute__((__packed__)); #define RTE_ETHER_LOCAL_ADMIN_ADDR 0x02 /**< Locally assigned Eth. address. */ @@ -81,8 +82,8 @@ struct rte_ether_addr { static inline int rte_is_same_ether_addr(const struct rte_ether_addr *ea1, const struct rte_ether_addr *ea2) { - const unaligned_uint16_t *w1 = (const uint16_t *)ea1; - const unaligned_uint16_t *w2 = (const uint16_t *)ea2; + const uint16_t *w1 = (const uint16_t *)ea1; + const uint16_t *w2 = (const uint16_t *)ea2; return ((w1[0] ^ w2[0]) | (w1[1] ^ w2[1]) | (w1[2] ^ w2[2])) == 0; } @@ -99,7 +100,7 @@ static inline int rte_is_same_ether_addr(const struct rte_ether_addr *ea1, */ static inline int rte_is_zero_ether_addr(const struct rte_ether_addr *ea) { - const unaligned_uint16_t *w = (const uint16_t *)ea; + const uint16_t *w = (const uint16_t *)ea; return (w[0] | w[1] | w[2]) == 0; } @@ -146,7 +147,7 @@ static inline int rte_is_multicast_ether_addr(const struct rte_ether_addr *ea) */ static inline int rte_is_broadcast_ether_addr(const struct rte_ether_addr *ea) { - const unaligned_uint16_t *ea_words = (const unaligned_uint16_t *)ea; + const uint16_t *ea_words = (const uint16_t *)ea; return (ea_words[0] == 0xFFFF && ea_words[1] == 0xFFFF && ea_words[2] == 0xFFFF); From patchwork Tue Jul 2 16:50:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55901 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C74741B9EC; Tue, 2 Jul 2019 18:50:44 +0200 (CEST) Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by dpdk.org (Postfix) with ESMTP id 34A551B9C3 for ; Tue, 2 Jul 2019 18:50:34 +0200 (CEST) Received: by mail-pg1-f195.google.com with SMTP id f25so7962112pgv.10 for ; Tue, 02 Jul 2019 09:50:34 -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=nSVFX0yQVcGBa1r6QYEZh1MHAfeY/re5mRSHtJ+79X4=; b=MOH3RBSImjEpNb3i0qNj7iNvWVlBo1v7BXzn3qU3ELP9cVeVuYiKllgyDn10gnubm+ 1spGss8GOIkQ2eO+6r+pQEBQBByuvbzs8rEf3bQ8fx/Jg9yEKqpbWDiHKLUQAi9ISFY1 DcQAk3Ly3hu7VIyIs4SK5Lwwrpzp5h3eZog3b9NjDa5rohYdgTnmX5BB/1wBRNTUNQZ4 Xp9v6p/A2f9tMw23XCc0iCfbPT1EDjZ1ZvH1exjZp69tlIK30fFowjupWSvgFnyU1C3t bs3wswUtjkELiukPAVnHMmSzXfwevMoZqjAq+unS1r4yHs0HeNiqrNM9v2niNk17kov1 QCsQ== 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=nSVFX0yQVcGBa1r6QYEZh1MHAfeY/re5mRSHtJ+79X4=; b=qlZo9/EWpFUD6XcZmz6brqU8yy1aUq7Lg0URw+c7A7emdi3uuhnWz/37TekOwH3l1x +ku7i0gFMy5POhhJ4wL3VzcvyWJaNohuZtTzZmCnpFCh9IqbayMtFSI1YGZsm2f0jboR x7xIYPfpkx7xin1WiD+g2+kyvZBuYVQ1qNrk8yFjHztrnJ2pgkaRHc/o9zXG/092Er2K IkpurhPA+AlIBcCMA1eC1WyIQSewkAEuJwSe+gQ1P+XdlQnjUGoigOF4rRHvlWJdMoev jZOmIFxr3lCNCqKbLUkBBYipZWgbOz/0JrwtER9n15ltpb3KqOOWPW6NVZ9yT3YVvzO5 J9Wg== X-Gm-Message-State: APjAAAWUNgmT+Ysjtnm9tVMKIp6qusUrX0zeMFrgiMTLe2epYU3QFXhU ckW1pysWn47v2mCbSb93zTpB22Yx X-Google-Smtp-Source: APXvYqxu8VDBGS+AeEqlL1IHi6orQfHKYcEIJCSD0wykGu/H6Na0L66jA1FzcnkrPOGTHGfCAp92gg== X-Received: by 2002:a17:90a:8a0b:: with SMTP id w11mr6592423pjn.125.1562086232871; Tue, 02 Jul 2019 09:50:32 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h62sm14340230pgc.54.2019.07.02.09.50.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 09:50:32 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 2 Jul 2019 09:50:15 -0700 Message-Id: <20190702165017.3802-7-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702165017.3802-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702165017.3802-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 6/8] cmdline: use new ethernet address parser 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" Now that there is a version of ether_aton in rte_ether, it can be used by the cmdline ethernet address parser. Note: ether_aton_r can not be used in cmdline because the old code would accept either bytes XX:XX:XX:XX:XX:XX or words XXXX:XXXX:XXXX and we need to keep compatiablity. Signed-off-by: Stephen Hemminger --- lib/Makefile | 2 +- lib/librte_cmdline/Makefile | 3 +- lib/librte_cmdline/cmdline_parse_etheraddr.c | 71 +++----------------- lib/librte_cmdline/meson.build | 6 +- lib/meson.build | 2 +- 5 files changed, 15 insertions(+), 69 deletions(-) diff --git a/lib/Makefile b/lib/Makefile index 82b2c4bfa8ea..cc36fe7591f0 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -20,7 +20,7 @@ DIRS-$(CONFIG_RTE_LIBRTE_TIMER) += librte_timer DEPDIRS-librte_timer := librte_eal DIRS-$(CONFIG_RTE_LIBRTE_CFGFILE) += librte_cfgfile DIRS-$(CONFIG_RTE_LIBRTE_CMDLINE) += librte_cmdline -DEPDIRS-librte_cmdline := librte_eal +DEPDIRS-librte_cmdline := librte_eal librte_net DIRS-$(CONFIG_RTE_LIBRTE_ETHER) += librte_ethdev DEPDIRS-librte_ethdev := librte_net librte_eal librte_mempool librte_ring DEPDIRS-librte_ethdev += librte_mbuf diff --git a/lib/librte_cmdline/Makefile b/lib/librte_cmdline/Makefile index c64142b8d5a0..04057d7c671f 100644 --- a/lib/librte_cmdline/Makefile +++ b/lib/librte_cmdline/Makefile @@ -7,6 +7,7 @@ include $(RTE_SDK)/mk/rte.vars.mk LIB = librte_cmdline.a CFLAGS += $(WERROR_FLAGS) -I$(SRCDIR) -O3 +CFLAGS += -DALLOW_EXPERIMENTAL_API EXPORT_MAP := rte_cmdline_version.map @@ -25,7 +26,7 @@ SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_vt100.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_socket.c SRCS-$(CONFIG_RTE_LIBRTE_CMDLINE) += cmdline_parse_portlist.c -LDLIBS += -lrte_eal +LDLIBS += -lrte_net -lrte_eal # install includes INCS := cmdline.h cmdline_parse.h cmdline_parse_num.h cmdline_parse_ipaddr.h diff --git a/lib/librte_cmdline/cmdline_parse_etheraddr.c b/lib/librte_cmdline/cmdline_parse_etheraddr.c index 24e04755cd9e..2cb8dd2a1267 100644 --- a/lib/librte_cmdline/cmdline_parse_etheraddr.c +++ b/lib/librte_cmdline/cmdline_parse_etheraddr.c @@ -12,9 +12,9 @@ #include #include #include -#include #include +#include #include "cmdline_parse.h" #include "cmdline_parse_etheraddr.h" @@ -26,69 +26,15 @@ struct cmdline_token_ops cmdline_token_etheraddr_ops = { .get_help = cmdline_get_help_etheraddr, }; -/* the format can be either XX:XX:XX:XX:XX:XX or XXXX:XXXX:XXXX */ -#define ETHER_ADDRSTRLENLONG 18 -#define ETHER_ADDRSTRLENSHORT 15 - -#ifdef __linux__ -#define ea_oct ether_addr_octet -#else -#define ea_oct octet -#endif - - -static struct ether_addr * -my_ether_aton(const char *a) -{ - int i; - char *end; - unsigned long o[ETHER_ADDR_LEN]; - static struct ether_addr ether_addr; - - i = 0; - do { - errno = 0; - o[i] = strtoul(a, &end, 16); - if (errno != 0 || end == a || (end[0] != ':' && end[0] != 0)) - return NULL; - a = end + 1; - } while (++i != sizeof (o) / sizeof (o[0]) && end[0] != 0); - - /* Junk at the end of line */ - if (end[0] != 0) - return NULL; - - /* Support the format XX:XX:XX:XX:XX:XX */ - if (i == ETHER_ADDR_LEN) { - while (i-- != 0) { - if (o[i] > UINT8_MAX) - return NULL; - ether_addr.ea_oct[i] = (uint8_t)o[i]; - } - /* Support the format XXXX:XXXX:XXXX */ - } else if (i == ETHER_ADDR_LEN / 2) { - while (i-- != 0) { - if (o[i] > UINT16_MAX) - return NULL; - ether_addr.ea_oct[i * 2] = (uint8_t)(o[i] >> 8); - ether_addr.ea_oct[i * 2 + 1] = (uint8_t)(o[i] & 0xff); - } - /* unknown format */ - } else - return NULL; - - return (struct ether_addr *)ðer_addr; -} - int cmdline_parse_etheraddr(__attribute__((unused)) cmdline_parse_token_hdr_t *tk, const char *buf, void *res, unsigned ressize) { unsigned int token_len = 0; - char ether_str[ETHER_ADDRSTRLENLONG+1]; - struct ether_addr *tmp; + char ether_str[RTE_ETHER_ADDR_FMT_SIZE]; + struct rte_ether_addr tmp; - if (res && ressize < sizeof(struct ether_addr)) + if (res && ressize < sizeof(tmp)) return -1; if (!buf || ! *buf) @@ -98,17 +44,16 @@ cmdline_parse_etheraddr(__attribute__((unused)) cmdline_parse_token_hdr_t *tk, token_len++; /* if token doesn't match possible string lengths... */ - if ((token_len != ETHER_ADDRSTRLENLONG - 1) && - (token_len != ETHER_ADDRSTRLENSHORT - 1)) + if (token_len >= RTE_ETHER_ADDR_FMT_SIZE) return -1; strlcpy(ether_str, buf, token_len + 1); - tmp = my_ether_aton(ether_str); - if (tmp == NULL) + if (rte_ether_unformat_addr(ether_str, &tmp) < 0) return -1; + if (res) - memcpy(res, tmp, sizeof(struct ether_addr)); + memcpy(res, &tmp, sizeof(tmp)); return token_len; } diff --git a/lib/librte_cmdline/meson.build b/lib/librte_cmdline/meson.build index 0fa61385fccf..07334c1b0956 100644 --- a/lib/librte_cmdline/meson.build +++ b/lib/librte_cmdline/meson.build @@ -1,10 +1,8 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Intel Corporation -# This library is processed before EAL -includes = [global_inc] - version = 2 +allow_experimental_apis = true sources = files('cmdline.c', 'cmdline_cirbuf.c', 'cmdline_parse.c', @@ -28,3 +26,5 @@ headers = files('cmdline.h', 'cmdline_socket.h', 'cmdline_cirbuf.h', 'cmdline_parse_portlist.h') + +deps += ['net'] diff --git a/lib/meson.build b/lib/meson.build index 9398a3ac04e3..c133f2f35ff3 100644 --- a/lib/meson.build +++ b/lib/meson.build @@ -11,8 +11,8 @@ libraries = [ 'kvargs', # eal depends on kvargs 'eal', # everything depends on eal - 'cmdline', # ethdev depends on cmdline for parsing functions 'ring', 'mempool', 'mbuf', 'net', 'meter', 'ethdev', 'pci', # core + 'cmdline', 'metrics', # bitrate/latency stats depends on this 'hash', # efd depends on this 'timer', # eventdev depends on this From patchwork Tue Jul 2 16:50:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55902 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9D5111B9F0; Tue, 2 Jul 2019 18:50:48 +0200 (CEST) Received: from mail-pg1-f193.google.com (mail-pg1-f193.google.com [209.85.215.193]) by dpdk.org (Postfix) with ESMTP id 9EE6B1B9C4 for ; Tue, 2 Jul 2019 18:50:34 +0200 (CEST) Received: by mail-pg1-f193.google.com with SMTP id s27so7973565pgl.2 for ; Tue, 02 Jul 2019 09:50:34 -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=i8sEf2BqVxRRW7Hf5r4EMIM/xDPKtZVL0Pik8O21io8=; b=kxkDyd3O7n04GShfEt7XG5OhDDEwb1+vI/EH9KmKcArsQChTHA5uUQ1f3okoGT+0lo utbSA6f5sQAV2yYBH3Uqhn5iNzPBx8/zQmylZ0Vvj6hpGmyQ1XgginavIkRONO5ITZVY v4H7sULMFxVlS7FKk0WjLkdZgQCoMke/dG6BIMcEAM4TZYa92pHAKfuDEiljbGcCY3Q+ x+9qtsuDR0s8U9cT0myorfM5VWThMXLI5j+53fouF7ATQL+H0CiZmAgnG1imap+kAJiP 7JNgpsXcc+eMWxpqLwGXUmbCVxDputkwMZ0/fH0MDKWbI7Qc2LhvfFvjGdbBaGKX8gFg GXVw== 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=i8sEf2BqVxRRW7Hf5r4EMIM/xDPKtZVL0Pik8O21io8=; b=gy/1coUw5yYh5r47Bb4LpOFGJrvx4tFGrg5IVptvC2C37wB8DVulDAhoPYDAoE6NKW VaO5ekBHdDfZ0Sa+j38MyYIIs+D7y7g9QFisTGmvqRdiq30nUN2vn+G7SQ8Onav3C7F4 9p71yVgwjIydnHK99riOniKOlsM5klrrCdZ61skHbLtKLPhJoZxpZHk/MeR0QcmXOaqK xnJwxEs2gDEzLU8BZXa95BA6R7Mg36s6r8e0ODQ4GxZHzkbqS3k7S7QUUB0qcUSuWRx2 0WU/OTypUj4Nk9wdHIASSmNrKhwDlHxyBVXj8TucPL3ZZkVpiVswQVJQGwunMLndfBc6 jRVg== X-Gm-Message-State: APjAAAUCWmcW8HtsLP/HBrqnTp14h6DzdATyw/IKvJdpfXVxgPjiUgsk 64D/MeBXUKFgYWQ2AxvdV8e8lnwLLMg= X-Google-Smtp-Source: APXvYqyEBPzsrgE4U5dZI2YhzRI1eWd+kJ6nsEJzHptKzdFrmnNzloVeORWnPuPpK8I0oPg+720TGw== X-Received: by 2002:a17:90b:d82:: with SMTP id bg2mr6733181pjb.87.1562086233570; Tue, 02 Jul 2019 09:50:33 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h62sm14340230pgc.54.2019.07.02.09.50.32 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 09:50:33 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 2 Jul 2019 09:50:16 -0700 Message-Id: <20190702165017.3802-8-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702165017.3802-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702165017.3802-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 7/8] net/bonding: use new ethernet address parser 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 library used to be the only way to parse a mac address. Now there is rte_ether_unformat_addr. Signed-off-by: Stephen Hemminger --- drivers/net/bonding/Makefile | 2 +- drivers/net/bonding/meson.build | 2 +- drivers/net/bonding/rte_eth_bond_args.c | 6 +----- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/drivers/net/bonding/Makefile b/drivers/net/bonding/Makefile index 1893e3cad313..26c1782554cd 100644 --- a/drivers/net/bonding/Makefile +++ b/drivers/net/bonding/Makefile @@ -12,7 +12,7 @@ CFLAGS += -DALLOW_EXPERIMENTAL_API CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring -LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs -lrte_cmdline +LDLIBS += -lrte_ethdev -lrte_net -lrte_kvargs LDLIBS += -lrte_pci -lrte_bus_pci LDLIBS += -lrte_bus_vdev diff --git a/drivers/net/bonding/meson.build b/drivers/net/bonding/meson.build index 00374edb2a9d..6267210adf5f 100644 --- a/drivers/net/bonding/meson.build +++ b/drivers/net/bonding/meson.build @@ -8,6 +8,6 @@ sources = files('rte_eth_bond_api.c', 'rte_eth_bond_pmd.c', 'rte_eth_bond_flow.c 'rte_eth_bond_args.c', 'rte_eth_bond_8023ad.c', 'rte_eth_bond_alb.c') deps += 'sched' # needed for rte_bitmap.h -deps += ['ip_frag', 'cmdline'] +deps += ['ip_frag'] install_headers('rte_eth_bond.h', 'rte_eth_bond_8023ad.h') diff --git a/drivers/net/bonding/rte_eth_bond_args.c b/drivers/net/bonding/rte_eth_bond_args.c index 01bbb06c1a84..936440fb8491 100644 --- a/drivers/net/bonding/rte_eth_bond_args.c +++ b/drivers/net/bonding/rte_eth_bond_args.c @@ -7,9 +7,6 @@ #include #include -#include -#include - #include "rte_eth_bond.h" #include "rte_eth_bond_private.h" @@ -281,8 +278,7 @@ bond_ethdev_parse_bond_mac_addr_kvarg(const char *key __rte_unused, return -1; /* Parse MAC */ - return cmdline_parse_etheraddr(NULL, value, extra_args, - sizeof(struct rte_ether_addr)); + return rte_ether_unformat_addr(value, extra_args); } int From patchwork Tue Jul 2 16:50:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 55903 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D4EC01B9F9; Tue, 2 Jul 2019 18:50:50 +0200 (CEST) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) by dpdk.org (Postfix) with ESMTP id 04A831B9C4 for ; Tue, 2 Jul 2019 18:50:36 +0200 (CEST) Received: by mail-pg1-f194.google.com with SMTP id s27so7973592pgl.2 for ; Tue, 02 Jul 2019 09:50:35 -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=kmK5qcxsbynlVwqWegKc+favRmKelg+HJao2VxYFb6exDJTOHnyZBlogYGdk/F7Ssb j7cJa4pFsTS4IHNy73S12/1WMH9kCioVftQvGbr0l6JjozpM3/iF1TsLFLvajgSxDFCM aSJIY5EG3GQ+uwUp/w7nt4IkmftgoX4LTmEmTwXDTPUvwFXCbcCADgqM43QMfPAHDSKb rJk3xbeMy2nQ2mAaxgj400HwzKKtWER9y8+0g1uXUmALhxpNSuSUfOYuIXzaa3DsEYdn Z8PSasdu0Ir20Ttf7OHQ1BTTjn0KomJw8/qHd4R1tBAoGDLuHpewXACZmcpUNqNEt+8H /hiA== 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=DcbN7iGhY58dEWZ+5E3ZJDTz6dvv4zEAU+ndL/VvBPFjcmGyuTSrXA27wncR2HSbaP s36YGfHSpxoIGYqAFPKDsgf8fmdl9Yekv3mS2Flqgduu4Qe/0AV+Tbn82PsdNCJO8jEH SJ1grjqLWixblKBj3+4IwCTnIatVK26TWot5fHuWUeIfzpBUexTWEBseXblAiZTYJ7rW qS7r9NljdwrcHqWIa40oWqLPd8Owk9q7SwXl7gernblTdt9hMCMYxtaEB/N0peBR82ol ZS0tf8maLTeViO1I9UrziIz5YuABuptGfAVb14f1kB1Q73mT8riOyJ/AQBy8eAQ8U4+S /4Zw== X-Gm-Message-State: APjAAAU50Gdgn7/PkhVF6mpdzgkjsm6bcW0A83wnEt/tmuBcjPtfbFI6 5tifREJ1tJF/n8NGkuQdk07NbritwMI= X-Google-Smtp-Source: APXvYqwcmRlMJLTPZVz80JnQM2QCYjJ0X+qQ3fn/Xmr5Lm4DWD09qdJDmOJlcCpuzG7NFxzAM0EF/Q== X-Received: by 2002:a17:90a:342c:: with SMTP id o41mr6682778pjb.1.1562086234973; Tue, 02 Jul 2019 09:50:34 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id h62sm14340230pgc.54.2019.07.02.09.50.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 02 Jul 2019 09:50:33 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 2 Jul 2019 09:50:17 -0700 Message-Id: <20190702165017.3802-9-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190702165017.3802-1-stephen@networkplumber.org> References: <20190516180427.17270-1-stephen@networkplumber.org> <20190702165017.3802-1-stephen@networkplumber.org> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v6 8/8] app/testpmd: use new ethernet address parser 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