From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 97FA1A0567 for ; Wed, 10 Mar 2021 10:19:56 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 84D5640687; Wed, 10 Mar 2021 10:19:56 +0100 (CET) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 716FE40687 for ; Wed, 10 Mar 2021 10:19:54 +0100 (CET) IronPort-SDR: hTb4+lJhCD9Krw31Fd8JCJTuUp44tEuleGlENmKmP6kyBvir2K1CWIdRDwqCf2oBKwUMZSRDlA DFajx4NvCWNw== X-IronPort-AV: E=McAfee;i="6000,8403,9917"; a="252442251" X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="252442251" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 01:19:53 -0800 IronPort-SDR: 1OAkFdigwpw32LiE8uQdIhSAxYtIhw74NfSkjVkohhi59v4iP3jnLMl2Idy8gWTXLhxWQEM52N rFTV0oNRdbUg== X-IronPort-AV: E=Sophos;i="5.81,237,1610438400"; d="scan'208";a="603008431" Received: from unknown (HELO intel-npg-odc-srv02.cd.intel.com) ([10.240.178.186]) by fmsmga005-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 10 Mar 2021 01:19:51 -0800 From: Murphy Yang To: stable@dpdk.org Cc: Murphy Yang , Jacob Keller , Paul M Stillwell Jr , Qi Zhang Date: Wed, 10 Mar 2021 09:13:09 +0000 Message-Id: <20210310091309.86205-1-murphyx.yang@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-stable] [PATCH 19.11] net/ice/base: add macro specifying max NVM offset X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" [ upstream commit 9f041a72140c480fed178a743b7d327cba1031e8 ] The ice_aq_read_nvm function uses a somewhat weird construction for verifying that the incoming offset is valid. Replace this construction with a simple greater-than expression, and define the maximum value (24bits) in the ice_adminq_cmd.h By providing a macro, the check becomes more clear. Additionally the maximum offset can be used in other locations. Signed-off-by: Jacob Keller Signed-off-by: Paul M Stillwell Jr Signed-off-by: Qi Zhang --- drivers/net/ice/base/ice_adminq_cmd.h | 3 ++- drivers/net/ice/base/ice_nvm.c | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ice/base/ice_adminq_cmd.h b/drivers/net/ice/base/ice_adminq_cmd.h index a99670d51e..c4128aafae 100644 --- a/drivers/net/ice/base/ice_adminq_cmd.h +++ b/drivers/net/ice/base/ice_adminq_cmd.h @@ -1672,8 +1672,9 @@ struct ice_aqc_sff_eeprom { * NVM Shadow RAM Dump commands (direct 0x0707) */ struct ice_aqc_nvm { +#define ICE_AQC_NVM_MAX_OFFSET 0xFFFFFF __le16 offset_low; - u8 offset_high; + u8 offset_high; /* For Write Activate offset_high is used as flags2 */ u8 cmd_flags; #define ICE_AQC_NVM_LAST_CMD BIT(0) #define ICE_AQC_NVM_PCIR_REQ BIT(0) /* Used by NVM Write reply */ diff --git a/drivers/net/ice/base/ice_nvm.c b/drivers/net/ice/base/ice_nvm.c index 64fb92b8a5..3eb097f955 100644 --- a/drivers/net/ice/base/ice_nvm.c +++ b/drivers/net/ice/base/ice_nvm.c @@ -29,8 +29,7 @@ ice_aq_read_nvm(struct ice_hw *hw, u16 module_typeid, u32 offset, u16 length, cmd = &desc.params.nvm; - /* In offset the highest byte must be zeroed. */ - if (offset & 0xFF000000) + if (offset > ICE_AQC_NVM_MAX_OFFSET) return ICE_ERR_PARAM; ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_nvm_read); -- 2.17.1