]> git.droids-corp.org - dpdk.git/commitdiff
net/mlx5: add E-Switch mode flag
authorMichael Baum <michaelba@nvidia.com>
Mon, 14 Feb 2022 09:35:04 +0000 (11:35 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Mon, 21 Feb 2022 10:36:49 +0000 (11:36 +0100)
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 <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/linux/mlx5_os.c
drivers/net/mlx5/mlx5.c
drivers/net/mlx5/mlx5.h
drivers/net/mlx5/mlx5_ethdev.c
drivers/net/mlx5/mlx5_flow_dv.c
drivers/net/mlx5/mlx5_trigger.c

index 1ff2b8dc2284868ef1421e9383cc0c5a70c44dc6..69ba2aaf88686f5cb6a462b571e28b1a88dcc19a 100644 (file)
@@ -951,10 +951,6 @@ err_secondary:
        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 @@ err_secondary:
        }
 #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 @@ err_secondary:
         * 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 @@ err_secondary:
        }
        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);
index 531916f3a5e425ebffecb8e618c457196a22acc2..b26632d2499079a132ed70ac556facd447bd6ab5 100644 (file)
@@ -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);
index d69b6a357be321c274e4a55c050d300005674ba3..a713e61572e420bd41f744ffd0ab53e3dcf158b8 100644 (file)
@@ -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. */
index 801c467bba71910df271265747a3033135b1923f..06d5acb75fcc00275f9cecee2a985b6941df20d3 100644 (file)
@@ -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;
        }
index 4e60a54df35fb1a123fa798b0ecec912f8d6f8b3..6a5ac01c2abe3f9d55511b5b5445e273bf26effc 100644 (file)
@@ -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"
index 7aefc93350b34aab947467cf860f17e69ff9e91e..a00b56eecfaefc87cbbd49b35395baa0f27fc2fa 100644 (file)
@@ -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