Re: [PATCH 3/5] net/virtio-user: support to report net status
From: Yuanhan Liu <hidden>
Date: 2017-03-29 07:16:39
On Wed, Mar 29, 2017 at 03:07:28PM +0800, Tan, Jianfeng wrote:
On 3/29/2017 2:33 PM, Yuanhan Liu wrote:quoted
On Mon, Mar 27, 2017 at 07:46:32AM +0000, Tan, Jianfeng wrote:quoted
quoted
quoted
diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.cb/drivers/net/virtio/virtio_user/virtio_user_dev.cquoted
index 9777d6b..cc6f557 100644--- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c@@ -176,6 +176,7 @@ virtio_user_start_device(struct virtio_user_dev*dev, uint8_t portid)quoted
features &= ~(1ull << VIRTIO_NET_F_MAC); /* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need toknow */quoted
features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ); + features &= ~(1ull << VIRTIO_NET_F_STATUS); ret = dev->ops->send_request(dev, VHOST_USER_SET_FEATURES,&features);quoted
if (ret < 0) goto error;diff --git a/drivers/net/virtio/virtio_user_ethdev.cb/drivers/net/virtio/virtio_user_ethdev.cquoted
index fa79419..fbdd0a8 100644--- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c@@ -121,7 +121,8 @@ virtio_user_get_features(struct virtio_hw *hw) struct virtio_user_dev *dev = virtio_user_get_dev(hw); /* unmask feature bits defined in vhost user protocol */ - return dev->device_features &VIRTIO_PMD_SUPPORTED_GUEST_FEATURES;quoted
+ return (dev->device_features | (1 << VIRTIO_NET_F_STATUS)) + & VIRTIO_PMD_SUPPORTED_GUEST_FEATURES;Why not handle the features at virtio_user_dev_init()?You mean add VIRTIO_NET_F_STATUS when get_features from device? Yes, we could do that there. But we originally add device_features to only record features supported by device.Aren't you adding the F_STATUS features to this device?For virtio driver, yes, we are adding F_STATUS feature so the it sees a device supporting LSC.
That means you are adding a device feature (F_STATUS) and reporting it to the driver that this feature is always on, no matter whether the device actually supports it or not? This looks wrong to me.
But for backend driver, we need hide this feature, it happens when we set_features to the backend driver.
The feature negotion of virtio-user seems broken to me. --yliu