From patchwork Sun Nov 13 13:44:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1686508wru; Sun, 13 Nov 2022 05:47:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf7w627nOEA1bko9khtITLg+csQMkcR6zfhNGCOSpC1kSYue1ZpI9rM33eJe7Hx7y7FbUFjw X-Received: by 2002:a17:907:9144:b0:7a8:3597:34a8 with SMTP id l4-20020a170907914400b007a8359734a8mr7537473ejs.628.1668347277576; Sun, 13 Nov 2022 05:47:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668347277; cv=pass; d=google.com; s=arc-20160816; b=n+390ip3tqYss44kKvn4R4uTXuKc6UuHfp+JIJm3ftRfoL7lOlYCmHQMCQqK9vDIWd 7tVg6culpNb53cLDw4cmWe6jO95X9MILUH1RLssp2Pke+izOkavPngEsAZGfywvi5gjk jMEcM+4eNegQnaJ8y6xHiZet94M7YTOEPdKdCJdm1+dYVTu6hJuxgRk6TcxxBRjKrAnG ettZx5vaFdKEAaVL+jLabNg3CPwSHdZruFcXCNWbWNIInTlF0iPiie0acsrmw+boeKtF QB5+rFRGLsnRjcnIxG+pDq4MeF5AsnWlhpOJc+bKQT0NWSBViwwl8pVAK68C6lFHrzqT b1VQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iouLEQGBjZWfTIEQk0Lgglr7+6bKQXTtXCox51OrOWU=; b=hLPq+yoWV51Alibma/fpv5N+dRSPU1+7W3aKC+6b1e2kpAo3vernN4awlD1G4YZMiO mteq3G+oGCQW/znrSYDXWi1eLTJbhgMxHSdmAJBktd9kPMETo4G4bBBx1Q2TuIE7ypdM LLdQ4SFZXiI/aHe0Cqc6qNoLKX51Qa/0U/H4VgBwfSnQsZA94+CSNEgULfIG7WR2xFOo ixiE7b75rJ7RMs+ec2cDQC5AJWESZkOQwrdxZIrMvLlIK2lvY5YiGnO1L0fdhCBT3vYa w4kVFs3qrTMAIXX6Bmpav2lMfLdR0FjMjglky1FVA4UAIA7b4d3sISIOgEeEq0404yQl EA9Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=CqLZRk1o; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cs14-20020a0564020c4e00b00462e4cbe815si7589904edb.550.2022.11.13.05.47.33; Sun, 13 Nov 2022 05:47:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=CqLZRk1o; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235364AbiKMNpI (ORCPT + 99 others); Sun, 13 Nov 2022 08:45:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235359AbiKMNpG (ORCPT ); Sun, 13 Nov 2022 08:45:06 -0500 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2060.outbound.protection.outlook.com [40.107.96.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53A206430 for ; Sun, 13 Nov 2022 05:45:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VgWhlV9tkLRJq94+pCLmQPCk9VV+SqmSKqQ6pKJI1fKBOmoQNfPeZAH/FRLbSExqU//6hGPxVWpJTTd5gWh0D1YYQ+SD6ozLZFDUGflvkwHjwjkpjyien9zb2BNfB66/HN0vzWc7yIMKzpShLdm2k158XTg7rh6tbi34CNvbjkpdPPz32EcbESEiDE7y6nwrO+AfJiuKiWvwoA4B7H7yhKinB+weN95MBCeCxTPl2KbxD0ZH8LjJSbTwY19yOabTC4sqCQ0DE6kHS1XhCY3E+S4AIxMbnAW+O2VfTZcXn30HhSVNeRXwdpdiaZn3SZJ5DfSeDOrk56PVEowaJ9mW3w== 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=iouLEQGBjZWfTIEQk0Lgglr7+6bKQXTtXCox51OrOWU=; b=jTBsr/UcVPsEQbXNimF1Xyekw0LXx1AedXZ6PZFKA2OGuj0ixY7PUrL6iCYJzQ7QRgG4xdBra3yJkGa+aFFMOqNmEii8novIsn0HxsJf16VSIuZ74oTk4VsnRhCjDLQSId9UWlb8eln3e9QhHQBnDVWo3CO3+9J1lgAIEnVDmjpF0nPs/HaMCk/NhpyYAkx67hwMdU4wRRt24OACpWMnCQKY/Vkzmx2I5+PFeY8HzbCsJfmhJQH1eSJXoCqcIhdLQMUBFEKTro2zji5PfNDaa0JXrv6saXUhFeALEtonr3QtGIZS6F7ll0QZonuIgDecj9OuQPD35m0qCKIIkkXTSw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.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=iouLEQGBjZWfTIEQk0Lgglr7+6bKQXTtXCox51OrOWU=; b=CqLZRk1oCrYWvnFbvop3NCREST4CqNNmJq5MYVvumiKo099qVL703oEH9mGsIzxUgYJnBKQrcS/kDz+/wJu0LNUQVAgtffMntdWSsb90dvAmcvSZgFA64eHEfzKl1hxJCt1mjwQUS8TGe948nHJKjBDLbZVKflWGwFoqtk626FBTc1jk1FX3FMj9kWExDZzFR6v/S5vP3k4bxOsZB3ySzSxJBKqQR/pHWCgomkD+xv7HE5eBv162ZPo+tMvLT7ASgYkQ/IWNBD3+EEb/KoLVivTcZ9HIo43vwwzZkQi+v5cF0SVMqej+xHbOh6Wrtq6EJ5rBia57I8J1FMA3+w9Etw== Received: from BN0PR04CA0054.namprd04.prod.outlook.com (2603:10b6:408:e8::29) by CH2PR12MB4326.namprd12.prod.outlook.com (2603:10b6:610:af::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.16; Sun, 13 Nov 2022 13:45:03 +0000 Received: from BL02EPF0000C406.namprd05.prod.outlook.com (2603:10b6:408:e8:cafe::2f) by BN0PR04CA0054.outlook.office365.com (2603:10b6:408:e8::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Sun, 13 Nov 2022 13:45:03 +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 BL02EPF0000C406.mail.protection.outlook.com (10.167.241.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Sun, 13 Nov 2022 13:45:03 +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.26; Sun, 13 Nov 2022 05:44:51 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.36; Sun, 13 Nov 2022 05:44:50 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 13 Nov 2022 05:44:48 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 1/7] vdpa/mlx5: Fix rule forwarding VLAN to TIR Date: Sun, 13 Nov 2022 15:44:36 +0200 Message-ID: <20221113134442.152695-2-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113134442.152695-1-elic@nvidia.com> References: <20221113134442.152695-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C406:EE_|CH2PR12MB4326:EE_ X-MS-Office365-Filtering-Correlation-Id: 43e521a9-0aa7-4db3-9a44-08dac57d4443 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: LXOtcNCOjW/93d1UAc7EHI7j7/mL0pMMUmx73JtntMX42K2Flr/jKUIpy1OTn9GU4czbi1Ez0B679uJJdP9K5//kH086m5YrL9EkWgCWtgbzoyi7wsQS5/dnplXHLz1l6CcO7gDHK3UFXO1aOVDLEo1FjlQ+9Nmga95IgJLU0RxHowxK2yJiJZ7AERa1izy6bxozT6BrcVG7KrU55OqQR0OVHmnwGWLk+za+uuDCKp0HxJHmtgoISQAsDakvAONuEu6uhXC4x1sjeTWwRRARcvxnupnpSNZX4oqmoQhYMlzGXDJ8BYgJUwDe/bfbUiVdRYXHPNDtqEnPFyJE+o1LRUCLDc/xJ6LEw0vkhtsuITKxrAu+4LVeB4zpEeZ9eYLQBDWRKQBLe7Duo6K4kKlE4pQufjafvAoKhEzoLW1FpFuYLqFKmO5QB+6uJuW0GRrg9O+kMiLpcfhaKMesE8v7fRBudEX07juf2ZpCPX72GxFuBBYHPe/xCIKGR6IVEbG7MV5N9BW9CC9IX2EIANAT0Vl8uvRu4xjw/8S1wk1ysRY0TBq3W72OfsVC//Gp10bxonNPjWeZbGFiU/K7lf+E5/eAwULmfoQmOjYvJ+XUJAAa23GVkTSPCvpsO5Z3cDWhWgu4/ETk58pXVpXN8t3X23Lqk75nMhEiS+Q03WZN9CQaAa7WlGgtZ76k1oeWoGq1DZuQPLh5NxzTk+hnMX03m3Ra76s5iRYPPDtASL3q4YrL9cf5PSpCx2vF3O+wA/h6gqJxJf5PDSxq7uSLoWieFA== 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:(13230022)(4636009)(396003)(376002)(136003)(346002)(39860400002)(451199015)(46966006)(40470700004)(36840700001)(47076005)(426003)(8936002)(336012)(41300700001)(82310400005)(83380400001)(1076003)(2616005)(186003)(5660300002)(316002)(26005)(4326008)(36756003)(36860700001)(478600001)(70206006)(7696005)(70586007)(356005)(7636003)(110136005)(86362001)(40480700001)(40460700003)(2906002)(6666004)(107886003)(8676002)(54906003)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2022 13:45:03.1180 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 43e521a9-0aa7-4db3-9a44-08dac57d4443 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: BL02EPF0000C406.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4326 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749388914999681561?= X-GMAIL-MSGID: =?utf-8?q?1749388914999681561?= Set the VLAN id to the header values field instead of overwriting the headers criteria field. Before this fix, VLAN filtering would not really work and tagged packets would be forwarded unfiltered to the TIR. In addition modify the logic so that VLAN filtering is enforced only when VIRTIO_NET_F_CTRL_VLAN is negotiated. When not negotiated, all incoming traffic is accepted as long as it is targeting the net device's MAC address. Fixes: baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support") Signed-off-by: Eli Cohen Acked-by: Jason Wang --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 90913365def4..ea95081eca0c 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1468,11 +1468,13 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, dmac_v = MLX5_ADDR_OF(fte_match_param, headers_v, outer_headers.dmac_47_16); eth_broadcast_addr(dmac_c); ether_addr_copy(dmac_v, mac); - MLX5_SET(fte_match_set_lyr_2_4, headers_c, cvlan_tag, 1); + if (ndev->mvdev.actual_features & VIRTIO_NET_F_CTRL_VLAN) { + MLX5_SET(fte_match_set_lyr_2_4, headers_c, cvlan_tag, 1); + MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, first_vid); + } if (tagged) { MLX5_SET(fte_match_set_lyr_2_4, headers_v, cvlan_tag, 1); - MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, first_vid); - MLX5_SET(fte_match_set_lyr_2_4, headers_c, first_vid, vid); + MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR; @@ -1821,6 +1823,9 @@ static virtio_net_ctrl_ack handle_ctrl_vlan(struct mlx5_vdpa_dev *mvdev, u8 cmd) size_t read; u16 id; + if (!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VLAN))) + return status; + switch (cmd) { case VIRTIO_NET_CTRL_VLAN_ADD: read = vringh_iov_pull_iotlb(&cvq->vring, &cvq->riov, &vlan, sizeof(vlan)); From patchwork Sun Nov 13 13:44:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19359 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1686529wru; Sun, 13 Nov 2022 05:48:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf5z2fPihWxH/cdBYXeFBEDOL6dWc3Juafyj3U4OO3KUvykba2dktoJB6ItG3R37ETGWEmjW X-Received: by 2002:a05:6402:22e5:b0:457:791d:8348 with SMTP id dn5-20020a05640222e500b00457791d8348mr8199323edb.306.1668347282788; Sun, 13 Nov 2022 05:48:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668347282; cv=pass; d=google.com; s=arc-20160816; b=G7K1JN1fUWr0NFPjVjZdW5D/ZhW6DMJBkCPaWL+sksOBxPCvYWWaP+GF3SBL5DuHgY w4lFwwZZysquxpBIyz/LSyJZI3IIbbz5qmYxcXTE9taDwddto/e6gcj7W7wRx4QgffHG JbkLU+MKl9VGp8IimCGC+UOkwkmQAs1fcIGO+jTN8+KfQZr+A1yac7/7O8WZsdBLJcWg I2nXQt6ZtFg4NSde6Ba0LuNdFKYdB1BXsGL+NLn6gy9Aq5zgFV5k3xYJat0iPZewcxzr x7KZCLt+3Ss0CxTBGc9YDsIGGeHgyewtuo/NL+bHfm1ArK+zf2eYhXdneUvc79WMayxR z1pA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=kDOJqcy0OOLQko69+5KPSSZvn1pkDgfG8yrDj23ndCQ=; b=Jb3WL+isKAYiQZDqVhXfWP2KdLrdc1aTu7aT2cW6iFUUGtj2p8rnlc1AIYAbfMtZsM 9+GCFhpHZmqA1pm6wHl1V2YzswtkO/viT1cZKtw6hF39+rfjJMKV5TSWp4FAEVaBwLUR ynF6HuM2kqNRtZyaGA2DS3qVkp1Q5kWKZT8LtTI+KjU2MKKErRMFdopfmQLI2RmGjoMY j44QaohgCVs/OrjOans7wOjMOjw3QzPWpJ5M1yp5kH/CCgAMj3oHms5E0L25N0TvghdT IPkKTsD98/nRM4I63B4hnejggHQhQ4HYgph67OiHPMscqen31oMJRncYXRresUrq3vkW 3M2Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=AGD2e6kJ; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc16-20020a170907169000b0078db371355esi324292ejc.987.2022.11.13.05.47.39; Sun, 13 Nov 2022 05:48:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=AGD2e6kJ; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235376AbiKMNpM (ORCPT + 99 others); Sun, 13 Nov 2022 08:45:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235280AbiKMNpI (ORCPT ); Sun, 13 Nov 2022 08:45:08 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4CB3B11C2F for ; Sun, 13 Nov 2022 05:45:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=koApI+W0sfq+ceIqZ6uCDWKw0Np+50XdSTd6QYAIKZL7mZ7k70ltoeoW0FHJ+ehCbU3cqvGaiUGphv82lKjVET8OstYcLNfKhwtYCTm+MYRQx16lCGQuz4zYzlyfIQKAVJkWbXkCa9YZrG3vpLao3jmyo8R2iVwOi1LHnAeX5SmHxH2bcE9996LhLWeETNbfvKnK+yoHjpDjoJuraj63Dhjw3cz3Wqikwr4kfzWKiOsRPQI7bNfcvlvO2iNOnm6iiwxQ4fKWgGTmw45oK6odLHyZZz+bJHT1LwihqMMe/KN+J/z9xOYkr/MrCLAnwsDHsiXUJj9rMePy/ME/DkK9Lg== 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=kDOJqcy0OOLQko69+5KPSSZvn1pkDgfG8yrDj23ndCQ=; b=CYQzTlwUp9ETh2AUPUJXfFnEHn4pSxnILyH77IMxAEXN0l7agis/WtnSS55nCtCeqhAcyK5xZje9yg2NCDKKme05ERVLjuLz2a5TWlDWESiacfI1tTOxL3mq2hzvBLOvNESai1G0neZlgmOF5ni8ZhGwz+mWh+UPWDFnzgkqCgEd0dRTwaQz+PECxh2J80+TIQi9Gqu4u4vHbkvXTuij+s9kgx27LP50XYOnkipi8qbBjOLZCtUnC8gMmn0HUgsSK6p/6n4mzRYhDHrt5HlJF+z5q8SJfjB2Kcr9dTUFILygAKa89YJWqbW6mpMBEEtn1qpX/TrNBH7tryijqYn5eg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.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=kDOJqcy0OOLQko69+5KPSSZvn1pkDgfG8yrDj23ndCQ=; b=AGD2e6kJNWEFylgKqbcLMln2xw1CIPVmDXcQbNvmtvpvbHi4OJkJrm1eKdgc7lWEDEexSmyNYDfhd4XFj63fxmg2RyURjRGQO8NyafpndKOYJAV3Yp/YiZzbrkAPl3Bhxex2ctwGfeRFaoiKgD7y9Xmdd9VN6/38Nn65uOzWV9uKqV+7Ke4YUvslNRTVAPnVafP0yNTa9oipSIxfY+ExEWLAWFADrGdVcYAMd8dw2sVn5wwBgt/bK0V8TlygwU2n50b0Qd8+AntgGVobr3TJsvOwkW4TgjHT8mJI1OpMGk0mia5vTiZswysSPmX0OLnk7f70Ju3KQbsJk7SvEe65uw== Received: from MN2PR19CA0015.namprd19.prod.outlook.com (2603:10b6:208:178::28) by DM4PR12MB5963.namprd12.prod.outlook.com (2603:10b6:8:6a::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Sun, 13 Nov 2022 13:45:05 +0000 Received: from BL02EPF0000C408.namprd05.prod.outlook.com (2603:10b6:208:178:cafe::c5) by MN2PR19CA0015.outlook.office365.com (2603:10b6:208:178::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Sun, 13 Nov 2022 13:45:05 +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 BL02EPF0000C408.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Sun, 13 Nov 2022 13:45:05 +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.26; Sun, 13 Nov 2022 05:44:53 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.36; Sun, 13 Nov 2022 05:44:53 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 13 Nov 2022 05:44:51 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 2/7] vdpa/mlx5: Fix wrong mac address deletion Date: Sun, 13 Nov 2022 15:44:37 +0200 Message-ID: <20221113134442.152695-3-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113134442.152695-1-elic@nvidia.com> References: <20221113134442.152695-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C408:EE_|DM4PR12MB5963:EE_ X-MS-Office365-Filtering-Correlation-Id: e602aa8a-77b5-41c9-19cb-08dac57d45b0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: E3iBkS4bYxewvlVbOLri5U5Lr+Wg+EyLQntHO7OLKWW68OdvVJ08adf4Rq8g+hNSm+PIKHvYqgSDLyh6eBHSh5E+/Erv+MAjqv4dxiO1bCrigyvnXVprO2/NeBDa7DTypcOPMeLpd0tbs0Acc/eIw96SqxBYRFBSLG0no0LjuW+hogU+g6d4mk+lWHq5ZR/G+B1GgcKiTEPie3frjI0fWaLguw+VsR24LTk9HNElT1XU16ojWcnEg3k7hg6TStc8IlQGTn2icexm1qKUo86t5QX12Chj7kNaFoUi5LQt5/EEOGfTlGdO6E/HUU/KxhiQXS45vfoYnkUZLYVN3Ih/nfDD61mgJ0/QgxdbZ6c5XX2cfTMty0/1scY29xg8VnEq7Vue1vplv4bmQaMnmy0e0+aiAlabQTYUStBA+Wg+vYEPYiudIsuhgnZdJn3tv3OIgoFI79s5+bBeTB0s4+Ab3Iekca8iVjgMtryzhquG3nB8BE9yczY6Nc/zKsRKs3VAgNjtzVxOlafzk0bR5gLGCoF6JBY0rwJQxaEYKk6jXOso2doFkkBAbK45vnycngHIec6oN+niQ4QziLiX+LIPwRZC0+E8CATP7MAWHo+8ZX9N94yzZoRTXOyBzpysnNni0WKZGL6R1TzV/5cGw02OHJU75c1Y3CcuEQtnALBXktmTEKxA8Q/hhzmyals/IVRdO1YwrB47fIDwNnV3o6CfAkiv6Z6B0Ud/jtzRpaLE20ezRo/FE2tv8wPNXAIsJ7A8T/tDm9OUd+XJ82hX1n2Jew== 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:(13230022)(4636009)(136003)(376002)(39860400002)(396003)(346002)(451199015)(40470700004)(36840700001)(46966006)(8936002)(2906002)(82310400005)(5660300002)(4744005)(36756003)(478600001)(8676002)(110136005)(54906003)(316002)(36860700001)(70206006)(70586007)(26005)(41300700001)(107886003)(4326008)(6666004)(7696005)(86362001)(40480700001)(83380400001)(336012)(426003)(1076003)(2616005)(186003)(356005)(7636003)(40460700003)(47076005)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2022 13:45:05.5067 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e602aa8a-77b5-41c9-19cb-08dac57d45b0 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: BL02EPF0000C408.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5963 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749388920224024491?= X-GMAIL-MSGID: =?utf-8?q?1749388920224024491?= Delete the old MAC from the table and not the new one which is not there yet. Fixes: baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support") Signed-off-by: Eli Cohen Acked-by: Jason Wang --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index ea95081eca0c..c54d5088ed4f 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1686,7 +1686,7 @@ static virtio_net_ctrl_ack handle_ctrl_mac(struct mlx5_vdpa_dev *mvdev, u8 cmd) /* Need recreate the flow table entry, so that the packet could forward back */ - mac_vlan_del(ndev, ndev->config.mac, 0, false); + mac_vlan_del(ndev, mac_back, 0, false); if (mac_vlan_add(ndev, ndev->config.mac, 0, false)) { mlx5_vdpa_warn(mvdev, "failed to insert forward rules, try to restore\n"); From patchwork Sun Nov 13 13:44:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19362 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1686988wru; Sun, 13 Nov 2022 05:49:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7U1NV9yx90AfMIkF1B2iE+hUDt5rVXwN0VXKxWx/0R9SGuoK1Eyaer2YSRj5jhw3VbrMUF X-Received: by 2002:a05:6402:3:b0:461:b2b1:9702 with SMTP id d3-20020a056402000300b00461b2b19702mr7950597edu.274.1668347385389; Sun, 13 Nov 2022 05:49:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668347385; cv=pass; d=google.com; s=arc-20160816; b=HRt1EFXdkp7GoNw+BqZzWP2CUpxvhH4DjgcDbKrMogyWl6PO9ua/Zsfm9aA71OVi19 LTxcfYrrTrxm0zXuUPLneVAknBpYkbjQbtNazl4lbupRhARRFi2wTO2+8xsrzEL2wFSf pay0Igxn97bXncxqxd6es7UbsjEor5sDF7xbC46sJEJdft1ZEzdiIaU8RTn3QVgJ0CqR jjNhen9pIsZy5ul5K2F6c1pfouM7uBOldQjpSTdp4o2M0qZ7+Wt3PKABXdTSzs65rPuN YSpJkWBM98Tcui3wl8WcKucgnvRasKmMUS2U0AgrCHqt5lf6l3N0rH3R4NvCgSzi+d7o S7GQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=vYigdZsLhTrnmCtcVUVkA0cuYfoVK5svzmDlqf2pu2M=; b=g2ChMeXnN6QKpfbDC3O2WjyAeVh1th3C4LLIB2rKzM0vyTS2u72FVztuYPQ3ym99Ob RokPhXD21gzhWWUztoExICGmvkewtrWXUvhyqUje5648HWN7ChV7gl0I8kJGeo6AQTN5 DXMafh4MvS3qgZpgTcuI4zhMF1yFY7O59f/aWJTGcCgbOkBjOem7LLULGMK8WmVwgRqO YNXToi1CBQOPYf5bdLVwDohAyAZJBItl/tufJ8N0WaGJ3BkVsKS25Nc992RDqliWUMUs HDAfKpnS31u75cCaMCncatV0X5sc1pflzT0IYDzZJAs5pXgAJK8yVwS7uFfT5QaVP0+5 WJ+g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=pMAM8ZmX; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id da5-20020a056402176500b004615bae2376si6039555edb.147.2022.11.13.05.49.21; Sun, 13 Nov 2022 05:49:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=pMAM8ZmX; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235380AbiKMNpP (ORCPT + 99 others); Sun, 13 Nov 2022 08:45:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235370AbiKMNpK (ORCPT ); Sun, 13 Nov 2022 08:45:10 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2086.outbound.protection.outlook.com [40.107.93.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B0F512081 for ; Sun, 13 Nov 2022 05:45:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HNU6+FMjdew1sCD+XILGgIqrJQI3aDXASQPPNZ5s8eizJaLcePuFfahhwiLNG0qvGc0WF2S7a5n8tvbff7vw2Znd67DF0RLkZZ+tOmGDK1awBodknWn6FLF77Dp0UBSGEngkD7jZhmeDLdz+OdRmCkHdF7p45vVQdXZSFxGunnAARGUxQl3UMxJuA1Gw3kjJdLRuYp+nyGcaNJkzpRBq97AFwiSO6OiWZ8T7YEvu3+AXII2ghckRmDtQEhJ8gQytelUhqugRoCG7MyaTQkna4YDzgFjULNwi54Y7A/bWcF7CzZnOhPzTWVzF4+9ho1XC1qmRTuZ8E4JM0C4g3W1kyQ== 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=vYigdZsLhTrnmCtcVUVkA0cuYfoVK5svzmDlqf2pu2M=; b=hSudeSjyrcdH478p0jegmA0xK28PnETkH8giLMHwte+CFLjco71gjB38+nClLAj5COI/0OdLg6zyqrLcX028L/zMek7bVjd3FqqzyzodI9AM9A2y7W9twMypn48xv46S5Q49vjkDZmlMXYIEqv6YlYugddpWlTPDGORjbeg1VW2HEJK585t4FYyN6dXaWU9YS1Idwc5YQnW/bqHFwvAancf98qq0kzwFzx4u/mzHEoMCqj0sMOPUPhj07p09ARwz51MR47W9MaehnYG4737rkyJ+33oxbNSjzw5K6EGk9FpPF8+kYvOxkRSRTeJII6oAyz8dvQ0cArq4K0NJ5ZidEg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.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=vYigdZsLhTrnmCtcVUVkA0cuYfoVK5svzmDlqf2pu2M=; b=pMAM8ZmXUJlXO6ML6qgWxDw8HgU0Otc67wZjQLkyGxIR/WMVM3Q2RDtasMIYK6o6H4Lcu7TH4z1IDK0eugqZmDWID6DmZNw9OIwxAQXvo4g1MRIM8ekT/D1TsMlqWRKU5wLUuBqmI5JNVSlaEmQBfaA5V3CMMgqJ2u1F95AgDLMXRTDOfkXAXQD/+F+gd0BVoS8G/8zah6JQZojLzyC5KG98k4+bY6ccqazAPaahqoDwNsyfrnWSpen+g/dZPUiMnj3lUHYmIlw6bLOfdhe3Yy3x7yz7bTTCD+17UCCysRW/rcHXULCTWcmprX3hOs5dcYlpMorYCcEyTCo58yZABA== Received: from MN2PR19CA0011.namprd19.prod.outlook.com (2603:10b6:208:178::24) by DS7PR12MB6070.namprd12.prod.outlook.com (2603:10b6:8:9e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.16; Sun, 13 Nov 2022 13:45:07 +0000 Received: from BL02EPF0000C408.namprd05.prod.outlook.com (2603:10b6:208:178:cafe::b8) by MN2PR19CA0011.outlook.office365.com (2603:10b6:208:178::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.14 via Frontend Transport; Sun, 13 Nov 2022 13:45:07 +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 BL02EPF0000C408.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Sun, 13 Nov 2022 13:45:07 +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.26; Sun, 13 Nov 2022 05:44:56 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.36; Sun, 13 Nov 2022 05:44:56 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 13 Nov 2022 05:44:53 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 3/7] vdpa/mlx5: Move some definitions to a new header file Date: Sun, 13 Nov 2022 15:44:38 +0200 Message-ID: <20221113134442.152695-4-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113134442.152695-1-elic@nvidia.com> References: <20221113134442.152695-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C408:EE_|DS7PR12MB6070:EE_ X-MS-Office365-Filtering-Correlation-Id: a0f4a6c4-1fe5-415d-9ad9-08dac57d46d0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qWH8Br+HbUNGHii6kA9HH38Soa1IbzHlrz4/EMGAMwXW3FYSgVRnY1ybQSKfoRBzukd6MUMahFsCQ9vf0Fk4rsExHrJUaFZGuAyzM462d7U/zYN4Xud0sA5g/DHwSOSkt2Qn7wMfyUztwpECOSGM3oF5cwZuqYl0qXBF7kAXVffcUlRmCJtM74C4PciYAwZiSQsib+LIVvUc52giN5XGUaVjkxh206bilOZ5lTi1Z543f3ieS1cz3EtivxYgmtN2/n17pBr12Vo7jCkr5LH25ml1yz/K5rhNdlzC6XmjVX87qeyg87xMu9hwKk90wo7gbz8j5KsmND0ySSG4shgAjSzYpgA8iRmfJHOisJ1uXARwlgQlCVXElluOWxBbeDsrDbS1XihWZOqHZY5BBIppwVEzX6rAhYylsRKazDeqcK5iEvIFxYDFfnWz7znYxeBU2mMVP1G05gZnYNbsb/199bah4vVKTbH+h93H5sDY5WafY89Bm7nK0WxooFdGHzSKp7sN+BFl9Kq/3PJXHbiB6TlJGhpftNfgbuhHT0Ly79LKfJMz5DpiRXMrnIzhdQFPDBEjK1LRV4Aujb4XY77Ii5zfoYYTr7Lt80ijEdx8/uQpM3iaKiqAMMZZFkCoWuSM/wpMTskM1HgrM0cr0R4c097OeCxrHZSVqUsWqu5bhwfJtVAA8IcBnvMx/tugxzfzp+N9d1bis/q8Qa3EudopRoZCoBuLEx68v42YveZ3Pi2N2hYAU6rBGC01HBGawAcxspyVCy3ftehABArgGKMbug== 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:(13230022)(4636009)(346002)(376002)(136003)(39860400002)(396003)(451199015)(36840700001)(46966006)(40470700004)(41300700001)(47076005)(5660300002)(426003)(336012)(2616005)(1076003)(186003)(8936002)(26005)(7696005)(6666004)(110136005)(478600001)(82740400003)(36756003)(40460700003)(356005)(8676002)(70586007)(7636003)(70206006)(4326008)(107886003)(40480700001)(316002)(54906003)(36860700001)(2906002)(86362001)(82310400005)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2022 13:45:07.3974 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0f4a6c4-1fe5-415d-9ad9-08dac57d46d0 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: BL02EPF0000C408.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB6070 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749389027958533483?= X-GMAIL-MSGID: =?utf-8?q?1749389027958533483?= Move some definitions from mlx5_vnet.c to newly added header file mlx5_vnet.h. We need these definitions for the following patches that add debugfs tree to expose information vital for debug. Reviewed-by: Si-Wei Liu Signed-off-by: Eli Cohen Acked-by: Jason Wang --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 45 +------------------------ drivers/vdpa/mlx5/net/mlx5_vnet.h | 55 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 44 deletions(-) create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.h diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index c54d5088ed4f..e45b83527b41 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -18,15 +18,12 @@ #include #include #include "mlx5_vdpa.h" +#include "mlx5_vnet.h" MODULE_AUTHOR("Eli Cohen "); MODULE_DESCRIPTION("Mellanox VDPA driver"); MODULE_LICENSE("Dual BSD/GPL"); -#define to_mlx5_vdpa_ndev(__mvdev) \ - container_of(__mvdev, struct mlx5_vdpa_net, mvdev) -#define to_mvdev(__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev) - #define VALID_FEATURES_MASK \ (BIT_ULL(VIRTIO_NET_F_CSUM) | BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) | \ BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT_ULL(VIRTIO_NET_F_MTU) | BIT_ULL(VIRTIO_NET_F_MAC) | \ @@ -50,14 +47,6 @@ MODULE_LICENSE("Dual BSD/GPL"); #define MLX5V_UNTAGGED 0x1000 -struct mlx5_vdpa_net_resources { - u32 tisn; - u32 tdn; - u32 tirn; - u32 rqtn; - bool valid; -}; - struct mlx5_vdpa_cq_buf { struct mlx5_frag_buf_ctrl fbc; struct mlx5_frag_buf frag_buf; @@ -146,38 +135,6 @@ static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx) return idx <= mvdev->max_idx; } -#define MLX5V_MACVLAN_SIZE 256 - -struct mlx5_vdpa_net { - struct mlx5_vdpa_dev mvdev; - struct mlx5_vdpa_net_resources res; - struct virtio_net_config config; - struct mlx5_vdpa_virtqueue *vqs; - struct vdpa_callback *event_cbs; - - /* Serialize vq resources creation and destruction. This is required - * since memory map might change and we need to destroy and create - * resources while driver in operational. - */ - struct rw_semaphore reslock; - struct mlx5_flow_table *rxft; - bool setup; - u32 cur_num_vqs; - u32 rqt_size; - bool nb_registered; - struct notifier_block nb; - struct vdpa_callback config_cb; - struct mlx5_vdpa_wq_ent cvq_ent; - struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE]; -}; - -struct macvlan_node { - struct hlist_node hlist; - struct mlx5_flow_handle *ucast_rule; - struct mlx5_flow_handle *mcast_rule; - u64 macvlan; -}; - static void free_resources(struct mlx5_vdpa_net *ndev); static void init_mvqs(struct mlx5_vdpa_net *ndev); static int setup_driver(struct mlx5_vdpa_dev *mvdev); diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.h b/drivers/vdpa/mlx5/net/mlx5_vnet.h new file mode 100644 index 000000000000..6691c879a6ca --- /dev/null +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#ifndef __MLX5_VNET_H__ +#define __MLX5_VNET_H__ + +#include "mlx5_vdpa.h" + +#define to_mlx5_vdpa_ndev(__mvdev) \ + container_of(__mvdev, struct mlx5_vdpa_net, mvdev) +#define to_mvdev(__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev) + +struct mlx5_vdpa_net_resources { + u32 tisn; + u32 tdn; + u32 tirn; + u32 rqtn; + bool valid; +}; + +#define MLX5V_MACVLAN_SIZE 256 + +struct mlx5_vdpa_net { + struct mlx5_vdpa_dev mvdev; + struct mlx5_vdpa_net_resources res; + struct virtio_net_config config; + struct mlx5_vdpa_virtqueue *vqs; + struct vdpa_callback *event_cbs; + + /* Serialize vq resources creation and destruction. This is required + * since memory map might change and we need to destroy and create + * resources while driver in operational. + */ + struct rw_semaphore reslock; + struct mlx5_flow_table *rxft; + struct dentry *rx_dent; + struct dentry *rx_table_dent; + bool setup; + u32 cur_num_vqs; + u32 rqt_size; + bool nb_registered; + struct notifier_block nb; + struct vdpa_callback config_cb; + struct mlx5_vdpa_wq_ent cvq_ent; + struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE]; +}; + +struct macvlan_node { + struct hlist_node hlist; + struct mlx5_flow_handle *ucast_rule; + struct mlx5_flow_handle *mcast_rule; + u64 macvlan; +}; + +#endif /* __MLX5_VNET_H__ */ From patchwork Sun Nov 13 13:44:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19357 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1686454wru; Sun, 13 Nov 2022 05:47:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf5c18SUJHs+wJa1dNY50LuHYwOSiItU84ZZ75kg03qi4rWlT4VMx6MsjMNP0wK/4cz+toi5 X-Received: by 2002:a05:6402:3710:b0:461:9512:ebfd with SMTP id ek16-20020a056402371000b004619512ebfdmr8339296edb.103.1668347265358; Sun, 13 Nov 2022 05:47:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668347265; cv=pass; d=google.com; s=arc-20160816; b=h+Q70ynM598zizbMK+aouDdTDWWMwORapZ/wCfkXrLMYOJGT6SCQmS+51YgSbFeddr hL2OlgpSmMD9z0Y396OxwobvPHpYvtDyjXZlAn77qYmQmLmDChVod2Om9lk3xPzYS1MH O9ZbN9zrPePv1h9JCJa38xm4ou5ITx8mICig4quyft2UwWysjAwVJZVW/sK638gLlTYC BU36vTcE/h7Z/UjIV6DU4zafh/knEvKrPFDlGzVfKTcv6ZjyRoAnwj0XFX1LdPfBvI5V aQN4+neq5s8cJSrES9U3veIKe/IVMLP0TnEoVtQVf4o1na6ZqROCbBpCoevUIYrmrUcp eDzw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=iFPdbLXbxd8Pb0dLS+9Lv/xtvji5z8KdziOO5mlzAPM=; b=tsZOWfy01AaEJK7Xvp3i3dAE+iYNI/CLOoThWu7VzV5h1A8LodgvusFAN2nhj13CvL 828XaTWHgK6nyd4gWcMy8gG905mC/MaZsiMNs/Wl5RFTR6WndfZSRy0x5LG2gJA3/H+0 Op/420ABQuA13Uz18dY4sReo6x5Wtjo6p00GAdwc5kUhwTGW1PthB78D/xkUNt0q6gdR SFEmshJoRpDWPRapnGh24qEpJ1LZ/FM80NGa5pIVGNXSax2w3FXmTms9UT8ONq9dMTKM BGSf/TgVu4+pJ7bUro/7WvHBXmC+a4xVXhbFZx86oB3kco2s6wmuR7W22bICc/94UUIK EsoQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="p/QidDbk"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k16-20020a17090666d000b00787abcb1ce0si6296748ejp.679.2022.11.13.05.47.21; Sun, 13 Nov 2022 05:47:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="p/QidDbk"; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235392AbiKMNpS (ORCPT + 99 others); Sun, 13 Nov 2022 08:45:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235375AbiKMNpM (ORCPT ); Sun, 13 Nov 2022 08:45:12 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2073.outbound.protection.outlook.com [40.107.223.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AEAAD1260C for ; Sun, 13 Nov 2022 05:45:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RRbq9+OrNPi/1JeCAVTxLwUwrmEhdVjasWZJyJOg0fX1AHGaruY4eVPMokVY3jFFDif9qfS7/Jpme6H9j6lFONFR/xkFQGFKhdXDwsJLrguLiBeWf4512oBFLHH2j/jcrOb1DsJ9IhGL7vRvf/80Pbfc76iJH5QTLi85odkvDa8Dcxcxara2XyNeUQXELAq8r/lzKnNZpKLXy6Fb7FQFG1DiNz9Ed9aSA5bWEp20pkuXNPvObS/snnABuREMZ6BtfvnBWvaVMcJob/+doWQ7Z0c54/Gs8nh2fpDd2AfGYzZztGghiMxOq7qpTzWFsRMCNQZUdgpM3WTVFPhCUKOJ8w== 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=iFPdbLXbxd8Pb0dLS+9Lv/xtvji5z8KdziOO5mlzAPM=; b=J1gWWQplDrVXff8lNpSbiuj9ZFwzLviYNsW6X8S6adEeFdOMoMtYukZTkvMWK24JqHdYHlBz0q8cHrnWX4PY+RikXER2MSvkO3ZRj6PDaaxkt3qtpJuwvMiqnQs7ErGNmVoApofNlqjgvm/dl+1qGdSnii+KDL76yP/cJ1nwFQZxzZ2NHPqAaDI2gTDOY19RIILDnBKnLhtP20bLkY0BJTocACnOPRSN5PilArOPcefwlwkFcSgy4h6hOq0UqZROUEQsGPCRVn10fuGxIkUbku91OJPnOuJYcMYyarL/pajqZrQONNFTmDEMCxZAStySDYhrjjmeR4Jpz9iT+rvtuA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.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=iFPdbLXbxd8Pb0dLS+9Lv/xtvji5z8KdziOO5mlzAPM=; b=p/QidDbkfGC3hTudaYeC2d7EqKoL4R8dC9lpLFd9sGqQbSs2eeyGH9Ge9/E6CFSQjyCp6BMcSmZO3GUvOYL8c5I2jmuAQ3sLcbc5DT032q8e61zAlSyOMJcHfVkoiNk8aSlBvW7r5EkLrSLPOb7zgS37YDa6LyulnEIV9eC0epv6OSbKpjmuiSkAZi1C9x4RgJasDBjTPNORfqmIP+Fp6/0WUuJuQ0Lmi162kCyUxKG1ywkboowfods+suqHrDpg2GZJvnbE5FgqycDuuNtFGyydnAbH+M7abtHbY3DTPrlXIHIXClN8D+JdeydGtKwzJW/CyRGjk5Yi2sG9jKmkTA== Received: from MN2PR19CA0011.namprd19.prod.outlook.com (2603:10b6:208:178::24) by MN2PR12MB4047.namprd12.prod.outlook.com (2603:10b6:208:1de::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Sun, 13 Nov 2022 13:45:09 +0000 Received: from BL02EPF0000C408.namprd05.prod.outlook.com (2603:10b6:208:178:cafe::b8) by MN2PR19CA0011.outlook.office365.com (2603:10b6:208:178::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.14 via Frontend Transport; Sun, 13 Nov 2022 13:45:09 +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 BL02EPF0000C408.mail.protection.outlook.com (10.167.241.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Sun, 13 Nov 2022 13:45:09 +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.26; Sun, 13 Nov 2022 05:44:59 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.36; Sun, 13 Nov 2022 05:44:58 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 13 Nov 2022 05:44:56 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 4/7] vdpa/mlx5: Add debugfs subtree Date: Sun, 13 Nov 2022 15:44:39 +0200 Message-ID: <20221113134442.152695-5-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113134442.152695-1-elic@nvidia.com> References: <20221113134442.152695-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C408:EE_|MN2PR12MB4047:EE_ X-MS-Office365-Filtering-Correlation-Id: bf120d14-d24a-4a8a-d772-08dac57d4814 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xx2VRwxHKx/0zlKocaruNnPEkUi/7WG8wnd2mH8M4GBE0Qym45WqjPK8gPfep35WbVolp4kbmd45cTXw3GkUzgZMv2Z8xBV7vPcQO6WTh1qohqxDNxOApllbQ2SdgGjvUppzm4an1CfApwTlfTCdA5p4UhJSeecUsxif9E0T1zkytsHjyhWrciUR7X4J16MNSnJPtztYS8br6BEDrLJyWwWJYuC55FpGhLQ7nkeAez3BxnjEG4TYEmi6xKf+x8HmhEtTd3ZnzxnAAe8komH4RhuX04VlSjVKRqrvGsVSS8DppLLEXwSQnlrhp0m5VOzxiPN6v2gIuUNDi3s6VlHKvtOW+A3yxnGOK6hGQGX1zmK3jOrYq0cuEmyC3d6amGX8OpJJnj2i57zRHg5YxkB4MTQHcavdqBZVZhHqHlInvBY3OwpMmNDPLt0PMgjmn2AhL3HY28OPPz3uhRiMu9jdlIISzmpcgJCPdUVWXRz63ekAbI7NblS4B6TKFk+XXKUvPNeE8kAzHcpDLNq+Fw+fejzvg7mVdcNYVfpSfjmlSMYiQFJbhVsPXdkWAJATRv8ldYf+5GTKd4JyuA24zJASJVhxem2mP1GAr7aqSMXs4R4aABNoHRnQT40SEfLklwYx5lb5ucMbzMpJSqlnx1Veu816OWVM7TTSttSFHocZZ5kRbw29Wh24szD/Z46pl5yfqRorTgiFmySfTrfrX8W9tDZhHE6W8SYr78hLz4vy9hh5FwbZwsFR0y8Lw1QB+Xz1e5hZNwT7FNf+IqxJ7Nkyhg== 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:(13230022)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(82310400005)(40480700001)(36756003)(1076003)(186003)(82740400003)(2616005)(336012)(83380400001)(26005)(86362001)(8936002)(41300700001)(5660300002)(2906002)(478600001)(356005)(7636003)(36860700001)(40460700003)(110136005)(426003)(47076005)(316002)(107886003)(6666004)(7696005)(4326008)(8676002)(54906003)(70586007)(70206006);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2022 13:45:09.5225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf120d14-d24a-4a8a-d772-08dac57d4814 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: BL02EPF0000C408.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4047 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749388901896337322?= X-GMAIL-MSGID: =?utf-8?q?1749388901896337322?= Add debugfs subtree and expose flow table ID and TIR number. This information can be used by external tools to do extended troubleshooting. The information can be retrieved like so: $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/table_id $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/tirn Reviewed-by: Si-Wei Liu Signed-off-by: Eli Cohen Acked-by: Jason Wang --- drivers/vdpa/mlx5/Makefile | 2 +- drivers/vdpa/mlx5/net/debug.c | 66 +++++++++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 11 ++++++ drivers/vdpa/mlx5/net/mlx5_vnet.h | 9 +++++ 4 files changed, 87 insertions(+), 1 deletion(-) create mode 100644 drivers/vdpa/mlx5/net/debug.c diff --git a/drivers/vdpa/mlx5/Makefile b/drivers/vdpa/mlx5/Makefile index f717978c83bf..e791394c33e3 100644 --- a/drivers/vdpa/mlx5/Makefile +++ b/drivers/vdpa/mlx5/Makefile @@ -1,4 +1,4 @@ subdir-ccflags-y += -I$(srctree)/drivers/vdpa/mlx5/core obj-$(CONFIG_MLX5_VDPA_NET) += mlx5_vdpa.o -mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o +mlx5_vdpa-$(CONFIG_MLX5_VDPA_NET) += net/mlx5_vnet.o core/resources.o core/mr.o net/debug.o diff --git a/drivers/vdpa/mlx5/net/debug.c b/drivers/vdpa/mlx5/net/debug.c new file mode 100644 index 000000000000..95e4801df211 --- /dev/null +++ b/drivers/vdpa/mlx5/net/debug.c @@ -0,0 +1,66 @@ +// SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#include +#include +#include "mlx5_vnet.h" + +static int tirn_show(struct seq_file *file, void *priv) +{ + struct mlx5_vdpa_net *ndev = file->private; + + seq_printf(file, "0x%x\n", ndev->res.tirn); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(tirn); + +void mlx5_vdpa_remove_tirn(struct mlx5_vdpa_net *ndev) +{ + if (ndev->debugfs) + debugfs_remove(ndev->res.tirn_dent); +} + +void mlx5_vdpa_add_tirn(struct mlx5_vdpa_net *ndev) +{ + ndev->res.tirn_dent = debugfs_create_file("tirn", 0444, ndev->rx_dent, + ndev, &tirn_fops); +} + +static int rx_flow_table_show(struct seq_file *file, void *priv) +{ + struct mlx5_vdpa_net *ndev = file->private; + + seq_printf(file, "0x%x\n", mlx5_flow_table_id(ndev->rxft)); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(rx_flow_table); + +void mlx5_vdpa_remove_rx_flow_table(struct mlx5_vdpa_net *ndev) +{ + if (ndev->debugfs) + debugfs_remove(ndev->rx_table_dent); +} + +void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev) +{ + ndev->rx_table_dent = debugfs_create_file("table_id", 0444, ndev->rx_dent, + ndev, &rx_flow_table_fops); +} + +void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev) +{ + struct mlx5_core_dev *mdev; + + mdev = ndev->mvdev.mdev; + ndev->debugfs = debugfs_create_dir(dev_name(&ndev->mvdev.vdev.dev), + mlx5_debugfs_get_dev_root(mdev)); + if (!IS_ERR(ndev->debugfs)) + ndev->rx_dent = debugfs_create_dir("rx", ndev->debugfs); +} + +void mlx5_vdpa_remove_debugfs(struct dentry *dbg) +{ + debugfs_remove_recursive(dbg); +} diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index e45b83527b41..ce2f478a93f5 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1388,11 +1388,16 @@ static int create_tir(struct mlx5_vdpa_net *ndev) err = mlx5_vdpa_create_tir(&ndev->mvdev, in, &ndev->res.tirn); kfree(in); + if (err) + return err; + + mlx5_vdpa_add_tirn(ndev); return err; } static void destroy_tir(struct mlx5_vdpa_net *ndev) { + mlx5_vdpa_remove_tirn(ndev); mlx5_vdpa_destroy_tir(&ndev->mvdev, ndev->res.tirn); } @@ -1578,6 +1583,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev) mlx5_vdpa_warn(&ndev->mvdev, "failed to create flow table\n"); return PTR_ERR(ndev->rxft); } + mlx5_vdpa_add_rx_flow_table(ndev); err = mac_vlan_add(ndev, ndev->config.mac, 0, false); if (err) @@ -1586,6 +1592,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev) return 0; err_add: + mlx5_vdpa_remove_rx_flow_table(ndev); mlx5_destroy_flow_table(ndev->rxft); return err; } @@ -1593,6 +1600,7 @@ static int setup_steering(struct mlx5_vdpa_net *ndev) static void teardown_steering(struct mlx5_vdpa_net *ndev) { clear_mac_vlan_table(ndev); + mlx5_vdpa_remove_rx_flow_table(ndev); mlx5_destroy_flow_table(ndev->rxft); } @@ -3172,6 +3180,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, if (err) goto err_reg; + mlx5_vdpa_add_debugfs(ndev); mgtdev->ndev = ndev; return 0; @@ -3198,6 +3207,8 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); struct workqueue_struct *wq; + mlx5_vdpa_remove_debugfs(ndev->debugfs); + ndev->debugfs = NULL; if (ndev->nb_registered) { mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); ndev->nb_registered = false; diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.h b/drivers/vdpa/mlx5/net/mlx5_vnet.h index 6691c879a6ca..f2cef3925e5b 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.h +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.h @@ -16,6 +16,7 @@ struct mlx5_vdpa_net_resources { u32 tirn; u32 rqtn; bool valid; + struct dentry *tirn_dent; }; #define MLX5V_MACVLAN_SIZE 256 @@ -43,6 +44,7 @@ struct mlx5_vdpa_net { struct vdpa_callback config_cb; struct mlx5_vdpa_wq_ent cvq_ent; struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE]; + struct dentry *debugfs; }; struct macvlan_node { @@ -52,4 +54,11 @@ struct macvlan_node { u64 macvlan; }; +void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_debugfs(struct dentry *dbg); +void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_rx_flow_table(struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_add_tirn(struct mlx5_vdpa_net *ndev); +void mlx5_vdpa_remove_tirn(struct mlx5_vdpa_net *ndev); + #endif /* __MLX5_VNET_H__ */ From patchwork Sun Nov 13 13:44:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19363 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1687116wru; Sun, 13 Nov 2022 05:50:05 -0800 (PST) X-Google-Smtp-Source: AA0mqf4C5PLoCj1AYX0V+B4oq2VWsbixCrzaKADJKJvjTaTe/xmo5oqH7AiiJDL8yayuIbBIpzKC X-Received: by 2002:a17:906:fb96:b0:7ad:dcf7:c4f with SMTP id lr22-20020a170906fb9600b007addcf70c4fmr7615280ejb.631.1668347405621; Sun, 13 Nov 2022 05:50:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668347405; cv=pass; d=google.com; s=arc-20160816; b=GTOpkpaRcsAgbuRSV3Mz8pwUuCswY77pUn2r+2HYN8dTMkS9DenrN+FPiUzthDy2XT 6O4cV4ejdtuLJXrFZfTZrr7yGcpZzQK1BFyHpbCn73erJUOEs5Phra56EzDYe1cVPRAm pPSKQ6mTevxCCFtegORHaapVhr7rSSyuIIn4fHiduu7DKAKauXkjGnEneXi75somTpr8 E/h7UTRFpOgTxMMfyBJUIaW4fVBtcBxV804Ez1B/cmH0uObhczUaRFyMXiv5WMeXWLs5 PRerudeKF8xrtqJZWBg9zHSBBQZi44maLYikpXKewOIfaCbpNg0UDYU8+a0sclTNzAA7 P9hA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=VwGJsXFTQHXSvdkXGXxGIfBK/nbeylSdILWJjYlVRys=; b=FTrSDM8xCMGfwzVHWyYZ5t66AEXeXk3Mc2Q67sRMhCu+viyf52+1GrlvVBQT2GFgxk GzuiFgs8iB04cBf8n05cAksRaK23cIabPRQhdRLxllwhPRajKDqmJnsNYjadPNiv+yCS 8k9xQ5E/GDEQZkAG3M+ZULf5tEffVOz5yltykUP9IfnY/y30pbmVPeflPIgtGJcJkfy3 MiBZCUe58IzZQ5xx8ywtGwtJk+xm4JYQr0VNLBipvsh3GsMD6xue6AfVnngEJ5IfeyAZ uTexzBwPuFJ7Ilf1y06MZSdDZ2itZbEr2Uu40YsNSAyLf8LtBg/fglOV+hcuTG6qpXWj FIzQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=UUeYeZEJ; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y25-20020aa7ccd9000000b0046400f454a3si6765928edt.125.2022.11.13.05.49.41; Sun, 13 Nov 2022 05:50:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=UUeYeZEJ; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235437AbiKMNpf (ORCPT + 99 others); Sun, 13 Nov 2022 08:45:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235405AbiKMNp1 (ORCPT ); Sun, 13 Nov 2022 08:45:27 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2075.outbound.protection.outlook.com [40.107.244.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A825812ACF for ; Sun, 13 Nov 2022 05:45:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oMeRTjHD3dw7KqZrms/JBm/UEO51U5DFqfQ6HR2BMPkC302J0kTohv/l5InVpOnilZXahWIW39FUSSNiczRamz4T5w63FQ8AAMyYrsmDfVNREWTzJxuh67jMGMKtWHTbBPVpwyUlVJuii6h/THtYDEFpL+jSYNL3nnnw0mXfGoo56X+cH379lnDBjlXSAt303t5LYmpeN/nPAiZBDyFGNdz+LCIOV0I5QpPf+Nj8f44rEorCaFUYh0WWVYKkjZ3fl15ib3eMxlbCSF5Dw8P4VWDXjLXvi9eOgC23F0KWRKkyJYH1Wg6yws0qq7Vh6ZsYrOH/Q7s/IKqQYSia1ffumw== 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=VwGJsXFTQHXSvdkXGXxGIfBK/nbeylSdILWJjYlVRys=; b=dqn3fOxK6uqknXWEVNGeckbj3Hi1h5OkkMKh72i0d7wDesmzx5b9kZuXahXHfX60pJ/S4XQduGNF/4bnwuXHyCw/AMoXdRVmQfqK3vYEyABYmh2+d6N623NwfHixxErWGUWg74HxnDOkfRiVPZ16E7dprbvzD95Lp0y3bgQIGBfvlouBhORhti8B6k74M3fLT60pAvbEjL2KmsepX0bKWxfh9f/tgE264fIU8p6DsIbiH66LV2G+nrTZlQ7sJoso6r6qetXejn4ChDcBpj5FjdhYew17+7PouCIaJh315O/cvd/aAqYWZqiNForXRpUH8to87VRGsuBrSVKxp+69rQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.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=VwGJsXFTQHXSvdkXGXxGIfBK/nbeylSdILWJjYlVRys=; b=UUeYeZEJbiUwKTT4N8jGDkrmNFmuLG3fuq/OOc5Rl2W8um8B62h2I2VC1xYvf2ZXb8cPAO/mocdcOmstNYgK2n1ClNP7U6pdTOZqHGoArAUnWjsazMdG0V04Ua5/SDq/tgc+fWwsyiiqheavjEUqKuW0bJu1prcl2H//WfaHQb3BjnquaT3ZH7NZFNP3b+Cz5Gk+KztvgEK5r4LNdme6G9yzAv7SLCWcSFrmAqP7QWzv3eAouq282HaovpJfhKK+VbjzldFNJk7ixofEoI6FakvOWfqhYxlX9uenyum7vHk4WOT9SaIEeXzl8tljjoBgWEtkijT5GIyvJfEBuavwDg== Received: from BN9PR03CA0905.namprd03.prod.outlook.com (2603:10b6:408:107::10) by MW3PR12MB4554.namprd12.prod.outlook.com (2603:10b6:303:55::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Sun, 13 Nov 2022 13:45:15 +0000 Received: from BL02EPF0000C407.namprd05.prod.outlook.com (2603:10b6:408:107:cafe::58) by BN9PR03CA0905.outlook.office365.com (2603:10b6:408:107::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Sun, 13 Nov 2022 13:45:15 +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 BL02EPF0000C407.mail.protection.outlook.com (10.167.241.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Sun, 13 Nov 2022 13:45:14 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) 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.26; Sun, 13 Nov 2022 05:45:02 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.36; Sun, 13 Nov 2022 05:45:01 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 13 Nov 2022 05:44:59 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 5/7] vdpa/mlx5: Add RX counters to debugfs Date: Sun, 13 Nov 2022 15:44:40 +0200 Message-ID: <20221113134442.152695-6-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113134442.152695-1-elic@nvidia.com> References: <20221113134442.152695-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C407:EE_|MW3PR12MB4554:EE_ X-MS-Office365-Filtering-Correlation-Id: 8984d7f4-aefa-414c-b16d-08dac57d4b44 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: s1WQatFwR/fGQjoVMfJ+AWgO3Neqo7g+c83egskQ+9Gz4EA51AWNPUE860npzrqAOy/xJldlynNq357bJcj+FZljg0JtkWpwgNHvZ8+zMd5kP36mE7QVmxijBzaGwsTebQYwCdfbsRsYzbGesCiOwLqqxJjWy1pMtswN93jKiENkLPO6TSQztBuRIhzB2dff72EpHws59+BkfLGq0voLaRLQeAZ3aI0poE6vPjFIQFq8vwXJtSNXrspJDv0ow8biv6Bu3XziminZp0VnzHPy/L5QYbHLE5GKbiezb4mLN/n42VSUHYShV8oh5u+APVmJGP7cB81kE3TiLHr+RUxGFr0nt9L4UimlikKnAi3YMVz3wHobQMICAcGh4RaGIggpzNgBmeFqo0mHADVyhEJOTdhvZ0SGCzocCDBdjG+65z9euB3DDkxAbeAqTwvcQ649buFd8L8aNpC54w9Ozn/etTXZe8nLRxHo/UDhBcAlwxdZkjLonkJyp5PpeeeqPMN7oaWETuJYPAyTbl4Q7bqHUSWHV5+DyiQpdqnbj2JRbRwIHsICY3MKKK3VuU1hSMManf2udGXuu+sJyxT9K7krY9kBAku7noMNYY/xddmNEkkAkt+M84Tb8mmHokiLKhCVyGlqBqhdicdlSkB+C54qEU3yxsXc0Vbvwm2mp6j9e4R5KiuaOt6wnXLEaeCxZgpm0JU386FJ12R85Qedm1p1ZB9ZibAdIoPdfJH49kG0vd7KHPMAmpJL8hQJ/BxbUotyHH+oKm4APofpDnrWbUH7PKq7NBNU8PPw8XfHBEmxY8Q= 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:(13230022)(4636009)(346002)(136003)(376002)(39860400002)(396003)(451199015)(40470700004)(46966006)(36840700001)(7696005)(86362001)(6666004)(107886003)(2906002)(478600001)(26005)(5660300002)(30864003)(82310400005)(41300700001)(40480700001)(36860700001)(70206006)(4326008)(8676002)(70586007)(336012)(1076003)(2616005)(426003)(47076005)(186003)(110136005)(40460700003)(356005)(7636003)(83380400001)(82740400003)(8936002)(54906003)(316002)(36756003)(290074003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2022 13:45:14.8692 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8984d7f4-aefa-414c-b16d-08dac57d4b44 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: BL02EPF0000C407.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4554 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749389049262890217?= X-GMAIL-MSGID: =?utf-8?q?1749389049262890217?= For each interface, either VLAN tagged or untagged, add two hardware counters: one for unicast and another for multicast. The counters count RX packets and bytes and can be read through debugfs: $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/mcast/packets $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/ucast/bytes This feature is controlled via the config option MLX5_VDPA_STEERING_DEBUG. It is off by default as it may have some impact on performance. Signed-off-by: Eli Cohen --- drivers/vdpa/Kconfig | 12 +++ drivers/vdpa/mlx5/net/debug.c | 86 ++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 118 +++++++++++++++++++++++------- drivers/vdpa/mlx5/net/mlx5_vnet.h | 30 ++++++++ 4 files changed, 218 insertions(+), 28 deletions(-) diff --git a/drivers/vdpa/Kconfig b/drivers/vdpa/Kconfig index 50f45d037611..43b716ec2d18 100644 --- a/drivers/vdpa/Kconfig +++ b/drivers/vdpa/Kconfig @@ -71,6 +71,18 @@ config MLX5_VDPA_NET be executed by the hardware. It also supports a variety of stateless offloads depending on the actual device used and firmware version. +config MLX5_VDPA_STEERING_DEBUG + bool "expose steering counters on debugfs" + select MLX5_VDPA + help + Expose RX steering counters in debugfs to aid in debugging. For each VLAN + or non VLAN interface, two hardware counters are added to the RX flow + table: one for unicast and one for multicast. + The counters counts the number of packets and bytes and exposes them in + debugfs. Once can read the counters using, e.g.: + cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/ucast/packets + cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/mcast/bytes + config VP_VDPA tristate "Virtio PCI bridge vDPA driver" select VIRTIO_PCI_LIB diff --git a/drivers/vdpa/mlx5/net/debug.c b/drivers/vdpa/mlx5/net/debug.c index 95e4801df211..60d6ac68cdc4 100644 --- a/drivers/vdpa/mlx5/net/debug.c +++ b/drivers/vdpa/mlx5/net/debug.c @@ -49,6 +49,92 @@ void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev) ndev, &rx_flow_table_fops); } +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) +static int packets_show(struct seq_file *file, void *priv) +{ + struct mlx5_vdpa_counter *counter = file->private; + u64 packets; + u64 bytes; + int err; + + err = mlx5_fc_query(counter->mdev, counter->counter, &packets, &bytes); + if (err) + return err; + + seq_printf(file, "0x%llx\n", packets); + return 0; +} + +static int bytes_show(struct seq_file *file, void *priv) +{ + struct mlx5_vdpa_counter *counter = file->private; + u64 packets; + u64 bytes; + int err; + + err = mlx5_fc_query(counter->mdev, counter->counter, &packets, &bytes); + if (err) + return err; + + seq_printf(file, "0x%llx\n", bytes); + return 0; +} + +DEFINE_SHOW_ATTRIBUTE(packets); +DEFINE_SHOW_ATTRIBUTE(bytes); + +static void add_counter_node(struct mlx5_vdpa_counter *counter, + struct dentry *parent) +{ + debugfs_create_file("packets", 0444, parent, counter, + &packets_fops); + debugfs_create_file("bytes", 0444, parent, counter, + &bytes_fops); +} + +void mlx5_vdpa_add_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node) +{ + static const char *ut = "untagged"; + char vidstr[9]; + u16 vid; + + node->ucast_counter.mdev = ndev->mvdev.mdev; + node->mcast_counter.mdev = ndev->mvdev.mdev; + if (node->tagged) { + vid = key2vid(node->macvlan); + snprintf(vidstr, sizeof(vidstr), "0x%x", vid); + } else { + strcpy(vidstr, ut); + } + + node->dent = debugfs_create_dir(vidstr, ndev->rx_dent); + if (IS_ERR(node->dent)) { + node->dent = NULL; + return; + } + + node->ucast_counter.dent = debugfs_create_dir("ucast", node->dent); + if (IS_ERR(node->ucast_counter.dent)) + return; + + add_counter_node(&node->ucast_counter, node->ucast_counter.dent); + + node->mcast_counter.dent = debugfs_create_dir("mcast", node->dent); + if (IS_ERR(node->mcast_counter.dent)) + return; + + add_counter_node(&node->mcast_counter, node->mcast_counter.dent); +} + +void mlx5_vdpa_remove_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node) +{ + if (node->dent && ndev->debugfs) + debugfs_remove_recursive(node->dent); +} +#endif + void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev) { struct mlx5_core_dev *mdev; diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index ce2f478a93f5..6e6490c85be2 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1404,12 +1404,55 @@ static void destroy_tir(struct mlx5_vdpa_net *ndev) #define MAX_STEERING_ENT 0x8000 #define MAX_STEERING_GROUPS 2 +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + #define NUM_DESTS 2 +#else + #define NUM_DESTS 1 +#endif + +static int add_steering_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node, + struct mlx5_flow_act *flow_act, + struct mlx5_flow_destination *dests) +{ +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + int err; + + node->ucast_counter.counter = mlx5_fc_create(ndev->mvdev.mdev, false); + if (IS_ERR(node->ucast_counter.counter)) + return PTR_ERR(node->ucast_counter.counter); + + node->mcast_counter.counter = mlx5_fc_create(ndev->mvdev.mdev, false); + if (IS_ERR(node->mcast_counter.counter)) { + err = PTR_ERR(node->mcast_counter.counter); + goto err_mcast_counter; + } + + dests[1].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER; + flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; + return 0; + +err_mcast_counter: + mlx5_fc_destroy(ndev->mvdev.mdev, node->ucast_counter.counter); + return err; +#else + return 0; +#endif +} + +static void remove_steering_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node) +{ +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + mlx5_fc_destroy(ndev->mvdev.mdev, node->mcast_counter.counter); + mlx5_fc_destroy(ndev->mvdev.mdev, node->ucast_counter.counter); +#endif +} + static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, - u16 vid, bool tagged, - struct mlx5_flow_handle **ucast, - struct mlx5_flow_handle **mcast) + struct macvlan_node *node) { - struct mlx5_flow_destination dest = {}; + struct mlx5_flow_destination dests[NUM_DESTS] = {}; struct mlx5_flow_act flow_act = {}; struct mlx5_flow_handle *rule; struct mlx5_flow_spec *spec; @@ -1418,11 +1461,13 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, u8 *dmac_c; u8 *dmac_v; int err; + u16 vid; spec = kvzalloc(sizeof(*spec), GFP_KERNEL); if (!spec) return -ENOMEM; + vid = key2vid(node->macvlan); spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS; headers_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria, outer_headers); headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, outer_headers); @@ -1430,48 +1475,62 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, dmac_v = MLX5_ADDR_OF(fte_match_param, headers_v, outer_headers.dmac_47_16); eth_broadcast_addr(dmac_c); ether_addr_copy(dmac_v, mac); - if (ndev->mvdev.actual_features & VIRTIO_NET_F_CTRL_VLAN) { + if (ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VLAN)) { MLX5_SET(fte_match_set_lyr_2_4, headers_c, cvlan_tag, 1); MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, first_vid); } - if (tagged) { + if (node->tagged) { MLX5_SET(fte_match_set_lyr_2_4, headers_v, cvlan_tag, 1); MLX5_SET(fte_match_set_lyr_2_4, headers_v, first_vid, vid); } flow_act.action = MLX5_FLOW_CONTEXT_ACTION_FWD_DEST; - dest.type = MLX5_FLOW_DESTINATION_TYPE_TIR; - dest.tir_num = ndev->res.tirn; - rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, &dest, 1); - if (IS_ERR(rule)) - return PTR_ERR(rule); + dests[0].type = MLX5_FLOW_DESTINATION_TYPE_TIR; + dests[0].tir_num = ndev->res.tirn; + err = add_steering_counters(ndev, node, &flow_act, dests); + if (err) + goto out_free; + +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + dests[1].counter_id = mlx5_fc_id(node->ucast_counter.counter); +#endif + node->ucast_rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, dests, NUM_DESTS); + if (IS_ERR(rule)) { + err = PTR_ERR(rule); + goto err_ucast; + } - *ucast = rule; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + dests[1].counter_id = mlx5_fc_id(node->mcast_counter.counter); +#endif memset(dmac_c, 0, ETH_ALEN); memset(dmac_v, 0, ETH_ALEN); dmac_c[0] = 1; dmac_v[0] = 1; - rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, &dest, 1); - kvfree(spec); + node->mcast_rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, dests, NUM_DESTS); if (IS_ERR(rule)) { err = PTR_ERR(rule); goto err_mcast; } - - *mcast = rule; + kvfree(spec); + mlx5_vdpa_add_rx_counters(ndev, node); return 0; err_mcast: - mlx5_del_flow_rules(*ucast); + mlx5_del_flow_rules(node->ucast_rule); +err_ucast: + remove_steering_counters(ndev, node); +out_free: + kvfree(spec); return err; } static void mlx5_vdpa_del_mac_vlan_rules(struct mlx5_vdpa_net *ndev, - struct mlx5_flow_handle *ucast, - struct mlx5_flow_handle *mcast) + struct macvlan_node *node) { - mlx5_del_flow_rules(ucast); - mlx5_del_flow_rules(mcast); + mlx5_vdpa_remove_rx_counters(ndev, node); + mlx5_del_flow_rules(node->ucast_rule); + mlx5_del_flow_rules(node->mcast_rule); } static u64 search_val(u8 *mac, u16 vlan, bool tagged) @@ -1505,14 +1564,14 @@ static struct macvlan_node *mac_vlan_lookup(struct mlx5_vdpa_net *ndev, u64 valu return NULL; } -static int mac_vlan_add(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vlan, bool tagged) // vlan -> vid +static int mac_vlan_add(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vid, bool tagged) { struct macvlan_node *ptr; u64 val; u32 idx; int err; - val = search_val(mac, vlan, tagged); + val = search_val(mac, vid, tagged); if (mac_vlan_lookup(ndev, val)) return -EEXIST; @@ -1520,12 +1579,13 @@ static int mac_vlan_add(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vlan, bool tagg if (!ptr) return -ENOMEM; - err = mlx5_vdpa_add_mac_vlan_rules(ndev, ndev->config.mac, vlan, tagged, - &ptr->ucast_rule, &ptr->mcast_rule); + ptr->tagged = tagged; + ptr->macvlan = val; + ptr->ndev = ndev; + err = mlx5_vdpa_add_mac_vlan_rules(ndev, ndev->config.mac, ptr); if (err) goto err_add; - ptr->macvlan = val; idx = hash_64(val, 8); hlist_add_head(&ptr->hlist, &ndev->macvlan_hash[idx]); return 0; @@ -1544,7 +1604,8 @@ static void mac_vlan_del(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vlan, bool tag return; hlist_del(&ptr->hlist); - mlx5_vdpa_del_mac_vlan_rules(ndev, ptr->ucast_rule, ptr->mcast_rule); + mlx5_vdpa_del_mac_vlan_rules(ndev, ptr); + remove_steering_counters(ndev, ptr); kfree(ptr); } @@ -1557,7 +1618,8 @@ static void clear_mac_vlan_table(struct mlx5_vdpa_net *ndev) for (i = 0; i < MLX5V_MACVLAN_SIZE; i++) { hlist_for_each_entry_safe(pos, n, &ndev->macvlan_hash[i], hlist) { hlist_del(&pos->hlist); - mlx5_vdpa_del_mac_vlan_rules(ndev, pos->ucast_rule, pos->mcast_rule); + mlx5_vdpa_del_mac_vlan_rules(ndev, pos); + remove_steering_counters(ndev, pos); kfree(pos); } } diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.h b/drivers/vdpa/mlx5/net/mlx5_vnet.h index f2cef3925e5b..c90a89e1de4d 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.h +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.h @@ -21,6 +21,11 @@ struct mlx5_vdpa_net_resources { #define MLX5V_MACVLAN_SIZE 256 +static inline u16 key2vid(u64 key) +{ + return (u16)(key >> 48) & 0xfff; +} + struct mlx5_vdpa_net { struct mlx5_vdpa_dev mvdev; struct mlx5_vdpa_net_resources res; @@ -47,11 +52,24 @@ struct mlx5_vdpa_net { struct dentry *debugfs; }; +struct mlx5_vdpa_counter { + struct mlx5_fc *counter; + struct dentry *dent; + struct mlx5_core_dev *mdev; +}; + struct macvlan_node { struct hlist_node hlist; struct mlx5_flow_handle *ucast_rule; struct mlx5_flow_handle *mcast_rule; u64 macvlan; + struct mlx5_vdpa_net *ndev; + bool tagged; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + struct dentry *dent; + struct mlx5_vdpa_counter ucast_counter; + struct mlx5_vdpa_counter mcast_counter; +#endif }; void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev); @@ -60,5 +78,17 @@ void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev); void mlx5_vdpa_remove_rx_flow_table(struct mlx5_vdpa_net *ndev); void mlx5_vdpa_add_tirn(struct mlx5_vdpa_net *ndev); void mlx5_vdpa_remove_tirn(struct mlx5_vdpa_net *ndev); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) +void mlx5_vdpa_add_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node); +void mlx5_vdpa_remove_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node); +#else +static inline void mlx5_vdpa_add_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node) {} +static inline void mlx5_vdpa_remove_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node) {} +#endif + #endif /* __MLX5_VNET_H__ */ From patchwork Sun Nov 13 13:44:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19360 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1686703wru; Sun, 13 Nov 2022 05:48:35 -0800 (PST) X-Google-Smtp-Source: AA0mqf70W+YKCKypJAbDs2Mbej3SJwUCOykDOnxxaZQJiqmKqhDnNoQD8ZK4kYECGZHTVF/9AVOY X-Received: by 2002:a05:6402:380f:b0:45a:3c66:b0e4 with SMTP id es15-20020a056402380f00b0045a3c66b0e4mr8220708edb.33.1668347315098; Sun, 13 Nov 2022 05:48:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668347315; cv=pass; d=google.com; s=arc-20160816; b=VYTSZ9YO3u6AFKXeqLBiiKoMALFnLkAnyetvuSGACuO3OR2VE98ejUrS558LEAYZed 71wk6p6L+6AWaFZhCuiUsOrzDHD4Z4KGzz8A6YmTbX9E9aAmqpmYjpi1cIU8t7vhmoD0 U9peTBG7J61dycqtNvIygflwesQzkYfSlbTvj6D9Ar2Fkdq1KHtLC9ofhnc19xlD63P4 3sGLBcTkeNs3dimDmiT77NeeFyYrsUGXoWku02B1vmhVwLEfzZBdNyAdhl0R+M6D97Qa NpECs5rcc2Lbp+zsA6q7PdY+HTCSBgsO51VwJCEEiGfJ6ovbE5gOHcIMO/ao0VoVxuUe kgdw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=dKLig1GdGW7wZa1AccNKQ6khk2+JhUNRH8VhFqTMzHE=; b=02FjNlr58Mutz7M0FD4BgvOfzeRnbEyFs95BwERh400xWlmN444c3pTXWJNXT3MJbW r+nqBxke7A5jXfzMZRfi+xAa/BnLFqh4oyPYhL6J8xeBdowilwEqxkGws1AHnN03HuNf SkPcV8EPKr/3J+o86P6IKtREN1QBUmybPUYZFyM4s20xC4/dobnVf7jSfkEorXWm0L4z agZjcMftEvPm4VzkHZmXwaj5AQQLVyoNzXVl2hhHwnEwZ4howVc2xSNzuwfNKkj98paQ tAS8DJQJVF9HNs/E9+5jdjn2+G+GUE+WI69BGRetDxUnbP+uCJlUDRysSJi3Ox1o4RkS tjUg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=SGHO8C+g; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h3-20020a056402280300b00461b96334eesi8375272ede.500.2022.11.13.05.48.11; Sun, 13 Nov 2022 05:48:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=SGHO8C+g; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235369AbiKMNp4 (ORCPT + 99 others); Sun, 13 Nov 2022 08:45:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235258AbiKMNpg (ORCPT ); Sun, 13 Nov 2022 08:45:36 -0500 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2051.outbound.protection.outlook.com [40.107.93.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05DB413DE6 for ; Sun, 13 Nov 2022 05:45:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bVemgTH60+kPjKTlv4EL5E234pwK/zuTgxErcsAmDKSbhICPUzPGdsPmc5YK5wtgemvaEuGQI+94mtOtmoRPG5LqWzvAGcLQUN6b76/4qeMY6awJg0JVAcdpfYtIX7YdfTxf8WslyRL+9+4gJ7Ut2u6dzrTq4w0fFx+4VXCgx1pPTdT5HE3Svfzm48yjPYweUy9UEmcIuTphdfDsWULqOCxZXhCyHSy02SBgEooZVmVDBJjAO9EqcMA+uMGxiLnJPC6ipNee8vjE6TeDEX2Ygo0+EgHW5R/QGKlUbGfbwq5XyhGxQd+jp5mYAo6LhgaWnNVEJheDZMGXtgDAhARvng== 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=dKLig1GdGW7wZa1AccNKQ6khk2+JhUNRH8VhFqTMzHE=; b=n5tBTjIY7pmiHY1IZeRUra49DvlGjM/Qfup6Ke67fL6JuRnGdFT5EbWedrAMsC0iC78k2zTw/PRiUfM/GGgXsOJpK/sh7LYXfhDJstFxVgp/+kJ1Htt4EYOcdxjz5BWYTUw29ExlSqjgtNcO0X/Iq+a8I7YQaGfvQ1FEtcQdlGCqOwr2WTcjiHFfzLyx0wPkHyfldoakvsKqFGR5hHHHf0p5MW0UFjXaxr7003I4gu35JlkmapXMPBH95Jgw+/vAjTW1s2qfsEKUplbee2UsXySe3OcJgI5RCm3N2+0EDeBIHyGm6jcM7jb9inYxqttWcRQp6enwQ9C6JySqYH2xsg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.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=dKLig1GdGW7wZa1AccNKQ6khk2+JhUNRH8VhFqTMzHE=; b=SGHO8C+gj1jlh/OMIUQeekE2mpH4sdxj7EUW3uDZ0E6snWVoZSHTJCy04OxXtINDn2p/CsLDy5MQkuXqb/z+CdR8XrOlE5DWkyjXEUh3iEMjRKL9AIHf9fPSwzIpu2tqOT63bSFwuojaWdPTsWSZ9HAZvJSm5CPg4O/WNXMGTDkZbaHNrW0iz9e7OTRWLVhk8PSofckld8POdULExxJFPT4VXgUPOeQ5XMWXjLzLEDl7UrhdGumPp/UGIL45/zu9zHqhzVH4KTWOWLjKd0+JcJ7zQvXorQCMlf9XoD3QjrIvo764xobKJA6oGJgqmF8gprzkRjh6euwrH+uXgRU5Ow== Received: from BL1PR13CA0448.namprd13.prod.outlook.com (2603:10b6:208:2c3::33) by IA1PR12MB6460.namprd12.prod.outlook.com (2603:10b6:208:3a8::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Sun, 13 Nov 2022 13:45:24 +0000 Received: from BL02EPF0000C405.namprd05.prod.outlook.com (2603:10b6:208:2c3:cafe::d) by BL1PR13CA0448.outlook.office365.com (2603:10b6:208:2c3::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Sun, 13 Nov 2022 13:45:24 +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 BL02EPF0000C405.mail.protection.outlook.com (10.167.241.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Sun, 13 Nov 2022 13:45:24 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.26; Sun, 13 Nov 2022 05:45:04 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 13 Nov 2022 05:45:04 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 13 Nov 2022 05:45:02 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 6/7] vdpa/mlx5: Avoid using reslock in event_handler Date: Sun, 13 Nov 2022 15:44:41 +0200 Message-ID: <20221113134442.152695-7-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113134442.152695-1-elic@nvidia.com> References: <20221113134442.152695-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C405:EE_|IA1PR12MB6460:EE_ X-MS-Office365-Filtering-Correlation-Id: 84c32c2a-940a-40f5-0133-08dac57d50dd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XVWxdmbGNucwLqZmdlEDH68cqKQVwb4xXTs8sdMwSZJ8cb2GHImiNiwhkZcbCr4UnOkZfO6OIBF67a5CWh/eE/m5CZbkemocS7GCUl8ZlaST+d97GQ+zekwAJLhLJViX8bzL35SWJzs7fZsG614f4642/AR/GXxsBGF6K319gORwP4wFF7qPxcvOzVBzsUfxKnqThc6XatCtEAEEe+dHPdlbkuswAXxORPLkrVoE8X1sb40S8/A43MMIzp34spwd2pXx9bnqLcQcheDg09Yjl8nS+cxrN1Up98mZMk3s92gisRJByDtqpiE+cc/w3IclHDCZA7Gg4VQviV5BOv4i5oNsfQsyFMYmeh5ufRWvayl7n1DhKyt3X2jbRyRqTFhzphAknB4uf73jwoqBYwW9suRYaHNIhGC84uf2an5kw1+NEnnmU8w0Ecb9meqE7iyoMTd3lzNmumjX3aQ+KwUOHP1CPMYOLrVIrevvG7ZQE4zfLLXrj2xgVvEaaUEYAbzhQFHwfFiZr6UT+TcrGBQvsrV+RyehUR6gSzTScZF2mxQaDSo17Cbir+9da2Nu9nDIEL8nTqbYMI+zXHLOj94OnhsBlb8wXrHKq/WqGyULJwNQaGJ67o1kce+lwe2wIqCU3aKf06eeU7vK/YajpegzPWJg6513TMQ+MbqIJNUN0zFaxFkD+fiBeQhgBtPBHy9FBJYI87S04GRFYFEyT/cziwkv9EqKH3+ciKWmEnXeGLiDkRepaxK0fXw6MzWRxI5OW4NvRh6NHEc6xabrZEuTSg== 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:(13230022)(4636009)(346002)(39860400002)(376002)(396003)(136003)(451199015)(46966006)(40470700004)(36840700001)(54906003)(86362001)(316002)(4326008)(8676002)(8936002)(41300700001)(36756003)(5660300002)(70586007)(70206006)(2616005)(47076005)(336012)(40480700001)(186003)(82740400003)(426003)(36860700001)(83380400001)(478600001)(1076003)(110136005)(107886003)(40460700003)(6666004)(7696005)(356005)(7636003)(26005)(82310400005)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2022 13:45:24.2403 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 84c32c2a-940a-40f5-0133-08dac57d50dd 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: BL02EPF0000C405.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6460 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749388954081818553?= X-GMAIL-MSGID: =?utf-8?q?1749388954081818553?= event_handler runs under atomic context and may not acquire reslock. We can still guarantee that the handler won't be called after suspend by clearing nb_registered, unregistering the handler and flushing the workqueue. Signed-off-by: Eli Cohen Acked-by: Jason Wang --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 6e6490c85be2..bebfba530247 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2872,8 +2872,8 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev) int i; down_write(&ndev->reslock); - mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); ndev->nb_registered = false; + mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); flush_workqueue(ndev->mvdev.wq); for (i = 0; i < ndev->cur_num_vqs; i++) { mvq = &ndev->vqs[i]; @@ -3051,7 +3051,7 @@ static void update_carrier(struct work_struct *work) else ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP); - if (ndev->config_cb.callback) + if (ndev->nb_registered && ndev->config_cb.callback) ndev->config_cb.callback(ndev->config_cb.private); kfree(wqent); @@ -3068,21 +3068,13 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p switch (eqe->sub_type) { case MLX5_PORT_CHANGE_SUBTYPE_DOWN: case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: - down_read(&ndev->reslock); - if (!ndev->nb_registered) { - up_read(&ndev->reslock); - return NOTIFY_DONE; - } wqent = kzalloc(sizeof(*wqent), GFP_ATOMIC); - if (!wqent) { - up_read(&ndev->reslock); + if (!wqent) return NOTIFY_DONE; - } wqent->mvdev = &ndev->mvdev; INIT_WORK(&wqent->work, update_carrier); queue_work(ndev->mvdev.wq, &wqent->work); - up_read(&ndev->reslock); ret = NOTIFY_OK; break; default: From patchwork Sun Nov 13 13:44:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19361 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1686945wru; Sun, 13 Nov 2022 05:49:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5xcKa/Vdju3AFyiqM3/UfjpmPiZ6SWZ5yAL3Pme5u+qrRp6va7HViqzo3ZjoDiNRH+lW8B X-Received: by 2002:a17:906:280c:b0:7ad:88f8:761f with SMTP id r12-20020a170906280c00b007ad88f8761fmr7178839ejc.417.1668347377204; Sun, 13 Nov 2022 05:49:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668347377; cv=pass; d=google.com; s=arc-20160816; b=hSX8Udmz1GQS4NkhbWKsgaFEzOch88TpjDJCuTBLURURnRbd4T2AZMoWK/SnvkM2Qk /sr7tZIlZhzznvgDXMMlbkl9kscWnruYX8O9CZTOf7BYOxcaCNpLWUoOWSucXybpZEoH 9Zhga2oZ+oZhAKmRZaBZ1dxpJ4LrZTckYzUMAesPcORz0eQMTJzpFQVyLm8Y5n9AZVRa xjGJMdEdGbj6WLXU7KqFKY/U5naLAA0fGI6MS9w1XFIPanK1iIyD4RYZ2kME6XckEslS mGpZke6BvzOOhA8Emy8aDw0iHxcdo+zaqnSEH1CIixV/UP7LOWi6rmqqoDVn3Nqnuyyx ZCJQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yCKTa8sf3HmP8m8UwYFV1AyaAU6GY+3vj6gQhujZFsE=; b=p17Bt4I1UDzz3gfsMDsOEufL3IMdqMG8P1vy6LCd8fKb6owwfwnCW06xzLX47shqxN 2S7HLAYJd0f90rPEyIZxcsEqByLwOffzmqsdT5aa/hhTRJCzl9vlnIAvj9LEQJMWZ0ff GJ39i6LTNemiszBNNTAI5j4ReCpqVd/5+wo/RHMujWwYGOqihKaEz2Tcpe5pd/gA7ioQ nuBkAY0CIrEybeNJVJ4ctWQkHBdX+wSp2NO2oeQhq3E/iXtiHCCYf0/rRiHXU83grXcp 1y3YHBqf1+OGkxggOBWH/ST1wV/PCiaWLkJmhpJ+Fz9zdPj20vUiDMp6lvFCE5GZLvIv PadA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Y2Q5EX+x; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga9-20020a1709070c0900b007a7d37e4684si8058146ejc.803.2022.11.13.05.49.12; Sun, 13 Nov 2022 05:49:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=Y2Q5EX+x; arc=pass (i=1 spf=pass spfdomain=nvidia.com dmarc=pass fromdomain=nvidia.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235417AbiKMNqG (ORCPT + 99 others); Sun, 13 Nov 2022 08:46:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52256 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235418AbiKMNpp (ORCPT ); Sun, 13 Nov 2022 08:45:45 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2087.outbound.protection.outlook.com [40.107.244.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE1F411C2F for ; Sun, 13 Nov 2022 05:45:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Vhf63zD5UTYFwzLMInP8E3aicbpkki227970nEBvOFPdX0eWtD46Rwfsp9XqITUwJTyiYhUptnPyPiS0IDxKKDlji9WpM7/8a+/XV1EJAPBismARgZ9wrMj8g5EtYlOYnGk3R1HVQRAQawvV6nbN7pMvZkvILChxdd3nsHT/nrIDMbi9BxeeGWwMZoS0D8AF12ZaQ9MxakdLACTSnxAelbeROu5cFKM2pLotsos5xOoyhHoHHEOS1ZvYdADcXXkqz5Zvt5LJGUZeAyQgb7zb49MIf/+Decpj5qfpYar+lYriP2j3djub9x2WzL9D5m4iN1NGWhgLMYvv9Lj5VvFpIg== 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=yCKTa8sf3HmP8m8UwYFV1AyaAU6GY+3vj6gQhujZFsE=; b=KhOeVDMEJOjN14k93XnqQEgmB68Y/qwZUiLWI4VAaCzDM/8I0reY2c1nR1L3vRA/cHasPVIN24ZsTsRL3fueghhpUtYoccWsldpHXAOB2LOH3w1XDNujSbSefSFUDJlJggODgvMeQwDduu+/xwjUOJRr5C0qDY9OPXVu+6OSsyAUMxV54PDJyDcFcyo4wnDRpZuMcNGXAYt3moSOu5DyEfnprhx3Q/8v4JpOElh4Q0z46UswPCqGMjghwYAquU/cg3kHIHkyMWVy5JLsHQq3anISB0gfsGXn2WiazHbJX9uYaJXPNuRS4Ts1415pHeoQ+kfqwEQ7st94x5OJTS28Ig== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=redhat.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=yCKTa8sf3HmP8m8UwYFV1AyaAU6GY+3vj6gQhujZFsE=; b=Y2Q5EX+xuJm8epsjR4SyDBYlVUuiUo/DAyozHc8vSo2tWhz4ShEhl1iwuenBXBAQMD4Mgij+8ekd08sSakdJTKsOv2o5DBpji3F1CutlqrCfr0sWRLOSXLChI3IwLzTFzjEa8SY00cl+4yBbv3cmOtK/WezKLKkXID5DkbnOLuYDb0N2GfJf3xtEFQXIKQ6bwcjqTuI27nuAa1AO5eDtCvU/sEb7vO8SXzO1Spa1R5p8OFlVODbEXakfY32BbcN2B/k6otVBZBGwJZjiUadfKhOAK19qkyXPJlQJNrgszp6nZYFNAEO4Tz58RoBR52n7C/7YdSKHTPmsQhc/yU0qTA== Received: from BL1PR13CA0443.namprd13.prod.outlook.com (2603:10b6:208:2c3::28) by DS7PR12MB5935.namprd12.prod.outlook.com (2603:10b6:8:7e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Sun, 13 Nov 2022 13:45:30 +0000 Received: from BL02EPF0000C405.namprd05.prod.outlook.com (2603:10b6:208:2c3:cafe::2d) by BL1PR13CA0443.outlook.office365.com (2603:10b6:208:2c3::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Sun, 13 Nov 2022 13:45:30 +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 BL02EPF0000C405.mail.protection.outlook.com (10.167.241.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Sun, 13 Nov 2022 13:45:30 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) 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.26; Sun, 13 Nov 2022 05:45:09 -0800 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Sun, 13 Nov 2022 05:45:07 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.129.68.7) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Sun, 13 Nov 2022 05:45:04 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 7/7] vdpa/mlx5: Avoid overwriting CVQ iotlb Date: Sun, 13 Nov 2022 15:44:42 +0200 Message-ID: <20221113134442.152695-8-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221113134442.152695-1-elic@nvidia.com> References: <20221113134442.152695-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BL02EPF0000C405:EE_|DS7PR12MB5935:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e2de4d0-294a-4cc1-aecc-08dac57d5496 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Hm6Niqhj05U7b2D4lIdhtTUwRr5/IdWKIRTcuKgeasZow2diBH/nZRf0W+7E10S9TThdmJGPbpsM9iUF9ada1P2r1INXgeTohwP+mYLBflsL1B0q0sxNLv35KNirf0W3GT42KR5x//ZzWx0hH4vqC9zBgWlncz5OikMbHeoP8xZUWtZekluI4hEuaCoT/O6wjvEAvMabq9i2RY70DAVjvl3fOLpB4DK2T9GXs1majPgMAp1/54Nn40BrUshWPRSo/BoYZT9oBPCVniSMYBRqGeeAZ8lphp+gpNCOFqk2itifzxCXDanRvh8YaHL3wgsGxQjw5QKjzOcSZx/mgpTLEawKQxMV6JbUQFVc8s0IyiuJmecO38wQaVHkWlbRdfdpkY09P/ajXztOeioPlHR/GFjoL46UR93JRLzYRnr2xEyyCh6bcOP+902ZHJ+mT6kGs+Im0BMCFSFJb1FeXTjX8iwntDTMXox0h3YH8Wmw2Xk2OpxxbITd5vB+oJxCziHGDypjkIlRNMWaS6cRyniqtWITLjjTa0wBWkDgEyNRxC01poSDCyHvJ6A8JOsk0HQ//60ZWGlt8jLUILyzI+Qxn4IQB+kljlTIzyjq14ZqoSgxU2l6jDYOx+eA1SE/EWWM9D7k6LJxQ7krIF4zBR8UfMm8ez75xDzyvi/gp+hBH4/XJ0Zayuf/7XrB5kwpRX9LoWPiFDVuXVtLIb4dV7BXmaW6GZ9Eq3BxO6QFGxqLqyIQWD7W4F7sq10vr/q4saKAem90PQGkAtYvx+1hmMOMUg== 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:(13230022)(4636009)(376002)(346002)(396003)(39860400002)(136003)(451199015)(40470700004)(46966006)(36840700001)(7696005)(40480700001)(26005)(6666004)(478600001)(107886003)(54906003)(110136005)(36756003)(4326008)(70206006)(70586007)(8676002)(41300700001)(186003)(336012)(426003)(2616005)(1076003)(316002)(40460700003)(83380400001)(47076005)(66574015)(8936002)(356005)(5660300002)(36860700001)(82740400003)(86362001)(82310400005)(2906002)(7636003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2022 13:45:30.5061 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8e2de4d0-294a-4cc1-aecc-08dac57d5496 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: BL02EPF0000C405.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB5935 X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749389019490205807?= X-GMAIL-MSGID: =?utf-8?q?1749389019490205807?= When qemu uses different address spaces for data and control virtqueues, the current code would overwrite the control virtqueue iotlb through the dup_iotlb call. Fix this by referring to the address space identifier and the group to asid mapping to determine which mapping needs to be updated. We also move the address space logic from mlx5 net to core directory. Reported-by: Eugenio PĂ©rez Signed-off-by: Eli Cohen --- drivers/vdpa/mlx5/core/mlx5_vdpa.h | 5 +-- drivers/vdpa/mlx5/core/mr.c | 44 ++++++++++++++++----------- drivers/vdpa/mlx5/net/mlx5_vnet.c | 49 ++++++------------------------ 3 files changed, 39 insertions(+), 59 deletions(-) diff --git a/drivers/vdpa/mlx5/core/mlx5_vdpa.h b/drivers/vdpa/mlx5/core/mlx5_vdpa.h index 6af9fdbb86b7..058fbe28107e 100644 --- a/drivers/vdpa/mlx5/core/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/core/mlx5_vdpa.h @@ -116,8 +116,9 @@ int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, u32 *mkey, u32 *in, int inlen); int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, u32 mkey); int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, - bool *change_map); -int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb); + bool *change_map, unsigned int asid); +int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, + unsigned int asid); void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev); #define mlx5_vdpa_warn(__dev, format, ...) \ diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c index a639b9208d41..a4d7ee2339fa 100644 --- a/drivers/vdpa/mlx5/core/mr.c +++ b/drivers/vdpa/mlx5/core/mr.c @@ -511,7 +511,8 @@ void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev) mutex_unlock(&mr->mkey_mtx); } -static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) +static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, + struct vhost_iotlb *iotlb, unsigned int asid) { struct mlx5_vdpa_mr *mr = &mvdev->mr; int err; @@ -519,42 +520,49 @@ static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb if (mr->initialized) return 0; - if (iotlb) - err = create_user_mr(mvdev, iotlb); - else - err = create_dma_mr(mvdev, mr); + if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { + if (iotlb) + err = create_user_mr(mvdev, iotlb); + else + err = create_dma_mr(mvdev, mr); - if (err) - return err; + if (err) + return err; + } - err = dup_iotlb(mvdev, iotlb); - if (err) - goto out_err; + if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid) { + err = dup_iotlb(mvdev, iotlb); + if (err) + goto out_err; + } mr->initialized = true; return 0; out_err: - if (iotlb) - destroy_user_mr(mvdev, mr); - else - destroy_dma_mr(mvdev, mr); + if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { + if (iotlb) + destroy_user_mr(mvdev, mr); + else + destroy_dma_mr(mvdev, mr); + } return err; } -int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) +int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, + unsigned int asid) { int err; mutex_lock(&mvdev->mr.mkey_mtx); - err = _mlx5_vdpa_create_mr(mvdev, iotlb); + err = _mlx5_vdpa_create_mr(mvdev, iotlb, asid); mutex_unlock(&mvdev->mr.mkey_mtx); return err; } int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, - bool *change_map) + bool *change_map, unsigned int asid) { struct mlx5_vdpa_mr *mr = &mvdev->mr; int err = 0; @@ -566,7 +574,7 @@ int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *io *change_map = true; } if (!*change_map) - err = _mlx5_vdpa_create_mr(mvdev, iotlb); + err = _mlx5_vdpa_create_mr(mvdev, iotlb, asid); mutex_unlock(&mr->mkey_mtx); return err; diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index bebfba530247..fc825958ab0c 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2421,7 +2421,8 @@ static void restore_channels_info(struct mlx5_vdpa_net *ndev) } } -static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) +static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, + struct vhost_iotlb *iotlb, unsigned int asid) { struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); int err; @@ -2433,7 +2434,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb teardown_driver(ndev); mlx5_vdpa_destroy_mr(mvdev); - err = mlx5_vdpa_create_mr(mvdev, iotlb); + err = mlx5_vdpa_create_mr(mvdev, iotlb, asid); if (err) goto err_mr; @@ -2614,7 +2615,7 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev) ++mvdev->generation; if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) { - if (mlx5_vdpa_create_mr(mvdev, NULL)) + if (mlx5_vdpa_create_mr(mvdev, NULL, 0)) mlx5_vdpa_warn(mvdev, "create MR failed\n"); } up_write(&ndev->reslock); @@ -2650,41 +2651,20 @@ static u32 mlx5_vdpa_get_generation(struct vdpa_device *vdev) return mvdev->generation; } -static int set_map_control(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) -{ - u64 start = 0ULL, last = 0ULL - 1; - struct vhost_iotlb_map *map; - int err = 0; - - spin_lock(&mvdev->cvq.iommu_lock); - vhost_iotlb_reset(mvdev->cvq.iotlb); - - for (map = vhost_iotlb_itree_first(iotlb, start, last); map; - map = vhost_iotlb_itree_next(map, start, last)) { - err = vhost_iotlb_add_range(mvdev->cvq.iotlb, map->start, - map->last, map->addr, map->perm); - if (err) - goto out; - } - -out: - spin_unlock(&mvdev->cvq.iommu_lock); - return err; -} - -static int set_map_data(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) +static int set_map_data(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, + unsigned int asid) { bool change_map; int err; - err = mlx5_vdpa_handle_set_map(mvdev, iotlb, &change_map); + err = mlx5_vdpa_handle_set_map(mvdev, iotlb, &change_map, asid); if (err) { mlx5_vdpa_warn(mvdev, "set map failed(%d)\n", err); return err; } if (change_map) - err = mlx5_vdpa_change_map(mvdev, iotlb); + err = mlx5_vdpa_change_map(mvdev, iotlb, asid); return err; } @@ -2697,16 +2677,7 @@ static int mlx5_vdpa_set_map(struct vdpa_device *vdev, unsigned int asid, int err = -EINVAL; down_write(&ndev->reslock); - if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { - err = set_map_data(mvdev, iotlb); - if (err) - goto out; - } - - if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid) - err = set_map_control(mvdev, iotlb); - -out: + err = set_map_data(mvdev, iotlb, asid); up_write(&ndev->reslock); return err; } @@ -3209,7 +3180,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, goto err_mpfs; if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) { - err = mlx5_vdpa_create_mr(mvdev, NULL); + err = mlx5_vdpa_create_mr(mvdev, NULL, 0); if (err) goto err_res; }