From patchwork Wed Oct 19 12:46:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eli Cohen X-Patchwork-Id: 5421 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp316380wrs; Wed, 19 Oct 2022 06:07:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5YhzhheQOJcrwJJR6qU4jHdy7rzJi3QZ3O/tOfitSPRXexBakxzwHHYCGDLNBp0ozhVjpX X-Received: by 2002:a63:88c8:0:b0:458:9ddd:e8ea with SMTP id l191-20020a6388c8000000b004589ddde8eamr7100252pgd.622.1666184862611; Wed, 19 Oct 2022 06:07:42 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1666184862; cv=pass; d=google.com; s=arc-20160816; b=t1Xpt2cgClpboFjPU8pdQFIh+LCXy+rBs3PSoVIxBgKFnR9ZRX6yTNkEFmiMgVYI9c rXTEM6cgsHAmuedmu5+uWVhuKy6H2DZkksCXq1qPPzsn9Q7ir6bRz8rKzIBXt2+z+8W6 HYmcXR5U3B9raz/gjUTKWomWEnm1435yXmdkjYiB2+KD0bAYVCPBLfFz4dziMVfrp3kj P7QT253KP6/VSMh1QMroIXOfENCRF3u9ZT/lGRKsb+CLsJKspLuIsJLiuMszBPQ92RZW gYvi8Rf05pjWVpQwA7J/4KN2HIQsBoA9ZVQLoWo6+LeIhuqbzo5l28qU1y0PCL8tJe4Q O4Tg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Tc2r0vtExSWff6ZJmHTOd6aPs0fsRIaw2iLicXxi1lU=; b=alWfgeqIKzqXWY79LaARa5VI6/Vtj0u2mkldZolQCvW2NIt2InrjdKtT3uoTXS2h0M V5vksJOT8b1LnXot6zg61EDfvAgifo1+D9LvQGNrmp7/rOjSW6PWpVg0VorUokrXZn8I CO8Dd5KcaQRPEWL+YwrdVaQd8MztCfxmr/kOjykXROQ+U4VQFeN5Sm0NOBbKgrVVPp3t MiQFivkJaF/Jup1Z/3XaHx4BNpnG3r8GSqalkkhiGTOjBv76Fn3Y5fQC9Q8I2VuMxBp4 9eixtAMNyuPBSI8zyO1K5o7XYZSY5Y79sJZyDsgCRqlQCJN6z7XRYeNGKQalhzFDjxF2 /7Og== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=B8Giz92y; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a19-20020a17090ad81300b0020a78bdb716si16815528pjv.24.2022.10.19.06.07.18; Wed, 19 Oct 2022 06:07:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@Nvidia.com header.s=selector2 header.b=B8Giz92y; arc=pass (i=1); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230435AbiJSNDt (ORCPT + 99 others); Wed, 19 Oct 2022 09:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230175AbiJSNDc (ORCPT ); Wed, 19 Oct 2022 09:03:32 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060.outbound.protection.outlook.com [40.107.243.60]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1B221FCF6 for ; Wed, 19 Oct 2022 05:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ozhm12w909x+RhGPAKc5k4vbzdNQPAvhCxVfIsb47JwqVc8n3WGBqoEFkw6jICeWqiDkAbz1WeTJPdTZzUtYFb5FCiMIWLXZcRRWtb/AQlOWPwaF5fTwSQ0XOPl7Q71jHCRS4Oca7TWFBqTDJ6vC8unq1+L1NAgwKpkgZCdimFdGEbK2QKz2ZiLjeJuiTcq5cNqGGlOYr163V3ZB8KnL2GKQ6LQtHX+6eCF0kRpgpoSwjnP5h4Ra7de2ShaWVDcRiTi1yEix/PR1Yb/p0Zic8bTsxzhkBl6SLu71dzL1RQKhLtfG7KaKvC92g0NY3fWndj0ckxxXGPuzm7vATtMdkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Tc2r0vtExSWff6ZJmHTOd6aPs0fsRIaw2iLicXxi1lU=; b=fXvim6g/6XT5uFFJoH9BhE75gu0mqwz0sjdfCZJ6tBXi7+7cev+GuI2CgKluwixyBFRhPm4NWkrCrHJIyI6xVZCG0/GFLYSCLFDgCylCuEpVsY9NzjLyU+oCSST873X5viYAtNQ5IdLYdEUnn+fU/WLmpz/I+yy4e8PjeyQeMOoAFrItuI3E/rlEGftbSWNs9fnK7GKnw1gQ+R5+VjchrG997+LjcoP03ujx8JO5ZmFZlvHrHilXGB0w8BiSd2rmxlbQCuY7K8wfK9lBgQgFjJM0jQDPZOGiiJaYr3MYQhQZOqM9jfmr6Xfw6jWvST5k0thW+UL//H1TTVkHgBQdXA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none (sender ip is 216.228.118.232) smtp.rcpttodomain=redhat.com smtp.mailfrom=nvidia.com; dmarc=fail (p=reject sp=reject pct=100) action=oreject header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Tc2r0vtExSWff6ZJmHTOd6aPs0fsRIaw2iLicXxi1lU=; b=B8Giz92yDa1uUS0xBH0vbGIgiAbg/2m1xDmlZlGGpio4ntHU8UpD4QYwFB4Y0UPH/c/TjmqNBWWjQrWJ93jO7qhyN7V8afACBhK20lkJP8o/YmG45ESLzw/DAghjksJ/c3Vaw2LSFtt4YsaSEWx/EYFQLg868Ma6RhOiaMQmU1mixGSfkpgYhl7QHjMpAhtZ3BOonWxKr6XIis2m6EiWF1hcBp4qQSFjl8sU4UKHuI7gzD8WqC4Ytn6VklrVCJXiq/KuV8gnMJZqB7PQDj15EPjy33gB+YoGRCjWHtlv/WtqqlXk1o8Hg4r4iu4HrHJVF9ss1oYwmyAIbpZrF/uVAw== Received: from BN9PR03CA0462.namprd03.prod.outlook.com (2603:10b6:408:139::17) by SA0PR12MB4511.namprd12.prod.outlook.com (2603:10b6:806:95::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.32; Wed, 19 Oct 2022 12:46:34 +0000 Received: from BN8NAM11FT095.eop-nam11.prod.protection.outlook.com (2603:10b6:408:139:cafe::2f) by BN9PR03CA0462.outlook.office365.com (2603:10b6:408:139::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.34 via Frontend Transport; Wed, 19 Oct 2022 12:46:33 +0000 X-MS-Exchange-Authentication-Results: spf=none (sender IP is 216.228.118.232) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=fail action=oreject header.from=nvidia.com; Received-SPF: None (protection.outlook.com: nvidia.com does not designate permitted sender hosts) Received: from mail.nvidia.com (216.228.118.232) by BN8NAM11FT095.mail.protection.outlook.com (10.13.176.206) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.16 via Frontend Transport; Wed, 19 Oct 2022 12:46:33 +0000 Received: from drhqmail203.nvidia.com (10.126.190.182) by mail.nvidia.com (10.127.129.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Wed, 19 Oct 2022 05:46:20 -0700 Received: from drhqmail201.nvidia.com (10.126.190.180) by drhqmail203.nvidia.com (10.126.190.182) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Wed, 19 Oct 2022 05:46:20 -0700 Received: from vdi.nvidia.com (10.127.8.13) by mail.nvidia.com (10.126.190.180) with Microsoft SMTP Server id 15.2.986.29 via Frontend Transport; Wed, 19 Oct 2022 05:46:18 -0700 From: Eli Cohen To: , , , CC: , , , "Eli Cohen" Subject: [PATCH v2 2/4] vdpa/mlx5: Move some definitions to a new header file Date: Wed, 19 Oct 2022 15:46:08 +0300 Message-ID: <20221019124610.208113-3-elic@nvidia.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221019124610.208113-1-elic@nvidia.com> References: <20221019124610.208113-1-elic@nvidia.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT095:EE_|SA0PR12MB4511:EE_ X-MS-Office365-Filtering-Correlation-Id: a17ac934-fdc0-4713-c640-08dab1cff430 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: k8syEBKF9l8HIEXkAm5dUOKddwhFLR8nurkFepEh4dCeWNbz7FEVa860Uq1dywKbFTbakimAYE7QiRyBCFpgKKDV7TKC0q9Dnm8bM0ViLB3WygX01lb+yTAyTJ7OOSegq8lPmqkn6ClQkuCh5OJrry1GKV8/Ob7pZmf5jpFpC4zAjn3AqusXoWZFykh259vS5KwOK2y9q+zwTSH9lImIWQN7p7jn6+JQMwa2I062tV9LfIq1jMuQZR9KSwexnnApiP78u8LYNTAbqCTSloZ6SZ3Na6CJv7YFZ9ViWnliezKow1ZRoXxrCiGOfmI0WbE414El/+ffq/c9Rh57WbKydSdh8AUAWskPTV8ZF6cPQj2x7oLv58U2MbkxWYC9u634T5N5+JyjQ7vHOWrb2Er4VJ3qC3d02xb9FLDVZA6HVXcnEahu+xpCpgLhAn3s0OburTwqq2dzmNIshMq9+SmP3BDkhiQYykQLuC/afkv01a+5w8JS+E2AbpctyXhyXRNXubCNS8Au6dDKwSSA9VyYa0D39lnthyCri7ipGg9zkdj7kldZd+TlOgzIqFaBnHaqzNdL9eQ5p+a0LO+KKhtnyrdDdC4WfgM+HJiDkxELWLGszV4uoyDPgv0JobYPkeAGIcIRyuHHPaJlZDbKgDbfVKPJflZxph+QqDxZXQSrJ9vBL2KJQRU2i630gZyzcaVGn2J3cCTfw3I+aXZq0wRWIP+NOcI0G3ubgWjS4w78+PP3UHvx4s5Ix15Y0Hf5+vUd8jPb2uKPsPlGQWa3XBQMjw== X-Forefront-Antispam-Report: CIP:216.228.118.232;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc7edge1.nvidia.com;CAT:NONE;SFS:(13230022)(4636009)(396003)(136003)(346002)(39860400002)(376002)(451199015)(40470700004)(36840700001)(46966006)(47076005)(426003)(83380400001)(82740400003)(82310400005)(36756003)(7636003)(356005)(40460700003)(40480700001)(86362001)(36860700001)(6666004)(107886003)(70206006)(70586007)(316002)(54906003)(110136005)(5660300002)(186003)(1076003)(2906002)(336012)(2616005)(7696005)(4326008)(8936002)(26005)(41300700001)(478600001)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Oct 2022 12:46:33.7655 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a17ac934-fdc0-4713-c640-08dab1cff430 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.118.232];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT095.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4511 X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747121458338352328?= X-GMAIL-MSGID: =?utf-8?q?1747121458338352328?= Move some definitions from mlx5_vnet.c to newly added header file mlx5_vnet.h. We need these definitions for the following patches that add debugfs tree to expose information vital for debug. Issue: 3214718 Change-Id: I23c02b11322b503065b5e40c9463d512ce6697b9 Signed-off-by: Eli Cohen --- drivers/vdpa/mlx5/net/mlx5_vnet.c | 45 +------------------------ drivers/vdpa/mlx5/net/mlx5_vnet.h | 55 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 44 deletions(-) create mode 100644 drivers/vdpa/mlx5/net/mlx5_vnet.h diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.c b/drivers/vdpa/mlx5/net/mlx5_vnet.c index 1bcd8dfa9b7e..acd95f2d0ba3 100644 --- a/drivers/vdpa/mlx5/net/mlx5_vnet.c +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.c @@ -18,15 +18,12 @@ #include #include #include "mlx5_vdpa.h" +#include "mlx5_vnet.h" MODULE_AUTHOR("Eli Cohen "); MODULE_DESCRIPTION("Mellanox VDPA driver"); MODULE_LICENSE("Dual BSD/GPL"); -#define to_mlx5_vdpa_ndev(__mvdev) \ - container_of(__mvdev, struct mlx5_vdpa_net, mvdev) -#define to_mvdev(__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev) - #define VALID_FEATURES_MASK \ (BIT_ULL(VIRTIO_NET_F_CSUM) | BIT_ULL(VIRTIO_NET_F_GUEST_CSUM) | \ BIT_ULL(VIRTIO_NET_F_CTRL_GUEST_OFFLOADS) | BIT_ULL(VIRTIO_NET_F_MTU) | BIT_ULL(VIRTIO_NET_F_MAC) | \ @@ -50,14 +47,6 @@ MODULE_LICENSE("Dual BSD/GPL"); #define MLX5V_UNTAGGED 0x1000 -struct mlx5_vdpa_net_resources { - u32 tisn; - u32 tdn; - u32 tirn; - u32 rqtn; - bool valid; -}; - struct mlx5_vdpa_cq_buf { struct mlx5_frag_buf_ctrl fbc; struct mlx5_frag_buf frag_buf; @@ -146,38 +135,6 @@ static bool is_index_valid(struct mlx5_vdpa_dev *mvdev, u16 idx) return idx <= mvdev->max_idx; } -#define MLX5V_MACVLAN_SIZE 256 - -struct mlx5_vdpa_net { - struct mlx5_vdpa_dev mvdev; - struct mlx5_vdpa_net_resources res; - struct virtio_net_config config; - struct mlx5_vdpa_virtqueue *vqs; - struct vdpa_callback *event_cbs; - - /* Serialize vq resources creation and destruction. This is required - * since memory map might change and we need to destroy and create - * resources while driver in operational. - */ - struct rw_semaphore reslock; - struct mlx5_flow_table *rxft; - bool setup; - u32 cur_num_vqs; - u32 rqt_size; - bool nb_registered; - struct notifier_block nb; - struct vdpa_callback config_cb; - struct mlx5_vdpa_wq_ent cvq_ent; - struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE]; -}; - -struct macvlan_node { - struct hlist_node hlist; - struct mlx5_flow_handle *ucast_rule; - struct mlx5_flow_handle *mcast_rule; - u64 macvlan; -}; - static void free_resources(struct mlx5_vdpa_net *ndev); static void init_mvqs(struct mlx5_vdpa_net *ndev); static int setup_driver(struct mlx5_vdpa_dev *mvdev); diff --git a/drivers/vdpa/mlx5/net/mlx5_vnet.h b/drivers/vdpa/mlx5/net/mlx5_vnet.h new file mode 100644 index 000000000000..6691c879a6ca --- /dev/null +++ b/drivers/vdpa/mlx5/net/mlx5_vnet.h @@ -0,0 +1,55 @@ +/* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */ +/* Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved. */ + +#ifndef __MLX5_VNET_H__ +#define __MLX5_VNET_H__ + +#include "mlx5_vdpa.h" + +#define to_mlx5_vdpa_ndev(__mvdev) \ + container_of(__mvdev, struct mlx5_vdpa_net, mvdev) +#define to_mvdev(__vdev) container_of((__vdev), struct mlx5_vdpa_dev, vdev) + +struct mlx5_vdpa_net_resources { + u32 tisn; + u32 tdn; + u32 tirn; + u32 rqtn; + bool valid; +}; + +#define MLX5V_MACVLAN_SIZE 256 + +struct mlx5_vdpa_net { + struct mlx5_vdpa_dev mvdev; + struct mlx5_vdpa_net_resources res; + struct virtio_net_config config; + struct mlx5_vdpa_virtqueue *vqs; + struct vdpa_callback *event_cbs; + + /* Serialize vq resources creation and destruction. This is required + * since memory map might change and we need to destroy and create + * resources while driver in operational. + */ + struct rw_semaphore reslock; + struct mlx5_flow_table *rxft; + struct dentry *rx_dent; + struct dentry *rx_table_dent; + bool setup; + u32 cur_num_vqs; + u32 rqt_size; + bool nb_registered; + struct notifier_block nb; + struct vdpa_callback config_cb; + struct mlx5_vdpa_wq_ent cvq_ent; + struct hlist_head macvlan_hash[MLX5V_MACVLAN_SIZE]; +}; + +struct macvlan_node { + struct hlist_node hlist; + struct mlx5_flow_handle *ucast_rule; + struct mlx5_flow_handle *mcast_rule; + u64 macvlan; +}; + +#endif /* __MLX5_VNET_H__ */