* [dpdk-stable] [PATCH] net/mlx5: fix use of bit numbers instead of masks
@ 2017-11-10 14:18 Edward Makarov
2017-11-10 14:49 ` Nelio Laranjeiro
0 siblings, 1 reply; 3+ messages in thread
From: Edward Makarov @ 2017-11-10 14:18 UTC (permalink / raw)
To: Nelio Laranjeiro
Cc: Adrien Mazarguil, Roman Khimov, dev, Edward Makarov, stable
The constant ETHTOOL_LINK_MODE_1000baseT_Full_BIT and the others like
that in mlx5_link_update_unlocked_gs must be bit masks but unfortunately
they are bit numbers. This commit fixes the issue.
Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
Cc: nelio.laranjeiro@6wind.com
Cc: stable@dpdk.org
Signed-off-by: Edward Makarov <makarov@kraftway.ru>
---
drivers/net/mlx5/mlx5_ethdev.c | 50 +++++++++++++++++++++---------------------
drivers/net/mlx5/mlx5_utils.h | 4 ++++
2 files changed, 29 insertions(+), 25 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
index c31ea4b62..a3cef6891 100644
--- a/drivers/net/mlx5/mlx5_ethdev.c
+++ b/drivers/net/mlx5/mlx5_ethdev.c
@@ -865,39 +865,39 @@ mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete)
sc = ecmd->link_mode_masks[0] |
((uint64_t)ecmd->link_mode_masks[1] << 32);
priv->link_speed_capa = 0;
- if (sc & ETHTOOL_LINK_MODE_Autoneg_BIT)
+ if (sc & MLX5_BITSHIFT(ETHTOOL_LINK_MODE_Autoneg_BIT))
priv->link_speed_capa |= ETH_LINK_SPEED_AUTONEG;
- if (sc & (ETHTOOL_LINK_MODE_1000baseT_Full_BIT |
- ETHTOOL_LINK_MODE_1000baseKX_Full_BIT))
+ if (sc & (MLX5_BITSHIFT(ETHTOOL_LINK_MODE_1000baseT_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_1000baseKX_Full_BIT)))
priv->link_speed_capa |= ETH_LINK_SPEED_1G;
- if (sc & (ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT |
- ETHTOOL_LINK_MODE_10000baseKR_Full_BIT |
- ETHTOOL_LINK_MODE_10000baseR_FEC_BIT))
+ if (sc & (MLX5_BITSHIFT(ETHTOOL_LINK_MODE_10000baseKX4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_10000baseKR_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_10000baseR_FEC_BIT)))
priv->link_speed_capa |= ETH_LINK_SPEED_10G;
- if (sc & (ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT |
- ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT))
+ if (sc & (MLX5_BITSHIFT(ETHTOOL_LINK_MODE_20000baseMLD2_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_20000baseKR2_Full_BIT)))
priv->link_speed_capa |= ETH_LINK_SPEED_20G;
- if (sc & (ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT |
- ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT |
- ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT |
- ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT))
+ if (sc & (MLX5_BITSHIFT(ETHTOOL_LINK_MODE_40000baseKR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_40000baseCR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_40000baseSR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_40000baseLR4_Full_BIT)))
priv->link_speed_capa |= ETH_LINK_SPEED_40G;
- if (sc & (ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT |
- ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT |
- ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT |
- ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT))
+ if (sc & (MLX5_BITSHIFT(ETHTOOL_LINK_MODE_56000baseKR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_56000baseCR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_56000baseSR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_56000baseLR4_Full_BIT)))
priv->link_speed_capa |= ETH_LINK_SPEED_56G;
- if (sc & (ETHTOOL_LINK_MODE_25000baseCR_Full_BIT |
- ETHTOOL_LINK_MODE_25000baseKR_Full_BIT |
- ETHTOOL_LINK_MODE_25000baseSR_Full_BIT))
+ if (sc & (MLX5_BITSHIFT(ETHTOOL_LINK_MODE_25000baseCR_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_25000baseKR_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_25000baseSR_Full_BIT)))
priv->link_speed_capa |= ETH_LINK_SPEED_25G;
- if (sc & (ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT |
- ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT))
+ if (sc & (MLX5_BITSHIFT(ETHTOOL_LINK_MODE_50000baseCR2_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_50000baseKR2_Full_BIT)))
priv->link_speed_capa |= ETH_LINK_SPEED_50G;
- if (sc & (ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT |
- ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT |
- ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT |
- ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT))
+ if (sc & (MLX5_BITSHIFT(ETHTOOL_LINK_MODE_100000baseKR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_100000baseSR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT) |
+ MLX5_BITSHIFT(ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT)))
priv->link_speed_capa |= ETH_LINK_SPEED_100G;
dev_link.link_duplex = ((ecmd->duplex == DUPLEX_HALF) ?
ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
diff --git a/drivers/net/mlx5/mlx5_utils.h b/drivers/net/mlx5/mlx5_utils.h
index 218ae831f..2fbd10b18 100644
--- a/drivers/net/mlx5/mlx5_utils.h
+++ b/drivers/net/mlx5/mlx5_utils.h
@@ -35,6 +35,7 @@
#define RTE_PMD_MLX5_UTILS_H_
#include <stddef.h>
+#include <stdint.h>
#include <stdio.h>
#include <limits.h>
#include <assert.h>
@@ -61,6 +62,9 @@
!!(((bf)[((b) / (sizeof((bf)[0]) * CHAR_BIT))] & \
((size_t)1 << ((b) % (sizeof((bf)[0]) * CHAR_BIT))))))
+/* Convert a bit number to the corresponding 64-bit mask */
+#define MLX5_BITSHIFT(v) (UINT64_C(1) << (v))
+
/* Save and restore errno around argument evaluation. */
#define ERRNO_SAFE(x) ((errno = (int []){ errno, ((x), 0) }[0]))
--
2.11.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-stable] [PATCH] net/mlx5: fix use of bit numbers instead of masks
2017-11-10 14:18 [dpdk-stable] [PATCH] net/mlx5: fix use of bit numbers instead of masks Edward Makarov
@ 2017-11-10 14:49 ` Nelio Laranjeiro
2017-11-11 11:23 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Nelio Laranjeiro @ 2017-11-10 14:49 UTC (permalink / raw)
To: Edward Makarov; +Cc: Adrien Mazarguil, Roman Khimov, dev, stable
On Fri, Nov 10, 2017 at 02:18:04PM +0000, Edward Makarov wrote:
> The constant ETHTOOL_LINK_MODE_1000baseT_Full_BIT and the others like
> that in mlx5_link_update_unlocked_gs must be bit masks but unfortunately
> they are bit numbers. This commit fixes the issue.
>
> Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
> Cc: nelio.laranjeiro@6wind.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Edward Makarov <makarov@kraftway.ru>
Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Indeed, nice catch.
Thanks,
--
Nélio Laranjeiro
6WIND
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-stable] [PATCH] net/mlx5: fix use of bit numbers instead of masks
2017-11-10 14:49 ` Nelio Laranjeiro
@ 2017-11-11 11:23 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2017-11-11 11:23 UTC (permalink / raw)
To: Edward Makarov
Cc: stable, Nelio Laranjeiro, Adrien Mazarguil, Roman Khimov, dev
10/11/2017 15:49, Nelio Laranjeiro:
> On Fri, Nov 10, 2017 at 02:18:04PM +0000, Edward Makarov wrote:
> > The constant ETHTOOL_LINK_MODE_1000baseT_Full_BIT and the others like
> > that in mlx5_link_update_unlocked_gs must be bit masks but unfortunately
> > they are bit numbers. This commit fixes the issue.
> >
> > Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
> > Cc: nelio.laranjeiro@6wind.com
> > Cc: stable@dpdk.org
> >
> > Signed-off-by: Edward Makarov <makarov@kraftway.ru>
>
> Acked-by: Nelio Laranjeiro <nelio.laranjeiro@6wind.com>
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-11-11 13:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-10 14:18 [dpdk-stable] [PATCH] net/mlx5: fix use of bit numbers instead of masks Edward Makarov
2017-11-10 14:49 ` Nelio Laranjeiro
2017-11-11 11:23 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).