From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 0C9521B817 for ; Wed, 11 Apr 2018 04:54:35 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Apr 2018 19:54:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,434,1517904000"; d="scan'208";a="42380314" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 10 Apr 2018 19:54:34 -0700 Received: from FMSMSX110.amr.corp.intel.com (10.18.116.10) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 10 Apr 2018 19:54:34 -0700 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx110.amr.corp.intel.com (10.18.116.10) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 10 Apr 2018 19:54:33 -0700 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.115]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.151]) with mapi id 14.03.0319.002; Wed, 11 Apr 2018 10:54:32 +0800 From: "Chen, Junjie J" To: Jens Freimann CC: "Tan, Jianfeng" , "maxime.coquelin@redhat.com" , "mtetsuyah@gmail.com" , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH] net/vhost: fix vhost invalid state Thread-Index: AQHT0JbAsnMkFuYAokqSjipgp9dbQqP5UpoAgAGMMGA= Date: Wed, 11 Apr 2018 02:54:31 +0000 Message-ID: References: <1523369889-73457-1-git-send-email-junjie.j.chen@intel.com> <20180410111326.if376elqdy7e3vkv@dhcp-192-241.str.redhat.com> In-Reply-To: <20180410111326.if376elqdy7e3vkv@dhcp-192-241.str.redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-ctpclassification: CTP_NT x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMjJhM2UzYmMtOWQ1ZS00MzMxLWE3OWItN2UyNWEyNzlhYjA0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjIuNS4xOCIsIlRydXN0ZWRMYWJlbEhhc2giOiI5ZjVDRklzRmIwTkJTenRRTmRKbFJrQVE2UGl4UG02NmMyUE5jNmxGeWhFZ1hvSHh4N3IrQ1Y2RGtTN0Q2RUk5In0= 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] net/vhost: fix vhost invalid state X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 11 Apr 2018 02:54:36 -0000 Thanks to point this out, I forgot to run 'git add' before generating patch= . Need following change also:=20 --- a/drivers/net/vhost/rte_eth_vhost.c +++ b/drivers/net/vhost/rte_eth_vhost.c @@ -655,9 +655,8 @@ destroy_device(int vid) eth_dev =3D list->eth_dev; internal =3D eth_dev->data->dev_private; - rte_atomic32_set(&internal->started, 0); - update_queuing_status(eth_dev); rte_atomic32_set(&internal->dev_attached, 0); + update_queuing_status(eth_dev); eth_dev->data->dev_link.link_status =3D ETH_LINK_DOWN; Will send out V2 to include this. Cheers JJ > -----Original Message----- > From: Jens Freimann [mailto:jfreimann@redhat.com] > Sent: Tuesday, April 10, 2018 7:13 PM > To: Chen, Junjie J > Cc: Tan, Jianfeng ; maxime.coquelin@redhat.com; > mtetsuyah@gmail.com; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] net/vhost: fix vhost invalid state >=20 > On Tue, Apr 10, 2018 at 10:18:09AM -0400, Junjie Chen wrote: > >dev_start sets *dev_attached* after setup queues, this sets device to > >invalid state since no frontend is attached. Also destroy_device set > >*started* to zero which makes *allow_queuing* always zero until > >dev_start get called again. Actually, we should not determine queues > >existence by > >*dev_attached* but by queues pointers or other separated variable(s). > > > >Fixes: 30a701a53737 ("net/vhost: fix crash when creating vdev > >dynamically") > > > >Signed-off-by: Junjie Chen >=20 > So this fixes the problem I saw with allow_queueing always being zero and= the > error message "VHOST_CONFIG: (0) device not found". >=20 > However with this patch on top of virtio-next/master no packets are being > forwarded to the guest and back anymore. >=20 > When I use virtio-next/master and revert 30a701a53737 both works fine. >=20 > regards, > Jens >=20 > >--- > > drivers/net/vhost/rte_eth_vhost.c | 64 > >+++++++++++++++++++++++---------------- > > 1 file changed, 38 insertions(+), 26 deletions(-) > > > >diff --git a/drivers/net/vhost/rte_eth_vhost.c > >b/drivers/net/vhost/rte_eth_vhost.c > >index 11b6076..6a2ff76 100644 > >--- a/drivers/net/vhost/rte_eth_vhost.c > >+++ b/drivers/net/vhost/rte_eth_vhost.c > >@@ -118,6 +118,7 @@ struct pmd_internal { > > char *iface_name; > > uint16_t max_queues; > > uint16_t vid; > >+ uint16_t queue_ready; > > rte_atomic32_t started; > > }; > > > >@@ -528,10 +529,13 @@ update_queuing_status(struct rte_eth_dev *dev) > > unsigned int i; > > int allow_queuing =3D 1; > > > >- if (rte_atomic32_read(&internal->dev_attached) =3D=3D 0) > >+ if (!dev->data->rx_queues || !dev->data->tx_queues) { > >+ RTE_LOG(ERR, PMD, "RX/TX queues not setup yet\n"); > > return; > >+ } > > > >- if (rte_atomic32_read(&internal->started) =3D=3D 0) > >+ if (rte_atomic32_read(&internal->started) =3D=3D 0 || > >+ rte_atomic32_read(&internal->dev_attached) =3D=3D 0) > > allow_queuing =3D 0; > > > > /* Wait until rx/tx_pkt_burst stops accessing vhost device */ @@ > >-576,6 +580,8 @@ queue_setup(struct rte_eth_dev *eth_dev, struct > pmd_internal *internal) > > vq->internal =3D internal; > > vq->port =3D eth_dev->data->port_id; > > } > >+ > >+ internal->queue_ready =3D 1; > > } > > > > static int > >@@ -607,13 +613,10 @@ new_device(int vid) #endif > > > > internal->vid =3D vid; > >- if (eth_dev->data->rx_queues && eth_dev->data->tx_queues) { > >+ if (eth_dev->data->rx_queues && eth_dev->data->tx_queues) > > queue_setup(eth_dev, internal); > >- rte_atomic32_set(&internal->dev_attached, 1); > >- } else { > >- RTE_LOG(INFO, PMD, "RX/TX queues have not setup yet\n"); > >- rte_atomic32_set(&internal->dev_attached, 0); > >- } > >+ else > >+ RTE_LOG(INFO, PMD, "RX/TX queues not setup yet\n"); > > > > for (i =3D 0; i < rte_vhost_get_vring_num(vid); i++) > > rte_vhost_enable_guest_notification(vid, i, 0); @@ -622,6 +625,7 > @@ > >new_device(int vid) > > > > eth_dev->data->dev_link.link_status =3D ETH_LINK_UP; > > > >+ rte_atomic32_set(&internal->dev_attached, 1); > > update_queuing_status(eth_dev); > > > > RTE_LOG(INFO, PMD, "Vhost device %d created\n", vid); @@ -657,17 > >+661,19 @@ destroy_device(int vid) > > > > eth_dev->data->dev_link.link_status =3D ETH_LINK_DOWN; > > > >- for (i =3D 0; i < eth_dev->data->nb_rx_queues; i++) { > >- vq =3D eth_dev->data->rx_queues[i]; > >- if (vq =3D=3D NULL) > >- continue; > >- vq->vid =3D -1; > >- } > >- for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) { > >- vq =3D eth_dev->data->tx_queues[i]; > >- if (vq =3D=3D NULL) > >- continue; > >- vq->vid =3D -1; > >+ if (eth_dev->data->rx_queues && eth_dev->data->tx_queues) { > >+ for (i =3D 0; i < eth_dev->data->nb_rx_queues; i++) { > >+ vq =3D eth_dev->data->rx_queues[i]; > >+ if (!vq) > >+ continue; > >+ vq->vid =3D -1; > >+ } > >+ for (i =3D 0; i < eth_dev->data->nb_tx_queues; i++) { > >+ vq =3D eth_dev->data->tx_queues[i]; > >+ if (!vq) > >+ continue; > >+ vq->vid =3D -1; > >+ } > > } > > > > state =3D vring_states[eth_dev->data->port_id]; > >@@ -792,11 +798,14 @@ eth_dev_start(struct rte_eth_dev *eth_dev) { > > struct pmd_internal *internal =3D eth_dev->data->dev_private; > > > >- if (unlikely(rte_atomic32_read(&internal->dev_attached) =3D=3D 0)) { > >- queue_setup(eth_dev, internal); > >- rte_atomic32_set(&internal->dev_attached, 1); > >+ if (!eth_dev->data->rx_queues || !eth_dev->data->tx_queues) { > >+ RTE_LOG(ERR, PMD, "RX/TX queues not exist yet\n"); > >+ return -1; > > } > > > >+ if (!internal->queue_ready) > >+ queue_setup(eth_dev, internal); > >+ > > rte_atomic32_set(&internal->started, 1); > > update_queuing_status(eth_dev); > > > >@@ -836,10 +845,13 @@ eth_dev_close(struct rte_eth_dev *dev) > > pthread_mutex_unlock(&internal_list_lock); > > rte_free(list); > > > >- for (i =3D 0; i < dev->data->nb_rx_queues; i++) > >- rte_free(dev->data->rx_queues[i]); > >- for (i =3D 0; i < dev->data->nb_tx_queues; i++) > >- rte_free(dev->data->tx_queues[i]); > >+ if (dev->data->rx_queues) > >+ for (i =3D 0; i < dev->data->nb_rx_queues; i++) > >+ rte_free(dev->data->rx_queues[i]); > >+ > >+ if (dev->data->tx_queues) > >+ for (i =3D 0; i < dev->data->nb_tx_queues; i++) > >+ rte_free(dev->data->tx_queues[i]); > > > > rte_free(dev->data->mac_addrs); > > free(internal->dev_name); > >-- > >2.0.1 > >