From patchwork Tue Feb 2 17:34:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Camelia Alexandra Groza X-Patchwork-Id: 375005 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=-18.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, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 9D042C433DB for ; Tue, 2 Feb 2021 17:38:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6CF9F64F4D for ; Tue, 2 Feb 2021 17:38:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237662AbhBBRic (ORCPT ); Tue, 2 Feb 2021 12:38:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237633AbhBBRgX (ORCPT ); Tue, 2 Feb 2021 12:36:23 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on0600.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::600]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B6BCC06174A for ; Tue, 2 Feb 2021 09:35:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KLByCX7D74g4b015V50TsG1TbWhhYro7VSJvGxad/I9h8ihaU/7LG/q2hWHHefrhezewuPkBnUytys+wLliTt0CmonWjBaxu6F6680ngpfRk2X0eD1gD2cT6NW6Bxe1oYRkN3SqhQg8IKGSg1DacxPecHr/FdHwG4x98RkT8kgf6kNnEsRnrDE291pS9ScIVQFOz3URPZiSAmfhs4XgP92IsOlsdIh9WDteJEaILWajlXMbV9TCRP1LlDsTv0xtrpa35mNTn0fGQ5VL8aEek2CzgMt5anT1L15XZO0I/myPybexAQk//CLZm8iFzqeyFjylwiTCGZCmJC0aLj5053Q== 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=/opQK1JsT0Y3WffcPTa1zoLMSaAeUoUqPdViq5yNbEM=; b=QrD9YtBTyNymkTUXMrR2QZ2Cu4J0vqsqxLD/2sXWe5r7wqhwwaftxxQjR1uVSNYY8czNaFLBQICkZJ3LZ4XPLg7pHql7+lml9T/Pn6DppSef5VJId3ljEUzHmVsQlq/yHGsplBQrUy5taSRD1pKPANRIbJIiX32dOEKeXnbdoW3jvC7fKKhNKJmuCoqDqlT5q563W8Czaqnamrf8rt6ncZh6FSPe5I8tyWLsMjNsz1kPmOmKj7w+9oNV9J8fJCd82sxzIE02xrsg1d2OS/72XiLE6m+06+JDGdpcRlWWM905YT0IHh+I43Cr7mao3cCWC8lVQaraxTo6w6N9RyzyRA== 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=/opQK1JsT0Y3WffcPTa1zoLMSaAeUoUqPdViq5yNbEM=; b=VscVZpvHqrhRdFxcwHqPhF+llYaWg8h2mbe9gNH66EFDSZlvL8pf5FpeoyOPAmRaruRU1FVqNucbWHSZ6KFVYdwbnqL3rf5Un2KGey4cCBUHUDmRyaEHyEzz4p76JcD76PEQiyCW2C3K7TV9K1ogEYHExuLjnR2qnPtsdlefzls= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) by VE1PR04MB6462.eurprd04.prod.outlook.com (2603:10a6:803:11c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16; Tue, 2 Feb 2021 17:35:34 +0000 Received: from VI1PR04MB5807.eurprd04.prod.outlook.com ([fe80::6ccd:7fa9:bada:4]) by VI1PR04MB5807.eurprd04.prod.outlook.com ([fe80::6ccd:7fa9:bada:4%7]) with mapi id 15.20.3805.027; Tue, 2 Feb 2021 17:35:34 +0000 From: Camelia Groza To: kuba@kernel.org, davem@davemloft.net, maciej.fijalkowski@intel.com Cc: madalin.bucur@oss.nxp.com, netdev@vger.kernel.org, Camelia Groza Subject: [PATCH net 1/3] dpaa_eth: reserve space for the xdp_frame under the A050385 erratum Date: Tue, 2 Feb 2021 19:34:42 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: AM3PR07CA0093.eurprd07.prod.outlook.com (2603:10a6:207:6::27) To VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15136.swis.ro-buh01.nxp.com (83.217.231.2) by AM3PR07CA0093.eurprd07.prod.outlook.com (2603:10a6:207:6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.8 via Frontend Transport; Tue, 2 Feb 2021 17:35:33 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: e8bc220d-4eb9-4e14-e300-08d8c7a0f1f8 X-MS-TrafficTypeDiagnostic: VE1PR04MB6462: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7691; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ASUXITgb0P9kcvx2ALH5fNy28rkS+zc8AFqfr83lENVc8QdHh2R9xAo8oGdDtPsGS0PDIlvPOpURfuj51430EZmU0VIDZ3sBQpH+0xO4PCAAE5DaJ/1kFSn+rgCyHjvhzpD7y8QHReQIfwH1G1bPAN4h8jDsW04NnTrnGCJApx0cwtXBn8aripyl4GCNxW8WTaBnoNYwPWj4rXvloY4ckfS+5IYQBK9UQbYqShik8Mts1Yd482RGb99une7AfpW9QyDkB0Ab93sf+uUH0VBMkqj5N2nCiGPyIkiB+5/cgc5MyixrkTlby7AVuc8I+/8KpbGhZ6yaX1bChuh9pLmdpmZJ4OJN37lRDtA6gMfQbruc4jDr85W+v/zRqsu5yrl4UdCqu0qnwuLT1mUyB/L5YKAqN9hkVGMVB+hIvS//hA4EVZAguZZRO/FHRQJZ2+HE62jmhF37VVVx7wSGeY+JbQKMKdVpMb/0BiLv/4ZdL/Z0pCLjyjSKzoEudoFhH5CbhAX6GQvOf8Iwljhu08LEIg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5807.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(5660300002)(26005)(6486002)(52116002)(86362001)(186003)(44832011)(316002)(36756003)(478600001)(8936002)(16526019)(8676002)(66946007)(2906002)(956004)(6666004)(2616005)(83380400001)(7696005)(4326008)(66476007)(66556008); DIR:OUT; SFP:1101; X-MS-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b0rIJaJHJOe1ngRJPqhyqp2NsHPXZmE7yvxZpGvmcbv0lUKC1uyM++QTyNJzovSE5hRLJn+PfTILxa/5fzfX7gT7SDXcRMXqgyYJ8o0Hrwn0mTVlIxGVpSwOIhdxwym0E1xOtVq5p3rjKV55N3br6rbBEA3RJdSu4WA/OR4OjAM9mWPiFf1RX0m1BgAZiBtIbXo1xYLVJ5D1ObFXHFKS8KZeDhW3WIvxvy8bRRFYeZQn7/2CQi0EyfgtLBTZ8x5Gy4XPhp4sPUlc7zF X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8bc220d-4eb9-4e14-e300-08d8c7a0f1f8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5807.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2021 17:35:34.2829 (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: wbmOwNDhZyiDEbyh7gD1pbNGZNMirn1Ael8KbmPH8RiscGd2M2c5nuRx90i2rpM0gbgY4HHki/CIVfkOH9/YKQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org When the erratum workaround is triggered, the newly created xdp_frame structure is stored at the start of the newly allocated buffer. Avoid the structure from being overwritten by explicitly reserving enough space in the buffer for storing it. Account for the fact that the structure's size might increase in time by aligning the headroom to DPAA_FD_DATA_ALIGNMENT bytes, thus guaranteeing the data's alignment. Fixes: ae680bcbd06a ("dpaa_eth: implement the A050385 erratum workaround for XDP") Signed-off-by: Camelia Groza --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 4360ce4d3fb6..e1d041c35ad9 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2182,6 +2182,7 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv, struct xdp_frame *new_xdpf, *xdpf = *init_xdpf; void *new_buff; struct page *p; + int headroom; /* Check the data alignment and make sure the headroom is large * enough to store the xdpf backpointer. Use an aligned headroom @@ -2197,19 +2198,31 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv, return 0; } + /* The new xdp_frame is stored in the new buffer. Reserve enough space + * in the headroom for storing it along with the driver's private + * info. The headroom needs to be aligned to DPAA_FD_DATA_ALIGNMENT to + * guarantee the data's alignment in the buffer. + */ + headroom = ALIGN(sizeof(*new_xdpf) + priv->tx_headroom, + DPAA_FD_DATA_ALIGNMENT); + + /* Assure the extended headroom and data fit in a one-paged buffer */ + if (headroom + xdpf->len > DPAA_BP_RAW_SIZE) + return -ENOMEM; + p = dev_alloc_pages(0); if (unlikely(!p)) return -ENOMEM; /* Copy the data to the new buffer at a properly aligned offset */ new_buff = page_address(p); - memcpy(new_buff + priv->tx_headroom, xdpf->data, xdpf->len); + memcpy(new_buff + headroom, xdpf->data, xdpf->len); /* Create an XDP frame around the new buffer in a similar fashion * to xdp_convert_buff_to_frame. */ new_xdpf = new_buff; - new_xdpf->data = new_buff + priv->tx_headroom; + new_xdpf->data = new_buff + headroom; new_xdpf->len = xdpf->len; new_xdpf->headroom = priv->tx_headroom; new_xdpf->frame_sz = DPAA_BP_RAW_SIZE; From patchwork Tue Feb 2 17:34:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Camelia Alexandra Groza X-Patchwork-Id: 375876 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=-18.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, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 17E3FC433E6 for ; Tue, 2 Feb 2021 17:39:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D4A8264F4D for ; Tue, 2 Feb 2021 17:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237591AbhBBRjo (ORCPT ); Tue, 2 Feb 2021 12:39:44 -0500 Received: from mail-eopbgr70088.outbound.protection.outlook.com ([40.107.7.88]:57602 "EHLO EUR04-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S234011AbhBBRhO (ORCPT ); Tue, 2 Feb 2021 12:37:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RZBUtPuVPaTeZ1JUA1eZ4OOMgg7xF8AM81NqGvdeBcAM5duNzwPdJw9jQogDjysZZIfAYLKaJBiHDsR4o3hErzcglzOGaJCgUvXGYaF+UtrZtMbB1uwwbOojXsrWOj5CT+SepvqJCvpjoYWpq8+MXS3DAtxFrF/DXkyvPQc/vEEKCxyU4RYB+aZxrPNQnKnTRdbDEULl1vzvAFthwGHG2EGBtV0wA/ICsamDYcEsDtUCjpMePIySMjyKteqpvid9WUjr8vnPLdY+JWOo1gLt7ZMfd3EqG5YAM33hp9Iy4iHoLKrL/X6yrJeWyNdcGtJl61sASD8LlTLYcojmLBmtAQ== 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=H62vxHvJ6GZBK5bLU/N9mBnjJJ4lA9+/vOTxuhxvbHs=; b=BPl0OPDz32QUTWzMH5q3VF8s4aHll0WW4dF9PqcEV9Gp8eZFSRObM0NN5fwhNWvYKa1MLgUXLpcGkv0cJtDarx9OgYQhEpcp1Tr2/5CEIY59GcVU6W5xBSH3FkA3G6e5Pjnx3aClBWHbVcIuNcu0O0o0h/Uvt3W3Lrab1iBsx7v5OmSROg/QSNflssXepIi84op6RspwSZBGOXJqYiZ50USwfvUKqjXRdX8of6xi/6X2AnoqacEoeXWjecb1iJrJgBXlGOkR6YTgBIDLTQZihos+1vL4l/qiM2aqnHDhvwwlkgsUgK3nvD9lQ33CXlsazwgpKdE+Rs6pbRm7Aj3+/A== 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=H62vxHvJ6GZBK5bLU/N9mBnjJJ4lA9+/vOTxuhxvbHs=; b=VrqEfswE2EasD87d2NDswm/bcYqWdNOyKQjDW421jdQZ5DRbUQQH42rTerbcDw6cFC7eVrHv/gru9T+mJsAsCq4U261+iKjEnH7drn+uaXACfMhiSNvB5T1mDEi08nhKC5ulwAk/qv7z9e0btM4FQWSklvcr23auvbBdr7nv4Ss= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) by VE1PR04MB6462.eurprd04.prod.outlook.com (2603:10a6:803:11c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16; Tue, 2 Feb 2021 17:35:36 +0000 Received: from VI1PR04MB5807.eurprd04.prod.outlook.com ([fe80::6ccd:7fa9:bada:4]) by VI1PR04MB5807.eurprd04.prod.outlook.com ([fe80::6ccd:7fa9:bada:4%7]) with mapi id 15.20.3805.027; Tue, 2 Feb 2021 17:35:36 +0000 From: Camelia Groza To: kuba@kernel.org, davem@davemloft.net, maciej.fijalkowski@intel.com Cc: madalin.bucur@oss.nxp.com, netdev@vger.kernel.org, Camelia Groza Subject: [PATCH net 2/3] dpaa_eth: reduce data alignment requirements for the A050385 erratum Date: Tue, 2 Feb 2021 19:34:43 +0200 Message-Id: <6e534e4b2da14bb57331446e950a49f237f979c0.1612275417.git.camelia.groza@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: AM3PR07CA0093.eurprd07.prod.outlook.com (2603:10a6:207:6::27) To VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15136.swis.ro-buh01.nxp.com (83.217.231.2) by AM3PR07CA0093.eurprd07.prod.outlook.com (2603:10a6:207:6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.8 via Frontend Transport; Tue, 2 Feb 2021 17:35:35 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: c37a2247-0447-4a15-ddc4-08d8c7a0f358 X-MS-TrafficTypeDiagnostic: VE1PR04MB6462: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gho7gDza694r4co8U2zHCJjqrYUsFZxu+fT+HP3luEdfewEHNg7kZfd4rKcDihUPQckQ3NuN1wytQlwVJ7nm/5w4/fm6EmQNdgqYtM75BTpMwIfRSm8S0YVX6KX6DPP9qGUEdKg19YKd9Kc5GKd1SWeoAhsVGYIpe/ooiVFWfbjMT6fxMVVh5FnYET3LSbo0hL+PK0gX33amsZR+1ov5q63rXhTl5Px7FUudOp1cXW1GIZMyqK0j3gzWxQc9JrTY6y5F4O8uW9H5RkWyvzVTH32z4QdkumABOwvD7dyq0LX+QOWaDYfGzq9e9/yXvBmVgf2OS5NAoXsYU+q11qKJi5xjErLva4F0ikp4ioNstzcW91sj/reAsQlKOh+wNjXS9b7G92IJxguMkKCXlKu59PPKav5OJdSRqW5Sis6eBo9+cOOAS3hes1ZbD4rkB9HhxL93QMgJw90RCi/MW4Qi+tSVds9U0UWeMS+MKMRC2wEqiSs/iN80+UMVL+k8dl7gW9kL8zI/afj7fIxjGO4uOA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5807.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(5660300002)(26005)(6486002)(52116002)(86362001)(186003)(44832011)(316002)(36756003)(478600001)(8936002)(16526019)(8676002)(66946007)(2906002)(956004)(6666004)(2616005)(83380400001)(7696005)(4326008)(66476007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: hpkuuUw4nfbe/Apk2OHwSRDJTt73qdOYFtxcGF9QLv3D+gy/r9cdpjP6axoNnYO4AyV2nCOovPa8hx2emTtqyfABKYYX1CEXgSB4eRHl248CgPXPtrgV6KzEhYfmrDq73DlPfDi8Cby6sLMbcW0eOP2oCzXw9f/DCOcN7XmNpKLT26Kpx+kpg0ABXDv6o0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A8nBVxFXeWYR9wvx4SMsScibHutz56on9ZqSgqCzmMY47JF8x+mWAOOQNV79BQen5ofisDouXW0TgdnhLlUnMP63V X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: c37a2247-0447-4a15-ddc4-08d8c7a0f358 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5807.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2021 17:35:36.6086 (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: iiv9IcLwl95TqXNdvH+1XeXbErubRHIrCek0jO5opDj1g2lgiklbIKGouFk4KF2YICcP+zgYiLpLnwtLGE9Urg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The 256 byte data alignment is required for preventing DMA transaction splits when crossing 4K page boundaries. Since XDP deals only with page sized buffers or less, this restriction isn't needed. Instead, the data only needs to be aligned to 64 bytes to prevent DMA transaction splits. These lessened restrictions can increase performance by widening the pool of permitted data alignments and preventing unnecessary realignments. Fixes: ae680bcbd06a ("dpaa_eth: implement the A050385 erratum workaround for XDP") Signed-off-by: Camelia Groza Acked-by: Maciej Fijalkowski --- drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index e1d041c35ad9..78dfa05f6d55 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2192,7 +2192,7 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv, * byte frame headroom. If the XDP program uses all of it, copy the * data to a new buffer and make room for storing the backpointer. */ - if (PTR_IS_ALIGNED(xdpf->data, DPAA_A050385_ALIGN) && + if (PTR_IS_ALIGNED(xdpf->data, DPAA_FD_DATA_ALIGNMENT) && xdpf->headroom >= priv->tx_headroom) { xdpf->headroom = priv->tx_headroom; return 0; From patchwork Tue Feb 2 17:34:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Camelia Alexandra Groza X-Patchwork-Id: 375004 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=-18.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, MSGID_FROM_MTA_HEADER, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT 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 E75E6C433E9 for ; Tue, 2 Feb 2021 17:39:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C1A8664F5F for ; Tue, 2 Feb 2021 17:39:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237658AbhBBRjZ (ORCPT ); Tue, 2 Feb 2021 12:39:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237715AbhBBRhQ (ORCPT ); Tue, 2 Feb 2021 12:37:16 -0500 Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on061b.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::61b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE231C06178C for ; Tue, 2 Feb 2021 09:36:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J2FbxM2GxST4BenYEy/eK0U6emW/n52sQVspIWPMLEt+E+TwngDfbr5yTZCnKPbmaXABzFCPn66xGqmAf5IHHLtEdpDvk2r9dryGBC1HiGb7BqY420F/hoIZ2pt+9Czusyo2EGB19S4WRetSLuN/hQzZ8xxfTcYsKXlQxpKkNJNX9Zq34RO/YfSb1wSKs/zUQKW0Iiic0gPNPW2JkXTBJepI9X16u+2Esyfnh/g6UYm5etzBlcehPlLVB4bNl9hKYGUDz3Uo7r/PxvT4wKEc+rFxOv59dLlQWGwkZyrNIwcnYun8ELKucBnbXfP1E9gADVh3XitDFbuyz+cIxB4sEw== 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=cdFHDv+Xoa+V5ZJUbX3xwPbAII33gY4jTVC4ctosGK0=; b=BO1HjOOGKA8G6pejv3gLSn7HGUrPV3tRyIh4CPrs10TZwML6QS+9NbfeGStg1932HY7FVzyRCRj3XLBQ92PYDv3kSnITrVX/OWkcYKniJwviUi0DUCFUVXQJS8r09HYJ0d/WZ9CltO2ZYiqfMvKVhYvWNqAN0w61G8mH7lrwA6Qo+VxAMnsZ9IIjB00+6kxg3d4Q0T2jyS0W9i8gCkYIlrRSNA080i0gTEyneua3gAISaTwb05bra4h7xRm2goPYL8iIbrwEbxXtFBmQh8TwVlji8NlEx5Ah0NUZP6FODwAbO3GDE3dpb14mlFajlX43wJziRW48ukVtzXkw4PnSsg== 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=cdFHDv+Xoa+V5ZJUbX3xwPbAII33gY4jTVC4ctosGK0=; b=rDzGznWtNzw5Rh0V616fC6i4BKlw7J0d9pbaQiF5QUlMTZDb+8SpE/1FnVicB8pPa6C8LvCnIPEgzaZNOiIjPDqUhkBU1wTjzqw18mtcMJTF/cjZPqH68Js+RziCXn630rraRzf8tii6GPA2oP5ch33zgZ9/RS1cQiiInLnG6rc= Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; kernel.org; dmarc=none action=none header.from=nxp.com; Received: from VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) by VE1PR04MB6462.eurprd04.prod.outlook.com (2603:10a6:803:11c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.16; Tue, 2 Feb 2021 17:35:38 +0000 Received: from VI1PR04MB5807.eurprd04.prod.outlook.com ([fe80::6ccd:7fa9:bada:4]) by VI1PR04MB5807.eurprd04.prod.outlook.com ([fe80::6ccd:7fa9:bada:4%7]) with mapi id 15.20.3805.027; Tue, 2 Feb 2021 17:35:38 +0000 From: Camelia Groza To: kuba@kernel.org, davem@davemloft.net, maciej.fijalkowski@intel.com Cc: madalin.bucur@oss.nxp.com, netdev@vger.kernel.org, Camelia Groza Subject: [PATCH net 3/3] dpaa_eth: try to move the data in place for the A050385 erratum Date: Tue, 2 Feb 2021 19:34:44 +0200 Message-Id: <387f3f2efeab12a7cb2b6933e3be10704dac48bf.1612275417.git.camelia.groza@nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: AM3PR07CA0093.eurprd07.prod.outlook.com (2603:10a6:207:6::27) To VI1PR04MB5807.eurprd04.prod.outlook.com (2603:10a6:803:ec::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from lsv15136.swis.ro-buh01.nxp.com (83.217.231.2) by AM3PR07CA0093.eurprd07.prod.outlook.com (2603:10a6:207:6::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3825.8 via Frontend Transport; Tue, 2 Feb 2021 17:35:38 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: dd271cf6-2ba1-4cca-2c34-08d8c7a0f4a5 X-MS-TrafficTypeDiagnostic: VE1PR04MB6462: X-MS-Exchange-Transport-Forked: True 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: z0s5fUg2i0fDM95L62e8DmRsLrGY6EgntuyCGQ15hasRlckBOCr6KaOiBHxmDvvNTRrfChWuU0L9cFgZI8f6fe/iGh3Mkgigi189voJ1X0tCniSrJs7WYz6Cnot+XPOD+9hZp3g5pZUe8apQftbpHKOvezq4p8FJOL/AE6d2Wo8Wv19SxC6rD8VdMnxvFx+DS2lFmCnntc1e3nio9s72yef2O5ofugNEnvNj5DovKXBvxBushsn3QyKZMpH6Yv3kxMy0PY+/ZmurF9O5VtlMerx0MUn65ALAvYuso+TjVExvHPk23usOl9P4BpB1+kWnJJqBjTxlCu0KQN+shHtiNdwC7WkJLJCpI37FXuTSO6wFOXP/hdheSgTSZoVaFqNumx0JVsRkRNOf3RSqcgcX/A7M+EX9Lfs1WSwHvbgdAuNSfQjUcQxBGoBm9cUenDCcIFW/PjXz0hRNZ/WLO2N8iIhdwacVw4T0lbpEr1BEceHsKue+UOyxLi2GvEqE9ZUR4IRbNYmWWtm8eP9kkabgpw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR04MB5807.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(136003)(396003)(376002)(346002)(39860400002)(5660300002)(26005)(6486002)(52116002)(86362001)(186003)(44832011)(316002)(36756003)(478600001)(8936002)(16526019)(8676002)(66946007)(2906002)(956004)(6666004)(2616005)(83380400001)(7696005)(4326008)(66476007)(66556008); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 0jgoDni4UfW6cFwtKIDvq9eEAD+Lum8K0LPkBf7H4Wqxuc0Zg+Jq28GDTjuJHisPyio5WV4L0uC6FdtzOuQtk+XCt9+ypCNZVxFSjrGFTck8K7oNZmaNlQu/sHjFki/PedsHkFziyhJQefm/ZrVArA/huwls03kNtGqzgD0ahIeIQ7H6vziETBDoF38vuIZu258B3sNFmhUenEXq88oo4qr7wp2mhCRk5+Dx1EOs7UoStwCStUtUMpNpWwoD6rG05BlCytD0DKg3Pxf2LDZmjRoArEUdwCX/Kk2EBpvUIh8g2W/8zPkCtzy7Nd3pLsMek/RvVzq1wmgp+LBhbkexpMPzqOTfzoOsLeKDIEoPkwYfoVphtbcsDGldiE+Z50sgNSdNh5uDQD/um2Zf641fZGHLmD5qUrxreIwZbEr1SfpUPjGUtAHwzXWqal4SwBEB2ove5m/tdWlZbYmH2tgyKUXev0YLQNgDVrqDapg2UDTb05+NcKf6DNLmQi1FCAZJ8ZqFdUsjS3JsREffcg27zl9oSVLUxPu+Nn79W4zN2n7yQJCBk2iufOiI25B7G+Wdtp06NNZEkIhrYEtL8aGzOcv148eMIrgcEa8y9BIyqWwiy2RNhOTxdoHP11uy6Mmj31mJYTdv+CsBDazOy8h76zDxTfGt2KWNcaHA5BEH5a4HnO9pORk7EOTqGiwvJE/ErD2DQrtTv6pMHGLJQyr18dwACDUvyGuWWKVONYvJew4OaPUMsawvS1Oz/bQyzBBjCpZz2fDlYsxGsPp/taJ0PR5VuAcAdIxe+856FVHIsyoa6dKMb0LbNvIzZEShGHqM6qZIzf7Elm+J1m73rGlRK4q5AjHZeVQYsYkdCr5Pro4t8kAKVQpcwds4JjEnnjbJAUH4ou8qtLci++YcdxvWrxHUWnSMBucS9PL9GuRV8uL3PHdWCLGd72GRt3Fcoei24nFGcfl0xCG+vd7hOIU1d0wFfhLhlLDx5pHiyP2cVR2jDUgyvdEXkDKzkJyR6D3XkUR2yoHwZrXInU0LXBJnpV4PtU2pdh9qm/36Oz/GJE09iO/PHpVY5aD2Ds7E9AtMfG5OhShaqF6yfueSfJyF1AhhHqQcJ0cz2jOOHaaXQJpYBjbIkYyEBqEnfxZjFRYV4jBIqhh/mzIApOIyqOxaz8fWjX+rYtkzuYON9w5I/Veh4VVRIo0NlAT6WGqu6hCNRlfOt8SZWoXVRN7/nqumlikKpwK1RT86DmyzSJu/kEon85EDuqyuehiThlbi+MeeL2VKj4XrKIXvKaw97UtZWzD/Gb4NEsX3x/NIGCrgt3bOTrBRv/rNTi3rDOrCzW1K X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dd271cf6-2ba1-4cca-2c34-08d8c7a0f4a5 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5807.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2021 17:35:38.7954 (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: 7uD3cO8jmCaUI21LAu5/kC9pBX3YUdIEZe0pom79peWnYmyOk7upeAzq8hhvE787ELng4cCCHcLIeE/HQNe12Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR04MB6462 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org The XDP frame's headroom might be large enough to accommodate the xdpf backpointer as well as shifting the data to an aligned address. Try this first before resorting to allocating a new buffer and copying the data. Suggested-by: Maciej Fijalkowski Signed-off-by: Camelia Groza Acked-by: Maciej Fijalkowski --- .../net/ethernet/freescale/dpaa/dpaa_eth.c | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 78dfa05f6d55..d093b56dc30f 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -2180,8 +2180,9 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv, struct xdp_frame **init_xdpf) { struct xdp_frame *new_xdpf, *xdpf = *init_xdpf; - void *new_buff; + void *new_buff, *aligned_data; struct page *p; + u32 data_shift; int headroom; /* Check the data alignment and make sure the headroom is large @@ -2198,6 +2199,23 @@ static int dpaa_a050385_wa_xdpf(struct dpaa_priv *priv, return 0; } + /* Try to move the data inside the buffer just enough to align it and + * store the xdpf backpointer. If the available headroom isn't large + * enough, resort to allocating a new buffer and copying the data. + */ + aligned_data = PTR_ALIGN_DOWN(xdpf->data, DPAA_FD_DATA_ALIGNMENT); + data_shift = xdpf->data - aligned_data; + + /* The XDP frame's headroom needs to be large enough to accommodate + * shifting the data as well as storing the xdpf backpointer. + */ + if (xdpf->headroom >= data_shift + priv->tx_headroom) { + memmove(aligned_data, xdpf->data, xdpf->len); + xdpf->data = aligned_data; + xdpf->headroom = priv->tx_headroom; + return 0; + } + /* The new xdp_frame is stored in the new buffer. Reserve enough space * in the headroom for storing it along with the driver's private * info. The headroom needs to be aligned to DPAA_FD_DATA_ALIGNMENT to