From patchwork Tue May 30 14:30:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liming Sun X-Patchwork-Id: 1787623 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=JkiR6qQD; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVvvz2BfKz20Pc for ; Wed, 31 May 2023 00:31:11 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1q40NM-0005rI-IE; Tue, 30 May 2023 14:31:04 +0000 Received: from mail-mw2nam04on2062.outbound.protection.outlook.com ([40.107.101.62] helo=NAM04-MW2-obe.outbound.protection.outlook.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q40NI-0005nr-Nn for kernel-team@lists.ubuntu.com; Tue, 30 May 2023 14:31:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AZXehnSPWbCyY87JQWeGcEU3nuKUwVm6lC19xaqpKcOFdINug8nT4YRNxVaXbQohBUsU0NNIy+BBbSNz4d5U+9+9K9X6NwKPCCZU6F6P2IdAfZ8PcG+mN/GJ3haYtisdr5lt3XRzPwrABd8J8LLRKS8RwQF3Uos7+zsWOqm+OkKaBkpLNpEm+rbKaS/vRaDbk2XabHKtBrXS1pNUEvTKf7mT32RfWWF34xPobaHC3cW/WvGmVCgEpqQ4b7QWUDASoVR0pmAYSVKQHNIaH4DmvgNHNy5o0IorhO2rebROaVnCLBvEQG+oCAUbg0bCKEhW0NsJF8xXHaL/UsWrTHUH1Q== 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=IDpqBWDd60SQRyryTHfWYFE2/JVMvCjaA0ZjVB9QuO0=; b=a01ZcZxNWYYROpMrjUF3zkKG9Y7EzI7gifEoMCo6dxR04E7HvEx9kWoFLMcw5Ru+fdKHwZRuKxNwWKm9aVZlgYP8/F0N/g0u2eE94Db3yFjEE+G4AVBZWUo+chZlMPeqLbZIc8JSOjlNqP2UII/M46pZtdu2uNZr16B/c/tjCQ5sp6MZMBQqvOAA03NVP7sWEHxcn5zT8jt0ZwZtQGutN7Nhbtxl4HxUQE+iUIm7ICfuHVH5YK0RlEfYVvR59limTYCiWti3UcyxH9YzbyfKIKNzVF2/xckFwxYT/oLJHXt/z9/45IYYma32HTybYfvfgfkVNHevPNXM/bmzo/AQlg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=lists.ubuntu.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IDpqBWDd60SQRyryTHfWYFE2/JVMvCjaA0ZjVB9QuO0=; b=JkiR6qQDPTf99srAaZUx4emI3D94qBOfbHGOpV29tyhv/1k3ySpesu86LOcLFqDfj4GbyBVg200sf4BXE4JBI+OLhttgxDy4+Bf4yD3AQs0jy5xC27cja3lqa4LPQ6GaqR05II+GYTxtxDDSMJgasAkwpJnacodomxsY3RY9S5+xUFnHyMnXMZ/075bAKujH4mD+Q5tfmtVzYEP9B32YJG+tITXARnQ4PMKCb9V38CUsR0w9DDWQ2UYnfwh5j7fLWl5+E/2+9BUSQCatjBbfkdZSaZebnbQ/yJ/6HHclufAbtwraoXmtKzmhAIKn+SzqDxZxLyS1TXtYAJJEZaPknA== Received: from BN9PR03CA0148.namprd03.prod.outlook.com (2603:10b6:408:fe::33) by CYYPR12MB8653.namprd12.prod.outlook.com (2603:10b6:930:c5::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23; Tue, 30 May 2023 14:30:55 +0000 Received: from BN8NAM11FT110.eop-nam11.prod.protection.outlook.com (2603:10b6:408:fe:cafe::3) by BN9PR03CA0148.outlook.office365.com (2603:10b6:408:fe::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 14:30:55 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT110.mail.protection.outlook.com (10.13.176.156) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:30:54 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:30:38 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:30:38 -0700 Received: from vdi.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:30:37 -0700 From: Liming Sun To: Subject: [PATCH 1/2] [SRU][J:linux-bluefield][PATCH v1 1/2] UBUNTU: SAUCE: mlxbf-tmfifo: Drop the Rx packet if no more descriptors Date: Tue, 30 May 2023 10:30:29 -0400 Message-ID: <0c5d1413dec7019a2ad8520920e8fcbef8ed72f2.1685455239.git.limings@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT110:EE_|CYYPR12MB8653:EE_ X-MS-Office365-Filtering-Correlation-Id: f8ddce12-8ace-4994-d3e6-08db611a7a3c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hkBAFsCCqmbvFnLZBp0Ck7xaf5h+y7uigwfLQWXT82Hntj4X8rMKbkvRVQmHvft2MChUZZUdGp7KRYOkGd9gix/yjmKbPuySh+SPfcZFOZgHl7/qDr2OeDCm832MEdCi/J9C89JPTNUaofXfqTDvh3fiz7PSG5YvKP5yw3xus/Pn4jqmpjpudMUn3HJOPoxvhcs7loUxp55dowPH1uV2LhGxvzkjZruronekK1iu7iCHiyJYFe+ozN2F6km0sWrvFoY5k5xCtONTV87ECT7Z5yyXgB8wwVeJQHPG3C3PPOSTd9zA3TuioDQezgDgsBc/eEDuKR/dKvhXmB6tyIIq72ONOtI1OU+Xt8xJ0LP28ESK84kXFwzEyj4jWlpt4lyclKZRqiWDk3dQjsZ1H0I/kLdVHkNSXicdcxwChQSOy97+Lrhz4RLHvu/ILo+DadZ5u2tdfOiuaqraqUZRMRJ+6Fw0XnljM+kXDkl6ctLT4miBKpGVKYHxgUWgo4KxTGGPTCXtl7RdvKa/jh5GUBICmTvzchCUCsoxFaxHNTVtVAjlBNTw9GRxUL0I2ScodMrgN/I9osgy1h7LTm+Vy4dWWhZjPEcQrq0+AzkasTd888PQQX3pt2WLGSzd4cJ0nFdm7MPKaLwnlzVka9bSsQ406p6MKs34xakbIcbOcF7AlpVUi1lQfUXwPb2UGdcrsCwRhybiyiqGC8AbfDL/XLlKlvB0ipUygJi5tSViq4NiaXUviGzMeUe2gHpX4WNEUKXP0pap/iNONkP13CsFxgD2K4mNIYYwEqnsxLo/7rxqAZ/ShTBeY5FGZ0sMu67CA15h X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(346002)(136003)(39860400002)(376002)(396003)(451199021)(40470700004)(36840700001)(46966006)(966005)(186003)(107886003)(2616005)(41300700001)(426003)(336012)(83380400001)(26005)(7696005)(6666004)(36860700001)(47076005)(478600001)(40460700003)(356005)(7636003)(4326008)(82740400003)(70206006)(70586007)(6916009)(40480700001)(316002)(8936002)(8676002)(5660300002)(2906002)(86362001)(82310400005)(36756003)(29513003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:30:54.9033 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8ddce12-8ace-4994-d3e6-08db611a7a3c X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT110.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8653 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Sun Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2021749 This commit fixes tmfifo console stuck issue when the virtual networking interface is in down state. In such case, the network Rx descriptors runs out which causes the network packet stays in the tmfifo and couldn't be popped out thus blocking the console packets. The fix is to drop the receiving packet when no more Rx descriptors. Signed-off-by: Liming Sun Change-Id: I98c2b9aa2e21277675022775538f053df393da4e --- drivers/platform/mellanox/mlxbf-tmfifo.c | 64 +++++++++++++++++------- 1 file changed, 45 insertions(+), 19 deletions(-) diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c index 19d539fc99ae..b986496b1da0 100644 --- a/drivers/platform/mellanox/mlxbf-tmfifo.c +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c @@ -59,6 +59,7 @@ struct mlxbf_tmfifo; * @vq: pointer to the virtio virtqueue * @desc: current descriptor of the pending packet * @desc_head: head descriptor of the pending packet + * @drop_desc: dummy desc for packet dropping * @cur_len: processed length of the current descriptor * @rem_len: remaining length of the pending packet * @pkt_len: total length of the pending packet @@ -75,6 +76,7 @@ struct mlxbf_tmfifo_vring { struct virtqueue *vq; struct vring_desc *desc; struct vring_desc *desc_head; + struct vring_desc drop_desc; int cur_len; int rem_len; u32 pkt_len; @@ -86,6 +88,11 @@ struct mlxbf_tmfifo_vring { struct mlxbf_tmfifo *fifo; }; +/* Check whether vring is in drop mode. */ +#define IS_VRING_DROP(_r) ({ \ + typeof(_r) (r) = (_r); \ + (r->desc_head == &r->drop_desc ? true : false); }) + /* Interrupt types. */ enum { MLXBF_TM_RX_LWM_IRQ, @@ -275,6 +282,7 @@ static int mlxbf_tmfifo_alloc_vrings(struct mlxbf_tmfifo *fifo, vring->align = SMP_CACHE_BYTES; vring->index = i; vring->vdev_id = tm_vdev->vdev.id.device; + vring->drop_desc.len = 0xffff; dev = &tm_vdev->vdev.dev; size = vring_size(vring->num, vring->align); @@ -380,7 +388,7 @@ static u32 mlxbf_tmfifo_get_pkt_len(struct mlxbf_tmfifo_vring *vring, return len; } -static void mlxbf_tmfifo_release_pending_pkt(struct mlxbf_tmfifo_vring *vring) +static void mlxbf_tmfifo_release_pkt(struct mlxbf_tmfifo_vring *vring) { struct vring_desc *desc_head; u32 len = 0; @@ -508,8 +516,6 @@ static int mlxbf_tmfifo_get_rx_avail(struct mlxbf_tmfifo *fifo) return FIELD_GET(MLXBF_TMFIFO_RX_STS__COUNT_MASK, sts); } - - /* Get the number of available words in the TmFifo for sending. */ static int mlxbf_tmfifo_get_tx_avail(struct mlxbf_tmfifo *fifo, int vdev_id) { @@ -732,19 +738,25 @@ static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring, if (vring->cur_len + sizeof(u64) <= len) { /* The whole word. */ - if (is_rx) - memcpy(addr + vring->cur_len, &data, sizeof(u64)); - else - memcpy(&data, addr + vring->cur_len, sizeof(u64)); + if (!IS_VRING_DROP(vring)) { + if (is_rx) + memcpy(addr + vring->cur_len, &data, + sizeof(u64)); + else + memcpy(&data, addr + vring->cur_len, + sizeof(u64)); + } vring->cur_len += sizeof(u64); } else { /* Leftover bytes. */ - if (is_rx) - memcpy(addr + vring->cur_len, &data, - len - vring->cur_len); - else - memcpy(&data, addr + vring->cur_len, - len - vring->cur_len); + if (!IS_VRING_DROP(vring)) { + if (is_rx) + memcpy(addr + vring->cur_len, &data, + len - vring->cur_len); + else + memcpy(&data, addr + vring->cur_len, + len - vring->cur_len); + } vring->cur_len = len; } @@ -847,8 +859,16 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring, /* Get the descriptor of the next packet. */ if (!vring->desc) { desc = mlxbf_tmfifo_get_next_pkt(vring, is_rx); - if (!desc) - return false; + if (!desc) { + /* Drop next Rx packet to avoid stuck. */ + if (is_rx) { + desc = &vring->drop_desc; + vring->desc_head = desc; + vring->desc = desc; + } else { + return false; + } + } } else { desc = vring->desc; } @@ -881,17 +901,23 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring, vring->rem_len -= len; /* Get the next desc on the chain. */ - if (vring->rem_len > 0 && + if (!IS_VRING_DROP(vring) && vring->rem_len > 0 && (virtio16_to_cpu(vdev, desc->flags) & VRING_DESC_F_NEXT)) { idx = virtio16_to_cpu(vdev, desc->next); desc = &vr->desc[idx]; goto mlxbf_tmfifo_desc_done; } - /* Done and release the pending packet. */ - mlxbf_tmfifo_release_pending_pkt(vring); + /* Done and release the packet. */ desc = NULL; fifo->vring[is_rx] = NULL; + if (!IS_VRING_DROP(vring)) { + mlxbf_tmfifo_release_pkt(vring); + } else { + vring->desc_head = NULL; + vring->desc = NULL; + return false; + } /* * Make sure the load/store are in order before @@ -1073,7 +1099,7 @@ static void mlxbf_tmfifo_virtio_del_vqs(struct virtio_device *vdev) /* Release the pending packet. */ if (vring->desc) - mlxbf_tmfifo_release_pending_pkt(vring); + mlxbf_tmfifo_release_pkt(vring); vq = vring->vq; if (vq) { vring->vq = NULL; From patchwork Tue May 30 14:30:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liming Sun X-Patchwork-Id: 1787622 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=SSGYDUkX; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QVvvx2qycz20Pc for ; Wed, 31 May 2023 00:31:09 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1q40NK-0005pS-Bl; Tue, 30 May 2023 14:31:02 +0000 Received: from mail-bn7nam10on2089.outbound.protection.outlook.com ([40.107.92.89] helo=NAM10-BN7-obe.outbound.protection.outlook.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1q40NI-0005nN-0R for kernel-team@lists.ubuntu.com; Tue, 30 May 2023 14:31:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iMhfqt6N5D+2rOl/vj7+tej1PFzHUV+oloGTlJ0nEbnjRVlxZp2vjd/Z0TFgfxmRdEbMvgME2+159DpNSLum8a9yYq7fTxldmcJCmYUG4OMAAX/RQArBrS9o/0Q/KywdZOli0H4yoSz5/Gkkt85i1nnPGa3CcnXIov88vaAcaKKztGnqhbS56EGRiocGHEvUjGYirZbI9YLqkcHIgMDoTc+A1Uwxg5PdnuW6mWcu7bKdIHGMh9KGRrmSfbDQWLp6EOY6DWyTT6y/Fj4dPv2mE7QddBpTgsMxU3cmooBVYBYU3E9meWRIQXOjkTxp7wuRFHh4aSuSIpndoe/76ckiFg== 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=zxO3jd2OP8jo6oiksAByTPJ5BvNwBFrHNtGX8oR5DMQ=; b=PO/JRjf9sQ00HDW55WqiRdESGWsW+tTB/93MCD3B7EoZmPq7gWYH5HC2X1vfjh7s79gvyQkvHq2DNeRKP2Q+UUIF8oNQZnfm1Q6DoLmzGZoaGKrFNIBgnjv3GuA5OjW5FxLr7QH8ovVLMESBuG7yVNRG4NNFp3ggTR0qwhsFf4G+M8EIY91XZ79IJGCRNj21dOvpRinqrbl3dKLslT4heFnpN/qbOXEt0XNil0Yb5z+iHsDHGCnzD9OZmRtQ3KAujJk5YdjIYZj2Uc2NJxy97g/GEtMogVGmGzezjgvbGhYgbBWHpCVoyX/yQ1ekGtbHfqksQXlCUYp0pYZ5HAmzhw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=lists.ubuntu.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zxO3jd2OP8jo6oiksAByTPJ5BvNwBFrHNtGX8oR5DMQ=; b=SSGYDUkXnF0lnjUdykZo2l87hxXhM4HCHEzTAoJ4L64eYND8SE7nztOjaoXYANVgz3m1p62G9TfR6OmdJsj2vnLKphl4RdfnH+m6KB6yUToV9B0O0Vm+A2jQuaofKVDiGWrKgyE8AKjaHtBsIY533CyUkBR0janj47IKPrBkzceVH9PUfTXVGCqU73sXKjzTASk0kBPP0VKBMJRwt8Gc9l7nBVVTHGV7IrXDpH4ZGMEdj3quZMXJ0+YBvzowCzDKJ4ntezpwKB5feuNKlSiwUzUN2Ic+UbB2JYy4J0bW3geSahDCp243HpBrUWdDTipIHjF22Fdo0Z4j/UN/OlkygA== Received: from MW4PR03CA0057.namprd03.prod.outlook.com (2603:10b6:303:8e::32) by SA1PR12MB8885.namprd12.prod.outlook.com (2603:10b6:806:376::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.22; Tue, 30 May 2023 14:30:57 +0000 Received: from CO1NAM11FT024.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8e:cafe::e0) by MW4PR03CA0057.outlook.office365.com (2603:10b6:303:8e::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6433.23 via Frontend Transport; Tue, 30 May 2023 14:30:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT024.mail.protection.outlook.com (10.13.174.162) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.22 via Frontend Transport; Tue, 30 May 2023 14:30:57 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.5; Tue, 30 May 2023 07:30:41 -0700 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.37; Tue, 30 May 2023 07:30:41 -0700 Received: from vdi.nvidia.com (10.127.8.12) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server id 15.2.986.37 via Frontend Transport; Tue, 30 May 2023 07:30:40 -0700 From: Liming Sun To: Subject: [PATCH 2/2] [SRU][J:linux-bluefield][PATCH v1 2/2] UBUNTU: SAUCE: mlxbf-tmfifo: Drop jumbo frames Date: Tue, 30 May 2023 10:30:30 -0400 Message-ID: <745f71b275ad1436f6cf6e9dfd7193f03bfa9799.1685455239.git.limings@nvidia.com> X-Mailer: git-send-email 2.30.1 In-Reply-To: References: MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT024:EE_|SA1PR12MB8885:EE_ X-MS-Office365-Filtering-Correlation-Id: 7eaee0fe-057d-4e6e-9bb0-08db611a7b79 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: mojPo3lBJy8YVbNwiPYAltgYPiet1+ET7pqj/a78cgqd6B/aKxacRqMfq/LMMWzMJF7rqovvicqI8A4TKbFC9WCn+J8cZHT8WuAeqsB+9C7eRjsDb1x6nDXbj6ABNpbt1lo1sJmAtM7R0vAzhldo4aAk63F8Q7KMmY/QZGKmluuJb1u2/XcPZP5YboziGsF06XuZIxTsIaCQJctDscD5tX6nEIirif23tf3TOzpEwAOVysGe6orI4sgyYStxBtmWE31jLnjaylRx1jas9w1QTbnpCWXkrSdedhjFJvJ9Oevs4u/AD6g88n+QjCuIWMYlTZFgqvpAyYx7nF6r/vI36g90ilRGHaugTpMWBVdS2yMn3f0kCyODn7ZUQ6GOV6WXvneK8daxagv9PuHq/SO0YeywzBonYvuvM32GYodeB9mXVDaUo3J7JE5UIQkLUb3gwdAVzCVsbcC2J5v5lTgf3jS+b8AENAsZMOMB3ExxzAAIo2XH4w0X5/rSpf9e52fO2POSbvviDYIZN6a+ZyDQgFSL2iRz0ZY4ui/0Fu3rNp2gOgC0jXj3gt2kkn/g3LigKJZhicvkzI4ynRBmUXGIKQ5wPC/VQxHjcqh7tqClB9Xfn6TYrurUvUjJx228zq73A726j2yJYqMSZl94ao8/DfUjR2fSkcw1vnUBaqc8I3/HFs9QVtQ1VzebzKCzMpeIN4XNrCuAMYwrB15e8PAovdTdIk2yZB2jSSvr0aLVr8aDLR2zW+DB9phXJw1gx1389BVOc7+YXcvdEX15cHbsfb5JwNjRvfKsFBQDztx2pu4= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230028)(4636009)(136003)(39860400002)(376002)(396003)(346002)(451199021)(46966006)(40470700004)(36840700001)(82310400005)(86362001)(41300700001)(7696005)(966005)(40480700001)(40460700003)(6916009)(6666004)(4326008)(316002)(36756003)(70586007)(70206006)(36860700001)(5660300002)(2906002)(186003)(478600001)(26005)(2616005)(83380400001)(47076005)(426003)(336012)(107886003)(8676002)(8936002)(82740400003)(356005)(7636003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 May 2023 14:30:57.0730 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7eaee0fe-057d-4e6e-9bb0-08db611a7b79 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT024.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB8885 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Sun Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" BugLink: https://bugs.launchpad.net/bugs/2021749 This commit drops over-sized network packets to avoid tmfifo queue stuck. Signed-off-by: Liming Sun Change-Id: Ieb0186dcd892295f00fca58fafd39512197e2b83 --- drivers/platform/mellanox/mlxbf-tmfifo.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/platform/mellanox/mlxbf-tmfifo.c b/drivers/platform/mellanox/mlxbf-tmfifo.c index b986496b1da0..c9d879fc0417 100644 --- a/drivers/platform/mellanox/mlxbf-tmfifo.c +++ b/drivers/platform/mellanox/mlxbf-tmfifo.c @@ -234,7 +234,7 @@ static u8 mlxbf_tmfifo_net_default_mac[ETH_ALEN] = { static efi_char16_t mlxbf_tmfifo_efi_name[] = L"RshimMacAddr"; /* Maximum L2 header length. */ -#define MLXBF_TMFIFO_NET_L2_OVERHEAD 36 +#define MLXBF_TMFIFO_NET_L2_OVERHEAD (ETH_HLEN + VLAN_HLEN) /* Supported virtio-net features. */ #define MLXBF_TMFIFO_NET_FEATURES \ @@ -773,13 +773,14 @@ static void mlxbf_tmfifo_rxtx_word(struct mlxbf_tmfifo_vring *vring, * flag is set. */ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring, - struct vring_desc *desc, + struct vring_desc **desc, bool is_rx, bool *vring_change) { struct mlxbf_tmfifo *fifo = vring->fifo; struct virtio_net_config *config; struct mlxbf_tmfifo_msg_hdr hdr; int vdev_id, hdr_len; + bool drop_rx = false; /* Read/Write packet header. */ if (is_rx) { @@ -801,8 +802,8 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring, if (ntohs(hdr.len) > __virtio16_to_cpu(virtio_legacy_is_little_endian(), config->mtu) + - MLXBF_TMFIFO_NET_L2_OVERHEAD) - return; + MLXBF_TMFIFO_NET_L2_OVERHEAD) + drop_rx = true; } else { vdev_id = VIRTIO_ID_CONSOLE; hdr_len = 0; @@ -817,16 +818,25 @@ static void mlxbf_tmfifo_rxtx_header(struct mlxbf_tmfifo_vring *vring, if (!tm_dev2) return; - vring->desc = desc; + vring->desc = *desc; vring = &tm_dev2->vrings[MLXBF_TMFIFO_VRING_RX]; *vring_change = true; } + + if (drop_rx && !IS_VRING_DROP(vring)) { + if (vring->desc_head) + mlxbf_tmfifo_release_pkt(vring); + *desc = &vring->drop_desc; + vring->desc_head = *desc; + vring->desc = *desc; + } + vring->pkt_len = ntohs(hdr.len) + hdr_len; } else { /* Network virtio has an extra header. */ hdr_len = (vring->vdev_id == VIRTIO_ID_NET) ? sizeof(struct virtio_net_hdr) : 0; - vring->pkt_len = mlxbf_tmfifo_get_pkt_len(vring, desc); + vring->pkt_len = mlxbf_tmfifo_get_pkt_len(vring, *desc); hdr.type = (vring->vdev_id == VIRTIO_ID_NET) ? VIRTIO_ID_NET : VIRTIO_ID_CONSOLE; hdr.len = htons(vring->pkt_len - hdr_len); @@ -875,7 +885,7 @@ static bool mlxbf_tmfifo_rxtx_one_desc(struct mlxbf_tmfifo_vring *vring, /* Beginning of a packet. Start to Rx/Tx packet header. */ if (vring->pkt_len == 0) { - mlxbf_tmfifo_rxtx_header(vring, desc, is_rx, &vring_change); + mlxbf_tmfifo_rxtx_header(vring, &desc, is_rx, &vring_change); (*avail)--; /* Return if new packet is for another ring. */