* [dpdk-stable] [PATCH v3 1/7] net/virtio_user: fix wrongly set features [not found] ` <1483502366-140154-1-git-send-email-jianfeng.tan@intel.com> @ 2017-01-04 3:59 ` Jianfeng Tan 2017-01-04 3:59 ` [dpdk-stable] [PATCH v3 2/7] net/virtio_user: fix not properly reset device Jianfeng Tan 1 sibling, 0 replies; 5+ messages in thread From: Jianfeng Tan @ 2017-01-04 3:59 UTC (permalink / raw) To: dev; +Cc: yuanhan.liu, ferruh.yigit, cunming.liang, Jianfeng Tan, stable Before the commit 86d59b21468a ("net/virtio: support LRO"), features in virtio PMD, is decided and properly set at device initialization and will not be changed. But afterward, features could be changed in virtio_dev_configure(), and will be re-negotiated if it's changed. In virtio_user, device features is obtained at driver probe phase only once, but we did not store it. So the added feature bits in re-negotiation will fail. To fix it, we store it down, and will be used to feature negotiation either at device initialization phase or device configure phase. Fixes: e9efa4d93821 ("net/virtio-user: add new virtual PCI driver") CC: stable@dpdk.org Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 34 +++++++++++------------- drivers/net/virtio/virtio_user/virtio_user_dev.h | 5 +++- drivers/net/virtio/virtio_user_ethdev.c | 4 +-- 3 files changed, 22 insertions(+), 21 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index e239e0e..0d7e17b 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -148,12 +148,13 @@ virtio_user_start_device(struct virtio_user_dev *dev) /* Step 1: set features * Make sure VHOST_USER_F_PROTOCOL_FEATURES is added if mq is enabled, - * and VIRTIO_NET_F_MAC is stripped. + * VIRTIO_NET_F_MAC and VIRTIO_NET_F_CTRL_VQ is stripped. */ features = dev->features; if (dev->max_queue_pairs > 1) features |= VHOST_USER_MQ; features &= ~(1ull << VIRTIO_NET_F_MAC); + features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ); ret = vhost_user_sock(dev->vhostfd, VHOST_USER_SET_FEATURES, &features); if (ret < 0) goto error; @@ -228,29 +229,26 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, } if (vhost_user_sock(dev->vhostfd, VHOST_USER_GET_FEATURES, - &dev->features) < 0) { + &dev->device_features) < 0) { PMD_INIT_LOG(ERR, "get_features failed: %s", strerror(errno)); return -1; } if (dev->mac_specified) - dev->features |= (1ull << VIRTIO_NET_F_MAC); + dev->device_features |= (1ull << VIRTIO_NET_F_MAC); - if (!cq) { - dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ); - /* Also disable features depends on VIRTIO_NET_F_CTRL_VQ */ - dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_RX); - dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN); - dev->features &= ~(1ull << VIRTIO_NET_F_GUEST_ANNOUNCE); - dev->features &= ~(1ull << VIRTIO_NET_F_MQ); - dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR); - } else { - /* vhost user backend does not need to know ctrl-q, so - * actually we need add this bit into features. However, - * DPDK vhost-user does send features with this bit, so we - * check it instead of OR it for now. + if (cq) { + /* device does not really need to know anything about CQ, + * so if necessary, we just claim to support CQ */ - if (!(dev->features & (1ull << VIRTIO_NET_F_CTRL_VQ))) - PMD_INIT_LOG(INFO, "vhost does not support ctrl-q"); + dev->device_features |= (1ull << VIRTIO_NET_F_CTRL_VQ); + } else { + dev->device_features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ); + /* Also disable features depends on VIRTIO_NET_F_CTRL_VQ */ + dev->device_features &= ~(1ull << VIRTIO_NET_F_CTRL_RX); + dev->device_features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN); + dev->device_features &= ~(1ull << VIRTIO_NET_F_GUEST_ANNOUNCE); + dev->device_features &= ~(1ull << VIRTIO_NET_F_MQ); + dev->device_features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR); } if (dev->max_queue_pairs > 1) { diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h index 33690b5..28fc788 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h @@ -46,7 +46,10 @@ struct virtio_user_dev { uint32_t max_queue_pairs; uint32_t queue_pairs; uint32_t queue_size; - uint64_t features; + uint64_t features; /* the negotiated features with driver, + * and will be sync with device + */ + uint64_t device_features; /* supported features by device */ uint8_t status; uint8_t mac_addr[ETHER_ADDR_LEN]; char path[PATH_MAX]; diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 8cb983c..4a5a227 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -117,7 +117,7 @@ virtio_user_get_features(struct virtio_hw *hw) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - return dev->features; + return dev->device_features; } static void @@ -125,7 +125,7 @@ virtio_user_set_features(struct virtio_hw *hw, uint64_t features) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - dev->features = features; + dev->features = features & dev->device_features; } static uint8_t -- 2.7.4 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-stable] [PATCH v3 2/7] net/virtio_user: fix not properly reset device [not found] ` <1483502366-140154-1-git-send-email-jianfeng.tan@intel.com> 2017-01-04 3:59 ` [dpdk-stable] [PATCH v3 1/7] net/virtio_user: fix wrongly set features Jianfeng Tan @ 2017-01-04 3:59 ` Jianfeng Tan 2017-01-04 5:46 ` Yuanhan Liu 1 sibling, 1 reply; 5+ messages in thread From: Jianfeng Tan @ 2017-01-04 3:59 UTC (permalink / raw) To: dev; +Cc: yuanhan.liu, ferruh.yigit, cunming.liang, Jianfeng Tan, stable virtio_user is not properly reset when users call vtpci_reset(), as it ignores VIRTIO_CONFIG_STATUS_RESET status in virtio_user_set_status(). This might lead to initialization failure as it starts to re-init the device before sending RESET messege to backend. Besides, previous callfds and kickfds are not closed. To fix it, we add support to disable virtqueues when it's set to DRIVER OK status, and re-init fields in struct virtio_user_dev. Fixes: e9efa4d93821 ("net/virtio-user: add new virtual PCI driver") Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer") CC: stable@dpdk.org Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 26 ++++++++++++++++-------- drivers/net/virtio/virtio_user_ethdev.c | 15 ++++++++------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 0d7e17b..a38398b 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -182,7 +182,17 @@ virtio_user_start_device(struct virtio_user_dev *dev) int virtio_user_stop_device(struct virtio_user_dev *dev) { - return vhost_user_sock(dev->vhostfd, VHOST_USER_RESET_OWNER, NULL); + uint32_t i; + + for (i = 0; i < dev->max_queue_pairs * 2; ++i) { + close(dev->callfds[i]); + close(dev->kickfds[i]); + } + + for (i = 0; i < dev->max_queue_pairs; ++i) + vhost_user_enable_queue_pair(dev->vhostfd, i, 0); + + return 0; } static inline void @@ -210,6 +220,8 @@ int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, int cq, int queue_size, const char *mac) { + uint32_t i; + snprintf(dev->path, PATH_MAX, "%s", path); dev->max_queue_pairs = queues; dev->queue_pairs = 1; /* mq disabled by default */ @@ -218,6 +230,11 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, parse_mac(dev, mac); dev->vhostfd = -1; + for (i = 0; i < VIRTIO_MAX_VIRTQUEUES * 2 + 1; ++i) { + dev->kickfds[i] = -1; + dev->callfds[i] = -1; + } + dev->vhostfd = vhost_user_setup(dev->path); if (dev->vhostfd < 0) { PMD_INIT_LOG(ERR, "backend set up fails"); @@ -264,13 +281,6 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, void virtio_user_dev_uninit(struct virtio_user_dev *dev) { - uint32_t i; - - for (i = 0; i < dev->max_queue_pairs * 2; ++i) { - close(dev->callfds[i]); - close(dev->kickfds[i]); - } - close(dev->vhostfd); } diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 4a5a227..93f5b01 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -87,21 +87,24 @@ virtio_user_write_dev_config(struct virtio_hw *hw, size_t offset, } static void -virtio_user_set_status(struct virtio_hw *hw, uint8_t status) +virtio_user_reset(struct virtio_hw *hw) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) - virtio_user_start_device(dev); - dev->status = status; + if (dev->status & VIRTIO_CONFIG_STATUS_DRIVER_OK) + virtio_user_stop_device(dev); } static void -virtio_user_reset(struct virtio_hw *hw) +virtio_user_set_status(struct virtio_hw *hw, uint8_t status) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - virtio_user_stop_device(dev); + if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) + virtio_user_start_device(dev); + else if (status == VIRTIO_CONFIG_STATUS_RESET) + virtio_user_reset(hw); + dev->status = status; } static uint8_t -- 2.7.4 ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-stable] [PATCH v3 2/7] net/virtio_user: fix not properly reset device 2017-01-04 3:59 ` [dpdk-stable] [PATCH v3 2/7] net/virtio_user: fix not properly reset device Jianfeng Tan @ 2017-01-04 5:46 ` Yuanhan Liu 0 siblings, 0 replies; 5+ messages in thread From: Yuanhan Liu @ 2017-01-04 5:46 UTC (permalink / raw) To: Jianfeng Tan; +Cc: dev, ferruh.yigit, cunming.liang, stable On Wed, Jan 04, 2017 at 03:59:21AM +0000, Jianfeng Tan wrote: > virtio_user is not properly reset when users call vtpci_reset(), > as it ignores VIRTIO_CONFIG_STATUS_RESET status in > virtio_user_set_status(). > > This might lead to initialization failure as it starts to re-init > the device before sending RESET messege to backend. Besides, previous > callfds and kickfds are not closed. > > To fix it, we add support to disable virtqueues when it's set to > DRIVER OK status, and re-init fields in struct virtio_user_dev. > > Fixes: e9efa4d93821 ("net/virtio-user: add new virtual PCI driver") > Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer") > > CC: stable@dpdk.org > > Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> Note that, typically, there should be no empty line between 'Cc' and SoB. > --- > drivers/net/virtio/virtio_user/virtio_user_dev.c | 26 ++++++++++++++++-------- > drivers/net/virtio/virtio_user_ethdev.c | 15 ++++++++------ > 2 files changed, 27 insertions(+), 14 deletions(-) > > diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c > index 0d7e17b..a38398b 100644 > --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c > +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c > @@ -182,7 +182,17 @@ virtio_user_start_device(struct virtio_user_dev *dev) > > int virtio_user_stop_device(struct virtio_user_dev *dev) The name doesn't seem to be well named: "dev_stop" comes to my firstly when I saw that :/ Rename it to "xxx_reset_device"? --yliu ^ permalink raw reply [flat|nested] 5+ messages in thread
[parent not found: <1484309921-116526-1-git-send-email-jianfeng.tan@intel.com>]
* [dpdk-stable] [PATCH v4 1/8] net/virtio_user: fix wrongly get/set features [not found] ` <1484309921-116526-1-git-send-email-jianfeng.tan@intel.com> @ 2017-01-13 12:18 ` Jianfeng Tan 2017-01-13 12:18 ` [dpdk-stable] [PATCH v4 2/8] net/virtio_user: fix not properly reset device Jianfeng Tan 1 sibling, 0 replies; 5+ messages in thread From: Jianfeng Tan @ 2017-01-13 12:18 UTC (permalink / raw) To: dev; +Cc: yuanhan.liu, ferruh.yigit, cunming.liang, Jianfeng Tan, stable Before the commit 86d59b21468a ("net/virtio: support LRO"), features in virtio PMD, is decided and properly set at device initialization and will not be changed. But afterward, features could be changed in virtio_dev_configure(), and will be re-negotiated if it's changed. In virtio_user, device features is obtained at driver probe phase only once, but we did not store it. So the added feature bits in re-negotiation will fail. To fix it, we store it down, and will be used to feature negotiation either at device initialization phase or device configure phase. Fixes: e9efa4d93821 ("net/virtio-user: add new virtual PCI driver") CC: stable@dpdk.org Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> --- drivers/net/virtio/virtio_ethdev.h | 5 ++++ drivers/net/virtio/virtio_user/virtio_user_dev.c | 34 +++++++++++------------- drivers/net/virtio/virtio_user/virtio_user_dev.h | 5 +++- drivers/net/virtio/virtio_user_ethdev.c | 5 ++-- 4 files changed, 28 insertions(+), 21 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h index 27d9a19..4feccf9 100644 --- a/drivers/net/virtio/virtio_ethdev.h +++ b/drivers/net/virtio/virtio_ethdev.h @@ -70,6 +70,11 @@ 1ULL << VIRTIO_F_VERSION_1 | \ 1ULL << VIRTIO_F_IOMMU_PLATFORM) +#define VIRTIO_PMD_SUPPORTED_GUEST_FEATURES \ + (VIRTIO_PMD_DEFAULT_GUEST_FEATURES | \ + 1u << VIRTIO_NET_F_GUEST_CSUM | \ + 1u << VIRTIO_NET_F_GUEST_TSO4 | \ + 1u << VIRTIO_NET_F_GUEST_TSO6) /* * CQ function prototype */ diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index e239e0e..0d7e17b 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -148,12 +148,13 @@ virtio_user_start_device(struct virtio_user_dev *dev) /* Step 1: set features * Make sure VHOST_USER_F_PROTOCOL_FEATURES is added if mq is enabled, - * and VIRTIO_NET_F_MAC is stripped. + * VIRTIO_NET_F_MAC and VIRTIO_NET_F_CTRL_VQ is stripped. */ features = dev->features; if (dev->max_queue_pairs > 1) features |= VHOST_USER_MQ; features &= ~(1ull << VIRTIO_NET_F_MAC); + features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ); ret = vhost_user_sock(dev->vhostfd, VHOST_USER_SET_FEATURES, &features); if (ret < 0) goto error; @@ -228,29 +229,26 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, } if (vhost_user_sock(dev->vhostfd, VHOST_USER_GET_FEATURES, - &dev->features) < 0) { + &dev->device_features) < 0) { PMD_INIT_LOG(ERR, "get_features failed: %s", strerror(errno)); return -1; } if (dev->mac_specified) - dev->features |= (1ull << VIRTIO_NET_F_MAC); + dev->device_features |= (1ull << VIRTIO_NET_F_MAC); - if (!cq) { - dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ); - /* Also disable features depends on VIRTIO_NET_F_CTRL_VQ */ - dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_RX); - dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN); - dev->features &= ~(1ull << VIRTIO_NET_F_GUEST_ANNOUNCE); - dev->features &= ~(1ull << VIRTIO_NET_F_MQ); - dev->features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR); - } else { - /* vhost user backend does not need to know ctrl-q, so - * actually we need add this bit into features. However, - * DPDK vhost-user does send features with this bit, so we - * check it instead of OR it for now. + if (cq) { + /* device does not really need to know anything about CQ, + * so if necessary, we just claim to support CQ */ - if (!(dev->features & (1ull << VIRTIO_NET_F_CTRL_VQ))) - PMD_INIT_LOG(INFO, "vhost does not support ctrl-q"); + dev->device_features |= (1ull << VIRTIO_NET_F_CTRL_VQ); + } else { + dev->device_features &= ~(1ull << VIRTIO_NET_F_CTRL_VQ); + /* Also disable features depends on VIRTIO_NET_F_CTRL_VQ */ + dev->device_features &= ~(1ull << VIRTIO_NET_F_CTRL_RX); + dev->device_features &= ~(1ull << VIRTIO_NET_F_CTRL_VLAN); + dev->device_features &= ~(1ull << VIRTIO_NET_F_GUEST_ANNOUNCE); + dev->device_features &= ~(1ull << VIRTIO_NET_F_MQ); + dev->device_features &= ~(1ull << VIRTIO_NET_F_CTRL_MAC_ADDR); } if (dev->max_queue_pairs > 1) { diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h index 33690b5..28fc788 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h @@ -46,7 +46,10 @@ struct virtio_user_dev { uint32_t max_queue_pairs; uint32_t queue_pairs; uint32_t queue_size; - uint64_t features; + uint64_t features; /* the negotiated features with driver, + * and will be sync with device + */ + uint64_t device_features; /* supported features by device */ uint8_t status; uint8_t mac_addr[ETHER_ADDR_LEN]; char path[PATH_MAX]; diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 8cb983c..6c16d2d 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -117,7 +117,8 @@ virtio_user_get_features(struct virtio_hw *hw) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - return dev->features; + /* unmask feature bits defined in vhost user protocol */ + return dev->device_features & VIRTIO_PMD_SUPPORTED_GUEST_FEATURES; } static void @@ -125,7 +126,7 @@ virtio_user_set_features(struct virtio_hw *hw, uint64_t features) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - dev->features = features; + dev->features = features & dev->device_features; } static uint8_t -- 2.7.4 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-stable] [PATCH v4 2/8] net/virtio_user: fix not properly reset device [not found] ` <1484309921-116526-1-git-send-email-jianfeng.tan@intel.com> 2017-01-13 12:18 ` [dpdk-stable] [PATCH v4 1/8] net/virtio_user: fix wrongly get/set features Jianfeng Tan @ 2017-01-13 12:18 ` Jianfeng Tan 1 sibling, 0 replies; 5+ messages in thread From: Jianfeng Tan @ 2017-01-13 12:18 UTC (permalink / raw) To: dev; +Cc: yuanhan.liu, ferruh.yigit, cunming.liang, Jianfeng Tan, stable virtio_user is not properly reset when users call vtpci_reset(), as it ignores VIRTIO_CONFIG_STATUS_RESET status in virtio_user_set_status(). This might lead to initialization failure as it starts to re-init the device before sending RESET messege to backend. Besides, previous callfds and kickfds are not closed. To fix it, we add support to disable virtqueues when it's set to DRIVER OK status, and re-init fields in struct virtio_user_dev. Fixes: e9efa4d93821 ("net/virtio-user: add new virtual PCI driver") Fixes: 37a7eb2ae816 ("net/virtio-user: add device emulation layer") CC: stable@dpdk.org Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com> --- drivers/net/virtio/virtio_user/virtio_user_dev.c | 26 ++++++++++++++++-------- drivers/net/virtio/virtio_user_ethdev.c | 15 ++++++++------ 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c index 0d7e17b..a38398b 100644 --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c @@ -182,7 +182,17 @@ virtio_user_start_device(struct virtio_user_dev *dev) int virtio_user_stop_device(struct virtio_user_dev *dev) { - return vhost_user_sock(dev->vhostfd, VHOST_USER_RESET_OWNER, NULL); + uint32_t i; + + for (i = 0; i < dev->max_queue_pairs * 2; ++i) { + close(dev->callfds[i]); + close(dev->kickfds[i]); + } + + for (i = 0; i < dev->max_queue_pairs; ++i) + vhost_user_enable_queue_pair(dev->vhostfd, i, 0); + + return 0; } static inline void @@ -210,6 +220,8 @@ int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, int cq, int queue_size, const char *mac) { + uint32_t i; + snprintf(dev->path, PATH_MAX, "%s", path); dev->max_queue_pairs = queues; dev->queue_pairs = 1; /* mq disabled by default */ @@ -218,6 +230,11 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, parse_mac(dev, mac); dev->vhostfd = -1; + for (i = 0; i < VIRTIO_MAX_VIRTQUEUES * 2 + 1; ++i) { + dev->kickfds[i] = -1; + dev->callfds[i] = -1; + } + dev->vhostfd = vhost_user_setup(dev->path); if (dev->vhostfd < 0) { PMD_INIT_LOG(ERR, "backend set up fails"); @@ -264,13 +281,6 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues, void virtio_user_dev_uninit(struct virtio_user_dev *dev) { - uint32_t i; - - for (i = 0; i < dev->max_queue_pairs * 2; ++i) { - close(dev->callfds[i]); - close(dev->kickfds[i]); - } - close(dev->vhostfd); } diff --git a/drivers/net/virtio/virtio_user_ethdev.c b/drivers/net/virtio/virtio_user_ethdev.c index 6c16d2d..298232a 100644 --- a/drivers/net/virtio/virtio_user_ethdev.c +++ b/drivers/net/virtio/virtio_user_ethdev.c @@ -87,21 +87,24 @@ virtio_user_write_dev_config(struct virtio_hw *hw, size_t offset, } static void -virtio_user_set_status(struct virtio_hw *hw, uint8_t status) +virtio_user_reset(struct virtio_hw *hw) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) - virtio_user_start_device(dev); - dev->status = status; + if (dev->status & VIRTIO_CONFIG_STATUS_DRIVER_OK) + virtio_user_stop_device(dev); } static void -virtio_user_reset(struct virtio_hw *hw) +virtio_user_set_status(struct virtio_hw *hw, uint8_t status) { struct virtio_user_dev *dev = virtio_user_get_dev(hw); - virtio_user_stop_device(dev); + if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK) + virtio_user_start_device(dev); + else if (status == VIRTIO_CONFIG_STATUS_RESET) + virtio_user_reset(hw); + dev->status = status; } static uint8_t -- 2.7.4 ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2017-01-13 13:48 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- [not found] <1480689075-66977-1-git-send-email-jianfeng.tan@intel.com> [not found] ` <1483502366-140154-1-git-send-email-jianfeng.tan@intel.com> 2017-01-04 3:59 ` [dpdk-stable] [PATCH v3 1/7] net/virtio_user: fix wrongly set features Jianfeng Tan 2017-01-04 3:59 ` [dpdk-stable] [PATCH v3 2/7] net/virtio_user: fix not properly reset device Jianfeng Tan 2017-01-04 5:46 ` Yuanhan Liu [not found] ` <1484309921-116526-1-git-send-email-jianfeng.tan@intel.com> 2017-01-13 12:18 ` [dpdk-stable] [PATCH v4 1/8] net/virtio_user: fix wrongly get/set features Jianfeng Tan 2017-01-13 12:18 ` [dpdk-stable] [PATCH v4 2/8] net/virtio_user: fix not properly reset device Jianfeng Tan
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).