DPDK patches and discussions
 help / color / Atom feed
From: "Xia, Chenbo" <chenbo.xia@intel.com>
To: Adrian Moreno <amorenoz@redhat.com>, "dev@dpdk.org" <dev@dpdk.org>
Cc: "Wang, Zhihong" <zhihong.wang@intel.com>,
	"maxime.coquelin@redhat.com" <maxime.coquelin@redhat.com>
Subject: Re: [dpdk-dev] [PATCH v3 3/4] net/virtio: add GET_STATUS support to virtio-user
Date: Thu, 6 Aug 2020 02:35:18 +0000
Message-ID: <MN2PR11MB40632501AF4B13404382F96A9C480@MN2PR11MB4063.namprd11.prod.outlook.com> (raw)
In-Reply-To: <20200805144517.54689-4-amorenoz@redhat.com>


> -----Original Message-----
> From: Adrian Moreno <amorenoz@redhat.com>
> Sent: Wednesday, August 5, 2020 10:45 PM
> To: dev@dpdk.org
> Cc: Wang, Zhihong <zhihong.wang@intel.com>; Xia, Chenbo
> <chenbo.xia@intel.com>; maxime.coquelin@redhat.com; Adrian Moreno
> <amorenoz@redhat.com>
> Subject: [PATCH v3 3/4] net/virtio: add GET_STATUS support to virtio-user
> 
> This patch adds support for VHOST_USER_GET_STATUS request.
> 
> Only vhost-user backed is supported for now
> 
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---
>  drivers/net/virtio/virtio_user/vhost_user.c   |  2 +
>  .../net/virtio/virtio_user/virtio_user_dev.c  | 44 +++++++++++++++++++
>  .../net/virtio/virtio_user/virtio_user_dev.h  |  1 +
>  drivers/net/virtio/virtio_user_ethdev.c       |  2 +
>  4 files changed, 49 insertions(+)
> 
> diff --git a/drivers/net/virtio/virtio_user/vhost_user.c
> b/drivers/net/virtio/virtio_user/vhost_user.c
> index 337e51199..12b6c7dbc 100644
> --- a/drivers/net/virtio/virtio_user/vhost_user.c
> +++ b/drivers/net/virtio/virtio_user/vhost_user.c
> @@ -279,6 +279,7 @@ vhost_user_sock(struct virtio_user_dev *dev,
>  	switch (req) {
>  	case VHOST_USER_GET_FEATURES:
>  	case VHOST_USER_GET_PROTOCOL_FEATURES:
> +	case VHOST_USER_GET_STATUS:
>  		need_reply = 1;
>  		break;
> 
> @@ -373,6 +374,7 @@ vhost_user_sock(struct virtio_user_dev *dev,
> 
>  		switch (req) {
>  		case VHOST_USER_GET_FEATURES:
> +		case VHOST_USER_GET_STATUS:
>  		case VHOST_USER_GET_PROTOCOL_FEATURES:
>  			if (msg.size != sizeof(m.payload.u64)) {
>  				PMD_DRV_LOG(ERR, "Received bad msg size");
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 670fc9d40..2a0c86108 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -807,3 +807,47 @@ virtio_user_send_status_update(struct virtio_user_dev
> *dev, uint8_t status)
> 
>  	return 0;
>  }
> +
> +int
> +virtio_user_update_status(struct virtio_user_dev *dev)
> +{
> +	uint64_t ret;
> +	int err;
> +
> +	/* Vhost-user only for now */
> +	if (!is_vhost_user_by_type(dev->path))
> +		return 0;
> +
> +	if (!(dev->protocol_features & (1UL <<
> VHOST_USER_PROTOCOL_F_STATUS)))
> +		return 0;
> +
> +	err = dev->ops->send_request(dev, VHOST_USER_GET_STATUS, &ret);
> +	if (err) {
> +		PMD_INIT_LOG(ERR, "VHOST_USER_GET_STATUS failed (%d): %s", err,
> +			     strerror(errno));
> +		return -1;
> +	}
> +	if (ret > UINT8_MAX) {
> +		PMD_INIT_LOG(ERR, "Invalid VHOST_USER_GET_STATUS response 0x%"
> PRIx64 "\n", ret);
> +		return -1;
> +	}
> +
> +	dev->status = ret;
> +	PMD_INIT_LOG(DEBUG, "Updated Device Status(0x%08x):\n"
> +			"\t-RESET: %u\n"
> +			"\t-ACKNOWLEDGE: %u\n"
> +			"\t-DRIVER: %u\n"
> +			"\t-DRIVER_OK: %u\n"
> +			"\t-FEATURES_OK: %u\n"
> +			"\t-DEVICE_NEED_RESET: %u\n"
> +			"\t-FAILED: %u\n",
> +			dev->status,
> +			(dev->status == VIRTIO_CONFIG_STATUS_RESET),
> +			!!(dev->status & VIRTIO_CONFIG_STATUS_ACK),
> +			!!(dev->status & VIRTIO_CONFIG_STATUS_DRIVER),
> +			!!(dev->status & VIRTIO_CONFIG_STATUS_DRIVER_OK),
> +			!!(dev->status & VIRTIO_CONFIG_STATUS_FEATURES_OK),
> +			!!(dev->status & VIRTIO_CONFIG_STATUS_DEV_NEED_RESET),
> +			!!(dev->status & VIRTIO_CONFIG_STATUS_FAILED));
> +	return 0;
> +}
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> index 835ab64ae..9377d5ba6 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> @@ -73,4 +73,5 @@ void virtio_user_handle_cq_packed(struct virtio_user_dev
> *dev,
>  				  uint16_t queue_idx);
>  uint8_t virtio_user_handle_mq(struct virtio_user_dev *dev, uint16_t
> q_pairs);
>  int virtio_user_send_status_update(struct virtio_user_dev *dev, uint8_t
> status);
> +int virtio_user_update_status(struct virtio_user_dev *dev);
>  #endif
> diff --git a/drivers/net/virtio/virtio_user_ethdev.c
> b/drivers/net/virtio/virtio_user_ethdev.c
> index 785882e06..87f6cb695 100644
> --- a/drivers/net/virtio/virtio_user_ethdev.c
> +++ b/drivers/net/virtio/virtio_user_ethdev.c
> @@ -280,6 +280,8 @@ virtio_user_get_status(struct virtio_hw *hw)
>  {
>  	struct virtio_user_dev *dev = virtio_user_get_dev(hw);
> 
> +	virtio_user_update_status(dev);
> +
>  	return dev->status;
>  }
> 
> --
> 2.26.2

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

  reply index

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-05 14:45 [dpdk-dev] [PATCH v3 0/4] Add support for GET/SET_STATUS on virtio-user pmd Adrian Moreno
2020-08-05 14:45 ` [dpdk-dev] [PATCH v3 1/4] net/virtio: add DEVICE_NEEDS_RESET status bit Adrian Moreno
2020-08-05 14:45 ` [dpdk-dev] [PATCH v3 2/4] net/virtio: add VIRTIO_SET_STATUS support to Virtio-user Adrian Moreno
2020-08-05 14:45 ` [dpdk-dev] [PATCH v3 3/4] net/virtio: add GET_STATUS support to virtio-user Adrian Moreno
2020-08-06  2:35   ` Xia, Chenbo [this message]
2020-08-05 14:45 ` [dpdk-dev] [PATCH v3 4/4] net/virtio: enable feature checking on virtio-user Adrian Moreno
2020-09-18 12:26 ` [dpdk-dev] [PATCH v3 0/4] Add support for GET/SET_STATUS on virtio-user pmd Maxime Coquelin

Reply instructions:

You may reply publically 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=MN2PR11MB40632501AF4B13404382F96A9C480@MN2PR11MB4063.namprd11.prod.outlook.com \
    --to=chenbo.xia@intel.com \
    --cc=amorenoz@redhat.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=zhihong.wang@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

DPDK patches and discussions

Archives are clonable:
	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/ public-inbox