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 A983AA00C4; Mon, 14 Feb 2022 10:36:51 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 59C124120A; Mon, 14 Feb 2022 10:35:53 +0100 (CET) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2086.outbound.protection.outlook.com [40.107.212.86]) by mails.dpdk.org (Postfix) with ESMTP id 444A44118F for ; Mon, 14 Feb 2022 10:35:52 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EOJ2v+W8OSeyo9gGbgNMx93OEDm4zhbC67Wf6ibEeIGQdb+GWVeOshtFNIN0zwx//AQpBDcU9QxdyTYIH27vb9YSZQakv7KyJCUbFPl0IKZYi7ZgO76qbn9WmuLSB5g1teflFy0fU27X+vVqcTUQfFmAFop8I/W5eugEarg4OdKAdT327Q6aMVLKIswArTW9IJ7shyYs9t37Cc/1CLCKh9LIWqyH1oKsO+nHvm5sIpTF3XcMtZFKLtDwzWnSxdBad42Imux+d5G5yeh7n7SkVtn24xu+qj19yPwoIPsEQi7dQrg/pEoKjDecRi3D9GulOCCQ4948P4/inap0z7d3uA== 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=fZWmjEvNLUdxUF3MBhsA8YJE6z7fOd4e37+oHWSTvDQ=; b=OQBU3rDVdSrVDdrD+i7CqxNIxpkY3tLbVyDzLYs0VnSf5omimIKyfQdrl1TpKzsxgGp/nfJ4r/bHHE4jPcjWrW0xbUgJ//3RORjw2b2nw5z+OkCy7f2/xZvqcbcGjuMT3LPQMe1GBgRUH/T9YwCCtcCczTyWteFiaZP/tycnLqqXm5EiTJYx6UQcn5eTzhmAQWXTyLW7BMvPM5tyubmuiKkeJ8Y5RFez7TCne6Ja5mQ48b47tF7VI3N9Md6u0qcs8RX6hI1m8d4mMf20tx1S6W9c1l/1zsVgXy1b5sF7vVCl1wli3aKTqRk9Lb5mnPWyFEUWmbr/xJJBBx5RFDCBuQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) smtp.rcpttodomain=dpdk.org 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=fZWmjEvNLUdxUF3MBhsA8YJE6z7fOd4e37+oHWSTvDQ=; b=gp5eVAJMFwr3nTPjTYhkQuxYxXZqhBsiV0qifGiQRCr61kte8LFleM2gdKLKLcbA5baOG2dDC0NmXa2brydyulBowN3hG8FWYP+nyWWXxdbVRfdyorArs0vtCzP1BBjKljI7kGxNQcEGbiLP4Y/9s7j2qgKDoSHFD0W/DusYmzZ3vzfUvIqAhp0/t4pvnL5UasBmG8c6lUOs93wQk+pcLG6g6lHQWwub8zsOCagZSWxMU+GSJOGIoLakvPGsGzFEH+whZtjy56WBFewXnGLf9RFFKSD00j/CEtHxKnZ/lnN2iSN71EJmoR9zbViauZYj6d/U+Xw/Eb2pRihngsRy1g== Received: from MW4PR04CA0363.namprd04.prod.outlook.com (2603:10b6:303:81::8) by DM4PR12MB5913.namprd12.prod.outlook.com (2603:10b6:8:66::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.11; Mon, 14 Feb 2022 09:35:50 +0000 Received: from CO1NAM11FT032.eop-nam11.prod.protection.outlook.com (2603:10b6:303:81:cafe::70) by MW4PR04CA0363.outlook.office365.com (2603:10b6:303:81::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4975.18 via Frontend Transport; Mon, 14 Feb 2022 09:35:50 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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 12.22.5.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.234) by CO1NAM11FT032.mail.protection.outlook.com (10.13.174.218) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4975.11 via Frontend Transport; Mon, 14 Feb 2022 09:35:50 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 14 Feb 2022 09:35:49 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.9; Mon, 14 Feb 2022 01:35:49 -0800 Received: from nvidia.com (10.127.8.13) by mail.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.9 via Frontend Transport; Mon, 14 Feb 2022 01:35:47 -0800 From: Michael Baum To: CC: Matan Azrad , Raslan Darawsheh , Viacheslav Ovsiienko Subject: [PATCH v2 13/20] net/mlx5: add E-switch mode flag Date: Mon, 14 Feb 2022 11:35:04 +0200 Message-ID: <20220214093511.1592698-14-michaelba@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220214093511.1592698-1-michaelba@nvidia.com> References: <20220127153950.812953-1-michaelba@nvidia.com> <20220214093511.1592698-1-michaelba@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2109bf3f-ce89-4706-c179-08d9ef9d633b X-MS-TrafficTypeDiagnostic: DM4PR12MB5913:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:6108; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MRuf5eFk4FvLFsAMRfhOIURw57hRbL/q7iK+c12gtmt9pF79ydYPfVGXEFTV4gju47WX+azOhrNPvWbVauXNNEe3kG02u5BFJBuByJSn13IjJkoXLPyvWXBP/ORP9Nl0Cm2zbg5WpLVtD2/ZhgCiWSIS97PHOICbHPqYGjZbeS89AerpzCPhotthPU/OVLz/LjMxbxNEc3y6aEFeCTFvGSPCsjxM+IY5FBu0nawfRkElkfl/wagRv1zxFYbP8Oz5p68HUnx6/GtEt0lFb95SBg9gzMyXyKBjS0nV7Blwf8lyyFzp0sqWw6mTsdhy5WzU4K9zbLvWAQrImEVJ3PPKa6RdM5FIWl726UIvQaeVzEy0Tg2pQxF8dfwQaJ5V3YNfTwcrIM5jwJ4c8uzDtrr8befN5/nz9SossXa2VpM4fcVZqDqeq2HlwiDGWWQxhxTpJjcfKzDPmrt0YfYqcZG0cVxu2KBPGKv/hVTqu1efPY6boqh+ZkvK6e/wY/AwKsJmDBmr37SgjhDXrhZC8hgS/+BGGg8FJzmV9C96KjA5iYkWUhEzO4HfZmc2Sj3scS2qGT9Lupxr9XLxvMLqd911yo3/63h9p1QCzjjOU0WhYhFl6E1lwi5b7FRyG7LD8FXO2ZTog6ruU2DHhWuJwIc9q3NDfJz4eTtpiaW806l9a/PLijLyFYjglqB5983nhqEpTR0oK57+2SGAZJ+o6TqGEA== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(508600001)(2906002)(7696005)(6666004)(5660300002)(47076005)(70586007)(81166007)(316002)(6286002)(40460700003)(54906003)(426003)(86362001)(55016003)(36860700001)(107886003)(36756003)(8676002)(8936002)(83380400001)(4326008)(6916009)(1076003)(186003)(356005)(336012)(70206006)(2616005)(26005)(82310400004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Feb 2022 09:35:50.2462 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2109bf3f-ce89-4706-c179-08d9ef9d633b X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT032.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5913 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 This patch adds in SH structure a flag which indicates whether is E-Switch mode. When configure "dv_esw_en" from devargs, it is enabled only when is E-switch mode. So, since dv_esw_en has been configure, it is enough to check if "dv_esw_en" is valid. This patch also removes E-Switch mode check when "dv_esw_en" is checked too. Signed-off-by: Michael Baum Acked-by: Matan Azrad --- drivers/net/mlx5/linux/mlx5_os.c | 14 +++++--------- drivers/net/mlx5/mlx5.c | 1 + drivers/net/mlx5/mlx5.h | 1 + drivers/net/mlx5/mlx5_ethdev.c | 4 ++-- drivers/net/mlx5/mlx5_flow_dv.c | 12 +++--------- drivers/net/mlx5/mlx5_trigger.c | 5 ++--- 6 files changed, 14 insertions(+), 23 deletions(-) diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c index 1ff2b8dc22..69ba2aaf88 100644 --- a/drivers/net/mlx5/linux/mlx5_os.c +++ b/drivers/net/mlx5/linux/mlx5_os.c @@ -951,10 +951,6 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, if (!sh) return NULL; /* Update final values for devargs before check sibling config. */ - if (config->dv_miss_info) { - if (switch_info->master || switch_info->representor) - config->dv_xmeta_en = MLX5_XMETA_MODE_META16; - } #if !defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_MLX5DV_DR) if (config->dv_flow_en) { DRV_LOG(WARNING, "DV flow is not supported."); @@ -962,12 +958,13 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } #endif #ifdef HAVE_MLX5DV_DR_ESWITCH - if (!(hca_attr->eswitch_manager && config->dv_flow_en && - (switch_info->representor || switch_info->master))) + if (!(hca_attr->eswitch_manager && config->dv_flow_en && sh->esw_mode)) config->dv_esw_en = 0; #else config->dv_esw_en = 0; #endif + if (config->dv_miss_info && config->dv_esw_en) + config->dv_xmeta_en = MLX5_XMETA_MODE_META16; if (!config->dv_esw_en && config->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) { DRV_LOG(WARNING, @@ -1133,7 +1130,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, * register to match on vport index. The engaged part of metadata * register is defined by mask. */ - if (switch_info->representor || switch_info->master) { + if (sh->esw_mode) { err = mlx5_glue->devx_port_query(sh->cdev->ctx, spawn->phys_port, &vport_info); @@ -1164,8 +1161,7 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev, } if (vport_info.query_flags & MLX5_PORT_QUERY_VPORT) { priv->vport_id = vport_info.vport_id; - } else if (spawn->pf_bond >= 0 && - (switch_info->representor || switch_info->master)) { + } else if (spawn->pf_bond >= 0 && sh->esw_mode) { DRV_LOG(ERR, "Cannot deduce vport index for port %d on bonding device %s", spawn->phys_port, spawn->phys_dev_name); diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c index 531916f3a5..b26632d249 100644 --- a/drivers/net/mlx5/mlx5.c +++ b/drivers/net/mlx5/mlx5.c @@ -1259,6 +1259,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn, pthread_mutex_init(&sh->txpp.mutex, NULL); sh->numa_node = spawn->cdev->dev->numa_node; sh->cdev = spawn->cdev; + sh->esw_mode = !!(spawn->info.master || spawn->info.representor); if (spawn->bond_info) sh->bond = *spawn->bond_info; err = mlx5_os_get_dev_attr(sh->cdev, &sh->device_attr); diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h index d69b6a357b..a713e61572 100644 --- a/drivers/net/mlx5/mlx5.h +++ b/drivers/net/mlx5/mlx5.h @@ -1146,6 +1146,7 @@ struct mlx5_flex_item { struct mlx5_dev_ctx_shared { LIST_ENTRY(mlx5_dev_ctx_shared) next; uint32_t refcnt; + uint32_t esw_mode:1; /* Whether is E-Switch mode. */ uint32_t flow_hit_aso_en:1; /* Flow Hit ASO is supported. */ uint32_t steering_format_version:4; /* Indicates the device steering logic format. */ diff --git a/drivers/net/mlx5/mlx5_ethdev.c b/drivers/net/mlx5/mlx5_ethdev.c index 801c467bba..06d5acb75f 100644 --- a/drivers/net/mlx5/mlx5_ethdev.c +++ b/drivers/net/mlx5/mlx5_ethdev.c @@ -672,7 +672,7 @@ mlx5_port_to_eswitch_info(uint16_t port, bool valid) } dev = &rte_eth_devices[port]; priv = dev->data->dev_private; - if (!(priv->representor || priv->master)) { + if (!priv->sh->esw_mode) { rte_errno = EINVAL; return NULL; } @@ -699,7 +699,7 @@ mlx5_dev_to_eswitch_info(struct rte_eth_dev *dev) struct mlx5_priv *priv; priv = dev->data->dev_private; - if (!(priv->representor || priv->master)) { + if (!priv->sh->esw_mode) { rte_errno = EINVAL; return NULL; } diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 4e60a54df3..6a5ac01c2a 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -6600,11 +6600,6 @@ flow_dv_validate_attributes(struct rte_eth_dev *dev, (error, ENOTSUP, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, NULL, "E-Switch dr is not supported"); - if (!(priv->representor || priv->master)) - return rte_flow_error_set - (error, EINVAL, RTE_FLOW_ERROR_TYPE_UNSPECIFIED, - NULL, "E-Switch configuration can only be" - " done by a master or a representor device"); if (attributes->egress) return rte_flow_error_set (error, ENOTSUP, @@ -13612,8 +13607,7 @@ flow_dv_translate(struct rte_eth_dev *dev, * E-Switch rule where no port_id item was found. In both cases * the source port is set according the current port in use. */ - if (!(item_flags & MLX5_FLOW_ITEM_PORT_ID) && - (priv->representor || priv->master)) { + if (!(item_flags & MLX5_FLOW_ITEM_PORT_ID) && priv->sh->esw_mode) { if (flow_dv_translate_item_port_id(dev, match_mask, match_value, NULL, attr)) return -rte_errno; @@ -16173,7 +16167,7 @@ __flow_dv_create_policy_flow(struct rte_eth_dev *dev, struct mlx5_priv *priv = dev->data->dev_private; uint8_t misc_mask; - if (match_src_port && (priv->representor || priv->master)) { + if (match_src_port && priv->sh->esw_mode) { if (flow_dv_translate_item_port_id(dev, matcher.buf, value.buf, item, attr)) { DRV_LOG(ERR, "Failed to create meter policy%d flow's" @@ -16225,7 +16219,7 @@ __flow_dv_create_policy_matcher(struct rte_eth_dev *dev, struct mlx5_priv *priv = dev->data->dev_private; const uint32_t color_mask = (UINT32_C(1) << MLX5_MTR_COLOR_BITS) - 1; - if (match_src_port && (priv->representor || priv->master)) { + if (match_src_port && priv->sh->esw_mode) { if (flow_dv_translate_item_port_id(dev, matcher.mask.buf, value.buf, item, attr)) { DRV_LOG(ERR, "Failed to register meter policy%d matcher" diff --git a/drivers/net/mlx5/mlx5_trigger.c b/drivers/net/mlx5/mlx5_trigger.c index 7aefc93350..a00b56eecf 100644 --- a/drivers/net/mlx5/mlx5_trigger.c +++ b/drivers/net/mlx5/mlx5_trigger.c @@ -1330,8 +1330,7 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) goto error; } } - if ((priv->representor || priv->master) && - priv->config.dv_esw_en) { + if (priv->config.dv_esw_en) { if (mlx5_flow_create_devx_sq_miss_flow(dev, i) == 0) { DRV_LOG(ERR, "Port %u Tx queue %u SQ create representor devx default miss rule failed.", @@ -1341,7 +1340,7 @@ mlx5_traffic_enable(struct rte_eth_dev *dev) } mlx5_txq_release(dev, i); } - if ((priv->master || priv->representor) && priv->config.dv_esw_en) { + if (priv->config.dv_esw_en) { if (mlx5_flow_create_esw_table_zero_flow(dev)) priv->fdb_def_rule = 1; else -- 2.25.1