net/mlx5: share counter config function
[dpdk.git] / drivers / net / mlx5 / linux / mlx5_os.c
index 191da1b..1ff2b8d 100644 (file)
@@ -171,6 +171,15 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
        device_attr->tso_supported_qpts = attr_ex.tso_caps.supported_qpts;
 
        struct mlx5dv_context dv_attr = { .comp_mask = 0 };
+#ifdef HAVE_IBV_MLX5_MOD_SWP
+       dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;
+#endif
+#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
+       dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS;
+#endif
+#ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
+       dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ;
+#endif
        err = mlx5_glue->dv_query_device(ctx, &dv_attr);
        if (err) {
                rte_errno = errno;
@@ -183,6 +192,7 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
        device_attr->sw_parsing_offloads =
                dv_attr.sw_parsing_caps.sw_parsing_offloads;
 #endif
+#ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
        device_attr->min_single_stride_log_num_of_bytes =
                dv_attr.striding_rq_caps.min_single_stride_log_num_of_bytes;
        device_attr->max_single_stride_log_num_of_bytes =
@@ -193,6 +203,7 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
                dv_attr.striding_rq_caps.max_single_wqe_log_num_of_strides;
        device_attr->stride_supported_qpts =
                dv_attr.striding_rq_caps.supported_qpts;
+#endif
 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
        device_attr->tunnel_offloads_caps = dv_attr.tunnel_offloads_caps;
 #endif
@@ -662,45 +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;
-       bool fallback;
-
-#ifndef HAVE_IBV_DEVX_ASYNC
-       fallback = true;
-#else
-       fallback = false;
-       if (!sh->devx || !priv->config.dv_flow_en ||
-           !priv->config.hca_attr.flow_counters_dump ||
-           !(priv->config.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.",
-                       priv->config.hca_attr.flow_counters_dump,
-                       priv->config.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.
  *
@@ -875,8 +847,8 @@ mlx5_dev_spawn(struct rte_device *dpdk_dev,
 {
        const struct mlx5_switch_info *switch_info = &spawn->info;
        struct mlx5_dev_ctx_shared *sh = NULL;
+       struct mlx5_hca_attr *hca_attr = &spawn->cdev->config.hca_attr;
        struct ibv_port_attr port_attr = { .state = IBV_PORT_NOP };
-       struct mlx5dv_context dv_attr = { .comp_mask = 0 };
        struct rte_eth_dev *eth_dev = NULL;
        struct mlx5_priv *priv = NULL;
        int err = 0;
@@ -990,7 +962,7 @@ err_secondary:
        }
 #endif
 #ifdef HAVE_MLX5DV_DR_ESWITCH
-       if (!(sh->cdev->config.hca_attr.eswitch_manager && config->dv_flow_en &&
+       if (!(hca_attr->eswitch_manager && config->dv_flow_en &&
              (switch_info->representor || switch_info->master)))
                config->dv_esw_en = 0;
 #else
@@ -1009,23 +981,13 @@ err_secondary:
                goto error;
 #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR
        config->dest_tir = 1;
-#endif
-#ifdef HAVE_IBV_MLX5_MOD_SWP
-       dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_SWP;
 #endif
        /*
         * Multi-packet send is supported by ConnectX-4 Lx PF as well
         * as all ConnectX-5 devices.
         */
-#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
-       dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS;
-#endif
-#ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
-       dv_attr.comp_mask |= MLX5DV_CONTEXT_MASK_STRIDING_RQ;
-#endif
-       mlx5_glue->dv_query_device(sh->cdev->ctx, &dv_attr);
-       if (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
-               if (dv_attr.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
+       if (sh->device_attr.flags & MLX5DV_CONTEXT_FLAGS_MPW_ALLOWED) {
+               if (sh->device_attr.flags & MLX5DV_CONTEXT_FLAGS_ENHANCED_MPW) {
                        DRV_LOG(DEBUG, "enhanced MPW is supported");
                        mps = MLX5_MPW_ENHANCED;
                } else {
@@ -1037,44 +999,41 @@ err_secondary:
                mps = MLX5_MPW_DISABLED;
        }
 #ifdef HAVE_IBV_MLX5_MOD_SWP
-       if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_SWP)
-               swp = dv_attr.sw_parsing_caps.sw_parsing_offloads;
+       if (sh->device_attr.comp_mask & MLX5DV_CONTEXT_MASK_SWP)
+               swp = sh->device_attr.sw_parsing_offloads;
        DRV_LOG(DEBUG, "SWP support: %u", swp);
 #endif
        config->swp = swp & (MLX5_SW_PARSING_CAP | MLX5_SW_PARSING_CSUM_CAP |
                MLX5_SW_PARSING_TSO_CAP);
 #ifdef HAVE_IBV_DEVICE_STRIDING_RQ_SUPPORT
-       if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) {
-               struct mlx5dv_striding_rq_caps mprq_caps =
-                       dv_attr.striding_rq_caps;
-
+       if (sh->device_attr.comp_mask & MLX5DV_CONTEXT_MASK_STRIDING_RQ) {
                DRV_LOG(DEBUG, "\tmin_single_stride_log_num_of_bytes: %d",
-                       mprq_caps.min_single_stride_log_num_of_bytes);
+                       sh->device_attr.min_single_stride_log_num_of_bytes);
                DRV_LOG(DEBUG, "\tmax_single_stride_log_num_of_bytes: %d",
-                       mprq_caps.max_single_stride_log_num_of_bytes);
+                       sh->device_attr.max_single_stride_log_num_of_bytes);
                DRV_LOG(DEBUG, "\tmin_single_wqe_log_num_of_strides: %d",
-                       mprq_caps.min_single_wqe_log_num_of_strides);
+                       sh->device_attr.min_single_wqe_log_num_of_strides);
                DRV_LOG(DEBUG, "\tmax_single_wqe_log_num_of_strides: %d",
-                       mprq_caps.max_single_wqe_log_num_of_strides);
+                       sh->device_attr.max_single_wqe_log_num_of_strides);
                DRV_LOG(DEBUG, "\tsupported_qpts: %d",
-                       mprq_caps.supported_qpts);
+                       sh->device_attr.stride_supported_qpts);
                DRV_LOG(DEBUG, "\tmin_stride_wqe_log_size: %d",
                        config->mprq.log_min_stride_wqe_size);
                DRV_LOG(DEBUG, "device supports Multi-Packet RQ");
                mprq = 1;
                config->mprq.log_min_stride_size =
-                       mprq_caps.min_single_stride_log_num_of_bytes;
+                       sh->device_attr.min_single_stride_log_num_of_bytes;
                config->mprq.log_max_stride_size =
-                       mprq_caps.max_single_stride_log_num_of_bytes;
+                       sh->device_attr.max_single_stride_log_num_of_bytes;
                config->mprq.log_min_stride_num =
-                       mprq_caps.min_single_wqe_log_num_of_strides;
+                       sh->device_attr.min_single_wqe_log_num_of_strides;
                config->mprq.log_max_stride_num =
-                       mprq_caps.max_single_wqe_log_num_of_strides;
+                       sh->device_attr.max_single_wqe_log_num_of_strides;
        }
 #endif
 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
-       if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) {
-               config->tunnel_en = dv_attr.tunnel_offloads_caps &
+       if (sh->device_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) {
+               config->tunnel_en = sh->device_attr.tunnel_offloads_caps &
                             (MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_VXLAN |
                              MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_GRE |
                              MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_GENEVE);
@@ -1096,9 +1055,9 @@ err_secondary:
                "tunnel offloading disabled due to old OFED/rdma-core version");
 #endif
 #ifdef HAVE_IBV_DEVICE_MPLS_SUPPORT
-       mpls_en = ((dv_attr.tunnel_offloads_caps &
+       mpls_en = ((sh->device_attr.tunnel_offloads_caps &
                    MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_GRE) &&
-                  (dv_attr.tunnel_offloads_caps &
+                  (sh->device_attr.tunnel_offloads_caps &
                    MLX5DV_RAW_PACKET_CAP_TUNNELED_OFFLOAD_CW_MPLS_OVER_UDP));
        DRV_LOG(DEBUG, "MPLS over GRE/UDP tunnel offloading is %ssupported",
                mpls_en ? "" : "not ");
@@ -1314,15 +1273,13 @@ err_secondary:
                config->mps == MLX5_MPW_ENHANCED ? "enhanced " :
                config->mps == MLX5_MPW ? "legacy " : "",
                config->mps != MLX5_MPW_DISABLED ? "enabled" : "disabled");
-       if (sh->devx) {
-               config->hca_attr = sh->cdev->config.hca_attr;
-               sh->steering_format_version =
-                       config->hca_attr.steering_format_version;
+       if (sh->cdev->config.devx) {
+               sh->steering_format_version = hca_attr->steering_format_version;
                /* Check for LRO support. */
-               if (config->dest_tir && config->hca_attr.lro_cap &&
+               if (config->dest_tir && hca_attr->lro_cap &&
                    config->dv_flow_en) {
                        /* TBD check tunnel lro caps. */
-                       config->lro.supported = config->hca_attr.lro_cap;
+                       config->lro.supported = hca_attr->lro_cap;
                        DRV_LOG(DEBUG, "Device supports LRO");
                        /*
                         * If LRO timeout is not configured by application,
@@ -1330,21 +1287,19 @@ err_secondary:
                         */
                        if (!config->lro.timeout)
                                config->lro.timeout =
-                               config->hca_attr.lro_timer_supported_periods[0];
+                                      hca_attr->lro_timer_supported_periods[0];
                        DRV_LOG(DEBUG, "LRO session timeout set to %d usec",
                                config->lro.timeout);
                        DRV_LOG(DEBUG, "LRO minimal size of TCP segment "
                                "required for coalescing is %d bytes",
-                               config->hca_attr.lro_min_mss_size);
+                               hca_attr->lro_min_mss_size);
                }
 #if defined(HAVE_MLX5DV_DR) && \
        (defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_METER) || \
         defined(HAVE_MLX5_DR_CREATE_ACTION_ASO))
-               if (config->hca_attr.qos.sup &&
-                   config->hca_attr.qos.flow_meter_old &&
+               if (hca_attr->qos.sup && hca_attr->qos.flow_meter_old &&
                    config->dv_flow_en) {
-                       uint8_t reg_c_mask =
-                               config->hca_attr.qos.flow_meter_reg_c_ids;
+                       uint8_t reg_c_mask = hca_attr->qos.flow_meter_reg_c_ids;
                        /*
                         * Meter needs two REG_C's for color match and pre-sfx
                         * flow match. Here get the REG_C for color match.
@@ -1368,20 +1323,18 @@ err_secondary:
                                        priv->mtr_color_reg = ffs(reg_c_mask)
                                                              - 1 + REG_C_0;
                                priv->mtr_en = 1;
-                               priv->mtr_reg_share =
-                                     config->hca_attr.qos.flow_meter;
+                               priv->mtr_reg_share = hca_attr->qos.flow_meter;
                                DRV_LOG(DEBUG, "The REG_C meter uses is %d",
                                        priv->mtr_color_reg);
                        }
                }
-               if (config->hca_attr.qos.sup &&
-                       config->hca_attr.qos.flow_meter_aso_sup) {
+               if (hca_attr->qos.sup && hca_attr->qos.flow_meter_aso_sup) {
                        uint32_t log_obj_size =
                                rte_log2_u32(MLX5_ASO_MTRS_PER_POOL >> 1);
                        if (log_obj_size >=
-                       config->hca_attr.qos.log_meter_aso_granularity &&
-                       log_obj_size <=
-                       config->hca_attr.qos.log_meter_aso_max_alloc)
+                           hca_attr->qos.log_meter_aso_granularity &&
+                           log_obj_size <=
+                           hca_attr->qos.log_meter_aso_max_alloc)
                                sh->meter_aso_en = 1;
                }
                if (priv->mtr_en) {
@@ -1391,12 +1344,11 @@ err_secondary:
                                goto error;
                        }
                }
-               if (config->hca_attr.flow.tunnel_header_0_1)
+               if (hca_attr->flow.tunnel_header_0_1)
                        sh->tunnel_header_0_1 = 1;
 #endif
 #ifdef HAVE_MLX5_DR_CREATE_ACTION_ASO
-               if (config->hca_attr.flow_hit_aso &&
-                   priv->mtr_color_reg == REG_C_3) {
+               if (hca_attr->flow_hit_aso && priv->mtr_color_reg == REG_C_3) {
                        sh->flow_hit_aso_en = 1;
                        err = mlx5_flow_aso_age_mng_init(sh);
                        if (err) {
@@ -1408,8 +1360,7 @@ err_secondary:
 #endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO */
 #if defined(HAVE_MLX5_DR_CREATE_ACTION_ASO) && \
        defined(HAVE_MLX5_DR_ACTION_ASO_CT)
-               if (config->hca_attr.ct_offload &&
-                   priv->mtr_color_reg == REG_C_3) {
+               if (hca_attr->ct_offload && priv->mtr_color_reg == REG_C_3) {
                        err = mlx5_flow_aso_ct_mng_init(sh);
                        if (err) {
                                err = -err;
@@ -1420,13 +1371,13 @@ err_secondary:
                }
 #endif /* HAVE_MLX5_DR_CREATE_ACTION_ASO && HAVE_MLX5_DR_ACTION_ASO_CT */
 #if defined(HAVE_MLX5DV_DR) && defined(HAVE_MLX5_DR_CREATE_ACTION_FLOW_SAMPLE)
-               if (config->hca_attr.log_max_ft_sampler_num > 0  &&
+               if (hca_attr->log_max_ft_sampler_num > 0  &&
                    config->dv_flow_en) {
                        priv->sampler_en = 1;
                        DRV_LOG(DEBUG, "Sampler enabled!");
                } else {
                        priv->sampler_en = 0;
-                       if (!config->hca_attr.log_max_ft_sampler_num)
+                       if (!hca_attr->log_max_ft_sampler_num)
                                DRV_LOG(WARNING,
                                        "No available register for sampler.");
                        else
@@ -1435,18 +1386,18 @@ err_secondary:
 #endif
        }
        if (config->cqe_comp && RTE_CACHE_LINE_SIZE == 128 &&
-           !(dv_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP)) {
+           !(sh->device_attr.flags & MLX5DV_CONTEXT_FLAGS_CQE_128B_COMP)) {
                DRV_LOG(WARNING, "Rx CQE 128B compression is not supported");
                config->cqe_comp = 0;
        }
        if (config->cqe_comp_fmt == MLX5_CQE_RESP_FORMAT_FTAG_STRIDX &&
-           (!sh->devx || !config->hca_attr.mini_cqe_resp_flow_tag)) {
+           (!sh->cdev->config.devx || !hca_attr->mini_cqe_resp_flow_tag)) {
                DRV_LOG(WARNING, "Flow Tag CQE compression"
                                 " format isn't supported.");
                config->cqe_comp = 0;
        }
        if (config->cqe_comp_fmt == MLX5_CQE_RESP_FORMAT_L34H_STRIDX &&
-           (!sh->devx || !config->hca_attr.mini_cqe_resp_l3_l4_tag)) {
+           (!sh->cdev->config.devx || !hca_attr->mini_cqe_resp_l3_l4_tag)) {
                DRV_LOG(WARNING, "L3/L4 Header CQE compression"
                                 " format isn't supported.");
                config->cqe_comp = 0;
@@ -1455,55 +1406,55 @@ err_secondary:
                        config->cqe_comp ? "" : "not ");
        if (config->tx_pp) {
                DRV_LOG(DEBUG, "Timestamp counter frequency %u kHz",
-                       config->hca_attr.dev_freq_khz);
+                       hca_attr->dev_freq_khz);
                DRV_LOG(DEBUG, "Packet pacing is %ssupported",
-                       config->hca_attr.qos.packet_pacing ? "" : "not ");
+                       hca_attr->qos.packet_pacing ? "" : "not ");
                DRV_LOG(DEBUG, "Cross channel ops are %ssupported",
-                       config->hca_attr.cross_channel ? "" : "not ");
+                       hca_attr->cross_channel ? "" : "not ");
                DRV_LOG(DEBUG, "WQE index ignore is %ssupported",
-                       config->hca_attr.wqe_index_ignore ? "" : "not ");
+                       hca_attr->wqe_index_ignore ? "" : "not ");
                DRV_LOG(DEBUG, "Non-wire SQ feature is %ssupported",
-                       config->hca_attr.non_wire_sq ? "" : "not ");
+                       hca_attr->non_wire_sq ? "" : "not ");
                DRV_LOG(DEBUG, "Static WQE SQ feature is %ssupported (%d)",
-                       config->hca_attr.log_max_static_sq_wq ? "" : "not ",
-                       config->hca_attr.log_max_static_sq_wq);
+                       hca_attr->log_max_static_sq_wq ? "" : "not ",
+                       hca_attr->log_max_static_sq_wq);
                DRV_LOG(DEBUG, "WQE rate PP mode is %ssupported",
-                       config->hca_attr.qos.wqe_rate_pp ? "" : "not ");
-               if (!sh->devx) {
+                       hca_attr->qos.wqe_rate_pp ? "" : "not ");
+               if (!sh->cdev->config.devx) {
                        DRV_LOG(ERR, "DevX is required for packet pacing");
                        err = ENODEV;
                        goto error;
                }
-               if (!config->hca_attr.qos.packet_pacing) {
+               if (!hca_attr->qos.packet_pacing) {
                        DRV_LOG(ERR, "Packet pacing is not supported");
                        err = ENODEV;
                        goto error;
                }
-               if (!config->hca_attr.cross_channel) {
+               if (!hca_attr->cross_channel) {
                        DRV_LOG(ERR, "Cross channel operations are"
                                     " required for packet pacing");
                        err = ENODEV;
                        goto error;
                }
-               if (!config->hca_attr.wqe_index_ignore) {
+               if (!hca_attr->wqe_index_ignore) {
                        DRV_LOG(ERR, "WQE index ignore feature is"
                                     " required for packet pacing");
                        err = ENODEV;
                        goto error;
                }
-               if (!config->hca_attr.non_wire_sq) {
+               if (!hca_attr->non_wire_sq) {
                        DRV_LOG(ERR, "Non-wire SQ feature is"
                                     " required for packet pacing");
                        err = ENODEV;
                        goto error;
                }
-               if (!config->hca_attr.log_max_static_sq_wq) {
+               if (!hca_attr->log_max_static_sq_wq) {
                        DRV_LOG(ERR, "Static WQE SQ feature is"
                                     " required for packet pacing");
                        err = ENODEV;
                        goto error;
                }
-               if (!config->hca_attr.qos.wqe_rate_pp) {
+               if (!hca_attr->qos.wqe_rate_pp) {
                        DRV_LOG(ERR, "WQE rate mode is required"
                                     " for packet pacing");
                        err = ENODEV;
@@ -1517,7 +1468,7 @@ err_secondary:
 #endif
        }
        if (config->std_delay_drop || config->hp_delay_drop) {
-               if (!config->hca_attr.rq_delay_drop) {
+               if (!hca_attr->rq_delay_drop) {
                        config->std_delay_drop = 0;
                        config->hp_delay_drop = 0;
                        DRV_LOG(WARNING,
@@ -1525,34 +1476,14 @@ err_secondary:
                                priv->dev_port);
                }
        }
-       if (sh->devx) {
-               uint32_t reg[MLX5_ST_SZ_DW(register_mtutc)];
-
-               err = config->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 (config->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
         * bit. Then RTE_ETH_RX_OFFLOAD_KEEP_CRC bit will not be set anymore.
         */
-       if (config->hca_attr.scatter_fcs_w_decap_disable && config->decap_en)
+       if (hca_attr->scatter_fcs_w_decap_disable && config->decap_en)
                config->hw_fcs_strip = 0;
        DRV_LOG(DEBUG, "FCS stripping configuration is %ssupported",
                (config->hw_fcs_strip ? "" : "not "));
@@ -1683,7 +1614,7 @@ err_secondary:
                if (mlx5_flex_item_port_init(eth_dev) < 0)
                        goto error;
        }
-       if (sh->devx && config->dv_flow_en && config->dest_tir) {
+       if (sh->cdev->config.devx && config->dv_flow_en && config->dest_tir) {
                priv->obj_ops = devx_obj_ops;
                mlx5_queue_counter_id_prepare(eth_dev);
                priv->obj_ops.lb_dummy_queue_create =
@@ -2110,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;
@@ -2431,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) {
@@ -2469,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) {
@@ -2742,7 +2657,7 @@ mlx5_os_dev_shared_handler_install(struct mlx5_dev_ctx_shared *sh)
                        rte_intr_fd_set(sh->intr_handle, -1);
                }
        }
-       if (sh->devx) {
+       if (sh->cdev->config.devx) {
 #ifdef HAVE_IBV_DEVX_ASYNC
                sh->intr_handle_devx =
                        rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_SHARED);