[dpdk-dev] mlx5: fix get link settings call for speed and duplex values
Checks
Commit Message
From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
mlx5 pmd does not correctly retrieve link speed and duplex values
in linksetting struct through ETHTOOL_GLINKSETTINGS ioctl call.
Due to which pktgen application could not correctly calculate tx/rx
rate and hence, very few packets (of count 32) only sent all the time.
Link settings can be derived through ETHTOOL_GLINKSETTINGS ioctl
only after updating ethtool_link_settings struct with appropriate
link mode bitmask words returned by its kernel side implementation.
With this patch, pktgen app is able to tx/rx packets on mlx5 ports.
Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
---
drivers/net/mlx5/mlx5_ethdev.c | 27 +++++++++++++++++++--------
1 file changed, 19 insertions(+), 8 deletions(-)
Comments
Hi Gowrishankar,
Sorry, it took me a little time to test this patch, nice catch.
Small format points, the title should be net/mlx5 and there is a
complain with checkpatch see below.
On Tue, Jul 18, 2017 at 11:58:34AM +0530, Gowrishankar wrote:
> From: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
>
> mlx5 pmd does not correctly retrieve link speed and duplex values
> in linksetting struct through ETHTOOL_GLINKSETTINGS ioctl call.
I would suggest to make it a little shorter by adding the following fact:
This returns an inconsistent link status.
It does not only impact traffic generator but anything relying on the
link status.
> Due to which pktgen application could not correctly calculate tx/rx
> rate and hence, very few packets (of count 32) only sent all the time.
>
> Link settings can be derived through ETHTOOL_GLINKSETTINGS ioctl
> only after updating ethtool_link_settings struct with appropriate
> link mode bitmask words returned by its kernel side implementation.
> With this patch, pktgen app is able to tx/rx packets on mlx5 ports.
As it is fixing an issue it should have the fixes tag line, in this case
add the following one:
Fixes: 188408719888 ("net/mlx5: fix support for newer link speeds")
Cc: stable@dpdk.org
> Signed-off-by: Gowrishankar Muthukrishnan <gowrishankar.m@linux.vnet.ibm.com>
> ---
> drivers/net/mlx5/mlx5_ethdev.c | 27 +++++++++++++++++++--------
> 1 file changed, 19 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c
> index b70b7b9..003cef3 100644
> --- a/drivers/net/mlx5/mlx5_ethdev.c
> +++ b/drivers/net/mlx5/mlx5_ethdev.c
> @@ -119,6 +119,7 @@ struct ethtool_link_settings {
> #define ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT 38
> #define ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT 39
> #endif
> +#define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX)
>
> /**
> * Return private structure associated with an Ethernet device.
> @@ -807,9 +808,11 @@ struct priv *
> mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete)
> {
> struct priv *priv = mlx5_get_priv(dev);
> - struct ethtool_link_settings edata = {
> - .cmd = ETHTOOL_GLINKSETTINGS,
> - };
> + struct {
> + struct ethtool_link_settings edata;
> + __u32 link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
Checkpatch complains about the line size here.
Thanks,
@@ -119,6 +119,7 @@ struct ethtool_link_settings {
#define ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT 38
#define ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT 39
#endif
+#define ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32 (SCHAR_MAX)
/**
* Return private structure associated with an Ethernet device.
@@ -807,9 +808,11 @@ struct priv *
mlx5_link_update_unlocked_gs(struct rte_eth_dev *dev, int wait_to_complete)
{
struct priv *priv = mlx5_get_priv(dev);
- struct ethtool_link_settings edata = {
- .cmd = ETHTOOL_GLINKSETTINGS,
- };
+ struct {
+ struct ethtool_link_settings edata;
+ __u32 link_mode_data[3 * ETHTOOL_LINK_MODE_MASK_MAX_KERNEL_NU32];
+ } ecmd;
+
struct ifreq ifr;
struct rte_eth_link dev_link;
uint64_t sc;
@@ -822,15 +825,23 @@ struct priv *
memset(&dev_link, 0, sizeof(dev_link));
dev_link.link_status = ((ifr.ifr_flags & IFF_UP) &&
(ifr.ifr_flags & IFF_RUNNING));
- ifr.ifr_data = (void *)&edata;
+ memset(&ecmd, 0, sizeof(ecmd));
+ ecmd.edata.cmd = ETHTOOL_GLINKSETTINGS;
+ ifr.ifr_data = (void *)&ecmd;
if (priv_ifreq(priv, SIOCETHTOOL, &ifr)) {
DEBUG("ioctl(SIOCETHTOOL, ETHTOOL_GLINKSETTINGS) failed: %s",
strerror(errno));
return -1;
}
- dev_link.link_speed = edata.speed;
- sc = edata.link_mode_masks[0] |
- ((uint64_t)edata.link_mode_masks[1] << 32);
+ ecmd.edata.link_mode_masks_nwords = -ecmd.edata.link_mode_masks_nwords;
+ if (priv_ifreq(priv, SIOCETHTOOL, &ifr)) {
+ DEBUG("ioctl(SIOCETHTOOL, ETHTOOL_GLINKSETTINGS) failed: %s",
+ strerror(errno));
+ return -1;
+ }
+ dev_link.link_speed = ecmd.edata.speed;
+ sc = ecmd.edata.link_mode_masks[0] |
+ ((uint64_t)ecmd.edata.link_mode_masks[1] << 32);
priv->link_speed_capa = 0;
if (sc & ETHTOOL_LINK_MODE_Autoneg_BIT)
priv->link_speed_capa |= ETH_LINK_SPEED_AUTONEG;
@@ -866,7 +877,7 @@ struct priv *
ETHTOOL_LINK_MODE_100000baseCR4_Full_BIT |
ETHTOOL_LINK_MODE_100000baseLR4_ER4_Full_BIT))
priv->link_speed_capa |= ETH_LINK_SPEED_100G;
- dev_link.link_duplex = ((edata.duplex == DUPLEX_HALF) ?
+ dev_link.link_duplex = ((ecmd.edata.duplex == DUPLEX_HALF) ?
ETH_LINK_HALF_DUPLEX : ETH_LINK_FULL_DUPLEX);
dev_link.link_autoneg = !(dev->data->dev_conf.link_speeds &
ETH_LINK_SPEED_FIXED);