priv->ctx = ctx;
priv->dev_addr.pci_addr = pci_dev->addr;
priv->dev_addr.type = VDPA_ADDR_PCI;
+ priv->var = mlx5_glue->dv_alloc_var(ctx, 0);
+ if (!priv->var) {
+ DRV_LOG(ERR, "Failed to allocate VAR %u.\n", errno);
+ goto error;
+ }
priv->id = rte_vdpa_register_device(&priv->dev_addr, &mlx5_vdpa_ops);
if (priv->id < 0) {
DRV_LOG(ERR, "Failed to register vDPA device.");
return 0;
error:
- if (priv)
+ if (priv) {
+ if (priv->var)
+ mlx5_glue->dv_free_var(priv->var);
rte_free(priv);
+ }
if (ctx)
mlx5_glue->close_device(ctx);
return -rte_errno;
if (found) {
if (priv->configured)
mlx5_vdpa_dev_close(priv->vid);
+ if (priv->var) {
+ mlx5_glue->dv_free_var(priv->var);
+ priv->var = NULL;
+ }
mlx5_glue->close_device(priv->ctx);
rte_free(priv);
}
claim_zero(munmap(priv->virtq_db_addr, priv->var->length));
priv->virtq_db_addr = NULL;
}
- if (priv->var) {
- mlx5_glue->dv_free_var(priv->var);
- priv->var = NULL;
- }
priv->features = 0;
}
DRV_LOG(ERR, "Failed to configure negotiated features.");
return -1;
}
- priv->var = mlx5_glue->dv_alloc_var(priv->ctx, 0);
- if (!priv->var) {
- DRV_LOG(ERR, "Failed to allocate VAR %u.\n", errno);
- return -1;
- }
/* Always map the entire page. */
priv->virtq_db_addr = mmap(NULL, priv->var->length, PROT_READ |
PROT_WRITE, MAP_SHARED, priv->ctx->cmd_fd,