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 2B5C3454EF; Tue, 25 Jun 2024 13:24:58 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 77C4F42FFB; Tue, 25 Jun 2024 13:18:31 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id EED6642D8C for ; Tue, 25 Jun 2024 13:17:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1719314228; x=1750850228; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=fWRMad7jhL2gokTdAy27nb99xHtA7KiJG2iJiowomL4=; b=hb6VuUl94+EJ5NK3zUUcBRTE2NM/ev79zkZzojyiQqdu+cOetYVzfW1S cLKZRJ4k5fY+UbdYmInDSXlnBBeWdRNh2vOiRJ/EkSBm00ySgzhQzE6ee Gzl6/BrnfG5SZCFe7N4FIz1lRUbWhXVnfqa5MM1Y4H3i6iqqn8oPJV2ED SQku96CEADyQxbN3pP5Lqvy02XJ6HESPeVVJeBtyxwgxV1Y1/zwI16ssO qaA69rRMay/RTxBLrdiU08zmwAzfrLqkc/lpBon4pxy2TjEiN1+c+YVwk f/Bwu+TI2ix7+kaJqWcH5+TJyl98hdlR8HwxWqUyky3ziIaFENGkJwE6F w==; X-CSE-ConnectionGUID: RDQpjBARRJmcEW5xVFH9EQ== X-CSE-MsgGUID: CAns8Kg3REOM8WP+t4eV/Q== X-IronPort-AV: E=McAfee;i="6700,10204,11113"; a="16080393" X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="16080393" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Jun 2024 04:17:06 -0700 X-CSE-ConnectionGUID: 1bmYtEIwQJiGhn72Uzk/ZA== X-CSE-MsgGUID: a/bc/v/4TrCIcILJt+gRkA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.08,263,1712646000"; d="scan'208";a="43719492" Received: from unknown (HELO silpixa00401119.ir.intel.com) ([10.55.129.167]) by orviesa009.jf.intel.com with ESMTP; 25 Jun 2024 04:17:05 -0700 From: Anatoly Burakov To: dev@dpdk.org Cc: Fabio Pricoco , bruce.richardson@intel.com, ian.stokes@intel.com Subject: [PATCH v3 079/129] net/ice/base: support for firmware sanitization Date: Tue, 25 Jun 2024 12:13:24 +0100 Message-ID: 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: Fabio Pricoco Add support for AQ 0x070C. Includes ice_nvm_sanitize and a helper function ice_nvm_sanitize_operate to facilitate the operate request. Signed-off-by: Fabio Pricoco Signed-off-by: Ian Stokes --- drivers/net/ice/base/ice_adminq_cmd.h | 25 ++++++++++++ drivers/net/ice/base/ice_nvm.c | 57 +++++++++++++++++++++++++++ drivers/net/ice/base/ice_nvm.h | 2 + 3 files changed, 84 insertions(+) diff --git a/drivers/net/ice/base/ice_adminq_cmd.h b/drivers/net/ice/base/ice_adminq_cmd.h index e1de15a0a4..848bbef393 100644 --- a/drivers/net/ice/base/ice_adminq_cmd.h +++ b/drivers/net/ice/base/ice_adminq_cmd.h @@ -2052,6 +2052,29 @@ struct ice_aqc_nvm_checksum { u8 rsvd2[12]; }; +/* Used for NVM Sanitization command - 0x070C */ +struct ice_aqc_nvm_sanitization { + u8 cmd_flags; +#define ICE_AQ_NVM_SANITIZE_REQ_READ 0 +#define ICE_AQ_NVM_SANITIZE_REQ_OPERATE BIT(0) + +#define ICE_AQ_NVM_SANITIZE_READ_SUBJECT_NVM_BITS 0 +#define ICE_AQ_NVM_SANITIZE_READ_SUBJECT_NVM_STATE BIT(1) +#define ICE_AQ_NVM_SANITIZE_OPERATE_SUBJECT_CLEAR 0 + u8 values; +#define ICE_AQ_NVM_SANITIZE_NVM_BITS_HOST_CLEAN_SUPPORT BIT(0) +#define ICE_AQ_NVM_SANITIZE_NVM_BITS_BMC_CLEAN_SUPPORT BIT(2) +#define ICE_AQ_NVM_SANITIZE_NVM_STATE_HOST_CLEAN_DONE BIT(0) +#define ICE_AQ_NVM_SANITIZE_NVM_STATE_HOST_CLEAN_SUCCESS BIT(1) +#define ICE_AQ_NVM_SANITIZE_NVM_STATE_BMC_CLEAN_DONE BIT(2) +#define ICE_AQ_NVM_SANITIZE_NVM_STATE_BMC_CLEAN_SUCCESS BIT(3) +#define ICE_AQ_NVM_SANITIZE_OPERATE_HOST_CLEAN_DONE BIT(0) +#define ICE_AQ_NVM_SANITIZE_OPERATE_HOST_CLEAN_SUCCESS BIT(1) +#define ICE_AQ_NVM_SANITIZE_OPERATE_BMC_CLEAN_DONE BIT(2) +#define ICE_AQ_NVM_SANITIZE_OPERATE_BMC_CLEAN_SUCCESS BIT(3) + u8 reserved[14]; +}; + /* Get LLDP MIB (indirect 0x0A00) * Note: This is also used by the LLDP MIB Change Event (0x0A01) * as the format is the same. @@ -3113,6 +3136,7 @@ struct ice_aq_desc { struct ice_aqc_nvm_cfg nvm_cfg; struct ice_aqc_nvm_checksum nvm_checksum; struct ice_aqc_pfc_ignore pfc_ignore; + struct ice_aqc_nvm_sanitization sanitization; struct ice_aqc_set_query_pfc_mode set_query_pfc_mode; struct ice_aqc_set_dcb_params set_dcb_params; struct ice_aqc_lldp_get_mib lldp_get_mib; @@ -3365,6 +3389,7 @@ enum ice_adminq_opc { ice_aqc_opc_nvm_sr_dump = 0x0707, ice_aqc_opc_nvm_save_factory_settings = 0x0708, ice_aqc_opc_nvm_update_empr = 0x0709, + ice_aqc_opc_nvm_sanitization = 0x070C, /* LLDP commands */ ice_aqc_opc_lldp_get_mib = 0x0A00, diff --git a/drivers/net/ice/base/ice_nvm.c b/drivers/net/ice/base/ice_nvm.c index 811bbc9bbc..b0d238f7e0 100644 --- a/drivers/net/ice/base/ice_nvm.c +++ b/drivers/net/ice/base/ice_nvm.c @@ -1427,3 +1427,60 @@ ice_handle_nvm_access(struct ice_hw *hw, struct ice_nvm_access_cmd *cmd, return ICE_ERR_PARAM; } } + +/** + * ice_nvm_sanitize_operate - Clear the user data + * @hw: pointer to the HW struct + * + * Clear user data from NVM using AQ command (0x070C). + * + * Return: the exit code of the operation. + */ +s32 ice_nvm_sanitize_operate(struct ice_hw *hw) +{ + s32 status; + u8 values; + + u8 cmd_flags = ICE_AQ_NVM_SANITIZE_REQ_OPERATE | + ICE_AQ_NVM_SANITIZE_OPERATE_SUBJECT_CLEAR; + + status = ice_nvm_sanitize(hw, cmd_flags, &values); + if (status) + return status; + if ((!(values & ICE_AQ_NVM_SANITIZE_OPERATE_HOST_CLEAN_DONE) && + !(values & ICE_AQ_NVM_SANITIZE_OPERATE_BMC_CLEAN_DONE)) || + ((values & ICE_AQ_NVM_SANITIZE_OPERATE_HOST_CLEAN_DONE) && + !(values & ICE_AQ_NVM_SANITIZE_OPERATE_HOST_CLEAN_SUCCESS)) || + ((values & ICE_AQ_NVM_SANITIZE_OPERATE_BMC_CLEAN_DONE) && + !(values & ICE_AQ_NVM_SANITIZE_OPERATE_BMC_CLEAN_SUCCESS))) + return ICE_ERR_AQ_ERROR; + + return ICE_SUCCESS; +} + +/** + * ice_nvm_sanitize - Sanitize NVM + * @hw: pointer to the HW struct + * @cmd_flags: flag to the ACI command + * @values: values returned from the command + * + * Sanitize NVM using AQ command (0x070C). + * + * Return: the exit code of the operation. + */ +s32 ice_nvm_sanitize(struct ice_hw *hw, u8 cmd_flags, u8 *values) +{ + struct ice_aqc_nvm_sanitization *cmd; + struct ice_aq_desc desc; + s32 status; + + cmd = &desc.params.sanitization; + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_nvm_sanitization); + cmd->cmd_flags = cmd_flags; + + status = ice_aq_send_cmd(hw, &desc, NULL, 0, NULL); + if (values) + *values = cmd->values; + + return status; +} diff --git a/drivers/net/ice/base/ice_nvm.h b/drivers/net/ice/base/ice_nvm.h index 552e4659b7..66443c2694 100644 --- a/drivers/net/ice/base/ice_nvm.h +++ b/drivers/net/ice/base/ice_nvm.h @@ -108,4 +108,6 @@ int ice_read_sr_buf(struct ice_hw *hw, u16 offset, u16 *words, u16 *data); int ice_nvm_validate_checksum(struct ice_hw *hw); int ice_nvm_recalculate_checksum(struct ice_hw *hw); +s32 ice_nvm_sanitize_operate(struct ice_hw *hw); +s32 ice_nvm_sanitize(struct ice_hw *hw, u8 cmd_flags, u8 *values); #endif /* _ICE_NVM_H_ */ -- 2.43.0