From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 272228E97 for ; Tue, 29 Dec 2015 12:39:51 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga104.fm.intel.com with ESMTP; 29 Dec 2015 03:39:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,495,1444719600"; d="scan'208";a="850067535" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga001.jf.intel.com with ESMTP; 29 Dec 2015 03:39:49 -0800 Received: from fmsmsx119.amr.corp.intel.com (10.18.124.207) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 29 Dec 2015 03:39:49 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by FMSMSX119.amr.corp.intel.com (10.18.124.207) with Microsoft SMTP Server (TLS) id 14.3.248.2; Tue, 29 Dec 2015 03:39:49 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.57]) by shsmsx102.ccr.corp.intel.com ([169.254.2.133]) with mapi id 14.03.0248.002; Tue, 29 Dec 2015 19:39:47 +0800 From: "Tan, Jianfeng" To: Yuanhan Liu , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH 6/6] virtio: add virtio v1.0 support Thread-Index: AQHRMv6U6GFKJr4svkyWcD4CHodKXZ7h804Q Date: Tue, 29 Dec 2015 11:39:47 +0000 Message-ID: References: <1449719650-3482-1-git-send-email-yuanhan.liu@linux.intel.com> <1449719650-3482-7-git-send-email-yuanhan.liu@linux.intel.com> In-Reply-To: <1449719650-3482-7-git-send-email-yuanhan.liu@linux.intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH 6/6] virtio: add virtio v1.0 support X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Dec 2015 11:39:51 -0000 > -----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 >=20 ... > Signed-off-by: Yuanhan Liu > --- > 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(-) >=20 As legacy VIRTIO_WRITE_REG_XXXs are only used in virtio_pci.c, move these d= efinitions into virtio_pci.c? > 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); > } >=20 > -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 =3D vtpci_negotiate_features(hw, host_features); > PMD_INIT_LOG(DEBUG, "features after negotiate =3D %"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? > + } > + > + return 0; > } >=20 > /* > @@ -1032,7 +1043,8 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) >=20 > /* 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; >=20 > /* 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) >=20 > /* > * 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 > +#include Put this "include" into macro RTE_EXEC_ENV_LINUXAPP followed? >=20 > #ifdef RTE_EXEC_ENV_LINUXAPP > #include > @@ -448,6 +449,205 @@ static const struct virtio_pci_ops legacy_ops =3D { > }; >=20 >=20 ... > + > +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. M= y concern is: this will affect some users, who are using LSC in legacy virtio. (If LSC works well on legac= y virtio?). > + > +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); > +} > + ... >=20 > +static inline void * > +get_cfg_addr(struct rte_pci_device *dev, struct virtio_pci_cap *cap) > +{ > + uint8_t bar =3D cap->bar; > + uint32_t length =3D cap->length; > + uint32_t offset =3D cap->offset; > + uint8_t *base; > + Use a macro to substitute hardcoded "5"? > + 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 =3D &legacy_ops; > + hw->dev =3D dev; >=20 > + /* > + * 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 Thanks, Jianfeng > + */ ... > + > struct vq_desc_extra { > void *cookie; > uint16_t ndescs; > -- > 1.9.0