common/mlx5: move basic probing functions to common
[dpdk.git] / drivers / net / mlx5 / mlx5.c
index 122d4c9..8b7629b 100644 (file)
@@ -953,6 +953,36 @@ mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev)
        prf->obj = NULL;
 }
 
+uint32_t
+mlx5_get_supported_sw_parsing_offloads(const struct mlx5_hca_attr *attr)
+{
+       uint32_t sw_parsing_offloads = 0;
+
+       if (attr->swp) {
+               sw_parsing_offloads |= MLX5_SW_PARSING_CAP;
+               if (attr->swp_csum)
+                       sw_parsing_offloads |= MLX5_SW_PARSING_CSUM_CAP;
+
+               if (attr->swp_lso)
+                       sw_parsing_offloads |= MLX5_SW_PARSING_TSO_CAP;
+       }
+       return sw_parsing_offloads;
+}
+
+uint32_t
+mlx5_get_supported_tunneling_offloads(const struct mlx5_hca_attr *attr)
+{
+       uint32_t tn_offloads = 0;
+
+       if (attr->tunnel_stateless_vxlan)
+               tn_offloads |= MLX5_TUNNELED_OFFLOADS_VXLAN_CAP;
+       if (attr->tunnel_stateless_gre)
+               tn_offloads |= MLX5_TUNNELED_OFFLOADS_GRE_CAP;
+       if (attr->tunnel_stateless_geneve_rx)
+               tn_offloads |= MLX5_TUNNELED_OFFLOADS_GENEVE_CAP;
+       return tn_offloads;
+}
+
 /*
  * Allocate Rx and Tx UARs in robust fashion.
  * This routine handles the following UAR allocation issues:
@@ -968,7 +998,7 @@ mlx5_flex_parser_ecpri_release(struct rte_eth_dev *dev)
  */
 static int
 mlx5_alloc_rxtx_uars(struct mlx5_dev_ctx_shared *sh,
-                    const struct mlx5_dev_config *config)
+                    const struct mlx5_common_dev_config *config)
 {
        uint32_t uar_mapping, retry;
        int err = 0;
@@ -1210,7 +1240,7 @@ mlx5_dev_ctx_shared_mempool_subscribe(struct rte_eth_dev *dev)
        int ret;
 
        /* Check if we only need to track Rx mempool destruction. */
-       if (!priv->config.mr_mempool_reg_en) {
+       if (!sh->cdev->config.mr_mempool_reg_en) {
                ret = rte_mempool_event_callback_register
                                (mlx5_dev_ctx_shared_rx_mempool_event_cb, sh);
                return ret == 0 || rte_errno == EEXIST ? 0 : ret;
@@ -1262,7 +1292,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
        /* Search for IB context by device name. */
        LIST_FOREACH(sh, &mlx5_dev_ctx_list, next) {
                if (!strcmp(sh->ibdev_name,
-                       mlx5_os_get_dev_device_name(spawn->phys_dev))) {
+                       mlx5_os_get_ctx_device_name(spawn->ctx))) {
                        sh->refcnt++;
                        goto exit;
                }
@@ -1279,12 +1309,13 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
                rte_errno  = ENOMEM;
                goto exit;
        }
-       sh->numa_node = spawn->numa_node;
+       pthread_mutex_init(&sh->txpp.mutex, NULL);
+       sh->numa_node = spawn->cdev->dev->numa_node;
+       sh->cdev = spawn->cdev;
+       sh->devx = sh->cdev->config.devx;
+       sh->ctx = spawn->ctx;
        if (spawn->bond_info)
                sh->bond = *spawn->bond_info;
-       err = mlx5_os_open_device(spawn, config, sh);
-       if (!sh->ctx)
-               goto error;
        err = mlx5_os_get_dev_attr(sh->ctx, &sh->device_attr);
        if (err) {
                DRV_LOG(DEBUG, "mlx5_os_get_dev_attr() failed");
@@ -1331,7 +1362,7 @@ mlx5_alloc_shared_dev_ctx(const struct mlx5_dev_spawn_data *spawn,
                        err = ENOMEM;
                        goto error;
                }
-               err = mlx5_alloc_rxtx_uars(sh, config);
+               err = mlx5_alloc_rxtx_uars(sh, &sh->cdev->config);
                if (err)
                        goto error;
                MLX5_ASSERT(sh->tx_uar);
@@ -2004,7 +2035,10 @@ 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_DRIVER_KEY, key) || !strcmp(MLX5_REPRESENTOR, key))
+       if (!strcmp(MLX5_DRIVER_KEY, key) || !strcmp(MLX5_REPRESENTOR, key) ||
+           !strcmp(MLX5_SYS_MEM_EN, key) || !strcmp(MLX5_TX_DB_NC, key) ||
+           !strcmp(MLX5_MR_MEMPOOL_REG_EN, key) ||
+           !strcmp(MLX5_MR_EXT_MEMSEG_EN, key))
                return 0;
        errno = 0;
        tmp = strtol(val, NULL, 0);
@@ -2057,16 +2091,6 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
                DRV_LOG(WARNING, "%s: deprecated parameter, ignored", key);
        } else if (strcmp(MLX5_TXQ_MPW_EN, key) == 0) {
                config->mps = !!tmp;
-       } else if (strcmp(MLX5_TX_DB_NC, key) == 0) {
-               if (tmp != MLX5_TXDB_CACHED &&
-                   tmp != MLX5_TXDB_NCACHED &&
-                   tmp != MLX5_TXDB_HEURISTIC) {
-                       DRV_LOG(ERR, "invalid Tx doorbell "
-                                    "mapping parameter");
-                       rte_errno = EINVAL;
-                       return -rte_errno;
-               }
-               config->dbnc = tmp;
        } else if (strcmp(MLX5_TXQ_MPW_HDR_DSEG_EN, key) == 0) {
                DRV_LOG(WARNING, "%s: deprecated parameter, ignored", key);
        } else if (strcmp(MLX5_TXQ_MAX_INLINE_LEN, key) == 0) {
@@ -2110,8 +2134,6 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
                        config->dv_miss_info = 1;
        } else if (strcmp(MLX5_LACP_BY_USER, key) == 0) {
                config->lacp_by_user = !!tmp;
-       } else if (strcmp(MLX5_MR_EXT_MEMSEG_EN, key) == 0) {
-               config->mr_ext_memseg_en = !!tmp;
        } else if (strcmp(MLX5_MAX_DUMP_FILES_NUM, key) == 0) {
                config->max_dump_files_num = tmp;
        } else if (strcmp(MLX5_LRO_TIMEOUT_USEC, key) == 0) {
@@ -2129,14 +2151,10 @@ mlx5_args_check(const char *key, const char *val, void *opaque)
                        return -rte_errno;
                }
                config->reclaim_mode = tmp;
