All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Jianfeng Tan <jianfeng.tan@intel.com>
Cc: dev@dpdk.org, ferruh.yigit@intel.com, cunming.liang@intel.com
Subject: Re: [PATCH 3/3] net/virtio_user: fix wrongly set features
Date: Thu, 8 Dec 2016 16:32:33 +0800	[thread overview]
Message-ID: <20161208083233.GC30698@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <1480689075-66977-4-git-send-email-jianfeng.tan@intel.com>

On Fri, Dec 02, 2016 at 02:31:15PM +0000, Jianfeng Tan wrote:
> 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, host features is obtained at device initialization
> only once, but we did not store it. So the added feature bits in
> re-negotiation will fail.

I think you misunderstood the features negotiation logic here, since
the beginning.

The feature negotiation is a work of 3 parts (the virtio device, the
virtio driver and the vhost). Each part has it's own feature bits
to claim what kind of features it supports.

On the init stage, the driver will have a sync with the device, and
that's what the "get_features" and "set_features" for. Once they have
come to an agreement on the negotiated features, it will have a
last sync with the vhost backend, through the GET_FEATURES and
SET_FEATURES request.

Last, we would have a features bits that would work for all of the
3 parts.

That said, you should not mix the driver's features bits with the
device one. It's Okay to introduce host_features, but it should not
be in the driver layer, it should be in the device layer. And naming
it to something like "device_features" is better, IMO.

And maybe you should re-visit the whole virtio_user features negotiation
logic, to see what can be improved.

Besides, I would put the bug fixing patch in the first of a series,
so that it has minimal chance to introduce conflics while backporting
it to a stable branch.

	--yliu

