All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guangbin Huang <huangguangbin2@huawei.com>
To: <davem@davemloft.net>, <kuba@kernel.org>, <jiri@nvidia.com>
Cc: <netdev@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<lipeng321@huawei.com>, <chenhao288@hisilicon.com>,
	<huangguangbin2@huawei.com>
Subject: [RFC PATCH net-next 4/8] net: hns3: add support for devlink get info for VF
Date: Tue, 6 Jul 2021 14:41:28 +0800	[thread overview]
Message-ID: <1625553692-2773-5-git-send-email-huangguangbin2@huawei.com> (raw)
In-Reply-To: <1625553692-2773-1-git-send-email-huangguangbin2@huawei.com>

From: Yufeng Mo <moyufeng@huawei.com>

Add devlink get info support for HNS3 ethernet VF driver.

Signed-off-by: Yufeng Mo <moyufeng@huawei.com>
Signed-off-by: Guangbin Huang <huangguangbin2@huawei.com>
---
 .../hisilicon/hns3/hns3vf/hclgevf_devlink.c        | 28 ++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c
index 55337a975981..1cc6e2fac3a3 100644
--- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c
+++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c
@@ -5,7 +5,35 @@
 
 #include "hclgevf_devlink.h"
 
+static int hclgevf_devlink_info_get(struct devlink *devlink,
+				    struct devlink_info_req *req,
+				    struct netlink_ext_ack *extack)
+{
+#define	HCLGEVF_DEVLINK_FW_STRING_LEN	32
+	struct hclgevf_devlink_priv *priv = devlink_priv(devlink);
+	char version_str[HCLGEVF_DEVLINK_FW_STRING_LEN];
+	struct hclgevf_dev *hdev = priv->hdev;
+	int ret;
+
+	ret = devlink_info_driver_name_put(req, KBUILD_MODNAME);
+	if (ret)
+		return ret;
+
+	snprintf(version_str, sizeof(version_str), "%lu.%lu.%lu.%lu",
+		 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE3_MASK,
+				 HNAE3_FW_VERSION_BYTE3_SHIFT),
+		 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE2_MASK,
+				 HNAE3_FW_VERSION_BYTE2_SHIFT),
+		 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE1_MASK,
+				 HNAE3_FW_VERSION_BYTE1_SHIFT),
+		 hnae3_get_field(hdev->fw_version, HNAE3_FW_VERSION_BYTE0_MASK,
+				 HNAE3_FW_VERSION_BYTE0_SHIFT));
+
+	return devlink_info_version_running_put(req, "fw-version", version_str);
+}
+
 static const struct devlink_ops hclgevf_devlink_ops = {
+	.info_get = hclgevf_devlink_info_get,
 };
 
 int hclgevf_devlink_init(struct hclgevf_dev *hdev)
-- 
2.8.1


  parent reply	other threads:[~2021-07-06  6:45 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-06  6:41 [RFC PATCH net-next 0/8] net: hns3: add support devlink Guangbin Huang
2021-07-06  6:41 ` [RFC PATCH net-next 1/8] net: hns3: add support for registering devlink for PF Guangbin Huang
2021-07-06  6:41 ` [RFC PATCH net-next 2/8] net: hns3: add support for registering devlink for VF Guangbin Huang
2021-07-06  6:41 ` [RFC PATCH net-next 3/8] net: hns3: add support for devlink get info for PF Guangbin Huang
2021-07-06 23:14   ` Jakub Kicinski
2021-07-07  9:21     ` huangguangbin (A)
2021-07-06  6:41 ` Guangbin Huang [this message]
2021-07-06  6:41 ` [RFC PATCH net-next 5/8] net: hns3: add devlink reload support " Guangbin Huang
2021-07-06  6:41 ` [RFC PATCH net-next 6/8] net: hns3: add devlink reload support for VF Guangbin Huang
2021-07-06  6:41 ` [RFC PATCH net-next 7/8] net: hns3: add support for PF setting rx/tx buffer size by devlink param Guangbin Huang
2021-07-06 23:16   ` Jakub Kicinski
2021-07-07  9:22     ` huangguangbin (A)
2021-07-06  6:41 ` [RFC PATCH net-next 8/8] net: hns3: add support for VF " Guangbin Huang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1625553692-2773-5-git-send-email-huangguangbin2@huawei.com \
    --to=huangguangbin2@huawei.com \
    --cc=chenhao288@hisilicon.com \
    --cc=davem@davemloft.net \
    --cc=jiri@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lipeng321@huawei.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.