From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3C9A3A2EEB for ; Tue, 10 Sep 2019 10:53:43 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C70AD1EE3A; Tue, 10 Sep 2019 10:53:20 +0200 (CEST) Received: from dispatch1-us1.ppe-hosted.com (dispatch1-us1.ppe-hosted.com [148.163.129.52]) by dpdk.org (Postfix) with ESMTP id 8CC951EB87 for ; Tue, 10 Sep 2019 10:53:08 +0200 (CEST) X-Virus-Scanned: Proofpoint Essentials engine Received: from webmail.solarflare.com (webmail.solarflare.com [12.187.104.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mx1-us3.ppe-hosted.com (PPE Hosted ESMTP Server) with ESMTPS id 5ECE548005F; Tue, 10 Sep 2019 08:53:07 +0000 (UTC) Received: from ocex03.SolarFlarecom.com (10.20.40.36) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Tue, 10 Sep 2019 01:53:05 -0700 Received: from opal.uk.solarflarecom.com (10.17.10.1) by ocex03.SolarFlarecom.com (10.20.40.36) with Microsoft SMTP Server (TLS) id 15.0.1395.4 via Frontend Transport; Tue, 10 Sep 2019 01:53:03 -0700 Received: from ukv-loginhost.uk.solarflarecom.com (ukv-loginhost.uk.solarflarecom.com [10.17.10.39]) by opal.uk.solarflarecom.com (8.13.8/8.13.8) with ESMTP id x8A8r2w6024713; Tue, 10 Sep 2019 09:53:02 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id 7DF1F1613D1; Tue, 10 Sep 2019 09:53:02 +0100 (BST) From: Andrew Rybchenko To: Wenzhuo Lu , Jingjing Wu , Bernard Iremonger CC: , Igor Romanov Date: Tue, 10 Sep 2019 09:52:16 +0100 Message-ID: <1568105541-7399-3-git-send-email-arybchenko@solarflare.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568105541-7399-1-git-send-email-arybchenko@solarflare.com> References: <1568105541-7399-1-git-send-email-arybchenko@solarflare.com> MIME-Version: 1.0 Content-Type: text/plain X-TM-AS-Product-Ver: SMEX-12.5.0.1300-8.5.1010-24898.005 X-TM-AS-Result: No-4.962600-4.000000-10 X-TMASE-MatchedRID: dKAjOXhtwHQfKML5AJtfLe1rOTqE/7IT3V4UShoTXafAlr9zf1x/liXD Fxgit6TpPqH3M3bmiaYDfZ2MQc5YmiHhSBQfglfsA9lly13c/gEvV5f7P0HVDPI35cQSjJK+ZeB 4wkR7kKb4AkYgG/wGtzG1wXUvEQeTaTkWqXcVprv1xv2JHBkcH29Xf86cwKVa1y0aXF5eX+iCoR dhd0kkJkkvdTTC5Z2VXlG4YAM40y66wtuwih3AcSAI8aJmq0jwLSi9nvTJ4eibKItl61J/yZ+in TK0bC9eKrauXd3MZDUSM49YGvhp6PaWjebFeT77oRkhPvSh5suysnqF7O5hczD+w/J8tOCakaVr IEYXUx+60lFHt9cAwf4LApwXzcG4p1w+94atdHaxoYIrU8aQ+DigZBQJvBjlD6DuZ3COjrnoW0N kKZgEnW3LgNyHejuiQwymtxuJ6y0= X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--4.962600-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24898.005 X-MDID: 1568105588-f2l4sKRox9N4 Subject: [dpdk-dev] [PATCH 2/7] app/testpmd: check status of getting MAC 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" From: Igor Romanov Add a wrapper for rte_eth_macaddr_get() that prints an error and returns a status code if the function fails. Signed-off-by: Igor Romanov Signed-off-by: Andrew Rybchenko --- app/test-pmd/config.c | 14 +++++++++----- app/test-pmd/testpmd.c | 13 +++++++++---- app/test-pmd/testpmd.h | 2 ++ app/test-pmd/util.c | 13 +++++++++++++ 4 files changed, 33 insertions(+), 9 deletions(-) diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 33a4e9827..957c61fbe 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -454,9 +454,11 @@ device_infos_display(const char *identifier) /* List ports with matching device name */ RTE_ETH_FOREACH_DEV_OF(port_id, dev) { - rte_eth_macaddr_get(port_id, &mac_addr); printf("\n\tPort id: %-2d", port_id); - print_ethaddr("\n\tMAC address: ", &mac_addr); + if (eth_macaddr_get_print_err(port_id, + &mac_addr) == 0) + print_ethaddr("\n\tMAC address: ", + &mac_addr); rte_eth_dev_get_name_by_port(port_id, name); printf("\n\tDevice name: %s", name); printf("\n"); @@ -494,8 +496,8 @@ port_infos_display(portid_t port_id) printf("\n%s Infos for port %-2d %s\n", info_border, port_id, info_border); - rte_eth_macaddr_get(port_id, &mac_addr); - print_ethaddr("MAC address: ", &mac_addr); + if (eth_macaddr_get_print_err(port_id, &mac_addr) == 0) + print_ethaddr("MAC address: ", &mac_addr); rte_eth_dev_get_name_by_port(port_id, name); printf("\nDevice name: %s", name); printf("\nDriver name: %s", dev_info.driver_name); @@ -646,7 +648,9 @@ port_summary_display(portid_t port_id) return; rte_eth_dev_get_name_by_port(port_id, name); - rte_eth_macaddr_get(port_id, &mac_addr); + ret = eth_macaddr_get_print_err(port_id, &mac_addr); + if (ret != 0) + return; printf("%-4d %02X:%02X:%02X:%02X:%02X:%02X %-12s %-14s %-8s %uMbps\n", port_id, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index 0f6e27962..1e3dc44a1 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -2209,8 +2209,8 @@ start_port(portid_t pid) RTE_PORT_HANDLING, RTE_PORT_STARTED) == 0) printf("Port %d can not be set into started\n", pi); - rte_eth_macaddr_get(pi, &mac_addr); - printf("Port %d: %02X:%02X:%02X:%02X:%02X:%02X\n", pi, + if (eth_macaddr_get_print_err(pi, &mac_addr) == 0) + printf("Port %d: %02X:%02X:%02X:%02X:%02X:%02X\n", pi, mac_addr.addr_bytes[0], mac_addr.addr_bytes[1], mac_addr.addr_bytes[2], mac_addr.addr_bytes[3], mac_addr.addr_bytes[4], mac_addr.addr_bytes[5]); @@ -2984,7 +2984,9 @@ init_port_config(void) rxtx_port_config(port); - rte_eth_macaddr_get(pid, &port->eth_addr); + ret = eth_macaddr_get_print_err(pid, &port->eth_addr); + if (ret != 0) + return; map_port_queue_stats_mapping_registers(pid, port); #if defined RTE_LIBRTE_IXGBE_PMD && defined RTE_LIBRTE_IXGBE_BYPASS @@ -3187,7 +3189,10 @@ init_port_dcb_config(portid_t pid, for (i = 0; i < RTE_DIM(vlan_tags); i++) rx_vft_set(pid, vlan_tags[i], 1); - rte_eth_macaddr_get(pid, &rte_port->eth_addr); + retval = eth_macaddr_get_print_err(pid, &rte_port->eth_addr); + if (retval != 0) + return retval; + map_port_queue_stats_mapping_registers(pid, rte_port); rte_port->dcb_flag = 1; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index c039e2961..f8ebe71ac 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -827,6 +827,8 @@ int eth_dev_info_get_print_err(uint16_t port_id, void eth_set_promisc_mode(uint16_t port_id, int enable); void eth_set_allmulticast_mode(uint16_t port, int enable); int eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link); +int eth_macaddr_get_print_err(uint16_t port_id, + struct rte_ether_addr *mac_addr); /* Functions to manage the set of filtered Multicast MAC addresses */ diff --git a/app/test-pmd/util.c b/app/test-pmd/util.c index 6c24bf8d9..47f86a5d8 100644 --- a/app/test-pmd/util.c +++ b/app/test-pmd/util.c @@ -291,3 +291,16 @@ eth_link_get_nowait_print_err(uint16_t port_id, return ret; } + +int +eth_macaddr_get_print_err(uint16_t port_id, struct rte_ether_addr *mac_addr) +{ + int ret; + + ret = rte_eth_macaddr_get(port_id, mac_addr); + if (ret != 0) + printf("Error getting device (port %u) mac address: %s\n", + port_id, rte_strerror(-ret)); + + return ret; +} -- 2.17.1