net/mlx5: share counter config function
[dpdk.git] / drivers / net / mlx5 / linux / mlx5_os.c
index 2616668..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.
  *
@@ -1516,27 +1476,8 @@ err_secondary:
                                priv->dev_port);
                }
        }
-       if (sh->cdev->config.devx) {
-               uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)];
-
-               err = hca_attr->access_register_user ?
-                       mlx5_devx_cmd_register_read
-                               (sh->cdev->ctx, MLX5_REGISTER_ID_MTUTC, 0,
-                               reg, MLX5_ST_SZ_DW(register_mtutc)) : ENOTSUP;
-               if (!err) {
-                       uint32_t ts_mode;
-
-                       /* MTUTC register is read successfully. */
-                       ts_mode = MLX5_GET(register_mtutc, reg,
-                                          time_stamp_mode);
-                       if (ts_mode == MLX5_MTUTC_TIMESTAMP_MODE_REAL_TIME)
-                               config->rt_timestamp = 1;
-               } else {
-                       /* Kernel does not support register reading. */
-                       if (hca_attr->dev_freq_khz == (NS_PER_S / MS_PER_S))
-                               config->rt_timestamp = 1;
-               }
-       }
+       if (sh->cdev->config.devx)
+               mlx5_rt_timestamp_config(sh, config, hca_attr);
        /*
         * If HW has bug working with tunnel packet decapsulation and
         * scatter FCS, and decapsulation is needed, clear the hw_fcs_strip
@@ -2100,7 +2041,6 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,
        struct rte_pci_device *pci_dev = RTE_DEV_TO_PCI(cdev->dev);
        struct mlx5_dev_spawn_data *list = NULL;
        struct mlx5_dev_config dev_config;
-       unsigned int dev_config_vf;
        struct rte_eth_devargs eth_da = *req_eth_da;
        struct rte_pci_addr owner_pci = pci_dev->addr; /* Owner PF. */
        struct mlx5_bond_info bond_info;
@@ -2421,21 +2361,6 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,
         * (i.e. master first, then representors from lowest to highest ID).
         */
        qsort(list, ns, sizeof(*list), mlx5_dev_spawn_data_cmp);
-       /* Device specific configuration. */
-       switch (pci_dev->id.device_id) {
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX4VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX4LXVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5EXVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX5BFVF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTX6VF:
-       case PCI_DEVICE_ID_MELLANOX_CONNECTXVF:
-               dev_config_vf = 1;
-               break;
-       default:
-               dev_config_vf = 0;
-               break;
-       }
        if (eth_da.type != RTE_ETH_REPRESENTOR_NONE) {
                /* Set devargs default values. */
                if (eth_da.nb_mh_controllers == 0) {
@@ -2459,7 +2384,7 @@ mlx5_os_pci_probe_pf(struct mlx5_common_device *cdev,
 
                /* Default configuration. */
                mlx5_os_config_default(&dev_config, &cdev->config);
-               dev_config.vf = dev_config_vf;
+               dev_config.vf = mlx5_dev_is_vf_pci(pci_dev);
                list[i].eth_dev = mlx5_dev_spawn(cdev->dev, &list[i],
                                                 &dev_config, &eth_da);
                if (!list[i].eth_dev) {