Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753370AbdLHMsx (ORCPT ); Fri, 8 Dec 2017 07:48:53 -0500 Received: from mail-sn1nam01on0063.outbound.protection.outlook.com ([104.47.32.63]:48736 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753060AbdLHMsC (ORCPT ); Fri, 8 Dec 2017 07:48:02 -0500 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=fail action=none header.from=nxp.com; From: Ioana Radulescu To: CC: , , Subject: [PATCH 5/6] staging: fsl-dpaa2/eth: Compute needed headroom per frame Date: Fri, 8 Dec 2017 06:47:57 -0600 Message-ID: <20171208124758.2732-6-ruxandra.radulescu@nxp.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20171208124758.2732-1-ruxandra.radulescu@nxp.com> References: <20171208124758.2732-1-ruxandra.radulescu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131572108848714218;(91ab9b29-cfa4-454e-5278-08d120cd25b8);() X-Forefront-Antispam-Report: CIP:192.88.168.50;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(336005)(7966004)(39860400002)(346002)(376002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(189003)(199004)(316002)(104016004)(51416003)(68736007)(81156014)(77096006)(50226002)(1076002)(8676002)(36756003)(2950100002)(8936002)(6916009)(54906003)(16586007)(97736004)(5660300001)(2351001)(105606002)(47776003)(106466001)(498600001)(50466002)(33646002)(356003)(81166006)(305945005)(8656006)(4326008)(53936002)(85426001)(76176011)(86362001)(2906002)(48376002)(343044003);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR03MB2703;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BL2FFO11OLC007;1:4XbM/se0SjMvpE7Am7/BDZA44NpITeTYCjrRf0qJ0Tb7L+VU5MoxA4ED4cK4w0XU+a/6/+Sp+mn1NKZQ3GIhTVv8lk+pFQAmrwF7Guk+XHqOxkeAAQocmCNQbbnquaTI MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ce0387eb-ca2b-468b-d1ea-08d53e39ecbd X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307);SRVR:MWHPR03MB2703; X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2703;3:cWGmZpBGyxGmOQ5+jVHtzXzpiAzk1OfcSNooDGlkBJiaS2UqsGf2s80jUj2eTODrtwskDOp8XReeSvG7QgtZ5esHrKRnF8lU2Wh7Yn+wgC+yDqfGOh7HC9Suv2umvvFbGW1YXilPB6wdYnnXJjTWBRwl6YZuJ6u6jv7SOhrSWFbPILJZHM8AzxQP55d+IeqkUaJ7BJuU/aJKcix7YzRDaUVccoTv7KIYidmIkxUITnUraVqd169tgb9Yi/atxrynln7i6lBuU9hUbNrBhPOJW40HgiHQx7Hib0noiu2nJl3eodLUDGdnWxeswTnKYT1iP/Ba2vpQmRC38P9DvaztqzZf9Tv0XrMHmHRNyo04yS4=;25:2pAoFzyc1VFJ/2rG8KJdHILeVzGhVagy1y2Ra9ElJPDRNzlhSOuxAdBPTPqsZpZY5y5+ipx9Udrq5ZyWRnQQ4T1xCycBlrlCDU3f9rgB2BzmXY5N1REvdCnTKxarRLNX3ZnIYNrrQ0Q9r6Ri1FR1uscQ6Jg93Zww0qVc2oBL75nncQHRTKK2yqyxZhi0z8uiSE7VqO02o2ZcNVQqplgpZ86u3ORoCuD5c4PnvjDUZWKccfTGtb3KHBdqrHloTM5pns3no2BizqYvK2rperMIQtId7Fslm9LzNOKIkC1WjMHhDxDWUiByTOnCT7IT8iJjbLsdJshPbN0Je149SKOHRQ== X-MS-TrafficTypeDiagnostic: MWHPR03MB2703: X-Microsoft-Exchange-Diagnostics: 1;MWHPR03MB2703;31:sy/dVGMOvcOgiir23bz3a6ZiSamvLrE5KjisNq1jHNlRc6Ei0CEE3TqQn8TacdKV0StL049O9sd0c0l0gmHNrW6OkgYXgFCxlIPmxxJut9/DfD1b1LNd5Z+AmwiHVrgbSAyKTiIKptoUhvfVp28llrOSPFBOZF29YUdVpIOWeR8IstpzgYhvmzdMz6nbsjVX8Umk5ICaGC5C039SkSxbZaYX7EW1olyp62M7P08wWGo=;4:+D8DA0lmQMSpSXA2O53R6xzZQZ/yAfgkWphaNt7FyU/BbJ0SOBVDHjurjMUGla7OFnTDvHYOxuRqRawOZwfYOjObxlkJspwvR7CnyHsB6TU2VP9bc38zjLHbQrOgO2sb+h5F562mkvCYMK/FUtFOnmgBFCBA4WNGcPebPlik1Za1rIchDgKEa8pm/nMKWvvE+jY/svXH/s+D/XzE06AdEYUtRPSBkNFMx6pVmo1aZlhEosEfGDhmlHWq61oODOxqyNSzL87hIS3nYGJdrJx2BZ3UaC2W26Biecjz+4uDiybNUmy4aUXVsnZctgJe0683 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6095135)(2401047)(5005006)(8121501046)(3231022)(3002001)(93006095)(93001095)(10201501046)(6055026)(6096035)(20161123563025)(20161123561025)(20161123565025)(20161123556025)(20161123559100)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(201708071742011);SRVR:MWHPR03MB2703;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:MWHPR03MB2703; X-Forefront-PRVS: 0515208626 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;MWHPR03MB2703;23:f1z2pEkIB8wcRcGbrwdrGSzXmvvrFOT9B+DPBsk2t?= =?us-ascii?Q?zIX6TO07cQAEUJpsJDV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8H3iGp96d7yeapDyp+Mevl4hOp+8LJNJYEa3iUN5LpWUJnnjW10FTwr28moMypoYCyqiLaX5Eh46Kv2/MEidtZOmyM6PSTIbP4IgapZaA83HDdB9mbTWDfQXq5XmXASLAUQXtXjJMFh7df9 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2017 12:48:04.6998 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ce0387eb-ca2b-468b-d1ea-08d53e39ecbd X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e;Ip=[192.88.168.50];Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR03MB2703 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3101 Lines: 79 For non-linear skbs we build scatter-gather frames and allocate a new buffer for the S/G table in which we reserve the required headroom, so the actual skb headroom size doesn't matter. Rather than use a one-size-fits-all approach, decide when to enforce headroom requirements on a frame by frame basis. Signed-off-by: Ioana Radulescu --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 9 ++++++--- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 11 ++++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index 2c12859..8edb7c1 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -437,7 +437,8 @@ static int build_single_fd(struct dpaa2_eth_priv *priv, struct sk_buff **skbh; dma_addr_t addr; - buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv), + buffer_start = PTR_ALIGN(skb->data - + dpaa2_eth_needed_headroom(priv, skb), DPAA2_ETH_TX_BUF_ALIGN); /* Store a backpointer to the skb at the beginning of the buffer @@ -532,15 +533,17 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) struct dpaa2_eth_drv_stats *percpu_extras; struct dpaa2_eth_fq *fq; u16 queue_mapping; + unsigned int needed_headroom; int err, i; percpu_stats = this_cpu_ptr(priv->percpu_stats); percpu_extras = this_cpu_ptr(priv->percpu_extras); - if (skb_headroom(skb) < dpaa2_eth_needed_headroom(priv)) { + needed_headroom = dpaa2_eth_needed_headroom(priv, skb); + if (skb_headroom(skb) < needed_headroom) { struct sk_buff *ns; - ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv)); + ns = skb_realloc_headroom(skb, needed_headroom); if (unlikely(!ns)) { percpu_stats->tx_dropped++; goto err_alloc_headroom; diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h index 546a862..4ea41d8 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -364,9 +364,13 @@ static inline unsigned int dpaa2_eth_buf_raw_size(struct dpaa2_eth_priv *priv) } static inline -unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv) +unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv, + struct sk_buff *skb) { - return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN; + if (skb_is_nonlinear(skb)) + return 0; + + return DPAA2_ETH_SWA_SIZE + DPAA2_ETH_TX_BUF_ALIGN; } /* Extra headroom space requested to hardware, in order to make sure there's @@ -374,7 +378,8 @@ unsigned int dpaa2_eth_needed_headroom(struct dpaa2_eth_priv *priv) */ static inline unsigned int dpaa2_eth_rx_head_room(struct dpaa2_eth_priv *priv) { - return dpaa2_eth_needed_headroom(priv) - DPAA2_ETH_RX_HWA_SIZE; + return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN - + DPAA2_ETH_RX_HWA_SIZE; } static int dpaa2_eth_queue_count(struct dpaa2_eth_priv *priv) -- 2.7.4