From patchwork Fri Sep 29 20:42:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13404817 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A22C5CE7AF3 for ; Fri, 29 Sep 2023 20:43:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233592AbjI2Ung (ORCPT ); Fri, 29 Sep 2023 16:43:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232748AbjI2Unf (ORCPT ); Fri, 29 Sep 2023 16:43:35 -0400 Received: from BN3PR00CU001.outbound.protection.outlook.com (mail-eastus2azon11020022.outbound.protection.outlook.com [52.101.56.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 971C81AE; Fri, 29 Sep 2023 13:43:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fxoKmNPpRvlnSW7rJuO2FFROhBC/eQj5919hGzMGhnQSouxT+sn3b98DvKe0zuFNvNMa0Fm0agLb037YrdE8Wb4Ftwfgpeq0oLSSRbeQSYYJH4QDjv3LyW8x2kYPESp+Y9AVTrLb/YkI3UzwQ0bEyPxxvmMNyvX/Op9nOzoPj9N8PgNVdqSBB70T+zYYgwB/i2mDK7JVxaORzr8jZXNi7qmOkvDYIZOHko9kLWqFzYPyBI2RL5VRnFNjxRWUpLypgMAdkdk/bNmZi1AUzPYNVVnnWOVo8RpWfiPboWk3OxVYERPYXZsoCzcotD+n8gyI0yCX9SuQe4b0pyVcNzyOpg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xXFNeo5UWEafj2CY2GwEkJpsUM73DhTAB01Uavi+FFs=; b=SfKDarQapz4RH6VRdOpy5adYcKppSukhZ2o5QcnrkDmdfKi4jbnw2yrvE1NtIPubvWf/0neTDH86iH+eD5gBwWQdspW36XQA+8JjwJ+D7ZlGhruApCYvVF2VR5v5S+ZnIVl5blIiRVFlhPW370VcjgaqN3JUyJ6O3CueHc+Xknpq3rhO5+tuGSxI6lNKwc2ynr94CFZiCkaDSl7Kxq44uSh+yzf9ZtYaV/E1yiuGPwVvaFCQuXEhbG5mKpFxVKdbsGdYVbIQmRFwssUEct0ZAKckzFocNOxqYEYqbKKsNry+uM3D+ifShNMeso/jyaLJNYxJu2f42gVjrfhYL1s7Uw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xXFNeo5UWEafj2CY2GwEkJpsUM73DhTAB01Uavi+FFs=; b=aN8BT7h/2SWY10GFEvp/iTlaYml+n8H+L7XdO5bnO3S6uF4qKmvgITfuQwtU4kTzFwi6s73xK8QAEA1Ej6rnDbBqOMGek2vktWKJf4zIOQ9TsOP5d76O/IqKuzwYng1f4WJiTfh/Kovt3BYJ/nhau++e/FJqfC5+gMdwLQLaYLI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by DM4PR21MB3178.namprd21.prod.outlook.com (2603:10b6:8:66::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.9; Fri, 29 Sep 2023 20:43:28 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::1d4f:5006:aed7:78aa]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::1d4f:5006:aed7:78aa%6]) with mapi id 15.20.6863.016; Fri, 29 Sep 2023 20:43:28 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, stephen@networkplumber.org, kys@microsoft.com, paulros@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, wei.liu@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, leon@kernel.org, longli@microsoft.com, ssengar@linux.microsoft.com, linux-rdma@vger.kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, bpf@vger.kernel.org, ast@kernel.org, sharmaajay@microsoft.com, hawk@kernel.org, tglx@linutronix.de, shradhagupta@linux.microsoft.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net,v2, 1/3] net: mana: Fix TX CQE error handling Date: Fri, 29 Sep 2023 13:42:25 -0700 Message-Id: <1696020147-14989-2-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1696020147-14989-1-git-send-email-haiyangz@microsoft.com> References: <1696020147-14989-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0209.namprd03.prod.outlook.com (2603:10b6:303:b8::34) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|DM4PR21MB3178:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a6ddd9a-4a7e-432d-2538-08dbc12cbc5c X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ky+aIH9ovTI61fWaAC/99ga6zf9/lFpHnIu/DCch6iYZPwpGMNsJ9mVG++KjfDcrWaOrWHhtkGZ+zjacGLTilZVPHgC0qTjoaRnnpgWREOJA6J8Swm3PnGN8vmwmpAybmqnhlUQPo3sGFoQXZTmFC2j2YbzDi5CNtXwqFakIogyQ6Au5CuJI3l4I4BcAIeWr02gs4qNTIITBjte+qZ8joFgKZB3a2c2k3bgdu4Z0mF/dsmwZRrm2NQcPbF315jM3cWeh4QSvu0WCdWIMQ1X0clUwpIFMbtgDNqvvfXUsml9aRuJTTSRIhp1stNWfpV4+9B1wdJQ1R80y2TDgvMje7aGx9WoF74RmhRmDCKxl60EC1JP47YeNLnagLV1Tv9Zgx7JbS1DTovNAYRXAELj9n/lSlWNSC219j3WPDBO0o+47y77yi+YGeQeUPkdBiWW8qlZVC2UxjsyH8sFAV3kdBqDtHR8S0/T7eHojsiXlOWVyd1W4gv/aoiPDtRMX2lse+sxk1fSMf2QXjES5OCl+ZoQhP5/ejUFz9kp23DgrEi0Xih2CTMQnX1d6XIHae7wokWh41wY1d9SR58gtZdRDAs9yHn4/RV2XOztLDV5Yv0eJ3Lj2byeBvlP2x5HIM/rZFtVog38np4RYiYwAp4Cj2qw58Hu3DxudOApFSuo2SiY= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(39860400002)(366004)(396003)(136003)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(7416002)(2906002)(6486002)(10290500003)(41300700001)(8676002)(66556008)(66946007)(8936002)(5660300002)(4326008)(66476007)(6666004)(478600001)(6512007)(7846003)(6506007)(52116002)(26005)(2616005)(316002)(83380400001)(38100700002)(36756003)(82960400001)(82950400001)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aP9P2sunhKLjtjERB5cKXaO4KdYqGcKRlWBwj8L4gB3DiYctQ+WmgzTAVB3S4LKuKQlUviDTP+kDPBy7PfVr5niW30LvTjDN03MQ+APdniTWAmlbHiYsRKHTrqDp/H+le8C1NwuWcE/VCWX5kmckrCZ03LbAZT7ShYX5aIf7CUjqLdwwREv/hGVnAkomFvMox8HKkyBZmkcSm/K1nrv7cAF6bFbxlJWskqtKA+FGsFfn10HH1ObiZgU60h3Aujpeo8dVcPa7Dko9zcRu7AdvCq8vQWsIOZjbuqzV81kzHAsdaY3QoFXgMEvlKuYf2qa4yZI9p++FGCbaE35swhTwvx79P6tMRb8X1aWM38mtrbbhBWFjxL7A8DCXsoHueSqtrjHIc6ObEhPnRpzqK6BNQjpTRhW7CupSUrW4JzR0BVBRTpFg5eSGNIXPO5Gbx4U5pe61UttSPbKV3Sk9v0kfar72ITL0jQlf7IleLo/R4wRnmf2PWhfyyFB+IJB66G5NQY3WjFCIOVoVrEXczVD9h2Cy+7fFt11K6I0DM4kQbjKEAJeJeIYT3LJRSCztdbiNCJOd3yZKUTEUAx/qEsf9LjPADGAQbOz+IUGpucl4Ogj6PtEVSdbdbsRK8WQlpUM34GTui8GZl9a2h2mMd1Sf2mPZD0ltZTCAKCf9oq8uTjhgUyNlOl/L3t4AUy6540MJvw4VU6TSzrT4gslDMV2YKIUJcwndKmBm8ltS+KbHfxrfNIVUNKJ/uIVpB7ORuWtGscxjRJQFwwlBXSJ7VegmUVtkZPmWpEMbAzf/nVa+kD+aKTSNDhnsSXobv3axHlyOwvlgj3zIQPRsg5dXf95Tw9nva/8O1ub4ZG7ye9hZBij91SmKVJS3jn9H3Ey5cJKwSNhJCzibsZWpR3kAIgI5e8eOTn+XMAUu1zLmq7RVl1x+RH+D/U49lBVgZN1nYwWAgyxPLe3jdv1xUCkDtjAu1nGMz3hlXtNhR7FAhdCSjsQaiqsUhbpAEEzYChSts10C2D68B0e3nrI83vG0ji/o6irp82+1UsdwwCI4w/S6I5pPzNGqCN3yn4XTis+9SuGT1eGHE7FMdOvKXfn5xoAKpIswVf6Ow4NwAsoWk61nr1yZzVPaCaV8+riMUHXIDs3gAqWly2K8Cts9xLshTnKmkjFphQJQlfO9DWzj40YC6e5KV3fam97e9R7wbiYSwOxQKO5s+xm5jXCG/vMzsbffouB6PMxmf06GBIlpIKrnyiUIV/eksz+bMMk3y5XcPU0/QeuDJaC8+DL//QPSc93HfGPx59lTiQ50hBWPzO/G94V7q/coZGwbuY++eOL9ADyvKOPJDMqHfQPhIo1FPSvI/xx7Kyk9gaZMG/L9IKa2ap4XqVaeqDNriEyLmR/3wLdVTjPtGQzMsdAKSRw2ETS25kER0N/wTgS2kfk2uCl41FywyH3lUVB7/4bdCnqSgGoTcWEy7dL3p/03i6mVi6MDeImYrfQGuPgp6aCq8azd9zIZzkzCd+ZIhpsfTrL2bmnJIOr2UP6oPuExIYBpTF/TYbjSg4vou4F+n8jRvUSJlLWLbjPIJfpBxE0TBbAJ4z/x X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6a6ddd9a-4a7e-432d-2538-08dbc12cbc5c X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1443.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 20:43:28.7197 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LRCpiBE8wU+d3Qiwl6wRtoYo4uVB6sNfUebSbgYkjJw+yjP64YOvwwS6RvZSQPzkfYfJKxe6t7E+nKO9Ku1j0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR21MB3178 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org For an unknown TX CQE error type (probably from a newer hardware), still free the SKB, update the queue tail, etc., otherwise the accounting will be wrong. Also, TX errors can be triggered by injecting corrupted packets, so replace the WARN_ONCE to ratelimited error logging. Cc: stable@vger.kernel.org Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Signed-off-by: Haiyang Zhang Reviewed-by: Simon Horman Reviewed-by: Shradha Gupta --- drivers/net/ethernet/microsoft/mana/mana_en.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 4a16ebff3d1d..5cdcf7561b38 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -1317,19 +1317,23 @@ static void mana_poll_tx_cq(struct mana_cq *cq) case CQE_TX_VPORT_IDX_OUT_OF_RANGE: case CQE_TX_VPORT_DISABLED: case CQE_TX_VLAN_TAGGING_VIOLATION: - WARN_ONCE(1, "TX: CQE error %d: ignored.\n", - cqe_oob->cqe_hdr.cqe_type); + if (net_ratelimit()) + netdev_err(ndev, "TX: CQE error %d\n", + cqe_oob->cqe_hdr.cqe_type); + apc->eth_stats.tx_cqe_err++; break; default: - /* If the CQE type is unexpected, log an error, assert, - * and go through the error path. + /* If the CQE type is unknown, log an error, + * and still free the SKB, update tail, etc. */ - WARN_ONCE(1, "TX: Unexpected CQE type %d: HW BUG?\n", - cqe_oob->cqe_hdr.cqe_type); + if (net_ratelimit()) + netdev_err(ndev, "TX: unknown CQE type %d\n", + cqe_oob->cqe_hdr.cqe_type); + apc->eth_stats.tx_cqe_unknown_type++; - return; + break; } if (WARN_ON_ONCE(txq->gdma_txq_id != completions[i].wq_num)) From patchwork Fri Sep 29 20:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13404818 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 54407CE7AF3 for ; Fri, 29 Sep 2023 20:43:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233634AbjI2Unn (ORCPT ); Fri, 29 Sep 2023 16:43:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60374 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233739AbjI2Unj (ORCPT ); Fri, 29 Sep 2023 16:43:39 -0400 Received: from BN3PR00CU001.outbound.protection.outlook.com (mail-eastus2azon11020024.outbound.protection.outlook.com [52.101.56.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4DE971B9; Fri, 29 Sep 2023 13:43:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hIoxStDkUulpjhGQVEDvBRQ3006hOqhO6wNfJBh5GqFjOjS4h0hVX4giCliGHolE96a0xKwOkapCHald8u3boH/pQGOhI96MxDetvt05/OzCO3zsxjOB4zNBrRs54DaW/J4kdpRNv9SKXphgQcn8AbX0zvhi346k1CuTAo1WHv09UYA8F7+0KP61amO3V+IYItw12OccH4myySO0VMzlCj7Qu2sXDtfiL0bWMlt1a81yYyR53VnMV6tnFba+hTQlXpcCYwbdMGnd+ZVOL+puDNmEXYaqoO5sb5dubbf57vq3pPEw8Kby2CPWS5mKOAClL8aAFhL8Gew6GIrmvZc8oQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bO61FgGwPpmJ4QfoMvSiX7Vk3sqhPzpyEaU/2v0N10U=; b=JCrXyjiYhOXHpyPev7kW0H+dutr7eYq2nJCWpkD35huVOE5OVkrnlk6yKtuvEj+PcYQmzLbik7F6iOIuat6WdRwBuRXOifhuxRApaESgcKExjGOwBWXq5/mNiZYNPafE7Eviv2e44J+OA9Lm+Nv0kkUUtNso61nFpWjogaKNExvAio23onYJN3BhUmmUQ9aWduvkHrj4t2Ls8sahL/wWuZn/YUt+18fapOqDLBFnaUI8GMJImY+TWGs2neeLm66O3smKvS8N2+LpxIUcggdIKzGTm37g48PLFqNvAB6tkJuei2XLHqwshd9il7HwalujQjQJw2wPj+Et0PkSV0/eBA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bO61FgGwPpmJ4QfoMvSiX7Vk3sqhPzpyEaU/2v0N10U=; b=A3HjZ7xSeRpKHuiA9ViEKEYMUU7veYH3OMqbGAMEnPETMJAmE0KMNSlWVl9xwlyF7KwKzEOtUX7l3L92/ZVOnrz2tYgzw/Tvum+Tfc9f0RyC0YwCMEPR9JIigXzhFNM5gE5DpgTqmXVoyMYeIaGOFP6xA5jNUmtzS6wJSP3j70g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by DM4PR21MB3178.namprd21.prod.outlook.com (2603:10b6:8:66::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.9; Fri, 29 Sep 2023 20:43:35 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::1d4f:5006:aed7:78aa]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::1d4f:5006:aed7:78aa%6]) with mapi id 15.20.6863.016; Fri, 29 Sep 2023 20:43:35 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, stephen@networkplumber.org, kys@microsoft.com, paulros@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, wei.liu@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, leon@kernel.org, longli@microsoft.com, ssengar@linux.microsoft.com, linux-rdma@vger.kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, bpf@vger.kernel.org, ast@kernel.org, sharmaajay@microsoft.com, hawk@kernel.org, tglx@linutronix.de, shradhagupta@linux.microsoft.com, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH net,v2, 2/3] net: mana: Fix the tso_bytes calculation Date: Fri, 29 Sep 2023 13:42:26 -0700 Message-Id: <1696020147-14989-3-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1696020147-14989-1-git-send-email-haiyangz@microsoft.com> References: <1696020147-14989-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0209.namprd03.prod.outlook.com (2603:10b6:303:b8::34) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|DM4PR21MB3178:EE_ X-MS-Office365-Filtering-Correlation-Id: 252a30d5-8eee-4757-8365-08dbc12cc032 X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RmtjItMvE5UYEoSnI8w8GU8H7WVOFLdbw7buUhSa2jvkQGNKUzVZD/MY+ihr5QN7uQuvBPudy9K6RoUKDpCruzHm+TXqvsz9Kny41P5k+3nZ/YFMouzF0b0EGUP1OinesaGlMxReSut60R0EZY3qxeg2xSjfJqW2zLaEsqu9/oxDFHgokGxc7JGVyliE2z3JFwEelmTs8CCZErlK+476BxVcyfsWWsWkT1ACONrTi3EKMlpATHr30z7PHehz6eh2kIgzPDaxAID9BDBuCo38DVrbUM+UIMG800CtAbY3XbyZ2vKf9Tp+Cjakxi6I9QdXwYd/O8oP1lV9FGcs5NCErsQQC0GrfJANAEIHJaL0VV++5w/Ewu+G562ViRhnGaZlPh9h4zylt3A2hcOc2kebTVJcMGokXVZx95xZJASPcoaX2RnGY26nw6I/gUWu8dXIgRr8ZllSZupNxIkOsWFr0DSt5jbvY4TKP5lId0m4JkvitmK4yej7dxGPRwuYV7xhEXASdbrfBehHeXjZeRgHaxnyP3VwDvkBwSZV2pWnNsyF2cfo3IcKirMkR5Y6BBBRvjfoGGoLqQnp/ygy5BMXukNwrWwgPBFWIuc60tKep0IXd+aKI2FttXGYDOiwowTFbz5h64rijB+6F26hNxyUSI0uJhekWvzfTz8RtbGCNhM= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(39860400002)(366004)(396003)(136003)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(7416002)(4744005)(2906002)(6486002)(10290500003)(41300700001)(8676002)(66556008)(66946007)(8936002)(5660300002)(4326008)(66476007)(6666004)(478600001)(6512007)(7846003)(6506007)(52116002)(26005)(2616005)(316002)(83380400001)(38100700002)(36756003)(82960400001)(82950400001)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sls80MKSXIytK138hjVf9dyNBUpCkn4x7O9fOFItU9sGfhd0OddknLXjnosHoLdxMUtVtZSRGTSofqeaRnFptJynHr7Vpx/b60pDkX+TWCk1YP9rwJVLXavNyovkjfBt/ARDanuvPw5A2AD6dHWjVzfjOJTD/e4Ak8B1y6pX8b3DzA19Am0npEWmKus8qy8QZ2v8Wb6zVCWcZVSV/SDMDrSyyMxNmjo3Q+2Jai+j3fQK5pX5H02qx2IBhljo+oGqzMhFaqir+d6Tu8rBz5ySW7LokBb15HHTPfed4YB5SGLn0EDV2tY4zGI00+h/pPALiic3+vlrh/Kula+d1O2E2W4M5UhPiIB/ZOCsjIEHLM75XzUNkFVBQ+EZZkMwWCyOBJXMM+5bB/xlDtImCVI2aDMcACenkv6/Y+WJYsqSAVr39yCDE7pVaPhVIm7SyMkAq0ovvYuPtDwXVt7e7mV4JpBXm1lZ2N1vwT9Wa46bnaZiDTyjXSEf2apwIIJFTTOrsItnAG3Wir8r/m3D1MKo/EGAWuuEiKFYMSI2W85kxKO1zUf5TwrPDoW0nVwm0GX74z+a3aq6gxY1cey02uRV0H/mF+umclXc4cpTBsH9QUjr/iez7LtjbPsTBtSLuEURyVoaStUhzJ136RCBWCUj3wUSy7uHFQGQRdhhE7jV8Bicyr84DK45HHIUBJX7JbR8BoVB/UCe+3Vz0VZWFjHZwenIfCBKxjXGxIvMUZ8ozBvHjUyMHu9DKgEhdzI5hs31W3UBMtkOzlo75R9jX+FlBn45KmiF44zMTT4jzbvUaYiRMtAOjL+VjpjRrEl2hBGBC5Y+jK1sFdhJUXkNOJzCwFMxczAUSmv5U16f4jlI0/qdNWPXpfAVEGU4wj0ynbFS+s8aJLsE/EcuYHySOMEyzXF3H0pOQsUHTqKV5JuMFds2JuZPBPzMwO0ZN65kFNPZJg2U1+eyRmD0bGhNK0gwIB72V8zDOBRzE3v/ZHHcKKslxJtjys7BA890EoeXqkb7r6ZTniQPQe+xbHnnhRW3U/EzKCPiOmF/wnkrh8tvz/ZqPLS9cAJ0ktzygcwV3cO77nGaH4mYAb6tvRzxChiW2DUV4Jn6nXzFa33zXhGgwiFut1EBDkGhG1g02EX5oPJtFJK++wZCLaJEP4uunxP/DoiPW6gm5AGEDDOMB1+a69QMQa3EHw3rWUspTkIm5WU4cG1QCObDVgViVlRGZxiDmFhIRnidniMB8/3h6doC5p8jJyA+mLNnMB9xFdxEacLC5Y5CQQXdIZn04R4FR+Q72xKp/rSTLlCqXAjXZramLVQ3iXaF71wi/V1cJbY6oCP32YmgTRsOT95zCPIM3LdRjI0PI3AX11w4uevZ9p9l4qJ4CMQsjxkzPHYQw2tYO7Mf33hyHO267ItnF1IJoMOReCNAtHbe+cAZCWqnlPUUQAdBqyYR2RJ/JFsAMnCFhhmvAmJmZ27QLk8FrNLq95IlswInVyCwfUdhGfwP/DH12h9l7FjrFNn2sWak/BGJZcuwyXsTXaZzZdnHAIcK9t8HyE4SvNR87+Ukxp402uHYtmx5eCJiYbLSbWh9JIIchT0v X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 252a30d5-8eee-4757-8365-08dbc12cc032 X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1443.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 20:43:35.1742 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: VJT2jyGPcXLfN0C4s1Fo0WzWPaUZh4/5nD/lzx2iYYboSdxSZFF0Ed8T4yPfGBtaevur5T1ctYSKjMujJkJugA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR21MB3178 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org sizeof(struct hop_jumbo_hdr) is not part of tso_bytes, so remove the subtraction from header size. Cc: stable@vger.kernel.org Fixes: bd7fc6e1957c ("net: mana: Add new MANA VF performance counters for easier troubleshooting") Signed-off-by: Haiyang Zhang Reviewed-by: Simon Horman Reviewed-by:Shradha Gupta --- drivers/net/ethernet/microsoft/mana/mana_en.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 5cdcf7561b38..86e724c3eb89 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -264,8 +264,6 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) ihs = skb_transport_offset(skb) + sizeof(struct udphdr); } else { ihs = skb_tcp_all_headers(skb); - if (ipv6_has_hopopt_jumbo(skb)) - ihs -= sizeof(struct hop_jumbo_hdr); } u64_stats_update_begin(&tx_stats->syncp); From patchwork Fri Sep 29 20:42:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13404819 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A06D2E728F3 for ; Fri, 29 Sep 2023 20:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233822AbjI2Unz (ORCPT ); Fri, 29 Sep 2023 16:43:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233755AbjI2Unv (ORCPT ); Fri, 29 Sep 2023 16:43:51 -0400 Received: from BN3PR00CU001.outbound.protection.outlook.com (mail-eastus2azon11020018.outbound.protection.outlook.com [52.101.56.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 351B2CC0; Fri, 29 Sep 2023 13:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Kn4TiHs7YvVL16wgSl+KCZJHgeon2wHpGX32skHRj4kfW5bCH7xionfc6ETiS3L6+AUTKnU6iKr+mwVIQCw4Wfmiys347UuwhdC+8uZxQ4SZ9ZkRsIirhbwcyYfCsrvCKD0pdkZ/uYA2kq4nFy4D1bOBSBjfXdDHl+d4ZBN9tPGpYbe02ayoBSA/1fZ7jKqkDcZyqYC+LKO4cOTgMrYU0IOdqKHak/JtqT66Q2hE9Wdi0AUe3PnDAkXPSPQ+b6NA+CcD6FdYp/cThLLUGbiihtSQR7O0jAd4DKGsNj57uZjmpLvqNVxCwIlCTcSyHuambQlExE9DqN3s2f1NPARIXA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=UqC7/sBy3Pmx8EznfoNj77qtEBuneii4Fl9wNU4LjF4=; b=IIV1YT6qZZAOILFffEtWmHhQ9FwShWy+aguUrKIK91J8+2ueR2RgkgH2Lj5A1ZimMI3XQf1yOvkCJLFkNG1GUQy6K8p2pUkGArtTG6vRsXAjpeJ4+sTTi17liW2sw5elI+jaeFX7fcsazmTfYU5TCSlyqUGVC1T5KKbVbiDTm3Ut8p6j18huHK2odE1Kx4xlrmbQPWUsMuxabLBYYQl77ce99qBfKF31xezWVPmnAMqku2miJpLxNUrIrnJxIsFhqsZ7Z1WwtBeeXydxlLbspFbrWuZJ8R7puaj1miULS3SXkWDSaAEuh3DcsaKNsoljPkYmet8I5VhSIs31TMDQmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=UqC7/sBy3Pmx8EznfoNj77qtEBuneii4Fl9wNU4LjF4=; b=iFaMMkkqTxMG3m0i4x/+f2YvC8dQE4IT/i0oEpxNRfCXgrNXQKVjDa0rRcbPH3bU/F7Vpyk8Ti0TOlmstWDQEUGrOEtu3NLur4M2FlZZtwJU33jMlnm+mSgcNdGTtUsrIWI9KyQ8wH2d9gBahpMIXrElUN5qi6wCpXxR303njf4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) by DM4PR21MB3178.namprd21.prod.outlook.com (2603:10b6:8:66::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.9; Fri, 29 Sep 2023 20:43:41 +0000 Received: from BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::1d4f:5006:aed7:78aa]) by BY5PR21MB1443.namprd21.prod.outlook.com ([fe80::1d4f:5006:aed7:78aa%6]) with mapi id 15.20.6863.016; Fri, 29 Sep 2023 20:43:41 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, stephen@networkplumber.org, kys@microsoft.com, paulros@microsoft.com, olaf@aepfle.de, vkuznets@redhat.com, davem@davemloft.net, wei.liu@kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, leon@kernel.org, longli@microsoft.com, ssengar@linux.microsoft.com, linux-rdma@vger.kernel.org, daniel@iogearbox.net, john.fastabend@gmail.com, bpf@vger.kernel.org, ast@kernel.org, sharmaajay@microsoft.com, hawk@kernel.org, tglx@linutronix.de, shradhagupta@linux.microsoft.com, linux-kernel@vger.kernel.org Subject: [PATCH net,v2, 3/3] net: mana: Fix oversized sge0 for GSO packets Date: Fri, 29 Sep 2023 13:42:27 -0700 Message-Id: <1696020147-14989-4-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1696020147-14989-1-git-send-email-haiyangz@microsoft.com> References: <1696020147-14989-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: MW4PR03CA0209.namprd03.prod.outlook.com (2603:10b6:303:b8::34) To BY5PR21MB1443.namprd21.prod.outlook.com (2603:10b6:a03:21f::18) MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BY5PR21MB1443:EE_|DM4PR21MB3178:EE_ X-MS-Office365-Filtering-Correlation-Id: 5fc082cd-13f9-4088-9f86-08dbc12cc40d X-LD-Processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: sWcQ6kgEC3IRe2ClVHhWuhx6EbC/qDfHSjueXqXjk7+fJBJ1o7OzuUaiVpuCtCyUZJhNrAPtEuA76ETOWGchhBKcROAljrcqEZ1eTzmWi3kNiMaLHizbce7+vKBp6cnCGbYtfD86Xp25vPFHDrnJVSEouRQwDIZze6Fk+ZPWdnaPoafUif7bwfGD/aWzV4NP9Gsn4XPQs6DvA0/CGXkfYWdEyxaoQnvL61ItmwWS3ipzLNb4ePdApFm198GZHe7Hs5LYCcHIncdXRiYW9r9dfnDrUpjUojCylBjjyhdgT3/pt5tEih+FAxxGsPPr+cNpqtH3zPTG4uoN3Z5zLPT+tn/TGaMr8ImVqZg/3Jcq2I7fbOl3T1aheiQhdnXC1e6iaWlN5sr8tCrZh7AQ5V8Rrh+gcqvwcfq8OBGnoSFjJVKj+W2n34v5cOJjXSiSaPzyqf2GLiqONympbBvJxId5zQASUqn3A0DjRDZYZKK5bg94Bn76vHSdLENgq6nabDw40flwTKwy9phqX3jFq2XFSj1aP/Cy8gLLNJ9AZY9NphW45MsvTPAnLNwSBpsbT4CPxfeh90CcciNZJMVeISIu88CWZZ2fWxcMnbPUigJFaFiwQbOJLRwglzg1qZkdqLfkaGECGbvYvW2k8lR+skxffrhcKxRmPPubr+/Rh0Vvma8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BY5PR21MB1443.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(376002)(346002)(39860400002)(366004)(396003)(136003)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(7416002)(2906002)(6486002)(10290500003)(41300700001)(8676002)(66556008)(66946007)(8936002)(5660300002)(4326008)(66476007)(6666004)(478600001)(6512007)(7846003)(6506007)(52116002)(26005)(2616005)(316002)(83380400001)(38100700002)(36756003)(82960400001)(82950400001)(38350700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: dEmOkRGezta3ICeZGoXZXw4A/4zVLXeECbSThETgHKMvSYtwdCusu4+a4JsMlQOxVsblRIJFlUrir1vIphOKF4UJyr4y2Q0n3dpdXBIUWpUYzMgiS/NY6s2Juqn+fy6L3JZNPV29o4iz8sQiNt9xGPHTr2NrBds1RRMOD7GIiCvNlq/L7VKDUjt3v8Yp/DtSkB3qzhz3vKAWgkCmoSD65v+7BH9fQ0G9G3IhhKBwBWh2IlquGNeI0kKrKCang/9ufBm0/c1N7w3zLofn5StUs9KwgqDe0ZWoTzgZTj7Ck2//d+K2xDS/AX3h7YwP7nMwLPv+LFcti9ICeBi1f1ZONs/aUPsknkUF4lpt8rUmMT3KtgeuCgSEKpOZlprKZFuMB7rhigeYQAe9Z134a+alyTLKScOSLQ2ak1C8Y9BkofLP5eVpFM0Dv/jSbRU5jiDlkCxYdxQugjpppLrpgwLQl3yPNERbH9iFlngb4sdXUJBQg+d8hH36LuZVvMjonuqqL54pOE9ApnBOQQ9REfq0F97CGeY8lDpzAaIltZ/yAKlbduHKb4ABc+VpMfz+DNU0OHQxtVpUgzyjSCQZwenkTP5589lzGv+eiP8bdDMpthwjdLV34gz/RSgxWIPmr6Il9rlQVhTxTcGO5elCioAF6NgcrhD2+65aJrN/24E3H8mRvgcSqvuJxMPTl+8FBN7qveR4t9u7o7VjGJXHPN1aFEN6Ya+KqN/3EdjbfU3FeeRR0BnaV1ZHW4LPbpzRpCRJdH/nphnA9os8havdHnfrjyH2gPbs3XfTh2ZKxwV8tDqkaAWcSTe4jPb7769fRvzW//ETHmL/HsVCGvq2xysyoeViBMLkUJzquYinU+DH9ZKMa5+9AipZx9gjDq7bdyOeIJ9NfF/ow8xrHLgsm2xl1e2eSnyIQgFRAsuKFP4ZUNGQcV9iaxNAkPyceqKRXT/X7tPYiQvKS+RYNr4kycnSzqj3U7fIiYHJy8wmlda8/kcLaSM0oZBbYK4qeWVD940zpUKoZav7hoGS4z4CMcKHlXXXKrSXzdAnQINV+XpP9SGts9RcA28Nzjq+CWlu7qykAKgLddde7H+f1HesHtVuoitVGA4Q2ILdlYHjPjhnmhkaZEnekawd/tMvZa4NOAvPxRR66gJF+HLBb8UR5SG0PFzBbvHo01CviaNSxnfc+PWPo5gqXpEb5EjObJd9jOgo8et6G5tJo+GdC78VHZpdMMHHKRDgCBTPwBLgufCYyaP1wh6l9vlB4kJhrW9J6J5e/HvA95B1bxvYI87BkXWGhFvC5turWuFWL1vucS+8QmQxzYmNUOdD2ByrUH1myi6mPAy5azCxWJ0nlfdOsrFM4nneQmclKSvM774cpNXt9M08TJR0AmqA0IktGuCBLCtvTbphBt9S8zHmSRdqoL8Rd2MnBAjl+3HVvN0bPOGvGjHoWl+hXe+ulJ0RHdJb7SNEmkBXvHxWDtnGsFJpkZQt1COPVTM91kVBxIjNuXngCa3mjtcbrF5fmQV35/Za5oF38F2GDNmzYb+b6IwuhBVfsggfDtRUNlgdv2Y8qnaECNSKKKcQKTQt4hcaTptQ0rL6 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fc082cd-13f9-4088-9f86-08dbc12cc40d X-MS-Exchange-CrossTenant-AuthSource: BY5PR21MB1443.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2023 20:43:41.6102 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: IOhvLssdInitd9lE6gUZGUTROdJi0qAf1Bn4ranWzLs9QR3p+mr4ypLe8aGu3yTuTPS0pHLBL7TAhkTzq/ExzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR21MB3178 Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Handle the case when GSO SKB linear length is too large. MANA NIC requires GSO packets to put only the header part to SGE0, otherwise the TX queue may stop at the HW level. So, use 2 SGEs for the skb linear part which contains more than the packet header. Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Signed-off-by: Haiyang Zhang Reviewed-by: Simon Horman Reviewed-by: Shradha Gupta --- v2: coding style updates suggested by Simon Horman --- drivers/net/ethernet/microsoft/mana/mana_en.c | 191 +++++++++++++----- include/net/mana/mana.h | 5 +- 2 files changed, 138 insertions(+), 58 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 86e724c3eb89..48ea4aeeea5d 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -91,63 +91,137 @@ static unsigned int mana_checksum_info(struct sk_buff *skb) return 0; } +static void mana_add_sge(struct mana_tx_package *tp, struct mana_skb_head *ash, + int sg_i, dma_addr_t da, int sge_len, u32 gpa_mkey) +{ + ash->dma_handle[sg_i] = da; + ash->size[sg_i] = sge_len; + + tp->wqe_req.sgl[sg_i].address = da; + tp->wqe_req.sgl[sg_i].mem_key = gpa_mkey; + tp->wqe_req.sgl[sg_i].size = sge_len; +} + static int mana_map_skb(struct sk_buff *skb, struct mana_port_context *apc, - struct mana_tx_package *tp) + struct mana_tx_package *tp, int gso_hs) { struct mana_skb_head *ash = (struct mana_skb_head *)skb->head; + int hsg = 1; /* num of SGEs of linear part */ struct gdma_dev *gd = apc->ac->gdma_dev; + int skb_hlen = skb_headlen(skb); + int sge0_len, sge1_len = 0; struct gdma_context *gc; struct device *dev; skb_frag_t *frag; dma_addr_t da; + int sg_i; int i; gc = gd->gdma_context; dev = gc->dev; - da = dma_map_single(dev, skb->data, skb_headlen(skb), DMA_TO_DEVICE); + if (gso_hs && gso_hs < skb_hlen) { + sge0_len = gso_hs; + sge1_len = skb_hlen - gso_hs; + } else { + sge0_len = skb_hlen; + } + + da = dma_map_single(dev, skb->data, sge0_len, DMA_TO_DEVICE); if (dma_mapping_error(dev, da)) return -ENOMEM; - ash->dma_handle[0] = da; - ash->size[0] = skb_headlen(skb); + mana_add_sge(tp, ash, 0, da, sge0_len, gd->gpa_mkey); - tp->wqe_req.sgl[0].address = ash->dma_handle[0]; - tp->wqe_req.sgl[0].mem_key = gd->gpa_mkey; - tp->wqe_req.sgl[0].size = ash->size[0]; + if (sge1_len) { + sg_i = 1; + da = dma_map_single(dev, skb->data + sge0_len, sge1_len, + DMA_TO_DEVICE); + if (dma_mapping_error(dev, da)) + goto frag_err; + + mana_add_sge(tp, ash, sg_i, da, sge1_len, gd->gpa_mkey); + hsg = 2; + } for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { + sg_i = hsg + i; + frag = &skb_shinfo(skb)->frags[i]; da = skb_frag_dma_map(dev, frag, 0, skb_frag_size(frag), DMA_TO_DEVICE); - if (dma_mapping_error(dev, da)) goto frag_err; - ash->dma_handle[i + 1] = da; - ash->size[i + 1] = skb_frag_size(frag); - - tp->wqe_req.sgl[i + 1].address = ash->dma_handle[i + 1]; - tp->wqe_req.sgl[i + 1].mem_key = gd->gpa_mkey; - tp->wqe_req.sgl[i + 1].size = ash->size[i + 1]; + mana_add_sge(tp, ash, sg_i, da, skb_frag_size(frag), + gd->gpa_mkey); } return 0; frag_err: - for (i = i - 1; i >= 0; i--) - dma_unmap_page(dev, ash->dma_handle[i + 1], ash->size[i + 1], + for (i = sg_i - 1; i >= hsg; i--) + dma_unmap_page(dev, ash->dma_handle[i], ash->size[i], DMA_TO_DEVICE); - dma_unmap_single(dev, ash->dma_handle[0], ash->size[0], DMA_TO_DEVICE); + for (i = hsg - 1; i >= 0; i--) + dma_unmap_single(dev, ash->dma_handle[i], ash->size[i], + DMA_TO_DEVICE); return -ENOMEM; } +/* Handle the case when GSO SKB linear length is too large. + * MANA NIC requires GSO packets to put only the packet header to SGE0. + * So, we need 2 SGEs for the skb linear part which contains more than the + * header. + * Return a positive value for the number of SGEs, or a negative value + * for an error. + */ +static int mana_fix_skb_head(struct net_device *ndev, struct sk_buff *skb, + int gso_hs) +{ + int num_sge = 1 + skb_shinfo(skb)->nr_frags; + int skb_hlen = skb_headlen(skb); + + if (gso_hs < skb_hlen) { + num_sge++; + } else if (gso_hs > skb_hlen) { + if (net_ratelimit()) + netdev_err(ndev, + "TX nonlinear head: hs:%d, skb_hlen:%d\n", + gso_hs, skb_hlen); + + return -EINVAL; + } + + return num_sge; +} + +/* Get the GSO packet's header size */ +static int mana_get_gso_hs(struct sk_buff *skb) +{ + int gso_hs; + + if (skb->encapsulation) { + gso_hs = skb_inner_tcp_all_headers(skb); + } else { + if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) { + gso_hs = skb_transport_offset(skb) + + sizeof(struct udphdr); + } else { + gso_hs = skb_tcp_all_headers(skb); + } + } + + return gso_hs; +} + netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) { enum mana_tx_pkt_format pkt_fmt = MANA_SHORT_PKT_FMT; struct mana_port_context *apc = netdev_priv(ndev); + int gso_hs = 0; /* zero for non-GSO pkts */ u16 txq_idx = skb_get_queue_mapping(skb); struct gdma_dev *gd = apc->ac->gdma_dev; bool ipv4 = false, ipv6 = false; @@ -159,7 +233,6 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) struct mana_txq *txq; struct mana_cq *cq; int err, len; - u16 ihs; if (unlikely(!apc->port_is_up)) goto tx_drop; @@ -209,19 +282,6 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) pkg.wqe_req.client_data_unit = 0; pkg.wqe_req.num_sge = 1 + skb_shinfo(skb)->nr_frags; - WARN_ON_ONCE(pkg.wqe_req.num_sge > MAX_TX_WQE_SGL_ENTRIES); - - if (pkg.wqe_req.num_sge <= ARRAY_SIZE(pkg.sgl_array)) { - pkg.wqe_req.sgl = pkg.sgl_array; - } else { - pkg.sgl_ptr = kmalloc_array(pkg.wqe_req.num_sge, - sizeof(struct gdma_sge), - GFP_ATOMIC); - if (!pkg.sgl_ptr) - goto tx_drop_count; - - pkg.wqe_req.sgl = pkg.sgl_ptr; - } if (skb->protocol == htons(ETH_P_IP)) ipv4 = true; @@ -229,6 +289,26 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) ipv6 = true; if (skb_is_gso(skb)) { + int num_sge; + + gso_hs = mana_get_gso_hs(skb); + + num_sge = mana_fix_skb_head(ndev, skb, gso_hs); + if (num_sge > 0) + pkg.wqe_req.num_sge = num_sge; + else + goto tx_drop_count; + + u64_stats_update_begin(&tx_stats->syncp); + if (skb->encapsulation) { + tx_stats->tso_inner_packets++; + tx_stats->tso_inner_bytes += skb->len - gso_hs; + } else { + tx_stats->tso_packets++; + tx_stats->tso_bytes += skb->len - gso_hs; + } + u64_stats_update_end(&tx_stats->syncp); + pkg.tx_oob.s_oob.is_outer_ipv4 = ipv4; pkg.tx_oob.s_oob.is_outer_ipv6 = ipv6; @@ -252,26 +332,6 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) &ipv6_hdr(skb)->daddr, 0, IPPROTO_TCP, 0); } - - if (skb->encapsulation) { - ihs = skb_inner_tcp_all_headers(skb); - u64_stats_update_begin(&tx_stats->syncp); - tx_stats->tso_inner_packets++; - tx_stats->tso_inner_bytes += skb->len - ihs; - u64_stats_update_end(&tx_stats->syncp); - } else { - if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) { - ihs = skb_transport_offset(skb) + sizeof(struct udphdr); - } else { - ihs = skb_tcp_all_headers(skb); - } - - u64_stats_update_begin(&tx_stats->syncp); - tx_stats->tso_packets++; - tx_stats->tso_bytes += skb->len - ihs; - u64_stats_update_end(&tx_stats->syncp); - } - } else if (skb->ip_summed == CHECKSUM_PARTIAL) { csum_type = mana_checksum_info(skb); @@ -294,11 +354,25 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) } else { /* Can't do offload of this type of checksum */ if (skb_checksum_help(skb)) - goto free_sgl_ptr; + goto tx_drop_count; } } - if (mana_map_skb(skb, apc, &pkg)) { + WARN_ON_ONCE(pkg.wqe_req.num_sge > MAX_TX_WQE_SGL_ENTRIES); + + if (pkg.wqe_req.num_sge <= ARRAY_SIZE(pkg.sgl_array)) { + pkg.wqe_req.sgl = pkg.sgl_array; + } else { + pkg.sgl_ptr = kmalloc_array(pkg.wqe_req.num_sge, + sizeof(struct gdma_sge), + GFP_ATOMIC); + if (!pkg.sgl_ptr) + goto tx_drop_count; + + pkg.wqe_req.sgl = pkg.sgl_ptr; + } + + if (mana_map_skb(skb, apc, &pkg, gso_hs)) { u64_stats_update_begin(&tx_stats->syncp); tx_stats->mana_map_err++; u64_stats_update_end(&tx_stats->syncp); @@ -1256,11 +1330,16 @@ static void mana_unmap_skb(struct sk_buff *skb, struct mana_port_context *apc) struct mana_skb_head *ash = (struct mana_skb_head *)skb->head; struct gdma_context *gc = apc->ac->gdma_dev->gdma_context; struct device *dev = gc->dev; - int i; + int hsg, i; + + /* Number of SGEs of linear part */ + hsg = (skb_is_gso(skb) && skb_headlen(skb) > ash->size[0]) ? 2 : 1; - dma_unmap_single(dev, ash->dma_handle[0], ash->size[0], DMA_TO_DEVICE); + for (i = 0; i < hsg; i++) + dma_unmap_single(dev, ash->dma_handle[i], ash->size[i], + DMA_TO_DEVICE); - for (i = 1; i < skb_shinfo(skb)->nr_frags + 1; i++) + for (i = hsg; i < skb_shinfo(skb)->nr_frags + hsg; i++) dma_unmap_page(dev, ash->dma_handle[i], ash->size[i], DMA_TO_DEVICE); } diff --git a/include/net/mana/mana.h b/include/net/mana/mana.h index 9f70b4332238..4d43adf18606 100644 --- a/include/net/mana/mana.h +++ b/include/net/mana/mana.h @@ -103,9 +103,10 @@ struct mana_txq { /* skb data and frags dma mappings */ struct mana_skb_head { - dma_addr_t dma_handle[MAX_SKB_FRAGS + 1]; + /* GSO pkts may have 2 SGEs for the linear part*/ + dma_addr_t dma_handle[MAX_SKB_FRAGS + 2]; - u32 size[MAX_SKB_FRAGS + 1]; + u32 size[MAX_SKB_FRAGS + 2]; }; #define MANA_HEADROOM sizeof(struct mana_skb_head)