From patchwork Thu May 18 15:16:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Qiming Yang X-Patchwork-Id: 127014 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 338E642AF1; Thu, 18 May 2023 17:36:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DACDB42F90; Thu, 18 May 2023 17:34:51 +0200 (CEST) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id 7B83B42DC2 for ; Thu, 18 May 2023 17:34:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1684424090; x=1715960090; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iIgAZuLlRMwa4I6vSSilLsuCJaCI3G3nggckGFIY5OQ=; b=EMw7ZQg0Wf+xB4GdrYcWNbtqzpBGcdSuaAVHQcrEVIvE5JaAUkWwohxe oYWIlcsWejFM+ouzPxPEn43j+xhen2qIdj8ZBnZTK7p5MYagMXsg32Qk2 SNSJBnB6rCJzCwp9xahaAq9AoPEVKVv966CFncXSjm5HsdpyV9d/OXv3X baN/uggl+1h/jqJAWmY/EaTO25XOQ/hrc8It0Nz6+f0x4bWq+XH9cM+F3 vJHFUuj687R7Aff3czZ1DTngx/9sVjSgp+4tI1xs5FGTBQal7FN7gm3sO ApnFg8T6Vunypp/Mk0ULpAY6Lfla7GZRqnp5iicVaIj/X/zavmmOIEStm A==; X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="341527827" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="341527827" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 May 2023 08:34:50 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10714"; a="705235281" X-IronPort-AV: E=Sophos;i="5.99,285,1677571200"; d="scan'208";a="705235281" Received: from dpdk-qiming3.sh.intel.com ([10.67.111.4]) by fmsmga007.fm.intel.com with ESMTP; 18 May 2023 08:34:48 -0700 From: Qiming Yang To: dev@dpdk.org Cc: qi.z.zhang@intel.com, Qiming Yang , Marcin Domagala , Eric Joyner Subject: [PATCH v2 20/20] net/ice/base: add new AQ ro read HW sensors Date: Thu, 18 May 2023 15:16:38 +0000 Message-Id: <20230518151638.1207021-21-qiming.yang@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518151638.1207021-1-qiming.yang@intel.com> References: <20230427062001.478032-1-qiming.yang@intel.com> <20230518151638.1207021-1-qiming.yang@intel.com> MIME-Version: 1.0 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 Adds new helper function to read from HW sensors via a new AQ command "Get Sensor Reading (0x0632)". Currently, this AQ command only supports reading the temperature from E810 devices with a supported firmware, but in the future it could be extended to read other sensors. Signed-off-by: Marcin Domagala Signed-off-by: Eric Joyner Signed-off-by: Qiming Yang --- drivers/net/ice/base/ice_adminq_cmd.h | 29 +++++++++++++++++++++ drivers/net/ice/base/ice_common.c | 36 +++++++++++++++++++++++++++ drivers/net/ice/base/ice_common.h | 4 +++ 3 files changed, 69 insertions(+) diff --git a/drivers/net/ice/base/ice_adminq_cmd.h b/drivers/net/ice/base/ice_adminq_cmd.h index 8df6ca41e9..844e90bbce 100644 --- a/drivers/net/ice/base/ice_adminq_cmd.h +++ b/drivers/net/ice/base/ice_adminq_cmd.h @@ -1666,6 +1666,32 @@ struct ice_aqc_set_mac_lb { u8 reserved[15]; }; +/* Get sensor reading (direct 0x0632) */ +struct ice_aqc_get_sensor_reading { + u8 sensor; +#define ICE_AQC_INT_TEMP_SENSOR 0x0 + u8 format; +#define ICE_AQC_INT_TEMP_FORMAT 0x0 + u8 reserved[6]; + __le32 addr_high; + __le32 addr_low; +}; + +/* Get sensor reading response (direct 0x0632) */ +struct ice_aqc_get_sensor_reading_resp { + union { + u8 raw[8]; + /* Output data for sensor 0x00, format 0x00 */ + struct { + s8 temp; + u8 temp_warning_threshold; + u8 temp_critical_threshold; + u8 temp_fatal_threshold; + u8 reserved[4]; + } s0f0; + } data; +}; + struct ice_aqc_link_topo_params { u8 lport_num; u8 lport_num_valid; @@ -3004,6 +3030,8 @@ struct ice_aq_desc { struct ice_aqc_get_phy_caps get_phy; struct ice_aqc_set_phy_cfg set_phy; struct ice_aqc_restart_an restart_an; + struct ice_aqc_get_sensor_reading get_sensor_reading; + struct ice_aqc_get_sensor_reading_resp get_sensor_reading_resp; struct ice_aqc_i2c read_write_i2c; struct ice_aqc_read_i2c_resp read_i2c_resp; struct ice_aqc_gpio read_write_gpio; @@ -3253,6 +3281,7 @@ enum ice_adminq_opc { ice_aqc_opc_get_link_status = 0x0607, ice_aqc_opc_set_event_mask = 0x0613, ice_aqc_opc_set_mac_lb = 0x0620, + ice_aqc_opc_get_sensor_reading = 0x0632, ice_aqc_opc_get_link_topo = 0x06E0, ice_aqc_opc_get_link_topo_pin = 0x06E1, ice_aqc_opc_read_i2c = 0x06E2, diff --git a/drivers/net/ice/base/ice_common.c b/drivers/net/ice/base/ice_common.c index f7f43cd7e0..0f26f1d854 100644 --- a/drivers/net/ice/base/ice_common.c +++ b/drivers/net/ice/base/ice_common.c @@ -5359,6 +5359,42 @@ ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_handle, u16 tc_bitmap, ICE_SCHED_NODE_OWNER_LAN); } +/** + * ice_aq_get_sensor_reading + * @hw: pointer to the HW struct + * @sensor: sensor type + * @format: requested response format + * @data: pointer to data to be read from the sensor + * @cd: pointer to command details structure or NULL + * + * Get sensor reading (0x0632) + */ +enum ice_status +ice_aq_get_sensor_reading(struct ice_hw *hw, u8 sensor, u8 format, + struct ice_aqc_get_sensor_reading_resp *data, + struct ice_sq_cd *cd) +{ + struct ice_aqc_get_sensor_reading *cmd; + struct ice_aq_desc desc; + enum ice_status status; + + if (!data) + return ICE_ERR_PARAM; + + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_sensor_reading); + cmd = &desc.params.get_sensor_reading; + cmd->sensor = sensor; + cmd->format = format; + + status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd); + + if (!status) + ice_memcpy(data, &desc.params.get_sensor_reading_resp, + sizeof(*data), ICE_NONDMA_TO_NONDMA); + + return status; +} + /** * ice_is_main_vsi - checks whether the VSI is main VSI * @hw: pointer to the HW struct diff --git a/drivers/net/ice/base/ice_common.h b/drivers/net/ice/base/ice_common.h index aff361e5aa..0f1be917db 100644 --- a/drivers/net/ice/base/ice_common.h +++ b/drivers/net/ice/base/ice_common.h @@ -249,6 +249,10 @@ enum ice_status ice_sbq_rw_reg_lp(struct ice_hw *hw, void ice_sbq_lock(struct ice_hw *hw); void ice_sbq_unlock(struct ice_hw *hw); enum ice_status ice_sbq_rw_reg(struct ice_hw *hw, struct ice_sbq_msg_input *in); +enum ice_status +ice_aq_get_sensor_reading(struct ice_hw *hw, u8 sensor, u8 format, + struct ice_aqc_get_sensor_reading_resp *data, + struct ice_sq_cd *cd); void ice_stat_update40(struct ice_hw *hw, u32 reg, bool prev_stat_loaded, u64 *prev_stat, u64 *cur_stat);