DPDK patches and discussions
 help / color / mirror / Atom feed
From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: "Tan, Jianfeng" <jianfeng.tan@intel.com>
Cc: "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [dpdk-dev] [PATCH 6/6] virtio: add virtio v1.0 support
Date: Wed, 30 Dec 2015 11:40:14 +0800	[thread overview]
Message-ID: <20151230034014.GB26062@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <ED26CBA2FAD1BF48A8719AEF02201E36691A65@SHSMSX103.ccr.corp.intel.com>

On Tue, Dec 29, 2015 at 11:39:47AM +0000, Tan, Jianfeng wrote:
> 
> 
> > -----Original Message-----
> > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Yuanhan Liu
> > Sent: Thursday, December 10, 2015 11:54 AM
> > To: dev@dpdk.org
> > Subject: [dpdk-dev] [PATCH 6/6] virtio: add virtio v1.0 support
> > 
> ...
> > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> > ---
> >  drivers/net/virtio/virtio_ethdev.c |  16 +-
> >  drivers/net/virtio/virtio_ethdev.h |   3 +-
> >  drivers/net/virtio/virtio_pci.c    | 313
> > ++++++++++++++++++++++++++++++++++++-
> >  drivers/net/virtio/virtio_pci.h    |  65 ++++++++
> >  drivers/net/virtio/virtqueue.h     |   2 +
> >  5 files changed, 395 insertions(+), 4 deletions(-)
> > 
> 
> As legacy VIRTIO_WRITE_REG_XXXs are only used in virtio_pci.c, move these definitions into virtio_pci.c?

Yes, and I planned to do it in another series, where I will do more virtio
cleanups. (hmm..., maybe I could stack them on top of this series).

> 
> > diff --git a/drivers/net/virtio/virtio_ethdev.c
> > b/drivers/net/virtio/virtio_ethdev.c
> > index 9847ed8..1f9de01 100644
> > --- a/drivers/net/virtio/virtio_ethdev.c
> > +++ b/drivers/net/virtio/virtio_ethdev.c
> > @@ -927,7 +927,7 @@ virtio_vlan_filter_set(struct rte_eth_dev *dev,
> > uint16_t vlan_id, int on)
> >  	return virtio_send_command(hw->cvq, &ctrl, &len, 1);
> >  }
> > 
> > -static void
> > +static int
> >  virtio_negotiate_features(struct virtio_hw *hw)
> >  {
> >  	uint64_t host_features;
> > @@ -949,6 +949,17 @@ virtio_negotiate_features(struct virtio_hw *hw)
> >  	hw->guest_features = vtpci_negotiate_features(hw, host_features);
> >  	PMD_INIT_LOG(DEBUG, "features after negotiate = %"PRIx64,
> >  		hw->guest_features);
> > +
> > +	if (hw->modern) {
> > +		if (!vtpci_with_feature(hw, VIRTIO_F_VERSION_1)) {
> > +			PMD_INIT_LOG(ERR,
> > +				"VIRTIO_F_VERSION_1 features is not
> > enabled");
> > +			return -1;
> > +		}
> > +		vtpci_set_status(hw,
> > VIRTIO_CONFIG_STATUS_FEATURES_OK);
> 
> 
> As per Linux code drivers/virtio/virtio.c:virtio_finalize_features(), vtpci_set_status() may fail, and there's a double check.
> Is it necessary here?

Yes, it's necessary: see the spec (3.1.1 Driver Requirements: Device
Initialization):

    5. Set the FEATURES_OK status bit. The driver MUST NOT accept new
       feature bits after this step.

    6. Re-read device status to ensure the FEATURES_OK bit is still set:
       otherwise, the device does not support our subset of features and
       the device is unusable.
> 
> 
> > +	}
> > +
> > +	return 0;
> >  }
> > 
> >  /*
> > @@ -1032,7 +1043,8 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev)
> > 
> >  	/* Tell the host we've known how to drive the device. */
> >  	vtpci_set_status(hw, VIRTIO_CONFIG_STATUS_DRIVER);
> > -	virtio_negotiate_features(hw);
> > +	if (virtio_negotiate_features(hw) < 0)
> > +		return -1;
> > 
> >  	/* If host does not support status then disable LSC */
> >  	if (!vtpci_with_feature(hw, VIRTIO_NET_F_STATUS))
> > diff --git a/drivers/net/virtio/virtio_ethdev.h
> > b/drivers/net/virtio/virtio_ethdev.h
> > index ae2d47d..fed9571 100644
> > --- a/drivers/net/virtio/virtio_ethdev.h
> > +++ b/drivers/net/virtio/virtio_ethdev.h
> > @@ -64,7 +64,8 @@
> >  	 1u << VIRTIO_NET_F_CTRL_VQ	  |	\
> >  	 1u << VIRTIO_NET_F_CTRL_RX	  |	\
> >  	 1u << VIRTIO_NET_F_CTRL_VLAN	  |	\
> > -	 1u << VIRTIO_NET_F_MRG_RXBUF)
> > +	 1u << VIRTIO_NET_F_MRG_RXBUF	  |	\
> > +	 1ULL << VIRTIO_F_VERSION_1)
> > 
> >  /*
> >   * CQ function prototype
> > diff --git a/drivers/net/virtio/virtio_pci.c b/drivers/net/virtio/virtio_pci.c
> > index 26b0a0c..7862d7f 100644
> > --- a/drivers/net/virtio/virtio_pci.c
> > +++ b/drivers/net/virtio/virtio_pci.c
> > @@ -31,6 +31,7 @@
> >   *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
> > DAMAGE.
> >   */
> >  #include <stdint.h>
> > +#include <linux/pci_regs.h>
> 
> Put this "include" into macro RTE_EXEC_ENV_LINUXAPP followed?

