From patchwork Thu Nov 19 22:01:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ramsay, Lincoln" X-Patchwork-Id: 11919049 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 X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70A12C388F9 for ; Thu, 19 Nov 2020 22:01:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E836622242 for ; Thu, 19 Nov 2020 22:01:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=digi.com header.i=@digi.com header.b="jiidD2CJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726362AbgKSWBd (ORCPT ); Thu, 19 Nov 2020 17:01:33 -0500 Received: from outbound-ip24a.ess.barracuda.com ([209.222.82.206]:50702 "EHLO outbound-ip24a.ess.barracuda.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726154AbgKSWBc (ORCPT ); Thu, 19 Nov 2020 17:01:32 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10lp2106.outbound.protection.outlook.com [104.47.55.106]) by mx6.us-east-2a.ess.aws.cudaops.com (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Thu, 19 Nov 2020 22:01:22 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T8bwgm0d28dI5b+zTlyWjAO54Qc95LdI5LQR2ZGTX16ocWeiShClrOsg0SmvogAIIw2nDyS6EKtPnxzJk6XEZLYnxYDw5PvQicqg59ahgITl18RX1XGrfgfzkvmsRR8t7vFn5YHp9JXIFBH+6L1QAolEFvHxlY5cEB4Nn/jMYdmkgkBrfIbsT/ovFt+4RZCLt5Rb+BHAm6+aNcspdBd8qaK4fnikt3a1BXFHNobBEgA+6vmc+v2ULNKj7mcEwJlyokxUJwpZldHb2beK+sLD8fDK9GLQjTvOK6kdwJYnknLEOhfWumnisVtN/gPlHbU72m5cUsYvheAalJ50JbGEYA== 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-SenderADCheck; bh=wjRgySdq9eDI1ttICg88/SyLu/oUtjeDqk6MfY8OJv0=; b=jl39moGxpNtpC4aMik2Oc+E52xL1+hXxXYXMoSm4NzHP+2awHaKpCYfPlgbN7rr47TbKrakn56/55SYNB+jX9WAjP9GA/IxZokHxeON7KXoNAiQVp+5mrV8LCScKNjUfxibkYdsJzdQzeNGzg7vxREnm4lzI4rOmLK/hDKSolqL7kUq1zEGCEIO2t6BDq5AbZrdrGUOn/zgkNML2rsrQWqxDzq/P09KAsTbDzFKid2v5WhaX/FmAjDXnjFXHfmH3v+krnBkbhbMQvwY0RxdEvLrgV7IUfLfVO7SJOLNg9GUeCe47OX7twSWSY3Sue76yGvJQrGdiJAztqWs9EvB9qA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=digi.com; dmarc=pass action=none header.from=digi.com; dkim=pass header.d=digi.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=digi.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wjRgySdq9eDI1ttICg88/SyLu/oUtjeDqk6MfY8OJv0=; b=jiidD2CJQN4Lb0LhUu1vxLGCgFnUfIdwBYAIVJFk3y5GULLFllbwS+jm3IEYcHDJHfY6//J6duSEXuHsqpKI91/r16C8vRZoh5eTHwwTDqkr27KG6m2f2o0iWmds0JEnsnNM5hXNUlwSi66NdONQd8glPPQF6AP20gZv8CoTiNU= Received: from CY4PR1001MB2311.namprd10.prod.outlook.com (2603:10b6:910:44::24) by CY4PR10MB1478.namprd10.prod.outlook.com (2603:10b6:903:2a::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3564.28; Thu, 19 Nov 2020 22:01:21 +0000 Received: from CY4PR1001MB2311.namprd10.prod.outlook.com ([fe80::a956:bdc0:5119:197]) by CY4PR1001MB2311.namprd10.prod.outlook.com ([fe80::a956:bdc0:5119:197%6]) with mapi id 15.20.3564.033; Thu, 19 Nov 2020 22:01:21 +0000 From: "Ramsay, Lincoln" To: Igor Russkikh , "David S. Miller" , Jakub Kicinski , "netdev@vger.kernel.org" , Dmitry Bogdanov Subject: [PATCH] aquantia: Remove the build_skb path Thread-Topic: [PATCH] aquantia: Remove the build_skb path Thread-Index: AQHWvr+D9OUe7+XJI0yBaR2s4ZL4BQ== Date: Thu, 19 Nov 2020 22:01:21 +0000 Message-ID: References: ,<2b392026-c077-2871-3492-eb5ddd582422@marvell.com>,, In-Reply-To: Accept-Language: en-AU, en-US Content-Language: en-AU X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: marvell.com; dkim=none (message not signed) header.d=none;marvell.com; dmarc=none action=none header.from=digi.com; x-originating-ip: [158.140.192.185] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 1fadea22-f843-4a66-46ab-08d88cd6a67e x-ms-traffictypediagnostic: CY4PR10MB1478: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:5516; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: O9gM6K+AtbE2z1DsvrXIa5f4o754aloDS3Do4yIQpas8Y11yWR6FTIp1I4q8bYXs6ZUGq6DXTam+grCakOnPRrpGtePjf6AAApRPdaaIyrMJQdboBi6FikAKawFGbQYT3RXDRViGzXZ5vdfxEIxDNl8z3qrjczvDGskzan+vjU2GkWJSHigS5zvB+uruyy4RTKjnCreYo4xquce3W09i6lCdCKHAe6SkzTchJWd/n2RUPefuHLwdBg1ckG4zVKK6mvek3GQRQer/iS7LKC5rcrbB79qyB8Fy1/zv0eYFZ4PoNqGgrX4rD0FqC8AONDrg x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR1001MB2311.namprd10.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(39850400004)(376002)(366004)(346002)(136003)(396003)(6506007)(76116006)(66946007)(66556008)(64756008)(8676002)(66446008)(83380400001)(86362001)(5660300002)(52536014)(71200400001)(33656002)(316002)(66476007)(91956017)(110136005)(2906002)(8936002)(55016002)(478600001)(186003)(2940100002)(26005)(7696005)(9686003);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata: HfNiMVwvkh+4jXNL7j3FaILAv0JK4wfLu5Yu0la3jo70XL7kgM0nRWVjVZpdkzzJo6n4n8gl9uqPI5qst7AhJXRhDFZYrBMZzUAjsALUSxW9uV09lKwDokGCmV2KuH0VHKlcJB9aVIV78jW40C16Fs+tHua+f7pmXSsoQf0ewDlM0gN7y09t6QfueQnE35O2C4jAl9L8LKCrDcDQ+n9xTnmmhIFr87kCJ0xLp8NZc7OAGxpZHO+1tjSBDB+sfjWQ9O15k2nJLrJ25mxrcws1aGUKpaMwDW26acDd8z6MktW4g/v3ewDce8hMzjIbNCkt6S5Mrz4u8eGqcQKocJlbW7cicQVDY7Zg2mLI+DLCdRaJHnkG40EFDaYkel4Rm6lrKFTscQfS0V6gh1M0Hnpr6vluJe+w/IMQQgcD+gdRGHPmL8AUA3McPUGd5ryhLy94hATa36t+Q8y9fvo/8f+cOW7kl+LpbiU7QHxCM6YWPA0/EKD5CrIHmoxoEO9deKrhXV5DBQXxMypyGp7bS215DV3XIDxE/dRicUtXaYLy24MJgEHXyW0m1xn3N4Xoc0J7xbAbbz0qzuPlvWuOLzSR3o2nkmBWbJClNuRw0tzyhcyJlM9RL/xEewY7suhndlVu8RkzKqyFNkSUN+9CEJ3Aj7jLcJX7kRHbZkfCIoTERqBv7T1oPaS/F5nRL3FrGSTT5Dyy6ECqMyDuSW+TFzAmLdHh38eSJDPFdh/SloEdNYKx8eOEKhoJODSGcEzjwcd85iZs+rB8V3WzsXohGYna7hTiuax6KR1piZjOkqCgflo4mIbLErZTRY2dK0cy74u9q3jSOjyfc2xofjdMh80MDGs1ArSTXvYmoaY9lsnrdSVlWKwB7SgVtjweJ217FC5AN/B7Lv2QcNnrRGUJFErMWw== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: digi.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: CY4PR1001MB2311.namprd10.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1fadea22-f843-4a66-46ab-08d88cd6a67e X-MS-Exchange-CrossTenant-originalarrivaltime: 19 Nov 2020 22:01:21.6029 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: abb4cdb7-1b7e-483e-a143-7ebfd1184b9e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: yvDns8rNRV5WZsqjXCiAzgIHgCfooIh4YDwUo9lFY1RYdVlSXdt1/TfAJIVZp0CDXOub627YLq9f1IRNCjbOHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR10MB1478 X-BESS-ID: 1605823282-893010-4404-14451-1 X-BESS-VER: 2019.1_20201119.1803 X-BESS-Apparent-Source-IP: 104.47.55.106 X-BESS-Outbound-Spam-Score: 0.00 X-BESS-Outbound-Spam-Report: Code version 3.2, rules version 3.2.2.228306 [from cloudscan17-107.us-east-2b.ess.aws.cudaops.com] Rule breakdown below pts rule name description ---- ---------------------- -------------------------------- 0.00 BSF_BESS_OUTBOUND META: BESS Outbound X-BESS-Outbound-Spam-Status: SCORE=0.00 using account:ESS112744 scores of KILL_LEVEL=7.0 tests=BSF_BESS_OUTBOUND X-BESS-BRTS-Status: 1 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The build_skb path fails to allow for an SKB header, but the hardware buffer it is built around won't allow for this anyway. Just always use the slower codepath that copies memory into an allocated SKB. Signed-off-by: Lincoln Ramsay Acked-by: Igor Russkikh --- .../net/ethernet/aquantia/atlantic/aq_ring.c | 118 ++++++++---------- 1 file changed, 50 insertions(+), 68 deletions(-) diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c index 68fdb3994088..74f6f41b57e9 100644 --- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c @@ -385,79 +385,61 @@ int aq_ring_rx_clean(struct aq_ring_s *self, buff->rxdata.pg_off, buff->len, DMA_FROM_DEVICE); - /* for single fragment packets use build_skb() */ - if (buff->is_eop && - buff->len <= AQ_CFG_RX_FRAME_MAX - AQ_SKB_ALIGN) { - skb = build_skb(aq_buf_vaddr(&buff->rxdata), + skb = napi_alloc_skb(napi, AQ_CFG_RX_HDR_SIZE); + if (unlikely(!skb)) { + err = -ENOMEM; + goto err_exit; + } + if (is_ptp_ring) + buff->len -= + aq_ptp_extract_ts(self->aq_nic, skb, + aq_buf_vaddr(&buff->rxdata), + buff->len); + + hdr_len = buff->len; + if (hdr_len > AQ_CFG_RX_HDR_SIZE) + hdr_len = eth_get_headlen(skb->dev, + aq_buf_vaddr(&buff->rxdata), + AQ_CFG_RX_HDR_SIZE); + + memcpy(__skb_put(skb, hdr_len), aq_buf_vaddr(&buff->rxdata), + ALIGN(hdr_len, sizeof(long))); + + if (buff->len - hdr_len > 0) { + skb_add_rx_frag(skb, 0, buff->rxdata.page, + buff->rxdata.pg_off + hdr_len, + buff->len - hdr_len, AQ_CFG_RX_FRAME_MAX); - if (unlikely(!skb)) { - err = -ENOMEM; - goto err_exit; - } - if (is_ptp_ring) - buff->len -= - aq_ptp_extract_ts(self->aq_nic, skb, - aq_buf_vaddr(&buff->rxdata), - buff->len); - skb_put(skb, buff->len); page_ref_inc(buff->rxdata.page); - } else { - skb = napi_alloc_skb(napi, AQ_CFG_RX_HDR_SIZE); - if (unlikely(!skb)) { - err = -ENOMEM; - goto err_exit; - } - if (is_ptp_ring) - buff->len -= - aq_ptp_extract_ts(self->aq_nic, skb, - aq_buf_vaddr(&buff->rxdata), - buff->len); - - hdr_len = buff->len; - if (hdr_len > AQ_CFG_RX_HDR_SIZE) - hdr_len = eth_get_headlen(skb->dev, - aq_buf_vaddr(&buff->rxdata), - AQ_CFG_RX_HDR_SIZE); - - memcpy(__skb_put(skb, hdr_len), aq_buf_vaddr(&buff->rxdata), - ALIGN(hdr_len, sizeof(long))); - - if (buff->len - hdr_len > 0) { - skb_add_rx_frag(skb, 0, buff->rxdata.page, - buff->rxdata.pg_off + hdr_len, - buff->len - hdr_len, - AQ_CFG_RX_FRAME_MAX); - page_ref_inc(buff->rxdata.page); - } + } - if (!buff->is_eop) { - buff_ = buff; - i = 1U; - do { - next_ = buff_->next, - buff_ = &self->buff_ring[next_]; + if (!buff->is_eop) { + buff_ = buff; + i = 1U; + do { + next_ = buff_->next, + buff_ = &self->buff_ring[next_]; - dma_sync_single_range_for_cpu( - aq_nic_get_dev(self->aq_nic), - buff_->rxdata.daddr, - buff_->rxdata.pg_off, - buff_->len, - DMA_FROM_DEVICE); - skb_add_rx_frag(skb, i++, - buff_->rxdata.page, - buff_->rxdata.pg_off, - buff_->len, - AQ_CFG_RX_FRAME_MAX); - page_ref_inc(buff_->rxdata.page); - buff_->is_cleaned = 1; - - buff->is_ip_cso &= buff_->is_ip_cso; - buff->is_udp_cso &= buff_->is_udp_cso; - buff->is_tcp_cso &= buff_->is_tcp_cso; - buff->is_cso_err |= buff_->is_cso_err; + dma_sync_single_range_for_cpu( + aq_nic_get_dev(self->aq_nic), + buff_->rxdata.daddr, + buff_->rxdata.pg_off, + buff_->len, + DMA_FROM_DEVICE); + skb_add_rx_frag(skb, i++, + buff_->rxdata.page, + buff_->rxdata.pg_off, + buff_->len, + AQ_CFG_RX_FRAME_MAX); + page_ref_inc(buff_->rxdata.page); + buff_->is_cleaned = 1; - } while (!buff_->is_eop); - } + buff->is_ip_cso &= buff_->is_ip_cso; + buff->is_udp_cso &= buff_->is_udp_cso; + buff->is_tcp_cso &= buff_->is_tcp_cso; + buff->is_cso_err |= buff_->is_cso_err; + + } while (!buff_->is_eop); } if (buff->is_vlan)