[01/11] net/bnxt: endianness conversions in cp ring macros

Message ID 20190602174247.32368-2-lance.richardson@broadcom.com (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series add support for BCM57508 controller |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail apply issues

Commit Message

Lance Richardson June 2, 2019, 5:42 p.m. UTC
  Descriptor fields in CP ring are in little-endian form, convert
to CPU endian before performing arithmetic operations.

Also use more general comparison when checking for ring
index wrap.

Fixes: f2a768d4d186 ("net/bnxt: add completion ring")
Cc: stable@dpdk.org
Signed-off-by: Lance Richardson <lance.richardson@broadcom.com>
Reviewed-by: Ajit Kumar Khaparde <ajit.khaparde@broadcom.com>
---
 drivers/net/bnxt/bnxt_cpr.h | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
  

Patch

diff --git a/drivers/net/bnxt/bnxt_cpr.h b/drivers/net/bnxt/bnxt_cpr.h
index c7af56983..ee5ca820e 100644
--- a/drivers/net/bnxt/bnxt_cpr.h
+++ b/drivers/net/bnxt/bnxt_cpr.h
@@ -10,11 +10,12 @@ 
 #include <rte_io.h>
 
 #define CMP_VALID(cmp, raw_cons, ring)					\
-	(!!(((struct cmpl_base *)(cmp))->info3_v & CMPL_BASE_V) ==	\
-	 !((raw_cons) & ((ring)->ring_size)))
+	(!!(rte_le_to_cpu_32(((struct cmpl_base *)(cmp))->info3_v) &	\
+	    CMPL_BASE_V) == !((raw_cons) & ((ring)->ring_size)))
 
 #define CMPL_VALID(cmp, v)						\
-	(!!(((struct cmpl_base *)(cmp))->info3_v & CMPL_BASE_V) == !(v))
+	(!!(rte_le_to_cpu_32(((struct cmpl_base *)(cmp))->info3_v) &	\
+	    CMPL_BASE_V) == !(v))
 
 #define CMP_TYPE(cmp)						\
 	(((struct cmpl_base *)cmp)->type & CMPL_BASE_TYPE_MASK)
@@ -31,7 +32,7 @@ 
 
 #define NEXT_CMPL(cpr, idx, v, inc)	do { \
 	(idx) += (inc); \
-	if (unlikely((idx) == (cpr)->cp_ring_struct->ring_size)) { \
+	if (unlikely((idx) >= (cpr)->cp_ring_struct->ring_size)) { \
 		(v) = !(v); \
 		(idx) = 0; \
 	} \