net/virtio-user: fix status management
[dpdk.git] / drivers / net / virtio / virtio_user_ethdev.c
index 798f191..6003f6d 100644 (file)
@@ -68,6 +68,7 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
        int connectfd;
        struct rte_eth_dev *eth_dev = &rte_eth_devices[dev->port_id];
        struct virtio_hw *hw = eth_dev->data->dev_private;
+       uint64_t protocol_features;
 
        connectfd = accept(dev->listenfd, NULL, NULL);
        if (connectfd < 0)
@@ -81,6 +82,25 @@ virtio_user_server_reconnect(struct virtio_user_dev *dev)
                return -1;
        }
 
+       if (dev->device_features &
+                       (1ULL << VHOST_USER_F_PROTOCOL_FEATURES)) {
+               if (dev->ops->send_request(dev,
+                                       VHOST_USER_GET_PROTOCOL_FEATURES,
+                                       &protocol_features))
+                       return -1;
+
+               dev->protocol_features &= protocol_features;
+
+               if (dev->ops->send_request(dev,
+                                       VHOST_USER_SET_PROTOCOL_FEATURES,
+                                       &dev->protocol_features))
+                       return -1;
+
+               if (!(dev->protocol_features &
+                               (1ULL << VHOST_USER_PROTOCOL_F_MQ)))
+                       dev->unsupported_features |= (1ull << VIRTIO_NET_F_MQ);
+       }
+
        dev->device_features |= dev->frontend_features;
 
        /* umask vhost-user unsupported features */
@@ -185,7 +205,7 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,
                        }
                        r = recv(dev->vhostfd, buf, 128, MSG_PEEK);
                        if (r == 0 || (r < 0 && errno != EAGAIN)) {
-                               dev->status &= (~VIRTIO_NET_S_LINK_UP);
+                               dev->net_status &= (~VIRTIO_NET_S_LINK_UP);
                                PMD_DRV_LOG(ERR, "virtio-user port %u is down",
                                            hw->port_id);
 
@@ -197,7 +217,7 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,
                                                  virtio_user_delayed_handler,
                                                  (void *)hw);
                        } else {
-                               dev->status |= VIRTIO_NET_S_LINK_UP;
+                               dev->net_status |= VIRTIO_NET_S_LINK_UP;
                        }
                        if (fcntl(dev->vhostfd, F_SETFL,
                                        flags & ~O_NONBLOCK) == -1) {
@@ -205,12 +225,12 @@ virtio_user_read_dev_config(struct virtio_hw *hw, size_t offset,
                                return;
                        }
                } else if (dev->is_server) {
-                       dev->status &= (~VIRTIO_NET_S_LINK_UP);
+                       dev->net_status &= (~VIRTIO_NET_S_LINK_UP);
                        if (virtio_user_server_reconnect(dev) >= 0)
-                               dev->status |= VIRTIO_NET_S_LINK_UP;
+                               dev->net_status |= VIRTIO_NET_S_LINK_UP;
                }
 
-               *(uint16_t *)dst = dev->status;
+               *(uint16_t *)dst = dev->net_status;
        }
 
        if (offset == offsetof(struct virtio_net_config, max_virtqueue_pairs))