From patchwork Tue Jul 4 08:29:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 115626 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1074390vqx; Tue, 4 Jul 2023 02:01:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlHle3Bd1m+NdW76mWD21LRaQxksBp1x38Kj0I2DyPaHxHSiJ60Klphizc3K6ZiLpcUI0yKl X-Received: by 2002:a92:da90:0:b0:345:ab32:115 with SMTP id u16-20020a92da90000000b00345ab320115mr9756155iln.4.1688461307213; Tue, 04 Jul 2023 02:01:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688461307; cv=pass; d=google.com; s=arc-20160816; b=A6HlR/5IO6sjZo9EfSBHS2CsWR51Dzvvhb0HoWVG0S6nmoW887HqxMGtFFMY1J//BM NSxeMFpmp6sc8JrbMc5vJHONDLs1hJIOIwsBKscOQ0rlcA72sLKTz5Q4wynhaUZtddgx HDvJAuNbDGKVjPnMgfEW/5StMwkUkW5TJ7RX5k3hubCJgunm+lD57e3PqTjmqvx8ougK a+3eNTE/PymGfS1iMuQvr31t+GOOWg2lD8g5l/w0jRYzQoYQYl2RhGn/WBwf/Vb24iGX nNfPgWbOTZpUGM8R1yfMSRII0obL2cuxlLHCN748t37DTeEUiZYavm4pVTv48op6XCwy n/gA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=oKwh4skTvICviWikmus1DwhacGnEq4RXoL8P+3xT/dg=; fh=SYUJmjUGpG2xsb/2udWEOqnn+PsMu/G7LfPz5pAgru8=; b=sXjLalZQ46/iZYYG212a7jW3bereRnHWGKx32bb2A1/y4KPW42rtp8RQlN7QP4xImp K/ZE3gH6d579DSI2oGi4/kwvqS9+SWWN38PCxNq4oh9XsJ5sqRB7lmialU7TM51lvDuE U9u9GXgryNZ3vNi3Zue5zcVFpIdM/yqjeE/Vd34VuztZGDX5bWjZB7C1frt7aSrMwhKU 51E2ccemsCQP7iw37/kSDaqVy/LGoPIEtUgJ4ySH/IUk/vtG1eyscyh94N27ZslZT1zR kCEPaW0N4TzzyJqSTRCeCvjkXNrJP73JD5qEEDFwgR5p9Jxl7/Q6HtL7sC96a3rddfmC Wmnw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=iYoKrR3a; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t25-20020a6564d9000000b0054294720d51si20369823pgv.386.2023.07.04.02.01.34; Tue, 04 Jul 2023 02:01:47 -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=@nxp.com header.s=selector2 header.b=iYoKrR3a; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230512AbjGDIgI (ORCPT + 99 others); Tue, 4 Jul 2023 04:36:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52380 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229736AbjGDIfw (ORCPT ); Tue, 4 Jul 2023 04:35:52 -0400 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2065.outbound.protection.outlook.com [40.107.241.65]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E3E8138; Tue, 4 Jul 2023 01:35:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PhGr9YTNBE9SSfyom+QtVq8uDNlIdyQmNFv/fLd20Q+eXAhx2KpmbgEcE8M/GHGGoy6Dj6fIyWhLHr9yBSdj4nx8IH3GEOBFpbKDLODIHcD7Scp05rYVKozxwskhqIxIKCN3iya2zd6YjW31UAMNGQQtJAcL2rnJ3Mo0ekdB+qyrIjVCxAecIpdOr5qgmubw2z2pMJ1/JaTyImY4mDKOoy7OwZT5p7bKjedk67nhqDmRyIWLmKzGSlBYad9783O16XIOkwc44DhVYQpr0esWBdOamZ/zEvIHIGyt6MDDkmaBQI6ZYoqGXvwEkxAjCDttWeha5otnNZBW0bLl/0s0pg== 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=oKwh4skTvICviWikmus1DwhacGnEq4RXoL8P+3xT/dg=; b=j93WB6dri5NbXaGPFYjgrI+shb8J03ZF1sKqbGSI86C/XREfVzsssqy5mPoAsfpGnp46y0mGwcDlOA8GLHQU3tGj3nqmocACIqDG60GLPDc1A0FDl30+8draDiLCEB9g9e1NJezqwaWzIaOgExEveUuA7BvNypKHoScgxcORzWvCDjOJGfioKzJDUnwIhLAvKM/Yiebop86lfMvw15qUtHpAHVjNnzj0TpjJFwSkMRHmyFuLAlvZl5a7l6wtFp15LjpsGKWGV1ivs5bnGZ03w4Ntk5SnM1XWr648K5DRT7AArzwDrXyavbGVO8bBQ1V8SCzkCFL53vOkospfj1RrZQ== 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=oKwh4skTvICviWikmus1DwhacGnEq4RXoL8P+3xT/dg=; b=iYoKrR3aBCeIgQ61aJ1uF75r1fbP458tcs84hYcvZCgsT5sQbKWw1t4NaxXpnNscjzOfEb4MMSHlOHBqGIT9m3UBAhSO4df35NJ1N3TfQlJV/2Xj2WFrGQ4RbolqjjOsQ/9C+0/vISP3M+SbtJxOnnSdckLWhjVaT+Pm6UeLhOo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM5PR04MB3139.eurprd04.prod.outlook.com (2603:10a6:206:8::20) by VI1PR04MB9931.eurprd04.prod.outlook.com (2603:10a6:800:1d4::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Tue, 4 Jul 2023 08:35:46 +0000 Received: from AM5PR04MB3139.eurprd04.prod.outlook.com ([fe80::1edd:68cb:85d0:29e0]) by AM5PR04MB3139.eurprd04.prod.outlook.com ([fe80::1edd:68cb:85d0:29e0%7]) with mapi id 15.20.6544.024; Tue, 4 Jul 2023 08:35:46 +0000 From: wei.fang@nxp.com To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com, netdev@vger.kernel.org Cc: linux-imx@nxp.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net 1/3] net: fec: dynamically set the NETDEV_XDP_ACT_NDO_XMIT feature of XDP Date: Tue, 4 Jul 2023 16:29:14 +0800 Message-Id: <20230704082916.2135501-2-wei.fang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230704082916.2135501-1-wei.fang@nxp.com> References: <20230704082916.2135501-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR01CA0168.apcprd01.prod.exchangelabs.com (2603:1096:4:28::24) To AM5PR04MB3139.eurprd04.prod.outlook.com (2603:10a6:206:8::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM5PR04MB3139:EE_|VI1PR04MB9931:EE_ X-MS-Office365-Filtering-Correlation-Id: 4bf61f70-19d7-4480-d18d-08db7c69a999 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fJTgt89LSwGP5cbpSvmmlI4/dwuAeWwqqpzCXILYP5KCzhAPrh0gjyGXlZR8MsVxplTvzz3hcXwSDeHErUJAOj8njUdihg7orDtI1dA0QH6PNmcqlkoWTyJyj5JkFGBnoueGF0Q4F1kjaCZPT17UQF/jyEpGHV/un2eUBNbNDX8BgNQauv+LUYzrwzE6IKKBi4gRUbwQvBGqNfuVjdTT/0ZIvMHKVDmDPgr+9pIESRcvrNmUzofRd4V0rfaoL0E3YL5E0lYGC0wHhJ/Xm66uXMFnBO1Lz04qaXHyic//RnK7e1/FjtYIPDanY8y0WuAEEkpUJ+Gvo/sgeXHEsY52FZSEA3+6PMKnMUia/FmFJn8Ik8uQ8d699KEUtqwvJYu2LoiXEs2Ecp0OXgOzpX5v9sbwVKZ46hM4sMrDT34tbeyOvsk7nhOfuORoqhofsTUGGM8rvloL1iIxRvo4KAbqMQzFKjaJg8L90zFL3LM8827j3TuYVLiLuGARUgJWEZeHCaii/xnXfsOlVcGRNfLc1KftSCP9E1A3cmGbtjjx6NbW4voygrSrDrjsL3bsuPvj7R1BWlRf+5ZNnGGaZZSyBM6v4mGDvARrlmyCovORVE9P2NLUU1PbLAszVEBHkVpU5xE2uUOS82axVcwp9S9QyA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM5PR04MB3139.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(366004)(39860400002)(136003)(396003)(346002)(376002)(451199021)(1076003)(921005)(6506007)(66556008)(66946007)(4326008)(66476007)(478600001)(41300700001)(38350700002)(38100700002)(316002)(2616005)(83380400001)(186003)(9686003)(6512007)(26005)(52116002)(2906002)(5660300002)(7416002)(6486002)(36756003)(86362001)(8936002)(6666004)(8676002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5w5QM6aghxASRVP5i7sH/XgC4AouGNgUO+9jfK6x3iLI0fD5N4KLhywIIqWl2NXVEj961uFTRBrqQV9N369kkVGbMS+J64wD2IldLVoxjZkNLGs0FAMzwOoZLs1rJDywhdZ5mEKFd3dRIS0QMEYAE8CiDPnDmg25QTW1xhBvYgCIGCnLln5AOHirSv79z2GE35FpnAX0wAcHdcUZSEOhYMwxbZo2+Q7U9yJmQ6PTO8ja/biov+y6wp4/fHVj60u4aAHGft5LrZfQSZvP4LWREPJbCrY7I6X7aUrFq2j3RDcwepV+6iUeaBBvY83dc7O7jYHTMolQkAevUGbfIZyo3l81a6sAygmGwZk83HVofsYcM+oBlUZ/SdOzQnPYtfCENzHLGl0kZCB5iglriClXWIrizRQbK+WwrPx+khQ9jWkttblwy7mb01UIRs/pq2Jsp6xep2+BnBbvZkQo0aNW/Kfs9kLtn2yBHaYhWlx9R/zmyYpp7TDz7CB/HAK/e4Y1iebq/XxH5u6XATmMgij+nI/yfgmEPgx+ST+iJyTljspJYwjk35hgAbP7A1vBOGlf8BIss1LZkfhJJpucI5hiFbaCEqVJvL3N9p5owM3usK1MBxZby25bwuew8SJBeXkozUbRsIu2+8MRvIWm/d8v+erHbmlvP4n4k7SFrtbatqP1Bw7YPx4RZkuQXHwnkCTs+Bf4cc/WjqR/wonOT4RYg8uGoND2yYTaDr0kTyrZz3bMGjsGLNTldWdMZ2z/w7GX9lNRIhBwf724N0ymTkRewU1RlS1A2d8WVOcx8pxWAZzG4x8HVpdUqRfIuzjSzLOZD7LHZIeU+fgHPGnzecKqMFKU36B6w2rp1tQvBLbwJ6NXvoJvRkKKaIQBHYPN8Jxa0ao3wpvCC4RsBjNCDsWQWyqqPBI9wq2GXyv2ytlbcfvx9F2AUZH+ViUpFQynADRKEhWazEtj5eQyUrd3BqOJN2q+wwmo9m7ppKRejo7I70Q0z8VksxxhkaUzH/0hFBnkUsvK3WngExnNJRnhcsuKbMJisrf7fSJAShqpXwjxzwFieSW10v4P/HDVbL/qSiC5wg+nPNPnECxjYlRie47ZUfgEKDDNX0I+UXBrfPGGgfFlQWKdKgai2/qeX74gE4FJLEMzfj7lRN2H8xXSHlGS6GZwTetVlWXzfQewu57DDQiueY+hEjV8hc/JbYhHp6EgodYamuiKskhBqSuQvC+38K4TrrLMFJN78T8sozOJstaVcBduzGemg9ggnl5LDiuXp+SRFq79N6sHMSb70OAHB/jauWURu2RpRpRvayA30p+8HFcTMrU3J1tdYQ1ou9hKc5MifAzr0+gDEBvxxzlGngSaUfjYetnXFPRwWGFltLdlw3sS/nV2B3R3pvDvUj+anAkfCaxg7nh6eS9Cl9VErZgycXo/3EgNqhR3R3bDQ+On4WdY4Ep3hOKlqHVfmCt53XRtV1udpuseG5ZB9nkdei7wYHc9UH1O42IdaNRBtj8Wih0e8YHOkbeWTJti3Oov4Y6UTztzZedBbGy5ZnW0axUG5t+fFC9HqnNjz+nkZSp5uHVrpPxjhgWhPORUwdQm X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bf61f70-19d7-4480-d18d-08db7c69a999 X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3139.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2023 08:35:46.3747 (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: IxBmvTeF2JPBK3Xos4LO88d/v8CVwnqaisa/qnA4aZigrxkvOU1P1me7uA45W3+haGSumsiZGJSXh/vWMvPLOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB9931 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770480003537301486?= X-GMAIL-MSGID: =?utf-8?q?1770480003537301486?= From: Wei Fang When a XDP program is installed or uninstalled, fec_restart() will be invoked to reset MAC and buffer descriptor rings. It's reasonable not to transmit any packet during the process of reset. However, the NETDEV_XDP_ACT_NDO_XMIT bit of xdp_features is enabled by default, that is to say, it's possible that the fec_enet_xdp_xmit() will be invoked even if the process of reset is not finished. In this case, the redirected XDP frames might be dropped and available transmit BDs may be incorrectly deemed insufficient. So this patch disable the NETDEV_XDP_ACT_NDO_XMIT feature by default and dynamically configure this feature when the bpf program is installed or uninstalled. Fixes: e4ac7cc6e5a4 ("net: fec: turn on XDP features") Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/fec_main.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 8fbe47703d47..9ce0319b33c3 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3732,12 +3732,18 @@ static int fec_enet_bpf(struct net_device *dev, struct netdev_bpf *bpf) if (fep->quirks & FEC_QUIRK_SWAP_FRAME) return -EOPNOTSUPP; + if (!bpf->prog) + xdp_features_clear_redirect_target(dev); + if (is_run) { napi_disable(&fep->napi); netif_tx_disable(dev); } old_prog = xchg(&fep->xdp_prog, bpf->prog); + if (old_prog) + bpf_prog_put(old_prog); + fec_restart(dev); if (is_run) { @@ -3745,8 +3751,8 @@ static int fec_enet_bpf(struct net_device *dev, struct netdev_bpf *bpf) netif_tx_start_all_queues(dev); } - if (old_prog) - bpf_prog_put(old_prog); + if (bpf->prog) + xdp_features_set_redirect_target(dev, false); return 0; @@ -4016,8 +4022,7 @@ static int fec_enet_init(struct net_device *ndev) if (!(fep->quirks & FEC_QUIRK_SWAP_FRAME)) ndev->xdp_features = NETDEV_XDP_ACT_BASIC | - NETDEV_XDP_ACT_REDIRECT | - NETDEV_XDP_ACT_NDO_XMIT; + NETDEV_XDP_ACT_REDIRECT; fec_restart(ndev); From patchwork Tue Jul 4 08:29:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 115622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1069823vqx; Tue, 4 Jul 2023 01:50:51 -0700 (PDT) X-Google-Smtp-Source: APBJJlF58ly5TP4IAP81p3ymLSR2wU6FTLeRv0Cl3ecSmGC/oCN/XsnjKqCU9jIks+oDSrQjaFVR X-Received: by 2002:a17:902:7245:b0:1b5:253f:d05f with SMTP id c5-20020a170902724500b001b5253fd05fmr8583270pll.29.1688460651455; Tue, 04 Jul 2023 01:50:51 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688460651; cv=pass; d=google.com; s=arc-20160816; b=tiReNNbbxmeXbrc6U0oZnQ3IVzjHTW7akxc8yA6RuJXWaKI5NBKLEBf2ZlDrKE8FYR cfGy0YkpXx/8WBuFImrdCa8ajW1ctPSyzmBrDqT4XSxQrBXhmDe87pFnQvHGL/hH294f LBO/sw5Zxe6RBRSiy0FQGXx/y53ljLJpoYEl684XHx1798z6ub2K5V/OcrxykKVN0Ndo AoeoLLNiVwSac1mvMcMoKENJcI166q5+JKTb76Lq46xkwLe6A24DHzqbTNqosCS/N91I PEhxWOlmjlMJqEX/eaeWFqafZUCAf3FzRX2g/mbDMRODsYoLNbh+nEuorkTZt5itInwc pipw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=LqmOszEzMjH8Wav47TqQalE35zrvojCmgFRuBx3VYOQ=; fh=SYUJmjUGpG2xsb/2udWEOqnn+PsMu/G7LfPz5pAgru8=; b=ZXdiQp+Fh1b5W+0Nd8rCPqJvW9H3TrmBhQ2xlp3yynMYrrXobh3Qd+XnrxMw0AzEN7 sjgPaNhBHH3ULO6ankvOV5aJ2gDBGo/MMN+oRSE5jzn8VfbsRHjVLe9LjQqt2zt8y5Yq FHA0M+JQi2jdERIx6Vc3ehrsapd0u6GMSuJtwvpf21326Uzy2qXCUuUx5QWBt+nZzXkT 2WQRxbhU8E2Nv7YmjGoG1rugFPsTWP5H1+OadS+dVBf+VExpXPxPwR6+i+d9lwQBYAOY a8vSqCZIM/zLSP/UnkcGmaWw/pGEpJUzB8PrI9wCPuSQ2mqH378ZNWmN6uzJnFENJtSo pnzQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=GzUMMVBG; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m3-20020a170902bb8300b001b80643d64dsi15913728pls.145.2023.07.04.01.50.38; Tue, 04 Jul 2023 01:50:51 -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=@nxp.com header.s=selector2 header.b=GzUMMVBG; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231710AbjGDIgZ (ORCPT + 99 others); Tue, 4 Jul 2023 04:36:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231669AbjGDIgF (ORCPT ); Tue, 4 Jul 2023 04:36:05 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2049.outbound.protection.outlook.com [40.107.13.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8FFEE5B; Tue, 4 Jul 2023 01:36:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UY4GgjiWaSVnlwwnb7G4ExH9zm6H+D8holf+HcJTEL8yIR9R/GbQB8SNYjGzIg+vjsNSvc9W0NsZyuNfdj5OZ95leFESlUfsqFOBbTmGoxvcydSEXOXj+FrbTGfoM2iZYlvm/Lg+eOStK3M2qbNhCsMP2lz60cqsu5nkP2Av7voWLpJNTk8yI6IjyZS4D9n7xCeWTkqkdMB5ws32RzEHrdcb/w9hBYlo5VJEyXsKpjjR64Kc6zmz4sKFT9qKTC+jC2FFgXL/sBhYQMLhw6b5ZaEsqsTg8B06c3PTeGFCLKuSmLIJCUgZj/bS8zjJip8Bbe7E9gQ2jS6MKgq2p6G1+w== 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=LqmOszEzMjH8Wav47TqQalE35zrvojCmgFRuBx3VYOQ=; b=WfKagPL56BcSchnE51/oTBNv14xdfRgHr6GGKP0T+d6hDsBamFv7elCDAked+bQESIgHJiBdFRe18oR5afqS1UCUOw0Wtvo4T+VXW3edM1YyrsOSkOnqqXp2upS9sYXheJ+z30ZYqSgbpyCLc4qhISqkL6SSp0tWTpkoiFyrzVkz+4gP+qRGZ67CwwvugmWEzch0llDFVe1TVBnBRjLJYSCJTmglv/ytic7Sgf8F4JtMbuwROJnOf2XX9UTzjxQZrvW374lY6Wao+NXh207z5sl4Tq9jPsEV24jb98sTAoJlt/vVG2DCpwILPjHb4gSzQwDvED61D90Uw5M2CKwvVw== 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=LqmOszEzMjH8Wav47TqQalE35zrvojCmgFRuBx3VYOQ=; b=GzUMMVBG/Sm8+HKazzkbO8R0NE+O0oR6yIGBUo+oI0ADzj9vcYDUrUJWIFfhDX8zvGyLcHfUnmSE7zi1/abEGzqAFF5GnMARM24TX0uu0FM3Yo3EcRWb2z3kLijIQjp9VXieozRV+k9MpUIV8ngiFjd6v7kkvLFhgcS/24HzzUY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM5PR04MB3139.eurprd04.prod.outlook.com (2603:10a6:206:8::20) by DB8PR04MB7081.eurprd04.prod.outlook.com (2603:10a6:10:fe::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Tue, 4 Jul 2023 08:36:00 +0000 Received: from AM5PR04MB3139.eurprd04.prod.outlook.com ([fe80::1edd:68cb:85d0:29e0]) by AM5PR04MB3139.eurprd04.prod.outlook.com ([fe80::1edd:68cb:85d0:29e0%7]) with mapi id 15.20.6544.024; Tue, 4 Jul 2023 08:36:00 +0000 From: wei.fang@nxp.com To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com, netdev@vger.kernel.org Cc: linux-imx@nxp.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net 2/3] net: fec: recycle pages for transmitted XDP frames Date: Tue, 4 Jul 2023 16:29:15 +0800 Message-Id: <20230704082916.2135501-3-wei.fang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230704082916.2135501-1-wei.fang@nxp.com> References: <20230704082916.2135501-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR01CA0168.apcprd01.prod.exchangelabs.com (2603:1096:4:28::24) To AM5PR04MB3139.eurprd04.prod.outlook.com (2603:10a6:206:8::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM5PR04MB3139:EE_|DB8PR04MB7081:EE_ X-MS-Office365-Filtering-Correlation-Id: 0cf89f90-0e12-4a94-6f28-08db7c69b1bd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kfiTcpX0AUonnLU4iKjF4Wi3m42tkEeABFq05m5qun+txsr/F0Cf4U/mbf+sKnPpHPYvQAiFmmLSvfZWyXXbbgrS0wuBQiEGkX0G08Ep44O/jojBsMKq8QpHX6qlYsukSaNvVjMjcz8D3Ufs56xc4hI+7+U+KmV9THW+OrTFjaTZWQ6cHBQdYdwAkdLMpNfp6WNttwkloiY1FQBBr9p3nbOr6O6eXbWUbvUNudz+gX+71RE/QWNqkIOaoJzNj3h9Soj59qV53xJ52tkXGwnSaiakwSyerrZrVPiLQP9ztff32p7EuHB7lzOLD8ZJw9wK/FHizp4JrWRg1wDsbZiolEBsqOplPJ8RaL+J1XtkRldbpNCyaD+m3jGCWrvqEb6l/8V6lvlUE01W6ays376CPaJVu6p3VrFd+wp/oymTohT/cJx5z0/rj3Chb6ERHlBYOCucSWaTlo3RkwK15XAUkpaMV5O8432R2XB9718u/9F88c4vlGCle88FMDMLw9ukWRB51C82Qe4x+rZ+7i/3oQcT6ABJWQpWgR+m2LLoAZWv6aF3cMk07KWxTTb5FEbS05CBVR4vxIjJMLx+GE6SA677An7BZ+oUaddlgsn0c16D2yaFGcY31jcSwGxlpNCcnvICBt5GNxzT7JARDebWww== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM5PR04MB3139.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199021)(316002)(41300700001)(6486002)(6512007)(52116002)(26005)(83380400001)(186003)(9686003)(1076003)(6506007)(2616005)(38350700002)(6666004)(478600001)(921005)(38100700002)(66556008)(66946007)(66476007)(4326008)(5660300002)(7416002)(86362001)(2906002)(8676002)(8936002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Dgyh1aCak651CR4KsbF2qUPvC7sC/6sGyJYOfMTAU1EaIdDZGs7SEajQnFxCwbH3dQXjFuOtUlFKFefMygeiYfSHtZ1d0OOizl4r0Bj6UnXElxxqtXOYyfv9ERv/X5qd2FFQC5N4l2/0gbSWbPEQo1/DsWWc5ln725REXeAL5ZkrHoz+4fsqMoKwlr/5TlCF4qFlf4BQkz4Y1es1aYsvSe7XUSlqAFSVvapGXETOmYPw4B9bc42XW5WSd7Q4wcwPJEoip8oeBZPIQynrgJzwDRvKc7hEezwDO7gamJ4MdfVeLWlc0D9QT1gaZMMvDcFifYtBgxA2+sU+Iiby3Rm+ZgV1Gi4JEBQwxTPEPjZPitMsziUuoZYGUGUWI4/KK+OPcBegPid5w8oDU+ZkDQVstsAsVn9b+BxUSVJfsKnE1Ud3EbldWSKyicl5AQ2AaX8+DqYwHqWsOh/nKOWJ5NaUD0Rb55WeMlnASBg0G0el7arOeXXRburNulPPj8vXM4fSDvgMKDN8BFGphF7cjc2S9ihUU5sBpZfCVsUQI4i2vJldBCApMn2zoyKjajVQdnWMkTfitaCUO9VLM6dqh0nAOYWZDPzlqLvSajrLtpBtYAcjP3Do+PEDS6aNWxqz74cXzZAen8tlOhi/KUja8uJc+TlfXd78+5u3B0h6txNS1kfUjuCVB8+wLWe+D3Z7YlLdXaWMZ7fLzUUTA9HVacwckl0hr/iq1IsvAS76VLhGD7dV34nR7gDNFHScOLJVPeFfdZCGvYjVrxg0Wbh7IriIgCWshU0hUIgoo+sVgOwBba/Uocze8i8JYLDw3ujgXte/XLe1C81VUn6Qmc+tzqAJtkxXd1MoZrQgsAf9gO4Lr7w8PFoJSLtzRFx7g+3Np859Wnx088mM4rKM8M1kzEKxItm6BMBhjfAOVs19E/j4Yo2VDDyKO+0ZzR8FVobo1LfyLEVGulwZ9tQvQMUoTNU1yyCdLWZpHkfwIuVzObGLdNbfEaafyMeP/jKWWgllOIXtNDDBKy42EhfRiR56vGMi2ZIrpAEWhghKEo/Hd03xzaVYIcreBDP+qTXmzYbqJC3r9+20ywNUZu5FcasVhzShxljANsDOBcBCjE5KKC6eiMf36xyjt3q+iUJUO6FGu79QtNjvsDj11/TC8H51w5fHfLFGqTfOy5LWBknYH3rIukcpS09MCVbEZDPfP8dX1DX5PawD8UN1rX/HeV4BhrDZmNN25To2aGc35qxWgMFPV3l9wM/6olZ5ZAnPAwYsNvI+Q5GDwQkWXGvmwkubk1oJON2V1+TexeltvcfoRupQvOH17tysXAE7Ce1faNneDCqby+hRIZ599DVB5uCzC1TBIgELBUbKHl7AbMtOoIQdxfzIqEJjGmqqPnJEj5o9n7+7VWdyrCfOer2pQOSwM+wKUM0U4209kfXfOgfjTHWJJC+0Mm+GvgXXgrNtz9eBxOtl6ZVCmJ9J1v6o8bNp25uplA8YPwIFBVDC1KOX2aCchp5rlHxJwnUMNNVV1V229sA6KmsFIZjQG7GfTEYuth265+f216lkVXIL7LWCYeEpbYiaFA5AsKRBVJDfhm6oORpY X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0cf89f90-0e12-4a94-6f28-08db7c69b1bd X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3139.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2023 08:36:00.2491 (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: 0TiF0Iqn4QHdszUX1T0FGTR2g/72CYGLnenuzmTkyaoNPdk01opdGqoY7udnG2UT1FFz7ZB+HPZGvs9w8A4AHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7081 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770479315870590216?= X-GMAIL-MSGID: =?utf-8?q?1770479315870590216?= From: Wei Fang Once the XDP frames have been successfully transmitted through the ndo_xdp_xmit() interface, it's the driver responsibility to free the frames so that the page_pool can recycle the pages and reuse them. However, this action is not implemented in the fec driver. This leads to a user-visible problem that the console will print the following warning log. [ 157.568851] page_pool_release_retry() stalled pool shutdown 1389 inflight 60 sec [ 217.983446] page_pool_release_retry() stalled pool shutdown 1389 inflight 120 sec [ 278.399006] page_pool_release_retry() stalled pool shutdown 1389 inflight 181 sec [ 338.812885] page_pool_release_retry() stalled pool shutdown 1389 inflight 241 sec [ 399.226946] page_pool_release_retry() stalled pool shutdown 1389 inflight 302 sec Therefore, to solve this issue, we free XDP frames via xdp_return_frame() while cleaning the tx BD ring. Fixes: 6d6b39f180b8 ("net: fec: add initial XDP support") Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/fec.h | 15 ++- drivers/net/ethernet/freescale/fec_main.c | 148 +++++++++++++++------- 2 files changed, 115 insertions(+), 48 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 9939ccafb556..8c0226d061fe 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -544,10 +544,23 @@ enum { XDP_STATS_TOTAL, }; +enum fec_txbuf_type { + FEC_TXBUF_T_SKB, + FEC_TXBUF_T_XDP_NDO, +}; + +struct fec_tx_buffer { + union { + struct sk_buff *skb; + struct xdp_frame *xdp; + }; + enum fec_txbuf_type type; +}; + struct fec_enet_priv_tx_q { struct bufdesc_prop bd; unsigned char *tx_bounce[TX_RING_SIZE]; - struct sk_buff *tx_skbuff[TX_RING_SIZE]; + struct fec_tx_buffer tx_buf[TX_RING_SIZE]; unsigned short tx_stop_threshold; unsigned short tx_wake_threshold; diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 9ce0319b33c3..940d3afe1d24 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -397,7 +397,7 @@ static void fec_dump(struct net_device *ndev) fec16_to_cpu(bdp->cbd_sc), fec32_to_cpu(bdp->cbd_bufaddr), fec16_to_cpu(bdp->cbd_datlen), - txq->tx_skbuff[index]); + txq->tx_buf[index].skb); bdp = fec_enet_get_nextdesc(bdp, &txq->bd); index++; } while (bdp != txq->bd.base); @@ -654,7 +654,7 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, index = fec_enet_get_bd_index(last_bdp, &txq->bd); /* Save skb pointer */ - txq->tx_skbuff[index] = skb; + txq->tx_buf[index].skb = skb; /* Make sure the updates to rest of the descriptor are performed before * transferring ownership. @@ -672,9 +672,7 @@ static int fec_enet_txq_submit_skb(struct fec_enet_priv_tx_q *txq, skb_tx_timestamp(skb); - /* Make sure the update to bdp and tx_skbuff are performed before - * txq->bd.cur. - */ + /* Make sure the update to bdp is performed before txq->bd.cur. */ wmb(); txq->bd.cur = bdp; @@ -862,7 +860,7 @@ static int fec_enet_txq_submit_tso(struct fec_enet_priv_tx_q *txq, } /* Save skb pointer */ - txq->tx_skbuff[index] = skb; + txq->tx_buf[index].skb = skb; skb_tx_timestamp(skb); txq->bd.cur = bdp; @@ -952,16 +950,33 @@ static void fec_enet_bd_init(struct net_device *dev) for (i = 0; i < txq->bd.ring_size; i++) { /* Initialize the BD for every fragment in the page. */ bdp->cbd_sc = cpu_to_fec16(0); - if (bdp->cbd_bufaddr && - !IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr))) - dma_unmap_single(&fep->pdev->dev, - fec32_to_cpu(bdp->cbd_bufaddr), - fec16_to_cpu(bdp->cbd_datlen), - DMA_TO_DEVICE); - if (txq->tx_skbuff[i]) { - dev_kfree_skb_any(txq->tx_skbuff[i]); - txq->tx_skbuff[i] = NULL; + if (txq->tx_buf[i].type == FEC_TXBUF_T_SKB) { + if (bdp->cbd_bufaddr && + !IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr))) + dma_unmap_single(&fep->pdev->dev, + fec32_to_cpu(bdp->cbd_bufaddr), + fec16_to_cpu(bdp->cbd_datlen), + DMA_TO_DEVICE); + if (txq->tx_buf[i].skb) { + dev_kfree_skb_any(txq->tx_buf[i].skb); + txq->tx_buf[i].skb = NULL; + } + } else { + if (bdp->cbd_bufaddr) + dma_unmap_single(&fep->pdev->dev, + fec32_to_cpu(bdp->cbd_bufaddr), + fec16_to_cpu(bdp->cbd_datlen), + DMA_TO_DEVICE); + + if (txq->tx_buf[i].xdp) { + xdp_return_frame(txq->tx_buf[i].xdp); + txq->tx_buf[i].xdp = NULL; + } + + /* restore default tx buffer type: FEC_TXBUF_T_SKB */ + txq->tx_buf[i].type = FEC_TXBUF_T_SKB; } + bdp->cbd_bufaddr = cpu_to_fec32(0); bdp = fec_enet_get_nextdesc(bdp, &txq->bd); } @@ -1360,6 +1375,7 @@ static void fec_enet_tx_queue(struct net_device *ndev, u16 queue_id) { struct fec_enet_private *fep; + struct xdp_frame *xdpf; struct bufdesc *bdp; unsigned short status; struct sk_buff *skb; @@ -1387,16 +1403,31 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id) index = fec_enet_get_bd_index(bdp, &txq->bd); - skb = txq->tx_skbuff[index]; - txq->tx_skbuff[index] = NULL; - if (!IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr))) - dma_unmap_single(&fep->pdev->dev, - fec32_to_cpu(bdp->cbd_bufaddr), - fec16_to_cpu(bdp->cbd_datlen), - DMA_TO_DEVICE); - bdp->cbd_bufaddr = cpu_to_fec32(0); - if (!skb) - goto skb_done; + if (txq->tx_buf[index].type == FEC_TXBUF_T_SKB) { + skb = txq->tx_buf[index].skb; + txq->tx_buf[index].skb = NULL; + if (bdp->cbd_bufaddr && + !IS_TSO_HEADER(txq, fec32_to_cpu(bdp->cbd_bufaddr))) + dma_unmap_single(&fep->pdev->dev, + fec32_to_cpu(bdp->cbd_bufaddr), + fec16_to_cpu(bdp->cbd_datlen), + DMA_TO_DEVICE); + bdp->cbd_bufaddr = cpu_to_fec32(0); + if (!skb) + goto tx_buf_done; + } else { + xdpf = txq->tx_buf[index].xdp; + if (bdp->cbd_bufaddr) + dma_unmap_single(&fep->pdev->dev, + fec32_to_cpu(bdp->cbd_bufaddr), + fec16_to_cpu(bdp->cbd_datlen), + DMA_TO_DEVICE); + bdp->cbd_bufaddr = cpu_to_fec32(0); + if (!xdpf) { + txq->tx_buf[index].type = FEC_TXBUF_T_SKB; + goto tx_buf_done; + } + } /* Check for errors. */ if (status & (BD_ENET_TX_HB | BD_ENET_TX_LC | @@ -1415,21 +1446,11 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id) ndev->stats.tx_carrier_errors++; } else { ndev->stats.tx_packets++; - ndev->stats.tx_bytes += skb->len; - } - /* NOTE: SKBTX_IN_PROGRESS being set does not imply it's we who - * are to time stamp the packet, so we still need to check time - * stamping enabled flag. - */ - if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS && - fep->hwts_tx_en) && - fep->bufdesc_ex) { - struct skb_shared_hwtstamps shhwtstamps; - struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; - - fec_enet_hwtstamp(fep, fec32_to_cpu(ebdp->ts), &shhwtstamps); - skb_tstamp_tx(skb, &shhwtstamps); + if (txq->tx_buf[index].type == FEC_TXBUF_T_SKB) + ndev->stats.tx_bytes += skb->len; + else + ndev->stats.tx_bytes += xdpf->len; } /* Deferred means some collisions occurred during transmit, @@ -1438,10 +1459,32 @@ fec_enet_tx_queue(struct net_device *ndev, u16 queue_id) if (status & BD_ENET_TX_DEF) ndev->stats.collisions++; - /* Free the sk buffer associated with this last transmit */ - dev_kfree_skb_any(skb); -skb_done: - /* Make sure the update to bdp and tx_skbuff are performed + if (txq->tx_buf[index].type == FEC_TXBUF_T_SKB) { + /* NOTE: SKBTX_IN_PROGRESS being set does not imply it's we who + * are to time stamp the packet, so we still need to check time + * stamping enabled flag. + */ + if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_IN_PROGRESS && + fep->hwts_tx_en) && fep->bufdesc_ex) { + struct skb_shared_hwtstamps shhwtstamps; + struct bufdesc_ex *ebdp = (struct bufdesc_ex *)bdp; + + fec_enet_hwtstamp(fep, fec32_to_cpu(ebdp->ts), &shhwtstamps); + skb_tstamp_tx(skb, &shhwtstamps); + } + + /* Free the sk buffer associated with this last transmit */ + dev_kfree_skb_any(skb); + } else { + xdp_return_frame(xdpf); + + txq->tx_buf[index].xdp = NULL; + /* restore default tx buffer type: FEC_TXBUF_T_SKB */ + txq->tx_buf[index].type = FEC_TXBUF_T_SKB; + } + +tx_buf_done: + /* Make sure the update to bdp and tx_buf are performed * before dirty_tx */ wmb(); @@ -3249,9 +3292,19 @@ static void fec_enet_free_buffers(struct net_device *ndev) for (i = 0; i < txq->bd.ring_size; i++) { kfree(txq->tx_bounce[i]); txq->tx_bounce[i] = NULL; - skb = txq->tx_skbuff[i]; - txq->tx_skbuff[i] = NULL; - dev_kfree_skb(skb); + + if (txq->tx_buf[i].type == FEC_TXBUF_T_SKB) { + skb = txq->tx_buf[i].skb; + txq->tx_buf[i].skb = NULL; + dev_kfree_skb(skb); + } else { + if (txq->tx_buf[i].xdp) { + xdp_return_frame(txq->tx_buf[i].xdp); + txq->tx_buf[i].xdp = NULL; + } + + txq->tx_buf[i].type = FEC_TXBUF_T_SKB; + } } } } @@ -3817,7 +3870,8 @@ static int fec_enet_txq_xmit_frame(struct fec_enet_private *fep, ebdp->cbd_esc = cpu_to_fec32(estatus); } - txq->tx_skbuff[index] = NULL; + txq->tx_buf[index].type = FEC_TXBUF_T_XDP_NDO; + txq->tx_buf[index].xdp = frame; /* Make sure the updates to rest of the descriptor are performed before * transferring ownership. From patchwork Tue Jul 4 08:29:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Fang X-Patchwork-Id: 115628 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp1076268vqx; Tue, 4 Jul 2023 02:05:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42vfCORqjZ3qxJMm2lE4HENItTcsXPH9maGZgcQqH5lRWpqlFZ6XQuF9ytJ0LZyfJhS304 X-Received: by 2002:a05:6a21:339d:b0:122:450b:48aa with SMTP id yy29-20020a056a21339d00b00122450b48aamr17476143pzb.21.1688461523962; Tue, 04 Jul 2023 02:05:23 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1688461523; cv=pass; d=google.com; s=arc-20160816; b=ppB3YClhxeQ00Torwm9p0eT9TibmuBrdNLamVtDxhaJpNP0n/2ljuKGFIypRrz38UM 3hCOzgiQWycd5durNhwOcsfT8VBJSJPTBV9jrPxg+iLfm72jnOwytg9NB27cmI9gG6iw se9qjJg0Xnqcxh3mDGdkFXuEqgr7Jb6dQxMMAL7SBCN6PHHgq1k9qiT+On18iXHiyhvv j3DgzFSc0Q5rME4OfmywLdOfXnA9ndIOmf3IIP3dKaUsYHFbKsvxv5b3wjKUdCvr+59g tpKnWyMGndN+DLdLEWArJCQtm3UNJtM7mBW4sE+dECHQj7MWr8xngLzbZIJ2a4Hz/sAD 8WdQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8TWwRRQcHEQ7tvYFsKYoBGP06TNaHnyF++a8BaZNPbU=; fh=SYUJmjUGpG2xsb/2udWEOqnn+PsMu/G7LfPz5pAgru8=; b=ze3+So/sLxS2Xk27VWhfJbuRTedFcmbsZOw/IeVN2v5uUxjRRtXo7cKa6YlZooIqGv c3J2maqJCuelkVAgEFm6n/ugzOIjoCCDiRMbaqDyKRUTQh6ZSEhmQtpfKHkgOpCosSKV YD8OVfqdqcvljmw57Y4zJYA0FieBbC+z5jx8fokiLYENiCXStIM1wfkuqwUEGjq5q7x/ 0QtYBalYWLjm9LzaPh/7qOWXToINx3pbHTj6WK7TWxpwgLIT2423cyWrG/iNeCYZ87i3 H2wjajIXH7EvcS4bQ5vFYza9f6ARNjYSNdd7SjmgIDQwA18SwRXb7pqnsCzX/CmPqsW9 FdPw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=MiVJqOLn; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m14-20020a656a0e000000b0055b4ef605e9si1935838pgu.496.2023.07.04.02.05.11; Tue, 04 Jul 2023 02:05:23 -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=@nxp.com header.s=selector2 header.b=MiVJqOLn; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.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=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231752AbjGDIgc (ORCPT + 99 others); Tue, 4 Jul 2023 04:36:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52572 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231696AbjGDIgQ (ORCPT ); Tue, 4 Jul 2023 04:36:16 -0400 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01on2040.outbound.protection.outlook.com [40.107.13.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9511E6D; Tue, 4 Jul 2023 01:36:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hb8TePXrNloDZf4lFHA0T7o3aQbEbBiRy1Sk6uOdJJB1fcJG+Yv7YY/6uG0Ysqq+5XBW0qibwbvoZc8sd0b87AbqOYig7Qe2E9LqECRZiRLOtvl02RrOBueadNkpoxDAgOPanWPjD3erHX3SgPGSx4AMYFzW+OH0fRN73iAYVAwewhNpmInyfr0krsnbfYAI2sM8s4YIjRUk9J3f721CeBSNKCKHhocDsxwcq/QkCSQN64LjbBWxOQSKXaM+fyMb7AAFN9HI6Jge+OmuAOhTJRL5KK8UXqmgYjhj0NHcRV8jYQ/jcYBmsSF6s7EyT2XzOsk260iAREaeyrtiKJ0puQ== 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=8TWwRRQcHEQ7tvYFsKYoBGP06TNaHnyF++a8BaZNPbU=; b=lwVo93rE4Yh58xAQgiCZzqv9yoiVLJG14lxzrz2UWQc1cpVnQrIeqsYEK599572tVlQA1S52LAqqzU7P7ABiVP/R+epPL50cFbgCx5M0RVEtIbLtjPz73kb/Z6Hjrq9Aruiu9S4lKDhyYR7meePFy5+Vn0nQ02prX+Qn0ZxxDkijyCM0JHvkY8H5XgQfX4s3hZKWmmFs7InEphsB9r4kUvJzlobi7QHTIV1nSh2SiCLpyeQGYMOG8Y6xQ5qV1x9Lo1w+5jXL5A3NQG1rENHX4LTqUaCmhKWFCzFES7uFIPxvrTBNGBFJ7xj22vreueTYbDWbRfqALK+zt7Sw1fibCQ== 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=8TWwRRQcHEQ7tvYFsKYoBGP06TNaHnyF++a8BaZNPbU=; b=MiVJqOLnxnzngr/jn+Csq6hTHbKaPZ+C9q3en2lxHAD3hV8ayItrEUyMZGPRvAEFCgflFbRv0m+m8bPZbAcpQwYxG8eVtxbH3UKos8LN8kAOGT3dDz3Mo2XlvSxHNBhFE6XLXFV5QMNUUksvht1enurdy7t9AxSHMopbwhOrAHs= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM5PR04MB3139.eurprd04.prod.outlook.com (2603:10a6:206:8::20) by DB8PR04MB7081.eurprd04.prod.outlook.com (2603:10a6:10:fe::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6544.24; Tue, 4 Jul 2023 08:36:11 +0000 Received: from AM5PR04MB3139.eurprd04.prod.outlook.com ([fe80::1edd:68cb:85d0:29e0]) by AM5PR04MB3139.eurprd04.prod.outlook.com ([fe80::1edd:68cb:85d0:29e0%7]) with mapi id 15.20.6544.024; Tue, 4 Jul 2023 08:36:11 +0000 From: wei.fang@nxp.com To: davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, ast@kernel.org, daniel@iogearbox.net, hawk@kernel.org, john.fastabend@gmail.com, shenwei.wang@nxp.com, xiaoning.wang@nxp.com, netdev@vger.kernel.org Cc: linux-imx@nxp.com, linux-kernel@vger.kernel.org, bpf@vger.kernel.org Subject: [PATCH net 3/3] net: fec: increase the size of tx ring and update thresholds of tx ring Date: Tue, 4 Jul 2023 16:29:16 +0800 Message-Id: <20230704082916.2135501-4-wei.fang@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230704082916.2135501-1-wei.fang@nxp.com> References: <20230704082916.2135501-1-wei.fang@nxp.com> X-ClientProxiedBy: SG2PR01CA0168.apcprd01.prod.exchangelabs.com (2603:1096:4:28::24) To AM5PR04MB3139.eurprd04.prod.outlook.com (2603:10a6:206:8::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM5PR04MB3139:EE_|DB8PR04MB7081:EE_ X-MS-Office365-Filtering-Correlation-Id: e74ae782-50f9-465b-1f20-08db7c69b8ca X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ONEYQpDOAA/ZtLHExvvzJ5EyWkJf1AuFICdWkPdCTjxcv5EpxBKZMoQyN9RUhB4TrrNZb2XRbvSrXKigbXPXwHKnjhsP7QU0sVTZ0BSlxUjXyD5wQR3yqKN7QwR2oqdyY8LXqbIXFu28WvWQ8v6rCLl3a/CM0y/h6jKli+BClQMkC8b9FNQXOjEF31djDBhW6r8S/ZA2HxePZKBwQanYawCZWBWjT1DECrll1seh7DHD/NnjwfTQDv9X4SlbZ4SSqaQEK2EQhzyDvVA3DwKajqY9z9ZtMr1MObDH6FN7jUzjpYnB3DnWemChctCrlUx/NOVcBwdAw+BYkIJzy2GI2/QwQPbzXlDJ/d7jCNs27OTltKOrKC85VMH1kelJsO86AoXQBS8KSUaBqT0aYHMacQhOPRB2u709HngPjUKhPvBXq5iKGwSJV60Of+x1eeeiRj+PPxqWA3sIiR3pc0AtZjtrAjTbZ4oBxPVaAB0Iy7om9qd+jyvYtXaPx3gvRkMwcPJpP736MfEaV93Gjqcnyn3tcPv2WXZ8hTy4IculL5favyweAD2jUi8gMaK9CWs90cEqQq+0EPHqj9j/vjECyjeU+m0CbcTn9exr6kHG9Qk14rR+D6heZSwXf/ANlJbL X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM5PR04MB3139.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(396003)(366004)(39860400002)(376002)(346002)(136003)(451199021)(316002)(41300700001)(6486002)(6512007)(52116002)(26005)(83380400001)(186003)(9686003)(1076003)(6506007)(2616005)(38350700002)(478600001)(921005)(38100700002)(66556008)(66946007)(66476007)(4326008)(5660300002)(7416002)(15650500001)(86362001)(2906002)(8676002)(8936002)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iBvaE2AoEFD/xTYfghkPrDO0bwSUs4BLeQV8bN9NpSvvjZ5Xs2bwJO7PlZUxGi8hU0f+fprUkXrZ6/QXkExV78EaSuEyk3Rhagm7vvpJt7Ub12IkhYALmdEWbmCZxkMf41hWrIELpUYMh/NELVnevR3gaGBI9bxZM5YggbRhyoyC1iiadzG+A3rk9HY0YzT1v0jRB4fpHxdhQX5HcCMIRGJ9o9CuqFbb56x74e/k3pXQilw4B7Inw7FL17NpnlIh4Z4dBJzrLbbhude5bp1nL+Oom9lXD77k8AdU7LdYp2KxM1SxsqesnEvhTboIq5g2Yfc/aLvvkWiL090ZeujPd3ZcIHb2f/skDheUEVeJ22mZHaeW2FG4qHT1qOCAw8ROPA285iGFa2tPNRgFxVzyu2WMlhJujUKRN+W9bxdglhr9o4SsSEhZvXA/2aKJPT0O+SwHPlbTBT+zxTTy9pocMvcDY4V+xrUMvSg05MzQlyvwFA/Sde85WYFLbtkr+9jqMBTnVqpOU1Phgp+m+Hp0GNTQzR3nfvaTaemSn2aPGZx+eN7a9GnYSjUU6MXJdc42w3C+4zx8usnJdvDDzYdX17M6kfkdq8O9LUoJwTWw/CU75s2lTaJzLJm3cTkDShOIGPPu6rSzSr5qviS0wwnAd7kVXbcsvh7Fc4UIEuZSlDIgC4wanVNjY6Fis+n1ydTr6qhhkB5OU0FbsWwrY6MWvLfiOhILMxiHjTFzrggL6kMZJVwArXIMTroKGDiTqfaaTnrXQUcm3r8DUbJMPLCFaNVnkJk2IO73JgR4WXCMAPAn1TDBWoKnk6QazVDQgG4rHo7tfL05g16EUMKRK5VmiX3+1ZLCB6LaMxKjd5vThYno90oo03nhCPAfHAxfJrgXz7+b6F+/t8AVBJpH+YXgPqAiuWqhszw3ieaP6q/1wAHZhVHgZrU/D/y7GTA7RvNIERSNKDLoFeffBtWMzcilGYjGGIySvM40i9hFfibkeDC4lkQxbPvDhCtXPJE0gbT28sDZE5mkZdYoqlytur4fzOJDxhQZJUc68TAO/XL8iVWnyPBIz5asRoRTq8J12v5wkzybD5CvtN/VrIg8eTKWPDe6K8HZ00/LjQe6AwRmkLiBgGsiEG5YjbGWR+tJ2bkdcdvy6HVn+AYNTur0pjeC1Xc3BNMYt/9gtfJ7jesU65IFV7Pr5wKXE7JGlBbePjjNOPVXu19y9ZjlPoqea4/3tPjYqU0mLEEooUjgABUaABONVUiXK5f23v/mZe5oHAstwzbImxHHW948Kjp8A5DSgw+85bYX01J7PASL7ZUIvomYl1waf+4FPHtrItuDo89Wo97yc4jtF/sLuzr9Ffel0QN3FoE2S8gSCkKcBPDQv1XO1ws3kDJ/j0nNUUA1wPLo55i8rqXEH1IGYqVZuoWSAvMmTLm2XNQzLscCpq2yYIkSSwuxrlhG6eiHiMKM8OM+zaV69ZuDqwsXl2E6lLHG8+VOKwyahyRK1R6eG538D0MDOoo3i+SR5uQiqwxXui6/UaiQGObzMM9m7Zsa7+9J0uTwGQFVdgLU4xeZFMEMihcgWb3rUIPZ8js/QzuGYBza X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e74ae782-50f9-465b-1f20-08db7c69b8ca X-MS-Exchange-CrossTenant-AuthSource: AM5PR04MB3139.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2023 08:36:11.8740 (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: YcvOK+JsauLRIkJ3FBlrZuj18+/KuVtxZQDaMPCRl+O4Lq/BTM73hHxCKDa2PUdCCZMBVRKWVKmgF3ShGo7aKA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7081 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770480230610140868?= X-GMAIL-MSGID: =?utf-8?q?1770480230610140868?= From: Wei Fang When the XDP feature is enabled and with heavy XDP frames to be transmitted, there is a considerable probability that available tx BDs are insufficient. This will lead to some XDP frames to be discarded and the "NOT enough BD for SG!" error log will appear in the console (as shown below). [ 160.013112] fec 30be0000.ethernet eth0: NOT enough BD for SG! [ 160.023116] fec 30be0000.ethernet eth0: NOT enough BD for SG! [ 160.028926] fec 30be0000.ethernet eth0: NOT enough BD for SG! [ 160.038946] fec 30be0000.ethernet eth0: NOT enough BD for SG! [ 160.044758] fec 30be0000.ethernet eth0: NOT enough BD for SG! In the case of heavy XDP traffic, sometimes the speed of recycling tx BDs may be slower than the speed of sending XDP frames. There may be several specific reasons, such as the interrupt is not responsed in time, the efficiency of the NAPI callback function is too low due to all the queues (tx queues and rx queues) share the same NAPI, and so on. After trying various methods, I think that increase the size of tx BD ring is simple and effective. Maybe the best resolution is that allocate NAPI for each queue to improve the efficiency of the NAPI callback, but this change is a bit big and I didn't try this method. Perheps this method will be implemented in a future patch. In addtion, this patch also updates the tx_stop_threshold and the tx_wake_threshold of the tx ring. In previous logic, the value of tx_stop_threshold is 217, however, the value of tx_wake_threshold is 147, it does not make sense that tx_wake_threshold is less than tx_stop_threshold. Besides, both XDP path and 'slow path' share the tx BD rings. So if tx_stop_threshold is 217, in the case of heavy XDP traffic, the slow path is easily to be stopped, this will have a serious impact on the slow path. Fixes: 6d6b39f180b8 ("net: fec: add initial XDP support") Signed-off-by: Wei Fang --- drivers/net/ethernet/freescale/fec.h | 2 +- drivers/net/ethernet/freescale/fec_main.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h index 8c0226d061fe..63a053dea819 100644 --- a/drivers/net/ethernet/freescale/fec.h +++ b/drivers/net/ethernet/freescale/fec.h @@ -355,7 +355,7 @@ struct bufdesc_ex { #define RX_RING_SIZE (FEC_ENET_RX_FRPPG * FEC_ENET_RX_PAGES) #define FEC_ENET_TX_FRSIZE 2048 #define FEC_ENET_TX_FRPPG (PAGE_SIZE / FEC_ENET_TX_FRSIZE) -#define TX_RING_SIZE 512 /* Must be power of two */ +#define TX_RING_SIZE 1024 /* Must be power of two */ #define TX_RING_MOD_MASK 511 /* for this to work */ #define BD_ENET_RX_INT 0x00800000 diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 940d3afe1d24..6c255c0d6f41 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3348,9 +3348,8 @@ static int fec_enet_alloc_queue(struct net_device *ndev) txq->bd.ring_size = TX_RING_SIZE; fep->total_tx_ring_size += fep->tx_queue[i]->bd.ring_size; - txq->tx_stop_threshold = FEC_MAX_SKB_DESCS; - txq->tx_wake_threshold = - (txq->bd.ring_size - txq->tx_stop_threshold) / 2; + txq->tx_stop_threshold = MAX_SKB_FRAGS; + txq->tx_wake_threshold = MAX_SKB_FRAGS + 1; txq->tso_hdrs = dma_alloc_coherent(&fep->pdev->dev, txq->bd.ring_size * TSO_HEADER_SIZE, @@ -3837,7 +3836,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"); + netdev_err_once(fep->netdev, "NOT enough BD for SG!\n"); return -EBUSY; }