Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7002267rwr; Wed, 10 May 2023 02:22:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4H3iLb0/wxYGdPf1WSEXnTFnp3/3VJXC1iU+Hjo5FfLGCgaCfeEGP8D5ypxf9rWCJmnrNi X-Received: by 2002:a17:90a:a608:b0:233:ee67:8eb3 with SMTP id c8-20020a17090aa60800b00233ee678eb3mr17622823pjq.24.1683710561758; Wed, 10 May 2023 02:22:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683710561; cv=pass; d=google.com; s=arc-20160816; b=wEAffL3vjFRGFTvDueZcc9W2LmOaaZsFfAtPxMl8XhE1uci9wT7hKnuInc1KtsjkWZ ELpCMfNVlZLk2HFnHySpqHgi/g60RyqD52vq/YJr5J6z6kjZYHeBGolgwC8628d48k+Z K51VhdPXmUpuCb5fg2k8go92t410wnd3BPJEW+PIt0QMzpEfI4iYGph/sx4iRq1sLSs1 WoNd8FUjpzYhOGA8crJ8KSup4KLjHA0r86VLl4J5+l7rCGMmzwJftUzl6m6D7LzTMuNn T1fBHSy8tNagGQ7NpFHKAl453gcaGHaLlKdPVByhrVlQ9zWKA7rbs/itD3DXl4Pvriyg zZtg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:content-disposition :references:message-id:subject:cc:to:from:date:dkim-signature; bh=bVTkDFqxXsDQ0LNgbGO/H8QFDGG2cXswbqI3l/RPq6g=; b=dLmTtkEiiWKy6dOssIH/ixojV7keCR6Su7bMgrl4ZkY4LsNq84lTZL3XKy8//zcCr5 c8dGHpYcuRn3pfQpnu86Ih3n4Ozl455W94fZOz3ruQrKi+0dpD0wIFLS6xi/KY2Vhk42 yDVCPnJrpUHVQmuLQPz2AEDbAU3y6gEvcd9Z5EF7zTRl85VQZ1KZ6fPSPj4HXBcqtqY9 olEyoEG7/TZ+55mDPQx8Zb4nfy0IWXi7CNqtdLAUBWKIfqyktimz0gg/StwTc0kKgYuF RJ9eAZUKE2as7hJ4WPGeQUBI21JKNLq264UbiamzmjN0gENU61D3JP/s5zD6ddy1bN1V frpQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=QnAUhM36; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d8-20020a17090a7bc800b002472a818166si17386513pjl.96.2023.05.10.02.22.29; Wed, 10 May 2023 02:22:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@corigine.onmicrosoft.com header.s=selector2-corigine-onmicrosoft-com header.b=QnAUhM36; arc=pass (i=1 spf=pass spfdomain=corigine.com dkim=pass dkdomain=corigine.com dmarc=pass fromdomain=corigine.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=corigine.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236144AbjEJJMA (ORCPT + 99 others); Wed, 10 May 2023 05:12:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231486AbjEJJL6 (ORCPT ); Wed, 10 May 2023 05:11:58 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2100.outbound.protection.outlook.com [40.107.244.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87C4A269E; Wed, 10 May 2023 02:11:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i36aruiiqPfw05NRR7H+SdV6Tgw2AS+K9EDRVX4TF15RoEYoY2+9quy7lwPmABe+hQmqZTu9J1htxsmKH8jUPqnDxZ6b8Nc7tlOX9QIXsiiAX5jg8puNAbVd08j4cKcj9lSShhOorhHXw+Ya59AvpAtLArdojIscaEwiUVFSpeXx2bsL6fgKv1Y2IhKg0MyxhbVlQh8TjwKl78P++b8KAM+7PtABI1IVQ5sHSnq/WC1ekGkDimhx4UbkbLJQnDSB+QO9MO3Az9CVrjfo4gKyuqOvwdXa11rgjhMHRzQ2KZnKc9Nv/ijOpIYNeIdqL+aZSprOhUPl45oeaZSSZwbGZw== 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=bVTkDFqxXsDQ0LNgbGO/H8QFDGG2cXswbqI3l/RPq6g=; b=e3mzC5WkWp0Pkwpqo5Lu6zrZh8xRm28eBrQABVVLQGa77/UW6GHWtxbytNsc9HUbupA7ereJmxLXY30eUe0hB95cs/WMZIjCqjGPu1QybxrE8YLX1ndprAGAU7N6M4bsvsjaV9tJ13Cm5jtz69SBGfqf29+z7USGPGpJEAYpLMEk/qpdqN235vXw7yz0uO6QDrFZVo4bZ8xypV5CoK1X78nlFyD7WYAzBvpp4nwgCLZ2+w7R8Eq3BJ55PA1m9WUpNsK90ujcBGGaDJSxBJwpLGjZa1XLo09ztZJG8s6AB/Z3O3v0dryVXjbSnL+lvJXdfQ2VINWMaP0BfCSc+0eIUg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=corigine.com; dmarc=pass action=none header.from=corigine.com; dkim=pass header.d=corigine.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corigine.onmicrosoft.com; s=selector2-corigine-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bVTkDFqxXsDQ0LNgbGO/H8QFDGG2cXswbqI3l/RPq6g=; b=QnAUhM36zxmWC6lj04BZmO7s4mnDbYVe+1FRUAp4QNriaaxWjfhMiwq0s+dCPzOO+sEc4kPVXAGbe+G7Yy8I7AFD8bLIPPs3n0AWEcyKGAKJ6DBX2rw9LzCO3Bnk79CZ4Ld4wWVBN3wVx9qUAbqy1Uk4hTt5wYSSEuzHOiWPZIs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=corigine.com; Received: from PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) by CH0PR13MB5236.namprd13.prod.outlook.com (2603:10b6:610:f4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.33; Wed, 10 May 2023 09:11:53 +0000 Received: from PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::f416:544d:18b7:bb34]) by PH0PR13MB4842.namprd13.prod.outlook.com ([fe80::f416:544d:18b7:bb34%5]) with mapi id 15.20.6387.020; Wed, 10 May 2023 09:11:52 +0000 Date: Wed, 10 May 2023 11:11:44 +0200 From: Simon Horman To: Shenwei Wang Cc: Wei Fang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Clark Wang , NXP Linux Team , Alexei Starovoitov , Daniel Borkmann , Jesper Dangaard Brouer , John Fastabend , Alexander Lobakin , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Subject: Re: [PATCH net 1/1] net: fec: using the standard return codes when xdp xmit errors Message-ID: References: <20230509193845.1090040-1-shenwei.wang@nxp.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230509193845.1090040-1-shenwei.wang@nxp.com> X-ClientProxiedBy: AS4P250CA0025.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:5e3::15) To PH0PR13MB4842.namprd13.prod.outlook.com (2603:10b6:510:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR13MB4842:EE_|CH0PR13MB5236:EE_ X-MS-Office365-Filtering-Correlation-Id: 72fbc566-9444-4de8-a03a-08db513697a0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rsOnFLEp98Ti/ZCswk2yRe55dkt00cb+VkMhcXdQ+dR020+CjtqNi2Q2jkBBPSMyy15hHl3V/h6Crm8M2Rlmj9kOMtm4XHO44GwKfG/u6TxVbakc+wd9AUh7MBEyC+phWlIv/xQQLwF8RjYsxvkwdV97YFIob3nUZVQV7BkU7UfL+SMytgFqv/FnUtZZupbi8hyIM9drSxjhV18Fm/cbDjU43W+F22AMq0xhAIqrrcYmbu967osIKULN3lkzZ05HixFAaAOxaPu1mQFsC1y/xsaAn2kG/SB1iixJduzmaMna2k6oKQt29Azy9kPA7SJ5qib99ZHH2QIUHw4wt/guTxSAEXCUCH5bhTP1gMzZ3wrzdINZZQz7M9NLIfku1T0jrR0yUJo9g5Qb+TRwDwerc/QNEJH8LWdQ/L8cS+Bow07TN9aQI8FfM5WaWupyFIeyJajjdFxVO4IhGCAhRRp8rhr6fY7tOLctdYr4wpV4//vM1KLee6x1kuRJ96Bt4OTG6s26ZgIIjVZnaLGTzmxvhoMhRoIW6mJWEg1c8foouUPEx+bbCWSe4opHimZkArNu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PH0PR13MB4842.namprd13.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(396003)(39840400004)(376002)(346002)(136003)(451199021)(2616005)(2906002)(83380400001)(186003)(4326008)(6512007)(316002)(66476007)(66946007)(6916009)(41300700001)(6666004)(66556008)(54906003)(478600001)(7416002)(5660300002)(6506007)(8676002)(6486002)(8936002)(44832011)(38100700002)(86362001)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?2wRVVfu+RsmDWZVbz39tj2fqI4h6iatJhtsd7/Uzmm4nOeZr6rayOG53rqfM?= =?us-ascii?Q?IwgtV1e5UKHwavWZBqNnzCh7xtWC9u6OhIwGcbU/wwntKzq9Zd8Yg/CeSS3j?= =?us-ascii?Q?oQy07lPI2j7BMyh+LMCor/2l4bCddnLP6JtdDr28pu1uqq7N4IkC1JIQbd4+?= =?us-ascii?Q?l4pSFYw8hLyl53pwtnuMDEe9Kam5tpZZ8kGf1TtthzKbbiY0efg0nizYgaff?= =?us-ascii?Q?vKKNHMNzfPhmQCZSnoEdKTXKsMjLdERoKKgb8aQ6Qd4N+wYR7yVkjsMvlQfi?= =?us-ascii?Q?F3ovweAM1HdxTbloVQT5XgkTULOihi3bLDLdRxIEtiCPJ/cXcS0ZNL5AZ2LF?= =?us-ascii?Q?e+v44gdfkyzIGp9cIBVBPEp/9noEAyUWEODTuyOkzcx9PrfWh8UnDRBeXDgC?= =?us-ascii?Q?92g+nM/X+vuSbfMeyk1pVs6n2RSQ9zAplEaXmANS9xaHFDYRcgxXtclRFqU1?= =?us-ascii?Q?jUb3x/Lz/I8pxU3hiHFGNdITG4pUkVoCMpgXbJySnCeGgSFWVgd3rELk5Z7B?= =?us-ascii?Q?s3rjgQXElvjfDH9LvjZdmmU7+5TVZxEF9UqKkDN1pT6qpgSoqfMuLCxSFU3J?= =?us-ascii?Q?U5jx4NrO0bMo3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cs3?= =?us-ascii?Q?3Mdppuj5d5TrO/bw4BIFZywZYxuw0aFiMDnvc/3ugh2chvbbD2DYgfxKDjAF?= =?us-ascii?Q?/SWECETHIbt2JrkVIk3FOzwCgEaoXDWSz5vIfnCQwokd71SlOY9U//3Vyv3K?= =?us-ascii?Q?6s5Mp7nPg4CaLScCJxzj86YtyYs/rh2e3C6tSXokuZvGukz+INc9AyEJfuyi?= =?us-ascii?Q?yngCYQ=3D=3D?= X-OriginatorOrg: corigine.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72fbc566-9444-4de8-a03a-08db513697a0 X-MS-Exchange-CrossTenant-AuthSource: PH0PR13MB4842.namprd13.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 May 2023 09:11:51.9965 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: fe128f2c-073b-4c20-818e-7246a585940c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: zCWby20zMcqAv5nLB/PWFIwmdh+zWzE8SoeBWVKfaJvwdD7Iv/LcpbWQlp/zXd8LQyXYiOPjxqSUYx2Dcy7uu2ZV1tiE2DbaSyx2V+iXA1E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR13MB5236 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham 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 On Tue, May 09, 2023 at 02:38:45PM -0500, Shenwei Wang wrote: > The existing logic did not properly handle unsuccessful xdp xmit frames, > this patch revises the logic to return standard error codes (-EBUSY or > -ENOMEM) on unsuccessful transmit. Hi Shenwei, I'm not sure that changing the calling convention is the fix here. The caller seems to get it right both before and after this part of this patch change. So this seems to be a cleanup rather than a fix. > Start the xmit of the frame immediately right after configuring the > tx descriptors. This is the money part of this change. I think it warrants more explanation. If there are two changes to be made, they probably belong in two patches. > > Fixes: e8a17397180f ("net: fec: correct the counting of XDP sent frames") I think this tag should be: Fixes: 26312c685ae0 ("net: fec: correct the counting of XDP sent frames") > Signed-off-by: Shenwei Wang > --- > drivers/net/ethernet/freescale/fec_main.c | 25 ++++++++++++++--------- > 1 file changed, 15 insertions(+), 10 deletions(-) > > diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c > index 42ec6ca3bf03..438fc1c3aea2 100644 > --- a/drivers/net/ethernet/freescale/fec_main.c > +++ b/drivers/net/ethernet/freescale/fec_main.c > @@ -3798,8 +3798,7 @@ static int fec_enet_txq_xmit_frame(struct fec_enet_private *fep, > entries_free = fec_enet_get_free_txdesc_num(txq); > if (entries_free < MAX_SKB_FRAGS + 1) { > netdev_err(fep->netdev, "NOT enough BD for SG!\n"); > - xdp_return_frame(frame); > - return NETDEV_TX_BUSY; > + return -EBUSY; > } > > /* Fill in a Tx ring entry */ > @@ -3813,7 +3812,7 @@ static int fec_enet_txq_xmit_frame(struct fec_enet_private *fep, > dma_addr = dma_map_single(&fep->pdev->dev, frame->data, > frame->len, DMA_TO_DEVICE); > if (dma_mapping_error(&fep->pdev->dev, dma_addr)) > - return FEC_ENET_XDP_CONSUMED; > + return -ENOMEM; > > status |= (BD_ENET_TX_INTR | BD_ENET_TX_LAST); > if (fep->bufdesc_ex) > @@ -3835,6 +3834,11 @@ static int fec_enet_txq_xmit_frame(struct fec_enet_private *fep, > index = fec_enet_get_bd_index(last_bdp, &txq->bd); > txq->tx_skbuff[index] = NULL; > > + /* Make sure the updates to rest of the descriptor are performed before > + * transferring ownership. > + */ > + wmb(); > + > /* Send it on its way. Tell FEC it's ready, interrupt when done, > * it's the last BD of the frame, and to put the CRC on the end. > */ > @@ -3844,8 +3848,15 @@ static int fec_enet_txq_xmit_frame(struct fec_enet_private *fep, > /* If this was the last BD in the ring, start at the beginning again. */ > bdp = fec_enet_get_nextdesc(last_bdp, &txq->bd); > > + /* Make sure the update to bdp and tx_skbuff are performed before > + * txq->bd.cur. > + */ > + wmb(); > txq->bd.cur = bdp; > > + /* Trigger transmission start */ > + writel(0, txq->bd.reg_desc_active); > + > return 0; > } > > @@ -3869,17 +3880,11 @@ static int fec_enet_xdp_xmit(struct net_device *dev, > __netif_tx_lock(nq, cpu); > > for (i = 0; i < num_frames; i++) { > - if (fec_enet_txq_xmit_frame(fep, txq, frames[i]) != 0) > + if (fec_enet_txq_xmit_frame(fep, txq, frames[i]) < 0) > break; > sent_frames++; > } > > - /* Make sure the update to bdp and tx_skbuff are performed. */ > - wmb(); > - > - /* Trigger transmission start */ > - writel(0, txq->bd.reg_desc_active); > - > __netif_tx_unlock(nq); > > return sent_frames; > -- > 2.34.1 > >