From patchwork Tue Oct 18 11:12:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 4096 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1899420wrs; Tue, 18 Oct 2022 04:18:00 -0700 (PDT) X-Google-Smtp-Source: AMsMyM74CFdd6Af3ttWQLMaTwwNk+v5IB81zQDFTjnDAotipFifUkUH8A/Hi6ioiCVIZGWSr4Y2w X-Received: by 2002:a63:2f82:0:b0:460:8786:5b91 with SMTP id v124-20020a632f82000000b0046087865b91mr2167297pgv.422.1666091879753; Tue, 18 Oct 2022 04:17:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666091879; cv=pass; d=google.com; s=arc-20160816; b=ZyvYh+o4wXgl/5rBAS4RmVztaY+X8U7NiXmm8Ctyivxs/d9wafds1WIqocc/xDpjIo ouKuQfBIB6iooULOIHJ4i2ViZ7sLfJ3yBHbx3FxMfsxQkqXOFfL21PlGc3wdsRSIWsP/ B/zHaP0HJiz/RLdu2Mqf542xD82QhmICIPY7ugqfhg3ClJdua3ovrzBKXvlNkYgYFLVk E82rbGaq8spG+q+H9zpRbLiwJMhHuLqOAJPdjx2NxrfQYy2VtEw6Co/dMn8U0aYD9xxA AlaANMJtOKLMNEZ8o8ts5I5fsTCdzX93oIMTBrR+MBHvX6iWgeylr7jRArHGur/49fRG pqwA== 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=OeAPQEwQKuNZQMaJQlGzvdbHNmcoYOHCAFDtDi7IAuU=; b=mspiWKcOs15q9Tf2lNuXa9y5nTj31NSIWoVXx++LLof2sfDC7paVOjnxDUYVd+lpJt LQsgYajCKNRFUqV9s5VQ8veFNbm8wTOi7RLckAlbyEM828eEk1S3FMYWos6QrttmBzD8 6Z8w89ew3i1K53hsQUMwKXTO7WFc2HgLVli70I0+0f9WHkClGDcoTwIuqYkfVhj6FTj/ p7I/rXlWXo3Cp0Btby/SXpCr0ZBEG57VN1+powBWWibNckCJ3dFMLAJJ/PR0SQFGsXXJ G3cYhpgaObOvy9IcS4i2Ea1aogbWib3jnMFjckCDGsy/lwLxQirWDofHdA/6oS9MSbx9 q3ow== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=GMyd3Rig; 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 n5-20020a632705000000b00460ea4393c9si13741637pgn.448.2022.10.18.04.17.47; Tue, 18 Oct 2022 04:17:59 -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=GMyd3Rig; 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 S230071AbiJRLNL (ORCPT + 99 others); Tue, 18 Oct 2022 07:13:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230058AbiJRLND (ORCPT ); Tue, 18 Oct 2022 07:13:03 -0400 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2060e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e88::60e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F101CB5FEF for ; Tue, 18 Oct 2022 04:12:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nCvS7atpx3cqyuyZpLgu0JkqLE1VqXquJpT2uP7fh0SGDvO/aKYSxxHA1soGyyxsauu5gojId55oZHnCbKNBNkTZmZ+fKRHdvXdMN7kg6M0r0cugTsq1TyNR41mO8+H6xAEa7ESby9rQG17coUcNa+sWnNAmKmVoVJmUf9u3nX56CNK5IzN/ChYjTfRoUEGSqsJ74XqIeKpA2TOuG8aLHsBqmlnBbvx4U+zfZFa61NBJFvfU/so/FSGfeM2WbhZUw2WUqMbDMPCHWN7hDOwUT3wsLtU5NlZpWwyo2tHZD0nqzX5D8R8eEcAsncE0/MYbGIWr5CxPwQvic8Uecugpkw== 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=OeAPQEwQKuNZQMaJQlGzvdbHNmcoYOHCAFDtDi7IAuU=; b=Tmn45YB9l+tsr05PR1EvciTDmH2XlZZOw01S58EnXrvlpSRE2OaT0UDM59BqxTCfm04sdXjccE9sHjs5Sxrw3zWri5vTKxGZw3KdNsMi25LX1l+RrIH1MADkrlYT0YiqZew3MF3MTD7TM3jLxrl95eJVgEHxE00cxvW2/sHZfZXxB50HKp7l8CFxgtN0RNN8Hy41axf7vjb2MoCUiQ9AX7nKCqlO90JS4ULYHt/DSuHINlwUhiH092B5pPPDnUprPv8NzxVUfl3Bbwev55CAuijnoAO2BjNchIvjdxDooy+PZPwQ3LABlts0IK0x56AD9t4ucO3k5WK7j/MM334/Eg== 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=OeAPQEwQKuNZQMaJQlGzvdbHNmcoYOHCAFDtDi7IAuU=; b=GMyd3RigostGeF5U5g2wRda3ebn0Svm1cySq+MFUqo8pY4c8TYevDQXs3bqDqB5RPlSLiH+6NZ5g47wDfLnQvFB7eDIZOFUlgLumanSZSZZd2hUi+EF8y4QoXJjR/sPAoa11FwGZlC+UStyIZZJAjCC2b/56eJ83drfGb5U/ZClZyzBcfJPSAPHwMPRGFT5TOdJewdDN5DfxZf3ApShdKpVr0bfo1moUBItJamzFJZMLBRSosuE4foDTFA3URTxZ9vqkDogF2KWZXklu4mjcljCrUfrPWSbXZf0DiYBeQBkURzYanLB5aAew63VE3pKznKAL8M9u+p5641Rku3uZQQ== Received: from BN9P221CA0003.NAMP221.PROD.OUTLOOK.COM (2603:10b6:408:10a::25) by MN2PR12MB4319.namprd12.prod.outlook.com (2603:10b6:208:1dc::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30; Tue, 18 Oct 2022 11:12:53 +0000 Received: from BN8NAM11FT113.eop-nam11.prod.protection.outlook.com (2603:10b6:408:10a:cafe::1b) by BN9P221CA0003.outlook.office365.com (2603:10b6:408:10a::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Tue, 18 Oct 2022 11:12:53 +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 BN8NAM11FT113.mail.protection.outlook.com (10.13.176.163) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 11:12:53 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) 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; Tue, 18 Oct 2022 04:12:44 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 18 Oct 2022 04:12:44 -0700 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.29 via Frontend Transport; Tue, 18 Oct 2022 04:12:42 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIR Date: Tue, 18 Oct 2022 14:12:29 +0300 Message-ID: <20221018111232.4021-2-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018111232.4021-1-elic@nvidia.com> References: <20221018111232.4021-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT113:EE_|MN2PR12MB4319:EE_ X-MS-Office365-Filtering-Correlation-Id: 50a9beda-3aa8-480c-1022-08dab0f9b39b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K53Ol84j8q5eqbX0FCs4Cf3DlMY4lThooX/f8KFI8GeMRKW4gz5RbG2gFwG1V3OKJqZW1sd3hdGQGijPCVdDDYj9oSA8OFczAYfnP4MU0ysVt3zbkAvZ7ifGAEC6uK/VJHXLYyvm/0GmUI+Biw+e1E2abjLVOTThwfbsNweqGNI6fne+7mBx8Nh8/4Ud16r25tBhGBQOhxtyJIAwwnBNx70cQlA7R+99dqNu54JsRROSOaR4CFkwy7VBiZEY4TbJSU0KX21vXLdw84mHigAvrk4qTuhKklkh1Ce+BLnMAlU8RcxF45Eo7xvoBAe16P/1us0tJM/r5/iAe+vZXTShxZIbjmt8KKYSeIadIpaB5EIyLU6vmeIFDxXKfrRlm7/D656klzlEbx9mBG0Fa/kzl9EYMrzrIpo3qzmaTI35Ars5mkgJOObsIKta15JRJWjf9lHNV3XtrbFKHc3UYIuCMm3RHo6m9zFaLk7a0ArKHV3kPQJSQWkhG3EyrI4n2asW6FKmwBR5e4vTDL6I3851HY5Y9IHpjCem8eA3osE6TCv4DUSFb45U6DClzBOj5EVISsW837urcoliXyrbc97QyvCrpQ8T7wrbLm+h/s2KEAqSf4VH8eOi/VOCjvSLdbsSyxXAnYXS7Dk2zGpIKcrY2uhMq1OWPeOsk83MlT+6s0Br9Q5pedFKI81K0eUdRQzCo4xBNxBQe0yp3g19YagxWX90GYFLhtuidzyezeCKdcpAiLXdgMdR8SOVOawApYiZkVjs1JPK02Csnb6QH9B9NA== 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)(39860400002)(346002)(136003)(396003)(451199015)(40470700004)(36840700001)(46966006)(2616005)(26005)(1076003)(8676002)(70586007)(70206006)(4326008)(40480700001)(316002)(54906003)(40460700003)(5660300002)(41300700001)(36756003)(8936002)(2906002)(7696005)(6666004)(107886003)(478600001)(110136005)(356005)(7636003)(86362001)(82310400005)(83380400001)(426003)(186003)(336012)(36860700001)(47076005)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 11:12:53.0632 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 50a9beda-3aa8-480c-1022-08dab0f9b39b 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: BN8NAM11FT113.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4319 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, 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?1747023958596217692?= X-GMAIL-MSGID: =?utf-8?q?1747023958596217692?= 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. Fixes: baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support") Signed-off-by: Eli Cohen Reviewed-by: Si-Wei Liu --- 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 90913365def4..dd29fdfc24ed 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1472,7 +1472,7 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, 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; From patchwork Tue Oct 18 11:12:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 4101 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1908051wrs; Tue, 18 Oct 2022 04:34:40 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4dBfDYBApc/sK9Nd8frOav6+GW6CqwArMF9u5uCOitZ9+bUnkn7pP8CfjyUfLhOhReeV+o X-Received: by 2002:a17:907:2c78:b0:78d:eacd:1060 with SMTP id ib24-20020a1709072c7800b0078deacd1060mr1975063ejc.244.1666092879892; Tue, 18 Oct 2022 04:34:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666092879; cv=pass; d=google.com; s=arc-20160816; b=lKDHLfvlDWmOLqkDTWr8hLfKhTpepV0X9etWP6zdhHWn8cmWsUPN/AvNHBNDOMydNS F7LVyGGqJbaEGS9PRUUVJO+gPphwBdxhlVu897qpiRjfjeuOyy9sf8MFWWUqniSio8Ps dVoNYEYC6aYsUJw7fLwGMlu2qXoK0a+vG7gbGiDzGcatd/oOXm4yHsg0lNW5I0br8v/Y 562Da5Kia08mTF6L+ZNU7c81Kmb4ohKs326So834jnR6YDC7oQ9zS7ulKfBLiPTznnaS Mt/bxGgxK8FElFfwcyS9CYFSzvr54n3uOpHNe3O47DSIgIugWJ4Ee9fzuAbW3dGRvNTd B4cQ== 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=njaC4xSe7MwINosfRo5PG25DOaWmb+qQPh2qasDsgGI=; b=BdEPYg6pRQw85sTkd55JNNPGvhjRC9hQy5vDg5CfrgrzVvyIeXVp8aduBrRTWuZa7/ q2Avgxu9MJvjkTejpqwJnhQOiUSTNU8we5uj6S4qa8iDWMh4LY1uD1cDdbhyyhwotXZE si4+rQWQ4xhYSyhY1cNTHBep5hplXR3DXT/UNv96qx/agyL8UhmfgRSIUXnuROOpgrvR MxWUtfoZq/wVxnkcPcTJuYnJMorCzYZs+ceYUT7zBITctceQRxd1HRvAfDpWF8Xswzn0 ZPHIZ8h+1TUGS7GFeB/8s4eB1F0S+cr8PLvVFoeEz5H3QgsQK21ydzzS7nWJl1XCZ9Oq K6WQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=h0AP+bHF; 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 e19-20020a056402089300b00458cbb6b6easi10407916edy.167.2022.10.18.04.34.12; Tue, 18 Oct 2022 04:34:39 -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=h0AP+bHF; 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 S230094AbiJRLNS (ORCPT + 99 others); Tue, 18 Oct 2022 07:13:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33054 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230099AbiJRLNM (ORCPT ); Tue, 18 Oct 2022 07:13:12 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2047.outbound.protection.outlook.com [40.107.237.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFD3EB7EE3 for ; Tue, 18 Oct 2022 04:12:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ps8zGk+huHonQLEqw5FGkwWdKaumw75dwSY8Y82uDsQLaTh6QDDWnI49V6RwFAQNuxYB2HF02+rARdO/gLjDxwqc1Nse6fBNSJbt3XfsCffV7hJ1SyzP2dMUy/+rO3ciqTLDKIetLond8AfjGy8+DZkxHLnumijarJOquKXXDrTEn7qKEKVan1zWX+OnB2RBQl16NmYwXahzyikOi4YkQcKjn/bPcz9jK8Yyx9WTQvHWmdqg7pkHUp7fkPIcFDBXNa3KhCtG9y6C+kalHo2fSVs72Dt/kpYjTA4/llEqBHJ1vF+lXoHANV434ZFVedYKp19dkfAuK/XA9Ksy7UYPbQ== 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=njaC4xSe7MwINosfRo5PG25DOaWmb+qQPh2qasDsgGI=; b=mVHk2I6MAO5y6+SL4ec6HdUOy+XZQZB0L51s62UGJfKg/xtoDP71vkUJQDEvM+QQ8VS7Bca2qgQMfdh/3geyqioRx+9/hg/QS2c/sPL1CI8bocjRve+z8x1wJZnHW09XwCJbB6933ki3aXmQFEkr+pHFZfDWQwK5DyuiVNyWIlHKJ9yVplFx2auohm490EcmwuARVXzOlLRvHuhqbnc80iquTFxzO9LB0if9T378qCzlm8Ijm4GGsR91T55OW/hguAY5bcYeZsyUmT7iZENGmK91mw260PVdluCrSHSjmC6hAWDRhhLNi4ubHUzZfsaUpYRnpuB5akuH4OQbMzdRNw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=njaC4xSe7MwINosfRo5PG25DOaWmb+qQPh2qasDsgGI=; b=h0AP+bHFKZL7icy7DeBu4PLZkQFzxooqHSPq2WPsWXDKtP7YdgQyhxB6Z59TfakPz9tzY97OxvPNaldcqUsgjWEKBNebKt4GlDWkNzy7dboc5wW0wQU+ZJnikFrON5+uvM8Qze+9zjXiY7hSl3WLZ9iqAJds9yeccXc1GWp46/habVnEiw0Q+YTcIbhWcY0yJvy+iPIxExszm7h4OWs7shZ1v0bQVyuxHm3OXHPDIceyxw8mHMd7MA1FEQlMSXuWtjw74mEcDlLc8YCHGrYtOtr07WwyAfh9/lwGctI/bG3inUGLaIePiLWgFwm45P4j0glcfXPHIS0vBYJaCyMTbw== Received: from MW4PR02CA0005.namprd02.prod.outlook.com (2603:10b6:303:16d::14) by SA1PR12MB5613.namprd12.prod.outlook.com (2603:10b6:806:23e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Tue, 18 Oct 2022 11:12:56 +0000 Received: from CO1NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:303:16d:cafe::de) by MW4PR02CA0005.outlook.office365.com (2603:10b6:303:16d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Tue, 18 Oct 2022 11:12:56 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT061.mail.protection.outlook.com (10.13.175.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 11:12:56 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 18 Oct 2022 04:12:47 -0700 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.29; Tue, 18 Oct 2022 04:12:47 -0700 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.29 via Frontend Transport; Tue, 18 Oct 2022 04:12:44 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 2/4] vdpa/mlx5: Move some definitions to a new header file Date: Tue, 18 Oct 2022 14:12:30 +0300 Message-ID: <20221018111232.4021-3-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018111232.4021-1-elic@nvidia.com> References: <20221018111232.4021-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT061:EE_|SA1PR12MB5613:EE_ X-MS-Office365-Filtering-Correlation-Id: 167d6632-c02b-47bf-48ec-08dab0f9b592 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c+ot3ua6bvi7gdHdb+Nsuzl14aPyW6UV39mcIs4U1QiqPkgu/erC0Wu/WIK8go4A3gEiutLOxzYuWz9Z7qxMDJXyADyCqWICyPiw5H59O54TS5AvCtRKaJQm5q0z2GuNGIbCc1Up4Sw+WLkBIZGtAqhvtfatBcQBS6l2WSiAOWv/FZGzYcTITIqlT7pgqtwSYOYT0xjwiDXkc+7ANGIs+VjkATBponh+fJKgR//7RDyG3QmpOGqz8iJ5pno3aOELUuO+tTKkI0g6jqINSGb5r1hTqQkUxnmXXVwUOFizckaTFbs6JDT5H0tTT/9thYcKMHwOzxpmd/JPo0jdCliSNHZ6N3q9AoYPi8RZyGmn83nBQaxHOHhghhfG9cXU0vNbGqcp0L9jiF2dp/E7WYH4UyVjIvoSbL/gIXGpiFoVM71p16SPTnqkOP8DuTw5HcN5/MO1Bx6KA3tCW0pniE14nqfhxMzWB9wEaTH/xeFEcqIu3h5lsQHmrPFADzH+RvUJOFzyuLZ27qWyUbG5BJFkmTMSG8xnLAIvJOH+YPxnsLaAAn/2lIBZy8dNYWxFsGJepJB8f1VcLSPP3Ib9iuEcqAlEW9lCM6J/lB8N6r909LGmnoeNgKKfkPzi+iGs364hmQZVgVK3GL2Dr75XX8el9nGzkEIkFnYKAwnxLm+buIe7TPuIswQvaG2ZxBDIGRFA1/+HqqeMekFUgAjyUMukWeYW/WyAbD0KWvGBzvm821nk2Hm31bOCQNosvN3Q59Z3kClu6iPPhHVuInRmpvB8yA== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(346002)(39860400002)(136003)(376002)(451199015)(46966006)(40470700004)(36840700001)(316002)(36860700001)(8936002)(26005)(86362001)(2616005)(5660300002)(40480700001)(36756003)(4326008)(8676002)(70206006)(70586007)(336012)(107886003)(6666004)(41300700001)(186003)(2906002)(1076003)(7696005)(426003)(47076005)(82740400003)(54906003)(110136005)(83380400001)(356005)(478600001)(82310400005)(40460700003)(7636003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 11:12:56.5017 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 167d6632-c02b-47bf-48ec-08dab0f9b592 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB5613 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?1747025007950968487?= X-GMAIL-MSGID: =?utf-8?q?1747025007950968487?= 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. 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 dd29fdfc24ed..64fdb940380f 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 Tue Oct 18 11:12:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 4098 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1905545wrs; Tue, 18 Oct 2022 04:30:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4MW2cNQ5j4yylI92chqRHFGfa8USpwB55wZaf4Aio0XTcaI5Hp+2LJzX+un8ATDFbAZHrV X-Received: by 2002:a17:907:a047:b0:78d:9b73:79bb with SMTP id gz7-20020a170907a04700b0078d9b7379bbmr1956121ejc.657.1666092654349; Tue, 18 Oct 2022 04:30:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666092654; cv=pass; d=google.com; s=arc-20160816; b=Ji/RKERP0LQI/B1GEs40t0HLeIG0tij5m9qh6b+PXwVY6/TMY8SPooVDC8iHak9uLU gcX6XhaFikosDkouBf16crTiiUlhAw7DfFe06ruD7mUHli4zTDrBtuWFhGIWOUtsZoAt qV55rbpl5Dfpdrc9Gn2du8AqSEC3Dz8bKlemxWHlU3gkfEFxtMSDQjbkmUqhFNoJVJwX M9+ykmH24USARGZfF8hN4m5f5wvzWIhGEi3fVxZIX14Q2tZi7OVvzjg7aMzeUaiA/4hP /WDHngwXkLksbU80qBcR0zDl4+gnbdnwvkP3mXAsNO2Wtz5ooonnMNWf+65IyDjV7Pr0 UgUQ== 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=UeeLze86q2FxnlzG/L+943BBAhWNKfXdUDu+jSAdu9Y=; b=V8yZ/QU99ZgqfDAOBzfT5w+choS8IhcWDetjYUtc7TsR0Ejzf/CxodapZ7B5HX6x+M uNTpjT4sjApQn8yabMO6zyyEBTMKCgMmrQpjKgtoHMoR2MhLXpdeunvSf1kAyciZ+Ox3 GfV060Glwx1HjynL+gBBtXU/tn+lD0+5IEwwiYr2ytLs3/ULf93dkEG7TTlCGKZv3LSU AYbxS/92Qu3QealoE3FCK3ES/jVu3n8JxDvqVibGvvuZFaP6XLqipif58uqxz5HwRSx0 LDUUfTSxmdUcGcIx15o6OCh8VRYnIG6F+trlawbpTTTc3eO7iQq2rr8a3wPtOGzncpE7 uMLQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=rWR969YM; 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 sc12-20020a1709078a0c00b0077fadd74307si12798344ejc.128.2022.10.18.04.30.29; Tue, 18 Oct 2022 04:30:54 -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=rWR969YM; 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 S229746AbiJRLOB (ORCPT + 99 others); Tue, 18 Oct 2022 07:14:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230198AbiJRLNp (ORCPT ); Tue, 18 Oct 2022 07:13:45 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2072.outbound.protection.outlook.com [40.107.223.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86B5BB7ED4 for ; Tue, 18 Oct 2022 04:13:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MVPPtsbyVVsEfDc8nAuK3pf2+LAQ6gVuV0EGYYqD5Gnd6q96w5nfDRv3sjyXnEAaMozpzyMnPjG3eXDcoRj4aVIxbCHv73zNxTVFyBqQXmdfLPIavvlCcuvRraTZ+Dxa3FuPp/TJfpKyOkON2k4OkMfycebYXg7WdA7mMzKuEXRmU9zK76YxSd+TW9alcNFtLpis5tAUTGN3RTAlsPLohvWwVuNff5I/FBDiG8MaXeADH0oCtDYQmRBesrwrv3TnePZoPTX4MzRBIj0jYmK28eeDGBXxFE1TwPJ4BJAsx/iEKrGexRlUdNwRaKG152GsqaarB3KRSka2U5brdF/0Yw== 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=UeeLze86q2FxnlzG/L+943BBAhWNKfXdUDu+jSAdu9Y=; b=UDDK+ZgofsRnNLEicOD/wOr0E/fNqOp5YUPx6EVjmDCYlgY6WUZZvC1ZWU87/RyObIaByRQ26qaxrpo9d5G4YV8xyfmGd13S4vPdy9apqS93nX+iFHWxRliG22GxpOdl195gXMv5wa+/Z8HJq9CgrLyNzrrsb0or52nTrxZdYXhM2ObNr/frVRm67FMYSWihrhX6sg8uq7yAdGqYgYH1dVXnfg9axMZ9jiRnyjoyzMRXXZw3exICZcf5b7pJpx+qFhndo9ft5rYX2dcPv7JUrOlw0TaqdfnbUck6wEZ5AdbhxemhSCnskYL73PJ4lRQDFP1jHIaBC2bF6kTmETjNyA== 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=UeeLze86q2FxnlzG/L+943BBAhWNKfXdUDu+jSAdu9Y=; b=rWR969YMDgSSSW2tD6rlzIMRpWbp4ZjlfkVHceKH9RNnHeT2r2/CMn+ePq5iB34p9ZkjzpiHMlOmTmRADyD+fP6MwbS2c9M2I8vJZ8muqLsloUovZhmxQIucIqULPNRqh1PY0nBjJbCp4ENQYg7qG8efc9eHvIbrzCZHUcWOMYxc2QQRJz0lQS9PynzMgJ4mmEtZZyPaJwQijUK2yCBJ8eMHk8XEHjb3lwDTn+IG8VPI+qnVfVav7HpFVgO6Kmr90WPktDhK4QLuxJpCwVoepoxOc/VGVxHUncHHlTgCYC8WI9fJi+HTndm8j2A8wMMnRFjD1TuVhE9wteBJfzNzdQ== Received: from BN8PR04CA0059.namprd04.prod.outlook.com (2603:10b6:408:d4::33) by CO6PR12MB5396.namprd12.prod.outlook.com (2603:10b6:303:139::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.33; Tue, 18 Oct 2022 11:13:03 +0000 Received: from BN8NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:408:d4:cafe::67) by BN8PR04CA0059.outlook.office365.com (2603:10b6:408:d4::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.29 via Frontend Transport; Tue, 18 Oct 2022 11:13: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 BN8NAM11FT005.mail.protection.outlook.com (10.13.176.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 11:13:03 +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; Tue, 18 Oct 2022 04:12:50 -0700 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.29; Tue, 18 Oct 2022 04:12:50 -0700 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.29 via Frontend Transport; Tue, 18 Oct 2022 04:12:47 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 3/4] vdpa/mlx5: Add debugfs subtree Date: Tue, 18 Oct 2022 14:12:31 +0300 Message-ID: <20221018111232.4021-4-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018111232.4021-1-elic@nvidia.com> References: <20221018111232.4021-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT005:EE_|CO6PR12MB5396:EE_ X-MS-Office365-Filtering-Correlation-Id: 997c95ac-2e83-45c7-9238-08dab0f9b999 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: UdzBVtPcDX+Fj+Jp2yDqgxbf+9tSTkaXk+pz5WSRrpKioRCbnI/JtmOKhH8UHxCWHoQ0YNvVfSquHd/4c4ophhBXntHmbw5F6CYffMk5Kfjb7e1gYeOwxmgKAT24YNHnfxvaCY+ml7Vj4RdoL37Wr3Brk0g/zvGRQuBcan/uogmtOCMeytp4gMUD/+DONjYp34jtHvySa3srAxtLHKCyW87QHNeXeXhcZ7Wv7+DjSgNhFRao+BHnT2TLNOVKqKT+CCpce09rhmaphnTQOW2Pw4GX79lOP7joJJ8Pi1/ttX5IuNuJDBBWj9Kr39XYYvc3UKyrngHviZx0GeC3A1OhTLIj739egwzwDUb3H1doQfEtmDthCOlAuDQhO8ir/pGzxAocO8QdYj+0uGuD0kn74Wb+xAsOkyGVDuBAA5TdcmjtIDH9JWcI+rtMxywSB684u0/mzuv417a3j+UYKFJ2vKoCRT8RU9WlbEBWYrlANtaWTP5iE6QnBdjiuWroD/BYauiJS9NvTrLE4VGX18SKtfeXX64gLruA1hN5OG+4mVoISH3p3Nhv6ywPrxFdVhK2BE2zXVMTO0ZD4USzIFQ+ce2ilZIp0eozLsRjP1CygM/nOeqwgPCIRtipcciMy9XSCiudmTUlPyR/ktsJnmAirn5GPaxH5Fzezz1LDwgngnTvvJp3juIWBLdw9uSny0bm5JMWqkV43n/Kt+MrwLSZ59VgTNCpjdic9AzRF1HaUn53Pyhum1xuj9WjIp9JT9ZOOtK0jSgN8F86K1pjExKOyw== 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)(346002)(39860400002)(136003)(451199015)(46966006)(36840700001)(40470700004)(478600001)(26005)(2616005)(426003)(8936002)(5660300002)(47076005)(70586007)(316002)(70206006)(40480700001)(4326008)(36860700001)(6666004)(107886003)(336012)(40460700003)(8676002)(41300700001)(2906002)(186003)(110136005)(54906003)(86362001)(1076003)(7696005)(36756003)(82740400003)(82310400005)(7636003)(356005)(83380400001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 11:13:03.1041 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 997c95ac-2e83-45c7-9238-08dab0f9b999 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: BN8NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5396 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?1747024771182850538?= X-GMAIL-MSGID: =?utf-8?q?1747024771182850538?= 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 Signed-off-by: Eli Cohen Reviewed-by: Si-Wei Liu --- 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 64fdb940380f..ee50da33e25b 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); } @@ -1576,6 +1581,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) @@ -1584,6 +1590,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; } @@ -1591,6 +1598,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); } @@ -3167,6 +3175,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; @@ -3193,6 +3202,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 Tue Oct 18 11:12:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 4100 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp1907375wrs; Tue, 18 Oct 2022 04:33:27 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Iu+zKlJGcALqTC2DMlMsa7Gne3qSZqBDDUi25A79U7DKMz97aJvamq4lYwHyXvQFocgkq X-Received: by 2002:a17:906:dc8f:b0:78d:f675:226 with SMTP id cs15-20020a170906dc8f00b0078df6750226mr1995384ejc.745.1666092807207; Tue, 18 Oct 2022 04:33:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666092807; cv=pass; d=google.com; s=arc-20160816; b=JTQC1MOehwuPRfI6vmsa0rEB1RDtZ6UCSSuqZhLodOfuha8tJvSHn5SY21sOXouyix CIMKkHW8Z+VT+L7Ud4m0HDEdFRxQjvMTg9l1PJiBbQGyy8lWyZ4hWvAOXuNsmgCGJl+w 4DxaJQvGp6j8hmruAEwtFVTwi3TnNTVqtwLjrYHQdymxFkHDNo21+oPRX9ktmtbMn+4K 47vuqxFggd560yH0XHWpWRo+wsKtp1/dIYKlMiQiSHhsZRHWyj/ndmLh+Ag7D0qvpThj ASZ+v/wTGn2E7e5ZeOLu5O9NkkeZ2592WiyVQ44f5WOvBE8crvFQ93XqXvjjY2Q0pEZa FFwQ== 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=sec6yJWfGN4sUqUGqJmE5wePIrUcnWUlMh3tejt0kiY=; b=vw8srgJupWjRchCVjJop/L7xc3/Y7jjiBbEVhvbY+uD9hiotQmTbhqauVkemsNmEu2 irlSKyif6IuG+J82eru0iRZ95qU56zqBsEAlR49tKmUCs5cSajzf76L6C8ks3j5RQ6xy GRIBi3rsnWv1FU0RYGRF05dgmNvIbcIP3pqDArfTgANR8eKYt7z36orR6qWYbJbDdyXg KZENUR8ARIH2JkoylCY3t9f03ssqw9E5yXe3pXHZ95qXXCDxn31Sgx9W3dPIuYOTZ4pv Sk6QDBSuyuTe/GI7gWT03cucBG/oEc6oqLxd7+zGnIG+cl+9OnRADCVWlHiT7tVd+quE JMjg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=aRdgHWmP; 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 cn4-20020a0564020ca400b0045c4b1f4315si10467523edb.485.2022.10.18.04.33.02; Tue, 18 Oct 2022 04:33:27 -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=aRdgHWmP; 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 S230178AbiJRLNf (ORCPT + 99 others); Tue, 18 Oct 2022 07:13:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230074AbiJRLNX (ORCPT ); Tue, 18 Oct 2022 07:13:23 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2048.outbound.protection.outlook.com [40.107.220.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48E9EB7F44 for ; Tue, 18 Oct 2022 04:13:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KJvC/SuruslWpSBV8yMuOVIwAItRYG/4dTfkSdHXmSkUGaG1OjpNILrTjRGxe6HTRWqo4diEzYduxSPZwv7O0xKAHQ+lhVh02CNdlAB+UIV/j2q6srJ9+Jm3lofgnFSG1c6XGM7RJ8DOP2yWVL58pyeyNw4FVeARoH50fhPaELcuMzKdjq66CVPGXqSCuVtohfVFqoAZZkqnceEdXLc3nXysL5HJgcmE43/Ox0yYsZN2z+5IMNACLuBWzyMbnpw+Su/v4ThQFrfYnC3LHZM3KEe4xW5uzoRx4hN1TTNzQmDGyKFAUXUxgCwEp6WIj1BX1EzHgTDEegLDwj8oPMAEOg== 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=sec6yJWfGN4sUqUGqJmE5wePIrUcnWUlMh3tejt0kiY=; b=FmIiUe1sQAylQuC/G/cIFAYwnfZyoR5lHvXkVf58FZk+eSRmfzOyUfb7KGdqMuYQ4TTdEihYaDW9y2l++rLagpd/ARtVDnTdl6JSWqP0PaUgn4r2NODQJM1prmr1QhnsN771+y7FiS2bV+u7h/7o/Z6a6JFE8VTdz9H+7FLTrPuTSBIhwo7LTOUwOT13oE25AyDcATm7Y06574xcHfoX/9KTcJ8osd4wGrO5mxXOnPbDn7aqudW/7KcSnKpubM/uoDzckOeLFKlwIb1BXMSTJipbsFoHCwpB3f4QuFDwrNfS8qcEynqNv0yJm31ni/ou6ofZ3ABtyCrLYIX1KmXOWQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) 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=sec6yJWfGN4sUqUGqJmE5wePIrUcnWUlMh3tejt0kiY=; b=aRdgHWmPM0wUc1qzmSjpd4Wb05wwYALA2OMBPSpP5ODw9LezBUxlMCHyHN+YMksmDFuf7L5Z3SRNjhDSOIfJL6D00d/JQZN4Ig/KJ0lGiIAjGAo7xS+lZnq5f6T4fKhW8XUE+yUZt/Rb/0jBJeKVroYthS0H4Xn01EFeQduD6ZPNUz0JK3hhyPAqDZRG5QKBuJSh4NuwxbqTBoY/Bovq1qY+NtETxOIMXOgIo8lXjcgx/yIkBCuVcKPExO0y8wERYais/1HwzMW6wpWE1VLBxemgPiPTr/8lQtRlQIrFOKfmyH3zmEhTa0mvU2cpIUjX6tim3V8YfJOLUIDKTcqdzQ== Received: from MW4PR04CA0240.namprd04.prod.outlook.com (2603:10b6:303:87::35) by SA0PR12MB4400.namprd12.prod.outlook.com (2603:10b6:806:95::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34; Tue, 18 Oct 2022 11:13:01 +0000 Received: from CO1NAM11FT063.eop-nam11.prod.protection.outlook.com (2603:10b6:303:87:cafe::a5) by MW4PR04CA0240.outlook.office365.com (2603:10b6:303:87::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.31 via Frontend Transport; Tue, 18 Oct 2022 11:13:01 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CO1NAM11FT063.mail.protection.outlook.com (10.13.175.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Tue, 18 Oct 2022 11:13:01 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Tue, 18 Oct 2022 04:12:53 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Tue, 18 Oct 2022 04:12:53 -0700 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.29 via Frontend Transport; Tue, 18 Oct 2022 04:12:50 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH 4/4] vdpa/mlx5: Add RX counters to debugfs Date: Tue, 18 Oct 2022 14:12:32 +0300 Message-ID: <20221018111232.4021-5-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221018111232.4021-1-elic@nvidia.com> References: <20221018111232.4021-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT063:EE_|SA0PR12MB4400:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bfbe015-bce2-4829-ba9b-08dab0f9b8a3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lSQ111y6G85WUoXlS+jodxNHAJ2RAGpX4jmIJHpS2cyhubZzXkEL2PO+b7VzKrzXIFv4D7PVVKu/pgIVErC43hTu21SWZxRsQKkuDPhh68l8sHmbqStC19KcbQ+XvgNZxMjNtTB2wc8I8Rni7J9WJyOmr/81dRJixNm+Wi/D2P84oy7U0EKr043c9hkCF7+b0wFFffmePO9k4Y1odFfWRnq/fCaMv6mlnD1Bd1Y3iMR9alkYMP/2tlmPvk6abg9vcaAEWVnG3VNFNmXCzshfB+S8HPAsfclaqbQus7JGQZv0r/VzuK3flnASko4FnfZqrJqI3lINSx0QXv/Wk7NCZ1PG9zZd+ZfRG0SIXiv4c+Mb79HLp5iy8DlxwpdWC6RqVYuc8qq1B85L/kN13V80/z+pTCHWtsqMmj6PELiA3T+IvYkbBzaSRMo/7lCRLTIJBSXKR2vo1hPkru4nSQLQruF7DPGL6bPrQx0S7ROD7t0A7v/jfkg8w+flOX4uuKoIDqhlKFx/DQY0HKPUWiKgdK6d8bWjHdPQ7gu8Slet0VhRqxoMPhiR/gMekIFFzJJoUVcH/e7BfUJ7sbCmU2rIyFqTeZwZ7zA3K0GwXBRGVwZ4IC1f1HRvwa4eti6ZCYkxS6G9MQqCcN26WfVFdqLQ1iSVWe1ly/pWEHxaLtBEGuPhadqSHMIf+ATFKK/mMg3OwKoEqVBnOW7q77FmjyicQiHnyDmfPKrD+vNWLZR1HpFgEU9o3jXfSfM7Jt7q/w1ukGfl/TiDutBDRIeGKusQcU49tSkVq973/cb6PY3vdFc= X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(396003)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(186003)(1076003)(2616005)(107886003)(7696005)(6666004)(26005)(36860700001)(83380400001)(426003)(47076005)(336012)(2906002)(5660300002)(30864003)(40480700001)(40460700003)(82310400005)(110136005)(54906003)(478600001)(316002)(41300700001)(8936002)(4326008)(8676002)(70206006)(70586007)(86362001)(36756003)(7636003)(356005)(82740400003)(290074003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Oct 2022 11:13:01.6492 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6bfbe015-bce2-4829-ba9b-08dab0f9b8a3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT063.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4400 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?1747024931500222313?= X-GMAIL-MSGID: =?utf-8?q?1747024931500222313?= 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 | 82 +++++++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 94 +++++++++++++++++++++++-------- drivers/vdpa/mlx5/net/mlx5_vnet.h | 30 ++++++++++ 4 files changed, 195 insertions(+), 23 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..35137a36433a 100644 --- a/drivers/vdpa/mlx5/net/debug.c +++ b/drivers/vdpa/mlx5/net/debug.c @@ -49,6 +49,88 @@ 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; + + 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)) + 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 (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 ee50da33e25b..1b850d0aee99 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1404,12 +1404,16 @@ 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 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 +1422,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); @@ -1431,45 +1437,78 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, 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 (tagged) { + if (node->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_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); + dests[0].type = MLX5_FLOW_DESTINATION_TYPE_TIR; + dests[0].tir_num = ndev->res.tirn; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + node->ucast_counter.counter = mlx5_fc_create(ndev->mvdev.mdev, false); + if (IS_ERR(node->ucast_counter.counter)) { + err = PTR_ERR(node->ucast_counter.counter); + goto err_ucast_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; +#endif + node->ucast_rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, dests, NUM_DESTS); if (IS_ERR(rule)) return PTR_ERR(rule); - *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); + node->mcast_rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, dests, NUM_DESTS); kvfree(spec); if (IS_ERR(rule)) { err = PTR_ERR(rule); goto err_mcast; } - *mcast = rule; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + node->ucast_counter.mdev = ndev->mvdev.mdev; + node->mcast_counter.mdev = ndev->mvdev.mdev; +#endif + mlx5_vdpa_add_rx_counters(ndev, node); + return 0; err_mcast: - mlx5_del_flow_rules(*ucast); + mlx5_del_flow_rules(node->ucast_rule); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) +err_mcast_counter: + mlx5_fc_destroy(ndev->mvdev.mdev, node->ucast_counter.counter); +err_ucast_counter: + kfree(spec); +#endif 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); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + if (node->dent && !IS_ERR(node->dent)) + mlx5_vdpa_remove_rx_counters(ndev, node); +#endif + + mlx5_del_flow_rules(node->ucast_rule); + mlx5_del_flow_rules(node->mcast_rule); } static u64 search_val(u8 *mac, u16 vlan, bool tagged) @@ -1503,14 +1542,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; @@ -1518,12 +1557,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; @@ -1542,7 +1582,11 @@ 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); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + mlx5_fc_destroy(ndev->mvdev.mdev, ptr->mcast_counter.counter); + mlx5_fc_destroy(ndev->mvdev.mdev, ptr->ucast_counter.counter); +#endif kfree(ptr); } @@ -1555,7 +1599,11 @@ 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); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + mlx5_fc_destroy(ndev->mvdev.mdev, pos->mcast_counter.counter); + mlx5_fc_destroy(ndev->mvdev.mdev, pos->ucast_counter.counter); +#endif 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__ */