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 15B89A2EEB for ; Tue, 10 Sep 2019 10:54:03 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 40B741EF20; Tue, 10 Sep 2019 10:53:24 +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 311DB1EBD2 for ; Tue, 10 Sep 2019 10:53:10 +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 EF39FB40057; Tue, 10 Sep 2019 08:53:08 +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:06 -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:06 -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 x8A8r4xY024751; Tue, 10 Sep 2019 09:53:05 +0100 Received: from ukv-loginhost.uk.solarflarecom.com (localhost [127.0.0.1]) by ukv-loginhost.uk.solarflarecom.com (Postfix) with ESMTP id E5F011613D1; Tue, 10 Sep 2019 09:53:04 +0100 (BST) From: Andrew Rybchenko To: Chas Williams CC: , Igor Romanov Date: Tue, 10 Sep 2019 09:52:21 +0100 Message-ID: <1568105541-7399-8-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-2.003600-4.000000-10 X-TMASE-MatchedRID: MRojtx73vL7NQetBFGxSlJzEHTUOuMX39teeW6UfkyAHZBaLwEXlKCzy bVqWyY2N+aSt+E6D0kXoRyzm1ypDijPDK33fd2NSTWuFDn5CUjRAbSn2l83OUbqln+jYe7ZhQtu FUiSMVEjVPGtJpQStsDEUEo62KQrYLvv2cUtLK/uhLSC6hXpJl1IOc8QjxyVt27KSseGDg91moe pWJU2SGfqgpAKmfb8+5dAcjqNCUH3RQdw4XFGJY07CajSVoNFscsjLQ6Lp2zC5ZjHyzYrpGhLjB 1Nuqu454vM1YF6AJbbCCfuIMF6xLSdET58jp62SHl11wdxn70vmUHUbYfgsUd9OavgXA0U3Hfox 2xtrYDIYjJLmmd66utCx5lUNzF/6Dio24RMqbthd/Q1tNPUIuApXMBSsm62CvU24pLfQFmdAgUh ku2yAbQNQf6dUs3KIKyog/1PG+0kxvqnnvSKWdw== X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-TMASE-Result: 10--2.003600-4.000000 X-TMASE-Version: SMEX-12.5.0.1300-8.5.1010-24898.005 X-MDID: 1568105589-e2FsZ3GD-gQg Subject: [dpdk-dev] [PATCH 7/7] examples/bond: 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 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 Signed-off-by: Andrew Rybchenko --- examples/bond/main.c | 58 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/examples/bond/main.c b/examples/bond/main.c index 39214cfee..ee8fa2d27 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(ð_hdr->s_addr, ð_hdr->d_addr); - rte_eth_macaddr_get(BOND_PORT, ð_hdr->s_addr); + rte_ether_addr_copy(&bond_mac_addr, ð_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(ð_hdr->s_addr, ð_hdr->d_addr); - rte_eth_macaddr_get(BOND_PORT, ð_hdr->s_addr); + rte_ether_addr_copy(&bond_mac_addr, ð_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, ð_hdr->s_addr); + rte_ether_addr_copy(&bond_mac_addr, ð_hdr->s_addr); memset(ð_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); -- 2.17.1