Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3243254ybi; Fri, 5 Jul 2019 04:17:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwT2YcqOS/qvPZ8GaSC25z2LtT2/CRdp+ntWw06G64f5PyF6fRP/psdVis5VSMS0oI6b7eD X-Received: by 2002:a17:902:e58b:: with SMTP id cl11mr4848721plb.24.1562325461968; Fri, 05 Jul 2019 04:17:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562325461; cv=none; d=google.com; s=arc-20160816; b=0XKc4lzZvkT4vygOETrSmCC0umnuKl7lIHk9ksO8Xa+8JO4mF4RIvv8G3yV12/bcZ0 KmR8KcCHkpDWd16Mj2BCFtUotMbCJ+bdjF+6ptwcJJopVTJxpEEFCjaArpDTXqQKVoyb qizWP7FMECL08rocw8Hr3pNyCHGCvIDTiHOQiDhihk7aI8pSeVL1QVAxSYFTUzG4FX67 zSV5+aDb8Ev0UrvyBj7pVavRUEMWdu4yXWifIatzKK7u0DJNnCFa00gfV9oZpBD4QtrF nDCKygAxykzGTwLx8fF/7If3H6kJWzDOFY+AlFRQ5xDdtlLs93lMrxlv8NHHOEtWlgoC C3cA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=a8EWOMdXqwzFvYxa9JFFKvq/7GoIVcrMfkUyeLLwcmE=; b=sY4jzwGHeukFpPa2zoY2VtdwuQn1tGpGttC4iiig6jBnozCNp3QB35XpDjcK5K4p+E LRb2Jl8nPXzgEMCieeQAW/i45JXxnauokxZIAKnFf88xhxvKe0uXnl7N377N3w3Lva58 kS9o/cUDTcrJhdjXN7myj5754Ll8ReI4myYWFkrD8KuasFFPaWviMvXeoyt48j+Wl6ZV +dKhpSTAZkYHueuQ6jvCErPiN4xc/ga/r5eCDfyl+dr+RWHeElyboIr6tKpLJfHcAcmZ zVyVo4iwEzG45H6ZdodiefBBKKljHGof4u3GbEdP2u4Yqma6GVfS0h6vJZYZXyPlAdoU 0PXA== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x13si9382380pfn.105.2019.07.05.04.17.26; Fri, 05 Jul 2019 04:17:41 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728042AbfGEK1A (ORCPT + 99 others); Fri, 5 Jul 2019 06:27:00 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:8710 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727358AbfGEK1A (ORCPT ); Fri, 5 Jul 2019 06:27:00 -0400 Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 80567AD3204B4059DCDA; Fri, 5 Jul 2019 18:26:43 +0800 (CST) Received: from localhost.localdomain (10.175.34.53) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.439.0; Fri, 5 Jul 2019 18:26:36 +0800 From: Xue Chaojing To: CC: , , , , , , Subject: [PATCH net-next] hinic: add fw version query Date: Fri, 5 Jul 2019 02:36:35 +0000 Message-ID: <20190705023635.5614-1-xuechaojing@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.34.53] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This patch adds firmware version query in ethtool -i. Signed-off-by: Xue Chaojing --- .../net/ethernet/huawei/hinic/hinic_ethtool.c | 8 +++++ .../net/ethernet/huawei/hinic/hinic_hw_dev.h | 2 ++ .../net/ethernet/huawei/hinic/hinic_port.c | 30 +++++++++++++++++++ .../net/ethernet/huawei/hinic/hinic_port.h | 13 ++++++++ 4 files changed, 53 insertions(+) diff --git a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c index 73a20f01ad4c..60ec48fe4144 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c @@ -117,11 +117,19 @@ static void hinic_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *info) { struct hinic_dev *nic_dev = netdev_priv(netdev); + u8 mgmt_ver[HINIC_MGMT_VERSION_MAX_LEN] = {0}; struct hinic_hwdev *hwdev = nic_dev->hwdev; struct hinic_hwif *hwif = hwdev->hwif; + int err; strlcpy(info->driver, HINIC_DRV_NAME, sizeof(info->driver)); strlcpy(info->bus_info, pci_name(hwif->pdev), sizeof(info->bus_info)); + + err = hinic_get_mgmt_version(nic_dev, mgmt_ver); + if (err) + return; + + snprintf(info->fw_version, sizeof(info->fw_version), "%s", mgmt_ver); } static void hinic_get_ringparam(struct net_device *netdev, diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h index 984c98f33258..b069045de416 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_dev.h @@ -77,6 +77,8 @@ enum hinic_port_cmd { HINIC_PORT_CMD_FWCTXT_INIT = 69, + HINIC_PORT_CMD_GET_MGMT_VERSION = 88, + HINIC_PORT_CMD_SET_FUNC_STATE = 93, HINIC_PORT_CMD_GET_GLOBAL_QPN = 102, diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c index 1bbeb91be808..1e389a004e50 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_port.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c @@ -1038,3 +1038,33 @@ int hinic_get_phy_port_stats(struct hinic_dev *nic_dev, return err; } + +int hinic_get_mgmt_version(struct hinic_dev *nic_dev, u8 *mgmt_ver) +{ + struct hinic_hwdev *hwdev = nic_dev->hwdev; + struct hinic_version_info up_ver = {0}; + struct hinic_hwif *hwif; + struct pci_dev *pdev; + u16 out_size; + int err; + + if (!hwdev) + return -EINVAL; + + hwif = hwdev->hwif; + pdev = hwif->pdev; + + err = hinic_port_msg_cmd(hwdev, HINIC_PORT_CMD_GET_MGMT_VERSION, + &up_ver, sizeof(up_ver), &up_ver, + &out_size); + if (err || !out_size || up_ver.status) { + dev_err(&pdev->dev, + "Failed to get mgmt version, err: %d, status: 0x%x, out size: 0x%x\n", + err, up_ver.status, out_size); + return -EINVAL; + } + + snprintf(mgmt_ver, HINIC_MGMT_VERSION_MAX_LEN, "%s", up_ver.ver); + + return 0; +} diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.h b/drivers/net/ethernet/huawei/hinic/hinic_port.h index 1bc47c7a5c00..56df6c21ca4a 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_port.h +++ b/drivers/net/ethernet/huawei/hinic/hinic_port.h @@ -16,7 +16,18 @@ #define HINIC_RSS_KEY_SIZE 40 #define HINIC_RSS_INDIR_SIZE 256 #define HINIC_PORT_STATS_VERSION 0 +#define HINIC_FW_VERSION_NAME 16 +#define HINIC_COMPILE_TIME_LEN 20 +#define HINIC_MGMT_VERSION_MAX_LEN 32 +struct hinic_version_info { + u8 status; + u8 version; + u8 rsvd[6]; + + u8 ver[HINIC_FW_VERSION_NAME]; + u8 time[HINIC_COMPILE_TIME_LEN]; +}; enum hinic_rx_mode { HINIC_RX_MODE_UC = BIT(0), HINIC_RX_MODE_MC = BIT(1), @@ -571,4 +582,6 @@ int hinic_get_vport_stats(struct hinic_dev *nic_dev, int hinic_set_rx_vlan_offload(struct hinic_dev *nic_dev, u8 en); +int hinic_get_mgmt_version(struct hinic_dev *nic_dev, u8 *mgmt_ver); + #endif -- 2.17.1