From 0876c8b821296eaaf466a03e1f89df05f75b661a Mon Sep 17 00:00:00 2001 From: Qi Zhang Date: Tue, 18 Oct 2016 02:29:42 +0800 Subject: [PATCH] net/fm10k: fix out of order Rx read In vPMD, when we load Rx desc with _mm_loadu_si128, the volatile modifier will be cast away, allowing the compiler to reorder the load instructions. The Rx recv function's correctness is relying on these load instructions following a strict sequence, reading the descriptors in reverse order, so we add compiler barrier to prevent compiler reorder. Fixes: 7092be8437bd ("fm10k: add vector Rx") Signed-off-by: Qi Zhang Acked-by: Konstantin Ananyev --- drivers/net/fm10k/fm10k_rxtx_vec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c b/drivers/net/fm10k/fm10k_rxtx_vec.c index b724486e9d..27f3e43fff 100644 --- a/drivers/net/fm10k/fm10k_rxtx_vec.c +++ b/drivers/net/fm10k/fm10k_rxtx_vec.c @@ -478,6 +478,7 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, /* Read desc statuses backwards to avoid race condition */ /* A.1 load 4 pkts desc */ descs0[3] = _mm_loadu_si128((__m128i *)(rxdp + 3)); + rte_compiler_barrier(); /* B.2 copy 2 mbuf point into rx_pkts */ _mm_storeu_si128((__m128i *)&rx_pkts[pos], mbp1); @@ -486,8 +487,10 @@ fm10k_recv_raw_pkts_vec(void *rx_queue, struct rte_mbuf **rx_pkts, mbp2 = _mm_loadu_si128((__m128i *)&mbufp[pos+2]); descs0[2] = _mm_loadu_si128((__m128i *)(rxdp + 2)); + rte_compiler_barrier(); /* B.1 load 2 mbuf point */ descs0[1] = _mm_loadu_si128((__m128i *)(rxdp + 1)); + rte_compiler_barrier(); descs0[0] = _mm_loadu_si128((__m128i *)(rxdp)); /* B.2 copy 2 mbuf point into rx_pkts */ -- 2.20.1