net/mlx5: support new global device syntax
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index 818e37f..aa42836 100644 (file)
@@ -43,6 +43,9 @@
 
 #define MLX5_ETH_DRIVER_NAME mlx5_eth
 
+/* Driver type key for new device global syntax. */
+#define MLX5_DRIVER_KEY "driver"
+
 /* Device parameter to enable RX completion queue compression. */
 #define MLX5_RXQ_CQE_COMP_EN "rxq_cqe_comp_en"
 
@@ -1254,6 +1257,8 @@ error:
        MLX5_ASSERT(sh);
        if (sh->cnt_id_tbl)
                mlx5_l3t_destroy(sh->cnt_id_tbl);
+       if (sh->share_cache.cache.table)
+               mlx5_mr_btree_free(&sh->share_cache.cache);
        if (sh->tis)
                claim_zero(mlx5_devx_cmd_destroy(sh->tis));
        if (sh->td)
@@ -1580,6 +1585,11 @@ mlx5_dev_close(struct rte_eth_dev *dev)
                priv->rxqs_n = 0;
                priv->rxqs = NULL;
        }
+       if (priv->representor) {
+               /* Each representor has a dedicated interrupts handler */
+               mlx5_free(dev->intr_handle);
+               dev->intr_handle = NULL;
+       }
        if (priv->txqs != NULL) {
                /* XXX race condition if mlx5_tx_burst() is still running. */
                rte_delay_us_sleep(1000);
@@ -1756,6 +1766,7 @@ const struct eth_dev_ops mlx5_dev_sec_ops = {
        .xstats_get_names = mlx5_xstats_get_names,
        .fw_version_get = mlx5_fw_version_get,
        .dev_infos_get = mlx5_dev_infos_get,
+       .representor_info_get = mlx5_representor_info_get,
        .read_clock = mlx5_txpp_read_clock,
        .rx_queue_start = mlx5_rx_queue_start,
        .rx_queue_stop = mlx5_rx_queue_stop,
@@ -1789,6 +1800,7 @@ const struct eth_dev_ops mlx5_dev_ops_isolate = {
        .xstats_get_names = mlx5_xstats_get_names,
        .fw_version_get = mlx5_fw_version_get,
        .dev_infos_get = mlx5_dev_infos_get,
+       .representor_info_get = mlx5_representor_info_get,
        .read_clock = mlx5_txpp_read_clock,
        .dev_supported_ptypes_get = mlx5_dev_supported_ptypes_get,
        .vlan_filter_set = mlx5_vlan_filter_set,
@@ -1853,7 +1865,7 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
        signed long tmp;
 
        /* No-op, port representors are processed in mlx5_dev_spawn(). */
-       if (!strcmp(MLX5_REPRESENTOR, key))
+       if (!strcmp(MLX5_DRIVER_KEY, key) || !strcmp(MLX5_REPRESENTOR, key))
                return 0;
        errno = 0;
        tmp = strtol(val, NULL, 0);
@@ -2007,6 +2019,7 @@ int
 mlx5_args(struct mlx5_dev_config *config, struct rte_devargs *devargs)
 {
        const char **params = (const char *[]){
+               MLX5_DRIVER_KEY,
                MLX5_RXQ_CQE_COMP_EN,
                MLX5_RXQ_PKT_PAD_EN,
                MLX5_RX_MPRQ_EN,
@@ -2290,7 +2303,8 @@ rte_pmd_mlx5_get_dyn_flag_names(char *names[], unsigned int n)
  */
 int
 mlx5_dev_check_sibling_config(struct mlx5_priv *priv,
-                             struct mlx5_dev_config *config)
+                             struct mlx5_dev_config *config,
+                             struct rte_device *dpdk_dev)
 {
        struct mlx5_dev_ctx_shared *sh = priv->sh;
        struct mlx5_dev_config *sh_conf = NULL;
@@ -2301,7 +2315,7 @@ mlx5_dev_check_sibling_config(struct mlx5_priv *priv,
        if (sh->refcnt == 1)
                return 0;
        /* Find the device with shared context. */
-       MLX5_ETH_FOREACH_DEV(port_id, NULL) {
+       MLX5_ETH_FOREACH_DEV(port_id, dpdk_dev) {
                struct mlx5_priv *opriv =
                        rte_eth_devices[port_id].data->dev_private;
 
@@ -2376,7 +2390,7 @@ mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev)
  * @return
  *   0 on success, the function cannot fail.
  */
-static int
+int
 mlx5_net_remove(struct rte_device *dev)
 {
        uint16_t port_id;