From patchwork Thu Feb 4 16:49:26 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: 376739 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 A86DBC43381 for ; Thu, 4 Feb 2021 16:52:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78D4764F47 for ; Thu, 4 Feb 2021 16:52:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236932AbhBDQwk (ORCPT ); Thu, 4 Feb 2021 11:52:40 -0500 Received: from mail-eopbgr130072.outbound.protection.outlook.com ([40.107.13.72]:22438 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237939AbhBDQvL (ORCPT ); Thu, 4 Feb 2021 11:51:11 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JeNnrebQWvXMdgGHf65nqzJzFEzhCj4Mv02YfMLFO4Cd0JGGblLq+5AJ91I183O2VQSMDVuUWGZ70rF5QS1YIJY2ygFkem1Ud7aDdOMuHyuhhk+/GtvqJf+1dUOtz/hnO0TtGqPblPoHaPQL3GSAHjvT5lkak/oIq59sPgtvhO8RHSyApbD1UnDm1vhbv7PbYexmcLeEoBBuUBZnO1ypPSqFcgaeX+0ojZKk07n90OVcBt6+HPU3cE90E1N7GPKAtt+86o4Qsk0conoR/ZwUMd/tldkuKtALMBWMeOd4s0JSNvxseNQRtB4sRBVha1wn1LoiT9aEsBT9ucLwDY8W2w== 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=lKBjZ0wvRKv+2bZtWIPXg1l25PnWe6NmVluXgXvIpgk=; b=VuVZemYAKkVfhxfvRyNTGUSPZ9A65YQipwq4lt9euW8AcX9U+ABJh8+1ARwt0GfihXowS2eWfu04itnsEglfwPcaZgAj0dfauinUAWkogzIEiiBFxuXtDF9pEV+DaIha0hhSZC4Jl/TC8osfwIdHVmetc+iKYK6C6TDO7p4Bzm/jerptf0HYpjT3LDl9nfN/QOdblytCKPBHGXly9LazEIYMgQr2vkurSdowATNbQKbq2IIRjJ7dvrz3VsRZdEOa6zQ/un3/KmUToMzXtsdH0wNx0b4t+PkgW1NH/VF7G1sNR3l3rezaMGreO+T+TEnXt2scDfJ2gJERbI+eOxgSAA== 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=lKBjZ0wvRKv+2bZtWIPXg1l25PnWe6NmVluXgXvIpgk=; b=A0eKiyCCtTvi7vwxtsiFIokCSahQZrueyy9STUidH7ZRBSEfWrQZ1KS9V9Gh9NksXUgMmhCk5QJW8MDHOyo1RuDk1tDWaHh4L3elZrz8hE7HbIYFLgY/2e16g2tNUuhXrLILP+ICM5Y2cSTr86OW9FboYzNyII7eXe1S/R3bR0w= 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 VI1PR04MB6206.eurprd04.prod.outlook.com (2603:10a6:803:fa::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.17; Thu, 4 Feb 2021 16:50:20 +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; Thu, 4 Feb 2021 16:50:20 +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 v2 1/3] dpaa_eth: reserve space for the xdp_frame under the A050385 erratum Date: Thu, 4 Feb 2021 18:49:26 +0200 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-Originating-IP: [83.217.231.2] X-ClientProxiedBy: FR2P281CA0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::13) 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 FR2P281CA0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.10 via Frontend Transport; Thu, 4 Feb 2021 16:50:19 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 102f5db6-6427-432a-10dd-08d8c92cf528 X-MS-TrafficTypeDiagnostic: VI1PR04MB6206: 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: yaB8VDwZgE9696XCA9USQ1dfEZq5QUEIdXPPwNuV7sv0FWSOENlh6Auv9GWEq3NxnhzHAPBXgq9lAuJEkpqZcI9Hqhh+vJ1Kt/omcf8jhx8If2Wjc6NNDg2E0IIGIyA0juZpv/+i8ADK1Icvyk0ArO+ldKcdIicvUcPDAX9Tuc1DLkl2X51PbvHKc/QPggDsxF/Lll7sKclhM/4Jdz8tDp2ry87cvA9QjcgXVfBY7gBToFLcZ4O/RJ4wt2qfev0xrlebMpY+gbYuFymrM2vp+2m2w3FCMJLcerXP5XwVGl0N057plwE9MyyJdKs6h+IRqF7cm/NfCcElyCgdBKs6EIJCtorzsj2c9Gc1vpcU2SfLY2sccbPXtxQF8EA1KDW/5BKm2dtLk0KgIViTmj25K770/TfxOXa2azzQUvc/MNsMZkWaG+da+w3mu75Y6u6NQ8EO0NNEP1T5+NGBuzqEt+JF33T2Js5ycXABo/0SX9r+fO7QhXujcb4lag1aZlv44N14AuATxhVWHVGHm5Tf0A== 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)(346002)(366004)(376002)(39860400002)(396003)(136003)(478600001)(83380400001)(2616005)(2906002)(66556008)(6486002)(956004)(66476007)(44832011)(7696005)(86362001)(4326008)(186003)(52116002)(5660300002)(16526019)(316002)(66946007)(8936002)(26005)(6666004)(36756003)(8676002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Cp2CI8jI7vtZZwt5pY26lvI75umbvrvRbFFQBmEOsEvZF/3Axj/Np72lmVLlQVow9de4tfh82FYQKHqsEVoNxXkF5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6Qd51sreVDogLRRKcaT5Tj3h3Pcfe4vCVLgJkOtzqC+8rkqlT6WOl4uRUT78mk7I8VTX6dGxHlIqXvfM/eJdoKJLYj90ezAcT+OpKEB31lYJygm8ourW6E0e14/htYbp4370Rog6ZctRT6NeN4NM2Lq1GDbheJxOvhe X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 102f5db6-6427-432a-10dd-08d8c92cf528 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5807.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 16:50:20.3421 (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: Sl1QFY5q7JjPmV2a+Pulm+cpmMnANzmIwDTD3Ve6TUXu212hNVtbUrSuBwpfgMsmBhMGcpdsJQenNZgAGmyZLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB6206 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 --- Changes in v2: - guarantee enough tailroom is available for the shared_info .../net/ethernet/freescale/dpaa/dpaa_eth.c | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) -- 2.17.1 diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 4360ce4d3fb6..f3a879937d8d 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,34 @@ 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 don't overflow the buffer, + * while maintaining the mandatory tailroom. + */ + if (headroom + xdpf->len > DPAA_BP_RAW_SIZE - + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) + 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 Thu Feb 4 16:49:27 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: 376738 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 424BFC433E9 for ; Thu, 4 Feb 2021 16:53:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1189A64F47 for ; Thu, 4 Feb 2021 16:53:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238204AbhBDQxP (ORCPT ); Thu, 4 Feb 2021 11:53:15 -0500 Received: from mail-eopbgr60078.outbound.protection.outlook.com ([40.107.6.78]:15142 "EHLO EUR04-DB3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237972AbhBDQvb (ORCPT ); Thu, 4 Feb 2021 11:51:31 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J71zhvIU2GPc6u5YVV3T4+iAxBlSjwkV99bPSEczeH4IFn6zul81hj7jUQLbJ9//6nY5F9GRYDBOU0I/sNWWEhFur4fK+TaC0JwW8A7Pnopxr6bQGD9JBxZ3xM/bKGePDzK8/G0YeXoWXt1TNagfzjnD0A40qsvuoF7WJBoARCJlNm2z5ZiZfO4hHLb+fYa1XJAc8yw5i8prNZJNqmhlLCJOeKr++s/jbXbQiyGpVlps6IG4LdToqKCUv/tG+8Dmb42syT08QtXm9ErKPqfgPFJjhNkPG6VPg9LTCfk5MW5rsEZ8B/xacoLpjJ+EW4u/hUxCtxQ5+U7lWVC5GDXQyw== 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=AlSFdVxF65blLSJjmAt2GnWzbPP5XYHraLn4Zi3bjE8=; b=HkGg6nK/hf8MCruuR0s+ZCNmJyTVHCwLLsKNE2QFWglzUHnDlsVCfD69IFbTJ9I0HsDGJKT7OCt5AcXoWu/nGxpJIIIq2nzSOGZ6wYSlOyNPRtXgp2/Ot+moZb/y869BiOEwVw76N7plCYUStCnFSAFLwE05jG4ZWT7IysHBsTrzqQdouqdrbaeTSoOq+FPJNC2EtD+Q3q6gj9gdVKtZXDNmgQw5oxtVBGyE3AJGp/75gen3nNdqooZFz35mNsMVHKBuQG6LWrHwADtmxI/rhOJfEmm35f0ajeUFHNOpyUAxKkfgjf+2PJSbpLjZMGf/laJrcvnl/ZiFmVTGFW0z0w== 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=AlSFdVxF65blLSJjmAt2GnWzbPP5XYHraLn4Zi3bjE8=; b=gzHYlqMEL7hvY2QUr0cnmJ/DJ6ne3vb9EWrMlGf5xnlt4FvFFpB6G3kEIaDCu1PzPKwCTJYvZWHGlKAWr1dj5OYeMNE6sOpVgMLezMgLTc5Oarj2PrZf3zZDQcMvssA2yBtLa5IREyyLPStFsva2rVxpKE+xW1o4NipiBJNsYfQ= 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 VI1PR0402MB3454.eurprd04.prod.outlook.com (2603:10a6:803:a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.22; Thu, 4 Feb 2021 16:50:41 +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; Thu, 4 Feb 2021 16:50:41 +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 v2 2/3] dpaa_eth: reduce data alignment requirements for the A050385 erratum Date: Thu, 4 Feb 2021 18:49:27 +0200 Message-Id: <07da2fe94891ddaeed1140544a7c6ffa156a6711.1612456902.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: FR2P281CA0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::13) 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 FR2P281CA0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.10 via Frontend Transport; Thu, 4 Feb 2021 16:50:40 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 511bc067-c0d0-408f-1573-08d8c92d01af X-MS-TrafficTypeDiagnostic: VI1PR0402MB3454: 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: Yw5emyRe7EWyCczNlyrZCyzIsFehHAyiJ1Op2JtGJwXTyCTwgwlEhvmUtlkMLo62pGMcPBwwWdrttUXpel+rQzEkFe5uIHqJVDK34yXHsGDmYZL9xdz29SvRUZAcG2TXOebKz85wALXzPajqBiyMwT7LXOfob2PXLBC3NdP8sqyVMz2W40r5BR/x3gJerj/3Wx0W8kX2hVpGLoccMERaH0vBxtmk9HLLHHXf99E8t3yi1a5DlqP+srODce5xcDZmVlD1pApLVKmGe2R+UBOhfdvdmYVVT5172yKa2cHOzvamwFC6G/LkY/9aSL91YcYJd338LgLyYnK3a5ozx43ywUjbKERPICbq4rnnSRlwx7FxK11jhpeEWU8XbC/FgrCIkzhGASN7LjRFLzb1+uBkxjbj128yEbx5Z2D1LCn4q3iJezt66Pa4N8VsvodAOwGKmkyQcVNcv/SG1Uw21uGdi6FkYvFzcNQQ5nuoTSIfJTrJwj8dZX4+O2pv9IWSxEMXrDtopXbC09gTjZWPRHhI/A== 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)(346002)(396003)(136003)(376002)(39860400002)(366004)(66476007)(956004)(4326008)(66556008)(6666004)(2616005)(6486002)(2906002)(52116002)(66946007)(44832011)(5660300002)(478600001)(36756003)(26005)(16526019)(186003)(8936002)(8676002)(316002)(7696005)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: btixqCOftbzWw7Gv0291tuotE3Swi/s9iq4t1rTiq+A+ooGXuKcBiPNAtyGBAF2WcsiMZ4i5ibBmVgp1UZed9J0Hw3sieLQSar6eOnKW/hsij4Bz7DbDJ75Yynjgv6sGwb+BooodTZSk81cli8E7zn7PgIjDzOX7pXzKUlGHH7Y9lBBf/66xOCk6UsB9MBJDByxslyY7xP575qFuaad/tT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xp6QDUtGXc7P2QG8uGmxznImWkA3UYQ0cGREeqM78r1jhX+3/xFBEDqNhMizgQ3+ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 511bc067-c0d0-408f-1573-08d8c92d01af X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5807.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 16:50:41.5206 (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: EYVDJrvlLAV+ZYmuXUhOjEp0T3llfLz6ZgnFTTMSDSNgalbcdrQgRqNG0tQXibXWAh9d9jLnYTsMN4WaGeorEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3454 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 f3a879937d8d..2a2c7db23407 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 Thu Feb 4 16:49:28 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: 376737 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 B2782C433DB for ; Thu, 4 Feb 2021 16:54:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7888164F47 for ; Thu, 4 Feb 2021 16:54:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237828AbhBDQyA (ORCPT ); Thu, 4 Feb 2021 11:54:00 -0500 Received: from mail-eopbgr80089.outbound.protection.outlook.com ([40.107.8.89]:44686 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S237971AbhBDQwa (ORCPT ); Thu, 4 Feb 2021 11:52:30 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PGJdMtGtP8Sm2YTbDzN6wZDxM51yuqNmtgNVnC4tCfk93APJm06zguxk2d+Puf8YAYB0sudbN6Uq9YTPOih2TIRX2mmoH6hQBbazvMiIUWPThct7kv3lkmu1pDCKk7dADoizCYRZnYba/UkPHOBIppUET4t5qF1QMT5s6xGVoIcM/KwydTg0aBZI9aE1HVg5MhtI55lsgZfCiPWJFfdK+NNzp7rR4Vuy1NzYioV6B90J/NYRS1NZHh7KdiU3PjBQHYSMX7kVljgkBHYqaZCqXWx2e9DLow88wcI2ZsSBuv21hN41pZjvK3CQfmtinBtErgoYunOvzA+AUqA5nYD8TQ== 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=yx0XsD26H2BNYAdlt+zxoZWZPuY1erzo+GEGjuFbSEM=; b=IIob3hUQzGnWS3hJ4vfoxfYrvTY+s7w+e+2NIvSdlewC4Wmi8FgsRiwtRE9TPEGg9zE3xJsA/hnMzCzcRtdMPZw/YSaP/77nntAMXufyIsNBZK5K07F4YemKNbgz2Q45C+ophr1Kq0ULcGtgfAacF5iXqAhKNCCldz+TV7ADA8/5vf2xYEt+73roKXIl1RKNNkenL3HIp0qVJGEhcO3lgUq0yXigoXx4+tkqTy072T2jcZZXdHI7Bagp9USZpm3ngg7uoM1ZlQRIXAUv7CfHEj7XJtmXTeCL3ZGRW3WmaMWYzGBT6LjFxFPLm5085viMJkfzAg4YnVONIXIMmNdxWg== 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=yx0XsD26H2BNYAdlt+zxoZWZPuY1erzo+GEGjuFbSEM=; b=bFKWxtekfAuh7WGRTAD2susl66sfjKhVFxodWz5pjJUGekYXs+CC/M73G4XZRE09Jjdb62hVOY3SaRqfrEBIFiSp8fEG/0MQT4nrBvZVAuACbpSMOPDwKtNgDOP5POI1z+Au7hno/G8laiVZ8u4wy885oLd6uKIyezwOvs4aXaQ= 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 VI1PR0402MB3454.eurprd04.prod.outlook.com (2603:10a6:803:a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3805.22; Thu, 4 Feb 2021 16:50:43 +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; Thu, 4 Feb 2021 16:50:43 +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 v2 3/3] dpaa_eth: try to move the data in place for the A050385 erratum Date: Thu, 4 Feb 2021 18:49:28 +0200 Message-Id: <883f775dabac981c0f46b6296b134a87cc74ca83.1612456902.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: FR2P281CA0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::13) 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 FR2P281CA0026.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:14::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3846.10 via Frontend Transport; Thu, 4 Feb 2021 16:50:42 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 74c7eb7d-4560-48f8-4d24-08d8c92d02d8 X-MS-TrafficTypeDiagnostic: VI1PR0402MB3454: 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: QqZN8TqH7LfBEW33KM7wt8KZ6UFXqt6aZQr/m1aPHTN6dVCYLophFkv9ilF7OJ0dvjhy3XLVvuH8hAdPx4/rI2FmpfV0gWUZ04FB4WkgXMBqSSjWmyfuc5vmkQLEbrRhXoxmUETGxbudzIqkCJ6q9OjD+7fKKZndg9tQOfBtw8Qe7TGXoYNX2/OGqGDBSNPr1Vt9w8XlgC89Udzh+mUw2g+ffgZ5xqpngYXWGkedwFsCvCC0Q5EhOZyzfQbML/S8ocGaNy1hAnCXrdOXaWWWzwbWLIeE2M9syMJwDzJcESDkc9TEkky6uxh3EfkE6aKrWxYIKvOCFRTEVqiyfWL4fJtAne+oELF6nmQN3wV7A7+Q1osZt2L1/jpSIJOJAND7WbINJN3+FTXM8aH7PDsOhE/RoEsGaPZ+nAVMhlgoIhyT9J6ag4cDRoHbU4x5SWTsKWBQbMjK6eb8GBH1wo47z8YC2YYOysfPcu1QIKztCB21Sjb5+OJXcue2zpRTqRALdN3XRR2bXdf74gEGOhmiog== 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)(346002)(396003)(136003)(376002)(39860400002)(366004)(66476007)(956004)(4326008)(66556008)(6666004)(2616005)(6486002)(2906002)(52116002)(66946007)(44832011)(5660300002)(478600001)(36756003)(26005)(16526019)(186003)(8936002)(8676002)(316002)(7696005)(86362001)(83380400001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: jSXQsr8+UbbTUEMHuo7fJv10F932ORHPeQ4LmVE8+23GSYrqeZMNYDRmBRNfvIddkjH+gBNFYmSG08R91Y72aEvJwUFGKqXvAfcCxS879VBBSCBo0Z6RaRmyXYQ/InOQObD4ZT0ccxbNIGuf6J0nhS/UjCDo2BwlhyMwu3V+M0SFrgabTRfqCVMjgu7svLJNDslxA5sg3K0zokYJ6jYz12NKf7l7j3ooZaKqy5c7RWLGv51U80pFSL0UEtty3EViqoLiKEp04es9l1TqR2SsEbkxjfp1ACjBl0Afec8jfqId6aXstaDC8Y4QjavpmJq4hfUsWINv/ixnF6v3EYkw9+GHufxLOzvt+Myoi7h86uFXcVuJIlFnL/6s5Fa/jLKb2A1adK5IbuPxe/n1+9MBsCy/NzNCnN+L6IRMV/ZvkqZXHgXG1V9TNePnMuXq1KPfsRdTCWIjE7jInpRFFY14zFwhAXOVJeyLInmw6+xbE9HSBg4vrtiA+ySPFBJxJXgV4+gg+oSqlVr29PYcb0P95jrADKV+SqsqyqeFUI+gbTnpIGTF0YJd25x1dwSwqRaXiusOAXQC5flglt8cDKiLUtoba3S3WS7gRhJTAE8AcpeynVlGFU+OBmkl835895leehjbIIiLA500UNAYve9NbgQa+iqFuj13WACyMxhSCFJmdW9gd5rMVmS5zWeUvPcKlPB6eZu9CXEp9nlgQx3QBhljiqF6SVrQ2DReqb4vPhXX5UV/7L3l3JuUelkdRfIaOAe1l1GRYktC1kDvgUvpxylldtKkFjGRK9YQABRm2SanCVQZKoaNr233MeZwQXOFLZdNr0lJtWUAX5a06eyjANqbT3yzpdMWUwdACsRjSLZW38bI4QN4GqJWAzXY1Csm7RlPsyMS8bvxEAZ70CZWvxLipb4g0tVROX43bXVHp4VuGv/qAGsFSt4zp2lNVu/9JsrWNdZx2y9MoyChLqrJCZC+XcZH0kMRo1jYmFFnCkKqBYOeC1o4+FhA3w9aeNlARdyjAGK1UyMKD7Cb5iy494B21NUYjetCYWp9PxZHDTLg5jZI7o07WANdxnJ1MKHFvFEzIXUIuoAJaNWmGn/N4Q1FxEWdLTv8Pj+vPkIO6/SePSAMjWETBx62h5NVMJ/LrmowvK2OveXMmqGfSM4q0r27y8Ckw2Rl9K7++229+oT6m35qQdSWbxWDdxkOhFBybs91YYNJo7UR40t6QPp+lkw5SQapY8kslf81yfEmtp8HmEi2Qy5onbXasM6JHNSpUV1RWJPNlxUkl/VmCePtFNfCKzy8DI+mrvxIjWEi1aqv2mloLGyX6XnuSJh++A3o X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 74c7eb7d-4560-48f8-4d24-08d8c92d02d8 X-MS-Exchange-CrossTenant-AuthSource: VI1PR04MB5807.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Feb 2021 16:50:43.3185 (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: w7fU0bdFYX9AsjyvbcQHO/j5K9ybapCcKDwrORGTCJNUqLgDnEiBSvZfX9xz8coFV5MAhslt9Ue1XTe/BOQ/1A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR0402MB3454 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 2a2c7db23407..6faa20bed488 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