-       } else if (strcmp(MLX5_SYS_MEM_EN, key) == 0) {
-               config->sys_mem_en = !!tmp;
        } else if (strcmp(MLX5_DECAP_EN, key) == 0) {
                config->decap_en = !!tmp;
        } else if (strcmp(MLX5_ALLOW_DUPLICATE_PATTERN, key) == 0) {
                config->allow_duplicate_pattern = !!tmp;
-       } else if (strcmp(MLX5_MR_MEMPOOL_REG_EN, key) == 0) {
-               config->mr_mempool_reg_en = !!tmp;
        } else {
                DRV_LOG(WARNING, "%s: unknown parameter", key);
                rte_errno = EINVAL;
@@ -2526,19 +2544,19 @@ mlx5_eth_find_next(uint16_t port_id, struct rte_device *odev)
  *
  * This function removes all Ethernet devices belong to a given device.
  *
- * @param[in] dev
+ * @param[in] cdev
  *   Pointer to the generic device.
  *
  * @return
  *   0 on success, the function cannot fail.
  */
 int
-mlx5_net_remove(struct rte_device *dev)
+mlx5_net_remove(struct mlx5_common_device *cdev)
 {
        uint16_t port_id;
        int ret = 0;
 
-       RTE_ETH_FOREACH_DEV_OF(port_id, dev) {
+       RTE_ETH_FOREACH_DEV_OF(port_id, cdev->dev) {
                /*
                 * mlx5_dev_close() is not registered to secondary process,
                 * call the close function explicitly for secondary process.