Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1235711pxb; Fri, 20 Aug 2021 00:41:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXzcy78MOVdptViLQRW8LTjB6bvjwYyCHpduzE2RHwy7loSod7xiNxgfYQYfRtClE7DpKH X-Received: by 2002:a17:906:f8c7:: with SMTP id lh7mr16118224ejb.211.1629445274656; Fri, 20 Aug 2021 00:41:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629445274; cv=none; d=google.com; s=arc-20160816; b=qI/wXIw+ne1dv3zPWahm2r5kCPqYfYms5EHhnun4ydD8Nv9sLEHwpvq3DmZaPa4N9i gsFKL7oOWchniC/kDt/bLUE/0ZpuB9FGeRrK+LsxyX/FVE7rYeySkfOb2D7alT2epIej X/XSmFJLLcN4Ku2TXfiF1F4KgUDocaHLzNuRuW8iuby5zclm7AN/cIIy4dhAZ/rLQklG rsqJIqb0eTq8gNiBcliybXYWbbPPlP5xRhN2nRvMlgSxq3XOWWY/rRQNCVR4e2mBUfhw soSjN+yzRuBFxeD7dwpiXuVhYliuh0IXupWqmKzVsAoGWnqeTVI5l5jFThXcP4fFGGja HkQg== 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=4fmCc23tGM3EyZrB0v6DYTQyYA4tEpdfV5saD+XKOvo=; b=Osi/T1ZmEkzBQMcGI+jHFz9oCrW5G8DEm6vhDXQEquEZkG1aq/7a7JV8Bv7wFTtO34 kbG6Z/80SgFc1WX3Tfi/uw2JnYi9nCxiCazLyR2Fd/MQSjVCXh5fcKo+wt2ISt2XyX23 xB/DaEnND1v83WMiIdiAp00k8XAWKgAnhFgzKUO8Ex2qjlKoNQ1Zi2JLBq0ZdKxbIrdf 3lM6CmYtjeHLJya/IJXaq3k33DRhoSdxhEF434gJjytO/rcFvMN8wNODLp8+Qd7rf4C5 4Nz/3+vNddFnX1WyRMLEJZ3x67JacUjeMr4ayGxh47i6v7QSGNU+2kBbRK7uV6yTAVhC ljjg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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 hp19si5984537ejc.372.2021.08.20.00.40.50; Fri, 20 Aug 2021 00:41:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-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 S236570AbhHTHkT (ORCPT + 99 others); Fri, 20 Aug 2021 03:40:19 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:8900 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238823AbhHTHjw (ORCPT ); Fri, 20 Aug 2021 03:39:52 -0400 Received: from dggemv703-chm.china.huawei.com (unknown [172.30.72.54]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4GrYM04dq3z8srP; Fri, 20 Aug 2021 15:35:08 +0800 (CST) Received: from dggpeml500024.china.huawei.com (7.185.36.10) by dggemv703-chm.china.huawei.com (10.3.19.46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 20 Aug 2021 15:39:13 +0800 Received: from localhost.localdomain (10.67.165.24) by dggpeml500024.china.huawei.com (7.185.36.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.2; Fri, 20 Aug 2021 15:39:12 +0800 From: Yufeng Mo To: , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH V3 net-next 4/4] net: hns3: add ethtool support for CQE/EQE mode configuration Date: Fri, 20 Aug 2021 15:35:20 +0800 Message-ID: <1629444920-25437-5-git-send-email-moyufeng@huawei.com> X-Mailer: git-send-email 2.8.1 In-Reply-To: <1629444920-25437-1-git-send-email-moyufeng@huawei.com> References: <1629444920-25437-1-git-send-email-moyufeng@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggpeml500024.china.huawei.com (7.185.36.10) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Add support in ethtool for switching EQE/CQE mode. Signed-off-by: Yufeng Mo Signed-off-by: Huazhong Tan --- drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | 6 +++--- drivers/net/ethernet/hisilicon/hns3/hns3_enet.h | 3 +++ drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c | 18 +++++++++++++++++- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index 1bd83d7..39d01ca 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -5055,9 +5055,9 @@ static void hns3_set_cq_period_mode(struct hns3_nic_priv *priv, } } -static void hns3_cq_period_mode_init(struct hns3_nic_priv *priv, - enum dim_cq_period_mode tx_mode, - enum dim_cq_period_mode rx_mode) +void hns3_cq_period_mode_init(struct hns3_nic_priv *priv, + enum dim_cq_period_mode tx_mode, + enum dim_cq_period_mode rx_mode) { hns3_set_cq_period_mode(priv, tx_mode, true); hns3_set_cq_period_mode(priv, rx_mode, false); diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index ff45825..dfad906 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -718,4 +718,7 @@ void hns3_dbg_register_debugfs(const char *debugfs_dir_name); void hns3_dbg_unregister_debugfs(void); void hns3_shinfo_pack(struct skb_shared_info *shinfo, __u32 *size); u16 hns3_get_max_available_channels(struct hnae3_handle *h); +void hns3_cq_period_mode_init(struct hns3_nic_priv *priv, + enum dim_cq_period_mode tx_mode, + enum dim_cq_period_mode rx_mode); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 049be076..b8d9851 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -1203,6 +1203,11 @@ static int hns3_get_coalesce(struct net_device *netdev, cmd->tx_max_coalesced_frames = tx_coal->int_ql; cmd->rx_max_coalesced_frames = rx_coal->int_ql; + kernel_coal->use_cqe_mode_tx = (priv->tx_cqe_mode == + DIM_CQ_PERIOD_MODE_START_FROM_CQE); + kernel_coal->use_cqe_mode_rx = (priv->rx_cqe_mode == + DIM_CQ_PERIOD_MODE_START_FROM_CQE); + return 0; } @@ -1372,6 +1377,8 @@ static int hns3_set_coalesce(struct net_device *netdev, struct hns3_enet_coalesce *tx_coal = &priv->tx_coal; struct hns3_enet_coalesce *rx_coal = &priv->rx_coal; u16 queue_num = h->kinfo.num_tqps; + enum dim_cq_period_mode tx_mode; + enum dim_cq_period_mode rx_mode; int ret; int i; @@ -1397,6 +1404,14 @@ static int hns3_set_coalesce(struct net_device *netdev, for (i = 0; i < queue_num; i++) hns3_set_coalesce_per_queue(netdev, cmd, i); + tx_mode = kernel_coal->use_cqe_mode_tx ? + DIM_CQ_PERIOD_MODE_START_FROM_CQE : + DIM_CQ_PERIOD_MODE_START_FROM_EQE; + rx_mode = kernel_coal->use_cqe_mode_rx ? + DIM_CQ_PERIOD_MODE_START_FROM_CQE : + DIM_CQ_PERIOD_MODE_START_FROM_EQE; + hns3_cq_period_mode_init(priv, tx_mode, rx_mode); + return 0; } @@ -1702,7 +1717,8 @@ static int hns3_set_tunable(struct net_device *netdev, ETHTOOL_COALESCE_USE_ADAPTIVE | \ ETHTOOL_COALESCE_RX_USECS_HIGH | \ ETHTOOL_COALESCE_TX_USECS_HIGH | \ - ETHTOOL_COALESCE_MAX_FRAMES) + ETHTOOL_COALESCE_MAX_FRAMES | \ + ETHTOOL_COALESCE_USE_CQE) static int hns3_get_ts_info(struct net_device *netdev, struct ethtool_ts_info *info) -- 2.8.1