[PATCH] net/mlx5: fix the counters map in bonding mode

Raslan Darawsheh rasland at nvidia.com
Thu Feb 29 14:36:27 CET 2024


Hi,

> -----Original Message-----
> From: Bing Zhao <bingz at nvidia.com>
> Sent: Thursday, February 29, 2024 11:35 AM
> To: Slava Ovsiienko <viacheslavo at nvidia.com>; dev at dpdk.org; Raslan
> Darawsheh <rasland at nvidia.com>
> Cc: Ori Kam <orika at nvidia.com>; Dariusz Sosnowski
> <dsosnowski at nvidia.com>; Suanming Mou <suanmingm at nvidia.com>;
> Matan Azrad <matan at nvidia.com>; Xueming Li <xuemingl at nvidia.com>;
> stable at dpdk.org
> Subject: [PATCH] net/mlx5: fix the counters map in bonding mode
> 
> In the HW-LAG mode, there is only one mlx5 IB device with 2 ETH interfaces. In
> theory, the settings on both ports should be the same.
> But in the real life, some inconsistent settings may be done by the user and the
> PMD is not aware of this.
> 
> In the previous implementation, the xstats map was generated from the
> information fetched on the 1st port of a bonding interface. If the 2nd port had
> a different settings, the number and the order of the counters may differ from
> that of the 1st one. The ioctl() call may corrupt the user buffers (copy_to_user)
> and cause a crash.
> 
> The commit will change the map between the driver counters to the PMD user
> counters.
>   1. Switch the inner and outer loop to speed up the initialization
>      time AMAP - since there will be >300 counters returned from the
>      driver.
>   2. Generate an unique map for both ports in LAG mode.
>     a. Scan the 1st port and find the supported counters' strings,
>        then add to the map.
>     b. In bonding, scan the 2nd port and find the strings. If one is
>        already in the map, use the index. Or append to the next free
>        slot.
>     c. Append the device counters that needs to be fetched via sysfs
>        or Devx command. This kind of counter(s) is unique per IB
>        device.
> 
> After querying the statistics from the driver, the value will be read from the
> proper offset in the "struct ethtool_stats" and then added into the output
> array based on the map information. In bonding mode, the statistics from
> both ports will be accumulated if the counters are valid on both ports.
> 
> Compared to the system call or Devx command, the overhead introduced by
> the extra index comparison is light and should not cause a significant
> degradation.
> 
> The application should ensure that the port settings should not be changed
> out of the DPDK application dynamically in most cases. Or else the change
> cannot be notified and the counters map might not be valid when the number
> doesn't change but the counters set had changed. A device restart will help to
> re-initialize the map from scrath.
> 
> Fixes: 7ed15acdcd69 ("net/mlx5: improve xstats of bonding port")
> Cc: xuemingl at nvidia.com
> Cc: stable at dpdk.org
> 
> Signed-off-by: Bing Zhao <bingz at nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo at nvidia.com>
Patch applied to next-net-mlx,

Kindest regards
Raslan Darawsheh


More information about the stable mailing list