From patchwork Mon Nov 14 13:17:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19809 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2146440wru; Mon, 14 Nov 2022 05:34:59 -0800 (PST) X-Google-Smtp-Source: AA0mqf4sZeU8z5U3ub43FxHRdtsWTq+WQj3UY9smHaE3jHzbRxphgaCDav1LP6lOp/hdqWDoRpkY X-Received: by 2002:a63:1d0a:0:b0:46f:8976:c7d2 with SMTP id d10-20020a631d0a000000b0046f8976c7d2mr11972432pgd.7.1668432898923; Mon, 14 Nov 2022 05:34:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668432898; cv=pass; d=google.com; s=arc-20160816; b=katjIALsD5yGf1Jv+PArxRQuC0rkXTSml+MZ8LDLr19kBW7hpJeX+bTsLJd2ETG1w3 GRn3mAenUzghTI3h3q8ZJmSgn9Im30CTcZ50p8DdK6f8WoXi1lzlDL+XX7Iae4zkgQGM HYpFotmc5r1PeIi77J9HOWcBGjj4mcjN/2eRnglBVz9frE9GD8qYFE1I6b/m05jdBq7+ UNQ0hMgtsj7FpUx5rw2vOodjPgYywYEl/bF1bGOXHuB4QQSx+v1hSTmNQd3qVBR8t/Jq dueS5BWhDpCu+bT54iecr6jpXLphhPGhIUfI/7XkQSxvVo9CDoIkuJELu54v3/ILAazO 7ysA== 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=ZuIYSLHvDxPkQHW0/KqpZT4mZEcCGBG+8bXOKR9nzh0=; b=wWnsD4wvPXYAcCi+Ijr+v0OTC+V8rJeGMSjzCkjQLkkEnVbj3OcVMiQi8O6WxJs36u Sl1IQzxY3oFlYQRB5BjgNNtkb5sVMAxoPcEbyLmFe/2CYRQlp1UEXw1W3ylhUYWKfLxS zdcQ/rVQ3F7n+Q9wNA9+ysXFjiMysn+BRvSHjAmIlF9OV0gXcyCZcqrzko8Vxo/DMdC+ EFd03ZOyx+23W4gXOBuIWh399icF4v2Fx2K0SQ9zj9vBPLitOE7NDdN/iU8L+ToyfkRc o8lirOv7ZibS20YkwY/ae7MgOownTIMh6y477QwI6z3chjNEoooeGEwQ4QVtgNfqC1gF 2gUQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ExgzBv3A; 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 p2-20020a170902e74200b00186a076362csi11311217plf.315.2022.11.14.05.34.45; Mon, 14 Nov 2022 05:34:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=ExgzBv3A; 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 S236792AbiKNNSp (ORCPT + 99 others); Mon, 14 Nov 2022 08:18:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237236AbiKNNSR (ORCPT ); Mon, 14 Nov 2022 08:18:17 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2074.outbound.protection.outlook.com [40.107.244.74]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E56DB20F6D for ; Mon, 14 Nov 2022 05:18:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CE99RCdtGJBhV0NoJTenDG4A3lKDPESNCIlvSsFk8rFdbUGoOgCF4bZ0H80vtLd2UIqVHsN6QvD58pgD+ziGg2+n1mFKXyNeyxZKLtnWxezKI/7wcbIBK2n4sb3lMTWkNLn4TP9wz/VgbcUme2rzd/ZQj8rxtLEkU2OiPisxfcqIbcr4e+Fn7uxZJb2ry0ZfSaQLW0IoV2wQEI0zHFNs+gV0ojXOe3NsD3BQenlxzDGOC/cuya2uCfHtdvqyi5Rur/UtKAvnp7UzCMnzrgGvMNsWVkwZ7vWWFKKURTdLemkv3g1h6URhF9a8icchjwX4XjJKyiBsG8+XR0av2nwj9A== 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=ZuIYSLHvDxPkQHW0/KqpZT4mZEcCGBG+8bXOKR9nzh0=; b=VRm/sb+INWuewnqmhbqwBWk4zWVDW782zqz0fmN3PrcToBPpVrf02yCnnFBarsd6oSB8fltJR0f9ErptoxCwbi9t2/GoDwa5DfJrOV8DeXwFb37ebZ6R3nHjjCKiod2Nor/v64Ypqn1L4fOlBFTPciBX2t2416jt1sVREUEvKPUCCLrIQCZJ4wzHjJ7D8fe+J0rH5UDfZiLbuXkYlRrZdaGPTlqc3bN1MDQeDvoKy0Chfq+lFliAW0neVYRIs04dTKOEdAUApEDmCGKBlZtIYUYD1QuPjVXokZzqp8CSDwxxENhwVbHi3Uo6F5nFbsXoj7IXebIvY65aZPPXkBK3LA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=ZuIYSLHvDxPkQHW0/KqpZT4mZEcCGBG+8bXOKR9nzh0=; b=ExgzBv3ABD+VE77npqFhK3USruClSitdOqUj8+vHx9Mt0hwv5JbkK4MtM80tpMvYkYARF9VY3yCfyo+mqOCjN49P+aFDqlpGIYRjPoZX9FwB9zVjrbdS0l1mwTHrlDpq1vbfb4tD58BBcp9yP0mU2R40+QfDP+EcwyQWL/WLTAUFhlwcg1Zpcy0ThfeMfy+0WO09T/4T2BVSGmi+ZzsQYA2e/MxJQP562IkV4qaZ7SXF5ct9Q5z6UO5+E9PN5YD7uLtf2wch9zHP2KwsLX5/fib12CZGqcvCkan3ceuMiWMTzoUE1yMguDTru3qSzUdlZUgMsAF2wcndMd0J+qDxfA== Received: from DM6PR07CA0057.namprd07.prod.outlook.com (2603:10b6:5:74::34) by CH0PR12MB5073.namprd12.prod.outlook.com (2603:10b6:610:e0::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Mon, 14 Nov 2022 13:18:14 +0000 Received: from DS1PEPF0000E657.namprd02.prod.outlook.com (2603:10b6:5:74:cafe::6d) by DM6PR07CA0057.outlook.office365.com (2603:10b6:5:74::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Mon, 14 Nov 2022 13:18:14 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E657.mail.protection.outlook.com (10.167.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Mon, 14 Nov 2022 13:18:14 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:07 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:07 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 14 Nov 2022 05:18:05 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATH v2 1/8] vdpa/mlx5: Fix rule forwarding VLAN to TIR Date: Mon, 14 Nov 2022 15:17:52 +0200 Message-ID: <20221114131759.57883-2-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114131759.57883-1-elic@nvidia.com> References: <20221114131759.57883-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E657:EE_|CH0PR12MB5073:EE_ X-MS-Office365-Filtering-Correlation-Id: c8948c31-853c-44c9-0e2a-08dac642af9e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WNv3QKa6+pK59n06fQjn0DAGrS7xz4qpcNmVffeRVGhwaoZajT0tPXg6Zns6VBUYSOfsmbGeF0GcGK+mIXY+J8qlDvG11OPlBNExO4KUrUa0O57rTop2wV2HmUaWbPW60IT1cwIIRYi/Hv4DJKbqBeWLXuUnpMmWqSNJmqHgU3OijkhpOPqHKnaOfCLnppYRX9J0SXKUfQqt4vQLV7IjyTiLi4bxOInmdVfomWoiybH9Jd+Awylc+pm/spLymYG4lSzXIsxkksrZO3AkCIIrkxWR1PKWLt88UsZGuEumoGp2Nk1QxlaDNQJbw9cCCHfVQPKqsKCf7VBUB4/U1iGwfHGfjJSuY73rBcYhJ+B0rZOUsds+fHtQ/3k+W7NUB2QKyjSzO3FwF+bSXMMpD0a7HlQ444tHyiw4dPosz6U8KDzz13E1b797P6SLGABb1xOH6HXNoOj0fdbGxjx5ajAttrWfbviaguQ3oJmwz7HagZ1BiYpPk418m+L2i9ToUhYbwvmuE2XAUn6KBb6/GIFHx1KAFTe18J1SIZD5BHmC/4kR4xWFu+pCKqnHiFW7Apjr2JOk3Jj4ck/ggb5punc2LH8ZKd8P4/5FH3W+tlitgQEcwOmsyZToYqrG7eF1nMyBxpOPRrn0HjAXgIZKs6p5KV20wcw586g8u7uN2Cr8u3lS6s3nu9YNUsW89Ud82GpHuEGk8CgO9SLaQIWAmXIR2rS82Q7OjLZs2PUm1UinGhYQf3wpjbUzpk/HtS5QWqLwrs2P5MAHtrYGsghge5i28g== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(396003)(376002)(136003)(346002)(451199015)(40470700004)(46966006)(36840700001)(8936002)(83380400001)(40480700001)(47076005)(426003)(186003)(336012)(6666004)(7696005)(26005)(2616005)(107886003)(1076003)(356005)(7636003)(82740400003)(36860700001)(2906002)(5660300002)(478600001)(110136005)(8676002)(70586007)(70206006)(4326008)(41300700001)(54906003)(316002)(40460700003)(36756003)(86362001)(82310400005);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 13:18:14.1296 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c8948c31-853c-44c9-0e2a-08dac642af9e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E657.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5073 X-Spam-Status: No, score=-1.1 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?1749478695469692990?= X-GMAIL-MSGID: =?utf-8?q?1749478695469692990?= 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") Acked-by: Jason Wang Signed-off-by: Eli Cohen --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 90913365def4..3fb06dcee943 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 & BIT_ULL(VIRTIO_NET_F_CTRL_VLAN)) { + MLX5_SET(fte_match_set_lyr_2_4, headers_c, cvlan_tag, 1); + MLX5_SET_TO_ONES(fte_match_set_lyr_2_4, headers_c, first_vid); + } if (tagged) { 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 Mon Nov 14 13:17:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19804 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2145987wru; Mon, 14 Nov 2022 05:34:04 -0800 (PST) X-Google-Smtp-Source: AA0mqf5Py8DH8yvKjjEPLCLmVO0y6WjGZstGLXWvQtt1xYgFPAPvY7SagZKwrppnav33xjaLn2oA X-Received: by 2002:a17:902:7618:b0:186:887b:baa2 with SMTP id k24-20020a170902761800b00186887bbaa2mr13800444pll.27.1668432844491; Mon, 14 Nov 2022 05:34:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668432844; cv=pass; d=google.com; s=arc-20160816; b=Jqa8kkFZXesNhiJpCSPk3jhBhE124e6Tr/kvyJ22i85l/lii4QPGizySRhhYciNuEm wOvN283xPBxvJPlGBCgcCA+DoH0E3BubBYtXUw3hRTP4b25WA4GLFc9YIBhEMq/zn4SV IWt13BGy0xTzNzg5AirQkATe7ms8O9j6IucC+nGS3Gp6IDWGHTjFgiU3c4+CiZvW4UgC 9f7G60+TIRqfR+K5c0oP92WvYXxg6lCnth/7hqj6RVMzeQhTkAYMWWjhWcaZMRw7REur 4a2fy037WrlpWXqqG4SbHNvRjRwzyyxPjA0btncEax8rVJ/hFtivkGDE/bMOAIssSngt Q3vg== 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=OJlecboikd8jAUBfmPbRPzYGdu4c53JvHpM3dMgaVyk=; b=li4aEDbB4ILHUUMzJQ4Xc88xdRfzWNMuhVl+74CNyY9QuVzJ9ap7toddhyINKcuk8h nPLt2T4H3LXXtFKNdWyowda3xb5epIDGWrAKRBwchBwE2Znt+A+vMJ9xMNFfn4y26eeE DyRpbInIy+dYOsh+AxaVwQknESyXLuGqWA+frgKzzQcw2Xkvb2tP7SIEBk4FCWfTpUTZ yD+X9Z3Enln0yKtwynKkkJBU7dd/ze0dcFO1YkWg+N58KsohRItSVsnmexAovGI8Nx7i nItJWLYz2va8EWSJ9QupVS/OI5tNoDpCuqIi37rTxcnng++GFOV7/ProeTMO5Z1vbe+o /lWg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=J9cILS4I; 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 s12-20020a17090aa10c00b00215e0e55a9esi9215653pjp.38.2022.11.14.05.33.46; Mon, 14 Nov 2022 05:34:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=J9cILS4I; 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 S236345AbiKNNTG (ORCPT + 99 others); Mon, 14 Nov 2022 08:19:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44228 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236031AbiKNNST (ORCPT ); Mon, 14 Nov 2022 08:18:19 -0500 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2046.outbound.protection.outlook.com [40.107.244.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 282B7B498 for ; Mon, 14 Nov 2022 05:18:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Qzjc9zyspYHPU9SOzixxCkq9hRJs2ncpgHwgk/UMUNTHaILh2RkJ4SxTk2oPiSsoa9He1oKOiI+p5aHGP112TwVNbBs3FfAXNaQk+OBrEzFIWJMK37Z9ruMGvlYCzhEqtLvDbr54VEONWBxuJPDdRU4H/NUtXZiAgRCAQ/btRCCAezKBVoe4WsAzbzUlIUYxkAyGZhLr3ZlZpRS8haXgPILcqpEkVqT4wpy+wLvIt9+F54cljPmr6aRDBKTazID+C7xdu/vwyd5lHPrvxZtsjvMMBMP8CbuHnzdaRR7gdrodBcT4T1cw+/2XtedYypXsM6Dm+cYN8I3UPJnOMbexFA== 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=OJlecboikd8jAUBfmPbRPzYGdu4c53JvHpM3dMgaVyk=; b=c3yo8wWoJb+oJgWJBsv7IPjQJap040OKgroI5aCL9VK/Kl/LaKCqvWtJgSwGOHxA88AEC2lDBM1oy8S1LGW67oJy4CfOc8704qxmc+R47ymxRw5NaLHp/JteS9SZ0Y/rcU8RtCenolDxkST90CDsZiuIxt06DmNH1gx/7FX2Sn7yEyKfXHmI01Ct5WyxxhPinz4QeE/v+qE7URHFdyk9viqceu1ZkAuped4/3P8vjot50Zhxdmw7Hf5CohwHtrdG5DLMEcJUr1fDX//Y9CchwjPxCo3mUuL0ZfrU4NZeDMdsZtsDFTKHUgFnz0vkxqiwZ2cidG81YeFMXNFV+zj5og== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=OJlecboikd8jAUBfmPbRPzYGdu4c53JvHpM3dMgaVyk=; b=J9cILS4IXjRDPpevQSixuntVw3SungrudPOGR6d9lzlfz1gONqYqEckM7WYp8BYUyAEQQwYH7No4lwNwQbbxjP5XGsaUgJzW3bUm29fBmynh2yQRyRq4gULaIcjPuWHZxFV+uAFJa6jvnYqva6Qevl5Jaf3/JJ7b+IFk80EXwwUkBf/ydKZFubnY1f0I9rULR9akldMWB8ZuHaQeiYO7fu7Lj6EVch1uWnvhtUoPkSQ6oT+SJOZiXZ6+SlFc0M+h9C7sRULrJuSQGQia92EX8/rqEOiolHbA6A9lREDDYrlVmY5BOGYNgfZp4pqiJk7zZOg9BpjU/C6MkouWHGbPqg== Received: from DM5PR07CA0050.namprd07.prod.outlook.com (2603:10b6:4:ad::15) by BY5PR12MB4968.namprd12.prod.outlook.com (2603:10b6:a03:1d2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Mon, 14 Nov 2022 13:18:17 +0000 Received: from DM6NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ad:cafe::80) by DM5PR07CA0050.outlook.office365.com (2603:10b6:4:ad::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.17 via Frontend Transport; Mon, 14 Nov 2022 13:18:17 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DM6NAM11FT013.mail.protection.outlook.com (10.13.173.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Mon, 14 Nov 2022 13:18:16 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:10 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:09 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 14 Nov 2022 05:18:07 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATH v2 2/8] vdpa/mlx5: Return error on vlan ctrl commands if not supported Date: Mon, 14 Nov 2022 15:17:53 +0200 Message-ID: <20221114131759.57883-3-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114131759.57883-1-elic@nvidia.com> References: <20221114131759.57883-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT013:EE_|BY5PR12MB4968:EE_ X-MS-Office365-Filtering-Correlation-Id: b30b7798-dae3-463a-8146-08dac642b14a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qtd3ZWCAb5ppQ5qW2HzQdpu+6tPcnxaYquwt8C9H/nk2TCpCPInfwaooQ62TA+xVXmcybCP7ZgcPi3sfNaP7+E+4qBjM8TEWqHQGW2JS0ki60YxCX//lxNc3z6/sZmvsFYHvQbuGfc4wBGy+1zwLvXnHpulFiRehBQUPTH0nWpUDCC8xPVw49XCdnQHKkDOv55GMMdHazV6KE6OF1OypXIoONioY0VgeZ+OC686FteflKZB6I8hOqFTE25A4xm2DIrzWDJ/u26nkA7X9g+rWwZqIzVbeK2pNmEQfum3HsZwaq0Ed7v5gNGTcFbMwym/KaeYj16gw5aMeT3cWN9jweewvSNKb+eEV2VbN7p+UNbQ4vfWcpP2C5PD0xO4aE0r0pXCXzgubD7tXroHO36Op7MFlsa6FWNpJBZ0ZkN3tZ3Y/VS5NrCfE5ZfAPr+XQZ2fDP67tusReSfhoVXTGAsVWKsyVyo6lMq4yUTI7AYTry0mf5xeQ7UBeN5ilGaiTQiWv7L0VAbm9piAmKWijNdeOxi7QQLtV2dHQ7lK46dvHWXaPv3Iy7qfps9VLp6Rtwv11Z/f0FBk61uKinTrg28Y4iiQC9auIiQavVD+VvpJtX/MO3jp4G1vORRFi0BeTXzALlh2fECT3FIaYjtdUTG7vyvugm61qY4NcNqkl5KghyamIvC8ewLNsfmPYwwQ9aJ4ZJ0zJ5aD600vCyu7+EykSC/OO87UMCyItkczGXxGZUZr5fbkRamI2k0U1oRJ9YYs8GLrMWIjUYORdAOgR6YEvA== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(39860400002)(376002)(396003)(346002)(136003)(451199015)(46966006)(40470700004)(36840700001)(40480700001)(36756003)(40460700003)(54906003)(107886003)(6666004)(110136005)(7696005)(2906002)(336012)(316002)(82740400003)(36860700001)(47076005)(426003)(41300700001)(70206006)(70586007)(4326008)(8676002)(1076003)(5660300002)(86362001)(26005)(186003)(7636003)(356005)(4744005)(2616005)(82310400005)(8936002)(478600001);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 13:18:16.9531 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b30b7798-dae3-463a-8146-08dac642b14a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4968 X-Spam-Status: No, score=-1.1 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?1749478638311594818?= X-GMAIL-MSGID: =?utf-8?q?1749478638311594818?= Check if VIRTIO_NET_F_CTRL_VLAN is negotiated and return error if control VQ command is received. Signed-off-by: Eli Cohen Acked-by: Jason Wang Acked-by: Eugenio Pérez --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 3fb06dcee943..01da229d22da 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1823,6 +1823,9 @@ static virtio_net_ctrl_ack handle_ctrl_vlan(struct mlx5_vdpa_dev *mvdev, u8 cmd) size_t read; u16 id; + if (!(ndev->mvdev.actual_features & BIT_ULL(VIRTIO_NET_F_CTRL_VLAN))) + return status; + switch (cmd) { case VIRTIO_NET_CTRL_VLAN_ADD: read = vringh_iov_pull_iotlb(&cvq->vring, &cvq->riov, &vlan, sizeof(vlan)); From patchwork Mon Nov 14 13:17:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19802 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2145767wru; Mon, 14 Nov 2022 05:33:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7WIrcvBxliO8xTwFNU0kPQot8zujptHUwYwD4nkFH5EWLOCdhh2LumBeS8ObmscJMmxXmf X-Received: by 2002:a63:f52:0:b0:46f:f482:6920 with SMTP id 18-20020a630f52000000b0046ff4826920mr11700359pgp.327.1668432813518; Mon, 14 Nov 2022 05:33:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668432812; cv=pass; d=google.com; s=arc-20160816; b=fxJznfVuxWk2koGeF5h/1JPXeOfu0gh2yqGr1fxamKUdxJTCKC4LgCJh30U3CBjxWv emaGFkyl//ZFxvMJxFoqZx1W9vo57GAa9fF6Z31IG6P+jfEN3v647cx6ISOW3zAGz/xb wew5SxCkHhwzw/sB5cPNAkmhEtwbi4qjWTHIaVF995p38VHXqtKDvf0agQPmkkiTDBZ6 i7g3Nyh9js3Z/pJny65+sqy4eFIDwEuny3VAQFZERnorPm9HVL8KAGNP7kglrAppMMSW +u9TuuMgkmq0PX+v+c8PbO0I/lLQaJTmwWI1g2e/qzDXAZfeEfAlyLS7FZkxbO0edJQD K0mQ== 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=NsgrjLBqFXTVeSS1fa67U60MVyrB2XNjlZk4BR3Pzos=; b=r3yLWmI/kk+czg5/84gc3fGdjTVfgvKcgkY+938MP3Iu3AVxM5HgINOeMy21ilQyxC F8xFjf9nyn+IhNiVvFaEfnK54Uw8XSjUL6X8JS7BfI94fzT1hh09KrpiusYK1ylAPiw6 2fC1wFASgVCxSAPMgFHHDbGZ7FMv6nLqe0g9DO5P4vv/Nj/ETgf0l90m/99fcx/246Is 8CuuplgVVslMe4FWPquPc/OHNl90BqD/Z393tlg1Me5ogAkdf26j5xoij38kyQFnhpbC JbOL51iRkMAuXQzlyKWlWKcwkB/mnA0WxggV+jIKBXpamGESpXBdxlMCe/OiHyha65dc +csg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=i3VCA6wc; 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 d21-20020a056a0024d500b0056bce3dfaa8si9965626pfv.27.2022.11.14.05.33.19; Mon, 14 Nov 2022 05:33:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=i3VCA6wc; 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 S237964AbiKNNSu (ORCPT + 99 others); Mon, 14 Nov 2022 08:18:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236888AbiKNNS0 (ORCPT ); Mon, 14 Nov 2022 08:18:26 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2081.outbound.protection.outlook.com [40.107.94.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88B5C1DE for ; Mon, 14 Nov 2022 05:18:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TOWTQrvh6nMBCZdu0J4zm91Ejb6vbS89Jlw5JSOpKKwUp4BhE5AejPYuV9zp7LvoQjeXIl3jJ8uXuflzpO98dxgE7b8JCFm10e5G5nNZU6itokrQqyZCd8yH4/zVr5Tuq7DiFhdJhermwM7Yz3RWvPYycbEPRWlWbGj9B/MMRsmpvotgTCzth7H00Z27KqRLXOBO2y5cadFdDwtibeEaMs7+dV/PMnlvJOuA8MUllTD385fryKbDE0YHMt0CUUG/K9sRTPdd35ndrojB/xeQba+E/bU7ul/1sJFtSsYIn38Nsx428kTm+firmc8sdD+n+l4cbz0iYT4EKcKXe6cm3g== 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=NsgrjLBqFXTVeSS1fa67U60MVyrB2XNjlZk4BR3Pzos=; b=a8EV2S8nDvGw5cKZaIOn+U5jRvMLHv3XuK93x0JlNHln03pYuFOu4fARLSiwTiSIqFS0JUD5Lq/izAg1QuaWoGPVWoEUHZikhDKXWBtypWQq1r2EfBy6OaYMAwpAEqWiAsoxjWQVUA6lmhFGzrqb0Zv6GmozMj73l//zR1sixNrPcCazZbXMiPL+jR64ZuqgFbJxl36y/aBPeXSy0lolt+ZOmlFJlZRncx7TJgMQca30F1C1OJr1fVcdZE6+UtPChDKEXE85cgCCmV2Td+K65Uh1V/qDgml4Xm7lUQSjmH4j0u88c5OKr6wkdI7TNwpHJAjOAkA5KHpXS6zpLdhiCg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=NsgrjLBqFXTVeSS1fa67U60MVyrB2XNjlZk4BR3Pzos=; b=i3VCA6wcFhJ2sSO5fwNhHhaqSZsxA4B1Rf4mNw9JU6DybyFd2AE0F70MfcB0nfqXY7YBawASioDobefUeADGrcQYzD/dDK3xyREI81YShHvwRs9zxZPPVmNpqjonPwq09I9r2Jb5sIU+5LtVxjOqJw7oFj4ONzfDIrReGRcdls2CZwJnonWBPbpO+PQHBApvdN4CdcBs9C9op6WDUVFjtTMwkEHNaCR8eAl9sMUGhAR1JY+KF9WktD8PtwQsPPaNDiCOPgA7n8GuWBt5EA2Ob43uJISsE26tg6UwTWhj7RhH/XbEvNbg6KYZ5PBh4y48P5ROSZEEsYUfnRyaBrNl2Q== Received: from DM6PR07CA0041.namprd07.prod.outlook.com (2603:10b6:5:74::18) by IA1PR12MB6092.namprd12.prod.outlook.com (2603:10b6:208:3ec::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Mon, 14 Nov 2022 13:18:21 +0000 Received: from DS1PEPF0000E657.namprd02.prod.outlook.com (2603:10b6:5:74:cafe::6c) by DM6PR07CA0041.outlook.office365.com (2603:10b6:5:74::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Mon, 14 Nov 2022 13:18:21 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E657.mail.protection.outlook.com (10.167.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Mon, 14 Nov 2022 13:18:21 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:12 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:12 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 14 Nov 2022 05:18:10 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATH v2 3/8] vdpa/mlx5: Fix wrong mac address deletion Date: Mon, 14 Nov 2022 15:17:54 +0200 Message-ID: <20221114131759.57883-4-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114131759.57883-1-elic@nvidia.com> References: <20221114131759.57883-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E657:EE_|IA1PR12MB6092:EE_ X-MS-Office365-Filtering-Correlation-Id: 475ace20-c7c3-4ad1-3642-08dac642b41b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VsR7TpiJuGKn8g9sVuDpgQYP4NmS63k9QQ58ikCllfoLdoDzjQcmVULeHxk1bbipBsOgL2ftstV7umUbaQcwZAeH4wLHTxpgIPGGrqMOmjbKsMX0VH1Zv/0woYE3VcploZ5ke/HDMkt4UGgz8eX2wUZMpmAy/BFM6eXPrtqUelPfsf3/aMxmVUjRT+t8L6DVRsPIeMzo/OZgUHZ/Y4IHpvhGBmuz79ootIjCXNDDCgeTCEvB73EJGfKPQVwT3zwByPCua98866lp6RpAj816coZYN+7fJLzwvoRz2RBB9CKa/GnMOWHd6alM9fbkAgi6VBR8KLVlAgr545lXgyCkEm0fnZts+XVHMST+vy5P9sCUS78Z8osOaCSj4BDRNzb55kEmsSm0OPf87oPAFFpzRIXChbxHBWgY+kxmQUL3s2TWHKQveDWAAWqK0F7YFe+zJZ9oJ1WRZCQa2zB6SNXYuWOMLQeIIHxy/PUVgIasUeQATYucnBqwpTB46cGz00lgG+IxTcFeyw3+teaSfBE2ycPJDzHBOGIGWBgyiDeoBsJ/biHv9E4/BkmAYgcr9iD5DY3wwOiuLmWwk0Yegcb9h0MJRQh6UezIjRu9h+lXPTZX1f8mMoah03mwkXutXahpNyh4+E5JtTw1gZuIRPb8RVwUbtokaCy4P9RsC4ibPeXaVdz0T+6QBJve53UipvctjLqDbzFL42X8qE9sGnsZvSk1bcQsxxoqnWaeMLqrBgGaGExjhs2K87m60TliGtjnS5sktH56Dku0X4CXwi0JwA== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(39860400002)(376002)(346002)(136003)(451199015)(40470700004)(46966006)(36840700001)(36756003)(7636003)(478600001)(40480700001)(82740400003)(36860700001)(83380400001)(86362001)(82310400005)(426003)(47076005)(7696005)(40460700003)(2616005)(2906002)(26005)(4744005)(336012)(6666004)(4326008)(316002)(8936002)(5660300002)(54906003)(1076003)(110136005)(186003)(356005)(107886003)(70206006)(8676002)(41300700001)(70586007);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 13:18:21.6763 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 475ace20-c7c3-4ad1-3642-08dac642b41b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E657.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB6092 X-Spam-Status: No, score=-1.1 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?1749478604780464966?= X-GMAIL-MSGID: =?utf-8?q?1749478604780464966?= Delete the old MAC from the table and not the new one which is not there yet. Fixes: baf2ad3f6a98 ("vdpa/mlx5: Add RX MAC VLAN filter support") Acked-by: Jason Wang Signed-off-by: Eli Cohen --- 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 01da229d22da..b06260a37680 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1686,7 +1686,7 @@ static virtio_net_ctrl_ack handle_ctrl_mac(struct mlx5_vdpa_dev *mvdev, u8 cmd) /* Need recreate the flow table entry, so that the packet could forward back */ - mac_vlan_del(ndev, ndev->config.mac, 0, false); + mac_vlan_del(ndev, mac_back, 0, false); if (mac_vlan_add(ndev, ndev->config.mac, 0, false)) { mlx5_vdpa_warn(mvdev, "failed to insert forward rules, try to restore\n"); From patchwork Mon Nov 14 13:17:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2146347wru; Mon, 14 Nov 2022 05:34:49 -0800 (PST) X-Google-Smtp-Source: AA0mqf6SOAzbXeHfykta+0ygCOPVIRVLcUBOy7wUitVTtIncMVPDqimy+jUNocAgoDMGugm1xTF3 X-Received: by 2002:a63:560e:0:b0:476:837c:e0a with SMTP id k14-20020a63560e000000b00476837c0e0amr4143456pgb.411.1668432888984; Mon, 14 Nov 2022 05:34:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668432888; cv=pass; d=google.com; s=arc-20160816; b=nNZSp72vccvmShLsdgaiPDDYshcWGVNPEdTL8RQsVIwmP351b2084lqLIG/48uwhIL CM6noiPnzuyLZf1MYxcG5KhRnGdZa/EL4B6wxcWIQ4BG6e8/ZFdFgHsGYFEysxUUk7Hp E86NPxFb2AWxkR7BJOqZJDin10z7iyje0wm7Ix9thaesga7BJx/wkxVgevUmDYZH5VWu G6I+4G/S5rwqY2qChK2HkiLeVU0VdkV+djFu6kCMCWMzODIhqDX3S5Ch1wCMFXFovLzO Ek2lDaOLVfK5WSIunV8oNDXJ+xDn2EKGrdWIgG9rDiGQkp1BgEv/Pj7Nlw/EEupyCrzf SeoA== 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=47KHRZUOqCD47Bd3hGZcGhnYXypbbdjn/wRrjSejX/0=; b=Yw3Ik1KtyFEiDmaumIZmppC1MgrxypWSs7nSC90rQEd3CXnaZdhrZX19T4n/NaaCk6 ScC6KDmJl4HsLNGCiaiGg/w8EEZ9Fr6V7V4SVshkSjcQjbN46eq/iMUjkywQWGtlgLv1 dYdJeAKtoVlcGry89BwlVY0W2uYS16/P+3KUGWaZAfvfbDrR6+iR8qGldsoI5SP9nvwL N/spw7SypLCnZL62WrhoWPSIkv5XhqGWpJPGeNmVLrjDEVB+F85AjF4NrBRB8yyhQegB YwngLThzY7huuc/4KzTW9q+Furrih8GrMLtj2TovL1wvhyvv32WavzOOEsHBm9Z+BLtH 10+Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="q7b0lP/v"; 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 13-20020a17090a08cd00b00217d892ab40si13121687pjn.29.2022.11.14.05.34.33; Mon, 14 Nov 2022 05:34:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="q7b0lP/v"; 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 S235633AbiKNNSy (ORCPT + 99 others); Mon, 14 Nov 2022 08:18:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237502AbiKNNS2 (ORCPT ); Mon, 14 Nov 2022 08:18:28 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2072.outbound.protection.outlook.com [40.107.92.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EDD5E18 for ; Mon, 14 Nov 2022 05:18:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G2942ZWVQZxkTq5+4twtblq0E+5INDorQWbGp5lkTlM4aXtim6cRy/I9M8dPz4oTlozGKcyXlCex28Y3aMLZRDpuRqG8gaYd49FxM78JTB0svf6zpPYCaRpXR2fVL9kRYoP/FBpG3uNM1khXqyeUzkgQwjguuZGBo4TC493z/vbfe8w7uqvaBKjtH8Vj9A6oF1V8UCqQxs0xbqUgcx5pHusRgJ1B6I9jhuYkjkdFeCvMhuoSq4jZlQyaT5k8t43FiAjPb47ouhLeDb5N1GWS5afZHjTGDvM1Yu5pKffjkVZsuPAEzVj6PWXI9imF5/yujpdxAq68eFdvyAqpOHLE7A== 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=47KHRZUOqCD47Bd3hGZcGhnYXypbbdjn/wRrjSejX/0=; b=jHL/KThlZ9TNskQ2rS8UKMHEKolw7sTDD8V+E36CoKig9Rf3EZjpJ3nN4sHLU3dwbKfh0q0fwoug5CUVwbf+SjknDhN5k9l2GRa4T9TtBoxgJh2A+PwsMuBZZ9690ta7sBxasWo/kS6IuLDEgAOm5KBkxBtkfRUasyDbtrRN6gdoBspYA6LGY3dsyexRFKd7BZCuzW9ScU+ef8llOJnfMOXbnINqu4k/qH9pYIoXDA0NDq+NPRdjqUNtAc6Jhf4+ktGvYhNjvwhKupFj8YZ98OUzxqgaD8swlwl0vROref1yBbkhua6cObuDsNbqt3B7qidolrUypsuNJ5FHacVPHA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=47KHRZUOqCD47Bd3hGZcGhnYXypbbdjn/wRrjSejX/0=; b=q7b0lP/vtPIVoFCz3owL708kN8POG9DSQgnFs0GhckfJTlRdUrUnc+QtNXeXpF4QwcTSopx1L8DvRoGj2VQCDS6zotW5Gr5/KmO4Ual7rE4GamjzqpkhU7aytng/woUpfnzXHTsB2vEKlmL/w7H4KFlN16Lquyf08HJjR97C04fHxuHsXVOF/+04YghMxlE6wIB4lACwHefl3pW0MhzfqNIBlfdwJjcac+9xdDcp1AhamXR7ZI08Oo9IubGV4tWjis2eZRMRKIiifZe1BGWQ1JFdQuND9Bu7ILtD0eX99okf8VWEexzBp6SoP0B/KjgtGDe/gvG+HfmlKxdKKjGlEg== Received: from DM6PR07CA0044.namprd07.prod.outlook.com (2603:10b6:5:74::21) by MN0PR12MB5714.namprd12.prod.outlook.com (2603:10b6:208:371::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Mon, 14 Nov 2022 13:18:25 +0000 Received: from DS1PEPF0000E657.namprd02.prod.outlook.com (2603:10b6:5:74:cafe::59) by DM6PR07CA0044.outlook.office365.com (2603:10b6:5:74::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Mon, 14 Nov 2022 13:18:24 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E657.mail.protection.outlook.com (10.167.18.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Mon, 14 Nov 2022 13:18:24 +0000 Received: from drhqmail201.nvidia.com (10.126.190.180) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:15 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail201.nvidia.com (10.126.190.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:15 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 14 Nov 2022 05:18:12 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATH v2 4/8] vdpa/mlx5: Avoid using reslock in event_handler Date: Mon, 14 Nov 2022 15:17:55 +0200 Message-ID: <20221114131759.57883-5-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114131759.57883-1-elic@nvidia.com> References: <20221114131759.57883-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E657:EE_|MN0PR12MB5714:EE_ X-MS-Office365-Filtering-Correlation-Id: fbe47cfe-febd-4e7e-1eac-08dac642b5ec X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8CZnoqJPvifX6f9h7rJl6p9Sk7MteqAN2SZZYcY5zYZIFQTgWa2ortD2+Yk9laEM7iZd3vcvKdX7K7cHtht5ON+60BQybu7v+a7xGXIXJaIrd7nT9UGBdYUMQ7HC7QNOV3F8Bs0NXoNfYkTBkq/+uB3LSYKgBJO8jQzt5BLqK554FoNl7R71OvwRyx21ZTX70+pJiXa4fh1SQsT+A7owrxfdmBBfjUlXI+jfnTOx1+Ff4o11sUKOgiunAWsiERGN5hs+6+my9+SrvM5w+MDgq+6vgyxj9YBTWiRoeXjfPU2UU3WBvipgwSHuIWfE+AuOFf0xutCLxmTxuprb22dxZaXgb77qKOlxj3JCVh3P6Cjp+a7Cw3lbkPoM0ZT0UnG2k5FzQUjQ7PyXogVFqDxm93iVit+jhfboEaVp9pZk9O7M5K6V46dESEavVVnnjIQzvTzW2VzFqrrWlLjMDIS1llvTqROglaY96mi79KRyantrmLsKZODd2iz7nvsXVgGrPEmOwqly2dN64Y7QtNAW5pirAUfFgvLUGWjTgGUJskJbXIBQTgoqmJiDMl9yGdnSHJQZzVM5Z33jeDRDS5f5xQ7fKAhVHzD1ZL6tOGV+ptfeAQw0NceHpnp8+nQF2kyLMEq1KCkip00GLgxKsA9LV1bnxyb3LOMqP+HG7nZQuWhTuSe/p68m77d7YWXDyw7FZnF+a6sdo68POqtALtzilJ9Zore4vGCBybF0lJPSqLHY5vclhyWNzYWUg8XKHWepzWDOgAriVK3Azj5RRoE5Bw== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(376002)(136003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(40480700001)(40460700003)(86362001)(54906003)(36756003)(356005)(7636003)(82740400003)(70206006)(316002)(70586007)(8676002)(4326008)(2906002)(41300700001)(83380400001)(426003)(8936002)(5660300002)(47076005)(36860700001)(1076003)(110136005)(107886003)(6666004)(478600001)(82310400005)(2616005)(7696005)(26005)(336012)(186003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 13:18:24.7231 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fbe47cfe-febd-4e7e-1eac-08dac642b5ec X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E657.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB5714 X-Spam-Status: No, score=-1.1 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?1749478685240735245?= X-GMAIL-MSGID: =?utf-8?q?1749478685240735245?= event_handler runs under atomic context and may not acquire reslock. We can still guarantee that the handler won't be called after suspend by clearing nb_registered, unregistering the handler and flushing the workqueue. Signed-off-by: Eli Cohen --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index b06260a37680..98dd8ce8af26 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2845,8 +2845,8 @@ static int mlx5_vdpa_suspend(struct vdpa_device *vdev) int i; down_write(&ndev->reslock); - mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); ndev->nb_registered = false; + mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); flush_workqueue(ndev->mvdev.wq); for (i = 0; i < ndev->cur_num_vqs; i++) { mvq = &ndev->vqs[i]; @@ -3024,7 +3024,7 @@ static void update_carrier(struct work_struct *work) else ndev->config.status &= cpu_to_mlx5vdpa16(mvdev, ~VIRTIO_NET_S_LINK_UP); - if (ndev->config_cb.callback) + if (ndev->nb_registered && ndev->config_cb.callback) ndev->config_cb.callback(ndev->config_cb.private); kfree(wqent); @@ -3041,21 +3041,13 @@ static int event_handler(struct notifier_block *nb, unsigned long event, void *p switch (eqe->sub_type) { case MLX5_PORT_CHANGE_SUBTYPE_DOWN: case MLX5_PORT_CHANGE_SUBTYPE_ACTIVE: - down_read(&ndev->reslock); - if (!ndev->nb_registered) { - up_read(&ndev->reslock); - return NOTIFY_DONE; - } wqent = kzalloc(sizeof(*wqent), GFP_ATOMIC); - if (!wqent) { - up_read(&ndev->reslock); + if (!wqent) return NOTIFY_DONE; - } wqent->mvdev = &ndev->mvdev; INIT_WORK(&wqent->work, update_carrier); queue_work(ndev->mvdev.wq, &wqent->work); - up_read(&ndev->reslock); ret = NOTIFY_OK; break; default: @@ -3242,8 +3234,8 @@ static void mlx5_vdpa_dev_del(struct vdpa_mgmt_dev *v_mdev, struct vdpa_device * struct workqueue_struct *wq; if (ndev->nb_registered) { - mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); ndev->nb_registered = false; + mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); } wq = mvdev->wq; mvdev->wq = NULL; From patchwork Mon Nov 14 13:17:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 19801 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2145764wru; Mon, 14 Nov 2022 05:33:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf4b1Rwxs3qld58acFnndI6HZRP0AiEUaAgeWVcOqbKS7SLaXFEYJhjTFKs88yDeWsSGWeO/ X-Received: by 2002:a17:902:a414:b0:188:abcb:a0d9 with SMTP id p20-20020a170902a41400b00188abcba0d9mr13035729plq.146.1668432825958; Mon, 14 Nov 2022 05:33:45 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668432825; cv=pass; d=google.com; s=arc-20160816; b=t83HfU4WHfZkf9guibjQJq4gta5Ybw4QCmhW6y8syuIFBu48HnwMo1m00n1Rekvvch xKSTYlRBnMP+Eo3Xsk5COR3bUuMV+02G84ueP0d8L8V7VzjgE1eSriHvwGxQQJe8zR3h sCrU6LjZ+br3GB0qd79vNuJY2cp1HsaQStzSrAABN4pDIqxBnTTgKw+h7slylwJhml3s w+mOpsA6RaYRQrmBTYTXAkoCqVK5HIsXK1UCadmcRGDsXfw7p3bhNhgfl0pL+Qzje/NC Tx6uceIgC2ZlQ5/nBpuTiws97NFkGOZ0szr0IjNOQbvpptBu1fGGXpomVKMEDmqPmzzh 3zGg== 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=OtMQ29h7Lk9QzHwCmJLYeJ799q5fNEMHc8rySqMW+Ac=; b=WDhlS8aTOnMPL/Z7/VryStfMsxbITS3ugsAUm998sIqPmyxzmAQCD9Qfp8Oip0dISb 0G+4tJiRp2X60yrG0rHKwVtXmV6J223IEOd8abmFmPHIQpvlmqlYraVmdS+7gI4f9q/O RBJycL+Mq+GE/zu3TMbf1HgV2MFeHps1GFRbpHQh2bl0PuK73ELEqvcKc69A+EDZrLOB /Dlv9fSdBb18wwjIXcVoLd1bgdDhsnTTSHIa0LvoR1CBBkcim9kWrOKWCQCilUHV7Ock fcgYUNHj7p2RN1YQlLVY7A3plC7Bm3Uzd6jn/lWQNekNKmTF/WsTcbhFA1wGxXT/iWnn NYOw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="Zb/qEBET"; 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 r12-20020a632b0c000000b004615836deeasi9573823pgr.860.2022.11.14.05.33.31; Mon, 14 Nov 2022 05:33:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="Zb/qEBET"; 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 S237510AbiKNNS5 (ORCPT + 99 others); Mon, 14 Nov 2022 08:18:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237501AbiKNNS2 (ORCPT ); Mon, 14 Nov 2022 08:18:28 -0500 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2071.outbound.protection.outlook.com [40.107.94.71]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17729DFD for ; Mon, 14 Nov 2022 05:18:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HSQLruxwDXnI9B8PJzp6ljAoHcMVVsy8nXzS9eYsqvFRZxGs5k8PrSpwIILFmz1IqRDo+52O2qDDNZFu3OydVwU734j/nJa5c33KeSfk/e5H+9+isGx4V+P44ZddCOneSORAQpn9e6SiCZNReh2gmsltlcH79u3W+QDTkLS6KwltdED/OCP9k82dycBEvWzN6iyzI65d+yobNmWPoZ9ShXyU/792Bt0plWVBKZz8nWk0NqFB920wxiHdafossQH0J0YCcS9CHZUwGHz7PadywoO+k8uRPcApJSy7/ovOvmlJhvtjfiNbZANE3JF2gvKCYoEQW+ZHoDrD4p6H7rGkuQ== 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=OtMQ29h7Lk9QzHwCmJLYeJ799q5fNEMHc8rySqMW+Ac=; b=nWq1hsuH+W1wJAiajLLhabUsE5yW9rw3JgogqYc9RZfrxGGlCsC20Vhts7/n/R8qrY5wq4Nw45POGwyNjLhsjPP0b2Ywr4gzS9EMsGmLAW9Ue7B+Xc4zDeikLyqxoP7sPokS9gUwxXFVRfXqpb1jVmTJw46sIcXO22ULj290q7HKOTMgWa7Ek8X+mcLDYRwsyGtwSM9q82tQxmE1Kb+4lkMFezRrNL9k/ktLHEjbywXgy/8wtKfMG7OcWOCEJa8ZfS22fWlqfad3B6U86aI5XD3L6VQmtOjdNLiDXWZC31TDnDmmms7E3GsCFja0z9ZP0nMXmFtsRYvsVoQxJJDsNA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=OtMQ29h7Lk9QzHwCmJLYeJ799q5fNEMHc8rySqMW+Ac=; b=Zb/qEBETTCSUIkkPV9FQk8DpFzgIIoI598uBAZ06TOmITLtMKSOtOd8fcR/v4WE05cbZgF3BC88TvB/tNEGW+Ii+Zt/P9D2Q0nfCkNJVhFuu8DuOeeOUR/qyzDiosWtgk+Cdp7/aejM4qMHzx5ID/XdBMCSz/Tj5y/lIvI7f6l1b3/Cw4L6+l6QgxotAhOs5hTcqStDLgSb+8Rdn+lnubEUDy6+uUnwFkoPbFL560iEQBsaD1B0DoL7dBtvCIhwuaPf5NVkwcM1ofeU+UZSGr4KXCN7g0Xe0REZgpEthWFgwAIXWg5UpiVj1xZQgPCeuYg9AijQS3fYzqSnhgMkr3A== Received: from DM6PR06CA0004.namprd06.prod.outlook.com (2603:10b6:5:120::17) by DM4PR12MB6615.namprd12.prod.outlook.com (2603:10b6:8:8d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.13; Mon, 14 Nov 2022 13:18:25 +0000 Received: from DM6NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::a0) by DM6PR06CA0004.outlook.office365.com (2603:10b6:5:120::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Mon, 14 Nov 2022 13:18:25 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DM6NAM11FT009.mail.protection.outlook.com (10.13.173.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Mon, 14 Nov 2022 13:18:25 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:18 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:17 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 14 Nov 2022 05:18:15 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATH v2 5/8] vdpa/mlx5: Avoid overwriting CVQ iotlb Date: Mon, 14 Nov 2022 15:17:56 +0200 Message-ID: <20221114131759.57883-6-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114131759.57883-1-elic@nvidia.com> References: <20221114131759.57883-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT009:EE_|DM4PR12MB6615:EE_ X-MS-Office365-Filtering-Correlation-Id: 72a29b43-bd70-4481-79a6-08dac642b674 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A1AP4VzRd+1BQzCfrxMTwd23/tWR1iOYlj3/zBBhj9hO9rcwiOgwvLZl5YQZLk/PPJkdbTMc4L+zfE6LJDIbeMyJWeJPLCCxZaTEHEOfv5/TE7tJGhV496tXRxT0mMB/l26GkDIL3ZhSvNqa5Fj+Dj9WKJYiHyKqASCTXPzsKqxYSA5jKNAJN0IhEsxSGoMmZ2eqlekKewP/EhFHqfQicHlzTpDbLP7OULFWqAgKGa9dkx0vn4vBRzl7hQB9AhYZWl3oVwd1KoaJ2HmfjFHEb2oMgbUIEsPPykM4ssCca93kJ5eluVUBS8EMpYU4urfiFRK/yoNhVqWbRA65k4/YfASnFUyN6IzNgYehcPKaOAxu56CSgnZP2sgyl2KpNXhvqDJu7ncIDRsmn8ExEUIOK1weuwq43W+jRDSBIve+0/+Evj4+wbkUtK85DmJtC1nXGYSAgYMx72OoP0tp7Dzy7VtUCx1korDQpX7KsXXLGt5IXX2IwXFl0+5BBTBkBepRVNq037KlUjbI9R0AOCamyJdX7nvwc3SokGRs9PmFqxz3buU0lUX+jmfqD6+9cfSyb9BGqdnYb4YyF8TMPXU0xYJvPTRyeJvxzgUAxobCI+x++qgUzBWOrqGunv8kInrVIpL2UAI9iK0Er8l1JwGiR0HVl85rWOjwNK2tFsIVF926nP65UqfaghGbViwjFXJFeJXINzjzeULzSaN1gMfETspr76gGG3lrZF5N6xl0XGn1+6hpouRgClfVWHa4CpaVC5gConXxXqMWZy4afg94Rg== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(346002)(39860400002)(136003)(396003)(451199015)(46966006)(36840700001)(40470700004)(41300700001)(478600001)(8936002)(107886003)(356005)(7696005)(6666004)(83380400001)(26005)(82740400003)(5660300002)(36756003)(86362001)(36860700001)(110136005)(316002)(54906003)(336012)(70206006)(7636003)(2906002)(8676002)(4326008)(70586007)(186003)(1076003)(2616005)(40480700001)(426003)(66574015)(82310400005)(47076005)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 13:18:25.6011 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 72a29b43-bd70-4481-79a6-08dac642b674 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB6615 X-Spam-Status: No, score=-1.1 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?1749478619231937656?= X-GMAIL-MSGID: =?utf-8?q?1749478619231937656?= When qemu uses different address spaces for data and control virtqueues, the current code would overwrite the control virtqueue iotlb through the dup_iotlb call. Fix this by referring to the address space identifier and the group to asid mapping to determine which mapping needs to be updated. We also move the address space logic from mlx5 net to core directory. Reported-by: Eugenio Pérez Signed-off-by: Eli Cohen Acked-by: Jason Wang Acked-by: Eugenio Pérez --- drivers/vdpa/mlx5/core/mlx5_vdpa.h | 5 +-- drivers/vdpa/mlx5/core/mr.c | 44 ++++++++++++++++----------- drivers/vdpa/mlx5/net/mlx5_vnet.c | 49 ++++++------------------------ 3 files changed, 39 insertions(+), 59 deletions(-) diff --git a/drivers/vdpa/mlx5/core/mlx5_vdpa.h b/drivers/vdpa/mlx5/core/mlx5_vdpa.h index 6af9fdbb86b7..058fbe28107e 100644 --- a/drivers/vdpa/mlx5/core/mlx5_vdpa.h +++ b/drivers/vdpa/mlx5/core/mlx5_vdpa.h @@ -116,8 +116,9 @@ int mlx5_vdpa_create_mkey(struct mlx5_vdpa_dev *mvdev, u32 *mkey, u32 *in, int inlen); int mlx5_vdpa_destroy_mkey(struct mlx5_vdpa_dev *mvdev, u32 mkey); int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, - bool *change_map); -int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb); + bool *change_map, unsigned int asid); +int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, + unsigned int asid); void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev); #define mlx5_vdpa_warn(__dev, format, ...) \ diff --git a/drivers/vdpa/mlx5/core/mr.c b/drivers/vdpa/mlx5/core/mr.c index a639b9208d41..a4d7ee2339fa 100644 --- a/drivers/vdpa/mlx5/core/mr.c +++ b/drivers/vdpa/mlx5/core/mr.c @@ -511,7 +511,8 @@ void mlx5_vdpa_destroy_mr(struct mlx5_vdpa_dev *mvdev) mutex_unlock(&mr->mkey_mtx); } -static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) +static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, + struct vhost_iotlb *iotlb, unsigned int asid) { struct mlx5_vdpa_mr *mr = &mvdev->mr; int err; @@ -519,42 +520,49 @@ static int _mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb if (mr->initialized) return 0; - if (iotlb) - err = create_user_mr(mvdev, iotlb); - else - err = create_dma_mr(mvdev, mr); + if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { + if (iotlb) + err = create_user_mr(mvdev, iotlb); + else + err = create_dma_mr(mvdev, mr); - if (err) - return err; + if (err) + return err; + } - err = dup_iotlb(mvdev, iotlb); - if (err) - goto out_err; + if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid) { + err = dup_iotlb(mvdev, iotlb); + if (err) + goto out_err; + } mr->initialized = true; return 0; out_err: - if (iotlb) - destroy_user_mr(mvdev, mr); - else - destroy_dma_mr(mvdev, mr); + if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { + if (iotlb) + destroy_user_mr(mvdev, mr); + else + destroy_dma_mr(mvdev, mr); + } return err; } -int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) +int mlx5_vdpa_create_mr(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, + unsigned int asid) { int err; mutex_lock(&mvdev->mr.mkey_mtx); - err = _mlx5_vdpa_create_mr(mvdev, iotlb); + err = _mlx5_vdpa_create_mr(mvdev, iotlb, asid); mutex_unlock(&mvdev->mr.mkey_mtx); return err; } int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, - bool *change_map) + bool *change_map, unsigned int asid) { struct mlx5_vdpa_mr *mr = &mvdev->mr; int err = 0; @@ -566,7 +574,7 @@ int mlx5_vdpa_handle_set_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *io *change_map = true; } if (!*change_map) - err = _mlx5_vdpa_create_mr(mvdev, iotlb); + err = _mlx5_vdpa_create_mr(mvdev, iotlb, asid); mutex_unlock(&mr->mkey_mtx); return err; diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 98dd8ce8af26..3a6dbbc6440d 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -2394,7 +2394,8 @@ static void restore_channels_info(struct mlx5_vdpa_net *ndev) } } -static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) +static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, + struct vhost_iotlb *iotlb, unsigned int asid) { struct mlx5_vdpa_net *ndev = to_mlx5_vdpa_ndev(mvdev); int err; @@ -2406,7 +2407,7 @@ static int mlx5_vdpa_change_map(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb teardown_driver(ndev); mlx5_vdpa_destroy_mr(mvdev); - err = mlx5_vdpa_create_mr(mvdev, iotlb); + err = mlx5_vdpa_create_mr(mvdev, iotlb, asid); if (err) goto err_mr; @@ -2587,7 +2588,7 @@ static int mlx5_vdpa_reset(struct vdpa_device *vdev) ++mvdev->generation; if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) { - if (mlx5_vdpa_create_mr(mvdev, NULL)) + if (mlx5_vdpa_create_mr(mvdev, NULL, 0)) mlx5_vdpa_warn(mvdev, "create MR failed\n"); } up_write(&ndev->reslock); @@ -2623,41 +2624,20 @@ static u32 mlx5_vdpa_get_generation(struct vdpa_device *vdev) return mvdev->generation; } -static int set_map_control(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) -{ - u64 start = 0ULL, last = 0ULL - 1; - struct vhost_iotlb_map *map; - int err = 0; - - spin_lock(&mvdev->cvq.iommu_lock); - vhost_iotlb_reset(mvdev->cvq.iotlb); - - for (map = vhost_iotlb_itree_first(iotlb, start, last); map; - map = vhost_iotlb_itree_next(map, start, last)) { - err = vhost_iotlb_add_range(mvdev->cvq.iotlb, map->start, - map->last, map->addr, map->perm); - if (err) - goto out; - } - -out: - spin_unlock(&mvdev->cvq.iommu_lock); - return err; -} - -static int set_map_data(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb) +static int set_map_data(struct mlx5_vdpa_dev *mvdev, struct vhost_iotlb *iotlb, + unsigned int asid) { bool change_map; int err; - err = mlx5_vdpa_handle_set_map(mvdev, iotlb, &change_map); + err = mlx5_vdpa_handle_set_map(mvdev, iotlb, &change_map, asid); if (err) { mlx5_vdpa_warn(mvdev, "set map failed(%d)\n", err); return err; } if (change_map) - err = mlx5_vdpa_change_map(mvdev, iotlb); + err = mlx5_vdpa_change_map(mvdev, iotlb, asid); return err; } @@ -2670,16 +2650,7 @@ static int mlx5_vdpa_set_map(struct vdpa_device *vdev, unsigned int asid, int err = -EINVAL; down_write(&ndev->reslock); - if (mvdev->group2asid[MLX5_VDPA_DATAVQ_GROUP] == asid) { - err = set_map_data(mvdev, iotlb); - if (err) - goto out; - } - - if (mvdev->group2asid[MLX5_VDPA_CVQ_GROUP] == asid) - err = set_map_control(mvdev, iotlb); - -out: + err = set_map_data(mvdev, iotlb, asid); up_write(&ndev->reslock); return err; } @@ -3182,7 +3153,7 @@ static int mlx5_vdpa_dev_add(struct vdpa_mgmt_dev *v_mdev, const char *name, goto err_mpfs; if (MLX5_CAP_GEN(mvdev->mdev, umem_uid_0)) { - err = mlx5_vdpa_create_mr(mvdev, NULL); + err = mlx5_vdpa_create_mr(mvdev, NULL, 0); if (err) goto err_res; } From patchwork Mon Nov 14 13:17: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: 19803 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2145964wru; Mon, 14 Nov 2022 05:34:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf6fdcGVHKooSkbFuMH7i35hgzbkCz2MZadF2/Go0tTlz8xahELMQR06erRBsrCSlBSKpcRJ X-Received: by 2002:a63:f552:0:b0:46f:c183:2437 with SMTP id e18-20020a63f552000000b0046fc1832437mr11801863pgk.613.1668432842269; Mon, 14 Nov 2022 05:34:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668432842; cv=pass; d=google.com; s=arc-20160816; b=OSFYZaIiPeLhKoLJi9vxr+YHVc/n4vnDzg0mFJ0z9ikfBWOdq3wp5es/rNe7+vRAmq w2s+AcyVD6YCVvjaMXuNl+R56h118JQEstx16DHlboyqhpmGwtIFe/bAhnPUMRcQksRp kaTC811nKK3+yWGW4FF+RaCti1Vs/ah+HnrjR38qFFVYUAEne8ISzR1osuKCboXpNgsw FE9FcjdSjYIQrwns4qZQtiGF3RScmrp8Wyekkyz5MSAspOEmmRTPuObW1MmBqVPblGld SzR7zwgbbGNv+I+Uz/HHk8NvOzTVPc+xAvmVB0qsQXWhWJJDGdF4AWX12HDkmfrNfGgc wwtw== 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=BQO7N62TbSgGDFzRVqbZ/fjSQmCq2j5uGvweKCC16L4=; b=1CEpnE4xyUeBeYlzv9VllWNusf7uTP5ZiYecY7Lz4E/QXF/FuvYu85qgw3qUMAWzO1 NVMsWscn3aWwYIZi86hucHEZZHFHzT6ZFJzeNR/pZRHTguRO8atFUqop1SU40LI2sowK XyFsRmeNoSABCx+/43knS6N+UMT1puVEjnDIoZzs5+yuBsZal9I0FijVqJGUlz2W6Mkz aX/YtHOhVW+ILF5WalxjxTCum7G6xPQ481VXLwDJzHSpBIg1Fc05U+eufjJ6gtqSLz5t nudJzTZw7c3I5KjrjTWOgBKKbnaZmK6NtoIhEwEbxToA1pC3+K15DtmsJaAXphcyr0a9 ZI+A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=uFfgrjaz; 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 oo1-20020a17090b1c8100b002182059ec7esi7510814pjb.145.2022.11.14.05.33.40; Mon, 14 Nov 2022 05:34:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=uFfgrjaz; 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 S238016AbiKNNTD (ORCPT + 99 others); Mon, 14 Nov 2022 08:19:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237598AbiKNNSb (ORCPT ); Mon, 14 Nov 2022 08:18:31 -0500 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2050.outbound.protection.outlook.com [40.107.243.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D6262BF6 for ; Mon, 14 Nov 2022 05:18:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gD5dUasCC3Kzm8hL3TT8K41OZ41UxmeDEXU6g1ewCH6ltAE8lbzv1ozzRyeH78MTIc1PUKIzCq1MgjgCrK3rnRLzG4uoRisZ0wEDhCtA4gvYWQK/2Ek7ofZwCXuTD0BoKfGGbQ0USz3ylfVtLzitkA9imqXc6b4+XfWgais1UIzu6y2oUvGKzsidbtkzdEQRb/R/EtLwc6xRgXY0zBTsmlphVR96G/gZC0SF1Sa0qWqvnolCMMaRM7qQTdc15oeE92LVFLwgvK8jXf9Cu472SW7C1Xi35WERUcOeQ7upas3DrirouhwKWdFjW6CJ0x0fqfBiVSlMuJvOdMuZRQE52A== 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=BQO7N62TbSgGDFzRVqbZ/fjSQmCq2j5uGvweKCC16L4=; b=b4rc77ym+ItroNQYCpqHiIkzILK0m1YSl+Tm9LklwdUDkYNOYwSrRa2qY3CuNJPG2CBfTDym02dN2460h7BVuHdjEF+YKRZsfeQZFobwZb2s5p+rt7I17m8Y/dL3Pmy/WEfmpEg/Nri40MMC2+Ujvu6CEVwzXJtg7qkyIrgkwGXgLOANchHUyOtMq3Q9tB1aFFbaWYMaLhgjEaRPeN96fDoOI21KFmzlAyErnj2mO8kKZSIBAgck5cm/E4C+T1PzFLxvTZyaP1E4+7fRzdhAOHoHiCNeJZrJG8QiXxEpw1ZHnrtr244aiTITvhEk+tPAHrIwAOTbHwMEqWTDv5k+lg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.233) 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=BQO7N62TbSgGDFzRVqbZ/fjSQmCq2j5uGvweKCC16L4=; b=uFfgrjazdjbpENuMPnRxReB0xU5/udrv+emfUK7ZyuUgc9xLSyYWZaA/Q0PIXFw/1jEB2ONIME/19klSRi7Oc8T7UqCCOF7oXpCLA+KHWoPiqFt4uuMLAjNM4M6FxjtVCtDwm9Y1lR5bfk6fmptLWc9n4OCdub5qQyFuJiP3qutea2UgfEJ7AwQMe36WgzRIycLWxHmRW359DCH3YZWISyba/7Y61vMsTZ+ALs7ai2q+vd7bOVVbtrB22REsjSWm1a4wbMb8mZXagPheHw09ez/+O23uVgKFy7GkxoYqh7DSwybe5tRO2jZQOBDpT4YSRbEoSyQKdPv+yZ49cw6hfw== Received: from DM6PR06CA0013.namprd06.prod.outlook.com (2603:10b6:5:120::26) by DM4PR12MB5136.namprd12.prod.outlook.com (2603:10b6:5:393::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Mon, 14 Nov 2022 13:18:28 +0000 Received: from DM6NAM11FT009.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::ca) by DM6PR06CA0013.outlook.office365.com (2603:10b6:5:120::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Mon, 14 Nov 2022 13:18:28 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.233) 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.118.233 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.233; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.233) by DM6NAM11FT009.mail.protection.outlook.com (10.13.173.20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.12 via Frontend Transport; Mon, 14 Nov 2022 13:18:28 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:20 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:20 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 14 Nov 2022 05:18:18 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATH v2 6/8] vdpa/mlx5: Move some definitions to a new header file Date: Mon, 14 Nov 2022 15:17:57 +0200 Message-ID: <20221114131759.57883-7-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114131759.57883-1-elic@nvidia.com> References: <20221114131759.57883-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT009:EE_|DM4PR12MB5136:EE_ X-MS-Office365-Filtering-Correlation-Id: 6a43e812-7506-4929-9d90-08dac642b7e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VkMQlrCLM771n7FDFFqw2HmIa7yC6uCQehPihE904ZHj0sQgpou4iFbdoHDDgs7VIYWIA2CBv89474kn8b7vGyAhUVjvL5NrU/wT8a6f1VP+yEvfnQnpFLBPmQdcK8FN55P93ZPv/ph223zoHYFLYcqv4f5Vcg79ZeCWlo1NAluioz9prQUQzF1EMu8/zHO6YUAB4blOteDOg6MSYi+5ozbujbIetsZIPHCoarOqyaOk8696aJJ53mwho9SYprtDhwXnI29+t30t7mza6+PUpU4bcWK0skzVYUY5zFO4f7MIebi5wE7Zl5keNqIKeg+Ms2LwC8qE8zaeIPnDH4bNWbjZXgM5L/k9qtUIztywCJdLFVTzlkrnp6D9sgXiSSdiKoSsKhwOsx1v5FJrOpJkKkHrGnpYCHkWYP43nz+GL5i35xHPsND8CGLpUObI1QrEllpbNb+AqAx3yEBA4PXKRf8rF3LamnwBu3ktThgDmAGiUspkdQnhSEREh+oij+0/orl47m6DfbX+QGn8sFpowKv8BUisyISTVNzZcSQDt09Vy473ihtiBhaK8rOZPpsEP9EHe8b0a61xxuh+IWygY+EW9mpuoaJDnSDQNcG2H2tVvuGKTbvwHq9/tKsivNdfro0ugpAXKOtoYdlsFrefHPLoljZIyHuzubnjaalXpgijonLVByIS5bHqKqRVuGPsf9oysb+0RxRkmlPH9yaaOVGSp41JMMeGCOWPcqdgjBlhm3kIt2sdSQvQ6pIYotSqqaxkzBSEK4MNDDY3nEaVrA== X-Forefront-Antispam-Report: CIP:216.228.118.233;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge2.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(39860400002)(376002)(451199015)(40470700004)(36840700001)(46966006)(41300700001)(6666004)(7696005)(26005)(70586007)(2906002)(1076003)(54906003)(336012)(186003)(110136005)(316002)(426003)(86362001)(36860700001)(478600001)(47076005)(82740400003)(83380400001)(4326008)(40460700003)(5660300002)(8936002)(8676002)(7636003)(356005)(70206006)(2616005)(82310400005)(40480700001)(36756003)(107886003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 13:18:28.0229 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 6a43e812-7506-4929-9d90-08dac642b7e3 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.233];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT009.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5136 X-Spam-Status: No, score=-1.1 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?1749478636108732365?= X-GMAIL-MSGID: =?utf-8?q?1749478636108732365?= 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 Acked-by: Jason Wang 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 3a6dbbc6440d..da54a188077d 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 Mon Nov 14 13:17: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: 19805 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2146023wru; Mon, 14 Nov 2022 05:34:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5r/54shJ4IWPdAz1ix3DqhTpDtHwvASFVXAbvCJBI3TIsc+1DdcwuIllPrFOfbGg84ZIUH X-Received: by 2002:a63:1348:0:b0:46e:96b9:ed63 with SMTP id 8-20020a631348000000b0046e96b9ed63mr11989874pgt.258.1668432848649; Mon, 14 Nov 2022 05:34:08 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668432848; cv=pass; d=google.com; s=arc-20160816; b=paO4HSUaAQw4yTntw5wUJFeIxjla8fwLBisErHpPrZQkQdGYfZEIiuRbVet1FNgsg2 WQ19pxGoblvSrf4X0GNLVbA4+OYjXClR4uFH/OSlra+FbrN/q3fhlGGpKQuFxgm5B0ZP PH0l8mlZ9aMFCncvbTQxy3D4DOt92bkFty/gxj7OyeRdLyBJrwAmGOIcFQJC8fchzWRt Y+suzCJVuDlcEd5WAis+LbCPismZZEaIHBpr3/lANoue5ePypBK5xQ05NCIgNOVezdmE VmP8rj+5SaL9WQYcpKGEO+L6ApkboIUJcO8CqFkVgeblv1ofuo9iFn2tGlwvpbj4c9I6 CbKQ== 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=2HuEBS6YZ1fJlswcDZL2OomEd9iZZrSxsPT7XHaH4wc=; b=kbm8JJJdJTOHPkLcf8tlDPMNKjxAqrBriqm0etANfAs9+zqUCx85jzSURvpiXSCQX+ QzqpaW7wqMgTsUC1vGqGf3V8U2ddF4aaGRqKwYTL95ltbgw29ccrpzYVy8k5BtDmZzz8 KjLCSmuPOGhkxCKR9apBdbDIdWF9OpOUNH7lJJYuWu7bLllnLne3BczNrUkcjAnb2N+W Y4I80cFtC1BxFVygtb4lLIcfhkaluCefWIdPjXqJ2WSf/uR2t6IOsPG4SUqq+tIPa5wd idNZI966kAxlFuGwX9sszW8Ng7kJyhd6cF+arGK+o31FgACuAYH9S5Ze78lrJAYCfCWp C9gQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=nM8ynCBl; 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 j7-20020a632307000000b0046ff35fa651si9537795pgj.181.2022.11.14.05.33.55; Mon, 14 Nov 2022 05:34:08 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=nM8ynCBl; 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 S236481AbiKNNTS (ORCPT + 99 others); Mon, 14 Nov 2022 08:19:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237317AbiKNNSh (ORCPT ); Mon, 14 Nov 2022 08:18:37 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2040.outbound.protection.outlook.com [40.107.236.40]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D95EFE18 for ; Mon, 14 Nov 2022 05:18:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QzzOuxbuXGQZfSzzsen76RiHndeDfUkc7/GV5RvxU0k4+1tU0ookiZ//oomQWhKvlSA4hVhodcA36VkgMeKWak68JmmxL5YyS3zL3DQ2S6Vn6H2VIP66kvpZag/fVjH/CLsKHtJiFoc2k8cVgKGsUBb3XoTU8+fKbVP4xaMY0mzJqoRuaESCUvGXtSh5CG9Uty9YbHpFjTNZ418hfBdCxd9yTyTXWy/+OYg1cXxmW7I2WZ6yRwxjDknoERZfjgdjf8vfgFfxrvk6CWO4dfp2dGZVH81rHjNu0b/dY3Lrcm/2pDWEpH6T8Z3+hcpYawiSntbVfKspjFLeeKWp7nvzsw== 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=2HuEBS6YZ1fJlswcDZL2OomEd9iZZrSxsPT7XHaH4wc=; b=Z3kQHSRYlVo6ozeKCdRqXTfhO9D/evRJH884++ZLYwcvgn8/hEOxqZHzDwZmW4ZdUywP8bdqDFOTYh3oXOSQv3AVjnDZo5I6fuZFDsbaq+FVO+R2Wj8Z61xaLVw3RJjB/BFz/hG/WbbLXSQEHhmECDPWg+Mg65vK0MksQeAcwJmT2VFa7METciZkJNgh2QTWx/xY9nzu1R7ehHgCelOtC3JSGOu8FTfQ02YUs+RCQlB/wmYc879+INQ2/MNYcZLqe8nWSifpSbl+Jxg4VN7hi+e2to4QgUWjJr/s2oeTVX4UnHdg4pkLNLh0Agb5omLYTRMrfJdkxJzw/6ZFQCAlYg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=2HuEBS6YZ1fJlswcDZL2OomEd9iZZrSxsPT7XHaH4wc=; b=nM8ynCBlex33wGw1s0MSxybzRD4HjY2frnV7CVzmb/chTGwpwWRS1tGvjDw/RacZRq7mP+BXLedRyvwNFd6ea6eJHrinuqjArjzwMFKzz3tAaIQzgZSZC9t1ZUcF+m+72Er0gGr8TEGwdpsRtGVQ1JoMps734IW7I8id8ZEMgjx5PIQwovU21IU897V8QMV7EH1ISoPUDZUklglEEzIbjHJQ2m0dJR54KqgSO89byb2Eurb4iMCGj+BdoDpAWSm+oIXQgCOu0MZGpbsEN++fo8cCEBTVXI42SnqvuQUeDgZs08x0qGoG6/7V+FuHnSC9VXHwYk0JxvIqzWymbzMyag== Received: from DM6PR08CA0022.namprd08.prod.outlook.com (2603:10b6:5:80::35) by SN7PR12MB7276.namprd12.prod.outlook.com (2603:10b6:806:2af::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Mon, 14 Nov 2022 13:18:32 +0000 Received: from DS1PEPF0000E65A.namprd02.prod.outlook.com (2603:10b6:5:80:cafe::1) by DM6PR08CA0022.outlook.office365.com (2603:10b6:5:80::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Mon, 14 Nov 2022 13:18:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E65A.mail.protection.outlook.com (10.167.18.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Mon, 14 Nov 2022 13:18:32 +0000 Received: from drhqmail202.nvidia.com (10.126.190.181) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:23 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail202.nvidia.com (10.126.190.181) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:23 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 14 Nov 2022 05:18:21 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATH v2 7/8] vdpa/mlx5: Add debugfs subtree Date: Mon, 14 Nov 2022 15:17:58 +0200 Message-ID: <20221114131759.57883-8-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114131759.57883-1-elic@nvidia.com> References: <20221114131759.57883-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E65A:EE_|SN7PR12MB7276:EE_ X-MS-Office365-Filtering-Correlation-Id: 7482836f-459f-4300-d6a5-08dac642ba87 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TuspzEZcsgITibLtTV5RcxgrmS84iM+qA6/oqEP/PWBVSb7ZXNX8uIxUWsHcGPkc8oXVSNvqcFyhMkZyvyrZpKfm35l/pmjv2iMLoEIvaUjSgtouG3Wz5P/MBgPSFTdWkKTOKNxhNIPG4T8KtgWie9MXaUkLy8tSU5POkRUVSU3hRW6Anf4D6ZVYegrOrUEq7ktJ+5Q7CqrtpMttf0TYRhBAYqsOoQoy3Se2N8l5hLh29gLlgSvsj3pR6hydH/jd2Iql5i3c7Ibj50AtiS+z5P6+DNxileMQf2qxthDm8iRvFE5WxwGpEVPpcxJqO0Xc1DLt10G9xuJ/fUcMZ7iERd+4s7F1nlYTJcw59IFEP/W8nUPhFCiU1kp1V1XR1D5qHex++slxDH1IexE9JGLdJGw1ze/1WLjlPVi/yyV3cymbKvCnd56QXFhJ+Xe8ponJxla+O2hnxs7cTjNF3aayjoT1zSklp+NbPLR4lXoYjJLbm11od5+WRGlkMfe1JhQOLsf3RoDUlBRUr2OApBhQ7hD5vBPHAzaosO5OImJI3Eh9tVQYZS66axbJmXtXPV2q8cNNse/O0BoGDyQcOu/uUIrfTMK2mQkBp4AVEF0fqQI5e9yvuivw5qd9R2Tms4EsA0/xYv80GJkS+E4Ak1tvFq/iWASjLwyh/U2t5XIm6cOZxlwlS5NQu9Ut7UkxJYAxJQHE8ALOOYRZsKIB6Dq1K+CXzQpGikl84eOjGMG1fRA6Fp8fg3nr3sAfmfCyJladNjoDzHBRPisTow9qbFxvLw== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(478600001)(86362001)(6666004)(107886003)(82740400003)(36860700001)(7636003)(40480700001)(186003)(2616005)(1076003)(26005)(426003)(40460700003)(7696005)(5660300002)(82310400005)(316002)(36756003)(336012)(54906003)(8936002)(41300700001)(110136005)(47076005)(4326008)(70586007)(70206006)(8676002)(356005)(83380400001)(2906002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 13:18:32.4545 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7482836f-459f-4300-d6a5-08dac642ba87 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E65A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB7276 X-Spam-Status: No, score=-1.1 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?1749478642737194938?= X-GMAIL-MSGID: =?utf-8?q?1749478642737194938?= 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 Acked-by: Jason Wang 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 da54a188077d..4b097e6ddba0 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); } @@ -3135,6 +3143,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; @@ -3161,6 +3170,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) { ndev->nb_registered = false; mlx5_notifier_unregister(mvdev->mdev, &ndev->nb); 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 Mon Nov 14 13:17: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: 19806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp2146029wru; Mon, 14 Nov 2022 05:34:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf5MRbQVtVC95oOyi2+Rb8Ir+vKuEI1RJsJC6glYcvNV4XiZunlvHHT7A2qBA3ejToEeAeJh X-Received: by 2002:a17:90b:4a51:b0:213:aa5f:a026 with SMTP id lb17-20020a17090b4a5100b00213aa5fa026mr13327961pjb.243.1668432849480; Mon, 14 Nov 2022 05:34:09 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668432849; cv=pass; d=google.com; s=arc-20160816; b=KVIysRplx4goocjAx/meXHHVMKf+TlLjGk0vcrprqRyN5vRkt+EiIZAJXS8kk5iCHb j4lXhv/OH0dvNsp60kjuMG+nVIzJwWoJikJxsIi3r/ubotKgArTCvosYcTHbZTpQ3YyG HvIflXdI+IaRCyFaA5dm8Hc1gWyCCOMMoSko2x0zPIp/nB1Zn+6PUhAUCtql9r882gmd Y0kqDulwUJpGIHU6Ei2BincN/EPz2wEp/hjsadHfeUxbxWMxs+yPPUQ37I5Jsb+go8KH kW2AOB76UJUlnEv6djNA+5ovQHYC+sPb/5S0nl5NWm5InBdXKx/XUmTHSVd5Ow6fd66q KCcg== 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=bu1nXZ5iBB7rHVUiQ2HDh28QVaXxBJ0Qqc72KdNbG00=; b=EVZLeONCIlJ/CSAPWkXmT1AJOuYZiZvX5mDbAEl1gY64bEvk7RznqNhRYcsDJUwuv2 Jvpvb9rLajeYUo9Olm6yFwQQ57FDmSx00DDKen5cAWlZAgenoWHC0yrvFXicQzrXphi9 /r7ucRy1YKk8/ZTxYde2c67hZsa+kdxbctvDZt036pYerkLe2CP+LlPQcJeu6De5dx7a 9OSKWoz6urlLsze1qRzdOfGhx/cH7yUiAARGP10haDBImHKLv1YHvZPLowUd9LW5ljWp /cQ16KAni8NgV2q1HrcDrLh/bEKGgDkJCv5Lscg0pE06Tn6iWvWt1YSsXp1NpbTESHP4 ZG0g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="D9/VOV/p"; 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 m22-20020a056a00081600b0056cb8f67eefsi9636751pfk.70.2022.11.14.05.33.55; Mon, 14 Nov 2022 05:34:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b="D9/VOV/p"; 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 S237581AbiKNNTU (ORCPT + 99 others); Mon, 14 Nov 2022 08:19:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237521AbiKNNSk (ORCPT ); Mon, 14 Nov 2022 08:18:40 -0500 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2087.outbound.protection.outlook.com [40.107.102.87]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8763DA46D for ; Mon, 14 Nov 2022 05:18:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=U4l6s+FEzm0yXkbHJxThHkUm2hjhWX5jRRrGdd7BzpQgbRtGbIXT4ODFR9KQiK3UKc4DZQ5RfwdFd/PLWx0bsIBttny6wLjG0NS1ZjKHaP5b9Uqn99Y9ibF8XOOcpZgzT/R8Xhpi1p+kzOXiIKLd4Q2Zu754Ai/5ra8IBKzx+9BR4LMPvVz7uDqyTiOyuIcqxvyMM6Q7bVng0O43CIkdZ5Gc44emva9X4GlxvHQzOwU7IZrEGdFvglYa6pr16lwksfGcIkMIslNE6wLzLPVBPOhwZa5iiOBZkIn6w5MJ6N5QUdpPtEjYF5LeezCmjOcIU8LFfuYqs63/bMo9uXLJIA== 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=bu1nXZ5iBB7rHVUiQ2HDh28QVaXxBJ0Qqc72KdNbG00=; b=ddYE7DZDmTjgjcgKlDU/QMlNnewdEhWWj9YtfW0sd7SKYhIj6iVnbrC+oFL48fvbiplaXFg/dif/cD6AINoauYmuQdMLwqvdq07042eetQf/z8SvIJNhSR0tEnss3igLGBJNXMxnIx0bWPlwc2PtRrTa/MmeB2AMy0uTKjT0+bDtM39NYurNcZ8qKKOtoKGNDVuW5uGFTn5PSKi06VqUI5/D3ZeI9R/pOYwNLdN2Lq6AoW/TEfLG4joLLFgAxucIXLYrQQ8a3dScxlvfZOv+9QeMB+oTLuMOBjwR+7YxlgvUu03WZSUzAss7HkWXFvBEtM8HzmMdt0gsk7sJTOwUwg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.118.232) 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=bu1nXZ5iBB7rHVUiQ2HDh28QVaXxBJ0Qqc72KdNbG00=; b=D9/VOV/plp/vTrGvj0KVSN7A1MjbOOmYLiU6X+t+KAd9jwdGAbrKgYHnJvcdAAP2NyNVo0JRkVlkZ2BxY4LpWGi27sXEElxJg7MW3n/OugkCjOw7PNZscDv9nmrrCICjD7+nnhRgE4ElQV1IwfCEYDZCmKEFio2cE0IKindS56NRjc9l8HU2zCuPL/95LGrKPmSfT6Ymmo/lEt7vJ2J5WERqIwYxzRlid4jok9j7EQ4A0kVIqXfCu8wGzB20/8KwUBXa9uA7ua0ZToqVOgN2we2ii5WAIBO0su2xrz6gWBFaNqMFIpoXFffkWWasR/RJq9p70Snvt1YxorxPnI8kIw== Received: from DM6PR08CA0008.namprd08.prod.outlook.com (2603:10b6:5:80::21) by MW4PR12MB6898.namprd12.prod.outlook.com (2603:10b6:303:207::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17; Mon, 14 Nov 2022 13:18:35 +0000 Received: from DS1PEPF0000E65A.namprd02.prod.outlook.com (2603:10b6:5:80:cafe::e3) by DM6PR08CA0008.outlook.office365.com (2603:10b6:5:80::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.17 via Frontend Transport; Mon, 14 Nov 2022 13:18:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.118.232) 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.118.232 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.118.232; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.118.232) by DS1PEPF0000E65A.mail.protection.outlook.com (10.167.18.72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.11 via Frontend Transport; Mon, 14 Nov 2022 13:18:35 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:26 -0800 Received: from drhqmail203.nvidia.com (10.126.190.182) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.36; Mon, 14 Nov 2022 05:18:25 -0800 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.182) with Microsoft SMTP Server id 15.2.986.36 via Frontend Transport; Mon, 14 Nov 2022 05:18:23 -0800 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATH v2 8/8] vdpa/mlx5: Add RX counters to debugfs Date: Mon, 14 Nov 2022 15:17:59 +0200 Message-ID: <20221114131759.57883-9-elic@nvidia.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221114131759.57883-1-elic@nvidia.com> References: <20221114131759.57883-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DS1PEPF0000E65A:EE_|MW4PR12MB6898:EE_ X-MS-Office365-Filtering-Correlation-Id: d7289358-d382-4438-879f-08dac642bc1f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IYIbnMmwMqq6JojVBUgp4dgF4Hv08h+//8zsCj4ukuyUfgE8ZanTrzic1+3nA0+mGTtrKd4/BPMkDJ/JYmEIV+XR8a9aB5c8hjuclGV0yyTI+VxnwMXLn62WIIqfUAjdnFPVlWk0y1+4l2MtfJVQBQ1zSuzTOLMJO9faupJ+7VkGmGrHgBRcZL9hQJOsudd5B/dnSSepwwWgrFnmbIxvdfntjvfiv+oNtrZsuhfkvu3Vky/Cbhy5BD5oU41SKPvH7+rtbuBO6L+2fBZ4LyB2qZ9Ufd8nvRV2DV/P0mzTSmfnR8Tt5bFf8k+kf9iU4yQ9E03eDG8jP1sUe4gw4byB6sViH/xg+gs1PF+vxlKaMCg9SlYrEawrRs8X4u0TzMksFj74OS2GuOMpa6efDZS1RpUC7YN2ztp6YA+R0cnhtRjoPnAr1siR+q+EuB5uAkn2dvsrCnz7TMXHek4ZsHV8jsD+7b6lw5kxd2HYi4FV2B+gEIAjQdCdJPJCLRMNEVOxi/ZdIOC5NE86oF8XwY9yaDMrJMmM5E5Ab5AKLD/T68VmL4L1hSQdwdMko3aEKoRnkGkgqSWeT7R9liRx/FWTwdl6dZCdGT6PPSAhUWtgtXz1uhShor6y6XVNg0TZ3r7549HWWJ1orRY6YfFBFkyWC4leIMymL62Yf0VjasC16TdEoeT7ZyhM94689TJ/CAP5wLB2Dl8mG7K4kiTIRZixHfNRsGNGgx3ybNs4mB298Kn7vFrIPKO6pzYT5GWrrgVcQpiSgUX0a7krlLBcaNwknv4vrZEeuAqVrw0WeeJ4ZeE= X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(136003)(396003)(376002)(39860400002)(346002)(451199015)(40470700004)(36840700001)(46966006)(86362001)(36756003)(336012)(40460700003)(7636003)(41300700001)(316002)(70206006)(70586007)(8676002)(186003)(4326008)(426003)(83380400001)(82310400005)(36860700001)(2616005)(40480700001)(82740400003)(356005)(1076003)(47076005)(8936002)(478600001)(110136005)(54906003)(30864003)(5660300002)(6666004)(2906002)(107886003)(7696005)(26005)(290074003);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Nov 2022 13:18:35.1264 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7289358-d382-4438-879f-08dac642bc1f X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DS1PEPF0000E65A.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB6898 X-Spam-Status: No, score=-1.1 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?1749478643592916425?= X-GMAIL-MSGID: =?utf-8?q?1749478643592916425?= 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 Acked-by: Jason Wang --- drivers/vdpa/Kconfig | 12 ++++ drivers/vdpa/mlx5/net/debug.c | 86 ++++++++++++++++++++++ drivers/vdpa/mlx5/net/mlx5_vnet.c | 116 +++++++++++++++++++++++------- drivers/vdpa/mlx5/net/mlx5_vnet.h | 30 ++++++++ 4 files changed, 217 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 4b097e6ddba0..6632651b1e54 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -1404,12 +1404,55 @@ static void destroy_tir(struct mlx5_vdpa_net *ndev) #define MAX_STEERING_ENT 0x8000 #define MAX_STEERING_GROUPS 2 +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + #define NUM_DESTS 2 +#else + #define NUM_DESTS 1 +#endif + +static int add_steering_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node, + struct mlx5_flow_act *flow_act, + struct mlx5_flow_destination *dests) +{ +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + int err; + + node->ucast_counter.counter = mlx5_fc_create(ndev->mvdev.mdev, false); + if (IS_ERR(node->ucast_counter.counter)) + return PTR_ERR(node->ucast_counter.counter); + + node->mcast_counter.counter = mlx5_fc_create(ndev->mvdev.mdev, false); + if (IS_ERR(node->mcast_counter.counter)) { + err = PTR_ERR(node->mcast_counter.counter); + goto err_mcast_counter; + } + + dests[1].type = MLX5_FLOW_DESTINATION_TYPE_COUNTER; + flow_act->action |= MLX5_FLOW_CONTEXT_ACTION_COUNT; + return 0; + +err_mcast_counter: + mlx5_fc_destroy(ndev->mvdev.mdev, node->ucast_counter.counter); + return err; +#else + return 0; +#endif +} + +static void remove_steering_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node) +{ +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + mlx5_fc_destroy(ndev->mvdev.mdev, node->mcast_counter.counter); + mlx5_fc_destroy(ndev->mvdev.mdev, node->ucast_counter.counter); +#endif +} + static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, - u16 vid, bool tagged, - struct mlx5_flow_handle **ucast, - struct mlx5_flow_handle **mcast) + struct macvlan_node *node) { - struct mlx5_flow_destination dest = {}; + struct mlx5_flow_destination dests[NUM_DESTS] = {}; struct mlx5_flow_act flow_act = {}; struct mlx5_flow_handle *rule; struct mlx5_flow_spec *spec; @@ -1418,11 +1461,13 @@ static int mlx5_vdpa_add_mac_vlan_rules(struct mlx5_vdpa_net *ndev, u8 *mac, u8 *dmac_c; u8 *dmac_v; int err; + u16 vid; spec = kvzalloc(sizeof(*spec), GFP_KERNEL); if (!spec) return -ENOMEM; + vid = key2vid(node->macvlan); spec->match_criteria_enable = MLX5_MATCH_OUTER_HEADERS; headers_c = MLX5_ADDR_OF(fte_match_param, spec->match_criteria, outer_headers); headers_v = MLX5_ADDR_OF(fte_match_param, spec->match_value, outer_headers); @@ -1434,44 +1479,58 @@ 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; + +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + dests[1].counter_id = mlx5_fc_id(node->ucast_counter.counter); +#endif + node->ucast_rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, dests, NUM_DESTS); + if (IS_ERR(rule)) { + err = PTR_ERR(rule); + goto err_ucast; + } - *ucast = rule; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + dests[1].counter_id = mlx5_fc_id(node->mcast_counter.counter); +#endif memset(dmac_c, 0, ETH_ALEN); memset(dmac_v, 0, ETH_ALEN); dmac_c[0] = 1; dmac_v[0] = 1; - rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, &dest, 1); - kvfree(spec); + node->mcast_rule = mlx5_add_flow_rules(ndev->rxft, spec, &flow_act, dests, NUM_DESTS); if (IS_ERR(rule)) { err = PTR_ERR(rule); goto err_mcast; } - - *mcast = rule; + kvfree(spec); + mlx5_vdpa_add_rx_counters(ndev, node); return 0; err_mcast: - mlx5_del_flow_rules(*ucast); + mlx5_del_flow_rules(node->ucast_rule); +err_ucast: + remove_steering_counters(ndev, node); +out_free: + kvfree(spec); return err; } static void mlx5_vdpa_del_mac_vlan_rules(struct mlx5_vdpa_net *ndev, - struct mlx5_flow_handle *ucast, - struct mlx5_flow_handle *mcast) + struct macvlan_node *node) { - mlx5_del_flow_rules(ucast); - mlx5_del_flow_rules(mcast); + mlx5_vdpa_remove_rx_counters(ndev, node); + mlx5_del_flow_rules(node->ucast_rule); + mlx5_del_flow_rules(node->mcast_rule); } static u64 search_val(u8 *mac, u16 vlan, bool tagged) @@ -1505,14 +1564,14 @@ static struct macvlan_node *mac_vlan_lookup(struct mlx5_vdpa_net *ndev, u64 valu return NULL; } -static int mac_vlan_add(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vlan, bool tagged) // vlan -> vid +static int mac_vlan_add(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vid, bool tagged) { struct macvlan_node *ptr; u64 val; u32 idx; int err; - val = search_val(mac, vlan, tagged); + val = search_val(mac, vid, tagged); if (mac_vlan_lookup(ndev, val)) return -EEXIST; @@ -1520,12 +1579,13 @@ static int mac_vlan_add(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vlan, bool tagg if (!ptr) return -ENOMEM; - err = mlx5_vdpa_add_mac_vlan_rules(ndev, ndev->config.mac, vlan, tagged, - &ptr->ucast_rule, &ptr->mcast_rule); + ptr->tagged = tagged; + ptr->macvlan = val; + ptr->ndev = ndev; + err = mlx5_vdpa_add_mac_vlan_rules(ndev, ndev->config.mac, ptr); if (err) goto err_add; - ptr->macvlan = val; idx = hash_64(val, 8); hlist_add_head(&ptr->hlist, &ndev->macvlan_hash[idx]); return 0; @@ -1544,7 +1604,8 @@ static void mac_vlan_del(struct mlx5_vdpa_net *ndev, u8 *mac, u16 vlan, bool tag return; hlist_del(&ptr->hlist); - mlx5_vdpa_del_mac_vlan_rules(ndev, ptr->ucast_rule, ptr->mcast_rule); + mlx5_vdpa_del_mac_vlan_rules(ndev, ptr); + remove_steering_counters(ndev, ptr); kfree(ptr); } @@ -1557,7 +1618,8 @@ static void clear_mac_vlan_table(struct mlx5_vdpa_net *ndev) for (i = 0; i < MLX5V_MACVLAN_SIZE; i++) { hlist_for_each_entry_safe(pos, n, &ndev->macvlan_hash[i], hlist) { hlist_del(&pos->hlist); - mlx5_vdpa_del_mac_vlan_rules(ndev, pos->ucast_rule, pos->mcast_rule); + mlx5_vdpa_del_mac_vlan_rules(ndev, pos); + remove_steering_counters(ndev, pos); kfree(pos); } } diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.h b/drivers/vdpa/mlx5/net/mlx5_vnet.h index f2cef3925e5b..c90a89e1de4d 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.h +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.h @@ -21,6 +21,11 @@ struct mlx5_vdpa_net_resources { #define MLX5V_MACVLAN_SIZE 256 +static inline u16 key2vid(u64 key) +{ + return (u16)(key >> 48) & 0xfff; +} + struct mlx5_vdpa_net { struct mlx5_vdpa_dev mvdev; struct mlx5_vdpa_net_resources res; @@ -47,11 +52,24 @@ struct mlx5_vdpa_net { struct dentry *debugfs; }; +struct mlx5_vdpa_counter { + struct mlx5_fc *counter; + struct dentry *dent; + struct mlx5_core_dev *mdev; +}; + struct macvlan_node { struct hlist_node hlist; struct mlx5_flow_handle *ucast_rule; struct mlx5_flow_handle *mcast_rule; u64 macvlan; + struct mlx5_vdpa_net *ndev; + bool tagged; +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) + struct dentry *dent; + struct mlx5_vdpa_counter ucast_counter; + struct mlx5_vdpa_counter mcast_counter; +#endif }; void mlx5_vdpa_add_debugfs(struct mlx5_vdpa_net *ndev); @@ -60,5 +78,17 @@ void mlx5_vdpa_add_rx_flow_table(struct mlx5_vdpa_net *ndev); void mlx5_vdpa_remove_rx_flow_table(struct mlx5_vdpa_net *ndev); void mlx5_vdpa_add_tirn(struct mlx5_vdpa_net *ndev); void mlx5_vdpa_remove_tirn(struct mlx5_vdpa_net *ndev); +#if defined(CONFIG_MLX5_VDPA_STEERING_DEBUG) +void mlx5_vdpa_add_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node); +void mlx5_vdpa_remove_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node); +#else +static inline void mlx5_vdpa_add_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node) {} +static inline void mlx5_vdpa_remove_rx_counters(struct mlx5_vdpa_net *ndev, + struct macvlan_node *node) {} +#endif + #endif /* __MLX5_VNET_H__ */