Skip to content

Commit

Permalink
vdpa/ifc: handle data path update failure
Browse files Browse the repository at this point in the history
[ upstream commit 903ec2b1b49e496815c016b0104fd655cd972661 ]

Stop and return the error code when update_datapath fails.
update_datapath prepares resources for the vdpa device.
The driver should not perform any further actions
if update_datapath returns an error.

Fixes: a3f8150 ("net/ifcvf: add ifcvf vDPA driver")

Signed-off-by: Taekyung Kim <kim.tae.kyung@navercorp.com>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Acked-by: Andy Pei <andy.pei@intel.com>
  • Loading branch information
tae-kyung-kim authored and cpaelzer committed Nov 24, 2022
1 parent ad41d00 commit b9dbbd4
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions drivers/net/ifc/ifcvf_vdpa.c
Expand Up @@ -893,7 +893,12 @@ ifcvf_dev_config(int vid)
internal = list->internal;
internal->vid = vid;
rte_atomic32_set(&internal->dev_attached, 1);
update_datapath(internal);
if (update_datapath(internal) < 0) {
DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
vdev->device->name);
rte_atomic32_set(&internal->dev_attached, 0);
return -1;
}

if (rte_vhost_host_notifier_ctrl(vid, true) != 0)
DRV_LOG(NOTICE, "vDPA (%d): software relay is used.", did);
Expand Down Expand Up @@ -933,7 +938,12 @@ ifcvf_dev_close(int vid)
internal->sw_fallback_running = false;
} else {
rte_atomic32_set(&internal->dev_attached, 0);
update_datapath(internal);
if (update_datapath(internal) < 0) {
DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
vdev->device->name);
internal->configured = 0;
return -1;
}
}

return 0;
Expand Down Expand Up @@ -1202,7 +1212,15 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
pthread_mutex_unlock(&internal_list_lock);

rte_atomic32_set(&internal->started, 1);
update_datapath(internal);
if (update_datapath(internal) < 0) {
DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
rte_atomic32_set(&internal->started, 0);
rte_vdpa_unregister_device(internal->vdev);
pthread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
pthread_mutex_unlock(&internal_list_lock);
goto error;
}

rte_kvargs_free(kvlist);
return 0;
Expand Down Expand Up @@ -1231,7 +1249,8 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)

internal = list->internal;
rte_atomic32_set(&internal->started, 0);
update_datapath(internal);
if (update_datapath(internal) < 0)
DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);

rte_pci_unmap_device(internal->pdev);
rte_vfio_container_destroy(internal->vfio_container_fd);
Expand Down

0 comments on commit b9dbbd4

Please sign in to comment.