From patchwork Sat Jan 29 02:03:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 12729356 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4BDCDC433F5 for ; Sat, 29 Jan 2022 02:04:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352133AbiA2CEo (ORCPT ); Fri, 28 Jan 2022 21:04:44 -0500 Received: from mail-dm6nam12on2094.outbound.protection.outlook.com ([40.107.243.94]:28512 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1352128AbiA2CEj (ORCPT ); Fri, 28 Jan 2022 21:04:39 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j1CZWV0HayDLxj89Hz+HYaDDDCI1o/o0UOL6zAay84g8OLs/Vo/Vn8crJcWwFz1E78yhx3RMcjXl4D2lHkHSk1HGwiZT4mvAUV+XMI2n8b9bEFKq1mlXcWuFwtptTGTDZ8F8B8jfDCU7qSM/e2VlQACo3PsmQNzHLf+N0W5I3t/bkrhsZKSK7bMJtdX38dIJPYX4efu4+DzkOKWgnfUNatCMgKJWeSjF1WeWZogFLfuK4OsUeJFnctBAYmvxfrsNjfwq8qAFOzN4d2HYc01ahaP4IIzIYJELX/fweebnIq29Ib4otao+9w3AYTQ+7fprgBHANwN7/fO6IF+UyQoyZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=uif6Rm8ZeDHR0oJ0vqxYU3q+9KVJKZqYE8VZtII7lho=; b=LA1R2j5PshmS91SE8RURWPfOqXp69hTM17UwCohNwN6Snim+Bpb1eevMY6Zr1W5NRTEo++gGwOmQf8t2qqOs3k7GCc60SxMNs238fpWZqjUu+KS5+cXdIIDwqvDpfETU760TBC7Fwvh112hibeNo+V5ZK2djnB2aty8iRAzh9gsHWaw9lpgmTGKqO9rjVpmi714sZyt6pDE5X5nQU+MJz/0qE7/WM5u6jjozYB2vSVvUSIESBGnlRf3hD/sRuDzguFBGrEObMQ4LkVZ3Jz/QTCjwYbRZRFO3n5f2U7Qj2rVJyOfnyx1NqI/0/hAgNqbX7CIRmR4aLBVMZE30rn4yrA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uif6Rm8ZeDHR0oJ0vqxYU3q+9KVJKZqYE8VZtII7lho=; b=R0e3VasVhk/Ja8uRfQH8+VQlHUXbg9bypMm9vWWzaR50WYxdEzjiw6oG1c4hTsq/ttK9UNrGr+En1IlfeQgwqWy2QocQmp261F4h/6qCPbdPK7c1cTccGgaX1/Pbsze3iHIoEOxEXGhpfwBXQ0tSfChC5CxrNew0cA2HWalPSRI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1340.namprd21.prod.outlook.com (2603:10b6:5:175::19) by MWHPR21MB0191.namprd21.prod.outlook.com (2603:10b6:300:79::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.7; Sat, 29 Jan 2022 02:04:33 +0000 Received: from DM6PR21MB1340.namprd21.prod.outlook.com ([fe80::1d9b:cd14:e6bb:43fd]) by DM6PR21MB1340.namprd21.prod.outlook.com ([fe80::1d9b:cd14:e6bb:43fd%6]) with mapi id 15.20.4951.007; Sat, 29 Jan 2022 02:04:33 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, kys@microsoft.com, sthemmin@microsoft.com, paulros@microsoft.com, shacharr@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, linux-kernel@vger.kernel.org Subject: [PATCH net-next, 1/3] net: mana: Add counter for packet dropped by XDP Date: Fri, 28 Jan 2022 18:03:36 -0800 Message-Id: <1643421818-14259-2-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1643421818-14259-1-git-send-email-haiyangz@microsoft.com> References: <1643421818-14259-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0311.namprd03.prod.outlook.com (2603:10b6:303:dd::16) To DM6PR21MB1340.namprd21.prod.outlook.com (2603:10b6:5:175::19) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: dca99126-e3e2-4655-23f8-08d9e2cbb1a0 X-MS-TrafficTypeDiagnostic: MWHPR21MB0191:EE_ X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-AtpMessageProperties: SA|SL X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1122; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: O3Zlofd5jddnT24udcIVbKM3dquxdTtYwS55Vsb2uPrtygOabJKS8I415FVFQyw6r6lH6H9u4Fx3gliQawfDBSwhDmOIsrB432SNMsisPwDGDEF8hUI4UdQArgbbf3ZEi4POSEMoWDyw2TU+Fht5dHXfjAKo4V+j/1nZ1hfmS5iJe6I84faJOVIoTSk7gp/pw3x2SSgCkef1LgaJ6X917+OdGhWINfuPBb4kB68IeIe1cq7+1beYOwCFbWYHf6+CBB6gvhVYVRd9XhLjGLDVm4Q9TLTymrsvn8Sn6WnDj7xIwINlO9ZAxqJHC+9q67MsZCwTb8NjRpOB12iiuBokDjg+6D+xTN88WaSHwJnmN3AdOc7/XQKirQJZ434FxRCHFyVOEDYLo969hS11cLiaSXiUGYhryepacK5sdrrx44z8fw63T6ICK/f3qDesA42YxUCC8857J/HCM/T6mKGsH1EnuRzPpx9RXJZDDG7xKjwY1I1WYu8w2qvlO8eX9IO36lOPIG1PIdKlanywFsLHCP4X8BVTbT5DOtnvKAqmEsK4yM7U7IbUx+qVQZLgOBDR1DIjkyMPJpRK2eEn1oAX8nd2tZzBYhIJtvojzcOe2MxXCm5vsE2Q/s+xKE2nm8ViN6bQzNRfgGJQS8iNFW0QNuWThNqSOD9qvD2Fw9jOeR/KzhCkze0skciumHTQSVaTDCFu+Kq8h1HHQtE/JOgi4LzsZBrVjSv7VxtIbm2Jr/5Dz0A1y6OgFLRX36cx8AFK X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1340.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66556008)(66946007)(4326008)(66476007)(8676002)(8936002)(5660300002)(38350700002)(38100700002)(82950400001)(316002)(82960400001)(186003)(6512007)(6506007)(26005)(2906002)(2616005)(508600001)(36756003)(7846003)(52116002)(83380400001)(6486002)(10290500003)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: oGSyA8aynNnfBL89n3TMJ5gh7Bo/yWLqtCWfLMkW1Kg+h8PUuDsQskQ0Go90px0ZlCb//7vjInOBcnTMJelggXPAprU0Ue0xT/Ug4IoS8pO+UfHuNP3Pc9U0frtZBt0dFhi/Mm7eyCtY48nz2SAH53POxWfF+m2LewtbvHpGmF0NkHL+145yjJ/rG9o1+mp+nzYC0Wu3GWYREIDMFSVeGIymw0mnLCu0PoAcXetPNH8RTfkVopvEBG/t+9Nt4tdzr+N5jl01EuXpPLNjqbOo5q4avQoaoPNfIandlHBYODGMkKa5254hOux0ENv7QmXy4B/+3vkyCYDIp5srqZjXL3KU9i4T3I3PqmkV41j17c+i8mVr3irKQ0pDNvim+s1g7z1Ms0XqczgzHtVyCCXv3lys2yUaAZen614808c8/K0q3N9D2RuDw9eGruqwz4EG9NucMHGAFrGa75r7wixeJ1VgMORsu8ReIV6pg82QprLPX8eoQHP9eFYRf1JKIctDf9rCNwSylAp7oewHt4wJAIto0Qp3emNJcMIS7UhZJWQrVcy9zXqqU2Rzwac0t8e1UJKThiKDsB4qwtm++YEvOqXsYw+TkbpfxJxlA1oVzFNAsiwIWf1wmc+cOtVbDV75NevV2r5NQ/pMyEc1MADi/1UYuTJ4AieSCTcUSgORGmL+pBLzWwJWI3Zhaqej3MSQwOh3ytOZJLRvTpoCXoaO6AOOHueQnAG1PJ2qT+YAHCasI2Acwr7H8uHV9+2w8rWzGi299S1kXu6dpFqj1uoo4ib8DvaJe6T53ApH2eyqMeVrDo5wtzZqG60CKhwVz0WTYxqrQa7amnQDEQmyhtk5lRSj8v1ZDwywqK+BSPnUAOYEHyiXsvdiBV/AkdvcRk1IuvhrCjhlKZMqzdol4vFAU4ajQyhYP69l8OQWhoatzeVe7e8Em5HPbfzqG+LAN4goEiWaVjDoD09BqsKIHimlY89UuoVhmkJ168pI8Bp6jradyacavv9jmWubjJsrAASxB5ddXhR5TC/lG+36Ac9ivjA4T1PUM2viOG+PwwwsdSw7CVwM2wziliqjvswUQql4TtLrqRyi9ko7kbYsvfqm867abzUFYRhg1vUyN5ZLWQIg3Wp+jjBsICQFTDf9/rRpGwPOx2PH8efM3I0e13uP6iOvrSj2ts4/7omqqD5l/UMOt5DnGrJRJb3tv9HAwtWUWh5KeCzJGb2D0wpINY/aEU1Q5ChFrn/95wFwkNs5TLaTOyShYBtPHHl6IP4tIVDSxyRrsXtJGii/vzXkwZtSfePLaAFvUW4CxdssyTU61sPhTRmUuJ0Zajd0EHFsbTQ0iEFlh2RhFk0wyOl+kmhsB7kRz7tibzc1tJf2gpK1UnI5o692OyacQDu8wLMFlOJz51Ngd4B+3xzwWcI9MYfLhBVo9MkPCzNOzRMvz17npLVKj3S38vzabRXHJli8XgQe89zBW7VBR5vsKDLCMNHDEu02dx3vJN+WnQI9BrOqevn0fFcxLOKMBpOpY3nL6bat6S4Pq9eA+QM82IbvdTll+fmupfSjq8qP9//pKx0mrMvqKi0JXAsEude9xcdRi84nSPhzkX1wEQ9SK+1gjHSRLwzoYfyw6reGnr/YeYNruaw= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: dca99126-e3e2-4655-23f8-08d9e2cbb1a0 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1340.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2022 02:04:33.8285 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: geHeoVTSHmJ2C8rEAK6MLzvrs7BOG4Ua6VyjYl8SziTut3q2ZZt3Cnfa+kfIBcaS+zIi/p1DEN/I0cjVhg0sEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0191 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This counter will show up in ethtool stat data. Signed-off-by: Haiyang Zhang --- drivers/net/ethernet/microsoft/mana/mana.h | 13 +++++-- drivers/net/ethernet/microsoft/mana/mana_en.c | 35 +++++++++++-------- .../ethernet/microsoft/mana/mana_ethtool.c | 30 +++++++++------- 3 files changed, 49 insertions(+), 29 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana.h b/drivers/net/ethernet/microsoft/mana/mana.h index 9a12607fb511..66fc98d7e1d6 100644 --- a/drivers/net/ethernet/microsoft/mana/mana.h +++ b/drivers/net/ethernet/microsoft/mana/mana.h @@ -48,7 +48,14 @@ enum TRI_STATE { #define MAX_PORTS_IN_MANA_DEV 256 -struct mana_stats { +struct mana_stats_rx { + u64 packets; + u64 bytes; + u64 xdp_drop; + struct u64_stats_sync syncp; +}; + +struct mana_stats_tx { u64 packets; u64 bytes; struct u64_stats_sync syncp; @@ -76,7 +83,7 @@ struct mana_txq { atomic_t pending_sends; - struct mana_stats stats; + struct mana_stats_tx stats; }; /* skb data and frags dma mappings */ @@ -298,7 +305,7 @@ struct mana_rxq { u32 buf_index; - struct mana_stats stats; + struct mana_stats_rx stats; struct bpf_prog __rcu *bpf_prog; struct xdp_rxq_info xdp_rxq; diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 498d0f999275..878c3d9bb39d 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -136,7 +136,7 @@ int mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) bool ipv4 = false, ipv6 = false; struct mana_tx_package pkg = {}; struct netdev_queue *net_txq; - struct mana_stats *tx_stats; + struct mana_stats_tx *tx_stats; struct gdma_queue *gdma_sq; unsigned int csum_type; struct mana_txq *txq; @@ -299,7 +299,8 @@ static void mana_get_stats64(struct net_device *ndev, { struct mana_port_context *apc = netdev_priv(ndev); unsigned int num_queues = apc->num_queues; - struct mana_stats *stats; + struct mana_stats_rx *rx_stats; + struct mana_stats_tx *tx_stats; unsigned int start; u64 packets, bytes; int q; @@ -310,26 +311,26 @@ static void mana_get_stats64(struct net_device *ndev, netdev_stats_to_stats64(st, &ndev->stats); for (q = 0; q < num_queues; q++) { - stats = &apc->rxqs[q]->stats; + rx_stats = &apc->rxqs[q]->stats; do { - start = u64_stats_fetch_begin_irq(&stats->syncp); - packets = stats->packets; - bytes = stats->bytes; - } while (u64_stats_fetch_retry_irq(&stats->syncp, start)); + start = u64_stats_fetch_begin_irq(&rx_stats->syncp); + packets = rx_stats->packets; + bytes = rx_stats->bytes; + } while (u64_stats_fetch_retry_irq(&rx_stats->syncp, start)); st->rx_packets += packets; st->rx_bytes += bytes; } for (q = 0; q < num_queues; q++) { - stats = &apc->tx_qp[q].txq.stats; + tx_stats = &apc->tx_qp[q].txq.stats; do { - start = u64_stats_fetch_begin_irq(&stats->syncp); - packets = stats->packets; - bytes = stats->bytes; - } while (u64_stats_fetch_retry_irq(&stats->syncp, start)); + start = u64_stats_fetch_begin_irq(&tx_stats->syncp); + packets = tx_stats->packets; + bytes = tx_stats->bytes; + } while (u64_stats_fetch_retry_irq(&tx_stats->syncp, start)); st->tx_packets += packets; st->tx_bytes += bytes; @@ -986,7 +987,7 @@ static struct sk_buff *mana_build_skb(void *buf_va, uint pkt_len, static void mana_rx_skb(void *buf_va, struct mana_rxcomp_oob *cqe, struct mana_rxq *rxq) { - struct mana_stats *rx_stats = &rxq->stats; + struct mana_stats_rx *rx_stats = &rxq->stats; struct net_device *ndev = rxq->ndev; uint pkt_len = cqe->ppi[0].pkt_len; u16 rxq_idx = rxq->rxq_idx; @@ -1007,7 +1008,7 @@ static void mana_rx_skb(void *buf_va, struct mana_rxcomp_oob *cqe, act = mana_run_xdp(ndev, rxq, &xdp, buf_va, pkt_len); if (act != XDP_PASS && act != XDP_TX) - goto drop; + goto drop_xdp; skb = mana_build_skb(buf_va, pkt_len, &xdp); @@ -1048,9 +1049,15 @@ static void mana_rx_skb(void *buf_va, struct mana_rxcomp_oob *cqe, u64_stats_update_end(&rx_stats->syncp); return; +drop_xdp: + u64_stats_update_begin(&rx_stats->syncp); + rx_stats->xdp_drop++; + u64_stats_update_end(&rx_stats->syncp); + drop: free_page((unsigned long)buf_va); ++ndev->stats.rx_dropped; + return; } diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c index c3c81ae3fafd..e1ccb9bf62de 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c @@ -23,7 +23,7 @@ static int mana_get_sset_count(struct net_device *ndev, int stringset) if (stringset != ETH_SS_STATS) return -EINVAL; - return ARRAY_SIZE(mana_eth_stats) + num_queues * 4; + return ARRAY_SIZE(mana_eth_stats) + num_queues * 5; } static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data) @@ -46,6 +46,8 @@ static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data) p += ETH_GSTRING_LEN; sprintf(p, "rx_%d_bytes", i); p += ETH_GSTRING_LEN; + sprintf(p, "rx_%d_xdp_drop", i); + p += ETH_GSTRING_LEN; } for (i = 0; i < num_queues; i++) { @@ -62,9 +64,11 @@ static void mana_get_ethtool_stats(struct net_device *ndev, struct mana_port_context *apc = netdev_priv(ndev); unsigned int num_queues = apc->num_queues; void *eth_stats = &apc->eth_stats; - struct mana_stats *stats; + struct mana_stats_rx *rx_stats; + struct mana_stats_tx *tx_stats; unsigned int start; u64 packets, bytes; + u64 xdp_drop; int q, i = 0; if (!apc->port_is_up) @@ -74,26 +78,28 @@ static void mana_get_ethtool_stats(struct net_device *ndev, data[i++] = *(u64 *)(eth_stats + mana_eth_stats[q].offset); for (q = 0; q < num_queues; q++) { - stats = &apc->rxqs[q]->stats; + rx_stats = &apc->rxqs[q]->stats; do { - start = u64_stats_fetch_begin_irq(&stats->syncp); - packets = stats->packets; - bytes = stats->bytes; - } while (u64_stats_fetch_retry_irq(&stats->syncp, start)); + start = u64_stats_fetch_begin_irq(&rx_stats->syncp); + packets = rx_stats->packets; + bytes = rx_stats->bytes; + xdp_drop = rx_stats->xdp_drop; + } while (u64_stats_fetch_retry_irq(&rx_stats->syncp, start)); data[i++] = packets; data[i++] = bytes; + data[i++] = xdp_drop; } for (q = 0; q < num_queues; q++) { - stats = &apc->tx_qp[q].txq.stats; + tx_stats = &apc->tx_qp[q].txq.stats; do { - start = u64_stats_fetch_begin_irq(&stats->syncp); - packets = stats->packets; - bytes = stats->bytes; - } while (u64_stats_fetch_retry_irq(&stats->syncp, start)); + start = u64_stats_fetch_begin_irq(&tx_stats->syncp); + packets = tx_stats->packets; + bytes = tx_stats->bytes; + } while (u64_stats_fetch_retry_irq(&tx_stats->syncp, start)); data[i++] = packets; data[i++] = bytes; From patchwork Sat Jan 29 02:03:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 12729357 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D21AFC433FE for ; Sat, 29 Jan 2022 02:04:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352145AbiA2CEq (ORCPT ); Fri, 28 Jan 2022 21:04:46 -0500 Received: from mail-dm6nam12on2094.outbound.protection.outlook.com ([40.107.243.94]:28512 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1344799AbiA2CEn (ORCPT ); Fri, 28 Jan 2022 21:04:43 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=heXeX4l0G3cpntZwY5IArn3y9WezJubHjSL7N6EgxCTePALcqrzJ5AQaEWWmmqTAFz5ZBaEAcp+6xHKYvBQODaZ88/h62ljHJ4AkTYrCV94cP7C91sSSL5h+AwN45qEyHFw+k51lke/m9QAeAmyjgrWEPTpPbj72ceYP5GayE+5RXJ5Ql2LBU+Db4WbL4iGjfDpscSwGwUIN87eNVR5KdZmEuNzCYv+RfFdTbknM+nC1Y5X7u6eZlWNnQIPPOgwWfVhoQT2Q1JBqR7pQxILzMVpbFEVUFhCdFx8tOQK9skpJhabhvIV4v/5EU7v3qmC8yLZ7cmG2ri1wM4cthkvBhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wT4VPGJxtAHLvWhPlhfrmp7aNRFbCRFErgdIdo/ZqCY=; b=kRQHq7xRlDC/Dy1fW146jRjbvs7AcbpZaT+InzxRAGpvy2oiIuFWoB+okLmtygG9lW2aDCAKAMGXR1owW+A+7p2J+8IxubcVTDSLZ8j2uXKnDGbu+7227MLZKdgxLk3x/mydD/ADFpOdPyYWqhmsFLPJrLld6EISkntSLjlgcG+yb7Pmx027DSudGPlAGEFwT5v6q19a1MS5oJwLMZ6zrie+OrQHgTvFSdK7JCQlKBYRtVFJUBNWI6zp7mzd4nTZKeIT1gH1pwpDgmARi3XySKLhxD3S/wx27BpDR11DcXOai5DFwWFr/+9rmaKZgtwGEilF2+DbzM1Ovt3b6uy1Wg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wT4VPGJxtAHLvWhPlhfrmp7aNRFbCRFErgdIdo/ZqCY=; b=U9Yg3tQYGtmCLpqECK4uzky4SqK8jMhsLfUQhmgRHss7Txg5Jp9rSWy7xpUzUkvcF/m8fXQlvBt+M2ydLWpfVb+Ip+K05AYxoQPQu/coS7uWu1Wi2Udx51MlW3fNwRIvNZkWBY46lF711vGtW38FI2Jxrju/1CZNuYXyDdLF7ew= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1340.namprd21.prod.outlook.com (2603:10b6:5:175::19) by MWHPR21MB0191.namprd21.prod.outlook.com (2603:10b6:300:79::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.7; Sat, 29 Jan 2022 02:04:37 +0000 Received: from DM6PR21MB1340.namprd21.prod.outlook.com ([fe80::1d9b:cd14:e6bb:43fd]) by DM6PR21MB1340.namprd21.prod.outlook.com ([fe80::1d9b:cd14:e6bb:43fd%6]) with mapi id 15.20.4951.007; Sat, 29 Jan 2022 02:04:37 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, kys@microsoft.com, sthemmin@microsoft.com, paulros@microsoft.com, shacharr@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, linux-kernel@vger.kernel.org Subject: [PATCH net-next, 2/3] net: mana: Add counter for XDP_TX Date: Fri, 28 Jan 2022 18:03:37 -0800 Message-Id: <1643421818-14259-3-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1643421818-14259-1-git-send-email-haiyangz@microsoft.com> References: <1643421818-14259-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0311.namprd03.prod.outlook.com (2603:10b6:303:dd::16) To DM6PR21MB1340.namprd21.prod.outlook.com (2603:10b6:5:175::19) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f7fe4f13-a20e-4974-ad4a-08d9e2cbb3a9 X-MS-TrafficTypeDiagnostic: MWHPR21MB0191:EE_ X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-AtpMessageProperties: SA|SL X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:2582; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nj8b0rLI181suoMN0pDUiRZtUABCaZ7BJ5BbGaF8fQInBhIB9Cn20spmsAxhP94+hhwlXwQGj/tYavYII/aIzJPy+gG+bEIhPTwE13rcdohnvR1AfhdqTciX1rj5TAe8/CSmpalIRhVVIVnrpkfqOINRgZhCCpn43xZbaPjuBrV9K8FOFR9SkRPSYlQCWcP02T5BYz+ONihvMep4mPewUQcwUV637Jo04xpVdaw2HjKVS6TTr0GNzX0iXUDy+blxtQGPHpyiOWvwtbKxfvo6AxPW/x8bmihm4QhLO9Cnxb9RxubObz1EvDmn9Frydn6kbepyY+u0itYAYtO+C+LBfbfxxP4codMwTgyUsG4fN1uN310/8Az1FOlhgpuzLopMriQGNOl9RyOzhDX4BUuioEXK4wvyJykDIlFINJc2dG4Amdj9JeN91nbMVGHCHcbVAI3/weUYtolYLTkCC8pRXIXrpoJH0tYbhR1LbRs4lM+0CUuNQ+AiwkUItU4TxKeM+cB2LIsOEl1o4kuZyvpa+5pJGkZhGrcBYJXkBOGwamdHPBSvWJFWa2TWj6Qv9tJ+EA0Go9qZYDM6tKxgSLlT7Mx05kS1hBBdnXxjuPSkr3zlbnJD3MOcNDLejgh1lmnSzOisqrrpUwHdJ8NZQC55I8F71U5zyUeLWFlWjHsVwS79DzvNH1fruqS9mSfXET1cDNp72VmBtmrfcgQtyK0k+zYOiw+uzNdW/leBpETsk0ZZC17LyPxg9uPF5HGpvapT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1340.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66556008)(66946007)(4326008)(66476007)(8676002)(8936002)(5660300002)(38350700002)(38100700002)(82950400001)(316002)(82960400001)(186003)(6512007)(6506007)(26005)(2906002)(2616005)(508600001)(36756003)(7846003)(52116002)(83380400001)(6486002)(10290500003)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: F281lrCiyBUdVfdIOqUImpPJ0tvHMlpxOPT2atrD7yQa5LAasZNrVu6pNeq8axw30AEl1EpReqfPX6GeHrQ2CQyHV3clwR8l9nsadPAbURFSjYwyYqNULypo0v/R7+xndgvBZIeKF6Uqc8wNwgSnjwcEZx07IvMwcZSxXALTQzZuOC44bunwM9dFARz4F9Pl3+oXiLoRcY2g0wiX5vPbLWdwzDSRqq/aVitxxxoUo2TQq9Y55ccbwA0nnCg5q1EQIgyHYiWmnqgqNznuYE+omzHcdx/aq/J/sQGjxDIObS5Jo5dAahCjIGERoLCr5zndcZ6sR1w/dcNs3WGyL2OKCOav90/Q3N4ZqK0AJgAGfEztdKgiHiFydm54MrVjhwLgOBwiUDjzrIbqSUBc1dGFKtzMttRHSqKJbrGFzWKUuBEBHcXIrlmb/HumJy083r4G4TZCSI8R8uVYuZe8huvJWkV5kJyZrJSSAaljj4X6ubdEHyfiP/mXakjbyyZd+vyJYnr6hduxQoqCWdCEOtvkwUjMSXG0ugjdCxdE4DIvHWhVSFA4+Ip2hf9olkK2vDZCpska5jjUk6wmomzohqYXwBip7NDNXvPUcIIr4lVdzLwMaRCa9WWfcQdBKpqCyvsRbEMfiJ47zRqiov8ABligUDbGz3kInq/2SZDFXZfdfkHdhrptWeBa0oEblm/tBbWprzasywGdxhCqA3Et4meJaJBp2ex8Ztq4Bw0+6BusYYouu8gk82QlhgoGnWJKOWGtyhhkkWJvn5TcCpmoxD18qkJMcSxrMAgGgiYv6Wh6JiI6wFEgBindKSwL4yZhm7SKO8JnkopyIiN+zS71P2MHihN5o6CVLQLaCcnsjjAtxLLUeH6H/Aq46uqESpSuy7tDAw3KbRA3uouXcntTuxXe/qmn3L5PqMcnD88HXVV2krAZWU13hGH7iK1Z3w/NUH5RY30gc7hsJ+COw38nnecf/+5hZaVeU9T44wZ+vyYXLurRzLp8el1TYNvk+h5U3x06Y16lM8xouHRr4sPjcufMmFpjWahkdhli7mA1YqNY37HZsEMYNBCH6WBG6CdD2HpGHDQBAzGMYFdGK+41l/0vNKyzfcZPqtgbuVacbULe9O/c9J5t8exv29ikc4V1NEqYhKqTguD8ZXh0vLZZ202YLfg+psWs8pQqQvDgISeo9gGAll343iJVsSPCQdN2L1oGhgQLtLrsYZXskQpO6M9soViKQmJmHeaDuYJiQaus5zQwSRjtCEWgrjym6BRIgupWu0H95zi8zvJcpS63DNhQqV1t8Dmk9kcaAGLGul1PXLyAYrhfTEVIElMU8flb0uZMF3Njx6+YOdNkCGm2H4tMug4AFc21ICxwKZ9E/1DAq0kok6rErSYxORgjlYAW4EMgMyWgR8u+hb++4Mm6y9z/tdMfFiLldxi9DkStVb8ugRxouO3HhrhoVSJDhAWKwxPa55TgoH47wk5jewkHd7+snsjU84lC+y0igYEVzXsjkeZWmbXHxjaAtg09yixX/tKNxJxjRg9Yng9qjHrJ0imn4mUCMBKbSUwgBlOSqVnsnr9726AMK5gWHzyQQe8w/T6EHbZcUumxzz0JBqNazSqlJAYTX+/EPCwhyGI4TSvf1Wc= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: f7fe4f13-a20e-4974-ad4a-08d9e2cbb3a9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1340.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2022 02:04:37.1665 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: JyC5lwn7gdcoMtcbBJc7v7iiHjSR/C/Dn0fgzRdinpYLXWAw6khTje9nvuR1Q7GVLxEet7A0bMPl2OouPBdmXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0191 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This counter will show up in ethtool stat. It is the number of packets received and forwarded by XDP program. Signed-off-by: Haiyang Zhang --- drivers/net/ethernet/microsoft/mana/mana.h | 1 + drivers/net/ethernet/microsoft/mana/mana_en.c | 12 ++++++++---- drivers/net/ethernet/microsoft/mana/mana_ethtool.c | 7 ++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana.h b/drivers/net/ethernet/microsoft/mana/mana.h index 66fc98d7e1d6..8ead960f898d 100644 --- a/drivers/net/ethernet/microsoft/mana/mana.h +++ b/drivers/net/ethernet/microsoft/mana/mana.h @@ -52,6 +52,7 @@ struct mana_stats_rx { u64 packets; u64 bytes; u64 xdp_drop; + u64 xdp_tx; struct u64_stats_sync syncp; }; diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 878c3d9bb39d..12067bf5b7d6 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -1035,6 +1035,14 @@ static void mana_rx_skb(void *buf_va, struct mana_rxcomp_oob *cqe, skb_set_hash(skb, hash_value, PKT_HASH_TYPE_L3); } + u64_stats_update_begin(&rx_stats->syncp); + rx_stats->packets++; + rx_stats->bytes += pkt_len; + + if (act == XDP_TX) + rx_stats->xdp_tx++; + u64_stats_update_end(&rx_stats->syncp); + if (act == XDP_TX) { skb_set_queue_mapping(skb, rxq_idx); mana_xdp_tx(skb, ndev); @@ -1043,10 +1051,6 @@ static void mana_rx_skb(void *buf_va, struct mana_rxcomp_oob *cqe, napi_gro_receive(napi, skb); - u64_stats_update_begin(&rx_stats->syncp); - rx_stats->packets++; - rx_stats->bytes += pkt_len; - u64_stats_update_end(&rx_stats->syncp); return; drop_xdp: diff --git a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c index e1ccb9bf62de..e13f2453eabb 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_ethtool.c +++ b/drivers/net/ethernet/microsoft/mana/mana_ethtool.c @@ -23,7 +23,7 @@ static int mana_get_sset_count(struct net_device *ndev, int stringset) if (stringset != ETH_SS_STATS) return -EINVAL; - return ARRAY_SIZE(mana_eth_stats) + num_queues * 5; + return ARRAY_SIZE(mana_eth_stats) + num_queues * 6; } static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data) @@ -48,6 +48,8 @@ static void mana_get_strings(struct net_device *ndev, u32 stringset, u8 *data) p += ETH_GSTRING_LEN; sprintf(p, "rx_%d_xdp_drop", i); p += ETH_GSTRING_LEN; + sprintf(p, "rx_%d_xdp_tx", i); + p += ETH_GSTRING_LEN; } for (i = 0; i < num_queues; i++) { @@ -69,6 +71,7 @@ static void mana_get_ethtool_stats(struct net_device *ndev, unsigned int start; u64 packets, bytes; u64 xdp_drop; + u64 xdp_tx; int q, i = 0; if (!apc->port_is_up) @@ -85,11 +88,13 @@ static void mana_get_ethtool_stats(struct net_device *ndev, packets = rx_stats->packets; bytes = rx_stats->bytes; xdp_drop = rx_stats->xdp_drop; + xdp_tx = rx_stats->xdp_tx; } while (u64_stats_fetch_retry_irq(&rx_stats->syncp, start)); data[i++] = packets; data[i++] = bytes; data[i++] = xdp_drop; + data[i++] = xdp_tx; } for (q = 0; q < num_queues; q++) { From patchwork Sat Jan 29 02:03:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 12729358 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11584C433F5 for ; Sat, 29 Jan 2022 02:04:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352128AbiA2CEr (ORCPT ); Fri, 28 Jan 2022 21:04:47 -0500 Received: from mail-dm6nam12on2094.outbound.protection.outlook.com ([40.107.243.94]:28512 "EHLO NAM12-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1352136AbiA2CEp (ORCPT ); Fri, 28 Jan 2022 21:04:45 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XlC+nrjT8qKoRTthr3c24tXw0CCJZgS1ZBaMXFMu/nhwTkGhnJ6KsTONBZWDiBA8P9axIR0YSjZMTAsTA1Wt+b0sDcjiT2IfknSlSJCpPWvQIA5D1F09/X/TEyRZJmj3TNT/vefutRkwFZxROR854VS0BUX+zatoIkPX5CqhoM0rk6kN/kIbRSc3bMAU/3ZM5HtESZsNQB7XspbRfkYa68h9AcrlN4Deuw1vnvItLsxmXs+XwL+s6Q1nHxnraAOP4MZnBZLnrqcYp98JRUUY/DGOMb0faN7y7hJX7k2ApoxKU19zehx+Kp8ivukQNtwxOC+EepfamvAjq1Wmb7mijA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lBtUJ0WthM4WNS/PwB/119hMxcAj9Gvk1JO/v29ONRQ=; b=gRJ2kqpQHX91Gp2O8duo4N+Nlvit1chqhZPijTvuf9fnDX7Sn2erIWna7j081WY4IF7avv1pCX1+bsVQ28melrlD9/Dcoz4I8P0PQSDOxVudp4mdM1oqfQJDeBwLZOiID8QYslsHQwpyLfmL0jNZKmo8JN6W1wk/21TN1roVsr7HEbpJLn5O8ujEohZA8vqbquzIIM1gcpnTCTTab6rfNuv54pKZCoD8oKDDoPSVT7tB/1+zw4yy9/862JTO/tsSRkBWDDJP20ypABNexcONNbSByOXjQ8m5j0cLMIKvDTc6iKUx5lqVp5mB3iKei4VqS18lBZolrMFLZK7Z+5X8FQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lBtUJ0WthM4WNS/PwB/119hMxcAj9Gvk1JO/v29ONRQ=; b=Z2eD+DYLPyK9mBpO6bs7OcEl5wfWDoOMUQ7zzlG+a4DstmlRs9bX2Mo0iNQSM4ijl+Ya7hUOODfz0UJ+nkd9BOFaKFA7KMO3vRFOgqkUkt8cIvS8typ43FU71S9kjtz+wnnMsS8Az1mUAsFeWsfgu4LSRSAia7px3VmBHKfNiOw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1340.namprd21.prod.outlook.com (2603:10b6:5:175::19) by MWHPR21MB0191.namprd21.prod.outlook.com (2603:10b6:300:79::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.7; Sat, 29 Jan 2022 02:04:40 +0000 Received: from DM6PR21MB1340.namprd21.prod.outlook.com ([fe80::1d9b:cd14:e6bb:43fd]) by DM6PR21MB1340.namprd21.prod.outlook.com ([fe80::1d9b:cd14:e6bb:43fd%6]) with mapi id 15.20.4951.007; Sat, 29 Jan 2022 02:04:40 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, kys@microsoft.com, sthemmin@microsoft.com, paulros@microsoft.com, shacharr@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, linux-kernel@vger.kernel.org Subject: [PATCH net-next, 3/3] net: mana: Reuse XDP dropped page Date: Fri, 28 Jan 2022 18:03:38 -0800 Message-Id: <1643421818-14259-4-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1643421818-14259-1-git-send-email-haiyangz@microsoft.com> References: <1643421818-14259-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0311.namprd03.prod.outlook.com (2603:10b6:303:dd::16) To DM6PR21MB1340.namprd21.prod.outlook.com (2603:10b6:5:175::19) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2bf149a6-ed80-4069-7c9d-08d9e2cbb570 X-MS-TrafficTypeDiagnostic: MWHPR21MB0191:EE_ X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-AtpMessageProperties: SA|SL X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1060; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K7r+T7CvNdaKP+AEatE9oyPgA8ifke7QLLdpV3YqCtQdXIlcnvVQ8rqkjlPUeUgB+ySJqMGuXzjcHC6HE3G1c3wmBd6/8LVCeRWbvQBpyabE7AM98gdr2yj0vOpbFVA75PaWABOsfAk4RleGD3Yk8nM5GYx3wYz15rSIV80UGhozEhtGIHDjaAw4ftVCtPkHwDv+Kx0b+iDBZXAm7+tznRY0IrFsFkxdkKZRgUoAG/MgmzE05v3DnKnYMBzdzMDwUEpkkFknrsKYlGzlIqpaNiB/YZr7oAi7+eItgYUYYxrCuyV1bXDWW1pNOk2EkqCp7Txy/4yferKkoEr7rItJRp/fqAuk9Ft72s+cNI1mHL9WjfnC8at3R2N8eqn8Bqa3itMJWeUzcU6sofEFfBUkp50vYI6ArC5wtXOyK983v+L2McXCh5mFsuYDj6bmWf5p+J6rEv6gDtttHF0g0lQe/11boXvUgsdj3MOhGmJI4qycjk6lh7PkXLHEV39XDgJnk09pwqI9wDKn/TCVHnZa5xeyedmBaGWkGm902EyfHLnf4OfI2vw7RJqkDFJAthoDq1tKM+nB3vDI35qjnILbyUUbzQEmcRHY8OMrEuZ3JMMEl74+gXd/YAGhajtcxe+3BUM0WWiQIQorA1kl1STYnKct1wBjZfv0auOuDdWQnBc8D0SRbYliLHbKoVtN2HoCx0PR/qkgOfmPExhp4Y9oGOCVvtTy58m7SwflNEEz1r1aqnOZZfSlPS9MMrQF7HiH X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1340.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(66556008)(66946007)(4326008)(66476007)(8676002)(8936002)(5660300002)(38350700002)(38100700002)(82950400001)(316002)(82960400001)(186003)(6512007)(6506007)(26005)(2906002)(2616005)(508600001)(36756003)(7846003)(52116002)(83380400001)(6486002)(10290500003)(20210929001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: P/NMUhZLGkiOollksnYXfl+7KCLAmIvzCnKvSqF0c7EQD6TC/c+FtdDvc6YeGwta2ew/Xv48ybU2f4io3GpGH8TLZTKzUbrEGWRAfQ0deJxxPH2SaYGsW2Nm1pQ6F5UDfxwxHWYm/fFQvWSdu03z17wDMXKz3zFm4rufa1PHOrpQG0XMlaq/GVBYUbQ1vAeonj4X3PnQfucYM3X8SCDTcJ0j6IvRNWBTjbq4st/liuCNB+v+jchF93D8NLddcmA4aJuoeBtyOgwasSDhBj1w1ofHav85kjwyx/e+Q5F8yfrzz6baF1g4fnpoRQVP3H7eMu99h9EimJBz2vcXpzrw3N89YIejWLCAVvqV8+TOdCFSBmCuCrQMUSsLsD4x1u0G9iOgQoahXnQmwaNVZFe/sZiQh4og5jc5Pq/wF1INxY/EzIz2xKolToU/Te8+TBSbbolUQnMT9qauW2YAgVZUqSR/NDqvu6m7Jhdnq97pF6j/1B844YM0nK03L6qdVrMsRfH6fYrqdPW5/GYgsgenlCD3fyY55KY3FM8YZFCVzh8MtEacrYm1xzO61viHgfnIpSgJ8g6C0OLRIkBbZWHGMPUjH0atVX7F4AlAR7Rjw6oUKkthy2rgzhSlaH0WMcF0nb8n3aRIpGjLqiQi4a1Wf/e2zZ3scTmsTvfetrnGeBCHIjeEQ5JtbhbfAJk9U0UYTOEeGXdY7NHPoMfl8MxdU5A6JlEL+KvBrosnLYPV5Ab+Dl3gjqfu7KeR/PlhnEY62JHuEC2PwtKpqw3rrmx5+lexISICnJVWusiXA6Bx0VwoT1Iq30K8SBk8j79K3HsXLnuc4IGTTTiNJcUzQpdaCNY+FjhzsQxnGJKqGvyH8Y/H6ibS9/3alv+SMdbTP+mMAeVA7CYuJl5eiSbA9iPOtbz+z4BKgAr0VvQ2AQ+nNldtoUA57aBMDVZdEaNQH3VHaUwisS1+mG9/wkfkMJO8qriGNFpTH2UwTonb4ArvIHFYI3Es+e3mnDdiW3L6mXcSzJ2vXG3Q3eDZKS3hVXpTTSk0rg5hdwNZonNrGi1Mg8WR1Xhrpx8OxVpo86wWOCTNC+vBll/igOU7+66Hytm2bbFIkQteogSOn8wttuAt6q6FXxA+HJTxaFygfuf5aBo0+9ZUthmtWAplYPGBofQikJxglJQhLD1YSLpBo7d8RHPvhkuO8d+jXIRpiXiqfEJK5gec0i1nvAhuMrmpsUOaHsb4iDXYkYViYIIVtY1F43cto04C+nvJlFdxHMbPGiA/iczBpPE38ZrGM9TBfPCJkNg7D9CkVl0G1PbZulNdYGn0yMnZUCO9Y94Hoa14+hnmvHQtoEC7sVF5Hot6LV74tKpwyEu7EDkfQLuekvZq9jpBgwkqyLpAmJoeqxik99xVEHkVRSa2a82U4Q+YvQu460nX6khpOnXJnSctnt04O6go3u79kiA+ZRs9Eax2OtKdY2HMOFYEsOSotVY5rVBfA9lwhKhcd4dv7dSPzrFL55IHZrEtOSwsq/1dHuzbipLIpK5qP+8RBAN36cdtSazhigmoIEfcgzu/YjeKJ/KQBdvISO5GE7TYh3Zfa+90sRtnY7AOvM7NxGrivkKsk1kbn9zhGwQUZRXhhX7aED9beek= X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2bf149a6-ed80-4069-7c9d-08d9e2cbb570 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1340.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jan 2022 02:04:40.0922 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0qJ/rC6Di8Lefd7FgFIBglfWJcaSOrm3EW+ejmCWBJpfnzASaXNYHLHhIHxrEl8uDXHIxUI5t/02zjRcM5SZ+g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR21MB0191 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Reuse the dropped page in RX path to save page allocation overhead. Signed-off-by: Haiyang Zhang --- drivers/net/ethernet/microsoft/mana/mana.h | 1 + drivers/net/ethernet/microsoft/mana/mana_en.c | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana.h b/drivers/net/ethernet/microsoft/mana/mana.h index 8ead960f898d..d36405af9432 100644 --- a/drivers/net/ethernet/microsoft/mana/mana.h +++ b/drivers/net/ethernet/microsoft/mana/mana.h @@ -310,6 +310,7 @@ struct mana_rxq { struct bpf_prog __rcu *bpf_prog; struct xdp_rxq_info xdp_rxq; + struct page *xdp_save_page; /* MUST BE THE LAST MEMBER: * Each receive buffer has an associated mana_recv_buf_oob. diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 12067bf5b7d6..69e791e6abc4 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -1059,7 +1059,9 @@ static void mana_rx_skb(void *buf_va, struct mana_rxcomp_oob *cqe, u64_stats_update_end(&rx_stats->syncp); drop: - free_page((unsigned long)buf_va); + WARN_ON_ONCE(rxq->xdp_save_page); + rxq->xdp_save_page = virt_to_page(buf_va); + ++ndev->stats.rx_dropped; return; @@ -1116,7 +1118,13 @@ static void mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq, rxbuf_oob = &rxq->rx_oobs[curr]; WARN_ON_ONCE(rxbuf_oob->wqe_inf.wqe_size_in_bu != 1); - new_page = alloc_page(GFP_ATOMIC); + /* Reuse XDP dropped page if available */ + if (rxq->xdp_save_page) { + new_page = rxq->xdp_save_page; + rxq->xdp_save_page = NULL; + } else { + new_page = alloc_page(GFP_ATOMIC); + } if (new_page) { da = dma_map_page(dev, new_page, XDP_PACKET_HEADROOM, rxq->datasize, @@ -1403,6 +1411,9 @@ static void mana_destroy_rxq(struct mana_port_context *apc, mana_deinit_cq(apc, &rxq->rx_cq); + if (rxq->xdp_save_page) + __free_page(rxq->xdp_save_page); + for (i = 0; i < rxq->num_rx_buf; i++) { rx_oob = &rxq->rx_oobs[i];