DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: Maxime Coquelin <maxime.coquelin@redhat.com>,
	"dev@dpdk.org" <dev@dpdk.org>,
	"Fu, Patrick" <patrick.fu@intel.com>,
	"amorenoz@redhat.com" <amorenoz@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v3 7/8] net/virtio: split virtio-user start
Date: Wed, 30 Sep 2020 05:49:53 +0000	[thread overview]
Message-ID: <MN2PR11MB4063705AC00664D99F6C60E19C330@MN2PR11MB4063.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200929161404.124580-8-maxime.coquelin@redhat.com>

> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Wednesday, September 30, 2020 12:14 AM
> To: dev@dpdk.org; Xia, Chenbo <chenbo.xia@intel.com>; Fu, Patrick
> <patrick.fu@intel.com>; amorenoz@redhat.com
> Cc: Maxime Coquelin <maxime.coquelin@redhat.com>
> Subject: [PATCH v3 7/8] net/virtio: split virtio-user start
> 
> Move feature bit settings in device start out as an standalone
> function, so that feature bit could be negotiated at device
> feature_ok status.
> 
> Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
> ---
>  .../net/virtio/virtio_user/virtio_user_dev.c  | 50 ++++++++++++-------
>  .../net/virtio/virtio_user/virtio_user_dev.h  |  1 +
>  drivers/net/virtio/virtio_user_ethdev.c       |  4 ++
>  3 files changed, 37 insertions(+), 18 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index ded44bf32b..63424656e3 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -112,25 +112,11 @@ virtio_user_queue_setup(struct virtio_user_dev *dev,
>  }
> 
>  int
> -virtio_user_start_device(struct virtio_user_dev *dev)
> +virtio_user_dev_set_features(struct virtio_user_dev *dev)
>  {
>  	uint64_t features;
> -	int ret;
> +	int ret = -1;
> 
> -	/*
> -	 * XXX workaround!
> -	 *
> -	 * We need to make sure that the locks will be
> -	 * taken in the correct order to avoid deadlocks.
> -	 *
> -	 * Before releasing this lock, this thread should
> -	 * not trigger any memory hotplug events.
> -	 *
> -	 * This is a temporary workaround, and should be
> -	 * replaced when we get proper supports from the
> -	 * memory subsystem in the future.
> -	 */
> -	rte_mcfg_mem_read_lock();
>  	pthread_mutex_lock(&dev->mutex);
> 
>  	if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER &&
> @@ -141,10 +127,8 @@ virtio_user_start_device(struct virtio_user_dev *dev)
>  	if (virtio_user_queue_setup(dev, virtio_user_create_queue) < 0)
>  		goto error;
> 
> -	/* Step 1: negotiate protocol features & set features */
>  	features = dev->features;
> 
> -
>  	/* Strip VIRTIO_NET_F_MAC, as MAC address is handled in vdev init */
>  	features &= ~(1ull << VIRTIO_NET_F_MAC);
>  	/* Strip VIRTIO_NET_F_CTRL_VQ, as devices do not really need to know
> */
> @@ -154,6 +138,36 @@ virtio_user_start_device(struct virtio_user_dev *dev)
>  	if (ret < 0)
>  		goto error;
>  	PMD_DRV_LOG(INFO, "set features: %" PRIx64, features);
> +error:
> +	pthread_mutex_unlock(&dev->mutex);
> +
> +	return ret;
> +}
> +
> +int
> +virtio_user_start_device(struct virtio_user_dev *dev)
> +{
> +	int ret;
> +
> +	/*
> +	 * XXX workaround!
> +	 *
> +	 * We need to make sure that the locks will be
> +	 * taken in the correct order to avoid deadlocks.
> +	 *
> +	 * Before releasing this lock, this thread should
> +	 * not trigger any memory hotplug events.
> +	 *
> +	 * This is a temporary workaround, and should be
> +	 * replaced when we get proper supports from the
> +	 * memory subsystem in the future.
> +	 */
> +	rte_mcfg_mem_read_lock();
> +	pthread_mutex_lock(&dev->mutex);
> +
> +	if (dev->backend_type == VIRTIO_USER_BACKEND_VHOST_USER &&
> +			dev->vhostfd < 0)
> +		goto error;
> 
>  	/* Step 2: share memory regions */
>  	ret = dev->ops->send_request(dev, VHOST_USER_SET_MEM_TABLE, NULL);
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> index 1c8c98b1cd..3e9d1a1eb3 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> @@ -68,6 +68,7 @@ struct virtio_user_dev {
>  	bool		started;
>  };
> 
> +int virtio_user_dev_set_features(struct virtio_user_dev *dev);
>  int virtio_user_start_device(struct virtio_user_dev *dev);
>  int virtio_user_stop_device(struct virtio_user_dev *dev);
>  int virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int
> queues,
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> b/drivers/net/virtio/virtio_user_ethdev.c
> index 3a51afd711..f56fc238c4 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -269,7 +269,11 @@ static void
>  virtio_user_set_status(struct virtio_hw *hw, uint8_t status)
>  {
>  	struct virtio_user_dev *dev = virtio_user_get_dev(hw);
> +	uint8_t old_status = dev->status;
> 
> +	if (status & VIRTIO_CONFIG_STATUS_FEATURES_OK &&
> +			~old_status & VIRTIO_CONFIG_STATUS_FEATURES_OK)
> +		virtio_user_dev_set_features(dev);
>  	if (status & VIRTIO_CONFIG_STATUS_DRIVER_OK)
>  		virtio_user_start_device(dev);
>  	else if (status == VIRTIO_CONFIG_STATUS_RESET)
> --
> 2.26.2

Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>

  reply	other threads:[~2020-09-30  5:50 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 16:13 [dpdk-dev] [PATCH v3 0/8] virtio-user: introduce vhost-vdpa backend Maxime Coquelin
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 1/8] bus/vdev: add DMA mapping ops Maxime Coquelin
2020-09-30  5:47   ` Xia, Chenbo
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 2/8] net/virtio: introduce DMA ops Maxime Coquelin
2020-09-30  5:47   ` Xia, Chenbo
2020-09-29 16:13 ` [dpdk-dev] [PATCH v3 3/8] net/virtio: move backend type selection to ethdev Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-10-16  5:42   ` Wang, Yinan
2020-10-16  5:58     ` Wang, Yinan
2020-10-20  1:52     ` Wang, Yinan
2020-10-20  7:11       ` Maxime Coquelin
2020-10-20  7:20         ` Adrian Moreno
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 4/8] net/virtio: introduce Vhost-vDPA backend type Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 5/8] net/virtio: check protocol feature in user backend Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 6/8] net/virtio: adapt Virtio-user status size Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 7/8] net/virtio: split virtio-user start Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo [this message]
2020-09-29 16:14 ` [dpdk-dev] [PATCH v3 8/8] net/virtio: introduce Vhost-vDPA backend Maxime Coquelin
2020-09-30  5:49   ` Xia, Chenbo
2020-09-30 16:22 ` [dpdk-dev] [PATCH v3 0/8] virtio-user: introduce vhost-vdpa backend Maxime Coquelin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=MN2PR11MB4063705AC00664D99F6C60E19C330@MN2PR11MB4063.namprd11.prod.outlook.com \
    --to=chenbo.xia@intel.com \
    --cc=amorenoz@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=patrick.fu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).