From: Jianfeng Tan Date: Thu, 13 Apr 2017 10:11:27 +0000 (+0000) Subject: net/virtio-user: fix feature negotiation X-Git-Tag: spdx-start~3504 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=bed3b24c87cb7fb63d24d16d65b911fe14525d82;p=dpdk.git net/virtio-user: fix feature negotiation The feature negotiation in virtio-user is proven to be broken, which results in device initialization failure. Originally, we get features from vhost backend, and remove those that are not supported. But when new feature is added, for example, VIRTIO_NET_F_MTU, we fail to remove this new feature. Then, this new feature will be negotiated, as both frontend and backend claim to support this feature. To fix it, we add a macro to record supported features, as a filter to remove newly added features. Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer") Signed-off-by: Jianfeng Tan Acked-by: Yuanhan Liu --- diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 6871cd4b1a..299ee16355 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -311,6 +311,25 @@ virtio_user_dev_setup(struct virtio_user_dev *dev) return dev->ops->setup(dev); } +/* Use below macro to filter features from vhost backend */ +#define VIRTIO_USER_SUPPORTED_FEATURES \ + (1ULL << VIRTIO_NET_F_MAC | \ + 1ULL << VIRTIO_NET_F_STATUS | \ + 1ULL << VIRTIO_NET_F_MQ | \ + 1ULL << VIRTIO_NET_F_CTRL_MAC_ADDR | \ + 1ULL << VIRTIO_NET_F_CTRL_VQ | \ + 1ULL << VIRTIO_NET_F_CTRL_RX | \ + 1ULL << VIRTIO_NET_F_CTRL_VLAN | \ + 1ULL << VIRTIO_NET_F_CSUM | \ + 1ULL << VIRTIO_NET_F_HOST_TSO4 | \ + 1ULL << VIRTIO_NET_F_HOST_TSO6 | \ + 1ULL << VIRTIO_NET_F_MRG_RXBUF | \ + 1ULL << VIRTIO_RING_F_INDIRECT_DESC | \ + 1ULL << VIRTIO_NET_F_GUEST_CSUM | \ + 1ULL << VIRTIO_NET_F_GUEST_TSO4 | \ + 1ULL << VIRTIO_NET_F_GUEST_TSO6 | \ + 1ULL << VIRTIO_F_VERSION_1) + int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, int cq, int queue_size, const char *mac, char **ifname) @@ -362,6 +381,8 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, /* The backend will not report this feature, we add it explicitly */ dev->device_features |= (1ull << VIRTIO_NET_F_STATUS); + dev->device_features &= VIRTIO_USER_SUPPORTED_FEATURES; + return 0; }