DRV_LOG(ERR, "Invalid vDPA device: %s.", vdev->device->name);
return -1;
}
- if (priv->configured)
- ret |= mlx5_vdpa_lm_log(priv);
mlx5_vdpa_err_event_unset(priv);
mlx5_vdpa_cqe_event_unset(priv);
+ if (priv->configured)
+ ret |= mlx5_vdpa_lm_log(priv);
mlx5_vdpa_steer_unset(priv);
mlx5_vdpa_virtqs_release(priv);
mlx5_vdpa_event_qp_global_release(priv);
unsigned long tmp;
int n_cores = sysconf(_SC_NPROCESSORS_ONLN);
- if (strcmp(key, RTE_DEVARGS_KEY_CLASS) == 0)
- return 0;
errno = 0;
tmp = strtoul(val, NULL, 0);
if (errno) {
priv->hw_max_latency_us = (uint32_t)tmp;
} else if (strcmp(key, "hw_max_pending_comp") == 0) {
priv->hw_max_pending_comp = (uint32_t)tmp;
- } else {
- DRV_LOG(WARNING, "Invalid key %s.", key);
}
return 0;
}
static void
-mlx5_vdpa_config_get(struct rte_devargs *devargs, struct mlx5_vdpa_priv *priv)
+mlx5_vdpa_config_get(struct mlx5_kvargs_ctrl *mkvlist,
+ struct mlx5_vdpa_priv *priv)
{
- struct rte_kvargs *kvlist;
+ const char **params = (const char *[]){
+ "event_core",
+ "event_mode",
+ "event_us",
+ "hw_latency_mode",
+ "hw_max_latency_us",
+ "hw_max_pending_comp",
+ "no_traffic_time",
+ NULL,
+ };
priv->event_mode = MLX5_VDPA_EVENT_MODE_FIXED_TIMER;
priv->event_us = 0;
priv->event_core = -1;
priv->no_traffic_max = MLX5_VDPA_DEFAULT_NO_TRAFFIC_MAX;
- if (devargs == NULL)
- return;
- kvlist = rte_kvargs_parse(devargs->args, NULL);
- if (kvlist == NULL)
+ if (mkvlist == NULL)
return;
- rte_kvargs_process(kvlist, NULL, mlx5_vdpa_args_check_handler, priv);
- rte_kvargs_free(kvlist);
+ mlx5_kvargs_process(mkvlist, params, mlx5_vdpa_args_check_handler,
+ priv);
if (!priv->event_us &&
priv->event_mode == MLX5_VDPA_EVENT_MODE_DYNAMIC_TIMER)
priv->event_us = MLX5_VDPA_DEFAULT_TIMER_STEP_US;
}
static int
-mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev)
+mlx5_vdpa_dev_probe(struct mlx5_common_device *cdev,
+ struct mlx5_kvargs_ctrl *mkvlist)
{
struct mlx5_vdpa_priv *priv = NULL;
- struct mlx5_hca_attr attr;
- int ret;
+ struct mlx5_hca_attr *attr = &cdev->config.hca_attr;
+ int retry;
- ret = mlx5_devx_cmd_query_hca_attr(cdev->ctx, &attr);
- if (ret) {
- DRV_LOG(ERR, "Unable to read HCA capabilities.");
- rte_errno = ENOTSUP;
- return -rte_errno;
- } else if (!attr.vdpa.valid || !attr.vdpa.max_num_virtio_queues) {
+ if (!attr->vdpa.valid || !attr->vdpa.max_num_virtio_queues) {
DRV_LOG(ERR, "Not enough capabilities to support vdpa, maybe "
"old FW/OFED version?");
rte_errno = ENOTSUP;
return -rte_errno;
}
- if (!attr.vdpa.queue_counters_valid)
+ if (!attr->vdpa.queue_counters_valid)
DRV_LOG(DEBUG, "No capability to support virtq statistics.");
priv = rte_zmalloc("mlx5 vDPA device private", sizeof(*priv) +
sizeof(struct mlx5_vdpa_virtq) *
- attr.vdpa.max_num_virtio_queues * 2,
+ attr->vdpa.max_num_virtio_queues * 2,
RTE_CACHE_LINE_SIZE);
if (!priv) {
DRV_LOG(ERR, "Failed to allocate private memory.");
rte_errno = ENOMEM;
return -rte_errno;
}
- priv->caps = attr.vdpa;
- priv->log_max_rqt_size = attr.log_max_rqt_size;
- priv->num_lag_ports = attr.num_lag_ports;
- priv->qp_ts_format = attr.qp_ts_format;
- if (attr.num_lag_ports == 0)
+ priv->caps = attr->vdpa;
+ priv->log_max_rqt_size = attr->log_max_rqt_size;
+ priv->num_lag_ports = attr->num_lag_ports;
+ if (attr->num_lag_ports == 0)
priv->num_lag_ports = 1;
priv->cdev = cdev;
- priv->var = mlx5_glue->dv_alloc_var(priv->cdev->ctx, 0);
+ for (retry = 0; retry < 7; retry++) {
+ priv->var = mlx5_glue->dv_alloc_var(priv->cdev->ctx, 0);
+ if (priv->var != NULL)
+ break;
+ DRV_LOG(WARNING, "Failed to allocate VAR, retry %d.\n", retry);
+ /* Wait Qemu release VAR during vdpa restart, 0.1 sec based. */
+ usleep(100000U << retry);
+ }
if (!priv->var) {
DRV_LOG(ERR, "Failed to allocate VAR %u.", errno);
goto error;
}
+ priv->err_intr_handle =
+ rte_intr_instance_alloc(RTE_INTR_INSTANCE_F_SHARED);
+ if (priv->err_intr_handle == NULL) {
+ DRV_LOG(ERR, "Fail to allocate intr_handle");
+ goto error;
+ }
priv->vdev = rte_vdpa_register_device(cdev->dev, &mlx5_vdpa_ops);
if (priv->vdev == NULL) {
DRV_LOG(ERR, "Failed to register vDPA device.");
rte_errno = rte_errno ? rte_errno : EINVAL;
goto error;
}
- mlx5_vdpa_config_get(cdev->dev->devargs, priv);
+ mlx5_vdpa_config_get(mkvlist, priv);
SLIST_INIT(&priv->mr_list);
pthread_mutex_init(&priv->vq_config_lock, NULL);
pthread_mutex_lock(&priv_list_lock);
if (priv) {
if (priv->var)
mlx5_glue->dv_free_var(priv->var);
+ rte_intr_instance_free(priv->err_intr_handle);
rte_free(priv);
}
return -rte_errno;
if (priv->vdev)
rte_vdpa_unregister_device(priv->vdev);
pthread_mutex_destroy(&priv->vq_config_lock);
+ rte_intr_instance_free(priv->err_intr_handle);
rte_free(priv);
}
return 0;