From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 20A12A00C2; Fri, 14 Oct 2022 13:49:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 97A4D42D9D; Fri, 14 Oct 2022 13:49:24 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam04on2056.outbound.protection.outlook.com [40.107.101.56]) by mails.dpdk.org (Postfix) with ESMTP id DF38B42D9C for ; Fri, 14 Oct 2022 13:49:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RnguTZeHXWNF59JvqGcf2oPOk625oQueLkV/RlFmIU6Lwzoq01A6HgtuehCFET1+CwSAJN7SWw+DWwQ7t4nFQqoM77ZOSIDU8T8vF+9yZbih1ZxCXJO2hnKa5JlmA6F9WnBwL1/jsIgwewz+c6T89+USm48pnN4kqxz3jIElKZHIX2yil8LWu4NvBRkmysK6e+ywYCHakTx216/TqGHzQgBUvp/zAh6wdqbCr5/iRvybC2KQHzpR4rV8r5HA+PKOD9q5mjihiVzuXIsanwuYfCJWH6jgCIZ7ok4FQ+/hImvztY+UB5khgKsZKMmeg0QAF/XnUgQonIJAw9CL8c+pjg== 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=nPNDhVhw8eWE6mDAYE+c5j5/2e1y6Mt82MlyOlB6jp8=; b=eo7HvhpN1Ece7+RzPTC88bcmwX+nbuIHAOg7UZkpPw7aIsfpHJj9rZkuaRfT8wCf2Z8/iK8y1KJzqXC/tdywH39+unavs2MJjsLVFe+Pkb/Zh1SxG6OYtLOZ96uGxah+WN5xdTHCRdNLOx9Sa3CqOPGiJ8KONfYbtgCVzcH5usYmdA3GedMeMgllsdpuiVWc5IzeKze2/6SXH6IZ2Q4U6xqmP7jAUHevl268cRD4xKqsCznMQaV2nWkJ9j5YB0VKMWMy68ZE16Nq6synQPvsuboxM9mBvjWzuvrVwfkTbFR6vMf0Q+WdJ2tAdgHTcgQrV6YsQ9Cq1IMPAOgEwpGEgw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=monjalon.net 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=nPNDhVhw8eWE6mDAYE+c5j5/2e1y6Mt82MlyOlB6jp8=; b=eI7SSDpZhOU9SfKvHYbAXkkPem9oXp+wSSBulPAHfY3OP7+d4893UEmTR0Sm/FMhndnvZFkL5eo5MILfhEIQvrK5vtLH58H0gGui+svDRXOihwv7TdspUHPmj63tOjMXcaFnlq/J2zBu1t0PkXYAHQLWc+bctCi45w1fBPWsioUmsXXgkluA9qA1pPtVlAtK/tHcsHacX8c6pFmmFra/xEf/yhq1J6YZIf4+qp68z69TqMwurQkPnaksj3s7fgAS5f5/XSZHxupN2nB6Uro8zbvcRsGgO3FXCG/htVSCaw14nZJSmwg0z37paEAObermk9u0GP76/9jXZ1XP9kR5tg== Received: from MW4P221CA0005.NAMP221.PROD.OUTLOOK.COM (2603:10b6:303:8b::10) by LV2PR12MB5751.namprd12.prod.outlook.com (2603:10b6:408:17d::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Fri, 14 Oct 2022 11:49:20 +0000 Received: from CO1NAM11FT111.eop-nam11.prod.protection.outlook.com (2603:10b6:303:8b:cafe::c0) by MW4P221CA0005.outlook.office365.com (2603:10b6:303:8b::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.30 via Frontend Transport; Fri, 14 Oct 2022 11:49:20 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by CO1NAM11FT111.mail.protection.outlook.com (10.13.174.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.20 via Frontend Transport; Fri, 14 Oct 2022 11:49:19 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Fri, 14 Oct 2022 04:49:10 -0700 Received: from nvidia.com (10.126.230.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.29; Fri, 14 Oct 2022 04:49:08 -0700 From: Alex Vesker To: , , , , Matan Azrad CC: , , Dariusz Sosnowski Subject: [v3 04/18] net/mlx5: add port to metadata conversion Date: Fri, 14 Oct 2022 14:48:19 +0300 Message-ID: <20221014114833.13389-5-valex@nvidia.com> X-Mailer: git-send-email 2.18.1 In-Reply-To: <20221014114833.13389-1-valex@nvidia.com> References: <20220922190345.394-1-valex@nvidia.com> <20221014114833.13389-1-valex@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.230.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT111:EE_|LV2PR12MB5751:EE_ X-MS-Office365-Filtering-Correlation-Id: 1782d404-9093-4c1f-9ee0-08daadda2156 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wLFRJvtVKEI0Zh05EL2tt2zhGGnSkgES3JLAghPpCs5XUsiI8EmeQ+b8nebjztrq2SKzwQtjblzCGD+6ADFw4XKbibHmF2Riw5S2rq86QfdXNnk+DXhz0/q/KJf41D6ixY4yPsjtc1y4vjdIv0X2eVaeYNJsRjyqQNzu5ouY/G/W5G3/XnXjW8nM2NvEs7tQ7eDKdeIVTS3TR9SouEnkgqSOi6VO8Tt878QPaC8gC1kyQ6/t9zxIZci5E3dI0+aSbNdQN1ehG+AFw58aDoBTOB7d1JWiTgXHfSSAausy1ImMicU5QYSvKFyyWp8lfRth/9zgNRfqSpLpNhMvoaBFjClLaXzZ5bbmrS3sxfgVh8wvYNSxBMYdDyHyXgWezjtOTpVTvF+b5VjK8WQslfFuqEHylLPLetmx/+rSg/VN1y/2wvTYaqhl3t4vWFt9aUyJlRDGOtsT+O9ctRL/1wQI70l0M+/pbAAn6NTNLpKm6uL+oDt4Y6xXL5f46IXz+cDYLD41fdsN1/3K560m0Qrv3B3Ge6wk6vWZH0iIg5F4y8GShQXPn3GVB48XBsEfRNvnfoqkoAPPQ2cfvfBwtcudx8LQaxz0KXeeofwb0xyP+Juq6nbMsSJEfq6P1ycnrYPlwibnAgBaCIYd6dKVgxk4eKVSAPlhc0v02PjnEnT3OISfMfXEGvMIsgeCSdpGfSRzZWR0w03ZW1QH/TscYv8spbjjam37hShx4oayyRr0wXEjueuezCav3PWukjRUKZGmHbjegbGefUCgH+iM+d6lSddEkSshydqzum4y8JG1CQQFLVKBV38XHrqwHZzVgz0u X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(136003)(39860400002)(396003)(346002)(376002)(451199015)(36840700001)(46966006)(40470700004)(83380400001)(186003)(426003)(107886003)(16526019)(2906002)(336012)(47076005)(41300700001)(2616005)(1076003)(5660300002)(8936002)(7636003)(356005)(86362001)(82310400005)(82740400003)(36756003)(70206006)(6286002)(36860700001)(55016003)(40480700001)(40460700003)(7696005)(478600001)(6666004)(6636002)(110136005)(26005)(70586007)(316002)(8676002)(54906003)(4326008)(21314003)(309714004); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Oct 2022 11:49:19.9209 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1782d404-9093-4c1f-9ee0-08daadda2156 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT111.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV2PR12MB5751 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org From: Dariusz Sosnowski This patch initial version of functions used to: - convert between ethdev port_id and internal tag/mask value, - convert between IB context and internal tag/mask value. Signed-off-by: Dariusz Sosnowski --- drivers/net/mlx5/linux/mlx5_os.c | 10 +++++- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5_flow.c | 6 ++++ drivers/net/mlx5/mlx5_flow.h | 52 ++++++++++++++++++++++++++++++++ drivers/net/mlx5/mlx5_flow_hw.c | 29 ++++++++++++++++++ 5 files changed, 97 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 60677eb8d7..98c6374547 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -1541,8 +1541,16 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, if (!priv->hrxqs) goto error; rte_rwlock_init(&priv->ind_tbls_lock); - if (priv->sh->config.dv_flow_en == 2) + if (priv->sh->config.dv_flow_en == 2) { +#ifdef HAVE_IBV_FLOW_DV_SUPPORT + if (priv->vport_meta_mask) + flow_hw_set_port_info(eth_dev); return eth_dev; +#else + DRV_LOG(ERR, "DV support is missing for HWS."); + goto error; +#endif + } /* Port representor shares the same max priority with pf port. */ if (!priv->sh->flow_priority_check_flag) { /* Supported Verbs flow priority number detection. */ diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 752b60d769..1d10932619 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1944,6 +1944,7 @@ mlx5_dev_close(struct rte_eth_dev *dev) mlx5_flex_item_port_cleanup(dev); #if defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_INFINIBAND_VERBS_H) flow_hw_resource_release(dev); + flow_hw_clear_port_info(dev); #endif if (priv->rxq_privs != NULL) { /* XXX race condition if mlx5_rx_burst() is still running. */ diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 81bed6f6a3..bdb0613d4a 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -33,6 +33,12 @@ #include "mlx5_common_os.h" #include "rte_pmd_mlx5.h" +/* + * Shared array for quick translation between port_id and vport mask/values + * used for HWS rules. + */ +struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS]; + struct tunnel_default_miss_ctx { uint16_t *queue; __extension__ diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 288e09d5ba..17102623c1 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1323,6 +1323,58 @@ struct mlx5_flow_split_info { uint64_t prefix_layers; /**< Prefix subflow layers. */ }; +struct flow_hw_port_info { + uint32_t regc_mask; + uint32_t regc_value; + uint32_t is_wire:1; +}; + +extern struct flow_hw_port_info mlx5_flow_hw_port_infos[RTE_MAX_ETHPORTS]; + +/* + * Get metadata match tag and mask for given rte_eth_dev port. + * Used in HWS rule creation. + */ +static __rte_always_inline const struct flow_hw_port_info * +flow_hw_conv_port_id(const uint16_t port_id) +{ + struct flow_hw_port_info *port_info; + + if (port_id >= RTE_MAX_ETHPORTS) + return NULL; + port_info = &mlx5_flow_hw_port_infos[port_id]; + return !!port_info->regc_mask ? port_info : NULL; +} + +#ifdef HAVE_IBV_FLOW_DV_SUPPORT +/* + * Get metadata match tag and mask for the uplink port represented + * by given IB context. Used in HWS context creation. + */ +static __rte_always_inline const struct flow_hw_port_info * +flow_hw_get_wire_port(struct ibv_context *ibctx) +{ + struct ibv_device *ibdev = ibctx->device; + uint16_t port_id; + + MLX5_ETH_FOREACH_DEV(port_id, NULL) { + const struct mlx5_priv *priv = + rte_eth_devices[port_id].data->dev_private; + + if (priv && priv->master) { + struct ibv_context *port_ibctx = priv->sh->cdev->ctx; + + if (port_ibctx->device == ibdev) + return flow_hw_conv_port_id(port_id); + } + } + return NULL; +} +#endif + +void flow_hw_set_port_info(struct rte_eth_dev *dev); +void flow_hw_clear_port_info(struct rte_eth_dev *dev); + typedef int (*mlx5_flow_validate_t)(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, const struct rte_flow_item items[], diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 12498794a5..fe809a83b9 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -2208,6 +2208,35 @@ flow_hw_resource_release(struct rte_eth_dev *dev) priv->nb_queue = 0; } +/* Sets vport tag and mask, for given port, used in HWS rules. */ +void +flow_hw_set_port_info(struct rte_eth_dev *dev) +{ + struct mlx5_priv *priv = dev->data->dev_private; + uint16_t port_id = dev->data->port_id; + struct flow_hw_port_info *info; + + MLX5_ASSERT(port_id < RTE_MAX_ETHPORTS); + info = &mlx5_flow_hw_port_infos[port_id]; + info->regc_mask = priv->vport_meta_mask; + info->regc_value = priv->vport_meta_tag; + info->is_wire = priv->master; +} + +/* Clears vport tag and mask used for HWS rules. */ +void +flow_hw_clear_port_info(struct rte_eth_dev *dev) +{ + uint16_t port_id = dev->data->port_id; + struct flow_hw_port_info *info; + + MLX5_ASSERT(port_id < RTE_MAX_ETHPORTS); + info = &mlx5_flow_hw_port_infos[port_id]; + info->regc_mask = 0; + info->regc_value = 0; + info->is_wire = 0; +} + /** * Create shared action. * -- 2.18.1