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 1D5A1A2EFC for ; Tue, 15 Oct 2019 13:36:13 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7FC871EBBA; Tue, 15 Oct 2019 13:36:12 +0200 (CEST) Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80085.outbound.protection.outlook.com [40.107.8.85]) by dpdk.org (Postfix) with ESMTP id 80AC31EBAA for ; Tue, 15 Oct 2019 13:36:10 +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=49S2yhCv3UBauSP1d8UWFEx2l5LA3pXyeQfYTNwU32U=; b=i23D5mdFpj82raADW33q7ONasOL9/5dz5YwPwSoWAM3i9mztghYexs5ZLAdg4hzzJeJXGm7U51O8JKCnv1y6Kt7zOTHPTXh6KXOnL/lvtGV217rBaPb7v+Onlh35rLjWV1h93xPCWGRfCjuMqLpdj9ainmhYkeOkLh12pG7zFRg= Received: from DB7PR08CA0033.eurprd08.prod.outlook.com (2603:10a6:5:16::46) by HE1PR0801MB2122.eurprd08.prod.outlook.com (2603:10a6:3:88::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.19; Tue, 15 Oct 2019 11:36:07 +0000 Received: from AM5EUR03FT021.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e08::208) by DB7PR08CA0033.outlook.office365.com (2603:10a6:5:16::46) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.17 via Frontend Transport; Tue, 15 Oct 2019 11:36:06 +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 AM5EUR03FT021.mail.protection.outlook.com (10.152.16.105) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.15 via Frontend Transport; Tue, 15 Oct 2019 11:36:06 +0000 Received: ("Tessian outbound 081de437afc7:v33"); Tue, 15 Oct 2019 11:36:03 +0000 X-CR-MTA-TID: 64aa7808 Received: from 0bcb3112cd47.1 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.14.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id D782FE99-0F14-4F03-9139-644E02F45B49.1; Tue, 15 Oct 2019 11:35:58 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04lp2051.outbound.protection.outlook.com [104.47.14.51]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0bcb3112cd47.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 15 Oct 2019 11:35:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aMFoaj/ADuJRe88gJOxvTGXGoEcTBDWX8Vb+BiOGXia/vE7ps7Aor6ikFz/UjrxRzIud4hrys4CePhcab09eMUt6OyxtaIF+Ieku6ArpTEJaDvD8z9QlJD1AhCxwgaeDYpW875QXloM7a0YBN/psiNyE/0XMlmt6vsjJdDnJjTMjqZul2vxUIOuk428hCD0rWhWiUXN5cV0H6Fv40X29uW1SRJYqZ51DDJzUy79NU9rllymWLukzoTtDRldy9Q1IWBNoAac0IU/7mhQGlYn9uRk70BcbUl826n5t2qA6SHeHYNyu8wcW897BTGtZoUVpuVlfcQaDuLFYh/vAu/dMoQ== 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=49S2yhCv3UBauSP1d8UWFEx2l5LA3pXyeQfYTNwU32U=; b=FJ9X0nv8CQ2xWZWJBCrAhTNZdhgq5jEjdsTJi4bV174VrpU25iXVCwmjiBvhEDGFfAJxfX25DHDavipHz191MEZvfQPLQJbKmTNsxRCVGwVn0988zyKWKkzNoPqRJu88D+BeMJW2ey8z3SK+ItALZJT+TJweO7JLWKwU0QZTaCXDSHRTNfzG+fGtIf5rLGmiLs4HVUKD/5YwZ76LFo/9F5Ms36ODQY2GXW/+xd6tRVjCcMrkQlFBy0Vpk/bZBLv4lP8EP/cVBA7r9TeSFcDZDeBwTavjolb4pODIYLLEUyplXGNNpaX2F5R6Wly4Lk2trckiQAmZJffkVG3iZtLmUw== 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=49S2yhCv3UBauSP1d8UWFEx2l5LA3pXyeQfYTNwU32U=; b=i23D5mdFpj82raADW33q7ONasOL9/5dz5YwPwSoWAM3i9mztghYexs5ZLAdg4hzzJeJXGm7U51O8JKCnv1y6Kt7zOTHPTXh6KXOnL/lvtGV217rBaPb7v+Onlh35rLjWV1h93xPCWGRfCjuMqLpdj9ainmhYkeOkLh12pG7zFRg= Received: from VI1PR08MB5376.eurprd08.prod.outlook.com (52.133.244.200) by VI1PR08MB4557.eurprd08.prod.outlook.com (20.179.25.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2347.21; Tue, 15 Oct 2019 11:35:56 +0000 Received: from VI1PR08MB5376.eurprd08.prod.outlook.com ([fe80::f8ea:be13:4728:f5fc]) by VI1PR08MB5376.eurprd08.prod.outlook.com ([fe80::f8ea:be13:4728:f5fc%4]) with mapi id 15.20.2347.023; Tue, 15 Oct 2019 11:35:56 +0000 From: "Gavin Hu (Arm Technology China)" To: Marvin Liu , "maxime.coquelin@redhat.com" , "tiwei.bie@intel.com" , "zhihong.wang@intel.com" , "stephen@networkplumber.org" CC: "dev@dpdk.org" , nd Thread-Topic: [PATCH v6 04/13] vhost: add packed ring batch enqueue Thread-Index: AQHVgzKejCM1TQmQhk6cPkW7V912UadbkZww Date: Tue, 15 Oct 2019 11:35:56 +0000 Message-ID: References: <20191015143014.1656-1-yong.liu@intel.com> <20191015160739.51940-1-yong.liu@intel.com> <20191015160739.51940-5-yong.liu@intel.com> In-Reply-To: <20191015160739.51940-5-yong.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 4d9e1bf3-6be7-4530-bb9d-d95369181010.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: 23bfbc40-1618-416a-2660-08d75163dde5 X-MS-Office365-Filtering-HT: Tenant X-MS-TrafficTypeDiagnostic: VI1PR08MB4557:|HE1PR0801MB2122: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:1148;OLM:1148; x-forefront-prvs: 01917B1794 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(366004)(136003)(346002)(396003)(39860400002)(376002)(13464003)(189003)(199004)(66066001)(54906003)(76116006)(26005)(74316002)(478600001)(8676002)(7736002)(4326008)(5660300002)(71190400001)(71200400001)(66946007)(9686003)(229853002)(256004)(14444005)(55236004)(66446008)(64756008)(66476007)(66556008)(2906002)(52536014)(6506007)(86362001)(53546011)(102836004)(110136005)(25786009)(11346002)(186003)(2201001)(7696005)(76176011)(446003)(486006)(14454004)(33656002)(316002)(55016002)(99286004)(3846002)(8936002)(6246003)(305945005)(6436002)(476003)(6116002)(81166006)(2501003)(81156014); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB4557; 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-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: ZJgA37mvpaIc4tsSigCrVjpBxO9ckWYqYU7i17qQyFPRSgwLRNozuhSMuDp98o/f+WZXuByUxO2Wv/lNEds0JkoeWIFCfxnHzwj+u9B0Kb9OyTWfZsGSEoMqO5rA6ui7O33zr5o1GT4vmchEkwsZguCOx2yL+Y/jVERcwv7FrS1UfE8aqcz9HepGTaFJoOsrNHvoSNilXrVoAwgrPAmmsahk7b/IDaTDnH4KlvhSWQ5PsfB5KgkHshMRQSitCjBYwyEo1V+y4eKcRqz1WEKAlqvOLoF723TcqGReRCXTxtFSde56duX+W6u5unPRflYYJkIpgW6ef3Urb4MLIJqrnpmR90EzfqURBOjE84TMF0eIz1keEyltPpdxudKs5/OMR4Uz3J1H2SlUpeAR/tvp9epZFG8QOhcO9m43Dcl5Fl8= 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: VI1PR08MB4557 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT021.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)(376002)(396003)(136003)(39860400002)(346002)(13464003)(189003)(199004)(97756001)(356004)(54906003)(110136005)(76130400001)(26005)(7736002)(305945005)(74316002)(5660300002)(86362001)(99286004)(186003)(336012)(70586007)(70206006)(2501003)(50466002)(66066001)(22756006)(46406003)(47776003)(2201001)(14454004)(52536014)(316002)(478600001)(8746002)(53546011)(3846002)(6506007)(6116002)(76176011)(36906005)(2906002)(14444005)(33656002)(9686003)(8936002)(26826003)(126002)(476003)(446003)(11346002)(25786009)(486006)(63350400001)(55016002)(4326008)(6246003)(23726003)(102836004)(81166006)(7696005)(81156014)(8676002)(229853002); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0801MB2122; 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: b6acd127-bf49-4143-0bd3-08d75163d858 NoDisclaimer: True X-Forefront-PRVS: 01917B1794 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: homT8BHXFqC64sb53iioRXBNdCMjxiiQhwJ7xkX9GfzmaWhvWN27vtJig5V29WkypUz5n4k8w7Rp1/Py/b0F23u5RraEfImcmHgBlnzZrA2P2pkCajbPdLqwuhhnQHoJlwdUIp1EkrpRnyAkMk2OAlr8MB4shF+JFD9LbKu0ZdOCbEsEdOTPSaFUyAKlJ594NxIvPICbkrANn6SrFEmFAjmHVG2S/FuKkppdOGuS0kfSrKqjQGW9MDYamrvRqPlkCCi8/TnJfPzxk/alq42Rnw1366DDIf44xRgPsNjwKz7uiQpSt30IWfm+NgqmJDjDs0R/OjjtiS2QLtHQlFUTfE2X1izxcajrP9hXXAqJwFN5BeozVsK0geo2NaiGPNAuE7E8IIGUDZhmV8So8Q26db5GUv3wpTcYl1VEuZAXjaw= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2019 11:36:06.2058 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 23bfbc40-1618-416a-2660-08d75163dde5 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: HE1PR0801MB2122 Subject: Re: [dpdk-dev] [PATCH v6 04/13] vhost: add packed ring batch enqueue 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: Marvin Liu > Sent: Wednesday, October 16, 2019 12:08 AM > To: maxime.coquelin@redhat.com; tiwei.bie@intel.com; > zhihong.wang@intel.com; stephen@networkplumber.org; Gavin Hu (Arm > Technology China) > Cc: dev@dpdk.org; Marvin Liu > Subject: [PATCH v6 04/13] vhost: add packed ring batch enqueue >=20 > Batch enqueue function will first check whether descriptors are cache > aligned. It will also check prerequisites in the beginning. Batch > enqueue function do not support chained mbufs, single packet enqueue > function will handle it. >=20 > Signed-off-by: Marvin Liu > Reviewed-by: Maxime Coquelin >=20 > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.= c > index 142c14e04..a8130dc06 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -881,6 +881,76 @@ virtio_dev_rx_split(struct virtio_net *dev, struct > vhost_virtqueue *vq, > return pkt_idx; > } >=20 > +static __rte_unused int > +virtio_dev_rx_batch_packed(struct virtio_net *dev, > + struct vhost_virtqueue *vq, > + struct rte_mbuf **pkts) > +{ > + bool wrap_counter =3D vq->avail_wrap_counter; > + struct vring_packed_desc *descs =3D vq->desc_packed; > + uint16_t avail_idx =3D vq->last_avail_idx; > + uint64_t desc_addrs[PACKED_BATCH_SIZE]; > + struct virtio_net_hdr_mrg_rxbuf *hdrs[PACKED_BATCH_SIZE]; > + uint32_t buf_offset =3D dev->vhost_hlen; > + uint64_t lens[PACKED_BATCH_SIZE]; > + uint16_t i; > + > + if (unlikely(avail_idx & PACKED_BATCH_MASK)) > + return -1; > + > + if (unlikely((avail_idx + PACKED_BATCH_SIZE) > vq->size)) > + return -1; > + > + for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { > + if (unlikely(pkts[i]->next !=3D NULL)) > + return -1; > + if (unlikely(!desc_is_avail(&descs[avail_idx + i], > + wrap_counter))) > + return -1; > + } > + > + rte_smp_rmb(); > + > + for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) > + lens[i] =3D descs[avail_idx + i].len; > + > + for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { > + if (unlikely(pkts[i]->pkt_len > (lens[i] - buf_offset))) > + return -1; > + } > + > + for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) > + desc_addrs[i] =3D vhost_iova_to_vva(dev, vq, > + descs[avail_idx + i].addr, > + &lens[i], > + VHOST_ACCESS_RW); > + > + for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { > + if (unlikely(lens[i] !=3D descs[avail_idx + i].len)) > + return -1; > + } > + > + for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { > + rte_prefetch0((void *)(uintptr_t)desc_addrs[i]); > + hdrs[i] =3D (struct virtio_net_hdr_mrg_rxbuf *) > + (uintptr_t)desc_addrs[i]; > + lens[i] =3D pkts[i]->pkt_len + dev->vhost_hlen; > + } > + > + for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) > + virtio_enqueue_offload(pkts[i], &hdrs[i]->hdr); > + > + vq_inc_last_avail_packed(vq, PACKED_BATCH_SIZE); Is the last_avail_idx a shared variable? Why is updated before the followin= g payload copy?=20 This will cause the other side get earlier-than-arrival data?=20 /Gavin > + > + for_each_try_unroll(i, 0, PACKED_BATCH_SIZE) { > + rte_memcpy((void *)(uintptr_t)(desc_addrs[i] + buf_offset), > + rte_pktmbuf_mtod_offset(pkts[i], void *, 0), > + pkts[i]->pkt_len); > + } > + > + return 0; > +} > + > static __rte_unused int16_t > virtio_dev_rx_single_packed(struct virtio_net *dev, > struct vhost_virtqueue *vq, > -- > 2.17.1