From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2B5F0A0613 for ; Mon, 23 Sep 2019 11:09:30 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 2C5B3343C; Mon, 23 Sep 2019 11:09:29 +0200 (CEST) Received: from FRA01-MR2-obe.outbound.protection.outlook.com (mail-eopbgr90048.outbound.protection.outlook.com [40.107.9.48]) by dpdk.org (Postfix) with ESMTP id 5A7232E8F for ; Mon, 23 Sep 2019 11:09:27 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=E+ZnFr0hQWDclhdXlOBZpqmQJ0CJEBjNHHxsiEDFNwo=; b=37DpapedH/JiRU2/6OXpsQvhOeCwNt/x9aYavkbiSPfUDFncsDzFv9aoQhQRYQRyoSDXG/1atcunHNHyhn3AALWJYXsF5ptD2TRTiOGokD1iut66tB/rtdACf2Q0glNRaKMmDoDRnrw6duAOHDJr0Cy9PAY47gpfxQWy1s1gRBk= Received: from VE1PR08CA0015.eurprd08.prod.outlook.com (2603:10a6:803:104::28) by PR2PR08MB4777.eurprd08.prod.outlook.com (2603:10a6:101:26::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.19; Mon, 23 Sep 2019 09:09:24 +0000 Received: from DB5EUR03FT057.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::200) by VE1PR08CA0015.outlook.office365.com (2603:10a6:803:104::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20 via Frontend Transport; Mon, 23 Sep 2019 09:09:24 +0000 Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dpdk.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dpdk.org; dmarc=none action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT057.mail.protection.outlook.com (10.152.20.235) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20 via Frontend Transport; Mon, 23 Sep 2019 09:09:23 +0000 Received: ("Tessian outbound 5061e1b5386c:v31"); Mon, 23 Sep 2019 09:09:22 +0000 X-CR-MTA-TID: 64aa7808 Received: from b6ee9a8c9feb.1 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.14.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id 302B1BD6-8F2C-429C-A288-D10495E8F539.1; Mon, 23 Sep 2019 09:09:17 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2050.outbound.protection.outlook.com [104.47.14.50]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b6ee9a8c9feb.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 23 Sep 2019 09:09:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IOpsP7gdMrKFhLJM81d0s8+1ueENC7kcaO5XsL3+Gdl5xJo79cpq4kakRbgZa0/LFyIWYgvv+U/mgI2vtUQgeGUPhWRCjhkhvGVPXIWioP6a9VKmz6iaMNjCE3PXIAnByQt5hcBr7Bi0zVRNwJqeKb7qR1MQY45E8+D9VT8/IHb1wXN35H1Ray6/LBUoj2+UHS3lo2/XgMk7zCo8F8pnobZDNP6GIbm3Wx9a11ecs1nQtohFbHXAy9E1FQX5vHYRNJbF8fc8sBipPAWcc05VEzAsncfQny5FFKdL0UPQv9Z1ssJhzb9WuUGEJOiAWrlid+rHVwGYPT04QBLP+bUmmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sUs/UIuj+5DwzaBkIKtWAzgsKguO8ztjeEJrdMU4zJ8=; b=mkS86Tt5kdZ0/UvfMw2Ls47YCtN8XpyGP579ehzlqfLe72cyPDYIEjpXnPx5bl4SLFzddHd+0GuEOCSHkplfVa131i+dGLdPXmwjG/wF5DlPfbSyvuBQ6cHAxNtCCcnO1N71i5GLIz1YbcQ1d6feCP97HVjvJF6cHMF60znK7eRM7DNQm5GnRk5v+pfeBi6itwqMIMT/cbNEihHxGyn/tgn6feaPm5I5iYqthrJoqZqeXXZoseK876OAmwnk685GM+N+UwfPlgBjNvGS4VfNVVx2i43VAo+fgEDPVkv8jcQYG0isIcP6QlU9YUPg3sTKowaJ0+/SOoqc6HeD1Ln5tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sUs/UIuj+5DwzaBkIKtWAzgsKguO8ztjeEJrdMU4zJ8=; b=wpi/9CXvg/x6kNDcy336zKGqJDUqR4Fh8BsxYladFiHjBLxWxsydLSfNdzYXttvfCHtT0Sigrk7uN/YIwrX4c71bpTtYPBy+5BkiJSR6eNJh0VZYpxn1vKkLx3FvAKnGDkfTC3JUx4XdiUVvOHn+6PM2TZRkVGX9hv4GKAfnaSo= Received: from VI1PR08MB5376.eurprd08.prod.outlook.com (52.133.244.200) by VI1PR08MB3375.eurprd08.prod.outlook.com (20.177.58.217) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.25; Mon, 23 Sep 2019 09:09:16 +0000 Received: from VI1PR08MB5376.eurprd08.prod.outlook.com ([fe80::c09a:49d3:eab2:f707]) by VI1PR08MB5376.eurprd08.prod.outlook.com ([fe80::c09a:49d3:eab2:f707%3]) with mapi id 15.20.2284.023; Mon, 23 Sep 2019 09:09:16 +0000 From: "Gavin Hu (Arm Technology China)" To: Marvin Liu , "maxime.coquelin@redhat.com" , "tiwei.bie@intel.com" , "zhihong.wang@intel.com" CC: "dev@dpdk.org" Thread-Topic: [dpdk-dev] [PATCH v2 01/16] vhost: add single packet enqueue function Thread-Index: AQHVbsgmgkTYFFHPWEaB2hgOJ4ZYK6c4/oUA Date: Mon, 23 Sep 2019 09:09:16 +0000 Message-ID: References: <20190905161421.55981-2-yong.liu@intel.com> <20190919163643.24130-1-yong.liu@intel.com> <20190919163643.24130-2-yong.liu@intel.com> In-Reply-To: <20190919163643.24130-2-yong.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 73a69d58-8c77-4874-b3db-75c0087091c9.0 x-checkrecipientchecked: true Authentication-Results-Original: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email X-MS-Office365-Filtering-Correlation-Id: 28c88ecf-20bb-4c8a-87b5-08d74005ba24 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VI1PR08MB3375; X-MS-TrafficTypeDiagnostic: VI1PR08MB3375:|PR2PR08MB4777: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:2276;OLM:2276; x-forefront-prvs: 0169092318 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(346002)(39860400002)(136003)(396003)(366004)(376002)(189003)(199004)(13464003)(66066001)(66446008)(66556008)(66476007)(2201001)(6116002)(71190400001)(11346002)(55236004)(3846002)(476003)(76176011)(81166006)(81156014)(186003)(446003)(7696005)(2501003)(7736002)(99286004)(478600001)(102836004)(53546011)(6506007)(26005)(305945005)(5660300002)(6246003)(86362001)(2906002)(33656002)(9686003)(55016002)(71200400001)(14454004)(8936002)(74316002)(4326008)(76116006)(256004)(14444005)(110136005)(229853002)(64756008)(66946007)(52536014)(25786009)(316002)(6436002)(486006); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3375; H:VI1PR08MB5376.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; received-spf: None (protection.outlook.com: arm.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Message-Info-Original: 7C/m8CjIFr5m0oZJQEWvv4BbTSuJvo4+NmWXLrt+RJ3FzYo7TDku32Wq0TFJsxlyardgxpus+lbq8AQUTpdzvClVpL7XU4PKOmgHn/FMyon2nD1HcpvRxvXVtxUkM3iIBF3kV8xSXN69pcu9f53E75g7S3O4J8BDLAi1J5m+emnuD3IYCa32+G5lpiwzI8DXHQa7ppwRNQLWgIUBFIS6laDiQ7O721N7MhJMnZRTKuz+7yIMbufRXmQ6lsOgIzzAjZAcI6eMGlkxuTaHrFzF1tL7/kLnDsG+JA0mT/olDXEOYo1zhfqN+Vttg5Ng+Tza9iRohLx5+yfochXE0nWdW0dDwo/1kDv/nPhCgJR5dLu0960Q16mzr8BiV5papWaqUyjOAjwMfoMx+ivgZUZwYzj2/vCmELFsTOHAf13c+vo= x-ms-exchange-transport-forked: True Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3375 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT057.eop-EUR03.prod.protection.outlook.com X-Forefront-Antispam-Report: CIP:63.35.35.123; IPV:CAL; SCL:-1; CTRY:IE; EFV:NLI; SFV:NSPM; SFS:(10009020)(4636009)(396003)(39860400002)(376002)(346002)(136003)(40434004)(189003)(199004)(13464003)(2501003)(74316002)(356004)(4326008)(2201001)(7736002)(5024004)(305945005)(336012)(33656002)(66066001)(6246003)(316002)(46406003)(110136005)(14444005)(55016002)(6116002)(23726003)(9686003)(47776003)(86362001)(50466002)(70586007)(70206006)(76130400001)(8936002)(99286004)(25786009)(7696005)(76176011)(97756001)(3846002)(26005)(52536014)(6506007)(53546011)(446003)(11346002)(2906002)(81166006)(186003)(102836004)(81156014)(8746002)(26826003)(126002)(486006)(14454004)(5660300002)(63350400001)(22756006)(229853002)(476003)(478600001); DIR:OUT; SFP:1101; SCL:1; SRVR:PR2PR08MB4777; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; MX:1; A:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: c791fbc8-72bd-473d-7d23-08d74005b595 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(710020)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:PR2PR08MB4777; X-Forefront-PRVS: 0169092318 X-Microsoft-Antispam-Message-Info: 3ufLNDeQZPnbicY04Qd45LphD09XkkQ+rmDKr+3g2e9sjoY99JM9UvHn8za7cojBrYJ72ObNF7JPdM/ftqaQCjQlEYN5I+RCllG3Cn6p+abXsKDA7Nhf8SCZ01aZ1UJfRFms3asmMOAxkAXAWs+eSwjmFZw93lpnzffXK0CYVUsqaDaYoAak9w2kbK+u98Wq2b+YTHK48zfOBnND6eeHy4IbjGa3ks7p/MUdjwpIC/2e3hdrWG4IaaHnhvSwE3zFcoxVAJI5D21V38GBwKUFy4VPc3bcO6iKtpznxjfqiUiMaiwhdQtKg7KYOzhDtlQQcO1jEBDasprLvt7Mk9ze3OX0lkrCP6TXXPs5O+l6VmcbpI5nUliIXFhHBpQzgsLYbf7wOC2X+VuH2nKUfqMLveiphG+i7SHInmWWp8z51nA= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Sep 2019 09:09:23.7664 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 28c88ecf-20bb-4c8a-87b5-08d74005ba24 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR2PR08MB4777 Subject: Re: [dpdk-dev] [PATCH v2 01/16] vhost: add single packet enqueue function 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Marvin, > -----Original Message----- > From: dev On Behalf Of Marvin Liu > Sent: Friday, September 20, 2019 12:36 AM > To: maxime.coquelin@redhat.com; tiwei.bie@intel.com; > zhihong.wang@intel.com > Cc: dev@dpdk.org; Marvin Liu > Subject: [dpdk-dev] [PATCH v2 01/16] vhost: add single packet enqueue > function > > Add vhost enqueue function for single packet and meanwhile left space > for flush used ring function. > > Signed-off-by: Marvin Liu > > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.= c > index 5b85b832d..2b5c47145 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -774,6 +774,70 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct > vhost_virtqueue *vq, > return error; > } > > +/* > + * Returns -1 on fail, 0 on success > + */ > +static __rte_always_inline int > +vhost_enqueue_single_packed(struct virtio_net *dev, struct > vhost_virtqueue *vq, > + struct rte_mbuf *pkt, struct buf_vector *buf_vec, uint16_t > *nr_descs) > +{ > + uint16_t nr_vec =3D 0; > + > + uint16_t avail_idx; > + uint16_t max_tries, tries =3D 0; > + > + uint16_t buf_id =3D 0; > + uint32_t len =3D 0; > + uint16_t desc_count; > + > + uint32_t size =3D pkt->pkt_len + dev->vhost_hlen; > + avail_idx =3D vq->last_avail_idx; > + > + if (rxvq_is_mergeable(dev)) > + max_tries =3D vq->size - 1; > + else > + max_tries =3D 1; > + > + uint16_t num_buffers =3D 0; > + > + while (size > 0) { > + /* > + * if we tried all available ring items, and still > + * can't get enough buf, it means something abnormal > + * happened. > + */ > + if (unlikely(++tries > max_tries)) > + return -1; > + > + if (unlikely(fill_vec_buf_packed(dev, vq, > + avail_idx, &desc_count, > + buf_vec, &nr_vec, > + &buf_id, &len, > + VHOST_ACCESS_RW) < 0)) { > + return -1; > + } > + > + len =3D RTE_MIN(len, size); > + > + size -=3D len; > + > + avail_idx +=3D desc_count; > + if (avail_idx >=3D vq->size) > + avail_idx -=3D vq->size; > + > + *nr_descs +=3D desc_count; > + num_buffers +=3D 1; > + } > + > + if (copy_mbuf_to_desc(dev, vq, pkt, > + buf_vec, nr_vec, > + num_buffers) < 0) { > + return 0; Why return 0, which means success, while "copy_mbuf_to_desc" encounters som= e problems and failed? /Gavin > + } > + > + return 0; > +} > + > static __rte_noinline uint32_t > virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, > struct rte_mbuf **pkts, uint32_t count) > @@ -831,6 +895,35 @@ virtio_dev_rx_split(struct virtio_net *dev, struct > vhost_virtqueue *vq, > return pkt_idx; > } > > +static __rte_unused int16_t > +virtio_dev_rx_single_packed(struct virtio_net *dev, struct vhost_virtque= ue > *vq, > + struct rte_mbuf *pkt) > +{ > + struct buf_vector buf_vec[BUF_VECTOR_MAX]; > + uint16_t nr_descs =3D 0; > + > + rte_smp_rmb(); > + if (unlikely(vhost_enqueue_single_packed(dev, vq, pkt, buf_vec, > + &nr_descs) < 0)) { > + VHOST_LOG_DEBUG(VHOST_DATA, > + "(%d) failed to get enough desc from > vring\n", > + dev->vid); > + return -1; > + } > + > + VHOST_LOG_DEBUG(VHOST_DATA, "(%d) current index %d | end > index %d\n", > + dev->vid, vq->last_avail_idx, > + vq->last_avail_idx + nr_descs); > + > + vq->last_avail_idx +=3D nr_descs; > + if (vq->last_avail_idx >=3D vq->size) { > + vq->last_avail_idx -=3D vq->size; > + vq->avail_wrap_counter ^=3D 1; > + } > + > + return 0; > +} > + > static __rte_noinline uint32_t > virtio_dev_rx_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > struct rte_mbuf **pkts, uint32_t count) > -- > 2.17.1 IMPORTANT NOTICE: The contents of this email and any attachments are confid= ential and may also be privileged. If you are not the intended recipient, p= lease notify the sender immediately and do not disclose the contents to any= other person, use it for any purpose, or store or copy the information in = any medium. Thank you.