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 C8FD545500; Wed, 26 Jun 2024 13:59:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 997BB433BC; Wed, 26 Jun 2024 13:55:47 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id EEC3042E95 for ; Wed, 26 Jun 2024 13:44:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719402248; x=1750938248; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=IrhL8Nc4IKnglEBcV8gw56f138PgAJmhZLsGktTTkIE=; b=cJZHCAs4Ye5RWVfiN2zNNsjEOiPtHqq7psspzTCsnpGhr73cAVz3TeeZ jh9FdiaSFd6CihJDuVhOPY36VMr72aWKYVZcfWkUHeaGHpoLpdeQmgnNB UoDMm7ZObHhKPsxLfslUaNgY+WG0AiSfk1s/BnuMyRf3n72h+2O4n0vNJ iWHbq/ktav0ZU9eWiKgfs9+I6LykKtfcrg2mM2UKBSxUDJcDzMcOdy8SM DH3s4keFFY3efhBZRCak1o31g/NDhChWrpXHOCLhImt28rRz4FNlVsnEz MLLY8R5cFTtiOqTj88/gH/Pqn/Tw76tpylGhQYo7v0TjUt+AfFpL6pARi A==; X-CSE-ConnectionGUID: S1x1XF5QS/i9wUfDyHVF/w== X-CSE-MsgGUID: WeRCZ2pnQXqub7FWXrRYVw== X-IronPort-AV: E=McAfee;i="6700,10204,11114"; a="38979404" X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="38979404" Received: from orviesa010.jf.intel.com ([10.64.159.150]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jun 2024 04:44:07 -0700 X-CSE-ConnectionGUID: p/hFunVWQpqs4KGl+BcBEg== X-CSE-MsgGUID: NDNDu+igT+mGSeVhInENLw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,266,1712646000"; d="scan'208";a="43873855" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa010.jf.intel.com with ESMTP; 26 Jun 2024 04:44:06 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Jaroslaw Ilgiewicz , ian.stokes@intel.com, bruce.richardson@intel.com Subject: [PATCH v4 040/103] net/ice/base: read OROM in a loop Date: Wed, 26 Jun 2024 12:41:28 +0100 Message-ID: <6b51a29f93b92eb99b11438b3130eeec8dd68a3d.1719401848.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: 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: Jaroslaw Ilgiewicz 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