net/mlx5: fix counter elements copies for HWS

The __hws_cnt_r2rcpy() function copies elements from one zero-copy ring
to another zero-copy ring in place.
This routine needs to consider the situation that the address was given
by source and destination could be both wrapped.

It uses 4 different "n" local variables to manage it:
 - n:  Number of elements to copy in total.
 - n1: Number of elements to copy from ptr1, it is the minimal value
       from source/dest n1 field.
 - n2: Number of elements to copy from src->ptr1 to dst->ptr2 or from
       src->ptr2 to dst->ptr1, this variable is 0 when both source and
       dest n1 field are equal.
 - n3: Number of elements to copy from src->ptr2 to dst->ptr2.

The function copies the first n1 elements. If n2 isn't zero it copies
more elements and check whether n3 is zero.
This logic is wrong since n3 may be bigger than zero even when n2 is
zero. This scenario is commonly happening in counters when the internal
mlx5 service thread copies elements from the reset ring into the reuse
ring.

This patch changes the function to copy n3 regardless of n2 value.

Fixes: 4d368e1da3 ("net/mlx5: support flow counter action for HWS")

Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
Acked-by: Xiaoyu Min <jackmin@nvidia.com>
This commit is contained in:
Michael Baum 2022-10-31 18:08:22 +02:00 committed by Raslan Darawsheh
parent 5b21f92556
commit 2fd25a6d13

View File

@ -281,11 +281,10 @@ __hws_cnt_r2rcpy(struct rte_ring_zc_data *zcdd, struct rte_ring_zc_data *zcds,
d3 = zcdd->ptr2;
}
memcpy(d1, s1, n1 * sizeof(cnt_id_t));
if (n2 != 0) {
if (n2 != 0)
memcpy(d2, s2, n2 * sizeof(cnt_id_t));
if (n3 != 0)
memcpy(d3, s3, n3 * sizeof(cnt_id_t));
}
if (n3 != 0)
memcpy(d3, s3, n3 * sizeof(cnt_id_t));
}
static __rte_always_inline int