Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp252833pxv; Thu, 15 Jul 2021 03:33:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxP44aRf2x/kUbhjbqKXj3o9Ri+Zlh75kjUl2CE1lTEoJ/GxzRb8Kp/G9FzZW2i3NmivJW X-Received: by 2002:a02:6f1c:: with SMTP id x28mr3354926jab.95.1626345210567; Thu, 15 Jul 2021 03:33:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626345210; cv=none; d=google.com; s=arc-20160816; b=qq9U+3lasa1FI8LmoV/8bkhC4E5SpQbvbNBr2+Lyzw2l+34ae0eiIHeQSokE4O+UnZ CfaoNfnV+QDSrgzoWVQplCCb50vI4EC3avs26FY79CiuQuipLC6zlAqU3rEk4s7lq6uu kNRxRV+MUabAkCQQdUC/3gdd97KVo6DNqLCYfvHI4YOl/v35vOKf6aCi5a5cDUHDRjs+ aZmsMaBk9ko7IPLGKshwNAhy81q/uw5Er3SOTY/3/XR+m5ftEQNgxlRgeacKn7HjRYE4 GD8P1dAYhhjFfQ7jZDQsJh95HB9IAV4NcF0ySpZ9jbyuiFPxSOxvpMLKcdxVFENXKi53 mkUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=N9z2axFOi87YZiV70Gn3JTgBqGwSpGS7ir/YWpAH244=; b=DojrHSUxX+mtB2yNkFsPK5Sy4yzxU/iVnsOqi98v/rLfd4mPv4rkBJvyhEAg+a6P1O OBgHRmecBGbcDZKXiT0/PKnzb99akXUMuFn3N+PeVV6sNBNERmpYDnsGxEQ1g5thS90g 7uGx55o1oo61mYFRVIbnxjKk0H1O8PF2B1cPpz9IBocCn3f6+uIDMNU7SdhdHas5BQoq kPNYiOWCwCuCgXaxmJJsrXhDvDJFcvLZvHmqaDx2r/HxuF19HpkOuRvoENkL+PRHlgYJ vfJisOq6e22+iN6Wy7Svx7ZrYE84/WawUyaSRowTmVthArrD6vDoVlDgfyWDIzmvML5S QfkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i1si6238754ils.142.2021.07.15.03.33.19; Thu, 15 Jul 2021 03:33:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240651AbhGOHvu (ORCPT + 99 others); Thu, 15 Jul 2021 03:51:50 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:11419 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240499AbhGOHvh (ORCPT ); Thu, 15 Jul 2021 03:51:37 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.53]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GQRHS3mPXzcddG; Thu, 15 Jul 2021 15:45:24 +0800 (CST) Received: from dggemi759-chm.china.huawei.com (10.1.198.145) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2176.2; Thu, 15 Jul 2021 15:48:39 +0800 Received: from localhost.localdomain (10.67.165.24) by dggemi759-chm.china.huawei.com (10.1.198.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2176.2; Thu, 15 Jul 2021 15:48:39 +0800 From: Guangbin Huang To: , , CC: , , , , Subject: [PATCH V2 net-next 4/9] net: hns3: add support for devlink get info for PF Date: Thu, 15 Jul 2021 15:45:05 +0800 Message-ID: <1626335110-50769-5-git-send-email-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1626335110-50769-1-git-send-email-huangguangbin2@huawei.com> References: <1626335110-50769-1-git-send-email-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To dggemi759-chm.china.huawei.com (10.1.198.145) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yufeng Mo Add devlink get info support for HNS3 ethernet PF driver. Signed-off-by: Yufeng Mo Signed-off-by: Guangbin Huang --- .../ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c index 03b822b0a8e7..7de423d510c5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c @@ -5,7 +5,37 @@ #include "hclge_devlink.h" +static int hclge_devlink_info_get(struct devlink *devlink, + struct devlink_info_req *req, + struct netlink_ext_ack *extack) +{ +#define HCLGE_DEVLINK_FW_STRING_LEN 32 + struct hclge_devlink_priv *priv = devlink_priv(devlink); + char version_str[HCLGE_DEVLINK_FW_STRING_LEN]; + struct hclge_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, + DEVLINK_INFO_VERSION_GENERIC_FW, + version_str); +} + static const struct devlink_ops hclge_devlink_ops = { + .info_get = hclge_devlink_info_get, }; int hclge_devlink_init(struct hclge_dev *hdev) -- 2.8.1