> 
> Fixes: e9efa4d93821 ("net/virtio-user: add new virtual PCI driver")
> 
> Signed-off-by: Jianfeng Tan <jianfeng.tan@intel.com>
> ---
>  drivers/net/virtio/virtio_user/virtio_user_dev.c | 2 +-
>  drivers/net/virtio/virtio_user/virtio_user_dev.h | 1 +
>  drivers/net/virtio/virtio_user_ethdev.c          | 4 ++--
>  3 files changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.c b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> index 3aef5f6..a9157a9 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.c
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.c
> @@ -224,7 +224,7 @@ virtio_user_dev_init(struct virtio_user_dev *dev, char *path, int queues,
>  	}
>  
>  	if (vhost_call(dev->vid, VHOST_USER_GET_FEATURES,
> -			    &dev->features) < 0) {
> +			    &dev->host_features) < 0) {
>  		PMD_INIT_LOG(ERR, "get_features failed: %s", strerror(errno));
>  		return -1;
>  	}
> diff --git a/drivers/net/virtio/virtio_user/virtio_user_dev.h b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> index 80efb6e..d219432 100644
> --- a/drivers/net/virtio/virtio_user/virtio_user_dev.h
> +++ b/drivers/net/virtio/virtio_user/virtio_user_dev.h
> @@ -47,6 +47,7 @@ struct virtio_user_dev {
>  	uint32_t	queue_pairs;
>  	uint32_t	queue_size;
>  	uint64_t	features;
> +	uint64_t	host_features;
>  	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 406beea..cfe2bfc 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->host_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->host_features;
>  }
>  
>  static uint8_t
> -- 
> 2.7.4

  reply	other threads:[~2016-12-08  8:31 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-02 14:31 [PATCH 0/3] virtio_user as an alternative exception path Jianfeng Tan
2016-12-02 14:31 ` [PATCH 1/3] net/virtio_user: add vhost layer Jianfeng Tan
2016-12-08  7:21   ` Yuanhan Liu
2016-12-02 14:31 ` [PATCH 2/3] net/virtio_user: add vhost kernel support Jianfeng Tan
2016-12-02 14:31 ` [PATCH 3/3] net/virtio_user: fix wrongly set features Jianfeng Tan
2016-12-08  8:32   ` Yuanhan Liu [this message]
2016-12-02 14:44 ` [PATCH 0/3] virtio_user as an alternative exception path Thomas Monjalon
2016-12-23  7:14 ` [PATCH v2 0/7] " Jianfeng Tan
2016-12-23  7:14   ` [PATCH v2 1/7] net/virtio_user: fix wrongly set features Jianfeng Tan
2016-12-23  7:14   ` [PATCH v2 2/7] net/virtio_user: postpone DRIVER OK notification Jianfeng Tan
2016-12-26  6:27     ` Yuanhan Liu
2016-12-26  6:55       ` Tan, Jianfeng
2016-12-26  8:02         ` Yuanhan Liu
2016-12-26  8:26           ` Tan, Jianfeng
2016-12-23  7:14   ` [PATCH v2 3/7] net/virtio_user: move vhost user specific code Jianfeng Tan
2016-12-26  6:28     ` Yuanhan Liu
2016-12-26  6:58       ` Tan, Jianfeng
2016-12-26  7:57         ` Yuanhan Liu
2016-12-29  9:40           ` Tan, Jianfeng
2016-12-23  7:14   ` [PATCH v2 4/7] net/virtio_user: abstract virtio user backend ops Jianfeng Tan
2016-12-26  6:41     ` Yuanhan Liu
2016-12-23  7:14   ` [PATCH v2 5/7] net/virtio_user: add vhost kernel support Jianfeng Tan
2016-12-26  7:44     ` Yuanhan Liu
2017-01-04  7:22       ` Tan, Jianfeng
2017-01-04  7:46         ` Yuanhan Liu
2017-01-09  4:51         ` Jason Wang
2017-01-09  4:39     ` Jason Wang
2017-01-10  6:11       ` Tan, Jianfeng
2017-01-10  8:46         ` Thomas Monjalon
2017-01-10  9:11           ` Tan, Jianfeng
2017-01-11  2:42         ` Jason Wang
2017-01-11  3:13           ` Tan, Jianfeng
2017-01-11  3:23             ` Jason Wang
2017-01-12  9:40               ` Tan, Jianfeng
2017-01-13  2:27                 ` Jason Wang
2017-01-11  2:30       ` Tan, Jianfeng
2017-01-11  2:45         ` Jason Wang
2016-12-23  7:14   ` [PATCH v2 6/7] net/virtio_user: enable offloading Jianfeng Tan
2016-12-26  7:53     ` Yuanhan Liu
2016-12-23  7:14   ` [PATCH v2 7/7] net/virtio_user: enable multiqueue with vhost kernel Jianfeng Tan
2017-01-04  3:59 ` [PATCH v3 0/7] virtio_user as an alternative exception path Jianfeng Tan
2017-01-04  3:59   ` [PATCH v3 1/7] net/virtio_user: fix wrongly set features Jianfeng Tan
2017-01-04  3:59   ` [PATCH v3 2/7] net/virtio_user: fix not properly reset device Jianfeng Tan
2017-01-04  5:46     ` Yuanhan Liu
2017-01-04  3:59   ` [PATCH v3 3/7] net/virtio_user: move vhost user specific code Jianfeng Tan
2017-01-04  6:02     ` Yuanhan Liu
2017-01-04  6:46       ` Tan, Jianfeng
2017-01-04  7:08         ` Yuanhan Liu
2017-01-04  3:59   ` [PATCH v3 4/7] net/virtio_user: abstract virtio user backend ops Jianfeng Tan
2017-01-04  6:11     ` Yuanhan Liu
2017-01-04  3:59   ` [PATCH v3 5/7] net/virtio_user: add vhost kernel support Jianfeng Tan
2017-01-04  6:13     ` Yuanhan Liu
2017-01-04  3:59   ` [PATCH v3 6/7] net/virtio_user: enable offloading Jianfeng Tan
2017-01-04  3:59   ` [PATCH v3 7/7] net/virtio_user: enable multiqueue with vhost kernel Jianfeng Tan
2017-01-09 14:06   ` [PATCH v3 0/7] virtio_user as an alternative exception path Bruce Richardson
2017-01-10  8:46     ` Tan, Jianfeng
2017-01-13 12:18 ` [PATCH v4 0/8] " Jianfeng Tan
2017-01-13 12:18   ` [PATCH v4 1/8] net/virtio_user: fix wrongly get/set features Jianfeng Tan
2017-01-13 12:18   ` [PATCH v4 2/8] net/virtio_user: fix not properly reset device Jianfeng Tan
2017-01-13 12:18   ` [PATCH v4 3/8] net/virtio_user: move vhost user specific code Jianfeng Tan
2017-01-13 12:18   ` [PATCH v4 4/8] net/virtio_user: abstract virtio user backend ops Jianfeng Tan
2017-01-13 12:18   ` [PATCH v4 5/8] net/virtio_user: add vhost kernel support Jianfeng Tan
2017-01-13 12:18   ` [PATCH v4 6/8] net/virtio_user: enable offloading Jianfeng Tan
2017-01-13 12:18   ` [PATCH v4 7/8] net/virtio_user: enable multiqueue with vhost kernel Jianfeng Tan
2017-01-13 12:18   ` [PATCH v4 8/8] doc: add guide to use virtio_user as exceptional path Jianfeng Tan
2017-01-16  6:00     ` Yuanhan Liu
2017-01-16  6:04       ` Yuanhan Liu
2017-01-16  9:44       ` Thomas Monjalon
2017-01-16  9:49         ` Yuanhan Liu
2017-01-16 14:45           ` Thomas Monjalon
2017-01-22  0:46     ` Aws Ismail
2017-01-22  7:16       ` Tan, Jianfeng
2017-01-16 15:05   ` [PATCH v4 0/8] virtio_user as an alternative exception path Yuanhan Liu

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=20161208083233.GC30698@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=cunming.liang@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jianfeng.tan@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.