Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp24011pxb; Tue, 12 Apr 2022 15:44:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTGWbKcJT3F3wJHfGfYMKLwdphei0XJMT/H1CA3RKhoHqRM9WTSe3fF4q7UeXK1j/Yfrbu X-Received: by 2002:a17:90b:4c8f:b0:1c7:7bc0:954a with SMTP id my15-20020a17090b4c8f00b001c77bc0954amr7482213pjb.214.1649803461648; Tue, 12 Apr 2022 15:44:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649803461; cv=none; d=google.com; s=arc-20160816; b=APkcwaJUZgHp6Khi10sgwTPnUnj2oJqu3Mv+kcbb0sLeyQaLYp+5ZkTP4jWg3zSbE/ PZoCWEMG/PZwn5n1qtzxpxoLdE680K/Pas4qlZobCHU1B/lsF91pc5kwS0WNfNPMJbtZ 6U1OMhgF1OwkmzJhFHCmhHln68wSKka9mwNQdHWbpP82cv1OIY7twegyKkTWxhk3RsWq ES+npRiIxq7kwjQehgkjfmsaSqXEV/KLcSVUhFYcCAnYzUWhWxWnvrC15nvqTHpMlFmc oXpwQZ4+5C+KDhDLjyw7Z3grm0+yAKAEd53n9znz0YnCRac+b+jOWvVXbvyVObwLSS/d lH6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3exgA2ykn6lrQCoiq9LZGJuTmamupKut+B9TNCer0cw=; b=LFI9Cv/J9dLPrUj/y1RUiT+ImIHJTjUd/xuJmIyNzWMAsY56eOi7nXLpRPUfbOcI3K 8CFesZWejZzRdT7rJmrbXPn3EyknZwCH1TVbkUILIrEPziauCH6f3l5ev3v9pMAc0D7K ciLvk6tiqilGqhwhjnokRd1mAHMdEp1WB4WkMM/R19/SqwNp6aOOAREo1MolBPhJ0UC+ lguvfzAw72f1ciZ9/oR9SjO3l330TD9HAZaxxM5kw46vhHxuHM70wvCzDOKQKzIdX6Wt s03Y4+2C+q0DaF9xTVgsVHO3PmiXioJ0jw96ADoLfQLI1XXn24VchdiBpaXa14cxQgIg fvLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q7-20020a170902dac700b00153b2d16652si925444plx.602.2022.04.12.15.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Apr 2022 15:44:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 76C5B7305E; Tue, 12 Apr 2022 14:25:58 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243623AbiDLCJl (ORCPT + 99 others); Mon, 11 Apr 2022 22:09:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60130 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242379AbiDLCJV (ORCPT ); Mon, 11 Apr 2022 22:09:21 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C8857338BF; Mon, 11 Apr 2022 19:07:04 -0700 (PDT) Received: from kwepemi500007.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KcpxJ1qR7zdZh4; Tue, 12 Apr 2022 10:06:28 +0800 (CST) Received: from kwepemm600016.china.huawei.com (7.193.23.20) by kwepemi500007.china.huawei.com (7.221.188.207) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 12 Apr 2022 10:07:02 +0800 Received: from localhost.localdomain (10.67.165.24) by kwepemm600016.china.huawei.com (7.193.23.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Tue, 12 Apr 2022 10:07:01 +0800 From: Guangbin Huang To: , , , CC: , , , , , Subject: [PATCH net-next v2 3/3] net: hns3: add tx push support in hns3 ring param process Date: Tue, 12 Apr 2022 10:01:21 +0800 Message-ID: <20220412020121.14140-4-huangguangbin2@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20220412020121.14140-1-huangguangbin2@huawei.com> References: <20220412020121.14140-1-huangguangbin2@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.24] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To kwepemm600016.china.huawei.com (7.193.23.20) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jie Wang This patch adds tx push param to hns3 ring param and adapts the set and get API of ring params. So users can set it by cmd ethtool -G and get it by cmd ethtool -g. Signed-off-by: Jie Wang Signed-off-by: Guangbin Huang --- .../ethernet/hisilicon/hns3/hns3_ethtool.c | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index f4da77452126..9f4111fd2986 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -664,6 +664,8 @@ static void hns3_get_ringparam(struct net_device *netdev, param->tx_pending = priv->ring[0].desc_num; param->rx_pending = priv->ring[rx_queue_index].desc_num; kernel_param->rx_buf_len = priv->ring[rx_queue_index].buf_size; + kernel_param->tx_push = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, + &priv->state); } static void hns3_get_pauseparam(struct net_device *netdev, @@ -1120,6 +1122,30 @@ static int hns3_change_rx_buf_len(struct net_device *ndev, u32 rx_buf_len) return 0; } +static int hns3_set_tx_push(struct net_device *netdev, u32 tx_push) +{ + struct hns3_nic_priv *priv = netdev_priv(netdev); + struct hnae3_handle *h = hns3_get_handle(netdev); + struct hnae3_ae_dev *ae_dev = pci_get_drvdata(h->pdev); + u32 old_state = test_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state); + + if (!test_bit(HNAE3_DEV_SUPPORT_TX_PUSH_B, ae_dev->caps) && tx_push) + return -EOPNOTSUPP; + + if (tx_push == old_state) + return 0; + + netdev_dbg(netdev, "Changing tx push from %s to %s\n", + old_state ? "on" : "off", tx_push ? "on" : "off"); + + if (tx_push) + set_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state); + else + clear_bit(HNS3_NIC_STATE_TX_PUSH_ENABLE, &priv->state); + + return 0; +} + static int hns3_set_ringparam(struct net_device *ndev, struct ethtool_ringparam *param, struct kernel_ethtool_ringparam *kernel_param, @@ -1139,6 +1165,10 @@ static int hns3_set_ringparam(struct net_device *ndev, if (ret) return ret; + ret = hns3_set_tx_push(ndev, kernel_param->tx_push); + if (ret) + return ret; + /* Hardware requires that its descriptors must be multiple of eight */ new_tx_desc_num = ALIGN(param->tx_pending, HNS3_RING_BD_MULTIPLE); new_rx_desc_num = ALIGN(param->rx_pending, HNS3_RING_BD_MULTIPLE); @@ -1858,7 +1888,8 @@ static int hns3_set_tunable(struct net_device *netdev, ETHTOOL_COALESCE_MAX_FRAMES | \ ETHTOOL_COALESCE_USE_CQE) -#define HNS3_ETHTOOL_RING ETHTOOL_RING_USE_RX_BUF_LEN +#define HNS3_ETHTOOL_RING (ETHTOOL_RING_USE_RX_BUF_LEN | \ + ETHTOOL_RING_USE_TX_PUSH) static int hns3_get_ts_info(struct net_device *netdev, struct ethtool_ts_info *info) -- 2.33.0