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 35CD34404F; Wed, 12 Jun 2024 17:16:45 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9739C42EC7; Wed, 12 Jun 2024 17:05:36 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by mails.dpdk.org (Postfix) with ESMTP id 853CD42EA5 for ; Wed, 12 Jun 2024 17:05:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1718204727; x=1749740727; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=Db5WMDsP++kcnLpcgO1hsG/YnJ477HEjArNFuOyE6K4=; b=SKsaNEP7Mqk/RivmICK8MZ/m+moz4pIqY01j84vGFVe/Joo6gAgVfXtU 5lewNan29yMXr37pBmigp89ZysJEJzPbj2v6lBnNXhOvFTeOADjpIgNed wuyOCxAiNIp+ugNI9e5KJkrA5ll0+fPCrDMSWs31OsqwZKQ5WYxDMRS2C nkhdbgzZ470KJjsP2dwIZLPqexC3RjVslTNuHKeTl0HyRllyoIuT0qA1z CJ8+Islt46lkxjsmfoGDUUTU1t5L2YgLEQDG6Fy3LmVknLilHsfWwRo18 ppfAZaf5zuT4djqBVEJECFtLJhmkZpXwZquZbus76txLWu4PMx/aWSE5G g==; X-CSE-ConnectionGUID: hafZeIPMT3WiJiIroHU8Aw== X-CSE-MsgGUID: 03PN6gmMTimccecijzqpSg== X-IronPort-AV: E=McAfee;i="6700,10204,11101"; a="32459673" X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="32459673" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jun 2024 08:05:26 -0700 X-CSE-ConnectionGUID: xNxUzvabRg219a/MAnn4lg== X-CSE-MsgGUID: 7Bz4gBMRS1uWsnrJrHuzxA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,233,1712646000"; d="scan'208";a="39925537" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 12 Jun 2024 08:05:25 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Ian Stokes , bruce.richardson@intel.com, Jaroslaw Ilgiewicz Subject: [PATCH v2 078/148] net/ice/base: read OROM in a loop Date: Wed, 12 Jun 2024 16:01:12 +0100 Message-ID: <4d908f84585c6225515f948b18aad3f7d53087c0.1718204528.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: <20240430154014.1026-1-ian.stokes@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Ian Stokes Previously NVM was once acquired and OROM was read to RAM in 4KB chunks. Changed this to a loop in which with each iteration NVM is acquired and only 4 bytes are read. Signed-off-by: Jaroslaw Ilgiewicz Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_nvm.c | 43 +++++++++++++++++----------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/drivers/net/ice/base/ice_nvm.c b/drivers/net/ice/base/ice_nvm.c index 55e624cb31..79b66fa70f 100644 --- a/drivers/net/ice/base/ice_nvm.c +++ b/drivers/net/ice/base/ice_nvm.c @@ -723,9 +723,10 @@ static int ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, struct ice_orom_civd_info *civd) { - u8 *orom_data; + struct ice_orom_civd_info civd_data_section; int status; u32 offset; + u32 tmp; /* The CIVD section is located in the Option ROM aligned to 512 bytes. * The first 4 bytes must contain the ASCII characters "$CIV". @@ -736,38 +737,37 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, * usually somewhere in the middle of the bank. We need to scan the * Option ROM bank to locate it. * - * It's significantly faster to read the entire Option ROM up front - * using the maximum page size, than to read each possible location - * with a separate firmware command. */ - orom_data = (u8 *)ice_calloc(hw, hw->flash.banks.orom_size, sizeof(u8)); - if (!orom_data) - return ICE_ERR_NO_MEMORY; - - status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, 0, - orom_data, hw->flash.banks.orom_size); - if (status) { - ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n"); - goto exit_error;; - } /* Scan the memory buffer to locate the CIVD data section */ for (offset = 0; (offset + 512) <= hw->flash.banks.orom_size; offset += 512) { - struct ice_orom_civd_info *tmp; u8 sum = 0, i; - tmp = (struct ice_orom_civd_info *)&orom_data[offset]; + status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, + offset, (u8 *)&tmp, sizeof(tmp)); + if (status) { + ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n"); + return status; + } /* Skip forward until we find a matching signature */ - if (memcmp("$CIV", tmp->signature, sizeof(tmp->signature)) != 0) + if (memcmp("$CIV", &tmp, sizeof(tmp)) != 0) continue; ice_debug(hw, ICE_DBG_NVM, "Found CIVD section at offset %u\n", offset); + status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, + offset, (u8 *)&civd_data_section, + sizeof(civd_data_section)); + if (status) { + ice_debug(hw, ICE_DBG_NVM, "Unable to read CIVD data\n"); + goto exit_error; + } + /* Verify that the simple checksum is zero */ - for (i = 0; i < sizeof(*tmp); i++) - sum += ((u8 *)tmp)[i]; + for (i = 0; i < sizeof(civd_data_section); i++) + sum += ((u8 *)&civd_data_section)[i]; if (sum) { ice_debug(hw, ICE_DBG_NVM, "Found CIVD data with invalid checksum of %u\n", @@ -776,8 +776,8 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, goto exit_error; } - *civd = *tmp; - ice_free(hw, orom_data); + *civd = civd_data_section; + return 0; } @@ -785,7 +785,6 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank, ice_debug(hw, ICE_DBG_NVM, "Unable to locate CIVD data within the Option ROM\n"); exit_error: - ice_free(hw, orom_data); return status; } -- 2.43.0