summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorIgor Romanov <igor.romanov@oktetlabs.ru>2019-09-10 09:52:16 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2019-10-07 15:00:55 +0200
commita5279d25616d7885c2b6d0a36590d0836281deff (patch)
tree0ebf8229a0bb22195ad67f6b9128014f5c148abf /app
parent1cde5e0acaface5862cb6699c4cee399b7a5280f (diff)
downloaddpdk-a5279d25616d7885c2b6d0a36590d0836281deff.zip
dpdk-a5279d25616d7885c2b6d0a36590d0836281deff.tar.gz
dpdk-a5279d25616d7885c2b6d0a36590d0836281deff.tar.xz
app/testpmd: check status of getting MAC address
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 <igor.romanov@oktetlabs.ru> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
Diffstat (limited to 'app')
-rw-r--r--app/test-pmd/config.c14
-rw-r--r--app/test-pmd/testpmd.c13
-rw-r--r--app/test-pmd/testpmd.h2
-rw-r--r--app/test-pmd/util.c13
4 files changed, 33 insertions, 9 deletions
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 33a4e98..957c61f 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -454,9 +454,11 @@ skip_parse:
/* 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 0f6e279..1e3dc44 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 9446d27..bec19ab 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -826,6 +826,8 @@ int eth_dev_info_get_print_err(uint16_t port_id,
struct rte_eth_dev_info *dev_info);
void eth_set_promisc_mode(uint16_t port_id, 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 19d3677..faf247c 100644
--- a/app/test-pmd/util.c
+++ b/app/test-pmd/util.c
@@ -274,3 +274,16 @@ eth_link_get_nowait_print_err(uint16_t port_id, struct rte_eth_link *link)
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;
+}