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 6DC3AA0613 for ; Thu, 26 Sep 2019 11:24:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 882FF1BEF5; Thu, 26 Sep 2019 11:24:43 +0200 (CEST) Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130079.outbound.protection.outlook.com [40.107.13.79]) by dpdk.org (Postfix) with ESMTP id 62E8B1BEF2 for ; Thu, 26 Sep 2019 11:24:42 +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=fkUqC4Q8D2k04GyCy5Ro25+sVOVlcaRrlRtc6TC0hqI=; b=DuvwgB0IRofHtt0/XTOHZ8asIi7t22A6rC2CN4j1kE2UDZYSdsG64M34UoHptRHuIg+/tNllEJ6G+xRKAUTkWAj7JMRfzUG0Me0P+VFae/gdU3TGrK/zBxqnIwbfV3ojLZ0/7nMfM0npi2o4XWY0/3vCztIasD5n90zYc2wR+ic= Received: from HE1PR0802CA0019.eurprd08.prod.outlook.com (2603:10a6:3:bd::29) by DB7PR08MB3002.eurprd08.prod.outlook.com (2603:10a6:5:20::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2305.17; Thu, 26 Sep 2019 09:24:40 +0000 Received: from DB5EUR03FT051.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::208) by HE1PR0802CA0019.outlook.office365.com (2603:10a6:3:bd::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.17 via Frontend Transport; Thu, 26 Sep 2019 09:24:40 +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 DB5EUR03FT051.mail.protection.outlook.com (10.152.21.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.2305.15 via Frontend Transport; Thu, 26 Sep 2019 09:24:39 +0000 Received: ("Tessian outbound 851a1162fca7:v33"); Thu, 26 Sep 2019 09:24:35 +0000 X-CR-MTA-TID: 64aa7808 Received: from 601ab5e7100b.1 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.0.55]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id F54DA114-9265-4D1E-8321-D22109315004.1; Thu, 26 Sep 2019 09:24:30 +0000 Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-he1eur01lp2055.outbound.protection.outlook.com [104.47.0.55]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 601ab5e7100b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384); Thu, 26 Sep 2019 09:24:30 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FnRq1L6HLG/ciulSNJmWCcKvo16riMFYsW8rP362+f4quvw9QrOZmivC7f/MkZ20ZvcUMwrpZjH9+BPCzA7vnEmE5xPJ04kDiRGdwXMvuojTLFZ3BMAfe88DTOuu6ib8IHbfhb6FfnDPj3bY2AwOhbIB57I0yVsMqDXBbyKK0s9wEEjYwBfW0vqhVsD3VBcsYjVD/y5IEcKK9FpKO7qJ8tplM3j7xVT6Yxxlh9kor98EoKYGrL44bHYehN6C4Ywdk/fNfo8ZE/gkhaoUqaYuAS+IWZNbQ0dktvNClK+3AByW6mdohw010Gl4063wQ0lAh2hVctoDYeLhop1TF2Wt4w== 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=fkUqC4Q8D2k04GyCy5Ro25+sVOVlcaRrlRtc6TC0hqI=; b=MJH3PFrCtJIJjPVdAF2O6A8vK8tNseGl1aMzndblcL1NUg7DKbMV2KNSegcj0pA4eTfsJbdnP7TxxSJuCfFN38WE1jSYn98tePkalTrkF6ND99s0akSyKLC7/aOXb8hIFgysLO/+vyBPAofyhcOodMETe/Q+x+2xAkfQ2gxKpo4wTz6ITWFHiBFFiZJMijujvo9GDiaBf5qX81dIRVQcUlmWKzdeXfde1KfTq1O1CcR2vYjhyR+MGMJKnH4aWfU6L1/Oq0dMVEoYI1YSwrbKly8a3HVIWTLDIr/4DXcAW4udid4ZNzfSxzP+JMSZjzszUGOjcc/F7xbcTtwdrqbQCA== 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=fkUqC4Q8D2k04GyCy5Ro25+sVOVlcaRrlRtc6TC0hqI=; b=DuvwgB0IRofHtt0/XTOHZ8asIi7t22A6rC2CN4j1kE2UDZYSdsG64M34UoHptRHuIg+/tNllEJ6G+xRKAUTkWAj7JMRfzUG0Me0P+VFae/gdU3TGrK/zBxqnIwbfV3ojLZ0/7nMfM0npi2o4XWY0/3vCztIasD5n90zYc2wR+ic= Received: from VI1PR08MB5376.eurprd08.prod.outlook.com (52.133.244.200) by VI1PR08MB3712.eurprd08.prod.outlook.com (20.178.14.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Thu, 26 Sep 2019 09:24:27 +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; Thu, 26 Sep 2019 09:24:27 +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 v3 07/15] vhost: add flush function for batch enqueue Thread-Index: AQHVc4QtclH7inEG6Uqezk3ltFUUj6c9r+cw Date: Thu, 26 Sep 2019 09:24:27 +0000 Message-ID: References: <20190919163643.24130-2-yong.liu@intel.com> <20190925171329.63734-1-yong.liu@intel.com> <20190925171329.63734-8-yong.liu@intel.com> In-Reply-To: <20190925171329.63734-8-yong.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 853f0df2-34c7-451f-bc91-7b96d8237b9b.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: 0409d87a-802d-4615-2372-08d742635b04 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam-Untrusted: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600167)(711020)(4605104)(1401327)(4618075)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:VI1PR08MB3712; X-MS-TrafficTypeDiagnostic: VI1PR08MB3712:|DB7PR08MB3002: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:338;OLM:338; x-forefront-prvs: 0172F0EF77 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(396003)(376002)(39860400002)(366004)(136003)(346002)(189003)(199004)(13464003)(81156014)(316002)(71200400001)(71190400001)(55236004)(66476007)(55016002)(6436002)(4326008)(33656002)(25786009)(66946007)(76116006)(66446008)(9686003)(64756008)(66556008)(99286004)(2201001)(7696005)(86362001)(6246003)(66066001)(11346002)(7736002)(14454004)(6506007)(53546011)(2501003)(2906002)(76176011)(256004)(74316002)(14444005)(446003)(52536014)(26005)(305945005)(6116002)(5660300002)(3846002)(229853002)(186003)(478600001)(102836004)(8676002)(81166006)(8936002)(54906003)(476003)(486006)(110136005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3712; 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: fnI5IBuNbbYwsaNhChhIYQG+V+WrXk+TvwHhvCtv0ozNXOVE7jGG4wbcinFaqAragpnnkDIKLjwKkAiB7p5UUTrSCuKWKHEpk0QUhn/Un+W7U0A4esCU6nRYHCzvcvuE4J2Sv4Wn+DBW0ueHiPEfhas4q2HSI01EKCQZM2MiIDW5VWvNxFQpuxPzJ4C1QmR2ONTCOVtC08kudAlbLVxCiuZeJcoIjHd3E/yvT4o0hPFjQN0AVNou7AgeARWTR+DMG/dsycCX4lBMYFab+yhnHkVATcvzd2RVKcU3vkLlCtrqlAFe50eb9AyAy60vJ4mWwQOtcsoW6e9PM2eL8qfa7Emhqcpc58pWQX19wFhuxrHh7Pc1lrzJIaa6JWKfY/n9YZ9G7OzcKYiBH9SYUw/P/8Z+iVPKfVHINSg83YmtOeM= 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: VI1PR08MB3712 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT051.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)(136003)(376002)(39860400002)(346002)(396003)(13464003)(189003)(199004)(186003)(6506007)(26005)(102836004)(336012)(63350400001)(2501003)(53546011)(81166006)(81156014)(356004)(8936002)(52536014)(5660300002)(8746002)(8676002)(70206006)(22756006)(74316002)(70586007)(126002)(11346002)(446003)(476003)(305945005)(229853002)(46406003)(478600001)(316002)(14444005)(7736002)(14454004)(76130400001)(110136005)(486006)(66066001)(54906003)(25786009)(26826003)(50466002)(23726003)(86362001)(99286004)(2906002)(6116002)(33656002)(2201001)(55016002)(97756001)(3846002)(7696005)(6246003)(76176011)(4326008)(9686003)(47776003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB7PR08MB3002; 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: 90f4c475-4141-42ab-1b26-08d7426353ee NoDisclaimer: True X-Forefront-PRVS: 0172F0EF77 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fl3ZTmuAH/NrQeHHpo6HgygtvH2mzV3cqXEiGnEovel29Uk4I0liTsRY+fa0T3+vRULwj25L7ZeWsQDHdOxPo+9peDNHTV3/eiKXqenav9Juo03z7HlX8wqwjiIOG8uPoMrR9ZTv/AhW/DpoASuHYoiC5jEABrTMUEsaR+myLcTlJcyK3AiBSruT7EuCA4rMrSIjZIKWQypiikS8Gxd4DtUHKaJ/T467m01MDxUehvzZxcmwsEwSGBdgzyUpqm4qU+e3er43BfYpq2WetXs2HUBh73Vwk5V/mKpHDtugz27vdp/TiCxw+GTJElmtH9+naVc/Htr3smsnX7LE5Aog3+NxBiYG4vB9dK//D3rfJ3xlzxw1gBhzImbWmH33yGkxOSkjC/Snv1xCrO1aQXkRIBuDj7oA0F2pKfELeLicG+o= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2019 09:24:39.1927 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0409d87a-802d-4615-2372-08d742635b04 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: DB7PR08MB3002 Subject: Re: [dpdk-dev] [PATCH v3 07/15] vhost: add flush function for 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" > -----Original Message----- > From: Marvin Liu > Sent: Thursday, September 26, 2019 1:13 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 v3 07/15] vhost: add flush function for batch enqueue >=20 > Flush used flags when batched enqueue function is finished. Descriptor's > flags are pre-calculated as they will be reset by vhost. >=20 > Signed-off-by: Marvin Liu >=20 > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h > index 18a207fc6..7bf9ff9b7 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -39,6 +39,9 @@ >=20 > #define VHOST_LOG_CACHE_NR 32 >=20 > +#define PACKED_RX_USED_FLAG (0ULL | VRING_DESC_F_AVAIL | > VRING_DESC_F_USED \ > + | VRING_DESC_F_WRITE) > +#define PACKED_RX_USED_WRAP_FLAG (VRING_DESC_F_WRITE) > #define PACKED_BATCH_SIZE (RTE_CACHE_LINE_SIZE / \ > sizeof(struct vring_packed_desc)) > #define PACKED_BATCH_MASK (PACKED_BATCH_SIZE - 1) > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.= c > index f85619dc2..a629e66d4 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -169,6 +169,49 @@ update_shadow_used_ring_packed(struct > vhost_virtqueue *vq, > vq->shadow_used_packed[i].count =3D count; > } >=20 > +static __rte_always_inline void > +flush_used_batch_packed(struct virtio_net *dev, struct vhost_virtqueue > *vq, > + uint64_t *lens, uint16_t *ids, uint16_t flags) > +{ > + uint16_t i; > + > + UNROLL_PRAGMA(UNROLL_PRAGMA_PARAM) > + for (i =3D 0; i < PACKED_BATCH_SIZE; i++) { > + vq->desc_packed[vq->last_used_idx + i].id =3D ids[i]; > + vq->desc_packed[vq->last_used_idx + i].len =3D lens[i]; > + } > + > + rte_smp_wmb(); > + UNROLL_PRAGMA(UNROLL_PRAGMA_PARAM) > + for (i =3D 0; i < PACKED_BATCH_SIZE; i++) > + vq->desc_packed[vq->last_used_idx + i].flags =3D flags; > + > + vhost_log_cache_used_vring(dev, vq, vq->last_used_idx * > + sizeof(struct vring_packed_desc), > + sizeof(struct vring_packed_desc) * > + PACKED_BATCH_SIZE); > + vhost_log_cache_sync(dev, vq); > + > + vq->last_used_idx +=3D PACKED_BATCH_SIZE; > + if (vq->last_used_idx >=3D vq->size) { > + vq->used_wrap_counter ^=3D 1; > + vq->last_used_idx -=3D vq->size; > + } > +} > + > +static __rte_always_inline void > +flush_enqueue_batch_packed(struct virtio_net *dev, struct > vhost_virtqueue *vq, > + uint64_t *lens, uint16_t *ids) > +{ > + uint16_t flags =3D 0; > + > + if (vq->used_wrap_counter) > + flags =3D PACKED_RX_USED_FLAG; > + else > + flags =3D PACKED_RX_USED_WRAP_FLAG; > + flush_used_batch_packed(dev, vq, lens, ids, flags); > +} > + > static __rte_always_inline void > update_enqueue_shadow_used_ring_packed(struct vhost_virtqueue *vq, > uint16_t desc_idx, uint32_t len, uint16_t count) > @@ -937,6 +980,7 @@ virtio_dev_rx_batch_packed(struct virtio_net *dev, > struct vhost_virtqueue *vq, > 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 ids[PACKED_BATCH_SIZE]; > uint16_t i; >=20 > if (unlikely(avail_idx & PACKED_BATCH_MASK)) > @@ -1003,6 +1047,12 @@ virtio_dev_rx_batch_packed(struct virtio_net > *dev, struct vhost_virtqueue *vq, > pkts[i]->pkt_len); > } >=20 > + UNROLL_PRAGMA(UNROLL_PRAGMA_PARAM) > + for (i =3D 0; i < PACKED_BATCH_SIZE; i++) > + ids[i] =3D descs[avail_idx + i].id; > + > + flush_enqueue_batch_packed(dev, vq, lens, ids); > + > return 0; > } Reviewed-by: Gavin Hu > -- > 2.17.1