Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753574AbdLHMtM (ORCPT ); Fri, 8 Dec 2017 07:49:12 -0500 Received: from mail-sn1nam01on0071.outbound.protection.outlook.com ([104.47.32.71]:63120 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752868AbdLHMsB (ORCPT ); Fri, 8 Dec 2017 07:48:01 -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 2/6] staging: fsl-dpaa2/eth: Don't set netdev->needed_headroom Date: Fri, 8 Dec 2017 06:47:54 -0600 Message-ID: <20171208124758.2732-3-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: 131572108772495959;(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)(39860400002)(39380400002)(346002)(376002)(2980300002)(1110001)(1109001)(339900001)(199004)(189003)(8936002)(316002)(4326008)(356003)(68736007)(97736004)(77096006)(50226002)(36756003)(1076002)(498600001)(104016004)(5660300001)(81166006)(6916009)(2906002)(76176011)(53936002)(8656006)(47776003)(81156014)(54906003)(50466002)(48376002)(33646002)(2351001)(2950100002)(16586007)(8676002)(6666003)(105606002)(85426001)(86362001)(305945005)(106466001)(51416003);DIR:OUT;SFP:1101;SCL:1;SRVR:CO2PR03MB2358;H:tx30smr01.am.freescale.net;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11OLC015;1:b/sYwPvcwAPZtmrxK+hevk6AgdXEWbVp+bIk/X+9rrctr3RvT+JxrSdP7zkLnMqlpLuXVBOhEAUuf1ByphQZPi4dj4ylDJpIR/YSqxEuWgce9O/2KSSWK31YSCX1qpcz MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b42fb22b-297e-403a-d257-08d53e39e832 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4628075)(201703131517081)(5600026)(4604075)(2017052603307);SRVR:CO2PR03MB2358; X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2358;3:1/+82jAToqDP8ojqxhd4oTgv6VHfsJE/+kuvSNZ6pq+mSFg3le7eFYJ4rTT8x+SsTgzCmWlqIcdlnH9t6YGMlDuSTRkVKv6JwOvxtkmMTVjcVr/VmmP1s7CPSMC8lE+U7j2Vd44s6Tsm3mGRe8+ZXwKMyYcMqbZ3IHbvZU/vrFiSJDvKnjMxKaG6BnTtF+pR9wn4u0gVvTx5WZyItQlkY5aGHBxLa0kFG42UcmFqtrxZs/2a+rfrNMRTtBRZAmbWYlxajqJIvx60W8HO4b7R7RslevueC4a+fyXE27pvh71xMf8R2Cr63iJwO9MTw/UqfvAnNCsgVCtwL/crXZgoJDtFyaVNlsT4nWU++PIXf7w=;25:CrGDnQqtQPHXwRrRFc23xLIDi7aMhpA79N5H+oajLlISg3xxjA5bpHeICPJndku63FUBu46slr86IAc9fD/CwdEeUfRkwqZja+Fpv8q3fNcRYUAqqL+7ZrF5gLufx71Sb+X0spMRvU/yRnOV0FTVodIncNa1D+TFSl7AEvqqnQttXpa7eiqykJqKCx0lydoLCwxlWoSFTzvCC7+T59AeMY0YP5TJW3d+HPS1JRb4kW2EjyDqcKbyzeMPu+9HXgO8gMn9APe30EeTOD1WJju0JgNM8dJQNmNxTtRfbcdgmmwEJOGl8VYxfLa2CIyB30N+4HM/c/61vmVdy6iE9Zu3Hg== X-MS-TrafficTypeDiagnostic: CO2PR03MB2358: X-Microsoft-Exchange-Diagnostics: 1;CO2PR03MB2358;31:zusaPrNMnWoFNl8WEFMj/rZkBm0v+IsJjN19GzF3ZQ9N1MK3GJrQM2ia9Zr2mbRIJEdY1jsrWdl3v8O+dUvy82cATreKiThtlINR4g6z8ZbyWSUjqqm7d4oiVOerMXBbIs18OWuvn/cEG592KRK2wzbvFDSmGowErDzgUxhPgRYMkDiocyh692aX5oFwBB0BNXSsnmNoj3W+ahgg8WyQQ15L/L38FD0PDnkiI7rzhXM=;4:dCDSOsqBcqmKU4TIJ4EUXcodUr1QjtWhpvNQRFoLA+eZOizjGmjZ0nRdP25IHFjQN7oQGbf9tp4GSv4sijFyQc1eVe0F5DR4jqI3Oy3KWgz35uPA7R8Bv9HZJlI++JBTxJCo8qXCrVR25CNPSbY8e+gJrYmhW6ATaR6pBo2fllx417qaCNn/hcdZfOpVKuhMb3cVkACQySo4m6MGoZGrD71f7eHlmD8h1lqoFCElwWg9JrfCaaHrgzTw+rTn5BbtE0W1JK5vZRYTxGO1sfwLUrStFD/hXIKoRDMmozOlU/mELhwUqDgKY+mdxJcgprrB 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)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123561025)(20161123565025)(20161123556025)(20161123563025)(20161123559100)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(201708071742011);SRVR:CO2PR03MB2358;BCL:0;PCL:0;RULEID:(100000803101)(100110400095)(400006);SRVR:CO2PR03MB2358; X-Forefront-PRVS: 0515208626 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;CO2PR03MB2358;23:QO4XS7s0K6+WIqTQtp2YFVQ6yTJiB69MWumV8HpBN?= =?us-ascii?Q?9HOIA8Sd7NdordP7Ta+xO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LU9KP3O6Z64wPiuG7mq/a2cx/QwJryUObsyAmYyMF3M4hZ99IwJTDy3KdanXTbBd SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2017 12:47:57.0623 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b42fb22b-297e-403a-d257-08d53e39e832 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: CO2PR03MB2358 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4050 Lines: 93 Commit 4b2d9fe87950 ("staging: fsl-dpaa2/eth: Extra headroom in RX buffers") tried to avoid the performance penalty of doing skb reallocations in the network stack for IP forwarded frames between two DPAA2 Ethernet interfaces. This led to a (too) complicated formula that relies on the stack's internal implementation. Instead, it's safer and easier to just not request any guarantee from the stack. We already double check in the driver the required headroom size of egress frames and realloc the skb if needed, so we don't need to add any extra code. On forwarding between two of our own interfaces, there is no functional change; for traffic forwarded from a different device or generated on the core, skb realloc operations are moved from the stack to our driver, with no visible impact on performance. Signed-off-by: Ioana Radulescu --- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c | 24 ++---------------------- drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h | 2 +- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c index c8a8e3a..04db65c 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.c @@ -449,8 +449,7 @@ static int build_single_fd(struct dpaa2_eth_priv *priv, struct sk_buff **skbh; dma_addr_t addr; - buffer_start = PTR_ALIGN(skb->data - priv->tx_data_offset - - DPAA2_ETH_TX_BUF_ALIGN, + buffer_start = PTR_ALIGN(skb->data - dpaa2_eth_needed_headroom(priv), DPAA2_ETH_TX_BUF_ALIGN); /* PTA from egress side is passed as is to the confirmation side so @@ -571,7 +570,7 @@ static netdev_tx_t dpaa2_eth_tx(struct sk_buff *skb, struct net_device *net_dev) percpu_stats = this_cpu_ptr(priv->percpu_stats); percpu_extras = this_cpu_ptr(priv->percpu_extras); - if (unlikely(skb_headroom(skb) < dpaa2_eth_needed_headroom(priv))) { + if (skb_headroom(skb) < dpaa2_eth_needed_headroom(priv)) { struct sk_buff *ns; ns = skb_realloc_headroom(skb, dpaa2_eth_needed_headroom(priv)); @@ -2273,7 +2272,6 @@ static int netdev_init(struct net_device *net_dev) { struct device *dev = net_dev->dev.parent; struct dpaa2_eth_priv *priv = netdev_priv(net_dev); - u16 rx_headroom, req_headroom; u8 bcast_addr[ETH_ALEN]; u8 num_queues; int err; @@ -2292,24 +2290,6 @@ static int netdev_init(struct net_device *net_dev) return err; } - /* Reserve enough space to align buffer as per hardware requirement; - * NOTE: priv->tx_data_offset MUST be initialized at this point. - */ - net_dev->needed_headroom = dpaa2_eth_needed_headroom(priv); - - /* If headroom guaranteed by hardware in the Rx frame buffer is - * smaller than the Tx headroom required by the stack, issue a - * one time warning. This will most likely mean skbs forwarded to - * another DPAA2 network interface will get reallocated, with a - * significant performance impact. - */ - req_headroom = LL_RESERVED_SPACE(net_dev) - ETH_HLEN; - rx_headroom = ALIGN(DPAA2_ETH_RX_HWA_SIZE + - dpaa2_eth_rx_head_room(priv), priv->rx_buf_align); - if (req_headroom > rx_headroom) - dev_info_once(dev, "Required headroom (%d) greater than available (%d)\n", - req_headroom, rx_headroom); - /* Set MTU limits */ net_dev->min_mtu = 68; net_dev->max_mtu = DPAA2_ETH_MAX_MTU; diff --git a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h index 3a4e939..63b09d1 100644 --- a/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h +++ b/drivers/staging/fsl-dpaa2/ethernet/dpaa2-eth.h @@ -371,7 +371,7 @@ 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) { - return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN - HH_DATA_MOD; + return priv->tx_data_offset + DPAA2_ETH_TX_BUF_ALIGN; } /* Extra headroom space requested to hardware, in order to make sure there's -- 2.7.4