net/mlx5: remove redundant check of devargs
[dpdk.git] / drivers / net / mlx5 / linux / mlx5_os.c
index bbe05bb..191da1b 100644 (file)
@@ -138,7 +138,7 @@ mlx5_os_set_nonblock_channel_fd(int fd)
  *   Pointer to mlx5 device attributes.
  *
  * @return
- *   0 on success, non zero error number otherwise
+ *   0 on success, a negative errno value otherwise and rte_errno is set.
  */
 int
 mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
@@ -150,8 +150,10 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
 
        memset(device_attr, 0, sizeof(*device_attr));
        err = mlx5_glue->query_device_ex(ctx, NULL, &attr_ex);
-       if (err)
-               return err;
+       if (err) {
+               rte_errno = errno;
+               return -rte_errno;
+       }
        device_attr->device_cap_flags_ex = attr_ex.device_cap_flags_ex;
        device_attr->max_qp_wr = attr_ex.orig_attr.max_qp_wr;
        device_attr->max_sge = attr_ex.orig_attr.max_sge;
@@ -170,8 +172,10 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
 
        struct mlx5dv_context dv_attr = { .comp_mask = 0 };
        err = mlx5_glue->dv_query_device(ctx, &dv_attr);
-       if (err)
-               return err;
+       if (err) {
+               rte_errno = errno;
+               return -rte_errno;
+       }
 
        device_attr->flags = dv_attr.flags;
        device_attr->comp_mask = dv_attr.comp_mask;
@@ -195,7 +199,7 @@ mlx5_os_get_dev_attr(struct mlx5_common_device *cdev,
        strlcpy(device_attr->fw_ver, attr_ex.orig_attr.fw_ver,
                sizeof(device_attr->fw_ver));
 
-       return err;
+       return 0;
 }
 
 /**
@@ -964,26 +968,45 @@ err_secondary:
                mlx5_dev_close(eth_dev);
                return NULL;
        }
-       /*
-        * Some parameters ("tx_db_nc" in particularly) are needed in
-        * advance to create dv/verbs device context. We proceed the
-        * devargs here to get ones, and later proceed devargs again
-        * to override some hardware settings.
-        */
+       /* Process parameters. */
        err = mlx5_args(config, dpdk_dev->devargs);
        if (err) {
-               err = rte_errno;
                DRV_LOG(ERR, "failed to process device arguments: %s",
                        strerror(rte_errno));
-               goto error;
+               return NULL;
        }
+       sh = mlx5_alloc_shared_dev_ctx(spawn, config);
+       if (!sh)
+               return NULL;
+       /* Update final values for devargs before check sibling config. */
        if (config->dv_miss_info) {
                if (switch_info->master || switch_info->representor)
                        config->dv_xmeta_en = MLX5_XMETA_MODE_META16;
        }
-       sh = mlx5_alloc_shared_dev_ctx(spawn, config);
-       if (!sh)
-               return NULL;
+#if !defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_MLX5DV_DR)
+       if (config->dv_flow_en) {
+               DRV_LOG(WARNING, "DV flow is not supported.");
+               config->dv_flow_en = 0;
+       }
+#endif
+#ifdef HAVE_MLX5DV_DR_ESWITCH
+       if (!(sh->cdev->config.hca_attr.eswitch_manager && config->dv_flow_en &&
+             (switch_info->representor || switch_info->master)))
+               config->dv_esw_en = 0;
+#else
+       config->dv_esw_en = 0;
+#endif
+       if (!config->dv_esw_en &&
+           config->dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
+               DRV_LOG(WARNING,
+                       "Metadata mode %u is not supported (no E-Switch).",
+                       config->dv_xmeta_en);
+               config->dv_xmeta_en = MLX5_XMETA_MODE_LEGACY;
+       }
+       /* Check sibling device configurations. */
+       err = mlx5_dev_check_sibling_config(sh, config, dpdk_dev);
+       if (err)
+               goto error;
 #ifdef HAVE_MLX5DV_DR_ACTION_DEST_DEVX_TIR
        config->dest_tir = 1;
 #endif
@@ -1049,8 +1072,6 @@ err_secondary:
                        mprq_caps.max_single_wqe_log_num_of_strides;
        }
 #endif
-       /* Rx CQE compression is enabled by default. */
-       config->cqe_comp = 1;
 #ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
        if (dv_attr.comp_mask & MLX5DV_CONTEXT_MASK_TUNNEL_OFFLOADS) {
                config->tunnel_en = dv_attr.tunnel_offloads_caps &
@@ -1239,11 +1260,6 @@ err_secondary:
                DRV_LOG(DEBUG, "dev_port-%u new domain_id=%u\n",
                        priv->dev_port, priv->domain_id);
        }
-       /* Override some values set by hardware configuration. */
-       mlx5_args(config, dpdk_dev->devargs);
-       err = mlx5_dev_check_sibling_config(priv, config, dpdk_dev);
-       if (err)
-               goto error;
        config->hw_csum = !!(sh->device_attr.device_cap_flags_ex &
                            IBV_DEVICE_RAW_IP_CSUM);
        DRV_LOG(DEBUG, "checksum offloading is %ssupported",
@@ -1251,12 +1267,6 @@ err_secondary:
 #if !defined(HAVE_IBV_DEVICE_COUNTERS_SET_V42) && \
        !defined(HAVE_IBV_DEVICE_COUNTERS_SET_V45)
        DRV_LOG(DEBUG, "counters are not supported");
-#endif
-#if !defined(HAVE_IBV_FLOW_DV_SUPPORT) || !defined(HAVE_MLX5DV_DR)
-       if (config->dv_flow_en) {
-               DRV_LOG(WARNING, "DV flow is not supported");
-               config->dv_flow_en = 0;
-       }
 #endif
        config->ind_table_max_size =
                sh->device_attr.max_rwq_indirection_table_size;
@@ -1652,13 +1662,6 @@ err_secondary:
         * Verbs context returned by ibv_open_device().
         */
        mlx5_link_update(eth_dev, 0);
-#ifdef HAVE_MLX5DV_DR_ESWITCH
-       if (!(config->hca_attr.eswitch_manager && config->dv_flow_en &&
-             (switch_info->representor || switch_info->master)))
-               config->dv_esw_en = 0;
-#else
-       config->dv_esw_en = 0;
-#endif
        /* Detect minimal data bytes to inline. */
        mlx5_set_min_inline(spawn, config);
        /* Store device configuration on private structure. */
@@ -1725,12 +1728,6 @@ err_secondary:
                err = -err;
                goto error;
        }
-       if (!priv->config.dv_esw_en &&
-           priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY) {
-               DRV_LOG(WARNING, "metadata mode %u is not supported "
-                                "(no E-Switch)", priv->config.dv_xmeta_en);
-               priv->config.dv_xmeta_en = MLX5_XMETA_MODE_LEGACY;
-       }
        mlx5_set_metadata_mask(eth_dev);
        if (priv->config.dv_xmeta_en != MLX5_XMETA_MODE_LEGACY &&
            !priv->sh->dv_regc0_mask) {
@@ -2042,6 +2039,7 @@ mlx5_os_config_default(struct mlx5_dev_config *config,
 {
        memset(config, 0, sizeof(*config));
        config->mps = MLX5_ARG_UNSET;
+       config->cqe_comp = 1;
        config->rx_vec_en = 1;
        config->txq_inline_max = MLX5_ARG_UNSET;
        config->txq_inline_min = MLX5_ARG_UNSET;