Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp3710581rdb; Sun, 10 Dec 2023 18:13:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IG0nrKEBCM/w+pPYCKVp9H+jCR4LMdDza+3Kb5BcI9fHChaWR/elRA9eH4U9ixq7VK9iqvL X-Received: by 2002:a05:6830:114b:b0:6d9:ddbf:abd7 with SMTP id x11-20020a056830114b00b006d9ddbfabd7mr3944354otq.8.1702260784933; Sun, 10 Dec 2023 18:13:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702260784; cv=none; d=google.com; s=arc-20160816; b=zyHobmb6yu7OdDVE5BIK/UpbS9/cxMi+132dcFb0yfR17cMtKNkxdN50jaPs9hy0k5 E1d8UKXO4oczSrzDVQysk24o3d9hN05f1BScVbDqqtLoAT2CBl1Ym/HSew056wxmlGsU 5EIc1rIi6/FmyLMmum+BoT8CGfwHijmel0oAI8UHi7idYECJ2sjX4GKr521ur6cw2t8k yfGFjscktY/Q9MfZ0hSABoixN350EHXirAr1iFHRgC/yaGsr8C4tYYpn0fc1RvVAvBya TOBkYFHf51YQDWANmCR/MnZ/4xAVd+c0ZUndfp93+hXFLLpzjuB9IGI5LJr4rqVnjNbL zKdQ== 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=hEqn8KLtxE07r8DMJ9iJiKw+EpDj/wWLbC1Uur4xPKo=; fh=28Gsh8p/Rrgoh0ZJgxMb30MiNZzzGa/AucmCEg5DMJI=; b=bijOjCjPipCKLopVJ5Bwv56OYRGFdsUnig/UtgDhuGVnpTsgcMtt54POgfMr/61c5T oJY39E7iyMMLUI8ip/h3WPb3qhGP3MX+Uonnu2TMaKuPvwUpRFiQKVyfAS3ik1ZBmjvr wZ8KsReorcPYYQzVtHAk70UBvh7bZz5PAV56zyY6YJbYkOGOMWnmYpSzKZ86e8rHKlAX MdzFwTLNFklEPdjQZOr+iy5BZflgT4deIRo+H9cmmoa72TxN2JtUkA9h846XuDKeTGEx mqqC2QzQINj05d5CDoFH3sxPKigDFcX/0XkiarT7IjIetBXXQSKxjbLjiY/coK/aM89t ObLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id m22-20020aa78a16000000b006ce63dbd7f4si5229862pfa.142.2023.12.10.18.13.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 Dec 2023 18:13:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 2150C808ABAB; Sun, 10 Dec 2023 18:12:57 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230049AbjLKCMe (ORCPT + 99 others); Sun, 10 Dec 2023 21:12:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbjLKCMd (ORCPT ); Sun, 10 Dec 2023 21:12:33 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3F7B1F1; Sun, 10 Dec 2023 18:12:39 -0800 (PST) Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4SpQHh4tbGz14M0Z; Mon, 11 Dec 2023 10:12:32 +0800 (CST) Received: from kwepemm000007.china.huawei.com (unknown [7.193.23.189]) by mail.maildlp.com (Postfix) with ESMTPS id 9D0DB140136; Mon, 11 Dec 2023 10:12:37 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemm000007.china.huawei.com (7.193.23.189) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.35; Mon, 11 Dec 2023 10:12:37 +0800 From: Jijie Shao To: , , , , , CC: , , , , , Subject: [PATCH net-next 1/6] net: hns3: add support for page_pool_get_stats Date: Mon, 11 Dec 2023 10:08:11 +0800 Message-ID: <20231211020816.69434-2-shaojijie@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231211020816.69434-1-shaojijie@huawei.com> References: <20231211020816.69434-1-shaojijie@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemm000007.china.huawei.com (7.193.23.189) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Sun, 10 Dec 2023 18:12:57 -0800 (PST) From: Jian Shen Add support for page_pool_get_stats, then the hns3 driver can get page pool statistics by ethtool. Signed-off-by: Jian Shen Signed-off-by: Jijie Shao --- .../net/ethernet/hisilicon/hns3/hns3_enet.c | 5 +++ .../net/ethernet/hisilicon/hns3/hns3_enet.h | 1 + .../ethernet/hisilicon/hns3/hns3_ethtool.c | 38 ++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index b618797a7e8d..94b27332cc3f 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c @@ -4959,6 +4959,11 @@ static void hns3_alloc_page_pool(struct hns3_enet_ring *ring) } } +bool hns3_is_page_pool_enabled(void) +{ + return page_pool_enabled; +} + static int hns3_alloc_ring_memory(struct hns3_enet_ring *ring) { int ret; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h index acd756b0c7c9..75fd3638d724 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.h @@ -754,4 +754,5 @@ void hns3_cq_period_mode_init(struct hns3_nic_priv *priv, void hns3_external_lb_prepare(struct net_device *ndev, bool if_running); void hns3_external_lb_restore(struct net_device *ndev, bool if_running); +bool hns3_is_page_pool_enabled(void); #endif diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c index 682239f33082..38e796f61475 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_ethtool.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "hns3_enet.h" #include "hns3_ethtool.h" @@ -474,14 +475,19 @@ static int hns3_get_sset_count(struct net_device *netdev, int stringset) { struct hnae3_handle *h = hns3_get_handle(netdev); const struct hnae3_ae_ops *ops = h->ae_algo->ops; + int pp_stats_count = 0; if (!ops->get_sset_count) return -EOPNOTSUPP; switch (stringset) { case ETH_SS_STATS: +#ifdef CONFIG_PAGE_POOL_STATS + if (hns3_is_page_pool_enabled()) + pp_stats_count = page_pool_ethtool_stats_get_count(); +#endif return ((HNS3_TQP_STATS_COUNT * h->kinfo.num_tqps) + - ops->get_sset_count(h, stringset)); + ops->get_sset_count(h, stringset) + pp_stats_count); case ETH_SS_TEST: return ops->get_sset_count(h, stringset); @@ -549,6 +555,10 @@ static void hns3_get_strings(struct net_device *netdev, u32 stringset, u8 *data) switch (stringset) { case ETH_SS_STATS: +#ifdef CONFIG_PAGE_POOL_STATS + if (hns3_is_page_pool_enabled()) + buff = page_pool_ethtool_stats_get_strings(buff); +#endif buff = hns3_get_strings_tqps(h, buff); ops->get_strings(h, stringset, (u8 *)buff); break; @@ -596,6 +606,28 @@ static u64 *hns3_get_stats_tqps(struct hnae3_handle *handle, u64 *data) return data; } +#ifdef CONFIG_PAGE_POOL_STATS +static u64 *hns3_ethtool_pp_stats(struct hnae3_handle *handle, u64 *data) +{ + struct hns3_nic_priv *priv = handle->priv; + int ring_num = handle->kinfo.num_tqps; + struct page_pool_stats stats = {0}; + struct page_pool *page_pool; + int i; + + if (!hns3_is_page_pool_enabled()) + return data; + + for (i = 0; i < ring_num; i++) { + page_pool = priv->ring[i + ring_num].page_pool; + if (page_pool) + page_pool_get_stats(page_pool, &stats); + } + + return page_pool_ethtool_stats_get(data, &stats); +} +#endif + /* hns3_get_stats - get detail statistics. * @netdev: net device * @stats: statistics info. @@ -617,6 +649,10 @@ static void hns3_get_stats(struct net_device *netdev, return; } +#ifdef CONFIG_PAGE_POOL_STATS + p = hns3_ethtool_pp_stats(h, p); +#endif + h->ae_algo->ops->update_stats(h); /* get per-queue stats */ -- 2.30.0