Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp5375468ybl; Tue, 14 Jan 2020 07:58:42 -0800 (PST) X-Google-Smtp-Source: APXvYqw/0E7pbAq0sv7Llb1MXkOYxv0Pz9NmPPeovZdmrYj1/dJOL03o322YN3zxiHz+w8Hk5dZj X-Received: by 2002:aca:4183:: with SMTP id o125mr16323662oia.125.1579017522106; Tue, 14 Jan 2020 07:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579017522; cv=none; d=google.com; s=arc-20160816; b=jK1/WXgAizPnNYxkahP/F1EfqZ5jH2l6f4H2tpCIDntk5xodZvmy4wa/eERHl7WpIy INENebdEhletPfx8gq19wotQcE1v/rc2JyTcgRatsy3eGyjKzr7LxSRGlMEfiU7oy+4B 3mAlfhUDPOIXwUwLTbovaBj0ryE5KchhVnrIQIjrInleMyPxtu2go9zdcmNr3gJgHlnn 8WFxdo+EznA1ttMdYCyCQUURV/905is6EIoxFxc3slh/6l+G7NaZgNMufmU1cSkgHVhQ j7JC4jSLoaNHPHuNjmPbj1qE00obcK4nLz4KeAwf6hl+gaR6YDLIPRCkpOYMYMx0EDwC jq3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=DHFpn6hdGsl4IYB4/5NcuFSJsrLq1jSaZ9R3uvoHtb4=; b=AfO08FUO5t+7x+Vz4UWidyZyXd9DN8jdAZJ1d3KoPIJUQGwmy/uPc/EMVs0yD3J2M7 oeYnXk1PcWN3Hw/e0bEI0E9HEptQbBBWSubDvAF2rh+6cC1G5usQDjoLq8c+keJNtN41 MsAqEkJj6/VxvAfWEp7Pj694+cZ9P/W5K+f6CXzDeJ23ndxmdly2ZSF/oFkrM8emOoIf h6+jKKUmPZxiHuT144MW6bVojd7/za/mid3yQWnKqOTFb9kyYUnP2slbxw/23PqwzAOr n2jAtLKjFWCmiwIz0PJO8DEXODPwH3e6yRYMd5MO4a7cc3op7uBnItknWga8krbxTI8q ehcQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a205si7742147oii.95.2020.01.14.07.58.30; Tue, 14 Jan 2020 07:58:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=mellanox.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726365AbgANPzv (ORCPT + 99 others); Tue, 14 Jan 2020 10:55:51 -0500 Received: from mail-il-dmz.mellanox.com ([193.47.165.129]:41675 "EHLO mellanox.co.il" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725904AbgANPzv (ORCPT ); Tue, 14 Jan 2020 10:55:51 -0500 Received: from Internal Mail-Server by MTLPINE1 (envelope-from moshe@mellanox.com) with ESMTPS (AES256-SHA encrypted); 14 Jan 2020 17:55:45 +0200 Received: from dev-l-vrt-136.mtl.labs.mlnx (dev-l-vrt-136.mtl.labs.mlnx [10.134.136.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 00EFtjD4015233; Tue, 14 Jan 2020 17:55:45 +0200 Received: from dev-l-vrt-136.mtl.labs.mlnx (localhost [127.0.0.1]) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7) with ESMTP id 00EFtjtl019702; Tue, 14 Jan 2020 17:55:45 +0200 Received: (from moshe@localhost) by dev-l-vrt-136.mtl.labs.mlnx (8.14.7/8.14.7/Submit) id 00EFtjK4019701; Tue, 14 Jan 2020 17:55:45 +0200 From: Moshe Shemesh To: "David S. Miller" Cc: Alexander Duyck , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Moshe Shemesh Subject: [PATCH net-next RFC 2/3] net/mlx5: Add functions to set/query MFRL register Date: Tue, 14 Jan 2020 17:55:27 +0200 Message-Id: <1579017328-19643-3-git-send-email-moshe@mellanox.com> X-Mailer: git-send-email 1.8.4.3 In-Reply-To: <1579017328-19643-1-git-send-email-moshe@mellanox.com> References: <1579017328-19643-1-git-send-email-moshe@mellanox.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add functions to set the reset level required and to query the reset levels supported by fw. Signed-off-by: Moshe Shemesh --- drivers/net/ethernet/mellanox/mlx5/core/fw.c | 44 ++++++++++++++++++++++ .../net/ethernet/mellanox/mlx5/core/mlx5_core.h | 2 + 2 files changed, 46 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fw.c b/drivers/net/ethernet/mellanox/mlx5/core/fw.c index 1723229..1c6dfe9 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fw.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fw.c @@ -769,3 +769,47 @@ int mlx5_fw_version_query(struct mlx5_core_dev *dev, return 0; } + +static int mlx5_reg_mfrl_set(struct mlx5_core_dev *dev, u8 reset_level, + u8 reset_type_sel) +{ + u32 out[MLX5_ST_SZ_DW(mfrl_reg)]; + u32 in[MLX5_ST_SZ_DW(mfrl_reg)] = {}; + + MLX5_SET(mfrl_reg, in, reset_level, reset_level); + MLX5_SET(mfrl_reg, in, rst_type_sel, reset_type_sel); + + return mlx5_core_access_reg(dev, in, sizeof(in), out, + sizeof(out), MLX5_REG_MFRL, 0, 1); +} + +static int mlx5_reg_mfrl_query(struct mlx5_core_dev *dev, u8 *reset_level, + u8 *reset_type_sel, u8 *reset_type) +{ + u32 out[MLX5_ST_SZ_DW(mfrl_reg)] = {}; + u32 in[MLX5_ST_SZ_DW(mfrl_reg)] = {}; + int err; + + err = mlx5_core_access_reg(dev, in, sizeof(in), out, + sizeof(out), MLX5_REG_MFRL, 0, 0); + if (err) + return err; + + *reset_level = MLX5_GET(mfrl_reg, out, reset_level); + *reset_type = MLX5_GET(mfrl_reg, out, reset_type); + *reset_type_sel = MLX5_GET(mfrl_reg, out, rst_type_sel); + + return 0; +} + +int mlx5_fw_query_reset_level(struct mlx5_core_dev *dev, u8 *reset_level) +{ + u8 reset_type_sel, reset_type; + + return mlx5_reg_mfrl_query(dev, reset_level, &reset_type_sel, &reset_type); +} + +int mlx5_fw_set_reset_level(struct mlx5_core_dev *dev, u8 reset_level) +{ + return mlx5_reg_mfrl_set(dev, reset_level, 0); +} diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h index da67b28..1b55a5a 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h +++ b/drivers/net/ethernet/mellanox/mlx5/core/mlx5_core.h @@ -210,6 +210,8 @@ int mlx5_firmware_flash(struct mlx5_core_dev *dev, const struct firmware *fw, struct netlink_ext_ack *extack); int mlx5_fw_version_query(struct mlx5_core_dev *dev, u32 *running_ver, u32 *stored_ver); +int mlx5_fw_query_reset_level(struct mlx5_core_dev *dev, u8 *reset_level); +int mlx5_fw_set_reset_level(struct mlx5_core_dev *dev, u8 reset_level); void mlx5e_init(void); void mlx5e_cleanup(void); -- 1.8.3.1