net/mlx5: add external Rx queue mapping API
[dpdk.git] / drivers / net / mlx5 / linux / mlx5_os.c
index 0faf26f..be95095 100644 (file)
@@ -1158,6 +1158,22 @@ err_secondary:
                err = ENOMEM;
                goto error;
        }
+       /*
+        * When user configures remote PD and CTX and device creates RxQ by
+        * DevX, external RxQ is both supported and requested.
+        */
+       if (mlx5_imported_pd_and_ctx(sh->cdev) && mlx5_devx_obj_ops_en(sh)) {
+               priv->ext_rxqs = mlx5_malloc(MLX5_MEM_ZERO | MLX5_MEM_RTE,
+                                            sizeof(struct mlx5_external_rxq) *
+                                            MLX5_MAX_EXT_RX_QUEUES, 0,
+                                            SOCKET_ID_ANY);
+               if (priv->ext_rxqs == NULL) {
+                       DRV_LOG(ERR, "Fail to allocate external RxQ array.");
+                       err = ENOMEM;
+                       goto error;
+               }
+               DRV_LOG(DEBUG, "External RxQ is supported.");
+       }
        priv->sh = sh;
        priv->dev_port = spawn->phys_port;
        priv->pci_dev = spawn->pci_dev;
@@ -1325,6 +1341,8 @@ err_secondary:
                }
                if (hca_attr->flow.tunnel_header_0_1)
                        sh->tunnel_header_0_1 = 1;
+               if (hca_attr->flow.tunnel_header_2_3)
+                       sh->tunnel_header_2_3 = 1;
 #endif
 #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO
                if (hca_attr->flow_hit_aso && priv->mtr_color_reg == REG_C_3) {
@@ -1521,6 +1539,15 @@ err_secondary:
        priv->drop_queue.hrxq = mlx5_drop_action_create(eth_dev);
        if (!priv->drop_queue.hrxq)
                goto error;
+       priv->hrxqs = mlx5_list_create("hrxq", eth_dev, true,
+                                      mlx5_hrxq_create_cb,
+                                      mlx5_hrxq_match_cb,
+                                      mlx5_hrxq_remove_cb,
+                                      mlx5_hrxq_clone_cb,
+                                      mlx5_hrxq_clone_free_cb);
+       if (!priv->hrxqs)
+               goto error;
+       rte_rwlock_init(&priv->ind_tbls_lock);
        if (priv->sh->config.dv_flow_en == 2)
                return eth_dev;
        /* Port representor shares the same max priority with pf port. */
@@ -1545,15 +1572,6 @@ err_secondary:
                        err = ENOTSUP;
                        goto error;
        }
-       priv->hrxqs = mlx5_list_create("hrxq", eth_dev, true,
-                                      mlx5_hrxq_create_cb,
-                                      mlx5_hrxq_match_cb,
-                                      mlx5_hrxq_remove_cb,
-                                      mlx5_hrxq_clone_cb,
-                                      mlx5_hrxq_clone_free_cb);
-       if (!priv->hrxqs)
-               goto error;
-       rte_rwlock_init(&priv->ind_tbls_lock);
        /* Query availability of metadata reg_c's. */
        if (!priv->sh->metadata_regc_check_flag) {
                err = mlx5_flow_discover_mreg_c(eth_dev);
@@ -1617,6 +1635,7 @@ error:
                        mlx5_list_destroy(priv->hrxqs);
                if (eth_dev && priv->flex_item_map)
                        mlx5_flex_item_port_cleanup(eth_dev);
+               mlx5_free(priv->ext_rxqs);
                mlx5_free(priv);
                if (eth_dev != NULL)
                        eth_dev->data->dev_private = NULL;