We can't simply do that, as we need reference some macros from it
in common code path, virtio_read_caps(). But yes, you just remind
me that there should be no such header in non-linux platform. We
can't include it blindly here. Good catch, btw!

What's lucky here is that we just need reference quite few macros,
maybe we could just define them by ourself, to get rid of the
depency.

> 
> > 
> >  #ifdef RTE_EXEC_ENV_LINUXAPP
> >   #include <dirent.h>
> > @@ -448,6 +449,205 @@ static const struct virtio_pci_ops legacy_ops = {
> >  };
> > 
> > 
> ...
> > +
> > +static uint16_t
> > +modern_set_irq(struct virtio_hw *hw __rte_unused, uint16_t vec
> > __rte_unused)
> > +{
> > +	/* FIXME: xxx */
> > +	return 0;
> > +}
> 
> If not going to support LSC, please give clear indication at related doc. My concern is: this will affect
> some users, who are using LSC in legacy virtio. (If LSC works well on legacy virtio?).

TBH, I don't spent too much time on that, therefore, I marked it as
FIXME here, with the hope that I will revisit it with more cares in
future version.

> > +
> > +static uint16_t
> > +modern_get_queue_num(struct virtio_hw *hw, uint16_t queue_id)
> > +{
> > +	modern_write16(queue_id, &hw->common_cfg->queue_select);
> > +	return modern_read16(&hw->common_cfg->queue_size);
> > +}
> > +
> ...
> > 
> > +static inline void *
> > +get_cfg_addr(struct rte_pci_device *dev, struct virtio_pci_cap *cap)
> > +{
> > +	uint8_t  bar    = cap->bar;
> > +	uint32_t length = cap->length;
> > +	uint32_t offset = cap->offset;
> > +	uint8_t *base;
> > +
> 
> Use a macro to substitute hardcoded "5"?

The fact that 5 is the max bar number is so well known, that I don't
think it's necessary to add a macro here.

> > +	if (unlikely(bar > 5)) {
> > +		PMD_INIT_LOG(ERR, "invalid bar: %u", bar);
> > +		return NULL;
> > +	}
> > +
> ...
> >  int
> >  vtpci_init(struct rte_pci_device *dev, struct virtio_hw *hw)
> >  {
> > -	hw->vtpci_ops = &legacy_ops;
> > +	hw->dev = dev;
> > 
> > +	/*
> > +	 * Try if we can succeed reading virtio pci caps, which exists
> > +	 * only on modern pci device. If failed, we fallback to legacy
> > +	 * virtio hanlding.
> 
> hanlding -> handling

Oops, and thanks.

	--yliu

  reply	other threads:[~2015-12-30  3:37 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10  3:54 [dpdk-dev] [PATCH 0/6 for 2.3] initial virtio 1.0 enabling Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 1/6] virtio: don't set vring address again at queue startup Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 2/6] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2015-12-29 11:31   ` Tan, Jianfeng
2015-12-30  3:45     ` Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 3/6] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 4/6] viritio: switch to 64 bit features Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 5/6] virtio: set RTE_PCI_DRV_NEED_MAPPING flag Yuanhan Liu
2015-12-10  3:54 ` [dpdk-dev] [PATCH 6/6] virtio: add virtio v1.0 support Yuanhan Liu
2015-12-29 11:39   ` Tan, Jianfeng
2015-12-30  3:40     ` Yuanhan Liu [this message]
2015-12-10  3:58 ` [dpdk-dev] [PATCH 0/6 for 2.3] initial virtio 1.0 enabling Yuanhan Liu
2015-12-29 11:19 ` Tan, Jianfeng
2015-12-30  3:53   ` Yuanhan Liu
2016-01-04  3:55   ` Xu, Qian Q
2016-01-04  4:16     ` Yuanhan Liu
2016-01-12  6:58 ` [dpdk-dev] [PATCH v2 0/7] virtio 1.0 enabling for virtio pmd driver Yuanhan Liu
2016-01-12  6:58   ` [dpdk-dev] [PATCH v2 1/7] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-12  6:58   ` [dpdk-dev] [PATCH v2 2/7] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 3/7] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 4/7] viritio: switch to 64 bit features Yuanhan Liu
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 5/7] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 6/7] eal: pci: export pci_map_device Yuanhan Liu
2016-01-12  8:31     ` David Marchand
2016-01-12  8:40       ` Yuanhan Liu
2016-01-12  9:05         ` Yuanhan Liu
2016-01-13 14:44           ` Santosh Shukla
2016-01-12  6:59   ` [dpdk-dev] [PATCH v2 7/7] virtio: add 1.0 support Yuanhan Liu
2016-01-13  3:31     ` Tetsuya Mukawa
2016-01-13  9:38       ` Yuanhan Liu
2016-01-14  7:47     ` Xie, Huawei
2016-01-14  7:50       ` Yuanhan Liu
2016-01-14  7:51         ` Xie, Huawei
2016-01-14  7:58           ` Yuanhan Liu
2016-01-14  8:08             ` Xie, Huawei
2016-01-14  8:22               ` Yuanhan Liu
2016-01-14  8:28                 ` Xie, Huawei
2016-01-14  7:50     ` Xie, Huawei
2016-01-14  8:38       ` Yuanhan Liu
2016-01-12  7:07   ` [dpdk-dev] [PATCH v2 0/7] virtio 1.0 enabling for virtio pmd driver Yuanhan Liu
2016-01-14  4:27   ` Tetsuya Mukawa
2016-01-14  5:59     ` Yuanhan Liu
2016-01-14  6:09     ` Tan, Jianfeng
2016-01-14  6:41       ` Tetsuya Mukawa
2016-01-18  9:04         ` Tetsuya Mukawa
2016-01-14  6:45       ` Yuanhan Liu
2016-01-14  7:42   ` [dpdk-dev] [PATCH v3 0/8] " Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 1/8] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 2/8] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 3/8] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 4/8] viritio: switch to 64 bit features Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 5/8] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 6/8] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-01-14  7:45       ` Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 7/8] virtio: add 1.0 support Yuanhan Liu
2016-01-14  7:42     ` [dpdk-dev] [PATCH v3 8/8] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-01-16 10:08       ` Santosh Shukla
2016-01-17 14:07         ` Santosh Shukla
2016-01-15  4:36   ` [dpdk-dev] [PATCH v4 0/8] virtio 1.0 enabling for virtio pmd driver Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 1/8] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 2/8] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-18 17:21       ` Xie, Huawei
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 3/8] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 4/8] viritio: switch to 64 bit features Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 5/8] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 6/8] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 7/8] virtio: add 1.0 support Yuanhan Liu
2016-01-18 16:38       ` Xie, Huawei
2016-01-18 16:50       ` Xie, Huawei
2016-01-19  5:55         ` Yuanhan Liu
2016-01-19  7:44           ` Xie, Huawei
2016-01-19  7:54             ` Yuanhan Liu
2016-01-19  8:02             ` Xie, Huawei
2016-01-18 17:07       ` Xie, Huawei
2016-01-19  1:36         ` Yuanhan Liu
2016-01-19  1:51           ` Xie, Huawei
2016-01-19  2:46             ` Yuanhan Liu
2016-01-19  2:48               ` Xie, Huawei
2016-01-19  5:54                 ` Yuanhan Liu
2016-01-15  4:36     ` [dpdk-dev] [PATCH v4 8/8] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-01-15  8:57       ` Xu, Qian Q
2016-01-18  8:04     ` [dpdk-dev] [PATCH v4 0/8] virtio 1.0 enabling for virtio pmd driver Tetsuya Mukawa
2016-01-19  8:11     ` [dpdk-dev] [PATCH v5 0/9] " Yuanhan Liu
2016-01-19  8:11       ` [dpdk-dev] [PATCH v5 1/9] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-19  8:11       ` [dpdk-dev] [PATCH v5 2/9] virtio: define offset as size_t type Yuanhan Liu
2016-01-19  8:11       ` [dpdk-dev] [PATCH v5 3/9] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 4/9] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 5/9] viritio: switch to 64 bit features Yuanhan Liu
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 6/9] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 7/9] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-01-19  8:17         ` David Marchand
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 8/9] virtio: add 1.0 support Yuanhan Liu
2016-01-21 11:37         ` Thomas Monjalon
2016-01-27  3:49           ` Yuanhan Liu
2016-01-21 11:49         ` Thomas Monjalon
2016-01-27  3:46           ` Yuanhan Liu
2016-01-27  8:11             ` Thomas Monjalon
2016-01-19  8:12       ` [dpdk-dev] [PATCH v5 9/9] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-01-19  8:55       ` [dpdk-dev] [PATCH v5 0/9] virtio 1.0 enabling for virtio pmd driver Xie, Huawei
2016-01-28  7:54       ` [dpdk-dev] [PATCH v6 " Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 1/9] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 2/9] virtio: define offset as size_t type Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 3/9] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 4/9] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 5/9] viritio: switch to 64 bit features Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 6/9] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 7/9] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 8/9] virtio: add 1.0 support Yuanhan Liu
2016-01-28  7:54         ` [dpdk-dev] [PATCH v6 9/9] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-02-02 10:46         ` [dpdk-dev] [PATCH v6 0/9] virtio 1.0 enabling for virtio pmd driver Thomas Monjalon
2016-02-02 13:00           ` Yuanhan Liu
2016-02-02 13:48         ` [dpdk-dev] [PATCH v7 " Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 1/9] virtio: don't set vring address again at queue startup Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 2/9] virtio: define offset as size_t type Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 3/9] virtio: introduce struct virtio_pci_ops Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 4/9] virtio: move left pci stuff to virtio_pci.c Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 5/9] viritio: switch to 64 bit features Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 6/9] virtio: retrieve hdr_size from hw->vtnet_hdr_size Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 7/9] eal: pci: export pci_[un]map_device Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 8/9] virtio: add 1.0 support Yuanhan Liu
2016-02-02 13:48           ` [dpdk-dev] [PATCH v7 9/9] virtio: move VIRTIO_READ/WRITE_REG_X into virtio_pci.c Yuanhan Liu
2016-02-03 15:09           ` [dpdk-dev] [PATCH v7 0/9] virtio 1.0 enabling for virtio pmd driver Thomas Monjalon

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=20151230034014.GB26062@yliu-dev.sh.intel.com \
    --to=yuanhan.liu@linux.intel.com \
    --cc=dev@dpdk.org \
    --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 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).