From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 50CFF5A33 for ; Sun, 6 Sep 2015 04:26:01 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP; 05 Sep 2015 19:26:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,477,1437462000"; d="scan'208";a="783669820" Received: from pgsmsx106.gar.corp.intel.com ([10.221.44.98]) by fmsmga001.fm.intel.com with ESMTP; 05 Sep 2015 19:25:59 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by PGSMSX106.gar.corp.intel.com (10.221.44.98) with Microsoft SMTP Server (TLS) id 14.3.224.2; Sun, 6 Sep 2015 10:25:58 +0800 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.206]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.143]) with mapi id 14.03.0224.002; Sun, 6 Sep 2015 10:25:57 +0800 From: "Ouyang, Changchun" To: Tetsuya Mukawa , "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v4 02/12] vhost: support multiple queues in virtio dev Thread-Index: AQHQ1NVUMORckLG1YUiFAf5S5kQh2p4psFqAgAU71wA= Date: Sun, 6 Sep 2015 02:25:56 +0000 Message-ID: References: <1434355006-30583-1-git-send-email-changchun.ouyang@intel.com> <1439366567-3402-1-git-send-email-changchun.ouyang@intel.com> <1439366567-3402-3-git-send-email-changchun.ouyang@intel.com> <55E7B00B.20000@igel.co.jp> In-Reply-To: <55E7B00B.20000@igel.co.jp> Accept-Language: zh-CN, 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 v4 02/12] vhost: support multiple queues in virtio dev 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: Sun, 06 Sep 2015 02:26:01 -0000 Hi Tetsuya, > -----Original Message----- > From: Tetsuya Mukawa [mailto:mukawa@igel.co.jp] > Sent: Thursday, September 3, 2015 10:27 AM > To: dev@dpdk.org; Ouyang, Changchun > Subject: Re: [dpdk-dev] [PATCH v4 02/12] vhost: support multiple queues i= n > virtio dev >=20 > On 2015/08/12 17:02, Ouyang Changchun wrote: > > diff --git a/lib/librte_vhost/vhost_user/virtio-net-user.h > > b/lib/librte_vhost/vhost_user/virtio-net-user.h > > index df24860..2429836 100644 > > --- a/lib/librte_vhost/vhost_user/virtio-net-user.h > > +++ b/lib/librte_vhost/vhost_user/virtio-net-user.h > > @@ -46,4 +46,6 @@ void user_set_vring_kick(struct vhost_device_ctx, > > struct VhostUserMsg *); > > > > /* > > @@ -206,9 +213,17 @@ cleanup_device(struct virtio_net *dev) static > > void free_device(struct virtio_net_config_ll *ll_dev) { > > - /* Free any malloc'd memory */ > > - rte_free(ll_dev->dev.virtqueue[VIRTIO_RXQ]); > > - rte_free(ll_dev->dev.virtqueue[VIRTIO_TXQ]); > > + uint32_t qp_idx; > > + > > + /* > > + * Free any malloc'd memory. > > + */ > > + /* Free every queue pair. */ > > + for (qp_idx =3D 0; qp_idx < ll_dev->dev.virt_qp_nb; qp_idx++) { > > + uint32_t virt_rx_q_idx =3D qp_idx * VIRTIO_QNUM + > VIRTIO_RXQ; > > + rte_free(ll_dev->dev.virtqueue[virt_rx_q_idx]); >=20 > Hi Changchun, >=20 > Should we free tx queue also here? > We don't need do it, as we allocate once for both rx and tx queue. Thus, we allocate once, free once. Pls see the following code snippet: + * Alloc mem for vring queue pair. + */ +int +alloc_vring_queue_pair(struct virtio_net *dev, uint16_t qp_idx) { + struct vhost_virtqueue *virtqueue =3D NULL; + uint32_t virt_rx_q_idx =3D qp_idx * VIRTIO_QNUM + VIRTIO_RXQ; + uint32_t virt_tx_q_idx =3D qp_idx * VIRTIO_QNUM + VIRTIO_TXQ; =20 - /* Backends are set to -1 indicating an inactive device. */ - dev->virtqueue[VIRTIO_RXQ]->backend =3D VIRTIO_DEV_STOPPED; - dev->virtqueue[VIRTIO_TXQ]->backend =3D VIRTIO_DEV_STOPPED; + virtqueue =3D rte_malloc(NULL, sizeof(struct vhost_virtqueue) * VIRTIO_QN= UM, 0); + if (virtqueue =3D=3D NULL) { + RTE_LOG(ERR, VHOST_CONFIG, + "Failed to allocate memory for virt qp:%d.\n", qp_idx); + return -1; + } + + dev->virtqueue[virt_rx_q_idx] =3D virtqueue; + dev->virtqueue[virt_tx_q_idx] =3D virtqueue + VIRTIO_TXQ; + + init_vring_queue_pair(dev, qp_idx); + + return 0; } Thanks Changchun >=20 > > + } > > + rte_free(ll_dev->dev.virtqueue); > > rte_free(ll_dev); > > } > > > >