net/mlx5: share counter config function
authorMichael Baum <michaelba@nvidia.com>
Mon, 14 Feb 2022 09:35:03 +0000 (11:35 +0200)
committerRaslan Darawsheh <rasland@nvidia.com>
Mon, 21 Feb 2022 10:36:48 +0000 (11:36 +0100)
The mlx5_flow_counter_mode_config function exists for both Linux and
Windows with the same name and content.
This patch moves its implementation to the folder shared between the
operating systems, removing the duplication.

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/windows/mlx5_os.c

index bee0557..1ff2b8d 100644 (file)
@@ -673,46 +673,6 @@ out:
        return ret;
 }
 
-/**
- * DV flow counter mode detect and config.
- *
- * @param dev
- *   Pointer to rte_eth_dev structure.
- *
- */
-static void
-mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)
-{
-#ifdef HAVE_IBV_FLOW_DV_SUPPORT
-       struct mlx5_priv *priv = dev->data->dev_private;
-       struct mlx5_dev_ctx_shared *sh = priv->sh;
-       struct mlx5_hca_attr *hca_attr = &sh->cdev->config.hca_attr;
-       bool fallback;
-
-#ifndef HAVE_IBV_DEVX_ASYNC
-       fallback = true;
-#else
-       fallback = false;
-       if (!sh->cdev->config.devx || !priv->config.dv_flow_en ||
-           !hca_attr->flow_counters_dump ||
-           !(hca_attr->flow_counter_bulk_alloc_bitmap & 0x4) ||
-           (mlx5_flow_dv_discover_counter_offset_support(dev) == -ENOTSUP))
-               fallback = true;
-#endif
-       if (fallback)
-               DRV_LOG(INFO, "Use fall-back DV counter management. Flow "
-                       "counter dump:%d, bulk_alloc_bitmap:0x%hhx.",
-                       hca_attr->flow_counters_dump,
-                       hca_attr->flow_counter_bulk_alloc_bitmap);
-       /* Initialize fallback mode only on the port initializes sh. */
-       if (sh->refcnt == 1)
-               sh->cmng.counter_fallback = fallback;
-       else if (fallback != sh->cmng.counter_fallback)
-               DRV_LOG(WARNING, "Port %d in sh has different fallback mode "
-                       "with others:%d.", PORT_ID(priv), fallback);
-#endif
-}
-
 /**
  * DR flow drop action support detect.
  *
index 4884198..531916f 100644 (file)
@@ -513,6 +513,46 @@ mlx5_flow_aging_init(struct mlx5_dev_ctx_shared *sh)
        }
 }
 
+/**
+ * DV flow counter mode detect and config.
+ *
+ * @param dev
+ *   Pointer to rte_eth_dev structure.
+ *
+ */
+void
+mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)
+{
+#ifdef HAVE_IBV_FLOW_DV_SUPPORT
+       struct mlx5_priv *priv = dev->data->dev_private;
+       struct mlx5_dev_ctx_shared *sh = priv->sh;
+       struct mlx5_hca_attr *hca_attr = &sh->cdev->config.hca_attr;
+       bool fallback;
+
+#ifndef HAVE_IBV_DEVX_ASYNC
+       fallback = true;
+#else
+       fallback = false;
+       if (!sh->cdev->config.devx || !priv->config.dv_flow_en ||
+           !hca_attr->flow_counters_dump ||
+           !(hca_attr->flow_counter_bulk_alloc_bitmap & 0x4) ||
+           (mlx5_flow_dv_discover_counter_offset_support(dev) == -ENOTSUP))
+               fallback = true;
+#endif
+       if (fallback)
+               DRV_LOG(INFO, "Use fall-back DV counter management. Flow "
+                       "counter dump:%d, bulk_alloc_bitmap:0x%hhx.",
+                       hca_attr->flow_counters_dump,
+                       hca_attr->flow_counter_bulk_alloc_bitmap);
+       /* Initialize fallback mode only on the port initializes sh. */
+       if (sh->refcnt == 1)
+               sh->cmng.counter_fallback = fallback;
+       else if (fallback != sh->cmng.counter_fallback)
+               DRV_LOG(WARNING, "Port %d in sh has different fallback mode "
+                       "with others:%d.", PORT_ID(priv), fallback);
+#endif
+}
+
 /**
  * Initialize the counters management structure.
  *
index 0f90d75..d69b6a3 100644 (file)
@@ -1535,6 +1535,7 @@ int mlx5_dev_check_sibling_config(struct mlx5_dev_ctx_shared *sh,
                                  struct rte_device *dpdk_dev);
 bool mlx5_flex_parser_ecpri_exist(struct rte_eth_dev *dev);
 int mlx5_flex_parser_ecpri_alloc(struct rte_eth_dev *dev);
+void mlx5_flow_counter_mode_config(struct rte_eth_dev *dev);
 int mlx5_flow_aso_age_mng_init(struct mlx5_dev_ctx_shared *sh);
 int mlx5_aso_flow_mtrs_mng_init(struct mlx5_dev_ctx_shared *sh);
 int mlx5_flow_aso_ct_mng_init(struct mlx5_dev_ctx_shared *sh);
index cf0819e..e509c34 100644 (file)
@@ -255,46 +255,6 @@ mlx5_os_set_nonblock_channel_fd(int fd)
        return -ENOTSUP;
 }
 
-/**
- * DV flow counter mode detect and config.
- *
- * @param dev
- *   Pointer to rte_eth_dev structure.
- *
- */
-static void
-mlx5_flow_counter_mode_config(struct rte_eth_dev *dev __rte_unused)
-{
-#ifdef HAVE_IBV_FLOW_DV_SUPPORT
-       struct mlx5_priv *priv = dev->data->dev_private;
-       struct mlx5_dev_ctx_shared *sh = priv->sh;
-       struct mlx5_hca_attr *hca_attr = &sh->cdev->config.hca_attr;
-       bool fallback;
-
-#ifndef HAVE_IBV_DEVX_ASYNC
-       fallback = true;
-#else
-       fallback = false;
-       if (!sh->cdev->config.devx || !priv->config.dv_flow_en ||
-           !hca_attr->flow_counters_dump ||
-           !(hca_attr->flow_counter_bulk_alloc_bitmap & 0x4) ||
-           (mlx5_flow_dv_discover_counter_offset_support(dev) == -ENOTSUP))
-               fallback = true;
-#endif
-       if (fallback)
-               DRV_LOG(INFO, "Use fall-back DV counter management. Flow "
-                       "counter dump:%d, bulk_alloc_bitmap:0x%hhx.",
-                       hca_attr->flow_counters_dump,
-                       hca_attr->flow_counter_bulk_alloc_bitmap);
-       /* Initialize fallback mode only on the port initializes sh. */
-       if (sh->refcnt == 1)
-               sh->cmng.counter_fallback = fallback;
-       else if (fallback != sh->cmng.counter_fallback)
-               DRV_LOG(WARNING, "Port %d in sh has different fallback mode "
-                       "with others:%d.", PORT_ID(priv), fallback);
-#endif
-}
-
 /**
  * Spawn an Ethernet device from DevX information.
  *