[14/18] examples/flow_filtering: check status of getting link info

Message ID 1568103959-25572-15-git-send-email-arybchenko@solarflare.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series ethdev: change link status get functions return value to int |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Andrew Rybchenko Sept. 10, 2019, 8:25 a.m. UTC
  From: Igor Romanov <igor.romanov@oktetlabs.ru>

The return value of rte_eth_link_get() and rte_eth_link_get_nowait()
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>
---
 examples/flow_filtering/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
  

Comments

Ori Kam Sept. 12, 2019, 5:16 a.m. UTC | #1
> -----Original Message-----
> From: Andrew Rybchenko <arybchenko@solarflare.com>
> Sent: Tuesday, September 10, 2019 11:26 AM
> To: Marko Kovacevic <marko.kovacevic@intel.com>; Ori Kam
> <orika@mellanox.com>; Bruce Richardson <bruce.richardson@intel.com>;
> Pablo de Lara <pablo.de.lara.guarch@intel.com>; Radu Nicolau
> <radu.nicolau@intel.com>; Akhil Goyal <akhil.goyal@nxp.com>; Tomasz
> Kantecki <tomasz.kantecki@intel.com>
> Cc: dev@dpdk.org; Igor Romanov <igor.romanov@oktetlabs.ru>
> Subject: [PATCH 14/18] examples/flow_filtering: check status of getting link
> info
> 
> From: Igor Romanov <igor.romanov@oktetlabs.ru>
> 
> The return value of rte_eth_link_get() and rte_eth_link_get_nowait()
> 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>
> ---
>  examples/flow_filtering/main.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
> index c40cfd098..cc9e7e780 100644
> --- a/examples/flow_filtering/main.c
> +++ b/examples/flow_filtering/main.c
> @@ -100,15 +100,19 @@ assert_link_status(void)
>  {
>  	struct rte_eth_link link;
>  	uint8_t rep_cnt = MAX_REPEAT_TIMES;
> +	int link_get_err = -EINVAL;
> 
>  	memset(&link, 0, sizeof(link));
>  	do {
> -		rte_eth_link_get(port_id, &link);
> -		if (link.link_status == ETH_LINK_UP)
> +		link_get_err = rte_eth_link_get(port_id, &link);
> +		if (link_get_err == 0 && link.link_status == ETH_LINK_UP)
>  			break;
>  		rte_delay_ms(CHECK_INTERVAL);
>  	} while (--rep_cnt);
> 
> +	if (link_get_err < 0)
> +		rte_exit(EXIT_FAILURE, ":: error: link get is failing: %s\n",
> +			 rte_strerror(-link_get_err));
>  	if (link.link_status == ETH_LINK_DOWN)
>  		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
>  }
> --
> 2.17.1

Acked-by: Ori Kam <orika@mellanox.com>
Thanks,
Ori Kam
  

Patch

diff --git a/examples/flow_filtering/main.c b/examples/flow_filtering/main.c
index c40cfd098..cc9e7e780 100644
--- a/examples/flow_filtering/main.c
+++ b/examples/flow_filtering/main.c
@@ -100,15 +100,19 @@  assert_link_status(void)
 {
 	struct rte_eth_link link;
 	uint8_t rep_cnt = MAX_REPEAT_TIMES;
+	int link_get_err = -EINVAL;
 
 	memset(&link, 0, sizeof(link));
 	do {
-		rte_eth_link_get(port_id, &link);
-		if (link.link_status == ETH_LINK_UP)
+		link_get_err = rte_eth_link_get(port_id, &link);
+		if (link_get_err == 0 && link.link_status == ETH_LINK_UP)
 			break;
 		rte_delay_ms(CHECK_INTERVAL);
 	} while (--rep_cnt);
 
+	if (link_get_err < 0)
+		rte_exit(EXIT_FAILURE, ":: error: link get is failing: %s\n",
+			 rte_strerror(-link_get_err));
 	if (link.link_status == ETH_LINK_DOWN)
 		rte_exit(EXIT_FAILURE, ":: error: link is still down\n");
 }