Received: by 10.213.65.68 with SMTP id h4csp1032919imn; Wed, 21 Mar 2018 00:24:30 -0700 (PDT) X-Google-Smtp-Source: AG47ELtiRP96/i94dCrrIg8mEtSi2SmoWhNRqNRzvL7gpi2hozkgbShIqfU8QAP00a9PQL85bX4I X-Received: by 10.98.147.27 with SMTP id b27mr16139026pfe.145.1521617070816; Wed, 21 Mar 2018 00:24:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521617070; cv=none; d=google.com; s=arc-20160816; b=0ecI4urO8lrLr3ZKyJMLRrPhyTCxO+i+YSJ2kWkAEWA9kNMqZIkOVkSjUgV2FNY2ON 4hn4kdwWUSbunNe3JzVNEzcFSVLJG3F8jgj2JpnPyzeqFKAqzG9CWvF+C5pZuNPs9XTq l+zsp557UzDyO2ApeuRJvXgdNGDznuLtYxc4rKpg1YBj8xHkUyxnLDQLBlqOi7rIk0Um 0iC8x2qmRrXGMcl6mkLvyse86zBFPIibd/u3TebFcnTW6ePtLG75rm9/7uGuLdzsDXJX VTlpMiQnXNMtxQ11gzvHnI0YSEx2QmcxOTSfEctuQHV4ORvt0XmS3v/el6lMb+c1W/GH at4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=czRUNxwB4IGMTDj5oxz9lrlsyNm1scLQvkEqxQPW1A8=; b=ardPZ+WZegbDuRysFwhSKwXM+zOcdPfICO8kVtty9+9SiryPxzusuySfK72+nV5Xb4 7CxYC7csFoiPSbAW7pSPgrrCC5QdpRA12n+EUjtXxecA5bODeERzetMXpJi3v7EHwjZ4 4JwOU15MvDuYmJ5HEFZycJR96ho0A8qU1F2SOvd+O5pnevUwT3iB87AaQad/Uxv900G4 94gCHp5HJTiBdxgZBZGT/HRm+Gu0Ym01okzjDrrf6AMrv5shKw7/9zMMwc9VbEGtycfc vhPHJX4/lMt+1/tpohZbO1T67BI+U1ablFCQ3g3jBX5Azt3doXfNKSeHk2MB6FTswbjs I5rQ== 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 b2si1336630pgq.646.2018.03.21.00.24.16; Wed, 21 Mar 2018 00:24:30 -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 S1751799AbeCUHVg (ORCPT + 99 others); Wed, 21 Mar 2018 03:21:36 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:6659 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751423AbeCUHSP (ORCPT ); Wed, 21 Mar 2018 03:18:15 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id EA6D0B57A681E; Wed, 21 Mar 2018 15:18:00 +0800 (CST) Received: from linux-ioko.site (10.71.200.31) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.361.1; Wed, 21 Mar 2018 15:17:54 +0800 From: Peng Li To: CC: , , , , Subject: [PATCH net-next 10/11] net: hns3: add querying speed and duplex support to VF Date: Wed, 21 Mar 2018 15:49:29 +0800 Message-ID: <1521618570-129694-11-git-send-email-lipeng321@huawei.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1521618570-129694-1-git-send-email-lipeng321@huawei.com> References: <1521618570-129694-1-git-send-email-lipeng321@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.71.200.31] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Fuyun Liang This patch adds support for querying speed and duplex by ethtool ethX to VF. Signed-off-by: Fuyun Liang Signed-off-by: Peng Li --- .../net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c | 8 ++++++-- .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c | 22 ++++++++++++++++++++++ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h | 4 ++++ .../ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c | 5 +++++ 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c index cef14e7..949da0c 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_mbx.c @@ -309,16 +309,20 @@ static int hclge_get_link_info(struct hclge_vport *vport, { struct hclge_dev *hdev = vport->back; u16 link_status; - u8 msg_data[2]; + u8 msg_data[8]; u8 dest_vfid; + u16 duplex; /* mac.link can only be 0 or 1 */ link_status = (u16)hdev->hw.mac.link; + duplex = hdev->hw.mac.duplex; memcpy(&msg_data[0], &link_status, sizeof(u16)); + memcpy(&msg_data[2], &hdev->hw.mac.speed, sizeof(u32)); + memcpy(&msg_data[6], &duplex, sizeof(u16)); dest_vfid = mbx_req->mbx_src_vfid; /* send this requested info to VF */ - return hclge_send_mbx_msg(vport, msg_data, sizeof(u8), + return hclge_send_mbx_msg(vport, msg_data, sizeof(msg_data), HCLGE_MBX_LINK_STAT_CHANGE, dest_vfid); } diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c index f917a1e..906dfa3 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.c @@ -1475,6 +1475,27 @@ static int hclgevf_get_status(struct hnae3_handle *handle) return hdev->hw.mac.link; } +static void hclgevf_get_ksettings_an_result(struct hnae3_handle *handle, + u8 *auto_neg, u32 *speed, + u8 *duplex) +{ + struct hclgevf_dev *hdev = hclgevf_ae_get_hdev(handle); + + if (speed) + *speed = hdev->hw.mac.speed; + if (duplex) + *duplex = hdev->hw.mac.duplex; + if (auto_neg) + *auto_neg = AUTONEG_DISABLE; +} + +void hclgevf_update_speed_duplex(struct hclgevf_dev *hdev, u32 speed, + u8 duplex) +{ + hdev->hw.mac.speed = speed; + hdev->hw.mac.duplex = duplex; +} + static const struct hnae3_ae_ops hclgevf_ops = { .init_ae_dev = hclgevf_init_ae_dev, .uninit_ae_dev = hclgevf_uninit_ae_dev, @@ -1508,6 +1529,7 @@ static const struct hnae3_ae_ops hclgevf_ops = { .get_channels = hclgevf_get_channels, .get_tqps_and_rss_info = hclgevf_get_tqps_and_rss_info, .get_status = hclgevf_get_status, + .get_ksettings_an_result = hclgevf_get_ksettings_an_result, }; static struct hnae3_ae_algo ae_algovf = { diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h index a63bee4..0eaea06 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_main.h @@ -61,6 +61,8 @@ enum hclgevf_states { struct hclgevf_mac { u8 mac_addr[ETH_ALEN]; int link; + u8 duplex; + u32 speed; }; struct hclgevf_hw { @@ -161,4 +163,6 @@ int hclgevf_send_mbx_msg(struct hclgevf_dev *hdev, u16 code, u16 subcode, u8 *resp_data, u16 resp_len); void hclgevf_mbx_handler(struct hclgevf_dev *hdev); void hclgevf_update_link_status(struct hclgevf_dev *hdev, int link_state); +void hclgevf_update_speed_duplex(struct hclgevf_dev *hdev, u32 speed, + u8 duplex); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c index 9768f71..a63ed3a 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3vf/hclgevf_mbx.c @@ -133,6 +133,8 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) struct hclgevf_cmq_ring *crq; struct hclgevf_desc *desc; u16 link_status, flag; + u32 speed; + u8 duplex; u8 *temp; int i; @@ -164,9 +166,12 @@ void hclgevf_mbx_handler(struct hclgevf_dev *hdev) break; case HCLGE_MBX_LINK_STAT_CHANGE: link_status = le16_to_cpu(req->msg[1]); + memcpy(&speed, &req->msg[2], sizeof(speed)); + duplex = (u8)le16_to_cpu(req->msg[4]); /* update upper layer with new link link status */ hclgevf_update_link_status(hdev, link_status); + hclgevf_update_speed_duplex(hdev, speed, duplex); break; default: -- 2.9.3