[dpdk-dev,1/2] net/mlx5: fix link status query

Message ID 1485348178-43771-1-git-send-email-shahafs@mellanox.com (mailing list archive)
State Superseded, archived
Delegated to: Ferruh Yigit
Headers

Checks

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

Commit Message

Shahaf Shuler Jan. 25, 2017, 12:42 p.m. UTC
  Trying to query the link status through new kernel ioctl API
ETHTOOL_GLINKSETTINGS was always failing due to kernel bug.
The bug was fixed on version 4.9
this patch uses the legacy ioctl API for lower kernels.

Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
CC: stable@dpdk.org

Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
---
while the ETHTOOL_GLINKSETTINGS API was introduced on kernel v4.6 [1]                   
the bug was fixed only on kernel v4.9 [2]                                               
                                                                                        
[1] https://github.com/torvalds/linux/commit/3f1ac7a700d039c61d8d8b99f28d605d489a60cf   
[2] https://github.com/torvalds/linux/commit/8006f6bf5e39f11c697f48df20382b81d2f2f8b8   
---
 drivers/net/mlx5/mlx5_ethdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
  

Comments

Nélio Laranjeiro Jan. 30, 2017, 3:25 p.m. UTC | #1
On Wed, Jan 25, 2017 at 02:42:58PM +0200, Shahaf Shuler wrote:
> Trying to query the link status through new kernel ioctl API
> ETHTOOL_GLINKSETTINGS was always failing due to kernel bug.
> The bug was fixed on version 4.9
> this patch uses the legacy ioctl API for lower kernels.
> 
> Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
> CC: stable@dpdk.org
> 
> Signed-off-by: Shahaf Shuler <shahafs@mellanox.com>
> ---
> while the ETHTOOL_GLINKSETTINGS API was introduced on kernel v4.6 [1]                   
> the bug was fixed only on kernel v4.9 [2]                                               
>                                                                                         
> [1] https://github.com/torvalds/linux/commit/3f1ac7a700d039c61d8d8b99f28d605d489a60cf   
> [2] https://github.com/torvalds/linux/commit/8006f6bf5e39f11c697f48df20382b81d2f2f8b8   
> ---
>  drivers/net/mlx5/mlx5_ethdev.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
> index 8efdff7..e77238f 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -46,6 +46,7 @@
>  #include <netinet/in.h>
>  #include <linux/ethtool.h>
>  #include <linux/sockios.h>
> +#include <linux/version.h>
>  #include <fcntl.h>
>  
>  /* DPDK headers don't like -pedantic. */
> @@ -697,7 +698,7 @@ struct priv *
>  
>  /**
>   * Retrieve physical link information (unlocked version using new ioctl from
> - * Linux 4.5).
> + * Linux 4.9).
>   *
>   * @param dev
>   *   Pointer to Ethernet device structure.
> @@ -707,7 +708,7 @@ struct priv *
>  static int
>  mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete)
>  {
> -#ifdef ETHTOOL_GLINKSETTINGS
> +#if KERNEL_VERSION(4, 9, 0) <= LINUX_VERSION_CODE
>  	struct priv *priv = mlx5_get_priv(dev);
>  	struct ethtool_link_settings edata = {
>  		.cmd = ETHTOOL_GLINKSETTINGS,
> -- 
> 1.8.3.1

Hi Shahaf,

This function embeds some HAVE_ETHTOOL_LINK_MODE_* to handle the
different version of Linux Kernel where those link speeds were added.
With this patch, they becomes useless.

It could be great for configuration and compilation time to remove them
from this file and the Makefile.

Regards,
  

Patch

diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index 8efdff7..e77238f 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -46,6 +46,7 @@ 
 #include <netinet/in.h>
 #include <linux/ethtool.h>
 #include <linux/sockios.h>
+#include <linux/version.h>
 #include <fcntl.h>
 
 /* DPDK headers don't like -pedantic. */
@@ -697,7 +698,7 @@  struct priv *
 
 /**
  * Retrieve physical link information (unlocked version using new ioctl from
- * Linux 4.5).
+ * Linux 4.9).
  *
  * @param dev
  *   Pointer to Ethernet device structure.
@@ -707,7 +708,7 @@  struct priv *
 static int
 mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete)
 {
-#ifdef ETHTOOL_GLINKSETTINGS
+#if KERNEL_VERSION(4, 9, 0) <= LINUX_VERSION_CODE
 	struct priv *priv = mlx5_get_priv(dev);
 	struct ethtool_link_settings edata = {
 		.cmd = ETHTOOL_GLINKSETTINGS,