summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Romanov <igor.romanov@oktetlabs.ru>2019-09-10 09:52:20 +0100
committerFerruh Yigit <ferruh.yigit@intel.com>2019-10-07 15:00:55 +0200
commit70febdcfd60f278be598ec9bcf1ff5bb5c5a59a8 (patch)
treee0d769ff6c24eae32e3c74b3f7057f50761f56fc
parent6fcf85860575b4075a1fc255e7907afe359178b3 (diff)
downloaddpdk-70febdcfd60f278be598ec9bcf1ff5bb5c5a59a8.zip
dpdk-70febdcfd60f278be598ec9bcf1ff5bb5c5a59a8.tar.gz
dpdk-70febdcfd60f278be598ec9bcf1ff5bb5c5a59a8.tar.xz
examples: check status of getting MAC address
The return value of rte_eth_macaddr_get() was changed from void to int. Update the usage of the functions according to the new return type. Signed-off-by: Igor Romanov <igor.romanov@oktetlabs.ru> Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
-rw-r--r--examples/bbdev_app/main.c8
-rw-r--r--examples/bond/main.c58
-rw-r--r--examples/distributor/main.c8
-rw-r--r--examples/ethtool/ethtool-app/main.c18
-rw-r--r--examples/ethtool/lib/rte_ethtool.c7
-rw-r--r--examples/eventdev_pipeline/main.c8
-rw-r--r--examples/flow_classify/flow_classify.c5
-rw-r--r--examples/ip_fragmentation/main.c9
-rw-r--r--examples/ip_pipeline/cli.c8
-rw-r--r--examples/ip_reassembly/main.c9
-rw-r--r--examples/ipsec-secgw/ipsec-secgw.c7
-rw-r--r--examples/ipv4_multicast/main.c7
-rw-r--r--examples/kni/main.c6
-rw-r--r--examples/l2fwd-cat/l2fwd-cat.c5
-rw-r--r--examples/l2fwd-crypto/main.c8
-rw-r--r--examples/l2fwd-jobstats/main.c7
-rw-r--r--examples/l2fwd-keepalive/main.c7
-rw-r--r--examples/l2fwd/main.c7
-rw-r--r--examples/l3fwd-acl/main.c7
-rw-r--r--examples/l3fwd-power/main.c7
-rw-r--r--examples/l3fwd-vf/main.c7
-rw-r--r--examples/l3fwd/main.c7
-rw-r--r--examples/link_status_interrupt/main.c6
-rw-r--r--examples/multi_process/client_server_mp/mp_server/main.c8
-rw-r--r--examples/packet_ordering/main.c8
-rw-r--r--examples/performance-thread/l3fwd-thread/main.c7
-rw-r--r--examples/ptpclient/ptpclient.c11
-rw-r--r--examples/quota_watermark/qw/main.c10
-rw-r--r--examples/rxtx_callbacks/main.c7
-rw-r--r--examples/server_node_efd/server/main.c9
-rw-r--r--examples/skeleton/basicfwd.c5
-rw-r--r--examples/tep_termination/vxlan_setup.c5
-rw-r--r--examples/vhost/main.c9
-rw-r--r--examples/vm_power_manager/guest_cli/main.c11
-rw-r--r--examples/vm_power_manager/guest_cli/vm_power_cli_guest.c17
-rw-r--r--examples/vm_power_manager/guest_cli/vm_power_cli_guest.h2
-rw-r--r--examples/vm_power_manager/main.c8
-rw-r--r--examples/vmdq/main.c7
-rw-r--r--examples/vmdq_dcb/main.c7
39 files changed, 304 insertions, 53 deletions
diff --git a/examples/bbdev_app/main.c b/examples/bbdev_app/main.c
index 3498765..fb38dc3 100644
--- a/examples/bbdev_app/main.c
+++ b/examples/bbdev_app/main.c
@@ -490,7 +490,13 @@ initialize_ports(struct app_config_params *app_params,
return ret;
}
- rte_eth_macaddr_get(port_id, &bbdev_port_eth_addr);
+ ret = rte_eth_macaddr_get(port_id, &bbdev_port_eth_addr);
+ if (ret < 0) {
+ printf("rte_eth_macaddr_get: err=%d, queue=%u\n",
+ ret, q);
+ return -1;
+ }
+
print_mac(port_id, &bbdev_port_eth_addr);
return 0;
diff --git a/examples/bond/main.c b/examples/bond/main.c
index 39214cf..ee8fa2d 100644
--- a/examples/bond/main.c
+++ b/examples/bond/main.c
@@ -208,7 +208,12 @@ slave_port_init(uint16_t portid, struct rte_mempool *mbuf_pool)
struct rte_ether_addr addr;
- rte_eth_macaddr_get(portid, &addr);
+ retval = rte_eth_macaddr_get(portid, &addr);
+ if (retval != 0)
+ rte_exit(retval,
+ "Mac address get port %d failed (res=%d)",
+ portid, retval);
+
printf("Port %u MAC: ", portid);
PRINT_MAC(addr);
printf("\n");
@@ -309,7 +314,11 @@ bond_port_init(struct rte_mempool *mbuf_pool)
struct rte_ether_addr addr;
- rte_eth_macaddr_get(BOND_PORT, &addr);
+ retval = rte_eth_macaddr_get(BOND_PORT, &addr);
+ if (retval != 0)
+ rte_exit(retval, "port %u: Mac address get failed (res=%d)",
+ BOND_PORT, retval);
+
printf("Port %u MAC: ", (unsigned)BOND_PORT);
PRINT_MAC(addr);
printf("\n");
@@ -355,6 +364,7 @@ static int lcore_main(__attribute__((unused)) void *arg1)
struct rte_mbuf *pkts[MAX_PKT_BURST] __rte_cache_aligned;
struct rte_ether_addr d_addr;
+ struct rte_ether_addr bond_mac_addr;
struct rte_ether_hdr *eth_hdr;
struct rte_arp_hdr *arp_hdr;
struct rte_ipv4_hdr *ipv4_hdr;
@@ -364,6 +374,7 @@ static int lcore_main(__attribute__((unused)) void *arg1)
uint32_t bond_ip;
int i = 0;
uint8_t is_free;
+ int ret;
bond_ip = BOND_IP_1 | (BOND_IP_2 << 8) |
(BOND_IP_3 << 16) | (BOND_IP_4 << 24);
@@ -381,6 +392,15 @@ static int lcore_main(__attribute__((unused)) void *arg1)
continue;
}
+ ret = rte_eth_macaddr_get(BOND_PORT, &bond_mac_addr);
+ if (ret != 0) {
+ printf("Bond (port %u) MAC address get failed: %s.\n"
+ "%u packets dropped", BOND_PORT, strerror(-ret),
+ rx_cnt);
+ rte_pktmbuf_free(pkts[i]);
+ continue;
+ }
+
/* Search incoming data for ARP packets and prepare response */
for (i = 0; i < rx_cnt; i++) {
if (rte_spinlock_trylock(&global_flag_stru_p->lock) == 1) {
@@ -407,11 +427,11 @@ static int lcore_main(__attribute__((unused)) void *arg1)
arp_hdr->arp_opcode = rte_cpu_to_be_16(RTE_ARP_OP_REPLY);
/* Switch src and dst data and set bonding MAC */
rte_ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
- rte_eth_macaddr_get(BOND_PORT, &eth_hdr->s_addr);
+ rte_ether_addr_copy(&bond_mac_addr, &eth_hdr->s_addr);
rte_ether_addr_copy(&arp_hdr->arp_data.arp_sha,
&arp_hdr->arp_data.arp_tha);
arp_hdr->arp_data.arp_tip = arp_hdr->arp_data.arp_sip;
- rte_eth_macaddr_get(BOND_PORT, &d_addr);
+ rte_ether_addr_copy(&bond_mac_addr, &d_addr);
rte_ether_addr_copy(&d_addr, &arp_hdr->arp_data.arp_sha);
arp_hdr->arp_data.arp_sip = bond_ip;
rte_eth_tx_burst(BOND_PORT, 0, &pkts[i], 1);
@@ -428,7 +448,7 @@ static int lcore_main(__attribute__((unused)) void *arg1)
ipv4_hdr = (struct rte_ipv4_hdr *)((char *)(eth_hdr + 1) + offset);
if (ipv4_hdr->dst_addr == bond_ip) {
rte_ether_addr_copy(&eth_hdr->s_addr, &eth_hdr->d_addr);
- rte_eth_macaddr_get(BOND_PORT, &eth_hdr->s_addr);
+ rte_ether_addr_copy(&bond_mac_addr, &eth_hdr->s_addr);
ipv4_hdr->dst_addr = ipv4_hdr->src_addr;
ipv4_hdr->src_addr = bond_ip;
rte_eth_tx_burst(BOND_PORT, 0, &pkts[i], 1);
@@ -468,12 +488,14 @@ static void cmd_obj_send_parsed(void *parsed_result,
struct cmd_obj_send_result *res = parsed_result;
char ip_str[INET6_ADDRSTRLEN];
+ struct rte_ether_addr bond_mac_addr;
struct rte_mbuf *created_pkt;
struct rte_ether_hdr *eth_hdr;
struct rte_arp_hdr *arp_hdr;
uint32_t bond_ip;
size_t pkt_size;
+ int ret;
if (res->ip.family == AF_INET)
get_string(res, ip_str, INET_ADDRSTRLEN);
@@ -483,6 +505,13 @@ static void cmd_obj_send_parsed(void *parsed_result,
bond_ip = BOND_IP_1 | (BOND_IP_2 << 8) |
(BOND_IP_3 << 16) | (BOND_IP_4 << 24);
+ ret = rte_eth_macaddr_get(BOND_PORT, &bond_mac_addr);
+ if (ret != 0) {
+ cmdline_printf(cl,
+ "Failed to get bond (port %u) MAC address: %s\n",
+ BOND_PORT, strerror(-ret));
+ }
+
created_pkt = rte_pktmbuf_alloc(mbuf_pool);
if (created_pkt == NULL) {
cmdline_printf(cl, "Failed to allocate mbuf\n");
@@ -494,7 +523,7 @@ static void cmd_obj_send_parsed(void *parsed_result,
created_pkt->pkt_len = pkt_size;
eth_hdr = rte_pktmbuf_mtod(created_pkt, struct rte_ether_hdr *);
- rte_eth_macaddr_get(BOND_PORT, &eth_hdr->s_addr);
+ rte_ether_addr_copy(&bond_mac_addr, &eth_hdr->s_addr);
memset(&eth_hdr->d_addr, 0xFF, RTE_ETHER_ADDR_LEN);
eth_hdr->ether_type = rte_cpu_to_be_16(RTE_ETHER_TYPE_ARP);
@@ -506,7 +535,7 @@ static void cmd_obj_send_parsed(void *parsed_result,
arp_hdr->arp_plen = sizeof(uint32_t);
arp_hdr->arp_opcode = rte_cpu_to_be_16(RTE_ARP_OP_REQUEST);
- rte_eth_macaddr_get(BOND_PORT, &arp_hdr->arp_data.arp_sha);
+ rte_ether_addr_copy(&bond_mac_addr, &arp_hdr->arp_data.arp_sha);
arp_hdr->arp_data.arp_sip = bond_ip;
memset(&arp_hdr->arp_data.arp_tha, 0, RTE_ETHER_ADDR_LEN);
arp_hdr->arp_data.arp_tip =
@@ -721,13 +750,20 @@ static void cmd_show_parsed(__attribute__((unused)) void *parsed_result,
uint16_t slaves[16] = {0};
uint8_t len = 16;
struct rte_ether_addr addr;
- uint16_t i = 0;
+ uint16_t i;
+ int ret;
+
+ for (i = 0; i < slaves_count; i++) {
+ ret = rte_eth_macaddr_get(i, &addr);
+ if (ret != 0) {
+ cmdline_printf(cl,
+ "Failed to get port %u MAC address: %s\n",
+ i, strerror(-ret));
+ continue;
+ }
- while (i < slaves_count) {
- rte_eth_macaddr_get(i, &addr);
PRINT_MAC(addr);
printf("\n");
- i++;
}
rte_spinlock_trylock(&global_flag_stru_p->lock);
diff --git a/examples/distributor/main.c b/examples/distributor/main.c
index 49b4e61..567c5e9 100644
--- a/examples/distributor/main.c
+++ b/examples/distributor/main.c
@@ -192,7 +192,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
}
struct rte_ether_addr addr;
- rte_eth_macaddr_get(port, &addr);
+ retval = rte_eth_macaddr_get(port, &addr);
+ if (retval < 0) {
+ printf("Failed to get MAC address (port %u): %s\n",
+ port, rte_strerror(-retval));
+ return retval;
+ }
+
printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
port,
diff --git a/examples/ethtool/ethtool-app/main.c b/examples/ethtool/ethtool-app/main.c
index 774df7e..2989101 100644
--- a/examples/ethtool/ethtool-app/main.c
+++ b/examples/ethtool/ethtool-app/main.c
@@ -156,7 +156,12 @@ static void setup_ports(struct app_config *app_cfg, int cnt_ports)
"%s:%i: rte_eth_dev_start failed",
__FILE__, __LINE__
);
- rte_eth_macaddr_get(idx_port, &ptr_port->mac_addr);
+ ret = rte_eth_macaddr_get(idx_port, &ptr_port->mac_addr);
+ if (ret != 0)
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_macaddr_get failed (port %u): %s\n",
+ idx_port, rte_strerror(-ret));
+
rte_spinlock_init(&ptr_port->lock);
}
}
@@ -182,6 +187,7 @@ static int slave_main(__attribute__((unused)) void *ptr_data)
uint16_t cnt_sent;
uint16_t idx_port;
uint16_t lock_result;
+ int ret;
while (app_cfg.exit_now == 0) {
for (idx_port = 0; idx_port < app_cfg.cnt_ports; idx_port++) {
@@ -198,8 +204,16 @@ static int slave_main(__attribute__((unused)) void *ptr_data)
/* MAC address was updated */
if (ptr_port->port_dirty == 1) {
- rte_eth_macaddr_get(ptr_port->idx_port,
+ ret = rte_eth_macaddr_get(ptr_port->idx_port,
&ptr_port->mac_addr);
+ if (ret != 0) {
+ rte_spinlock_unlock(&ptr_port->lock);
+ printf("Failed to get MAC address (port %u): %s",
+ ptr_port->idx_port,
+ rte_strerror(-ret));
+ return ret;
+ }
+
ptr_port->port_dirty = 0;
}
diff --git a/examples/ethtool/lib/rte_ethtool.c b/examples/ethtool/lib/rte_ethtool.c
index 8393b0d..667d7ea 100644
--- a/examples/ethtool/lib/rte_ethtool.c
+++ b/examples/ethtool/lib/rte_ethtool.c
@@ -314,10 +314,15 @@ rte_ethtool_net_stop(uint16_t port_id)
int
rte_ethtool_net_get_mac_addr(uint16_t port_id, struct rte_ether_addr *addr)
{
+ int ret;
+
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
if (addr == NULL)
return -EINVAL;
- rte_eth_macaddr_get(port_id, addr);
+
+ ret = rte_eth_macaddr_get(port_id, addr);
+ if (ret != 0)
+ return ret;
return 0;
}
diff --git a/examples/eventdev_pipeline/main.c b/examples/eventdev_pipeline/main.c
index c734c77..f778302 100644
--- a/examples/eventdev_pipeline/main.c
+++ b/examples/eventdev_pipeline/main.c
@@ -324,7 +324,13 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
/* Display the port MAC address. */
struct rte_ether_addr addr;
- rte_eth_macaddr_get(port, &addr);
+ retval = rte_eth_macaddr_get(port, &addr);
+ if (retval != 0) {
+ printf("Failed to get MAC address (port %u): %s\n",
+ port, rte_strerror(-retval));
+ return retval;
+ }
+
printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
" %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
(unsigned int)port,
diff --git a/examples/flow_classify/flow_classify.c b/examples/flow_classify/flow_classify.c
index ae0faf6..1c12bbb 100644
--- a/examples/flow_classify/flow_classify.c
+++ b/examples/flow_classify/flow_classify.c
@@ -242,7 +242,10 @@ port_init(uint8_t port, struct rte_mempool *mbuf_pool)
return retval;
/* Display the port MAC address. */
- rte_eth_macaddr_get(port, &addr);
+ retval = rte_eth_macaddr_get(port, &addr);
+ if (retval != 0)
+ return retval;
+
printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
" %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
port,
diff --git a/examples/ip_fragmentation/main.c b/examples/ip_fragmentation/main.c
index f90edc5..1046123 100644
--- a/examples/ip_fragmentation/main.c
+++ b/examples/ip_fragmentation/main.c
@@ -992,7 +992,14 @@ main(int argc, char **argv)
ret, portid);
}
- rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ if (ret < 0) {
+ printf("\n");
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_macaddr_get: err=%d, port=%d\n",
+ ret, portid);
+ }
+
print_ethaddr(" Address:", &ports_eth_addr[portid]);
printf("\n");
diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 4930310..02dc114 100644
--- a/examples/ip_pipeline/cli.c
+++ b/examples/ip_pipeline/cli.c
@@ -253,7 +253,13 @@ print_link_info(struct link *link, char *out, size_t out_size)
memset(&stats, 0, sizeof(stats));
rte_eth_stats_get(link->port_id, &stats);
- rte_eth_macaddr_get(link->port_id, &mac_addr);
+ ret = rte_eth_macaddr_get(link->port_id, &mac_addr);
+ if (ret != 0) {
+ snprintf(out, out_size, "\n%s: MAC address get failed: %s",
+ link->name, rte_strerror(-ret));
+ return;
+ }
+
ret = rte_eth_link_get(link->port_id, &eth_link);
if (ret < 0) {
snprintf(out, out_size, "\n%s: link get failed: %s",
diff --git a/examples/ip_reassembly/main.c b/examples/ip_reassembly/main.c
index c822c8c..d59e6d0 100644
--- a/examples/ip_reassembly/main.c
+++ b/examples/ip_reassembly/main.c
@@ -1132,7 +1132,14 @@ main(int argc, char **argv)
ret, portid);
}
- rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ if (ret < 0) {
+ printf("\n");
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_macaddr_get: err=%d, port=%d\n",
+ ret, portid);
+ }
+
print_ethaddr(" Address:", &ports_eth_addr[portid]);
printf("\n");
diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c
index eda049b..f52ca52 100644
--- a/examples/ipsec-secgw/ipsec-secgw.c
+++ b/examples/ipsec-secgw/ipsec-secgw.c
@@ -1934,7 +1934,12 @@ port_init(uint16_t portid, uint64_t req_rx_offloads, uint64_t req_tx_offloads)
printf("Configuring device port %u:\n", portid);
- rte_eth_macaddr_get(portid, &ethaddr);
+ ret = rte_eth_macaddr_get(portid, &ethaddr);
+ if (ret != 0)
+ rte_exit(EXIT_FAILURE,
+ "Error getting MAC address (port %u): %s\n",
+ portid, rte_strerror(-ret));
+
ethaddr_tbl[portid].src = ETHADDR_TO_UINT64(&ethaddr);
print_ethaddr("Address: ", &ethaddr);
printf("\n");
diff --git a/examples/ipv4_multicast/main.c b/examples/ipv4_multicast/main.c
index 7389bee..464b546 100644
--- a/examples/ipv4_multicast/main.c
+++ b/examples/ipv4_multicast/main.c
@@ -739,7 +739,12 @@ main(int argc, char **argv)
"Cannot adjust number of descriptors: err=%d, port=%d\n",
ret, portid);
- rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Cannot get MAC address: err=%d, port=%d\n",
+ ret, portid);
+
print_ethaddr(" Address:", &ports_eth_addr[portid]);
printf(", ");
diff --git a/examples/kni/main.c b/examples/kni/main.c
index 8eb5b61..c576fc7 100644
--- a/examples/kni/main.c
+++ b/examples/kni/main.c
@@ -940,8 +940,12 @@ kni_alloc(uint16_t port_id)
port_id, strerror(-ret));
/* Get the interface default mac address */
- rte_eth_macaddr_get(port_id,
+ ret = rte_eth_macaddr_get(port_id,
(struct rte_ether_addr *)&conf.mac_addr);
+ if (ret != 0)
+ rte_exit(EXIT_FAILURE,
+ "Failed to get MAC address (port %u): %s\n",
+ port_id, rte_strerror(-ret));
rte_eth_dev_get_mtu(port_id, &conf.mtu);
diff --git a/examples/l2fwd-cat/l2fwd-cat.c b/examples/l2fwd-cat/l2fwd-cat.c
index b15f033..6838f28 100644
--- a/examples/l2fwd-cat/l2fwd-cat.c
+++ b/examples/l2fwd-cat/l2fwd-cat.c
@@ -74,7 +74,10 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
/* Display the port MAC address. */
struct rte_ether_addr addr;
- rte_eth_macaddr_get(port, &addr);
+ retval = rte_eth_macaddr_get(port, &addr);
+ if (retval < 0)
+ return retval;
+
printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
" %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
port,
diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c
index 7c84b40..61d7829 100644
--- a/examples/l2fwd-crypto/main.c
+++ b/examples/l2fwd-crypto/main.c
@@ -2589,7 +2589,13 @@ initialize_ports(struct l2fwd_crypto_options *options)
return -1;
}
- rte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);
+ retval = rte_eth_macaddr_get(portid,
+ &l2fwd_ports_eth_addr[portid]);
+ if (retval < 0) {
+ printf("rte_eth_macaddr_get :err=%d, port=%u\n",
+ retval, portid);
+ return -1;
+ }
printf("Port %u, MAC address: %02X:%02X:%02X:%02X:%02X:%02X\n\n",
portid,
diff --git a/examples/l2fwd-jobstats/main.c b/examples/l2fwd-jobstats/main.c
index 4f930d0..f975aa1 100644
--- a/examples/l2fwd-jobstats/main.c
+++ b/examples/l2fwd-jobstats/main.c
@@ -872,7 +872,12 @@ main(int argc, char **argv)
"Cannot adjust number of descriptors: err=%d, port=%u\n",
ret, portid);
- rte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid,
+ &l2fwd_ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Cannot get MAC address: err=%d, port=%u\n",
+ ret, portid);
/* init one RX queue */
fflush(stdout);
diff --git a/examples/l2fwd-keepalive/main.c b/examples/l2fwd-keepalive/main.c
index 21278ee..b368349 100644
--- a/examples/l2fwd-keepalive/main.c
+++ b/examples/l2fwd-keepalive/main.c
@@ -665,7 +665,12 @@ main(int argc, char **argv)
"Cannot adjust number of descriptors: err=%d, port=%u\n",
ret, portid);
- rte_eth_macaddr_get(portid, &l2fwd_ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid,
+ &l2fwd_ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Cannot mac address: err=%d, port=%u\n",
+ ret, portid);
/* init one RX queue */
fflush(stdout);
diff --git a/examples/l2fwd/main.c b/examples/l2fwd/main.c
index 6b9f09a..d7bcbfa 100644
--- a/examples/l2fwd/main.c
+++ b/examples/l2fwd/main.c
@@ -665,7 +665,12 @@ main(int argc, char **argv)
"Cannot adjust number of descriptors: err=%d, port=%u\n",
ret, portid);
- rte_eth_macaddr_get(portid,&l2fwd_ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid,
+ &l2fwd_ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Cannot get MAC address: err=%d, port=%u\n",
+ ret, portid);
/* init one RX queue */
fflush(stdout);
diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c
index 0abb8cb..fa92a28 100644
--- a/examples/l3fwd-acl/main.c
+++ b/examples/l3fwd-acl/main.c
@@ -1968,7 +1968,12 @@ main(int argc, char **argv)
"rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
ret, portid);
- rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_macaddr_get: err=%d, port=%d\n",
+ ret, portid);
+
print_ethaddr(" Address:", &ports_eth_addr[portid]);
printf(", ");
diff --git a/examples/l3fwd-power/main.c b/examples/l3fwd-power/main.c
index 2e3b1d3..a03f64a 100644
--- a/examples/l3fwd-power/main.c
+++ b/examples/l3fwd-power/main.c
@@ -2323,7 +2323,12 @@ main(int argc, char **argv)
"Cannot adjust number of descriptors: err=%d, port=%d\n",
ret, portid);
- rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Cannot get MAC address: err=%d, port=%d\n",
+ ret, portid);
+
print_ethaddr(" Address:", &ports_eth_addr[portid]);
printf(", ");
diff --git a/examples/l3fwd-vf/main.c b/examples/l3fwd-vf/main.c
index 572e74c..ff6c9e2 100644
--- a/examples/l3fwd-vf/main.c
+++ b/examples/l3fwd-vf/main.c
@@ -985,7 +985,12 @@ main(int argc, char **argv)
"Cannot adjust number of descriptors: err=%d, port=%d\n",
ret, portid);
- rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Cannot get MAC address: err=%d, port=%d\n",
+ ret, portid);
+
print_ethaddr(" Address:", &ports_eth_addr[portid]);
printf(", ");
diff --git a/examples/l3fwd/main.c b/examples/l3fwd/main.c
index 7253aca..4dea12a 100644
--- a/examples/l3fwd/main.c
+++ b/examples/l3fwd/main.c
@@ -917,7 +917,12 @@ main(int argc, char **argv)
"Cannot adjust number of descriptors: err=%d, "
"port=%d\n", ret, portid);
- rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "Cannot get MAC address: err=%d, port=%d\n",
+ ret, portid);
+
print_ethaddr(" Address:", &ports_eth_addr[portid]);
printf(", ");
print_ethaddr("Destination:",
diff --git a/examples/link_status_interrupt/main.c b/examples/link_status_interrupt/main.c
index a0b75d9..a924aa2 100644
--- a/examples/link_status_interrupt/main.c
+++ b/examples/link_status_interrupt/main.c
@@ -657,8 +657,12 @@ main(int argc, char **argv)
rte_eth_dev_callback_register(portid,
RTE_ETH_EVENT_INTR_LSC, lsi_event_callback, NULL);
- rte_eth_macaddr_get(portid,
+ ret = rte_eth_macaddr_get(portid,
&lsi_ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_macaddr_get: err=%d, port=%u\n",
+ ret, (unsigned int)portid);
/* init one RX queue */
fflush(stdout);
diff --git a/examples/multi_process/client_server_mp/mp_server/main.c b/examples/multi_process/client_server_mp/mp_server/main.c
index 0150533..802e29d 100644
--- a/examples/multi_process/client_server_mp/mp_server/main.c
+++ b/examples/multi_process/client_server_mp/mp_server/main.c
@@ -61,12 +61,18 @@ get_printable_mac_addr(uint16_t port)
{
static const char err_address[] = "00:00:00:00:00:00";
static char addresses[RTE_MAX_ETHPORTS][sizeof(err_address)];
+ int ret;
if (unlikely(port >= RTE_MAX_ETHPORTS))
return err_address;
if (unlikely(addresses[port][0]=='\0')){
struct rte_ether_addr mac;
- rte_eth_macaddr_get(port, &mac);
+ ret = rte_eth_macaddr_get(port, &mac);
+ if (ret != 0) {
+ printf("Failed to get MAC address (port %u): %s\n",
+ port, rte_strerror(-ret));
+ return err_address;
+ }
snprintf(addresses[port], sizeof(addresses[port]),
"%02x:%02x:%02x:%02x:%02x:%02x\n",
mac.addr_bytes[0], mac.addr_bytes[1], mac.addr_bytes[2],
diff --git a/examples/packet_ordering/main.c b/examples/packet_ordering/main.c
index 132f582..b397b31 100644
--- a/examples/packet_ordering/main.c
+++ b/examples/packet_ordering/main.c
@@ -322,7 +322,13 @@ configure_eth_port(uint16_t port_id)
if (ret < 0)
return ret;
- rte_eth_macaddr_get(port_id, &addr);
+ ret = rte_eth_macaddr_get(port_id, &addr);
+ if (ret != 0) {
+ printf("Failed to get MAC address (port %u): %s\n",
+ port_id, rte_strerror(-ret));
+ return ret;
+ }
+
printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
port_id,
diff --git a/examples/performance-thread/l3fwd-thread/main.c b/examples/performance-thread/l3fwd-thread/main.c
index de05219..122c632 100644
--- a/examples/performance-thread/l3fwd-thread/main.c
+++ b/examples/performance-thread/l3fwd-thread/main.c
@@ -3602,7 +3602,12 @@ main(int argc, char **argv)
"rte_eth_dev_adjust_nb_rx_tx_desc: err=%d, port=%d\n",
ret, portid);
- rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ ret = rte_eth_macaddr_get(portid, &ports_eth_addr[portid]);
+ if (ret < 0)
+ rte_exit(EXIT_FAILURE,
+ "rte_eth_macaddr_get: err=%d, port=%d\n",
+ ret, portid);
+
print_ethaddr(" Address:", &ports_eth_addr[portid]);
printf(", ");
print_ethaddr("Destination:",
diff --git a/examples/ptpclient/ptpclient.c b/examples/ptpclient/ptpclient.c
index 6e273f6..a1a7ae6 100644
--- a/examples/ptpclient/ptpclient.c
+++ b/examples/ptpclient/ptpclient.c
@@ -378,6 +378,7 @@ static void
parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
{
struct rte_ether_hdr *eth_hdr;
+ struct rte_ether_addr eth_addr;
struct ptp_header *ptp_hdr;
struct clock_id *client_clkid;
struct ptp_message *ptp_msg;
@@ -387,6 +388,7 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
size_t pkt_size;
int wait_us;
struct rte_mbuf *m = ptp_data->m;
+ int ret;
eth_hdr = rte_pktmbuf_mtod(m, struct rte_ether_hdr *);
ptp_hdr = (struct ptp_header *)(rte_pktmbuf_mtod(m, char *)
@@ -407,6 +409,13 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
(((uint64_t)ntohs(origin_tstamp->sec_msb)) << 32);
if (ptp_data->seqID_FOLLOWUP == ptp_data->seqID_SYNC) {
+ ret = rte_eth_macaddr_get(ptp_data->portid, &eth_addr);
+ if (ret != 0) {
+ printf("\nCore %u: port %u failed to get MAC address: %s\n",
+ rte_lcore_id(), ptp_data->portid,
+ rte_strerror(-ret));
+ return;
+ }
created_pkt = rte_pktmbuf_alloc(mbuf_pool);
pkt_size = sizeof(struct rte_ether_hdr) +
@@ -414,7 +423,7 @@ parse_fup(struct ptpv2_data_slave_ordinary *ptp_data)
created_pkt->data_len = pkt_size;
created_pkt->pkt_len = pkt_size;
eth_hdr = rte_pktmbuf_mtod(created_pkt, struct rte_ether_hdr *);
- rte_eth_macaddr_get(ptp_data->portid, &eth_hdr->s_addr);
+ rte_ether_addr_copy(&eth_addr, &eth_hdr->s_addr);
/* Set multicast address 01-1B-19-00-00-00. */
rte_ether_addr_copy(&eth_multicast, &eth_hdr->d_addr);
diff --git a/examples/quota_watermark/qw/main.c b/examples/quota_watermark/qw/main.c
index a61360b..c985eed 100644
--- a/examples/quota_watermark/qw/main.c
+++ b/examples/quota_watermark/qw/main.c
@@ -52,11 +52,20 @@ static void send_pause_frame(uint16_t port_id, uint16_t duration)
struct ether_fc_frame *pause_frame;
struct rte_ether_hdr *hdr;
struct rte_ether_addr mac_addr;
+ int ret;
RTE_LOG_DP(DEBUG, USER1,
"Sending PAUSE frame (duration=%d) on port %d\n",
duration, port_id);
+ ret = rte_eth_macaddr_get(port_id, &mac_addr);
+ if (ret != 0) {
+ RTE_LOG_DP(ERR, USER1,
+ "Failed to get MAC address (port %u): %s\n",
+ port_id, rte_strerror(-ret));
+ return;
+ }
+
/* Get a mbuf from the pool */
mbuf = rte_pktmbuf_alloc(mbuf_pool);
if (unlikely(mbuf == NULL))
@@ -66,7 +75,6 @@ static void send_pause_frame(uint16_t port_id, uint16_t duration)
hdr = rte_pktmbuf_mtod(mbuf, struct rte_ether_hdr *);
pause_frame = (struct ether_fc_frame *) &hdr[1];
- rte_eth_macaddr_get(port_id, &mac_addr);
rte_ether_addr_copy(&mac_addr, &hdr->s_addr);
void *tmp = &hdr->d_addr.addr_bytes[0];
diff --git a/examples/rxtx_callbacks/main.c b/examples/rxtx_callbacks/main.c
index 5d54511..07e95e8 100644
--- a/examples/rxtx_callbacks/main.c
+++ b/examples/rxtx_callbacks/main.c
@@ -188,7 +188,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
struct rte_ether_addr addr;
- rte_eth_macaddr_get(port, &addr);
+ retval = rte_eth_macaddr_get(port, &addr);
+ if (retval < 0) {
+ printf("Failed to get MAC address on port %u: %s\n",
+ port, rte_strerror(-retval));
+ return retval;
+ }
printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
(unsigned)port,
diff --git a/examples/server_node_efd/server/main.c b/examples/server_node_efd/server/main.c
index 7b4657e..455bdc0 100644
--- a/examples/server_node_efd/server/main.c
+++ b/examples/server_node_efd/server/main.c
@@ -69,11 +69,18 @@ get_printable_mac_addr(uint16_t port)
static const char err_address[] = "00:00:00:00:00:00";
static char addresses[RTE_MAX_ETHPORTS][sizeof(err_address)];
struct rte_ether_addr mac;
+ int ret;
if (unlikely(port >= RTE_MAX_ETHPORTS))
return err_address;
if (unlikely(addresses[port][0] == '\0')) {
- rte_eth_macaddr_get(port, &mac);
+ ret = rte_eth_macaddr_get(port, &mac);
+ if (ret != 0) {
+ printf("Failed to get MAC address (port %u): %s\n",
+ port, rte_strerror(-ret));
+ return err_address;
+ }
+
snprintf(addresses[port], sizeof(addresses[port]),
"%02x:%02x:%02x:%02x:%02x:%02x\n",
mac.addr_bytes[0], mac.addr_bytes[1],
diff --git a/examples/skeleton/basicfwd.c b/examples/skeleton/basicfwd.c
index 8f1805a..73d313b 100644
--- a/examples/skeleton/basicfwd.c
+++ b/examples/skeleton/basicfwd.c
@@ -89,7 +89,10 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
/* Display the port MAC address. */
struct rte_ether_addr addr;
- rte_eth_macaddr_get(port, &addr);
+ retval = rte_eth_macaddr_get(port, &addr);
+ if (retval != 0)
+ return retval;
+
printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
" %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
port,
diff --git a/examples/tep_termination/vxlan_setup.c b/examples/tep_termination/vxlan_setup.c
index 8d6514d..f9f857c 100644
--- a/examples/tep_termination/vxlan_setup.c
+++ b/examples/tep_termination/vxlan_setup.c
@@ -182,7 +182,10 @@ vxlan_port_init(uint16_t port, struct rte_mempool *mbuf_pool)
retval = rte_eth_dev_udp_tunnel_port_add(port, &tunnel_udp);
if (retval < 0)
return retval;
- rte_eth_macaddr_get(port, &ports_eth_addr[port]);
+ retval = rte_eth_macaddr_get(port, &ports_eth_addr[port]);
+ if (retval < 0)
+ return retval;
+
RTE_LOG(INFO, PORT, "Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
port,
diff --git a/examples/vhost/main.c b/examples/vhost/main.c
index b5632d7..ab649bf 100644
--- a/examples/vhost/main.c
+++ b/examples/vhost/main.c
@@ -346,7 +346,14 @@ port_init(uint16_t port)
}
}
- rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]);
+ retval = rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]);
+ if (retval < 0) {
+ RTE_LOG(ERR, VHOST_PORT,
+ "Failed to get MAC address on port %u: %s\n",
+ port, rte_strerror(-retval));
+ return retval;
+ }
+
RTE_LOG(INFO, VHOST_PORT, "Max virtio devices supported: %u\n", num_devices);
RTE_LOG(INFO, VHOST_PORT, "Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
diff --git a/examples/vm_power_manager/guest_cli/main.c b/examples/vm_power_manager/guest_cli/main.c
index 2094145..f63b3c9 100644
--- a/examples/vm_power_manager/guest_cli/main.c
+++ b/examples/vm_power_manager/guest_cli/main.c
@@ -55,7 +55,11 @@ parse_args(int argc, char **argv)
int i, cnt, idx;
policy = get_policy();
- set_policy_defaults(policy);
+ ret = set_policy_defaults(policy);
+ if (ret != 0) {
+ printf("Failed to set policy defaults\n");
+ return -1;
+ }
argvopt = argv;
@@ -120,7 +124,10 @@ parse_args(int argc, char **argv)
for (i = 0; i < MAX_VCPU_PER_VM; i++) {
if (ports[i]) {
printf("***Using port %d\n", i);
- set_policy_mac(i, idx++);
+ if (set_policy_mac(i, idx++) != 0) {
+ printf("Cannot set policy MAC");
+ return -1;
+ }
}
}
policy->nb_mac_to_monitor = idx;
diff --git a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c
index 78c3aa0..77e5440 100644
--- a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c
+++ b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.c
@@ -51,9 +51,15 @@ set_policy_mac(int port, int idx)
{
struct channel_packet *policy;
union PFID pfid;
+ int ret;
/* Use port MAC address as the vfid */
- rte_eth_macaddr_get(port, &pfid.addr);
+ ret = rte_eth_macaddr_get(port, &pfid.addr);
+ if (retval != 0) {
+ printf("Failed to get device (port %u) MAC address: %s\n",
+ port, rte_strerror(-retval));
+ return retval;
+ }
printf("Port %u MAC: %02" PRIx8 ":%02" PRIx8 ":%02" PRIx8 ":"
"%02" PRIx8 ":%02" PRIx8 ":%02" PRIx8 "\n",
@@ -66,10 +72,15 @@ set_policy_mac(int port, int idx)
return 0;
}
-void
+int
set_policy_defaults(struct channel_packet *pkt)
{
- set_policy_mac(0, 0);
+ int ret;
+
+ ret = set_policy_mac(0, 0);
+ if (ret != 0)
+ return ret;
+
pkt->nb_mac_to_monitor = 1;
pkt->t_boost_status.tbEnabled = false;
diff --git a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.h b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.h
index fd77f6a..0c2cc13 100644
--- a/examples/vm_power_manager/guest_cli/vm_power_cli_guest.h
+++ b/examples/vm_power_manager/guest_cli/vm_power_cli_guest.h
@@ -15,7 +15,7 @@ struct channel_packet *get_policy(void);
int set_policy_mac(int port, int idx);
-void set_policy_defaults(struct channel_packet *pkt);
+int set_policy_defaults(struct channel_packet *pkt);
void run_cli(__attribute__((unused)) void *arg);
diff --git a/examples/vm_power_manager/main.c b/examples/vm_power_manager/main.c
index ed18177..d39f044 100644
--- a/examples/vm_power_manager/main.c
+++ b/examples/vm_power_manager/main.c
@@ -112,7 +112,13 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
/* Display the port MAC address. */
struct rte_ether_addr addr;
- rte_eth_macaddr_get(port, &addr);
+ retval = rte_eth_macaddr_get(port, &addr);
+ if (retval != 0) {
+ printf("Failed to get device (port %u) MAC address: %s\n",
+ port, rte_strerror(-retval));
+ return retval;
+ }
+
printf("Port %u MAC: %02" PRIx8 " %02" PRIx8 " %02" PRIx8
" %02" PRIx8 " %02" PRIx8 " %02" PRIx8 "\n",
(unsigned int)port,
diff --git a/examples/vmdq/main.c b/examples/vmdq/main.c
index 91f9a99..6e6fc91 100644
--- a/examples/vmdq/main.c
+++ b/examples/vmdq/main.c
@@ -276,7 +276,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
return retval;
}
- rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]);
+ retval = rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]);
+ if (retval < 0) {
+ printf("port %d MAC address get failed: %s\n", port,
+ rte_strerror(-retval));
+ return retval;
+ }
printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
(unsigned)port,
diff --git a/examples/vmdq_dcb/main.c b/examples/vmdq_dcb/main.c
index 2122e41..594c4f1 100644
--- a/examples/vmdq_dcb/main.c
+++ b/examples/vmdq_dcb/main.c
@@ -333,7 +333,12 @@ port_init(uint16_t port, struct rte_mempool *mbuf_pool)
return retval;
}
- rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]);
+ retval = rte_eth_macaddr_get(port, &vmdq_ports_eth_addr[port]);
+ if (retval < 0) {
+ printf("port %d MAC address get failed: %s\n", port,
+ rte_strerror(-retval));
+ return retval;
+ }
printf("Port %u MAC: %02"PRIx8" %02"PRIx8" %02"PRIx8
" %02"PRIx8" %02"PRIx8" %02"PRIx8"\n",
(unsigned)port,