net/virtio_user: fix wrong sequence of messages
authorJianfeng Tan <jianfeng.tan@intel.com>
Tue, 27 Sep 2016 19:11:05 +0000 (19:11 +0000)
committerYuanhan Liu <yuanhan.liu@linux.intel.com>
Wed, 28 Sep 2016 00:18:39 +0000 (02:18 +0200)
commit57ae79a75b8ade1ea4624789caf5dc55a3a95c98
tree1133af24022dcc0ba03a289adcc52dd9afbd27af
parent33a290899dd2b6e2e26e8e5c33d08979f8315d18
net/virtio_user: fix wrong sequence of messages

When virtio_user is used with VPP's native vhost user, it cannot
send/receive any packets.

The root cause is that vpp-vhost-user translates the message
VHOST_USER_SET_FEATURES as puting this device into init state,
aka, zero all related structures. However, previous code
puts this message at last in the whole initialization process,
which leads to all previous information are zeroed.

To fix this issue, we rearrange the sequence of those messages.
  - step 0, send VHOST_USER_SET_VRING_CALL so that vhost allocates
    virtqueue structures;
  - step 1, send VHOST_USER_SET_FEATURES to confirm the features;
  - step 2, send VHOST_USER_SET_MEM_TABLE to share mem regions;
  - step 3, send VHOST_USER_SET_VRING_NUM, VHOST_USER_SET_VRING_BASE,
    VHOST_USER_SET_VRING_ADDR, VHOST_USER_SET_VRING_KICK for each
    queue;
  - ...

Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer")

Reported-by: Zhihong Wang <zhihong.wang@intel.com>
Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
Acked-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
drivers/net/virtio/virtio_user/virtio_user_dev.c