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 BFB02A0613 for ; Wed, 25 Sep 2019 05:38:04 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id B6C5C2BBB; Wed, 25 Sep 2019 05:38:03 +0200 (CEST) Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00040.outbound.protection.outlook.com [40.107.0.40]) by dpdk.org (Postfix) with ESMTP id 3352C1E25 for ; Wed, 25 Sep 2019 05:38:02 +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=U7IjUXLd2+t7W9u93gcnZq520+Txpgds1Inj/XY1gSI=; b=3o6/iiBNJ0gPlRMxSTHisKKX5ICJKYtmNBvaHqh8xyB4t+TLEuokthXZxpquXjUQfWcGu0XNkuKStDAJzoitubU5LYroHqPwYg5AOYTU3PDUVOs5DQn0wV1tBsCt1gDtD/ePjuUDfg2lZRfVLtDldUEQ6zQI06bcho+EEPCbZ2I= Received: from AM6PR08CA0016.eurprd08.prod.outlook.com (2603:10a6:20b:b2::28) by VI1PR08MB3856.eurprd08.prod.outlook.com (2603:10a6:803:c2::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20; Wed, 25 Sep 2019 03:37:57 +0000 Received: from DB5EUR03FT021.eop-EUR03.prod.protection.outlook.com (2a01:111:f400:7e0a::207) by AM6PR08CA0016.outlook.office365.com (2603:10a6:20b:b2::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; Wed, 25 Sep 2019 03:37:55 +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 DB5EUR03FT021.mail.protection.outlook.com (10.152.20.238) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.20 via Frontend Transport; Wed, 25 Sep 2019 03:37:54 +0000 Received: ("Tessian outbound 6481c7fa5a3c:v33"); Wed, 25 Sep 2019 03:37:53 +0000 X-CR-MTA-TID: 64aa7808 Received: from e4149d89d85c.1 (ip-172-16-0-2.eu-west-1.compute.internal [104.47.8.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com id D2B76604-1EA5-4294-B083-E6509EA133D9.1; Wed, 25 Sep 2019 03:37:48 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03lp2052.outbound.protection.outlook.com [104.47.8.52]) by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e4149d89d85c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 25 Sep 2019 03:37:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UTLYTyOHYgBonFTdnS1N9X7j2pE07T6B8tKwZ6DIIZrHB6XXLAzqvyzhnGpV8mx3/5TFzEdDAOG+uv6CKUcL7DJ4lqzrVpMb7m7P6HNxmY7hCwisV0/433vZbSo/2pUOnmW7u8ICVTp/Dk2arzUjqDqgpLbqcYHeIP9O0YdCf0xM2gUNKanFV8H5xB0OtS3ynyMzbw/TbXBLiu3GviZg8KF4nIXdN8PKmGQk45MPcZQJpSi3A3JJeLRMwrV3Gogg6PMnXXLBpTNLJp6lO60/wXVn7lbUbKMT/SiTWeEsuJI0H1pV9Nal/JYO429L33v/WUPkC05TfF9ryyItZYeEAQ== 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=U7IjUXLd2+t7W9u93gcnZq520+Txpgds1Inj/XY1gSI=; b=jYLl5Z6FPQbTfpaOR2J55vjy5SQ5WwABooYn9Ib3slVUlD5eTRQnygaULEGRbHluYU6FdK2ATAiJyOSwK8OxN13/lTrjBl/i1iaTTMYMTnKksiTtdw6JHoWDbGPqstsvXZIYyTLlpPP0aWDiz+5xU4XzW8jH3Lg6Ia9v2d/nle+JpBTMM/4/EymQye/ZvEqPLEpq4R6SonwHZd6xnCFLyWh/R02HnUaN+N7JgoFTf+R2pn+Un2gUKZlgWdGzdYKB6PB5g7UbLOTGpIW7r5gL0hZ6hY0FZaGYl8oS+ce7A1bEKUcU5S7ZLjZWnh4m1L+NeWLmODWvOcpXomeIfkKZww== 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=U7IjUXLd2+t7W9u93gcnZq520+Txpgds1Inj/XY1gSI=; b=3o6/iiBNJ0gPlRMxSTHisKKX5ICJKYtmNBvaHqh8xyB4t+TLEuokthXZxpquXjUQfWcGu0XNkuKStDAJzoitubU5LYroHqPwYg5AOYTU3PDUVOs5DQn0wV1tBsCt1gDtD/ePjuUDfg2lZRfVLtDldUEQ6zQI06bcho+EEPCbZ2I= Received: from VI1PR08MB5376.eurprd08.prod.outlook.com (52.133.244.200) by VI1PR08MB2925.eurprd08.prod.outlook.com (10.170.239.157) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2284.18; Wed, 25 Sep 2019 03:37:46 +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; Wed, 25 Sep 2019 03:37:46 +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" , nd Thread-Topic: [dpdk-dev] [PATCH v2 08/16] vhost: add flush function for burst enqueue Thread-Index: AQHVbshQyvDz2MRg6k67Hms4iIqIBqc7xaZg Date: Wed, 25 Sep 2019 03:37:46 +0000 Message-ID: References: <20190905161421.55981-2-yong.liu@intel.com> <20190919163643.24130-1-yong.liu@intel.com> <20190919163643.24130-9-yong.liu@intel.com> In-Reply-To: <20190919163643.24130-9-yong.liu@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ts-tracking-id: 2243f576-95e3-477b-8372-452b36098da6.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: 3f9eabac-e028-4750-8715-08d74169c009 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:VI1PR08MB2925; X-MS-TrafficTypeDiagnostic: VI1PR08MB2925:|VI1PR08MB3856: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true x-ms-oob-tlc-oobclassifiers: OLM:1923;OLM:1923; x-forefront-prvs: 01713B2841 X-Forefront-Antispam-Report-Untrusted: SFV:NSPM; SFS:(10009020)(4636009)(39860400002)(376002)(396003)(346002)(366004)(136003)(199004)(13464003)(189003)(316002)(476003)(6116002)(2201001)(6246003)(7736002)(9686003)(55016002)(6506007)(305945005)(74316002)(2906002)(71200400001)(2501003)(86362001)(6436002)(3846002)(53546011)(14444005)(256004)(102836004)(55236004)(33656002)(11346002)(66556008)(64756008)(446003)(229853002)(25786009)(71190400001)(81166006)(186003)(66946007)(26005)(7696005)(81156014)(4326008)(54906003)(52536014)(478600001)(66476007)(486006)(76116006)(5660300002)(66446008)(66066001)(110136005)(76176011)(99286004)(14454004)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB2925; H:VI1PR08MB5376.eurprd08.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX: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: 84bTLHuiB7NmgoplewZGRk52993UUuZ0LseJrxGv6esBOJcBJdwMKKKpvGhT1ZOQWGSHSUSylDq/cuWhVLsh4LEuIMl1tID7jL6PZ034U4ZtDv5WWIBEta/SmaxYpqHsT85OFkCWS3cpaPXiq3B2f1PmUd36NicFVyERgYZslJkN3VXmhJfDA+1T8ASQij4eRQZcspKGX4TeFyf8937xMBazGS4P6EnkL/1rcstwz6VU9oi+NEwF/NiKNJq0PE6SyO0ZSMd7r0OAle2o2tufR7D/hPmcw4Wpe5mOLOPwqgN+i2MPuIMrZUALb2QKghR3/iSZOhtdYYXdp5UZHac1BZgljY+YPRQ5vkwWs5QbU8D+jIfbDosfiKox3TlIrQMmKO0mlRf69m5YFpaB6DLrfNj/5/ZbutqO7MXiN7faHsk= 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: VI1PR08MB2925 Original-Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT021.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)(39860400002)(346002)(136003)(396003)(13464003)(199004)(189003)(5660300002)(47776003)(26005)(11346002)(316002)(25786009)(86362001)(81166006)(52536014)(76176011)(478600001)(102836004)(63350400001)(186003)(97756001)(6246003)(26826003)(7736002)(8936002)(8746002)(2201001)(81156014)(14454004)(476003)(486006)(9686003)(356004)(7696005)(46406003)(70586007)(126002)(33656002)(50466002)(2906002)(305945005)(3846002)(336012)(6506007)(6116002)(74316002)(55016002)(23726003)(4326008)(76130400001)(53546011)(70206006)(54906003)(2501003)(66066001)(99286004)(110136005)(446003)(229853002)(22756006)(14444005); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3856; H:64aa7808-outbound-1.mta.getcheckrecipient.com; FPR:; SPF:TempError; LANG:en; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; A:1; MX:1; X-MS-Office365-Filtering-Correlation-Id-Prvs: a29517b8-32b5-49fb-40a4-08d74169bb11 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600167)(710020)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:VI1PR08MB3856; NoDisclaimer: True X-Forefront-PRVS: 01713B2841 X-Microsoft-Antispam-Message-Info: nVhRgc7RBncz2GOjFECkLtTsumouOs0lZW7/+QvjC3mbdc5QWyrHQF7w2HmpjkfpTXcN3y9FSoc5qtC/9s7ywZ0N4/Qk65TdIwtlLRRkovIV0XE5BCqRy8LJG7iOw13zdeEfDTA55HWj0zEQWHpb7vMlZg2yRfJDzKHJ60tjJjGTQZcjYt24KY6gE/5IYE3St2KREiQhbqv14hip423CjBKWGhDoADRZjhn/Fa1sS+bB0yBRzKBprXSzkg4ELg91tpxfWBhwz2oZJSgctR10ummYLHv/dWd5rLaY3IAbLo83vGv1GbmU48HzjkQAwYH/4bSWKY9F9HbELieAsn/NdXFMpo5nR0cvR8HwQHSQFcv6R/DlVhtX9Qjef4Pj/8A32JF+YL6V3avnEA4KzDHEQf2DukvpOHzo/JVO7EGQCTU= X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Sep 2019 03:37:54.4875 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3f9eabac-e028-4750-8715-08d74169c009 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: VI1PR08MB3856 Subject: Re: [dpdk-dev] [PATCH v2 08/16] vhost: add flush function for burst 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, One typo and one comment about the barrier. /Gavin > -----Original Message----- > From: dev On Behalf Of Marvin Liu > Sent: Friday, September 20, 2019 12:37 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 08/16] vhost: add flush function for burst > enqueue >=20 > Flush used flags when burst enqueue function is finished. Descriptor's > flags are pre-calculated as them will be reset by vhost. s/them/they >=20 > Signed-off-by: Marvin Liu >=20 > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h > index 000648dd4..9c42c7db0 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 VIRTIO_RX_USED_FLAG (0ULL | VRING_DESC_F_AVAIL | > VRING_DESC_F_USED \ > + | VRING_DESC_F_WRITE) > +#define VIRTIO_RX_USED_WRAP_FLAG (VRING_DESC_F_WRITE) > #define PACKED_DESCS_BURST (RTE_CACHE_LINE_SIZE / \ > sizeof(struct vring_packed_desc)) >=20 > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.= c > index e2787b72e..8e4036204 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -169,6 +169,51 @@ update_shadow_packed(struct vhost_virtqueue > *vq, > vq->shadow_used_packed[i].count =3D count; > } >=20 > +static __rte_always_inline void > +flush_burst_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > + uint64_t *lens, uint16_t *ids, uint16_t flags) > +{ > + uint16_t i; > + > + UNROLL_PRAGMA(PRAGMA_PARAM) > + for (i =3D 0; i < PACKED_DESCS_BURST; 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]; > + } > + > + UNROLL_PRAGMA(PRAGMA_PARAM) > + for (i =3D 0; i < PACKED_DESCS_BURST; i++) { > + rte_smp_wmb(); Should this rte_smp_wmb() be moved above the loop? It guarantees the orderi= ngs of updates of id, len happens before the flags, But all the flags of different descriptors should not be ordered.=20 > + 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_DESCS_BURST); > + vhost_log_cache_sync(dev, vq); > + > + vq->last_used_idx +=3D PACKED_DESCS_BURST; > + 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_burst_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 VIRTIO_RX_USED_FLAG; > + else > + flags =3D VIRTIO_RX_USED_WRAP_FLAG; > + > + flush_burst_packed(dev, vq, lens, ids, flags); > +} > + > static __rte_always_inline void > update_enqueue_shadow_packed(struct vhost_virtqueue *vq, uint16_t > desc_idx, > uint32_t len, uint16_t count) > @@ -950,6 +995,7 @@ virtio_dev_rx_burst_packed(struct virtio_net *dev, > struct vhost_virtqueue *vq, > struct virtio_net_hdr_mrg_rxbuf *hdrs[PACKED_DESCS_BURST]; > uint32_t buf_offset =3D dev->vhost_hlen; > uint64_t lens[PACKED_DESCS_BURST]; > + uint16_t ids[PACKED_DESCS_BURST]; >=20 > uint16_t i; >=20 > @@ -1013,6 +1059,12 @@ virtio_dev_rx_burst_packed(struct virtio_net > *dev, struct vhost_virtqueue *vq, > pkts[i]->pkt_len); > } >=20 > + UNROLL_PRAGMA(PRAGMA_PARAM) > + for (i =3D 0; i < PACKED_DESCS_BURST; i++) > + ids[i] =3D descs[avail_idx + i].id; > + > + flush_enqueue_burst_packed(dev, vq, lens, ids); > + > return 0; > } >=20 > -- > 2.17.1