From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 47667A0096 for ; Sun, 2 Jun 2019 19:43:17 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2CB941B949; Sun, 2 Jun 2019 19:43:09 +0200 (CEST) Received: from mail-yb1-f196.google.com (mail-yb1-f196.google.com [209.85.219.196]) by dpdk.org (Postfix) with ESMTP id 958F74C9D for ; Sun, 2 Jun 2019 19:43:05 +0200 (CEST) Received: by mail-yb1-f196.google.com with SMTP id 129so2773456ybk.6 for ; Sun, 02 Jun 2019 10:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7iedGxHwAjs15hNSxvU4hgGw0fzC9MO9ITjTY2X6/G4=; b=NRob92WF3OZx20Yj0xODJuSpYa92tj/xvV6dH839IccAe99anVFSeAi3TUBZ4I/arz lakzjLWxkxE8JPf1IjWqTqNw00RI+TM/uZYH90nvVrP7vqO/R7AZKZcSTGrfWQbtzmnU A3d36ePBxLa7QBbOEnMJV7KjThOJis3smmRV0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7iedGxHwAjs15hNSxvU4hgGw0fzC9MO9ITjTY2X6/G4=; b=OETI0OZ4o95rFecCjhSRU4WixF73Q9l6+zAKePMfH2crFTHNG22ee8laSeMyAGYQqv pTMPJ3P5RyxO0bMOZ6rIZW2WyEg9o+jcZEDJjo9AgPClHNdbXmTNPc4cANQwN1Z7jJ13 tdg8y8bzBA4QmWj3pEBL2fKyIp5EFqgvmgKIe/DCtMvbMaswC6QtTeAfs2wwH/hdpUlK IyUeI5J4S7CJcfKuPRwHDONoDxDbVQmi4cttE8yFSrGOZJogN+MhSwlHQJ2r+PFB+0uE SXBGtzrqsBMawBpEp1Qks/tosLf66rixNZnYXOJPglog8EN1PXskijUsEqXS6wAbtmZY xQMQ== X-Gm-Message-State: APjAAAV21vX3qhAxxbFg2uwJIRVMWnAwXdq8+yJuA3oQGAnfzGiFm8eZ d6CSUJUe8rEK93G/OFImnZm52T8GPtZ3tb5MlxAvGm0JlaWlHJo4I+Asu0fBYpcZCIHN2JXb3GR AHQfbpMxO9alunkQ7DNlcmoZ/8J2stdhzYdueL/523s3QLnXX8Wr9ps9uccD2r6Ma X-Google-Smtp-Source: APXvYqwwkeghx4s47FBEBGhNqV16k4IiRN327DDFjy2YRQHTxs1ETLKyVGhneM0ehUreHVuxw9JQpQ== X-Received: by 2002:a25:7:: with SMTP id 7mr10975326yba.83.1559497384886; Sun, 02 Jun 2019 10:43:04 -0700 (PDT) Received: from lrichardson-VirtualBox.attlocal.net (69-218-223-106.lightspeed.rlghnc.sbcglobal.net. [69.218.223.106]) by smtp.gmail.com with ESMTPSA id n78sm1000819ywd.2.2019.06.02.10.43.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 02 Jun 2019 10:43:04 -0700 (PDT) From: Lance Richardson To: dev@dpdk.org Cc: ajit.khaparde@broadcom.com, ferruh.yigit@intel.com, Lance Richardson , stable@dpdk.org Date: Sun, 2 Jun 2019 13:42:36 -0400 Message-Id: <20190602174247.32368-2-lance.richardson@broadcom.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190602174247.32368-1-lance.richardson@broadcom.com> References: <20190602174247.32368-1-lance.richardson@broadcom.com> Subject: [dpdk-dev] [PATCH 01/11] net/bnxt: endianness conversions in cp ring macros X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 Reviewed-by: Ajit Kumar Khaparde --- drivers/net/bnxt/bnxt_cpr.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) 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 #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; \ } \ -- 2.17.1