From patchwork Wed Oct 19 12:54:57 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5431 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp319922wrs; Wed, 19 Oct 2022 06:13:59 -0700 (PDT) X-Google-Smtp-Source: AMsMyM52AVBm/311OlQctMOL6np2bAr5SnHZ5mVoqakRxZabiX5gg1FUvyQuEdEsjLNl29HGVa1o X-Received: by 2002:a17:907:2c4b:b0:78d:8621:c113 with SMTP id hf11-20020a1709072c4b00b0078d8621c113mr6388028ejc.364.1666185239748; Wed, 19 Oct 2022 06:13:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666185239; cv=pass; d=google.com; s=arc-20160816; b=fIxfS5494IYyxB0rMYRYSYu7+bvO2bKSevtS9haVih0smNV7kiZ57g3TeBFY7UFzO2 jDQfB06odSeYt1MeXj80lcEzjaaERDEalvzT325ZXkY6eEFjs6abo4hGKJQsbMAdeiFj QrYdtkDOHgmO7Hedwf4yM2e6QdNZAfqx5SLmS79WaI8N/GWRzUTVPt5rzW/qHdRNa3oP /67N7xBDTacsinG2TvLgGyUere8HQ3n+d1ZX0h1I5DM+ptuXXWCnYZQKK6OIyM04GKKA tigUEzsK51GH3wz5l8PxJJVr05eJQ/tONInMtYS3+a6ZKzpmIp8/RA98KE/Tf7GMhd/S DLiw== 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=02KiW4Q8qfcZnsX/w2U4lROfID6YDRMLCnv6M4TGowc=; b=1DRtkq0A3TlRRyhWRQrSzZf4FUC4dFVjcPnCIHw6MWkLWzFhOHzpApe2Qte+w6vJi8 pT4eQjbrJJP0Tu2hZT/1tc6V5UiM0e+j72KxCMB9Io/bL1H7A5FJUlZNXoJhzEGPB3cF nX8J5W+55qLldUxZ35asTyMPt89veMc2DIrpbqtsEgKZRoA2XtTH+XfV15vTdAxtqZWU WO0HQ9S2KOE+7e4lYupYhmBvjH6WEcHVR2YZlZ+lt4+P04I7uWBYkXjhyi96q8H+Mzlu ZBdo5ZBR2lu1pjGBhsb8r7/+Lw+vkcsjTC9otDV65YHg8y6SsuN8kOFzGSfY2QGOCftc IPPg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=fjaK1AvT; 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 m25-20020aa7d359000000b004597aa082ddsi12080677edr.257.2022.10.19.06.13.34; Wed, 19 Oct 2022 06:13: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=fjaK1AvT; 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 S231223AbiJSNLz (ORCPT + 99 others); Wed, 19 Oct 2022 09:11:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233290AbiJSNLh (ORCPT ); Wed, 19 Oct 2022 09:11:37 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2040.outbound.protection.outlook.com [40.107.237.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D94A9101C7 for ; Wed, 19 Oct 2022 05:56:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GajI+GJ73fk8m2+hbixkjMcciviltW+Zz9hXLGrEVEuDTqK/v7sIREV4+eezZr241O/+SEbQc9JBHtUuXUnTOSIZ5jvtr3B3pAy/kClXNT23IDUHJ7IDgJB3whWidUFmk8ph6RlI46EH167/m/4PyZ/6ET0Amj45r1GDYG4N4WVVapStC8G3EbrJqyp/k8npllTUmjWtm5CF5Oc7Yl643PKN7KgXXKXz3Q1uS/+W64fg+KeEAfQfF+aU46ZJkZnfXpnxKmzXvxHetlNP7DIAklNAOB/LMaLaxRSy/D1osYhotP/BonUKXzTJIHVVuqt1csqN+ZcLoAf4bfIhqHw9CQ== 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=02KiW4Q8qfcZnsX/w2U4lROfID6YDRMLCnv6M4TGowc=; b=C2zzIiXyAF6SF4Ue73u3SS7wb10L5EziNUMI/hYWOyzaYCZDK0TGMtcJHu4WHSNZjy6fF7Ocuu+dJZya8/Yjt4Vq9olH7b9RIp5Y+3zyDVx0loBbVXut/VhGFp/1oD7sOjLXPEFl51zTYDfuZUH3cl7ChV/ycLPJpiLGUjTp/4wlZ7gezlc4KtTyZVmGI2BlIvtEPpZVaH8tQyeJxsYAWqqZZW4cAa5azU0xJmlseBFv5kjAa+wEKuya5kl3j8nND6onaq2viTvr8defoLMxRaaZz1eX4Pr6HS6HZHTuPYADHPk55YrpMnHDYxv7P1Y9f4VBPHSpXh2/VR6sEuN+ZQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.117.160) 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=02KiW4Q8qfcZnsX/w2U4lROfID6YDRMLCnv6M4TGowc=; b=fjaK1AvT2pmChVHIsIS77rKS6wvhniQmtY5Adj27GegYXSsfWYsDV4cbBznfxGBfmMwpBrsmKNO8pUa37XB+XVFdKdeB2muIDBWAszWbxEbjePoOkZW/ZXquW0uYxhAe2+XGikWiRVikWpitclULC/7A8lso+dQUQMieDYneqV6lpJLBa2jGiDYBO42Y+ZXOBPfnysvzbVmKHuYldAJg6Uykgy3JepIVfZ9q5P79X+VOS+lD9FCW6LjwT/7WwaHYF5ukJDpq9SwRKj/tWDFZM9utYSXtqJsvSeV31Hawk6Y2rg8kA/rl0DNNLmT1Vn+nQEpljjoIPZioDhGiGi36dg== Received: from BN9PR03CA0630.namprd03.prod.outlook.com (2603:10b6:408:106::35) by BL1PR12MB5222.namprd12.prod.outlook.com (2603:10b6:208:31e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.29; Wed, 19 Oct 2022 12:55:19 +0000 Received: from BN8NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:408:106:cafe::c) by BN9PR03CA0630.outlook.office365.com (2603:10b6:408:106::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:55:19 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.117.160) 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.117.160) by BN8NAM11FT056.mail.protection.outlook.com (10.13.177.26) 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:55:19 +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; Wed, 19 Oct 2022 05:55:09 -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; Wed, 19 Oct 2022 05:55:09 -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; Wed, 19 Oct 2022 05:55:07 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 resend 1/4] vdpa/mlx5: Fix rule forwarding VLAN to TIR Date: Wed, 19 Oct 2022 15:54:57 +0300 Message-ID: <20221019125500.208841-2-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019125500.208841-1-elic@nvidia.com> References: <20221019125500.208841-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT056:EE_|BL1PR12MB5222:EE_ X-MS-Office365-Filtering-Correlation-Id: c35ebed8-6de0-4cf1-c7f5-08dab1d12daa X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HuVwqznueACZSI9cW+dYmuJ0uUzxAURefCaSLEftRAKeQY+GLhCEeNn6dfRqCuU/VbWE7zJwUgh213zO4Yr99jR82VmBWPcckNS3FStR8YO3MsjlK58AQqoMcixO0qXnUQpBl7GUYnbx4LerD5FZ6W9SAKgPU6jMPkDHOKhgfaHFgzpKYhyK0yrhJs5V0UgK03riw+oG692fITFm6tfLijmmg5r9Iv0T1L9Ia1EkoztU99xN7LQ4Llla6RKnWuw1El86fZnZSBYmusXPH1sIni8iMrYwqgs1/ysmmyMW3z8onT46DeSwAV2c/NGgFgiS6UjhOPseYF0RJVAWcLuzmxpQI4nmy8Sdfuq5Kd++yOKYwEJjK8TFYBli3hXEchN7pjBwDCyNo7ZCMgTpNieR3Na1VCKQlk59TX81aorfoSkBnjdKwGkkPfP8xOjdhwUug129V8VE7RZDHoO2C3AETOL243GqFPZMm7CaM71oSDi0Y6En1N8WsHZeliCH53S0GvBayUdh0fBPQ/OlHw/ShaMNv3/0l1hHmz58gCetrKFpQDSSlvCKlNgIWhsWoIXtXkSS2R0IKp7EQ6j6+jbqbnqS0TL8ZtWfEsiVv5tZXy+hObZmqlvVtKM5Xuzik6EJmqOQl8HCfDw7yA0+m2pv5xSJbXfH0abg3qK/b+ooDAirgjw8WXiD/pHg0u4XyUT7PHSPrlgN4re9TaLgm0Y5P8K4QvnCRA1J2/qkkYrOMtxSHYTSMjaIN1k3NIjf0h1gmyZRfBjO/dGZTgKLIpQHbQ== 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)(376002)(136003)(39860400002)(451199015)(46966006)(40470700004)(36840700001)(316002)(4326008)(110136005)(186003)(7696005)(2616005)(40460700003)(36756003)(54906003)(26005)(8936002)(2906002)(86362001)(41300700001)(83380400001)(47076005)(6666004)(336012)(107886003)(70206006)(70586007)(426003)(40480700001)(8676002)(1076003)(5660300002)(82310400005)(82740400003)(36860700001)(7636003)(356005)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:55:19.6763 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c35ebed8-6de0-4cf1-c7f5-08dab1d12daa 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: BN8NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5222 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?1747121854094253502?= X-GMAIL-MSGID: =?utf-8?q?1747121854094253502?= Set the VLAN id to the header values field instead of overwriting the headers criteria field. Before this fix, VLAN filtering would not really work and tagged packets would be forwarded unfiltered to the TIR. In addition modify the logic so that VLAN filtering is enforced only when VIRTIO_NET_F_CTRL_VLAN is negotiated. When not negotiated, all incoming traffic is accepted as long as it is targeting the net device's MAC address. Fixes: baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support") Signed-off-by: Eli Cohen --- 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:54:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5434 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp320101wrs; Wed, 19 Oct 2022 06:14:25 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7OptkcHhq+jvMCU0pChFTGQlDfujAxNCw8qHc6TjbtyRuG3LvIscJiuzE48P3lA5lTU88Y X-Received: by 2002:a17:907:75d4:b0:78d:efa7:f78c with SMTP id jl20-20020a17090775d400b0078defa7f78cmr6536558ejc.454.1666185254398; Wed, 19 Oct 2022 06:14:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666185254; cv=pass; d=google.com; s=arc-20160816; b=hL48jZcW2K3VGnJxN33CTWyDRi3QUsHedmJ4Y47AU3sZ0/qseLnooFcgb/5y0wD8Qt q/5sDFcNhD5QRjVg/oNvllI7z+LJhb/gJCsngnv+B3MtahLJKrP8tTlOSsTQcE1k3t5M i9hrPQyN9GJ1rSnmIRBYGzEnafDF3sBww8d/MCmUJdZU9WMYPJiT+8Ms2uNo9UAcaGmu T3A2RUA1XoHdasYUTFMEdhpC5h4OGNvqGGny97SQYNRF4Kuiv84+qKq9kCRzq93X4+bu KCR3Pwr71j/yLAr5SLD+/Hc9128n4UEgcrH1n3+PGi5zn6l7uus2cBnuE7NUFfGmZtct lJ0g== 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=oDOkZSa0/v0kkFguBysT+WRyNN/qW8l/UoHVSPHkuKw=; b=OJ/mINmreW/lEbm8lmzprGRYhyVzPVlPZihB0fr0bfSewM8X/umB/cHZkT3BlAnRn5 kAVoy70SLWEFpmQLUQw4vcmYsKkLzMNVW+kDdOc/KzJ7kGJVRjlRJrBDqa+J1uY/vy9o NejtsETEPuS42Mq9ajycyqFQrGgxScgNcC+nKyTt4kGLF1j4/CogrD9a1g7pRlxOkEL5 xwGhBw5uogvLuzf45BLiG+gYdkW3r93ZJwxs6ZrdJ58lBwpeeWpEMyNiKpkQx2EA38sn +WWU6UX7ZJAnFW/h/sevFl32qOzcVOTYXoLNt8ljKnn1AyUY+fDNxRP4UIYLn1LR5el1 ZBZw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="eh/XbsAM"; 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 z88-20020a509e61000000b00459dc4e4b7fsi13057401ede.143.2022.10.19.06.13.49; Wed, 19 Oct 2022 06:14:14 -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="eh/XbsAM"; 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 S232140AbiJSNMD (ORCPT + 99 others); Wed, 19 Oct 2022 09:12:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232029AbiJSNLm (ORCPT ); Wed, 19 Oct 2022 09:11:42 -0400 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2060.outbound.protection.outlook.com [40.107.223.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3AC5A1CBAB1 for ; Wed, 19 Oct 2022 05:56:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N138YqDS4yi21fJbAPtO+vi2zjVhgdZHdjaM3LkNILWzE1vr1GxbuUWxNj1VoLfOBIHmFYXuoqNa41E3gh4iqJCuMgdGLC39aHRj79Ld8Ec4flw3yI/MutD9FI9SDF5/I1e7XNU0XThQwOpaZe6QELNPjGDUGF6AkShy4pV3T6Nywsq86r2YSmWhCY0QixKJ4ogdsq3LplxMmIKyIrLro5qqbRGmIvdK3+qQadvGom25D+/K5TlEETNc/sA/+nR2O0bAMKnqcD3IeefCabgzGG8hsMKpt6CGAYU3FmMGXgwwab1kCDTJYJueK+niZssX2LB4AL8opW7zxdXktICCtA== 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=oDOkZSa0/v0kkFguBysT+WRyNN/qW8l/UoHVSPHkuKw=; b=JM6SI0NCwLljyFMK0ld0hhOZGaWs0tS18+k0BjN6q9isP1G+Iq3+AKi5xlSVsJKNc/DspsaWlqv2sCMeNQQkzWSYbPUaj0Fntqcc4vUdwelJ+mqH7jzqZP7jSu0Y9OEBnb+D8kaQ3EXPjghZHE9+0G+4zq3bWyocTVtlkKF/0a4Jp1plkLksQjBsFy0D6FnO3hThRmGhWygXpYdFWF1pTvfZJn6ovxAh6c/p2FZBHQ7Ay8GQTgXTQbcJ2mvxtQaSO+/scCAMddBe9phQkOshoSF9ejH39IzvOe3mBbOYExblSgxbbtEXkgNkZN7I9oI9qsgzHGUzOef6YenbJB8+qA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.117.161) 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=oDOkZSa0/v0kkFguBysT+WRyNN/qW8l/UoHVSPHkuKw=; b=eh/XbsAMJuq73RltDrl+zIjLeilERqt3IxgFYZnubJcxsjrIrOdY64TU0dvxT9uibwjS5BKB7ij8GZzX6dKH1sQXgZde1p5rT9v8GnKji2buN4YQ81Jpn12tL89vlcPWIhif0xto5IReHYZQJTuSjHVh2GpBuF+WH+jqp6CABYG2sJtRvgr2cLLAj1UAq0KkmCAMr4mQP3UeSKxmRRs4h5QmLdtN1+Ca8yqfszMAGUj2CF6F9SwbWtucf7PEnSN5cmWA/Furx2/FUtOBagV7hOUpu2K6Zt40Bq0bSxa3qj/k91k6eTMVS7K1tXArOCs+X9zPj79oAi3A3uioWV4PwA== Received: from DS7PR03CA0293.namprd03.prod.outlook.com (2603:10b6:5:3ad::28) by BL0PR12MB5010.namprd12.prod.outlook.com (2603:10b6:208:17c::13) 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:55:26 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::74) by DS7PR03CA0293.outlook.office365.com (2603:10b6:5:3ad::28) 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:55:26 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.117.161) 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.117.161) by DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) 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:55:26 +0000 Received: from rnnvmail204.nvidia.com (10.129.68.6) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 19 Oct 2022 05:55:12 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail204.nvidia.com (10.129.68.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 19 Oct 2022 05:55:12 -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; Wed, 19 Oct 2022 05:55:09 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 resend 2/4] vdpa/mlx5: Move some definitions to a new header file Date: Wed, 19 Oct 2022 15:54:58 +0300 Message-ID: <20221019125500.208841-3-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019125500.208841-1-elic@nvidia.com> References: <20221019125500.208841-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT035:EE_|BL0PR12MB5010:EE_ X-MS-Office365-Filtering-Correlation-Id: d7c3fcc9-2d47-4d03-1f40-08dab1d131c4 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6YsMH1RIw8wbIIeF0CoFpzRf4r87XifhFsyVb3Juuei1SMmi6tTHxlgbO+U2kmifhuSs5SK5TqFz1ALDFtsOGvWITF6q2q+7YqPQzX6xlVtoUaRIFMzn3qk9pMyw34wbYFADBMOyL5lpDeGJ+ZWeUpUIKctK+asbk/3G0FYAAe1szlEl9/KHML39C2vkwmaIjs8tje0tgDuwkv9wpXBdLzttCASrO0+W5LphRX8YCKrD41TUee7rznjsa0kT4bnGx8BdboNQ9NDStgjWShScYFiNHegVp3qUl8JtqyVeoBx3VKvsP/df3zoq8nKqwiAbuw/0vrBVrBY71jQktQuvnb9KM92JwTiTCMG+xoMmpdKeHSBpcnDPbdsf5hVe3PvrR45/ppV99ug8NBa2UGQNMmgTJLv+5x2rymA/HCOSXoAu5MsjpoLSlCMlVaBn/z4O2PUkC74x4snlUiOXDJIPewPjnUJ0TVL6WUNzUyegkFconFJ8VDgGdu+b/WpD9+SnAqdHkDwBaRJLlMAGhNRvZxMlV+kbk2qq9gH9Ze6/yKiRbzE2i0dm2wDog21GarCujTJ+xvploTKGEgM3Q2nvG/qqu5+Ksn/8J1ARYBKq9VUYX/QYeH4nOIWAhJH+lBSIusSIJnMD3/ZTUPwOQpsNk3wdaH/+KLw78FH2k0zAagHGzA6ANk48dbQdSxpN+3d/Vp/P2SgWPOyUF9Oiqs88RgbmBgebQF0EiSiwuVhmau8M994VjlpnDoilYnevBVHQyjNv2/bdC0BMcT4/uIKmEA== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(136003)(376002)(396003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(47076005)(426003)(1076003)(186003)(2616005)(83380400001)(356005)(26005)(7636003)(86362001)(36860700001)(336012)(82740400003)(5660300002)(2906002)(8936002)(4326008)(40480700001)(82310400005)(107886003)(8676002)(40460700003)(478600001)(110136005)(7696005)(316002)(41300700001)(6666004)(70206006)(54906003)(70586007)(36756003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:55:26.5845 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7c3fcc9-2d47-4d03-1f40-08dab1d131c4 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: DM6NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5010 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?1747121868981895146?= X-GMAIL-MSGID: =?utf-8?q?1747121868981895146?= Move some definitions from mlx5_vnet.c to newly added header file mlx5_vnet.h. We need these definitions for the following patches that add debugfs tree to expose information vital for debug. Reviewed-by: Si-Wei Liu Signed-off-by: Eli Cohen --- 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:54:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5432 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp320034wrs; Wed, 19 Oct 2022 06:14:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6ebHRJi3eGVH34+viHIkwFpFSFSykdfj0ucmHEE2Td9HPEqsZlQK5M1R4DgyOVUZz9ZOqh X-Received: by 2002:a17:906:8b81:b0:78e:1cb:e411 with SMTP id nr1-20020a1709068b8100b0078e01cbe411mr6498521ejc.681.1666185254163; Wed, 19 Oct 2022 06:14:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666185254; cv=pass; d=google.com; s=arc-20160816; b=OIEmm9oSlZod293tCiRNnk7wcRtyRwZLrLRlYP1BitWdbHvhooVuEaIh87b4lr+NBe 3w7v4mtQBT0GQOt8ehQIaaplkc7M/3V/bPVW5xzietRKvS03DeJowiU5qYMDQXZTcjAs incIK2q9Xhe675UoOTSJ3RL1UnPtOac+d4xp9eG8AOaODjHrdmdX+8JXmdewUsJwUrpQ CMFTgzQ4RLDUiUOpNW7GO1igw1JEc2+Ng2IUqwksJ2BrJiuxxs9we+jWxDm6YxzkrDZF oxHris0tK1UVwNgfaONfAzi8/1twgT3P+fbSq8Xj2cSviwPULRpllNfenGVOOXGrZ6uF M9iw== 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=2xjSw/J7v1abqK+2JOTWDLp2G5ropTA9j/01cHayi3I=; b=ZzRQdP+jG4lJOjmBAigrq/+tXSRVkW4uogNwDiSkehAfCHA0kmU1564UjuCSq8IuDJ /by4kGkCwOIQVM6rlChuz+/3S6zwrTL8d/U5aNlLY3j1E8d0d5XLFPPR4Njxmz/GiRAO zu67OAiSHHU6eYrzXxIBSnH4QMtyhcz+euZE9oHOWQgHq/RYDv0c9hT3NqLQC9Bpcw4h xvTcw1vOnCUNGA3rLZQOzhtad9hthHtR9Cwmceiso1wtS/dl7CwFrzC7mR+54Cnhwy95 G5YdFZeBJuAsgf70uWNJflKVfSy2hQtocaJvx2pGhrnMkXULecHXOoiKvL/rqP5P5KXX 9Frg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=awB7l0M7; 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 dm17-20020a170907949100b0078dcd448f99si1823004ejc.855.2022.10.19.06.13.47; Wed, 19 Oct 2022 06:14:14 -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=awB7l0M7; 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 S233324AbiJSNL6 (ORCPT + 99 others); Wed, 19 Oct 2022 09:11:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231523AbiJSNLj (ORCPT ); Wed, 19 Oct 2022 09:11:39 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2052.outbound.protection.outlook.com [40.107.94.52]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 794C31CC761 for ; Wed, 19 Oct 2022 05:56:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fYJEy43uRpbGG9ztgzwQg/KvYJKR6+l9FfazZApg2XVECvlthqbhpD3/k1BxIkD6sQbVOuH8MnBj2xwXPf1naR7BPInpWmnSkBujkyiT4Nk5lXVtqSddgVRKjjN5hWhHUCCQDlJaEOQSLCNgQ+lP5wcm8SRxbolplJVfOMROWnzuTkzBnsnUXsu7u/OaN91gRDCSXFXdTLgebs4Hn/frSC0Wyz5jr/EFd2bvtjVyhTKNazum6lTYvqtu2/IMcEjKIu9fa3gITNdsLif9nNaNdZ9oMvoLJlvuiHWhDVvMOJhCqplVb2vSaOR5/kMsBJyw10PZv9EoSzeD6jkTrZ4iRQ== 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=2xjSw/J7v1abqK+2JOTWDLp2G5ropTA9j/01cHayi3I=; b=AgPiyCDUdROfb2feX030/f9cvJ3ll2vbpm8pU4MwWLGLuITpN+l2KM5XWkuQHEs0R9CpuXZ41g91RdBW/m1pS/hbq3vCwXJWpg6ai3/rBvfZP8st0kQZ0SLxVTssOorM/IziZLskJ10+XDK9Q1M493A3QShcmfvhe7vEEf9bqthNezoMkOYGn02/T43hYw0DAILKkNorNvClLn0l898hLfMR/9VqBHoU6uxj/jGcoDoiQYsTQt5lefAga/Ug+MP9BB/rXctRut1izu4PmF8pgQF9wioz9+G7HIUEuY+WEG1Tm5z+oja0DhKc8bBBsrCRB6fMO6XTuhZgH9d4xd4siQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.117.161) 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=2xjSw/J7v1abqK+2JOTWDLp2G5ropTA9j/01cHayi3I=; b=awB7l0M7HNhNgPwq0TeqFl/tSjpqavwUIcjdQrRL0xdHnlYCfqvhwzhm63ft0PZ/BtGNoEWG3aKgPrCS1byhH8yVsZBaHazCeuVdLpvXrqDL4gdpm6/pBZ8NfpthAyg7/ehvRsm48yX28oOyPKt02kczQRMw3+QE9+uorUdtg+gn5Xlh8+mflVIbjPgnvPdwhVm3uby5znmb0NDKV+/Imse0k3uBqZ5rJPg63HhcqKtpjPmRf0mLnUGq57xx2kSW9xZIzC2M1cjQhHushh9vnrMjp6VwR+nCe3AxjePodlqScZHdVVLaJ/ZITLVJySMUFVkJ/yxFEsmW64+yozY/IQ== Received: from DS7PR03CA0279.namprd03.prod.outlook.com (2603:10b6:5:3ad::14) by MN2PR12MB4581.namprd12.prod.outlook.com (2603:10b6:208:260::11) 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:55:31 +0000 Received: from DM6NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3ad:cafe::21) by DS7PR03CA0279.outlook.office365.com (2603:10b6:5:3ad::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32 via Frontend Transport; Wed, 19 Oct 2022 12:55:31 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.117.161) 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.117.161) by DM6NAM11FT035.mail.protection.outlook.com (10.13.172.100) 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:55:31 +0000 Received: from rnnvmail205.nvidia.com (10.129.68.10) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 19 Oct 2022 05:55:15 -0700 Received: from rnnvmail202.nvidia.com (10.129.68.7) by rnnvmail205.nvidia.com (10.129.68.10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 19 Oct 2022 05:55:15 -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; Wed, 19 Oct 2022 05:55:12 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 resend 3/4] vdpa/mlx5: Add debugfs subtree Date: Wed, 19 Oct 2022 15:54:59 +0300 Message-ID: <20221019125500.208841-4-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019125500.208841-1-elic@nvidia.com> References: <20221019125500.208841-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT035:EE_|MN2PR12MB4581:EE_ X-MS-Office365-Filtering-Correlation-Id: 48df3b8c-696b-4717-2d89-08dab1d13488 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4OV3lmCW8qQVN/tylGWJsnE+NYxxdnzAaI7wUryw+FTWGHjrjHpnveT5NqmbuQBCOnB71xshib7XD/a8FM6M9RhMRhzsuE/EGPcg8xnvY0EDF9epOTtpLm5KeanuQkoxCdBySMjiwKXjwm2PJIGUytzpH7UYUEoPnW67VBiBQnNiJlJZLYz7E2C6e5eLWteTuk50Z2qRlqk+EfZKkwS7ZAhjdOq7eWIXHJTO5gr9or/AoIoRqm8pAFqnJpXY9Dh1nj0GvWHGzLpzG1R9Dc/kdOIhlwec+1Nao4vbBCFz7z0gMk9hBuoHeIa/RMIjrcHJHuvvsQshQ8dV8K+w2is5xP8e+HEKKdIcMIFjahKUVYefxOyngF74DsOASafSqv4r7C6ao2tu2DrRrbpFgZF8htIBPSa3RQy2JNCF/m2noSHNzAlTcxgIDxj6/sRals6/PJF7/7hAcMAeV1LV3QyAMwhebNVs1VweFZG31ZdUzvJOxeLtuG587zkQHndCvsRkrPT1LERWIuTrlp0k6+JEXlGPOgL+4RIVxWhDPVXjbjnL8Qwmyw+OrMBPIEVSxADjhWJLkXNPlp5mmeW6UVfiW4bToABK4/pc7SPLeTtj7ouiO0glG9EeK5mNZPKXuBIUFgabkB58OxgiLb3RWdYS557fCIJfEFk3r07L/7HAtkBar4Z9Cu+s4uYeZ05/ltO7By8IUCj8Lxkr+oZR0uFBhllweoIc2E10TKENtg65BB3Rirw9f3HUu+xDm3Cby3ixP/h2c2+yhJYVorM1tlhG7w== X-Forefront-Antispam-Report: CIP:216.228.117.161;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(376002)(346002)(396003)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(186003)(26005)(7696005)(107886003)(6666004)(1076003)(2616005)(47076005)(426003)(83380400001)(336012)(2906002)(40480700001)(5660300002)(40460700003)(36860700001)(82310400005)(110136005)(54906003)(41300700001)(478600001)(316002)(8936002)(4326008)(8676002)(70206006)(70586007)(36756003)(86362001)(7636003)(356005)(82740400003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:55:31.2248 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 48df3b8c-696b-4717-2d89-08dab1d13488 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: DM6NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4581 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?1747121868880924338?= X-GMAIL-MSGID: =?utf-8?q?1747121868880924338?= Add debugfs subtree and expose flow table ID and TIR number. This information can be used by external tools to do extended troubleshooting. The information can be retrieved like so: $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/table_id $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/tirn Reviewed-by: Si-Wei Liu Signed-off-by: Eli Cohen --- 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:55:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5443 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp324368wrs; Wed, 19 Oct 2022 06:22:36 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5sZ+/jFJdL5PTRNPUK1W0f0OpMoGKPnHDAkCUgpVwijEsnw1gpMhKq4HnNdMwjMs7rFpsC X-Received: by 2002:a17:907:2cd8:b0:78d:9c3c:d788 with SMTP id hg24-20020a1709072cd800b0078d9c3cd788mr6869087ejc.327.1666185756531; Wed, 19 Oct 2022 06:22:36 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666185756; cv=pass; d=google.com; s=arc-20160816; b=wP/EioSAVzVIyoI21pkFyfWcmi75T5PJlh6xijbH1F0AWYkjQPrGsXFojTGoGUczLx k4gXdCFH0p9/yNpV0iQY8aB0KqchZ+CHJxnzN9ffh1bqv5/cuFOypJGYVkRL1fLy0cNk MKKpqetk9L0W93lK3iLRtNpBAkHE3mwLQk8PuxYkCNF46sVCfxoGuViEl/SNqQFeni6R pwkji2JIxWed89f93h4yKsXysxRr8tjfDS1aMjC7hoq0iJEoABD7AInTk5p0kYP+t2KO wU/nlVhgJo+Rt6912liF2lWkzrx4aBjrAUqAdj83UZPHg84Y4EsAtlH01GpVrmp6Pgju ++mw== 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=vTlXZdFKIOJirBykCmjvd0FxmMiiqOioLW0EZJ0TXtM=; b=hpFt5Y80Bod2L59rfASPS+lQdgzYMYmXN1daMWlzOFBzJz0x8weBeLRH/7S2ByOdlk QWyccbAHmMK/F4e+KKXcTwbkGMKpHzznWlz/17UmdolbOBEGKwwdQPykjLZEtKNF1sYL MsiruDhZgUeK4cwtoh8rsxHabWWjo7gdlG0fWs+4b+1xk10nDuoLHXd4trJ53hzA6+cx uOfUz5D58xUjb9QyX8L5UUeVwKTYkYGPDH5UfVgY2OKAtCbkg0KokdukOjsXrxBdONSB twUr+UylqdspUKmDtqdEVzkF8BL1Sj5/W8CsJ7M9DciP0GSwOkgxcExLsZjLtZi/Fd1s JJwg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=i5atNfcu; 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 hv12-20020a17090760cc00b007807f3d1e6dsi15624031ejc.599.2022.10.19.06.22.10; Wed, 19 Oct 2022 06:22:36 -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=i5atNfcu; 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 S232331AbiJSNMT (ORCPT + 99 others); Wed, 19 Oct 2022 09:12:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232951AbiJSNLo (ORCPT ); Wed, 19 Oct 2022 09:11:44 -0400 Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2060d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe5b::60d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C5AE165536 for ; Wed, 19 Oct 2022 05:56:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QAEBDJOLkteS9mcqB5AgZOlFshcr+BjTl/TnQx1PW7EaWfZEgh2KD+buzdQsP00J4lhVtPHiYFAJswtsQnnNU7tS2UP7XGtWIibku0flCyNCAdLNMapujLKgbqcKUm8M+nXgosZkZbJ361VP9nl3FwGTrGxPS3TtzD+VmPth80ECWzTxdfX4psFeEOb3nPLMdG0SDK7D5rjO+ERwSzPdMTaItjT+QvujECmQMLa7PQ97usqzBByg0Hm8rxLr2S5L04qS6VCAiQOR2GbVKBaZDn9uENQTTbK1COf8pLR3dfRoRsdBi8YRLnDhKI6YRu8hi56RUDcc6ancojWOTlXOIw== 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=vTlXZdFKIOJirBykCmjvd0FxmMiiqOioLW0EZJ0TXtM=; b=mxA7OVFBbwF7B1hHEgxMoZN93BHFg9rntmP2K+ctSo69yukOnUAdgvj/R38/FIDFDozTAmSTj/WSv3puJS686CjfbEj5zQelUhw4/ObcKYpd98Xw1VozrqIRe5nDzFedmYLujJ+PR9VaEdMlO9x0iyPVoPttUUxnKZ5I7q5HcOnmiHi7fRarEcIdJl+U2rD97UTN/gFjIiNY8hupNOMJg6MYDGlQFsHasQxoSrwSZUECRNsU9uC31eHlX3z7rYYNewg53KPLDiJ+FG/Z5RCwDXZQE9MawR3YssHZhvl3h1X0H0ziQHbQBT1BtIfyujAizwrwPSMeHHB+wn6omreM4A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.117.160) 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=vTlXZdFKIOJirBykCmjvd0FxmMiiqOioLW0EZJ0TXtM=; b=i5atNfcuFKLb+rcXLw3Jpi2Aixuqa9l8pEDdiy0b9Fm4s9cnHZ8NakfKmsb6HYOKoc4t43ZcXarXgmZuT/L/0+AJrGHbcGEGU+jrTOkaSRy+/frJxAvm0R9RYKN7/qRaaw9lSWyJOpwJ66P2tl5lFvMDoRjrxEOu+gIBAypl9yaJJUFN/n81ojkoeaGg7MJhy426R/8MXh/8aRdks6LquSweLkLDmUTwWzZz/R9gmNaku1CDd70MInzUF+466dWiOVAOyPodEwZ46YZtyJ67qBSqdDzK44HyAISL+EFNAlpqQVfd9edmtYqBMfdEj08pAEVnDZD/ZemSh2Ty5OkjEQ== Received: from BN8PR16CA0036.namprd16.prod.outlook.com (2603:10b6:408:4c::49) by CH2PR12MB4085.namprd12.prod.outlook.com (2603:10b6:610:79::9) 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:55:36 +0000 Received: from BN8NAM11FT018.eop-nam11.prod.protection.outlook.com (2603:10b6:408:4c:cafe::ee) by BN8PR16CA0036.outlook.office365.com (2603:10b6:408:4c::49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26 via Frontend Transport; Wed, 19 Oct 2022 12:55:36 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.117.160) 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.117.160) by BN8NAM11FT018.mail.protection.outlook.com (10.13.176.89) 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:55:36 +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; Wed, 19 Oct 2022 05:55:18 -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; Wed, 19 Oct 2022 05:55:18 -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; Wed, 19 Oct 2022 05:55:15 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 resend 4/4] vdpa/mlx5: Add RX counters to debugfs Date: Wed, 19 Oct 2022 15:55:00 +0300 Message-ID: <20221019125500.208841-5-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019125500.208841-1-elic@nvidia.com> References: <20221019125500.208841-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT018:EE_|CH2PR12MB4085:EE_ X-MS-Office365-Filtering-Correlation-Id: ef7891f1-b785-4ccb-f9bb-08dab1d137a6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qGTp0QERgKQ30QTnjolrOq0hB75Ct9xd+yYylvOxSnAfDE59LWyqGf/uz761U0NQ1F4bmp/OkMcI+AuqjUjEIjR5/BxHDO1O3Mk0aazif0ue5E0bBe3Ibjnvxb+kz/OxadfB/JHLI5NqdImGGXUfIFU0UFIynW3kC5VlnBZB1FBrQcZvjT5eLgC08ZhqM3SVdMtNkbjL8jDjVSBuvhFVxZBU1I32WlY0vmfAyi62Qd1i471FfT7mc7uavpTn0uBC4DxFqXV3OopDSNwLrhRjinwUu03oAcA+No+XHK9cFcfehLzyypHrn4cNq8tgDvHjubhb3BAAbF2CAc1Zmg6gCgu6a+Fm2obcQdJSWeCovsZvs9uFVcMMfMuv+jNFaXnQoi9cDiMXoBnN5RZui4lCxGRMulhGAvAWzGobfqr8eLaO3b8ENNsUsY49qvx2kk1B86YYVHGIeDDe4+054xuYrGycte/iUt9kBvMZaLTyq26ibarM3CrliEo3+W5E/hNHOfDFyJLfOIv0rjIW/tVrQOZW6TdKBuO+B48fDM3M6O8oAdLNLsKAqFab+Fv3Xe/lr9dzQ/LJvd9FRJ7dGVnKF/H1sn7wmq3Fzj/7ByN6W6aG6fVUzlFfP/PG7SPx3AlY1Alc9uYcRsx4kb4uUyfBexyPhfHNYSjzS7ppZimw4NqHI+MKDo4fy8CHH4xMXBOs2qLAAt1Q8G94ZbIGI+MPXsBJgQ16m//0kCvjrPp/0f5vgKRvpViMBJs/Qtt1+5U7kILPapVbvGFsVDPAkw6QhxbCNFe0ObxUGfDKXXp/Ksg= 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)(136003)(376002)(346002)(396003)(39860400002)(451199015)(36840700001)(40470700004)(46966006)(186003)(26005)(7696005)(107886003)(6666004)(1076003)(2616005)(47076005)(426003)(83380400001)(336012)(30864003)(2906002)(40480700001)(5660300002)(40460700003)(36860700001)(82310400005)(110136005)(54906003)(41300700001)(478600001)(316002)(8936002)(4326008)(8676002)(70206006)(70586007)(36756003)(86362001)(7636003)(356005)(82740400003)(290074003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:55:36.4286 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ef7891f1-b785-4ccb-f9bb-08dab1d137a6 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: BN8NAM11FT018.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4085 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?1747122395752232130?= X-GMAIL-MSGID: =?utf-8?q?1747122395752232130?= For each interface, either VLAN tagged or untagged, add two hardware counters: one for unicast and another for multicast. The counters count RX packets and bytes and can be read through debugfs: $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/mcast/packets $ cat /sys/kernel/debug/mlx5/mlx5_core.sf.1/vdpa-0/rx/untagged/ucast/bytes This feature is controlled via the config option MLX5_VDPA_STEERING_DEBUG. It is off by default as it may have some impact on performance. Signed-off-by: Eli Cohen --- drivers/vdpa/Kconfig | 12 ++++ drivers/vdpa/mlx5/net/debug.c | 86 ++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 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__ */