From patchwork Mon Feb 6 10:08:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Oltean X-Patchwork-Id: 13129596 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 37A76C61DA4 for ; Mon, 6 Feb 2023 10:09:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230139AbjBFKJ3 (ORCPT ); Mon, 6 Feb 2023 05:09:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbjBFKJZ (ORCPT ); Mon, 6 Feb 2023 05:09:25 -0500 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0621.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::621]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E19B12F3A; Mon, 6 Feb 2023 02:09:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EE8yHemtFxMl5rYCpb1B8yaqVtGaZbr3aBERQXGfFLyaGp3wI1CUkuDIDwoQGJ5O+F/F+/RdGZcgrOjHsn0tLUlJeMXmWKPeAafzvl6/fgE9a+Qh/0IAjqgmSeDWMs2CExwON4rTxO6tuyl0jvd46QeZxxwJ4VO4l6MVPK9KrokO1sUBlCNK6ypkQurQMqL/jUs0rXxjbZbvifZMnwr9qULWCP0yRJx0B2J3GBkb4+QsPasnjEQV3Fp+lw6t26Mb9U+dBfoJ8jOaPVkeJN+FZbzW8t0nEoAyTncQ9FXrD/FSk40r65zKerqiaJAjaJWZMoXEImUsf9hFA2u7beh2Zg== 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=8Oki15vmcIgJjBGTfklTBzJKOfHFRepAumEeMsAKh4M=; b=DE+rWfmUOozDm2dlKPGvcnLhgOC2x5WVJlJ7xNuakR+S8v5d+nGYG1ZlDyNl9Amt3l8Fba2xk34iiWDGQBL9tTr2hiDRmVL66oGYpI1hFeVaDzJNt8gvXEozG1dtz1joRqd1ECEJec/d1DPTXr04++lgqVseWWg4IZ7A3/wasEkhHAGC0txrMyGrZNMjz/r1ALeI6+KQ0QzeK7saRkJosXOy5LU7+A3AMIq7ZKv2BXkhcsA30ADlZ2Vok7wgCgn3NZk287FXFRLXdwHSSN28552xNYiGhFhIcCCPgsl8LJ5v9Cz+DYRADEVYNzCLidHESyEquUXqKe+giQJLMIG7Ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=8Oki15vmcIgJjBGTfklTBzJKOfHFRepAumEeMsAKh4M=; b=NJRGLgoLjQWoMrwRBhkqL2ZUXfKCFRW49rcD59/2VpEKG7VyUll8uMVdqJTnz7NYvE8IXOM9AcUUYec6Xw1pmauJXYHMlxplNYC3yx4FyG0mEm63iXNyipxPsg0tdA60GTJ3J1piGpFHSASMD1/0LWaxBZmvGgVoN+DcDZXr8xU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) by AS8PR04MB7813.eurprd04.prod.outlook.com (2603:10a6:20b:2a4::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6064.34; Mon, 6 Feb 2023 10:09:02 +0000 Received: from VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b]) by VI1PR04MB5136.eurprd04.prod.outlook.com ([fe80::3cfb:3ae7:1686:a68b%5]) with mapi id 15.20.6064.034; Mon, 6 Feb 2023 10:09:02 +0000 From: Vladimir Oltean To: netdev@vger.kernel.org Cc: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Claudiu Manoil , =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= , Magnus Karlsson , Maciej Fijalkowski , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH net-next 03/11] net: enetc: rename "cleaned_cnt" to "buffs_missing" Date: Mon, 6 Feb 2023 12:08:29 +0200 Message-Id: <20230206100837.451300-4-vladimir.oltean@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230206100837.451300-1-vladimir.oltean@nxp.com> References: <20230206100837.451300-1-vladimir.oltean@nxp.com> X-ClientProxiedBy: AS4PR10CA0019.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:20b:5d8::19) To VI1PR04MB5136.eurprd04.prod.outlook.com (2603:10a6:803:55::19) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: VI1PR04MB5136:EE_|AS8PR04MB7813:EE_ X-MS-Office365-Filtering-Correlation-Id: d7d17353-7759-4a49-a080-08db082a2bc8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8IxLpDxOI2nxZCfHIIZM3eL0LK+lxt7+VeywuHkbyxK65wfdCHLiMtVoP+gOZgs+lL2aZZxAs60f5GQ5tfCIO2OcRGzmpVWsoQqzW8BcwKYfj+qY83OGeYU+uD0ixoJkBh2EUPUuzdzUNfWjEwzZHgqIJTmWGQKBw27ITdnSnfTmVcbkh7X6upk8VoBuiZrzss+mKdN6q1Qxwc/ardfqlX0Ka5e++DFgai9GAi+BEeNkkLqLmgXY8tYNFneIuOMib2CviU924NIWrr2Iz6PkPE6R+tEStKU9iGytM2x1kIzjCLc7y8TooLnyTyHkyQiSAhigjttP5HBtfcYq/L0HcDSd2saqk5N0+uuwc3dJlNWN4t2+5gnkec7+ifdu2XV6sF5O8YToWRArcaC5dXpdhAennYdR5gBN48EnDfL0aeEHWtukJDn1TC3JSi2SrCY/qLB/StzlzMsq4GpYt7CCoUdJt6Alf+MQiA3J87VyVsxUlVteaQZNO2dr6CnVU1wfQDrI+cbDWUmxlJbrPKw1cK88mqBiSJeSnRk7/hTj1N9QPjVGhieYSrgUo1Pa6/jL/BWrT9JpbTLnrzKrRQbX4QmBV3hbhN+6H1fqM4ooisp9TjMFkDW82j6vdAfDVT//nj1ydRFRgnt9Oz17/OSqbYWVYMFtjJvK68vT3CoDw4RUyVLJHXTi46M7rFezf9YMba99nMIiLgw0C3kZbXd65w== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:VI1PR04MB5136.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230025)(4636009)(366004)(376002)(136003)(39860400002)(346002)(396003)(451199018)(86362001)(2906002)(36756003)(83380400001)(52116002)(6506007)(1076003)(6512007)(2616005)(186003)(26005)(478600001)(6666004)(6486002)(5660300002)(8936002)(7416002)(38350700002)(41300700001)(38100700002)(44832011)(54906003)(66476007)(8676002)(6916009)(66946007)(4326008)(316002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: etzV0fE7k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TzYVVZiitFdvef+FcxB7m2rjfqSJwic+ZuXtS224UMCyb+hAZBv2VZHE5xA0o4Y8wVWJ33jZiKO0kPDgqRyHkXyb5pGUIeOXwDg9I6J8yJ+lEjDmHWAQIr5doKn4nhsgKZs0zRmHlXOuKGdzHIlUSaqIggPdY+47Xab2wbzSXj0v7YQ6FV2dxPGhBZzf2P4VLoF6LlsJE++QUuTsIy353N0Tcr8GAlQCg+d923CFyc6/fm3QLxrwJcJj1IbDZJ5aCb47Kj5lAR+gmYoK+0vabXjQTJQA3TPvLy5nUHHqsYdyUchFx14arPDqKsdj3Fc6SHNzjMAezFngQ8VMsyQ+aWLl70PDcXWlNQ5zMPdulrk2LEbZNP3TuPv+jvD4eOISVYvCdblcXl7bljCyP09hmjIzYYhfajBijM9CVNo8Yv9PwDAnIZwblUcGVrkrsaaLjrcDgcGRRlg79cqwQioPpqJjqdGnrpeyeneZJn+GZU36eo42Nc0lcvHCMAOkfVY7XUF/0ikAA== X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d7d17353-7759-4a49-a080-08db082a2bc8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5136.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Feb 2023 10:09:02.1305 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: H4OJZcZNUjmtry94GgmWP6Xoc6LqOy0Q+CfmSalnCw6zaMuHnRIhcBZXFEL4YBxXO3SNXpkIyqT/OoYABoJCPg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB7813 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org X-Patchwork-State: RFC Calling enetc_bd_unused() on an RX ring returns the number of descriptors necessary for the ring to be full with descriptors owned by hardware (for it to put packets in). Putting this value in a variable named "cleaned_cnt" is misleading to me, especially since we may start the NAPI poll routine (enetc_clean_rx_ring) with a non-zero cleaned_cnt. Signed-off-by: Vladimir Oltean --- drivers/net/ethernet/freescale/enetc/enetc.c | 41 ++++++++++---------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c index 2d8f79ddb78f..4a81a23539fb 100644 --- a/drivers/net/ethernet/freescale/enetc/enetc.c +++ b/drivers/net/ethernet/freescale/enetc/enetc.c @@ -1145,7 +1145,8 @@ static bool enetc_check_bd_errors_and_consume(struct enetc_bdr *rx_ring, static struct sk_buff *enetc_build_skb(struct enetc_bdr *rx_ring, u32 bd_status, union enetc_rx_bd **rxbd, - int *i, int *cleaned_cnt, int buffer_size) + int *i, int *buffs_missing, + int buffer_size) { struct sk_buff *skb; u16 size; @@ -1157,7 +1158,7 @@ static struct sk_buff *enetc_build_skb(struct enetc_bdr *rx_ring, enetc_get_offloads(rx_ring, *rxbd, skb); - (*cleaned_cnt)++; + (*buffs_missing)++; enetc_rxbd_next(rx_ring, rxbd, i); @@ -1173,7 +1174,7 @@ static struct sk_buff *enetc_build_skb(struct enetc_bdr *rx_ring, enetc_add_rx_buff_to_skb(rx_ring, *i, size, skb); - (*cleaned_cnt)++; + (*buffs_missing)++; enetc_rxbd_next(rx_ring, rxbd, i); } @@ -1190,9 +1191,9 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, struct napi_struct *napi, int work_limit) { int rx_frm_cnt = 0, rx_byte_cnt = 0; - int cleaned_cnt, i; + int buffs_missing, i; - cleaned_cnt = enetc_bd_unused(rx_ring); + buffs_missing = enetc_bd_unused(rx_ring); /* next descriptor to process */ i = rx_ring->next_to_clean; @@ -1201,9 +1202,9 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, struct sk_buff *skb; u32 bd_status; - if (cleaned_cnt >= ENETC_RXBD_BUNDLE) - cleaned_cnt -= enetc_refill_rx_ring(rx_ring, - cleaned_cnt); + if (buffs_missing >= ENETC_RXBD_BUNDLE) + buffs_missing -= enetc_refill_rx_ring(rx_ring, + buffs_missing); rxbd = enetc_rxbd(rx_ring, i); bd_status = le32_to_cpu(rxbd->r.lstatus); @@ -1218,7 +1219,7 @@ static int enetc_clean_rx_ring(struct enetc_bdr *rx_ring, break; skb = enetc_build_skb(rx_ring, bd_status, &rxbd, &i, - &cleaned_cnt, ENETC_RXB_DMA_SIZE); + &buffs_missing, ENETC_RXB_DMA_SIZE); if (!skb) break; @@ -1447,14 +1448,14 @@ static void enetc_add_rx_buff_to_xdp(struct enetc_bdr *rx_ring, int i, static void enetc_build_xdp_buff(struct enetc_bdr *rx_ring, u32 bd_status, union enetc_rx_bd **rxbd, int *i, - int *cleaned_cnt, struct xdp_buff *xdp_buff) + int *buffs_missing, struct xdp_buff *xdp_buff) { u16 size = le16_to_cpu((*rxbd)->r.buf_len); xdp_init_buff(xdp_buff, ENETC_RXB_TRUESIZE, &rx_ring->xdp.rxq); enetc_map_rx_buff_to_xdp(rx_ring, *i, xdp_buff, size); - (*cleaned_cnt)++; + (*buffs_missing)++; enetc_rxbd_next(rx_ring, rxbd, i); /* not last BD in frame? */ @@ -1468,7 +1469,7 @@ static void enetc_build_xdp_buff(struct enetc_bdr *rx_ring, u32 bd_status, } enetc_add_rx_buff_to_xdp(rx_ring, *i, size, xdp_buff); - (*cleaned_cnt)++; + (*buffs_missing)++; enetc_rxbd_next(rx_ring, rxbd, i); } } @@ -1524,16 +1525,16 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, struct enetc_ndev_priv *priv = netdev_priv(rx_ring->ndev); int rx_frm_cnt = 0, rx_byte_cnt = 0; struct enetc_bdr *tx_ring; - int cleaned_cnt, i; + int buffs_missing, i; u32 xdp_act; - cleaned_cnt = enetc_bd_unused(rx_ring); + buffs_missing = enetc_bd_unused(rx_ring); /* next descriptor to process */ i = rx_ring->next_to_clean; while (likely(rx_frm_cnt < work_limit)) { union enetc_rx_bd *rxbd, *orig_rxbd; - int orig_i, orig_cleaned_cnt; + int orig_i, orig_buffs_missing; struct xdp_buff xdp_buff; struct sk_buff *skb; u32 bd_status; @@ -1552,11 +1553,11 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, break; orig_rxbd = rxbd; - orig_cleaned_cnt = cleaned_cnt; + orig_buffs_missing = buffs_missing; orig_i = i; enetc_build_xdp_buff(rx_ring, bd_status, &rxbd, &i, - &cleaned_cnt, &xdp_buff); + &buffs_missing, &xdp_buff); xdp_act = bpf_prog_run_xdp(prog, &xdp_buff); @@ -1572,11 +1573,11 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, break; case XDP_PASS: rxbd = orig_rxbd; - cleaned_cnt = orig_cleaned_cnt; + buffs_missing = orig_buffs_missing; i = orig_i; skb = enetc_build_skb(rx_ring, bd_status, &rxbd, - &i, &cleaned_cnt, + &i, &buffs_missing, ENETC_RXB_DMA_SIZE_XDP); if (unlikely(!skb)) goto out; @@ -1640,7 +1641,7 @@ static int enetc_clean_rx_ring_xdp(struct enetc_bdr *rx_ring, if (xdp_tx_frm_cnt) enetc_update_tx_ring_tail(tx_ring); - if (cleaned_cnt > rx_ring->xdp.xdp_tx_in_flight) + if (buffs_missing > rx_ring->xdp.xdp_tx_in_flight) enetc_refill_rx_ring(rx_ring, enetc_bd_unused(rx_ring) - rx_ring->xdp.xdp_tx_in_flight);