From patchwork Sun Sep 24 01:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13396896 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A065F7EA; Sun, 24 Sep 2023 01:33:08 +0000 (UTC) Received: from BN3PR00CU001.outbound.protection.outlook.com (mail-eastus2azon11020017.outbound.protection.outlook.com [52.101.56.17]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 07F49192; Sat, 23 Sep 2023 18:33:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b8Dr5eQHdNeVkz8A7/slJWQbSMuFhsbkAPvJVi38HuqUsH0YFa3VNP0YGRXyn8qxNwMYOzDRxoHPiJzvk+k0TkmBq1UkU9YZ1Gf3htt2hHmUgVEn8oxf5QLxqn0gZmoJXGEIQXrxw4km2zlJroPDIRUSbb4O76fcgEkYf8L1A11GLgrntRqQHyi/3/+agvq8JRsMP0NVOWbBMakpPL+5edSG1GEbcvtg5VoVP7VQh0DYSU347/AVMzC8fy0vp2Swo349V4plvrqtBM47UrgnA6TenCbmnJOaL4w3g8XmrxU/chESpuPpdboX4wmK+DE3wIY26JoFnUXdKgtaU5AcoA== 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=dE2PCYv+oUYCqjHEVmZ4YCeUOMeM3DeRepH9vdbt0XM=; b=eH/w7A49ge7nXb1fCGmSxIcC3jZAMWYOEvPBm6QhcHxItuya7KoBlsUBGJSXLhjFU9qGs9VEUprK+79mMdgfMn5OYNfaPCj6HAnF9oAMqFFCmZYXkIbGXidqx7RFg067ky/lgqyY95uGWqlnlpgE/0q6EwGa4X967zgdI7SKeL9DZqQDk571a4jnq+7otxP+Ysfnpe5TyeVYpe6wzgPMdlAMZuFGKc96/rs/5A4NXEwqkGooiShdoKMExqI4l3Dl7J8zAKeILIve5gHg0DkEgnvJoIhFa7FHVEJL32ZTpZqlouzmRx8GUhhfgwh7K+0b33ufGaZ0BuAriW92XkaMsA== 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=dE2PCYv+oUYCqjHEVmZ4YCeUOMeM3DeRepH9vdbt0XM=; b=OTzbTCSeBZm0iKEhjSI9uZSBK0mubVqPfIpMsekJeFjBzFLGdAR4Q6M7oBLnvTTh+qtPvqUv3M7jxkK0+mMBJ8YYANlsmZ6zYFChwW+sWFCIhzIw4C88GL5K7RtibtzT3L8OgwOVldXlG3ZgjFiVwnZMlG/Q5Vsde1Wh9POIkJ0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1451.namprd21.prod.outlook.com (2603:10b6:5:25c::16) by SJ0PR21MB1323.namprd21.prod.outlook.com (2603:10b6:a03:3e7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14; Sun, 24 Sep 2023 01:33:03 +0000 Received: from DM6PR21MB1451.namprd21.prod.outlook.com ([fe80::827:4af:136a:236e]) by DM6PR21MB1451.namprd21.prod.outlook.com ([fe80::827:4af:136a:236e%3]) with mapi id 15.20.6838.010; Sun, 24 Sep 2023 01:33:03 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, 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, 1/3] net: mana: Fix TX CQE error handling Date: Sat, 23 Sep 2023 18:31:45 -0700 Message-Id: <1695519107-24139-2-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1695519107-24139-1-git-send-email-haiyangz@microsoft.com> References: <1695519107-24139-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: SJ0PR13CA0043.namprd13.prod.outlook.com (2603:10b6:a03:2c2::18) To DM6PR21MB1451.namprd21.prod.outlook.com (2603:10b6:5:25c::16) Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR21MB1451:EE_|SJ0PR21MB1323:EE_ X-MS-Office365-Filtering-Correlation-Id: 7afdb778-5fb3-424f-51d2-08dbbc9e31be 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: G4LrCQc1+jHX1ws0Nq/Chhiq+T9GWiDO1ogZhBc9lWuEnzGR7J80aABsr7cPok/FW9HHVly0NybBgWmjML4nmNT8AX3+gowFlruyGt7s0OhJfUfTFJs5R10jBagguuFD1jMbkuMKjc6TOoQ5s+mRFhWi54t6cF/xO4puwMxBSCYZcqsSo2Ej5FJSx99j0M4i0xoBBAWerZ8iywjh58qZqw0JYny+7/EXs8XBGUsoEdeHa20AoeGGZR4hbZEvopuy0FAijBI6Uh+ZiAjIoLcUhq/i7WVqpgsNwiZwkfywL3jPYlaOfXe8/UPJINCjxXKcL7Fbwwqz0lwN62I547WB5s1gLWTkXYXmlF3RtFEHu/HJKfhPXU+g5KSMQhB/ozucwaC1KL/eOoXmi4XetvStfSGJqJ6TJiSMyUdl6jZOq3FYbc2chgn8zjAXCE+1cJ+CkrlewsPc1Dy2qbFjX0ceXA+I1IVtn4O7PgbepF6NzptbO9bemdU9r0TWjPm7/ivyJ7NSopOl5bs/bf0Qeu6Jf2ba2sXiMiYgu7QWLvhrjaGMHTxlHRW9Vmm4GnJILmLnUUeJoaD8VRK1Q+aFlvoqgwY+qTu9+AGWWwP8a8Uv74SZjCCWiHACXdUwIxppVkSCfGU7Zpg2PdqmkW/AvdOvEIC5nty2Gvoj2LdYA070+Hk= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1451.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(39860400002)(376002)(346002)(136003)(230922051799003)(1800799009)(186009)(451199024)(52116002)(10290500003)(6506007)(6486002)(6666004)(478600001)(83380400001)(6512007)(26005)(2616005)(7416002)(2906002)(41300700001)(66476007)(8936002)(8676002)(66556008)(66946007)(316002)(4326008)(5660300002)(36756003)(7846003)(82950400001)(82960400001)(38350700002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1s9sK1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MjxoifF9F5xaSu/tekJDZWj3kCexDsJYKHSnsqsidvHSdxGSVEpp2/wdmEq5/EJyxIZJJJZCAaaQctdGvT1jg2btmd4k7B2trGAU7E3vCxWtMmz3Yq4mw2K+tSLU074oEOqIQQoHw1t5kMkGxd0Tfd/xh5wTa+TG5XSf4xmHrbWU3C0P+Av2kTPRmcEf86sKXt+kpO+gkTatrFX86bt/miZsb0rbcgQGVYh3ov5wqioFDwO8EUHxU38s6GSFZ7SwVuO9AxnB0C16EO39qg6N9GBysblTUT6vnTO5wdTfGQEagvu2+R3PG3mdF/VsK1xwdBl/gZjhsCS5T320PlrYDZryGDQDeZoRPXzy042q8BFsBJiEA8UQiMsgK+1mYC2m3NO/9J/j7a1EFBMsCo+3oXBOCEeOgQJ89ewjCwTOe+qipXO1uGFeX7/TrDH+M0j3yZ+VxC5ztNLoN+o/9QRjJrTE47aXqSlFA0SVAdMhrkH6rRhfyYhqO/8JVQWdKAdHTVB0zr2tdzL X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7afdb778-5fb3-424f-51d2-08dbbc9e31be X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1451.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2023 01:33:03.1164 (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: Y2JyBHBIDiKS17O6Y2zRUoqFmwafT0VkwtmQNrpuiZ74Xvrj36n/wouI6y/SSFbG9g/vgfgUwRRObi7TiH3mLw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR21MB1323 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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, because we don't need stack trace here. 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 --- 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 Sun Sep 24 01:31:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13396901 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E259E36D; Sun, 24 Sep 2023 01:33:42 +0000 (UTC) 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 EC75611D; Sat, 23 Sep 2023 18:33:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jqRPZfiUkatgU/oBiEZO27DpQ3o1UOMSQ+RqNcapj6OGJDxvktNnW4H4LFV5qEwzjIOGQkJbA0At7B69x/S8B6lp+wlotDizjaUioVyd1P/RBIFBM2grYYz/F0TdWSTdGSN6NKkatDA7ruHeXBlkAmXeY0ekUvhWo9BdIYYAmdFzi5PAvbHQORMKuWb6QD9v2bRQpSYsU19bBA6FS4R0mgst7w/LRrjv2yrCcJwWmgHKUp03XUg6gT5JrtRk6I9wYdKSRyKMcvfGLMQyIUVRGr50iHFv7/YdyShniZQVBh2qUCasClBmaagoE0Z46uLjGYFgpiqgDa/EFyt4JOfi7g== 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=lPBHGr4d8D8McbJSo9Zz/VAuWF9uuj073tZYcXksau0=; b=YXDtg3110MCPeAXB4kTexytQopyh/R1AYV1OQUe08tg/dBu/8Pi71IXKWDwSkb92XQ1hb/jaNrhXyFdzEcpReTKRPibiN87ym1tmY6wDynxzV6kQXxXmYbyXMqRML6kOswUvcwWyXUAULvg8lR7UR8mdfn+Ga+Zv2HE5gJvC02kSNEnoK8lwdS7MyTiPiMQ59U+q/MdRhrduSAsH/JdQ8oMctutTtvvoFRtE2W35cdDeLAybjjnLGAbnm2lVHve+MEvSEmcO7zL6SjOouxZI6v2nMnEj52BnxRnoe0CTFS0C6vkth6CeNyHdRoDkXRw6J+l8Ytm4tUznmKZ3nWNE4Q== 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=lPBHGr4d8D8McbJSo9Zz/VAuWF9uuj073tZYcXksau0=; b=edybGDfK6+Rb2C6WQquo3rQ55PvFHWCtuoMkX80M5Q51zpeccPBcZrPUxtOygTlsg2kcbBcJIdp66IRRRHaIWd2+wmGIxmL0wBHZFfcvVWPmqq3zLGdMVUGYPXFcW/FFHk3hNKUkJJmSZUyskSTyL4yJwEN18GMQ41ReKHXBwpY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1451.namprd21.prod.outlook.com (2603:10b6:5:25c::16) by SJ0PR21MB1323.namprd21.prod.outlook.com (2603:10b6:a03:3e7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14; Sun, 24 Sep 2023 01:33:38 +0000 Received: from DM6PR21MB1451.namprd21.prod.outlook.com ([fe80::827:4af:136a:236e]) by DM6PR21MB1451.namprd21.prod.outlook.com ([fe80::827:4af:136a:236e%3]) with mapi id 15.20.6838.010; Sun, 24 Sep 2023 01:33:37 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, 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, 2/3] net: mana: Fix the tso_bytes calculation Date: Sat, 23 Sep 2023 18:31:46 -0700 Message-Id: <1695519107-24139-3-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1695519107-24139-1-git-send-email-haiyangz@microsoft.com> References: <1695519107-24139-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: SJ0PR13CA0043.namprd13.prod.outlook.com (2603:10b6:a03:2c2::18) To DM6PR21MB1451.namprd21.prod.outlook.com (2603:10b6:5:25c::16) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR21MB1451:EE_|SJ0PR21MB1323:EE_ X-MS-Office365-Filtering-Correlation-Id: 334162eb-c530-4449-d3b5-08dbbc9e4685 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: /Fgl+lRoWZkDJnC/oYgWOXbr12yzKjfAYVnZgfciZ+Qm97XcyXmWOP6vX0sz/mgLQT4y8hzRPwRqq/7C03r/ZqOQaVO8f1TaOvDqW4NvMWL+lXqtM5L4/MzZyGSLOKtEI4AMbsAznf/ISjCV0n17utHHdg/JjpDiyY68Qh/V1SBvmMaO/qKpkOjeMUYE3l5Id07rxuwM30h+oOtHYuPDmZMgXqXYAkVaYkytK7rRq8hoJTdWDaD3RPmptCSmYnlb2nGMipeiZ98NQ86ghkFWMSBDiE2o3D2EL6FRkhuy1QfySGqbN1aH36oXvmm1q8DarsrNl+JJfJ6htk9+Q0lhwIp00y77bbTWQPboey8JTcsCFmpN/F8fAYVYeDaSlIByvUK1Y70Dye4EaSyw9myBsnpuvYI7Qt4KEr+CixUHb6dezruv2IeWVC9JUA8Pl0CKD3SvwYMCpOO029/Kew3Ydn18wRVMNKUJNa4omLrARMbYgCmdD8IUdnP5sr8NxFEMIRiaGLTQuZ7x8QwtIGnwTllPY+zARTDIO4OVkhG1CjXYzrF0JHfFPNR/epV6VVaIveIGInUSgbJtoVtyKe2oi57U/50/xG0RjDCpJUChQszhqWCsLSHXOB/kKjHBg2wWlgy5WCw66y/gZLdjSs/uPQINmJqccGa9MMNHUwGanVI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1451.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(39860400002)(376002)(346002)(136003)(230922051799003)(1800799009)(186009)(451199024)(52116002)(10290500003)(6506007)(6486002)(6666004)(478600001)(83380400001)(6512007)(26005)(2616005)(7416002)(4744005)(2906002)(41300700001)(66476007)(8936002)(8676002)(66556008)(66946007)(316002)(4326008)(5660300002)(36756003)(7846003)(82950400001)(82960400001)(38350700002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-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BrCAGrqj47auwTNmZCb3MXUAwobT4C7LDIMAyRWK7dQ3/d+ALSOZXPsC+iy/kkndUdjmWlv/DmiySNTPwDs80d3RuuDuNNDvmbgYd3D6YI18mhPnMaRh5mRIzLrAlbvWyo9R13nKfuElFVPoKzYa2Vx4yzdETQN4FyD8UcK7Vp26GpaFzgs9gX2bDIxalhZU/tKJyymPcEtFRRvKmL63G+T1T4u1v6Au4DOHBfziK7+hsByp9y+zCYV0+qTJnVDLY79+o6g48xGaQJnc1r9GTli9TRrfA+2Wsrl5x2eaDt9FTEuHluQPmMJBYJJ26q51/iUGDlaEZ1REBbGifNM/3JpVPgUWq6yJISc9ri0ORvYTX5QntDxC9DoLzUSbcS/e39v4PUuZDCg2BTj4UQvvqv6eo9qItOcVKL8k/aphOadT/NYTAgUXvt/nCq6FL1h5aJi7uEwnWxL16QhObDYkYWxmbhNuMh7xEZHgrx/N8w75YsAkjPnkt4frb4LxcCj+eEBX85wFix2HSJV5MW1150/0Cyr2wmJaum864ez X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 334162eb-c530-4449-d3b5-08dbbc9e4685 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1451.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2023 01:33:37.8773 (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: NCr8iJ9x9XOrto7M95QBXFnOskYyiRkKkPMYtQSZ8CmFKtFmkjNK0uZ7XGmvlHgjNO8YziEh4Jtiobtz/T59Hg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR21MB1323 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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 --- 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 Sun Sep 24 01:31:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haiyang Zhang X-Patchwork-Id: 13396902 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 538457ED; Sun, 24 Sep 2023 01:33:47 +0000 (UTC) Received: from BN3PR00CU001.outbound.protection.outlook.com (mail-eastus2azon11020025.outbound.protection.outlook.com [52.101.56.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B520B113; Sat, 23 Sep 2023 18:33:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bgOTnok+d/IUxP5niH7/Wnbnb6FI+2+6Q8NhA4hkMz9LpN0tZ74MFHCgMv+NNniVeYvaiM5eGYmM98Muexh0qFtiDkiWE6rfmI06pA47YHE2E/fUKm4QYTamnmycuaqTj/9FT217C2Cn/3ngg3+ueaeYz+wHksAzsIJ1AkL4DK+LVv2emcncOv6PvgXgJ6fIBFnYlYnTyVgXPFRPXIa1tavlBgXkjM1dQ9hZ3z3Kv/B242oOQwACyHabGztRgWqMedVYPQHIIk2Imgu8DXUg6JuYPuTtc3sMpqVkiAUPE4+v8D6+R4DcxejriMB/fxgdxdUctxA4JXh0u9aZK7Wlkw== 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=wvcaYKE7Rt77HnfuS3vgkr4C4LVsxQtewIxQCeXXFvw=; b=BArMEOBIw3ShyFEN0ma12Cf+l123lID3dGYHaU9MZOzCmFSNTrEXJbwqX7frct/IQIiYvsjZ15sr5RB4rGRH7IYbSa3n7H8tNWPwt6EyeSggkGtaPOLONXP9Zr/sXpus4uI+dCE3+RTsR2kpBJK0n05N/sAUw0b4Ehuu/zmn+IWS9Qdx0IxBiD/2BYd6zXvoR+Lv/D4hwUiUMERlDRCvLIdriJvlXtKokHBeAD5nOK27/Mjb927XsEfYaSOklE0fXRVY8fK48/neOfvTPtv/Xq2gp7cgVzqejBOVA7r6lz49+fTZ0zGshjYIxxUBEZAxeCg4Y+YUuJMPZE3gIDmx5w== 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=wvcaYKE7Rt77HnfuS3vgkr4C4LVsxQtewIxQCeXXFvw=; b=cCZ0dIZl/9oM0/wjGZXC7qBRcUdheiiTYOaNT4KoheRc6rImBEBz95sQbrJJSLdoDlzpR9Ql84KRakJJFrNwh2liPYeTugpN+q1K8SbmgHwvDIrBkXlQOFeyWx4/7Po69DNH97K7/zs9LI9nQNPTDfk85cIu8cIOkslSXJvJuWY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=microsoft.com; Received: from DM6PR21MB1451.namprd21.prod.outlook.com (2603:10b6:5:25c::16) by SJ0PR21MB1323.namprd21.prod.outlook.com (2603:10b6:a03:3e7::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.14; Sun, 24 Sep 2023 01:33:42 +0000 Received: from DM6PR21MB1451.namprd21.prod.outlook.com ([fe80::827:4af:136a:236e]) by DM6PR21MB1451.namprd21.prod.outlook.com ([fe80::827:4af:136a:236e%3]) with mapi id 15.20.6838.010; Sun, 24 Sep 2023 01:33:42 +0000 From: Haiyang Zhang To: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org Cc: haiyangz@microsoft.com, decui@microsoft.com, 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, 3/3] net: mana: Fix oversized sge0 for GSO packets Date: Sat, 23 Sep 2023 18:31:47 -0700 Message-Id: <1695519107-24139-4-git-send-email-haiyangz@microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1695519107-24139-1-git-send-email-haiyangz@microsoft.com> References: <1695519107-24139-1-git-send-email-haiyangz@microsoft.com> X-ClientProxiedBy: SJ0PR13CA0043.namprd13.prod.outlook.com (2603:10b6:a03:2c2::18) To DM6PR21MB1451.namprd21.prod.outlook.com (2603:10b6:5:25c::16) Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: LKML haiyangz X-MS-Exchange-MessageSentRepresentingType: 2 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6PR21MB1451:EE_|SJ0PR21MB1323:EE_ X-MS-Office365-Filtering-Correlation-Id: a4b20246-629f-4d07-ec99-08dbbc9e48f8 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: 2kP0CA/PvOpkel397RWubNooHdOVB7pAL/wMJSDqqyqIzj5tsgQ5X5yMvrdYNeKlfyJ0lVSYpyKr0mUaHmvPPUHTkl1eYev4gphSNbuwcVE3jgom9L7Lqd4ERMpeyYwRE5Te9F5MEeL9wVfHtjlPODkigOiL/sFEWTuBvk5RQK+1++rKwj8oENhWGPpogLnGKSsaMolkgZf6hUX5QagA69wuIkvapSOxthXf3/xRB0I0eB2YxYJWEwWm/tCjdux0VtWuJ3RO0YGd+drQwktqseehthDzAuGJMwdxr3rxvUrbEbD78ioJRrbse2qrhaN74oIVfS8JdKghsdCocyY6uH7iERJLdEhz8uoeNOiEnBUHTPT9AINc3g/j44XAlzbsrDllehwhkuTfSLxlcYoYLu+hKlau15ZiSOp8IxE2b7FLaCJ+fbH/gT9utX2zFBfIKGTEw7Mi4at7vQy2hGpTA/eo/xp2EPgjZxmUeCtxCxMJGtayU0acOZH73LjVBqIv+ezvMVkmqY+/3+WWFMVTKUiQ2XGh8uSaIJYgUbcA+vZUBeiP20dEbT+5IJQjRXfL5r8lMXB89QDBScvq8Rlz9Ta6ilHzmORAO2oaDrv8hvt7NN6tTG1R4d1k1EXujs0wABZyOZw0Ii2kCgaCfwCmpA04Y+79KO5nCte6sEBi+k0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR21MB1451.namprd21.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(366004)(39860400002)(376002)(346002)(136003)(230922051799003)(1800799009)(186009)(451199024)(52116002)(10290500003)(6506007)(6486002)(478600001)(83380400001)(6512007)(26005)(2616005)(7416002)(2906002)(41300700001)(66476007)(8936002)(8676002)(66556008)(66946007)(316002)(4326008)(5660300002)(36756003)(7846003)(82950400001)(82960400001)(38350700002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Vh2BtkZvN2tLvEh9wPsA8AEgur2GW41aeFnHlBmBfV/0I8vdzUKKDnwRdVhZxW47toO+T4mlsPDp7Lpc+KmveVcG8UlQho14N4OZ+Ik7OVW5tmfwQbuRGvmdyps02x0i8Ssvt+b5YO/nFofnJjH7QcrKw0HrS62YcohhXKbsU9BQZYuSp0b9otcLxipsjx4bnzrEk0eXRNBpnVxqVa3yRH0Ehi+h/sTcXs6lRAKALlqQZbZCshpiqdQ3XIKNTqvXy4rIFHuKb8UJPoG/1+QxHtWxLCJOsOe0H0V7DOi0ulVY5ErhrxdLJiau7GVbJntLR7rAX7aad4bxFoFDeFcyjAB1CXqpZRITPe7xoWOKTLDXYIwBn8uBm80qxd3/hNZ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H7PZt1BaiZOWGVUHSFuj2lktP6jdgTJOpLmTgqbpgqbSauYWuSGPDSRuTeMqgGPwuUphkioXJWdP7kUNMi8eb9CrcjJ5gZbbPou3uxch2RK1drGDycOh0jBeKYol6SVoPdpkB6ley4Fof5FZ X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: a4b20246-629f-4d07-ec99-08dbbc9e48f8 X-MS-Exchange-CrossTenant-AuthSource: DM6PR21MB1451.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2023 01:33:41.9619 (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: Zb0d0ixjrkhIcXp741v4WBeLw8j92q7vBBd5ZLh5pOwilob2HTiz6W0V0W0MvkN5g8RIJLBK4TZJKOF2GX5aXQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR21MB1323 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@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 --- drivers/net/ethernet/microsoft/mana/mana_en.c | 186 ++++++++++++------ include/net/mana/mana.h | 5 +- 2 files changed, 134 insertions(+), 57 deletions(-) diff --git a/drivers/net/ethernet/microsoft/mana/mana_en.c b/drivers/net/ethernet/microsoft/mana/mana_en.c index 86e724c3eb89..0a3879163b56 100644 --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -91,63 +91,136 @@ static unsigned int mana_checksum_info(struct sk_buff *skb) return 0; } +static inline 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. + */ +static inline int mana_fix_skb_head(struct net_device *ndev, + struct sk_buff *skb, int gso_hs, + u32 *num_sge) +{ + int skb_hlen = skb_headlen(skb); + + if (gso_hs < skb_hlen) { + *num_sge = 2 + skb_shinfo(skb)->nr_frags; + } 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 0; +} + +/* Get the GSO packet's header size */ +static inline 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 +232,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 +281,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 +288,23 @@ netdev_tx_t mana_start_xmit(struct sk_buff *skb, struct net_device *ndev) ipv6 = true; if (skb_is_gso(skb)) { + gso_hs = mana_get_gso_hs(skb); + + if (mana_fix_skb_head(ndev, skb, gso_hs, &pkg.wqe_req.num_sge)) + goto tx_drop_count; + + if (skb->encapsulation) { + u64_stats_update_begin(&tx_stats->syncp); + tx_stats->tso_inner_packets++; + tx_stats->tso_inner_bytes += skb->len - gso_hs; + u64_stats_update_end(&tx_stats->syncp); + } else { + u64_stats_update_begin(&tx_stats->syncp); + 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 +328,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 +350,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); @@ -1255,12 +1325,18 @@ 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; + int hsg = 1; /* num of SGEs of linear part */ struct device *dev = gc->dev; int i; - dma_unmap_single(dev, ash->dma_handle[0], ash->size[0], DMA_TO_DEVICE); + if (skb_is_gso(skb) && skb_headlen(skb) > ash->size[0]) + hsg = 2; + + 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)