Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp183412pxv; Thu, 15 Jul 2021 01:46:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzvOtWAK6AxRYfki8e7hKJZhtA86pORTFNnSKYJVwchVF9/6FYSg2v/MiTDT9hRAaCzEZs3 X-Received: by 2002:aa7:cd96:: with SMTP id x22mr5449597edv.102.1626338799368; Thu, 15 Jul 2021 01:46:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626338799; cv=none; d=google.com; s=arc-20160816; b=goBljQf1I7uAyXmcthTGHFXXcZ7bX0Ti8OXfhIJEEIJG/YyKRAb9q8ywd7ANvxJdUd Uf/LGDxKa5ASQKDosYEql/lsR3yeT3aFURsu13rGkJlrc5Lod1VA6wnhsEx4xdhveGhO Brby9okQJrV3Gd8UbpH937uxwDGilkXJTdADfIaZCzTT7VjeNiovwbwrwhhDTv/9J8fi /mB+FCIuI4OEpJheNScPzlq4WP+OjabUGCCmCGyVTzXP9Yb6DPihhvghrAWLmgSa6+Lq U5PXgbnaj7uVIVy/l8IjyBYBDVFXUmzNYAQ/H1V0tnIS5ZXrpvtiCkfmCLy8UtXc68xI T0WQ== 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=2U0neyDBBUPFPjsr8nlbyILE+Y0S1lPlcTAeqk++4mk=; b=LfqKz9/H63ActGXRIalGYSFiQA6X8S7jDzHr+XUCyRSBCivk1RdCM4sl5BPfkzwxm4 C2oiCl4zDP/5RGAvQJn0ZgcLFUY3dItaw7mkPnx0P/Gap0qalgI9W0UpZEKgQEQKKz2m A7NJ8rtXKnOWWg4nt29r0JiKzDxovMCK+jL9N862VYj712lyAxrbdkULfitO86LG+rGZ /vl4WR+iG8JrwaJGC+bdtq7fA0TRUmf+eLgWrSFw65OCf1loMLr/K/n9A+KU//oV/zgI qW+c4rbx0UpODmOu06ISe3DAWtq0vRVtgV3Ig6VvfYO9UuMYJbMcIjMhwi/OhhTjtp+/ k7ww== 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 y20si6574550edv.174.2021.07.15.01.46.16; Thu, 15 Jul 2021 01:46:39 -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 S240547AbhGOHvj (ORCPT + 99 others); Thu, 15 Jul 2021 03:51:39 -0400 Received: from szxga01-in.huawei.com ([45.249.212.187]:7015 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231785AbhGOHvf (ORCPT ); Thu, 15 Jul 2021 03:51:35 -0400 Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4GQRDj3kYhzXtLD; Thu, 15 Jul 2021 15:43:01 +0800 (CST) Received: from dggemi759-chm.china.huawei.com (10.1.198.145) by dggemv711-chm.china.huawei.com (10.1.198.66) 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 5/9] net: hns3: add support for devlink get info for VF Date: Thu, 15 Jul 2021 15:45:06 +0800 Message-ID: <1626335110-50769-6-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 VF driver. Signed-off-by: Yufeng Mo Signed-off-by: Guangbin Huang --- .../hisilicon/hns3/hns3vf/hclgevf_devlink.c | 30 ++++++++++++++++++++++ 1 file changed, 30 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..49993c8be313 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_devlink.c @@ -5,7 +5,37 @@ #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, + DEVLINK_INFO_VERSION_GENERIC_FW, + 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