net/virtio: remove duplicated port ID from virtio-user
authorDavid Marchand <david.marchand@redhat.com>
Mon, 1 Feb 2021 17:46:01 +0000 (18:46 +0100)
committerChenbo Xia <chenbo.xia@intel.com>
Wed, 31 Mar 2021 08:30:17 +0000 (10:30 +0200)
The private virtio_user_dev structure embeds a virtio_hw which itself
contains the ethdev port_id.
Make use of it and remove the duplicate port_id field.

Signed-off-by: David Marchand <david.marchand@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_user/vhost_user.c
drivers/net/virtio/virtio_user/virtio_user_dev.c
drivers/net/virtio/virtio_user/virtio_user_dev.h
drivers/net/virtio/virtio_user_ethdev.c

index f8569f6..bc56d60 100644 (file)
@@ -951,7 +951,7 @@ vhost_user_update_link_state(struct virtio_user_dev *dev)
                r = recv(data->vhostfd, buf, 128, MSG_PEEK);
                if (r == 0 || (r < 0 && errno != EAGAIN)) {
                        dev->net_status &= (~VIRTIO_NET_S_LINK_UP);
-                       PMD_DRV_LOG(ERR, "virtio-user port %u is down", dev->port_id);
+                       PMD_DRV_LOG(ERR, "virtio-user port %u is down", dev->hw.port_id);
 
                        /* This function could be called in the process
                         * of interrupt handling, callback cannot be
index 446837b..d077673 100644 (file)
@@ -340,7 +340,7 @@ static int
 virtio_user_fill_intr_handle(struct virtio_user_dev *dev)
 {
        uint32_t i;
-       struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
+       struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
 
        if (!eth_dev->intr_handle) {
                eth_dev->intr_handle = malloc(sizeof(*eth_dev->intr_handle));
@@ -888,7 +888,7 @@ void
 virtio_user_dev_delayed_handler(void *param)
 {
        struct virtio_user_dev *dev = param;
-       struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
+       struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
 
        if (rte_intr_disable(eth_dev->intr_handle) < 0) {
                PMD_DRV_LOG(ERR, "interrupt disable failed");
@@ -913,7 +913,7 @@ int
 virtio_user_dev_server_reconnect(struct virtio_user_dev *dev)
 {
        int ret, old_status;
-       struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
+       struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->hw.port_id];
        struct virtio_hw *hw = &dev->hw;
 
        if (!dev->ops->server_reconnect) {
index 8a62f7e..7fd4622 100644 (file)
@@ -43,7 +43,6 @@ struct virtio_user_dev {
        uint64_t        unsupported_features; /* unsupported features mask */
        uint8_t         status;
        uint16_t        net_status;
-       uint16_t        port_id;
        uint8_t         mac_addr[RTE_ETHER_ADDR_LEN];
        char            path[PATH_MAX];
        char            *ifname;
index 9314ca5..79bd31e 100644 (file)
@@ -428,7 +428,6 @@ virtio_user_eth_dev_alloc(struct rte_vdev_device *vdev)
        hw = &dev->hw;
 
        hw->port_id = data->port_id;
-       dev->port_id = data->port_id;
        VIRTIO_OPS(hw) = &virtio_user_ops;
 
        hw->intr_lsc = 1;