Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp2926161pxb; Mon, 16 Nov 2020 00:24:51 -0800 (PST) X-Google-Smtp-Source: ABdhPJxyCes/4VT5KcEGIHrMEe8avyoidNscZ9eDVePrrtSq+WHGHianF/05Fi06C0fVhXVVKCUX X-Received: by 2002:a17:907:10d9:: with SMTP id rv25mr13773380ejb.437.1605515090953; Mon, 16 Nov 2020 00:24:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605515090; cv=none; d=google.com; s=arc-20160816; b=cRBbroVv+/aZjgCi4D9Zj2rde/dVFD7NRXVB8jcMAi+qrFyXWJxIQvyFskLVNCwbfK vvLcyt0yY0NIdnlmq6mDPB/M9eOk1FA6r4m95rrMgh857OJtGk1uyZ4bJ8gXl16Z8k8G 2mgGnznrzZIuAyjYSdw7HLhzvnW2msWGun9dkTK1S8p3i81EFZq9RxcAnGaNuDVCvsT5 kr4ob9NsFPpxvLNzVvFT+rKTfRSml+NZnhT1VCE1csvbTrUmDg+sRqkvQUCI1Flz5aSr /mQzGsJVw4TPb4iNKp1IRy5mGyudR/Dwf/t5Zedr1hTdkwbc1A7rI7ZD/GP0K/RxS1nW Ag7g== 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=i1L7z+wj5BQ2tovi77xjTub6aWTG0qj2cFnkW4nDjoI=; b=FIckxFVTblhxtJrHuqEBv0pNRcNmpig4+wQsEnh7TFlwlOwwnBbeWr3vCQmBIBcCQy M8MWKpx6hCfXP774ZM9obNp2scQQsTT+oSZsp+eczkLtrpSPK77H0yRCS2hdIgESYgxE tQZVbO9SoD27ZNiiJqmZ/nWZQDaj4YOYo7WcMMtuDHFwAt4nFcD1bE91YaQmo9oXSjKf bEFPtq0ixpFbbXvn82X4VZPhCAMvA5Pdu5VAfb1uAd0mKHaf2wlmBxfw11/wQpXhn8Vl Rmr8JzXK9CcKsJCioBlDUQnPmO63RAEX3N2u4zroGx6YuCltnZpYqa43nKZfqm/1IM1B E7Mg== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y10si10797613ejf.165.2020.11.16.00.24.28; Mon, 16 Nov 2020 00:24:50 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726376AbgKPIUu (ORCPT + 99 others); Mon, 16 Nov 2020 03:20:50 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:7244 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725904AbgKPIUt (ORCPT ); Mon, 16 Nov 2020 03:20:49 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CZMT90NM4zkYwM; Mon, 16 Nov 2020 16:20:29 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Mon, 16 Nov 2020 16:20:36 +0800 From: Huazhong Tan To: CC: , , , , , , Huazhong Tan Subject: [PATCH V4 net-next 3/4] net: hns3: add support for 1us unit GL configuration Date: Mon, 16 Nov 2020 16:20:53 +0800 Message-ID: <1605514854-11205-4-git-send-email-tanhuazhong@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1605514854-11205-1-git-send-email-tanhuazhong@huawei.com> References: <1605514854-11205-1-git-send-email-tanhuazhong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For device whose version is above V3(include V3), the GL configuration can set as 1us unit, so adds support for configuring this field. Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 26 ++++++++++++++++++---- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 3 +++ drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 6 +++++ 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 6e08719..2813fe5 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -224,17 +224,27 @@ void hns3_set_vector_coalesce_rl(struct hns3_enet_tqp_vector *tqp_vector, void hns3_set_vector_coalesce_rx_gl(struct hns3_enet_tqp_vector *tqp_vector, u32 gl_value) { - u32 rx_gl_reg = hns3_gl_usec_to_reg(gl_value); + u32 new_val; - writel(rx_gl_reg, tqp_vector->mask_addr + HNS3_VECTOR_GL0_OFFSET); + if (tqp_vector->rx_group.coal.unit_1us) + new_val = gl_value | HNS3_INT_GL_1US; + else + new_val = hns3_gl_usec_to_reg(gl_value); + + writel(new_val, tqp_vector->mask_addr + HNS3_VECTOR_GL0_OFFSET); } void hns3_set_vector_coalesce_tx_gl(struct hns3_enet_tqp_vector *tqp_vector, u32 gl_value) { - u32 tx_gl_reg = hns3_gl_usec_to_reg(gl_value); + u32 new_val; + + if (tqp_vector->tx_group.coal.unit_1us) + new_val = gl_value | HNS3_INT_GL_1US; + else + new_val = hns3_gl_usec_to_reg(gl_value); - writel(tx_gl_reg, tqp_vector->mask_addr + HNS3_VECTOR_GL1_OFFSET); + writel(new_val, tqp_vector->mask_addr + HNS3_VECTOR_GL1_OFFSET); } void hns3_set_vector_coalesce_tx_ql(struct hns3_enet_tqp_vector *tqp_vector, @@ -272,6 +282,14 @@ static void hns3_vector_coalesce_init(struct hns3_enet_tqp_vector *tqp_vector, rx_coal->flow_level = HNS3_FLOW_LOW; tx_coal->flow_level = HNS3_FLOW_LOW; + /* device version above V3(include V3), GL can configure 1us + * unit, so uses 1us unit. + */ + if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) { + tx_coal->unit_1us = 1; + rx_coal->unit_1us = 1; + } + if (ae_dev->dev_specs.int_ql_max) { tx_coal->ql_enable = 1; rx_coal->ql_enable = 1; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index be099dd..4651ad1 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -425,6 +425,8 @@ enum hns3_flow_level_range { #define HNS3_INT_GL_18K 0x0036 #define HNS3_INT_GL_8K 0x007C +#define HNS3_INT_GL_1US BIT(31) + #define HNS3_INT_RL_MAX 0x00EC #define HNS3_INT_RL_ENABLE_MASK 0x40 @@ -436,6 +438,7 @@ struct hns3_enet_coalesce { u16 int_ql_max; u8 gl_adapt_enable:1; u8 ql_enable:1; + u8 unit_1us:1; enum hns3_flow_level_range flow_level; }; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 49d3061..09aa608 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -1148,6 +1148,12 @@ static int hns3_check_gl_coalesce_para(struct net_device *netdev, return -EINVAL; } + /* device version above V3(include V3), GL uses 1us unit, + * so the round down is not needed. + */ + if (ae_dev->dev_version >= HNAE3_DEVICE_VERSION_V3) + return 0; + rx_gl = hns3_gl_round_down(cmd->rx_coalesce_usecs); if (rx_gl != cmd->rx_coalesce_usecs) { netdev_info(netdev, -- 2.7.4