net/intel/common: avoid field pointer arithmetic
PATCH 1/1 net/intel/common: avoid field pointer arithmetic
The Rx rearm failure path assigns fake mbufs through rxp, but rxp is the address of the mbuf field in a single software ring entry.
Use the software ring array for indexed access so pointer arithmetic is done on struct ci_rx_entry instead of on the address of a field.
--- drivers/net/intel/common/rx_vec_x86.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/intel/common/rx_vec_x86.h +1 -1
@@ -33,7 +33,7 @@ _ci_rxq_rearm_get_bufs(struct ci_rx_queue *rxq)const __m128i zero =_mm_setzero_si128 ();for (i =0 ; i <CI_VPMD_DESCS_PER_LOOP ; i++) { - rxp[i] = &rxq->fake_mbuf; + rxq->sw_ring[rxq->rxrearm_start + i].mbuf = &rxq->fake_mbuf; _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i]), zero); } }
Signature · 1 line
2.43.0
Quoted 20 lines · Artem Novikov
The Rx rearm failure path assigns fake mbufs through rxp, but rxp is the address of the mbuf field in a single software ring entry.
Use the software ring array for indexed access so pointer arithmetic is done on struct
ci_rx_entryinstead of on the address of a field.Fixes 773cbaf2ad38 ("net/intel: avoid allocating from mempool directly")Signed-off-by Artem Novikov <[email protected]>--- drivers/net/intel/common/rx_vec_x86.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/intel/common/rx_vec_x86.h +0
-0
drivers/net/intel/common/rx_vec_x86.h _ci_rxq_rearm_get_bufs(struct ci_rx_queue *rxq) · line 38
Quoted 7 lines
drivers/net/intel/common/rx_vec_x86.h +1
-1@@ -33,7 +33,7 @@ _ci_rxq_rearm_get_bufs(struct ci_rx_queue *rxq)const __m128i zero =_mm_setzero_si128 ();for (i =0 ; i <CI_VPMD_DESCS_PER_LOOP ; i++) { - rxp[i] = &rxq->fake_mbuf; + rxq->sw_ring[rxq->rxrearm_start + i].mbuf = &rxq->fake_mbuf; _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i]), zero); }
The existing code here is correct, because the SW ring elements are just 1 mbuf in themselves. While the change you propose does make things "more correct" from a theoretical viewpoint, I would prefer to keep the existing code because it means that the assignments to both HW and SW ring are done similarly, by indexing into rxdp[i] and rxp[i].
/Bruce
Quoted 4 lines
drivers/net/intel/common/rx_vec_x86.h +0
-0}Signature · 1 line
2.43.0
Quoted 35 lines · Bruce Richardson
Quoted 20 lines · Artem Novikov
The Rx rearm failure path assigns fake mbufs through rxp, but rxp is the address of the mbuf field in a single software ring entry.
Use the software ring array for indexed access so pointer arithmetic is done on struct
ci_rx_entryinstead of on the address of a field.Fixes 773cbaf2ad38 ("net/intel: avoid allocating from mempool directly")Signed-off-by Artem Novikov <[email protected]>--- drivers/net/intel/common/rx_vec_x86.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/intel/common/rx_vec_x86.h +0
-0drivers/net/intel/common/rx_vec_x86.h _ci_rxq_rearm_get_bufs(struct ci_rx_queue *rxq) · line 38
Quoted 7 lines
drivers/net/intel/common/rx_vec_x86.h +1
-1@@ -33,7 +33,7 @@ _ci_rxq_rearm_get_bufs(struct ci_rx_queue *rxq)const __m128i zero =_mm_setzero_si128 ();for (i =0 ; i <CI_VPMD_DESCS_PER_LOOP ; i++) { - rxp[i] = &rxq->fake_mbuf; + rxq->sw_ring[rxq->rxrearm_start + i].mbuf = &rxq->fake_mbuf; _mm_store_si128(RTE_CAST_PTR(__m128i *, &rxdp[i]), zero); }The existing code here is correct, because the SW ring elements are just 1 mbuf in themselves. While the change you propose does make things "more correct" from a theoretical viewpoint, I would prefer to keep the existing code because it means that the assignments to both HW and SW ring are done similarly, by indexing into rxdp[i] and rxp[i].
Quoted 2 lines
/Bruce
Marking as rejected in patchwork