Skip to content

Commit

Permalink
net/virtio: fix initialization to return negative errno
Browse files Browse the repository at this point in the history
[ upstream commit 55e19d06f8a8a865297532071453c10544a07a24 ]

virtio_init_device() and called helper functions sometimes return -1
when return code should be negative errno. Fix all such cases to return
correct negative errno instead.

Fixes: 26b683b ("net/virtio: setup Rx queue interrupts")
Fixes: 0c9d662 ("net/virtio: support RSS")
Fixes: 6ba1f63 ("virtio: support specification 1.0")
Fixes: 49d26d9 ("net/virtio: support MTU feature")

Signed-off-by: Boleslav Stankevich <boleslav.stankevich@oktetlabs.ru>
Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
  • Loading branch information
ol-bstankevich authored and bluca committed Jun 15, 2023
1 parent bdc6b54 commit 08faea9
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions drivers/net/virtio/virtio_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -1695,15 +1695,17 @@ static int
virtio_configure_intr(struct rte_eth_dev *dev)
{
struct virtio_hw *hw = dev->data->dev_private;
int ret;

if (!rte_intr_cap_multiple(dev->intr_handle)) {
PMD_INIT_LOG(ERR, "Multiple intr vector not supported");
return -ENOTSUP;
}

if (rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues)) {
ret = rte_intr_efd_enable(dev->intr_handle, dev->data->nb_rx_queues);
if (ret < 0) {
PMD_INIT_LOG(ERR, "Fail to create eventfd");
return -1;
return ret;
}

if (!dev->intr_handle->intr_vec) {
Expand Down Expand Up @@ -1735,12 +1737,13 @@ virtio_configure_intr(struct rte_eth_dev *dev)
*/
if (virtio_intr_enable(dev) < 0) {
PMD_DRV_LOG(ERR, "interrupt enable failed");
return -1;
return -EINVAL;
}

if (virtio_queues_bind_intr(dev) < 0) {
ret = virtio_queues_bind_intr(dev);
if (ret < 0) {
PMD_INIT_LOG(ERR, "Failed to bind queue/interrupt");
return -1;
return ret;
}

return 0;
Expand Down Expand Up @@ -1796,7 +1799,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
/* Tell the host we've known how to drive the device. */
vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
if (virtio_negotiate_features(hw, req_features) < 0)
return -1;
return -EINVAL;

hw->weak_barriers = !vtpci_with_feature(hw, VIRTIO_F_ORDER_PLATFORM);

Expand Down Expand Up @@ -1881,7 +1884,7 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
if (config->mtu < RTE_ETHER_MIN_MTU) {
PMD_INIT_LOG(ERR, "invalid max MTU value (%u)",
config->mtu);
return -1;
return -EINVAL;
}

hw->max_mtu = config->mtu;
Expand Down Expand Up @@ -1913,10 +1916,11 @@ virtio_init_device(struct rte_eth_dev *eth_dev, uint64_t req_features)
return ret;

if (eth_dev->data->dev_conf.intr_conf.rxq) {
if (virtio_configure_intr(eth_dev) < 0) {
ret = virtio_configure_intr(eth_dev);
if (ret < 0) {
PMD_INIT_LOG(ERR, "failed to configure interrupt");
virtio_free_queues(hw);
return -1;
return ret;
}
}

Expand Down

0 comments on commit 08faea9

Please sign in to comment.