Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp4414135pxv; Mon, 5 Jul 2021 23:47:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyLUL90HVYDSEETDw88Z0NnkmFVHRKSHCUO+NKfYCuZLdgFWbdCjIkLk7UfxprDhpUl2JKR X-Received: by 2002:a6b:f91a:: with SMTP id j26mr6042048iog.97.1625554053413; Mon, 05 Jul 2021 23:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625554053; cv=none; d=google.com; s=arc-20160816; b=MPtRBEYy0xHe0K4F8V9+C8+moNXGonoIDBWPm6T817vIpS/NVZv36hb0HapXJnenJg snnIWpTqGKfx//q17rFPUqimxgh6wBir0nPM3wz7olb8TOf75s8dReQWqpKIMQvOhSs3 Bq5tz1J1oDnMKr3vuoO12k3VYIO4IoVKXRqoCmCacOnLe6KLksN9nBzNrXp1J1OvIC2b MCQLY/mLnw8OO5FqiE2eufFOJz5txErtoCXk1lI1xEKXc+TnfPQC4I41u+SSxZ0STWut T0aMZshv/gfMZVxzUa3gYGMCgqmjdMK3D8s92YIRzduFZ1oFKIKCSsqMy6+qofHzaL6i Xkmg== 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=r3liYMrUy46VFE2KspZOx+2VXFWRJZge6Ybz2ZjqSYE=; b=oDlKmveqU9deNM3l+jMrTm3yX4dA6aMQBcDqykBzYUXLoXtTbAiFYQeCTTvfLks0Oi 6mMZ9tB138NP3r1NJDKa88c68Nk6Qj7k1aR9r41T47Ow/UGUFuXL+BOriEvcQuVLd6tN uDKQHzD8KKUVKmqJwF3cFONuvDi2BbpDzp2WVmfRBWRBmIu2Il2tqvtBMNCkQsy8yeCK W2e1I4Mf3m+r3evw6pnFJzl/6iFUWG3+2TM+9iNTZ7qRikCT4FUQ4z7pydH42DfOIq0M 85hx5IUZl3VK/oO8Pr1OYooP93f8Og2640pKH9vtGZQngu+Jy1vHGNGiYvTyinx6x5M0 n78A== 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 d6si7301001ilv.2.2021.07.05.23.47.22; Mon, 05 Jul 2021 23:47:33 -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 S230440AbhGFGr6 (ORCPT + 99 others); Tue, 6 Jul 2021 02:47:58 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:6420 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230146AbhGFGrj (ORCPT ); Tue, 6 Jul 2021 02:47:39 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.57]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GJtHt0DPJz78Z7; Tue, 6 Jul 2021 14:41:30 +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; Tue, 6 Jul 2021 14:44:55 +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; Tue, 6 Jul 2021 14:44:55 +0800 From: Guangbin Huang To: , , CC: , , , , Subject: [RFC PATCH net-next 3/8] net: hns3: add support for devlink get info for PF Date: Tue, 6 Jul 2021 14:41:27 +0800 Message-ID: <1625553692-2773-4-git-send-email-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1625553692-2773-1-git-send-email-huangguangbin2@huawei.com> References: <1625553692-2773-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 | 28 ++++++++++++++++++++++ 1 file changed, 28 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..1646e9e234fe 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_devlink.c @@ -5,7 +5,35 @@ #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, "fw-version", 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