From patchwork Wed Oct 19 12:46:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5420 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp316297wrs; Wed, 19 Oct 2022 06:07:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7LdOKdBL9CxnfGunTEh04neHN4nhCqAiWRH06ibXwrCL3YbJfpUL+BepT/KS2WfxD88cur X-Received: by 2002:a17:902:a502:b0:180:e637:a934 with SMTP id s2-20020a170902a50200b00180e637a934mr8520034plq.64.1666184854986; Wed, 19 Oct 2022 06:07:34 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666184854; cv=pass; d=google.com; s=arc-20160816; b=n5KrELhczcFJQqlxaTq1xpr6iy4cgJ6vZlXOSq4FY0BI65zfSUUZaAM2aJrMeDuDrR jYNEOrIY+NWtftcGfOvNOqz56Oz0/kdn0bCkMFI7PagHedRAyWkmDyPV2knOMhYe8AHd J/o5bHe7Bc1eqznmjHbuEtvdQ99bS0Rsn7KUg3MLTXQIGeIAA1LBV/Afk9lM8jskQPo8 /ZnMVQeiRC8Nc5AR0bRkPGy8gS1wAOJaQdsVZ+xQoY2lLqLBUnzUuIfKkIrZcIPLFw6m 4Dp8Aa4kCI2xHKxINH/FVCoeKDmp9zJx6ko7x8xZCShtao/o+yHNcAKrR2f9R0cvjuwy bptw== 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=9b1WbkgVUdgVphboZ2mUqLEFFKxWn2NcOrVzWdUAccY=; b=buuufGBI9LYJZm8IjKEgxmCS254HPq1vQMBi6HHrK6vWqeAe45XKUuaE+G0gX7KIOd WfdUijtoOGbGleR/6xaMn0idPp1KFNNnvi3ei5kQhN0Pj5XziLcIGSB8wZoL3hXBBx3J EtssMQgpIECu+lOySrewBKf9bcX0qmqfAqyawOeLveBPVCoqmTwrCPulqgwmmmdHx8jL 6K/vusIXUCMcpVND6nrSB/BzPWY2KmvdEnrZxRMfa0gBQHSdel47CafyftWA/pC/C/wi OTqmT9M3bzAjVIQ3ifSYBqPlZWvpezchi8mkCw0vhdq4/iKPGQS7dZT8xGKS4oVVVYIG u3YQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=LT+FgCmb; arc=pass (i=1); 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 n28-20020a635c5c000000b004404705691dsi18659055pgm.487.2022.10.19.06.07.20; Wed, 19 Oct 2022 06:07:34 -0700 (PDT) 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=LT+FgCmb; arc=pass (i=1); 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 S232642AbiJSNDz (ORCPT + 99 others); Wed, 19 Oct 2022 09:03:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232145AbiJSNDb (ORCPT ); Wed, 19 Oct 2022 09:03:31 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2063.outbound.protection.outlook.com [40.107.237.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 932151AF36 for ; Wed, 19 Oct 2022 05:47:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=loxVR+cO0xcn71aTuiYm0Nr709ZwqZUHoy5tBfoHtfLd8pHd6ldRCXuqbV5DkrbntYplcyYgSKxaQwdFFi7sNQJ3GXDIZwgiiKdU3o1GU2ELQ9qnXcHct0dhbLi3ebrStATTAB3TghF/i99KxW3CTRZzuPyl7tjz+DiQyLJfy0XXg+oCxaA5nxhB0JKOH9drn2ve4YJxjppdsd0U28qr1ZMzQsfjAqNtGdRCQj5pRgdGt4oYNbcbp+b/LHre4Lr7lFDkDZnnd202CzfIdUXVsUofxdBTkmtQTFStoFY80jocdO0nrs6AWa0Oh5lcmTwadEHDsGHKvFXLQFnOAH5auQ== 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=9b1WbkgVUdgVphboZ2mUqLEFFKxWn2NcOrVzWdUAccY=; b=h8LAXwOCRJvI4qZcG+44xOUxJaerK9wS5AQl7lVLPWcSrw0eWRWKUK5dZf5c64qrqf1wHnIRZONlqAm1B49MnO7Gt6rHKwTPtakgiqT+F4O+r0nY87axCpEbVKx+PBqTviHyTfwiTiN5bYqh8Pe7gAXyCNacG2nmhdrW2XFdhy4s3uCmogth1WZjfVYUp57YnYhXR9MbB6w3qgsCaqZ+430qGDbQtiD0gKIAA+PVckju+we7PHShMDi3vFEi1o3X8jxQPOhvy9PTReKJJT1JV3dfVh6GcIAHGPQ/c6dgWK5XBcnDyEWnzb0g5g2o3pkPwh207praqZh6QBTO8xmP1w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.118.232) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject 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=9b1WbkgVUdgVphboZ2mUqLEFFKxWn2NcOrVzWdUAccY=; b=LT+FgCmbn9yMJCpxTaKVFXVY/IwYOyLhTywPhRHjkVRDoBeAprXtuk+/AlEt+EaAyOfLDafN0mL5XSPLBaq0iJ8rsbhon0alf6YJO6mptgp10iejhjL/tgDbyhwA6T4hJDjF/3ScYgF3sHj33l4eBDhXIKZiJT7np27JEj5a90/WnetKfO2KxAE9RDnlsM4zAoDKEaQWloDHKRS6sgKvBconFzy21xsQbIy4hQhKC8+AWeQt2N4AHKQDoHywTwkqxUxyknmG6ekXAxgQnNxIvvosiC6TYA4XVE/Y8OHQI1e4IuqcCt0hgx3Fj5pcK1k63UBtWavo2afvJN4lZItwVw== Received: from BN9PR03CA0480.namprd03.prod.outlook.com (2603:10b6:408:139::35) by BL3PR12MB6378.namprd12.prod.outlook.com (2603:10b6:208:3b1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Wed, 19 Oct 2022 12:46:28 +0000 Received: from BN8NAM11FT095.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::fb) by BN9PR03CA0480.outlook.office365.com (2603:10b6:408:139::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 12:46:28 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=nvidia.com; Received-SPF: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT095.mail.protection.outlook.com (10.13.176.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 12:46:28 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 19 Oct 2022 05:46:18 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 19 Oct 2022 05:46:17 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Wed, 19 Oct 2022 05:46:15 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIR Date: Wed, 19 Oct 2022 15:46:07 +0300 Message-ID: <20221019124610.208113-2-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019124610.208113-1-elic@nvidia.com> References: <20221019124610.208113-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT095:EE_|BL3PR12MB6378:EE_ X-MS-Office365-Filtering-Correlation-Id: f8bf2afb-3a0a-4dca-faa7-08dab1cff10a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZrTF5ze/2pA+scIKX6Dzv5wOoYHolvneAWZFBXiY/N7pTivEr2LpyQN2F6furocF6t3bAsEZv7lRVj1bTD0imnM8KOe4KBtzuBF5qC5BHtxrSi4WoiTAWYHvpI0NV1RFycLq1WVIHRE0FVUxj5/IrJMC6S00JEkb3C9soZuLOE12GUD8EtcQkohbG1yOP+HsEjXtz7w/2I5uWf5wFvkEj7rxTU/KOL0jUbOHW36ikQRiDmX31Mc86wYrmCThVm5E1IvGaqDd4yo3E5oGDDBW0yA4VNziDQP+PCJbeN8sQzcEMtrG0AUJZg5FrlMGyHXiV4fi9WiUgf1vE+664lnP3b363FsdQhUMoTaGY96OrILPwAqJKEno/Uk15MY/9o2I30o35E6x8CegemE1Vy1lBmNxv1SPL+yN/wkaQAKM/25JXAOr63T+GQZOQba6ixflKKLkAxAgB2QjxvswFB3XL1zZ1QrPrTG4OZwy7Ta7bwpE3SSUWROIC+X6v8hT6CBLW3vM2XWYE4hZ6B76u/ccmpINsHSA5LaR5vdkukHhyDls8h1T+COhe7lOHh9/yX1ZDYmglZkcCMQgaqE0V7vvBBQrW/6bYZ3NpMTi8bHwwf6Q0875Y0iFurZ8/KrpyQpKoJqiPKfP8rhpVTmObC5DLG+mEUuI0fkoW/5GkGxJO6SRB6iGmg1aGnlArrSNt5OTRE284hV8q7+yxcgEIc6C6C/rcGlnjth0zcvfTHtfZ2voEp6KRxQPK3nOwsxO3KiNfJY9ZV8mFlAniG6Xd+294w== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(396003)(136003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(40480700001)(36756003)(426003)(47076005)(2906002)(82310400005)(7636003)(8936002)(356005)(70206006)(70586007)(41300700001)(4326008)(8676002)(7696005)(40460700003)(82740400003)(26005)(54906003)(110136005)(86362001)(107886003)(316002)(6666004)(83380400001)(5660300002)(186003)(1076003)(478600001)(2616005)(336012)(36860700001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:46:28.4690 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8bf2afb-3a0a-4dca-faa7-08dab1cff10a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT095.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6378 X-Spam-Status: No, score=-1.4 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?1747121450148038231?= X-GMAIL-MSGID: =?utf-8?q?1747121450148038231?= 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") Change-Id: Ie93d6756c301774664973adc19718618a7008947 Signed-off-by: Eli Cohen --- 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..1bcd8dfa9b7e 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 & 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 Wed Oct 19 12:46:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp316380wrs; Wed, 19 Oct 2022 06:07:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YhzhheQOJcrwJJR6qU4jHdy7rzJi3QZ3O/tOfitSPRXexBakxzwHHYCGDLNBp0ozhVjpX X-Received: by 2002:a63:88c8:0:b0:458:9ddd:e8ea with SMTP id l191-20020a6388c8000000b004589ddde8eamr7100252pgd.622.1666184862611; Wed, 19 Oct 2022 06:07:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666184862; cv=pass; d=google.com; s=arc-20160816; b=t1Xpt2cgClpboFjPU8pdQFIh+LCXy+rBs3PSoVIxBgKFnR9ZRX6yTNkEFmiMgVYI9c rXTEM6cgsHAmuedmu5+uWVhuKy6H2DZkksCXq1qPPzsn9Q7ir6bRz8rKzIBXt2+z+8W6 HYmcXR5U3B9raz/gjUTKWomWEnm1435yXmdkjYiB2+KD0bAYVCPBLfFz4dziMVfrp3kj P7QT253KP6/VSMh1QMroIXOfENCRF3u9ZT/lGRKsb+CLsJKspLuIsJLiuMszBPQ92RZW gYvi8Rf05pjWVpQwA7J/4KN2HIQsBoA9ZVQLoWo6+LeIhuqbzo5l28qU1y0PCL8tJe4Q O4Tg== 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=Tc2r0vtExSWff6ZJmHTOd6aPs0fsRIaw2iLicXxi1lU=; b=alWfgeqIKzqXWY79LaARa5VI6/Vtj0u2mkldZolQCvW2NIt2InrjdKtT3uoTXS2h0M V5vksJOT8b1LnXot6zg61EDfvAgifo1+D9LvQGNrmp7/rOjSW6PWpVg0VorUokrXZn8I CO8Dd5KcaQRPEWL+YwrdVaQd8MztCfxmr/kOjykXROQ+U4VQFeN5Sm0NOBbKgrVVPp3t MiQFivkJaF/Jup1Z/3XaHx4BNpnG3r8GSqalkkhiGTOjBv76Fn3Y5fQC9Q8I2VuMxBp4 9eixtAMNyuPBSI8zyO1K5o7XYZSY5Y79sJZyDsgCRqlQCJN6z7XRYeNGKQalhzFDjxF2 /7Og== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=B8Giz92y; arc=pass (i=1); 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 a19-20020a17090ad81300b0020a78bdb716si16815528pjv.24.2022.10.19.06.07.18; Wed, 19 Oct 2022 06:07:42 -0700 (PDT) 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=B8Giz92y; arc=pass (i=1); 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 S230435AbiJSNDt (ORCPT + 99 others); Wed, 19 Oct 2022 09:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbiJSNDc (ORCPT ); Wed, 19 Oct 2022 09:03:32 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060.outbound.protection.outlook.com [40.107.243.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1B221FCF6 for ; Wed, 19 Oct 2022 05:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ozhm12w909x+RhGPAKc5k4vbzdNQPAvhCxVfIsb47JwqVc8n3WGBqoEFkw6jICeWqiDkAbz1WeTJPdTZzUtYFb5FCiMIWLXZcRRWtb/AQlOWPwaF5fTwSQ0XOPl7Q71jHCRS4Oca7TWFBqTDJ6vC8unq1+L1NAgwKpkgZCdimFdGEbK2QKz2ZiLjeJuiTcq5cNqGGlOYr163V3ZB8KnL2GKQ6LQtHX+6eCF0kRpgpoSwjnP5h4Ra7de2ShaWVDcRiTi1yEix/PR1Yb/p0Zic8bTsxzhkBl6SLu71dzL1RQKhLtfG7KaKvC92g0NY3fWndj0ckxxXGPuzm7vATtMdkQ== 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=Tc2r0vtExSWff6ZJmHTOd6aPs0fsRIaw2iLicXxi1lU=; b=fXvim6g/6XT5uFFJoH9BhE75gu0mqwz0sjdfCZJ6tBXi7+7cev+GuI2CgKluwixyBFRhPm4NWkrCrHJIyI6xVZCG0/GFLYSCLFDgCylCuEpVsY9NzjLyU+oCSST873X5viYAtNQ5IdLYdEUnn+fU/WLmpz/I+yy4e8PjeyQeMOoAFrItuI3E/rlEGftbSWNs9fnK7GKnw1gQ+R5+VjchrG997+LjcoP03ujx8JO5ZmFZlvHrHilXGB0w8BiSd2rmxlbQCuY7K8wfK9lBgQgFjJM0jQDPZOGiiJaYr3MYQhQZOqM9jfmr6Xfw6jWvST5k0thW+UL//H1TTVkHgBQdXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.118.232) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject 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=Tc2r0vtExSWff6ZJmHTOd6aPs0fsRIaw2iLicXxi1lU=; b=B8Giz92yDa1uUS0xBH0vbGIgiAbg/2m1xDmlZlGGpio4ntHU8UpD4QYwFB4Y0UPH/c/TjmqNBWWjQrWJ93jO7qhyN7V8afACBhK20lkJP8o/YmG45ESLzw/DAghjksJ/c3Vaw2LSFtt4YsaSEWx/EYFQLg868Ma6RhOiaMQmU1mixGSfkpgYhl7QHjMpAhtZ3BOonWxKr6XIis2m6EiWF1hcBp4qQSFjl8sU4UKHuI7gzD8WqC4Ytn6VklrVCJXiq/KuV8gnMJZqB7PQDj15EPjy33gB+YoGRCjWHtlv/WtqqlXk1o8Hg4r4iu4HrHJVF9ss1oYwmyAIbpZrF/uVAw== Received: from BN9PR03CA0462.namprd03.prod.outlook.com (2603:10b6:408:139::17) by SA0PR12MB4511.namprd12.prod.outlook.com (2603:10b6:806:95::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Wed, 19 Oct 2022 12:46:34 +0000 Received: from BN8NAM11FT095.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::2f) by BN9PR03CA0462.outlook.office365.com (2603:10b6:408:139::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 12:46:33 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=nvidia.com; Received-SPF: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT095.mail.protection.outlook.com (10.13.176.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 12:46:33 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 19 Oct 2022 05:46:20 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 19 Oct 2022 05:46:20 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Wed, 19 Oct 2022 05:46:18 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 2/4] vdpa/mlx5: Move some definitions to a new header file Date: Wed, 19 Oct 2022 15:46:08 +0300 Message-ID: <20221019124610.208113-3-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019124610.208113-1-elic@nvidia.com> References: <20221019124610.208113-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT095:EE_|SA0PR12MB4511:EE_ X-MS-Office365-Filtering-Correlation-Id: a17ac934-fdc0-4713-c640-08dab1cff430 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k8syEBKF9l8HIEXkAm5dUOKddwhFLR8nurkFepEh4dCeWNbz7FEVa860Uq1dywKbFTbakimAYE7QiRyBCFpgKKDV7TKC0q9Dnm8bM0ViLB3WygX01lb+yTAyTJ7OOSegq8lPmqkn6ClQkuCh5OJrry1GKV8/Ob7pZmf5jpFpC4zAjn3AqusXoWZFykh259vS5KwOK2y9q+zwTSH9lImIWQN7p7jn6+JQMwa2I062tV9LfIq1jMuQZR9KSwexnnApiP78u8LYNTAbqCTSloZ6SZ3Na6CJv7YFZ9ViWnliezKow1ZRoXxrCiGOfmI0WbE414El/+ffq/c9Rh57WbKydSdh8AUAWskPTV8ZF6cPQj2x7oLv58U2MbkxWYC9u634T5N5+JyjQ7vHOWrb2Er4VJ3qC3d02xb9FLDVZA6HVXcnEahu+xpCpgLhAn3s0OburTwqq2dzmNIshMq9+SmP3BDkhiQYykQLuC/afkv01a+5w8JS+E2AbpctyXhyXRNXubCNS8Au6dDKwSSA9VyYa0D39lnthyCri7ipGg9zkdj7kldZd+TlOgzIqFaBnHaqzNdL9eQ5p+a0LO+KKhtnyrdDdC4WfgM+HJiDkxELWLGszV4uoyDPgv0JobYPkeAGIcIRyuHHPaJlZDbKgDbfVKPJflZxph+QqDxZXQSrJ9vBL2KJQRU2i630gZyzcaVGn2J3cCTfw3I+aXZq0wRWIP+NOcI0G3ubgWjS4w78+PP3UHvx4s5Ix15Y0Hf5+vUd8jPb2uKPsPlGQWa3XBQMjw== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(39860400002)(376002)(451199015)(40470700004)(36840700001)(46966006)(47076005)(426003)(83380400001)(82740400003)(82310400005)(36756003)(7636003)(356005)(40460700003)(40480700001)(86362001)(36860700001)(6666004)(107886003)(70206006)(70586007)(316002)(54906003)(110136005)(5660300002)(186003)(1076003)(2906002)(336012)(2616005)(7696005)(4326008)(8936002)(26005)(41300700001)(478600001)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:46:33.7655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a17ac934-fdc0-4713-c640-08dab1cff430 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT095.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4511 X-Spam-Status: No, score=-1.4 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?1747121458338352328?= X-GMAIL-MSGID: =?utf-8?q?1747121458338352328?= 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. Issue: 3214718 Change-Id: I23c02b11322b503065b5e40c9463d512ce6697b9 Signed-off-by: Eli Cohen --- 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 1bcd8dfa9b7e..acd95f2d0ba3 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 Wed Oct 19 12:46:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5423 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp317059wrs; Wed, 19 Oct 2022 06:08:51 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7tT1twl2PmYLPD+0EDdT+XqxmSGBgQQlDPEbWF9PkfDV3th7WRvkO5IEb3XpkvEbWfai8e X-Received: by 2002:a17:90b:4a09:b0:20d:5b67:1496 with SMTP id kk9-20020a17090b4a0900b0020d5b671496mr44428846pjb.67.1666184921030; Wed, 19 Oct 2022 06:08:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666184921; cv=pass; d=google.com; s=arc-20160816; b=N3LhPDxiTobMoo5Lg5DJ/zyg7dRnWkQRLuHdmdrUrS7zC96Ph55K7Eu94xjH1o563j ENOd7MDQEenKZxC4eMnpGmmWC6NNakBac1zIqU2Hz2js3DPZZyjjOHcAAMin0/9qDew7 ehmrtECwgT5JsvmIFCWU0bdTpUlhXupIGoHL3IsCF8GOYDa/5h51EAcRTpS8qZ8k47cJ nIv6qiz4z1Gbte709hmVSIvjznK9jB5NtSiXfjX4ZUAAyiAe91K3sXQ6fhMcZroV8jx4 H6fIdYeuxwtdsZxikvMFVKKjGvb3wIrMA6A+SvqAcyipa5yD1Jqv1odHzaTQ2hi0ygye K91A== 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=ai2nL4dPdc8YZ6r7al96+NkgKRDkcZM/8yTgdWXhclI=; b=n/GMRDkhgbibS6ut4RN8JLj4Z1n2Yg23PETVzmzxALgtCjb3AFE1bz5nIzsEECym3F UfLWExuVTZ8+1SUXP03R9Bm9HVnY73qLBvO2niNVUJ8DbusQ5tQHDv5cSvlY+jIHwLW8 YegvSSF9l0xRYNyN84eazYG82SzjQwW1dNGqOqxveytYeTgRfxZP4eA/hVs1v4VtmPGO SFcvI3vym+mae1tQ2egNekNwgQdTAgh6rLttPvQulmGlYkgSq9u0VAul4vXaSmdhEqZK WqO97y3H1ke4hwRGPWnVToctvwplyvUYSfwSgFWktNpjijN6uQlBLl8lZNsRhVxShyOO 5XaQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=SKyA5tDZ; arc=pass (i=1); 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 s10-20020a056a00178a00b00565a581ecc0si20424529pfg.11.2022.10.19.06.08.23; Wed, 19 Oct 2022 06:08:41 -0700 (PDT) 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=SKyA5tDZ; arc=pass (i=1); 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 S231822AbiJSNEa (ORCPT + 99 others); Wed, 19 Oct 2022 09:04:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34354 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229862AbiJSNDr (ORCPT ); Wed, 19 Oct 2022 09:03:47 -0400 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C5DFB4BA5F for ; Wed, 19 Oct 2022 05:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BeJ5IBoPl0RO9AgXht9S9t97V1UzLuLwupppQ5ZNTUHC5vw1EcrdOIq3vDq0OX4SnrVWNW/in+2xG9YIfwVBq0WSaB4Y8o8rMsfQzg4A5/en6daop2vjMM9s0eUuVA8Vu7LN5WX/9El0zTYbRp7S9o4khtI1Xq/fK9rjvaIwIoK6M2tNLD1Vj8GOCFwnCc+KlemH12UHI9bZOLuJMWcjyWqVvC1TUqFq7Q8EFjZqs9AXuc2ED9sAb2ikgVdwBhEtmumjG9euVsbm0pyaoFnCn40m+U4ETQjorYIB1ZB67WyLnPRe09gj5ZcvpXaAk6sUGnErwEdIhPfrttm2Yks41Q== 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=ai2nL4dPdc8YZ6r7al96+NkgKRDkcZM/8yTgdWXhclI=; b=dL/KpcY9CaPI04r0y8MhCfNmyUICzrdaKtcpWQK62veGduBO+PxXpz/tUhZjql+j82GSxRGjIVzPvhpiR/O+KxOKB0PKHgLvmvFEFWweBPPZCvYk1YsROjVAl8BMo+6ncXoAUqzCIfKDXRiJiUm0q7X35ujlyqd4NUCQSnoOApjnF0GREyqCwvsyXTlGZ+JLCQuinKRbocvZlBZbjHI2tnyb340Qvs8FkIIJ2Shcq1AQo2pd/l9vn9bj4LXsf0XjWoMJtvgrEs6CiHdvs2VjE/ffQg5Q+qDSOQiCHOXel5JOTb1biDAaJbwD9OwHSWPN/H5BxkGhGyWVa/pnYdt4kA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.118.233) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject 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=ai2nL4dPdc8YZ6r7al96+NkgKRDkcZM/8yTgdWXhclI=; b=SKyA5tDZ90ylfYQiiX+jRouX7d/xBriwF7EVI62LcMUhnjYJb9aZyCr+YAmGzZkS+yyKVS89FH/xbxPVe56fOYyJJhtu9V9rFtoDHyt6e5DLuHUYJifJhLYBlxwzyguaCXxfyLbZkK2FRiJo5JmC9kSWdoGdvF2sDbxnE8Y1ROxExy6RDLD8B1dzgxHmXaIJgOu+7KvZMQvOW8lVyXSsmm+6TK2xrBIOxlwTcasBg5yLcw+TTeeEj4+EnAZzH4WlWd7qFlcYCeY/0MJiUTPZm//OLmYOkXur9cfpBNY3GYoHmdWcuvMHqyVPFD3EBdmD7IKC9eHbvYFFGqjfJzdeSQ== Received: from MW3PR06CA0008.namprd06.prod.outlook.com (2603:10b6:303:2a::13) by MW3PR12MB4507.namprd12.prod.outlook.com (2603:10b6:303:2c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Wed, 19 Oct 2022 12:46:36 +0000 Received: from CO1NAM11FT071.eop-nam11.prod.protection.outlook.com (2603:10b6:303:2a:cafe::8f) by MW3PR06CA0008.outlook.office365.com (2603:10b6:303:2a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 12:46:36 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.118.233) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=nvidia.com; Received-SPF: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) Received: from mail.nvidia.com (216.228.118.233) by CO1NAM11FT071.mail.protection.outlook.com (10.13.175.56) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 12:46:36 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 19 Oct 2022 05:46:23 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 19 Oct 2022 05:46:22 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Wed, 19 Oct 2022 05:46:20 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 3/4] vdpa/mlx5: Add debugfs subtree Date: Wed, 19 Oct 2022 15:46:09 +0300 Message-ID: <20221019124610.208113-4-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019124610.208113-1-elic@nvidia.com> References: <20221019124610.208113-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT071:EE_|MW3PR12MB4507:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b584d52-13be-43cc-383f-08dab1cff57f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yj4HwhhdNVHEjJDe4GVl0yaG63G1cymy7/isHA0+c3UMcwhIdTG3jcIg4y5VKuqLG7nLXHUFukIiFmAFeAp2ewss9xgfD4DZXjtGyP3L3zCGHm5L8aKPf+VzEXNIhMiGrBIsaYDEb/qFo7BJHxT3DK9gLopkcD6SWmfFPajcQYyNuAB3vQ9ZDNWzsofRodWt+jRN1sKgtAWpCnzdCeMpG2yROEpGtqzghc+ouQafqQvB62q7Qj2Q+4OqUimaZj1LZqFV+R5QT4hBNWaV0TFbPyd+SLob66gWP9TkMRJgw4hu/E7MXtdEoNWpPyu9/O5xAawjpNRnyPN9HAELVScpLHQf28ASZUmvanNugg0U9g9I6VVc68Mf1b1u9NywOu9obRuShpDVeqGTNflHetpOX7624ExbmdZK1q/hnpc1bTvvKnPXEiolmUoFQxy0ulUncrxAuVbCwyX/oMcUkz1Onz4gXGrLngcb4SjERc3pQi0dXm9oJPBOIEzye65NYHwnvcVWlCa92szZPPVCv1TxbdiW85DhkwpM4iwRXXMC3rlgGUzD7kLSEzXxqInlg+iiSvso2PXegqdndHxulrIYo7EwjMT1QfGYNWyJZ5A+ClOEFKPeKyPdOn77MtIByekxmX8+AsyM/f9M+I75oJXzeQ78DS7WwBIznqmzCB3/4DcHi+zTCpqT4VjGPH53i3T154FIayr2932z8LbP8PKbsJdV59RSq7xs8jZaTQF5iNhHVHeWs3ki4QTz0cu3MIksjWbMIM7Mmp9BxqUCDMH2VA== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(396003)(136003)(39860400002)(346002)(451199015)(46966006)(40470700004)(36840700001)(186003)(2616005)(26005)(107886003)(7696005)(1076003)(36860700001)(426003)(47076005)(83380400001)(336012)(2906002)(6666004)(40460700003)(5660300002)(40480700001)(41300700001)(110136005)(316002)(82310400005)(478600001)(8936002)(54906003)(70586007)(4326008)(70206006)(8676002)(36756003)(86362001)(7636003)(356005)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:46:36.0354 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7b584d52-13be-43cc-383f-08dab1cff57f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT071.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4507 X-Spam-Status: No, score=-1.4 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?1747121519465443430?= X-GMAIL-MSGID: =?utf-8?q?1747121519465443430?= 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 Issue: 3214718 Change-Id: Ibd798d18ed02df34d0b461c1aeb0b500fd908d69 Signed-off-by: Eli Cohen --- 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 acd95f2d0ba3..b9353c642b85 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 Wed Oct 19 12:46:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5422 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp316869wrs; Wed, 19 Oct 2022 06:08:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7XHyNj4eS0apfazEZ13k5ljPji3E+oV5dCABxEcTBnouPjUAUqIblVNtxshFWyBFtB2GuQ X-Received: by 2002:a50:fb0f:0:b0:458:df03:c3aa with SMTP id d15-20020a50fb0f000000b00458df03c3aamr7240718edq.83.1666184911173; Wed, 19 Oct 2022 06:08:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666184911; cv=pass; d=google.com; s=arc-20160816; b=aAdA8z0w9p2htZ7B1nov57QVzP5Hb3M4uWuRdnPjZVhGk4uUJ2uHQ4he4FKMsxRjID YYo2rBuf6Jbg65IaZNV390ZOwKVRoinTvVCBQnavtLNlWNT6FC7bV1xgYxc1f7wMwmFC EjTNZoRQEKBTVNzGmx8DVE7oFnqqRT1TC6pSnxy33waiWbIC92D2ocZKDSg2+2I736+v 5rIBVECl7+7eq+gLgFXK8U/5jl1IxkzxTbcWTCy2gmOe0bgYtpYN3YdIVEyGcm1kVgU3 HoOhH/jjZWRI8Da9+HV6NEdh1oxI8T5SmV2blDKCD7/e686IZDjjp7szfS2S5xf6eaoa ht7Q== 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=4fiOgVpOeJwDca8G6hIO03N6JKVlAOjtOTHwFoyPSU4=; b=dUt1rJ35JRaAnvRsSDHt7eTHMHBY6DdHLvbMcs+fbh0u4kf9QXFDzAsE7Z9cdKgGei 9wtPxqQZTSO3wflE94eHXm8AKlFTmQOWTdNkvDxvqtR37fDVvPL2cO8WseqgxK38qaZA cM9sNNpZepkKopNFxVvcFM6QqXQvbmKUI7QzhKlzZ+kUTFA/qp0xbd6Vpues+cGidSoc dKvguBWBNOS+5D9RkF09umUT8Fqi4IFWhDDiW00FAcGPawJPI8jDEXZtS2ixd2Jt0PiO H64tcmQX2KJYBOvmaO0g9hfwqaO94PwCC7PqXWv08qmc8m9xiTDlDpw/uHqv6za4xSLd E5lA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="iSN/73tl"; arc=pass (i=1); 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 gn41-20020a1709070d2900b00781c9c3b6f5si14086610ejc.474.2022.10.19.06.08.00; Wed, 19 Oct 2022 06:08:31 -0700 (PDT) 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="iSN/73tl"; arc=pass (i=1); 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 S230166AbiJSNEP (ORCPT + 99 others); Wed, 19 Oct 2022 09:04:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232321AbiJSNDi (ORCPT ); Wed, 19 Oct 2022 09:03:38 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2083.outbound.protection.outlook.com [40.107.96.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 634C04F64C for ; Wed, 19 Oct 2022 05:47:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SCCvp+cpqj8NZDkQy1bybKAi5LfsHAGZJuJrua/ySbibWOAQDdSUTak0MM+Xce4RmYatWCdsYrL4PI2Rlu9TOXi9On6fesmT5SL957+BVPMt4+od032pkHhIRj1m0nhvQbtdAjMt+laehA6eZjO1kaRY8cRRSF96/kqbqv/N+dvVAewOv+Jk1M+gOPGt0iHMvVUm6/AtOlMX2PIJJ92KBvnkfpKpKVH7hnI3IN59Ur6UYZQGCsBPu0yA644sxGAuh2MTMYZc9uS9LO6i3cO/+LTi+/Y1vOPvAoskLdiIIvkSNs4DcSV82nptbJQgMs/mmLHAa1Etdpk3lltWA88bjw== 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=4fiOgVpOeJwDca8G6hIO03N6JKVlAOjtOTHwFoyPSU4=; b=VfkYw+0tYmvT7D1wCYeWv5IiGFogBhl52nOLlhYZ3wrfc+z17qxrVzZFH1M8BsAiemqUUaLkvuLdUcC5n0oG1dCSrLE/G7eFlzibphd3RiSzS0IYHKf0s7pPxn5ueg/W/+PSXqigFnB3YOrYLBCkm9Z4qrkv60nqVFh2QnXQXEUsWrsgny05yvTr+o0KMUv+1Rz5gdoh/si1xQNkuP7EkBvjItiCw+xsUaqdGAIGAA7bt87gf5GMW0xA7vZPPtlztpO+bLGac0oplOxjyR7khY1Bdr5fat9SizatQQLj7vvOjkfJXTFFkQvLmB9I34zWxv8pX8gh2cwDTzH1EPE+JQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.118.232) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject 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=4fiOgVpOeJwDca8G6hIO03N6JKVlAOjtOTHwFoyPSU4=; b=iSN/73tl6pJPsYujZ/yzJzwd0MVY/yhnJPl6FtgMsCRAY+ky5Zj9pspS0+tihlKeZQ6h2F57Xo80GLuzxsIn1QeArlpD1g/c+R3frxlMieOPsCw8ynqqDYOeeWhqLV6lBL9S5DE1NttPEH8Z4Jp9eLUdNhoKbYpTxWiZIWnBr4oGpkXfcKwN0O1PXrLzRWhn8n4au0+drOLh5Sg3Athu3/ewks9+Mr2iD/1rHZamAoCpHnDBuF0Xh2VED7US56KX80A706NZjnBO/xrCjnP5sb7s+BOGGPG1qlA5cryr35hW4SXzZzCxf14Tm9g0kiYZGOPqgrNDpY8dMyhfRW0g3A== Received: from BN9PR03CA0467.namprd03.prod.outlook.com (2603:10b6:408:139::22) by DM4PR12MB6423.namprd12.prod.outlook.com (2603:10b6:8:bd::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26; Wed, 19 Oct 2022 12:46:37 +0000 Received: from BN8NAM11FT095.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::60) by BN9PR03CA0467.outlook.office365.com (2603:10b6:408:139::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 12:46:37 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=nvidia.com; Received-SPF: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT095.mail.protection.outlook.com (10.13.176.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 12:46:37 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 19 Oct 2022 05:46:25 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 19 Oct 2022 05:46:25 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Wed, 19 Oct 2022 05:46:23 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 4/4] vdpa/mlx5: Add RX counters to debugfs Date: Wed, 19 Oct 2022 15:46:10 +0300 Message-ID: <20221019124610.208113-5-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019124610.208113-1-elic@nvidia.com> References: <20221019124610.208113-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT095:EE_|DM4PR12MB6423:EE_ X-MS-Office365-Filtering-Correlation-Id: 4d7187d8-9d77-4085-cb08-08dab1cff646 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tc++5mpWXXrOb+6r7jA4ufEh8uMD4/dkXJItmJMLuGVdb+ZYZkLYLVH1pzXlPAznSmchNnG/vpE7fARI0SGyQQH+sE41Wcvb2BvqARaaz10r3t/rVPqOva0Cgmyme501ZRJUZI+eOtJWKLdk979fVqT6TlClEt7v71njSuMzuqbwUMX3wt7Z3J6iQb798XK+/hWtO+d+8YSDMnkQj24dGFw/77Kfe4aeUHvO1lzRmMkKkNh9RGWbbM0moTKFYmYpmOAaFur+DweNHWTeeIBNhzpq4/V9M5NcjBC11AN1MZlBFS1WuTxjhWPbUVy3O1Wt9BwJQl3sJ2o5V2L5By0oa3X1gg4fa0TC49UJd0uPHu8ZJOM0LVU1ndLLvmMjCrhOTi5Nwisq9KwEzyAfvVdqUE80ehvIoGk0Q1IfksW1yfHH8TxinJBue2IBVNszLzblrTuiIBw/CXvZkSOxdn5128+3GdXsQoy5MAosPOnMtrjm2qXdFnJGVAbIlljQjrBkZR2KzkOhOaYLNm8q5qqjFrp+QWDL1CkwyEkZBYTgOcEukFOhAYyBlIgIQ/xSupXsqqD1yangDhwCXQ+ID2evv394FoCESzoRU7gcTv1UNbUr8gG8x80cKIjG4Epy94KBuTllHQfeO/hh97Oznp1Q5kwUFVZQrM9YNVqXiU6fwRIaxnq1MR1j0woi34aSdE1huupT0R6XSynqsxeLOda5G+85Vn6sHbg6QMJofZg7CuP1YxU+GVVoFTPgcx/ZbSXNOiIsg0Lwgw9KTi8IdxMdLB9zGQ35+ECCBJyAttUIIVw= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(396003)(39860400002)(346002)(451199015)(36840700001)(46966006)(40470700004)(7636003)(478600001)(356005)(82740400003)(82310400005)(8676002)(4326008)(316002)(2616005)(186003)(1076003)(54906003)(6666004)(110136005)(107886003)(70586007)(70206006)(5660300002)(7696005)(30864003)(40460700003)(41300700001)(26005)(8936002)(36860700001)(86362001)(40480700001)(36756003)(83380400001)(2906002)(426003)(47076005)(336012)(290074003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:46:37.2652 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4d7187d8-9d77-4085-cb08-08dab1cff646 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT095.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6423 X-Spam-Status: No, score=-1.4 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?1747121509117764451?= X-GMAIL-MSGID: =?utf-8?q?1747121509117764451?= 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. Issue: 3214718 Change-Id: I0ca5ba189d526a09047e6ebd4ee7c5a42e4282c2 Signed-off-by: Eli Cohen --- drivers/vdpa/Kconfig | 12 ++++ drivers/vdpa/mlx5/net/debug.c | 86 ++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 114 +++++++++++++++++++++++------- drivers/vdpa/mlx5/net/mlx5_vnet.h | 30 ++++++++ 4 files changed, 215 insertions(+), 27 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 b9353c642b85..4cc674a84c3c 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1404,12 +1404,56 @@ 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; + dests[1].counter_id = mlx5_fc_id(node->ucast_counter.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 +1462,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); @@ -1434,44 +1480,55 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, 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; + + 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 +1562,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 +1577,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 +1602,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 +1616,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..706c83016b71 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); +} + 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__ */