From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60071.outbound.protection.outlook.com [40.107.6.71]) by dpdk.org (Postfix) with ESMTP id BD3E011A4 for ; Mon, 10 Sep 2018 09:13:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector1-arm-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6Ua7A2QYkXy9w0wLF6WBl4+MwcUqMAQveQih8sLEs/c=; b=U8nV52Qg7nNDv8Ka5i85YMPzLcMudPLoGow/nZ3vTcPas2lQYgmjEnumTruLd9jBYkZI7YaBUUmOg3N0rdujjpNq1sePd2gE9mseByxqFwU2LapigvPhAR8A/mXJpBLD1Ek3uRcnOtY4TWeqxFdSsU85EHRQuk2lsNbWlivb8cg= Received: from VI1PR08MB3167.eurprd08.prod.outlook.com (52.133.15.142) by VI1PR08MB0861.eurprd08.prod.outlook.com (10.164.93.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.17; Mon, 10 Sep 2018 07:13:56 +0000 Received: from VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::b91d:e285:4647:f3e8]) by VI1PR08MB3167.eurprd08.prod.outlook.com ([fe80::b91d:e285:4647:f3e8%2]) with mapi id 15.20.1122.019; Mon, 10 Sep 2018 07:13:56 +0000 From: "Gavin Hu (Arm Technology China)" To: Jens Freimann , "dev@dpdk.org" CC: "tiwei.bie@intel.com" , "maxime.coquelin@redhat.com" Thread-Topic: [dpdk-dev] [PATCH v5 07/11] net/virtio: implement transmit path for packed queues Thread-Index: AQHURg5dHbJBdkkD0US9OfPNZD3+a6TpHyGg Date: Mon, 10 Sep 2018 07:13:56 +0000 Message-ID: References: <20180906181947.20646-1-jfreimann@redhat.com> <20180906181947.20646-8-jfreimann@redhat.com> In-Reply-To: <20180906181947.20646-8-jfreimann@redhat.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Gavin.Hu@arm.com; x-originating-ip: [113.29.88.7] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1; VI1PR08MB0861; 6:N3jpftXT1a5B5XLh9pQMm7SKZcgWCv/3BxYHYFJSqCGNNCEtHl5ioertox0Yy2nTDwjb2Ov3y8KtSnmqtXw8s8TOBYXJ4uekMhpIopFrGy7cqCNICE9bm7m7xsyEmKMJtZuLomrtLV87BG1ubstZqaN3DJY6KxK5fK4Y4C0ta19jIw1hArFTmhuH+lin/1ulaTd/k5qT3jDCUpACjasXq4HneL19o/Zkpmta8lp9X3/hrsVGm4QNq4Gk8bkGZAs8zstNfDR9flMduZ9v53/OvQtvQyRseZk6LjG96lzL+2osZYKAn6ikWg6e85mWV+mwmlPzdWwo52lJwry4FMuhDbCSy/u+y3O+g03uYBmWnY1DQ5Wu2wOPLi8dWnAEriXGA04Uu1kbHev+IV7WOnh3pAHH0zXmV7Ym+lcWv6bymA7y6SWS7ICrzAsyUYXxcTkPX1rC3LE2wEHXJ2J+ROr9hg==; 5:NXPm/YkQCpl3nrbwBqBBtu826f1TCfqH/W170h2BtSVSdQ2HggwzkXcLfiryp/NijJKpsll46fopl5nyrXczkpoY/iKNrPxSTS1pkb0qMFp3JY8oy8c7t1aH9dlQzsTuxxHTBPLbqoSTJzPEDl3i/It3eftbh5xUGgEhO+CclVU=; 7:JRZKos79z/zpPlZTaP1WLSvYKKu2jtyn/hjwND1yhWW1zx6X+zOrXYc+Tqa1E8KqGiSbtu8nEwPigvaMXa6jW6/ri2g00t/4XNAOrFyMn5eUDiQsFr27uA2N5IDidYQvCY8Uh+CdSsOGvpiTMTccIJnbtrSRPo274UFeZcHzH8cX8IC7lXFMjREGhR8LRC+yCKZUdy2o891W6DwgElQ43OcrcVNP4p45NyFRYPbjMovGyLJAvygL6s0KWYCwg9E0 x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 2ef077b1-8560-49a8-f64d-08d616ecf90f x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB0861; x-ms-traffictypediagnostic: VI1PR08MB0861: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(131327999870524)(103651359005742)(228905959029699); x-ms-exchange-senderadcheck: 1 x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(3231311)(944501410)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(201708071742011)(7699050); SRVR:VI1PR08MB0861; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB0861; x-forefront-prvs: 07915F544A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(376002)(136003)(346002)(366004)(39850400004)(396003)(199004)(189003)(40434004)(13464003)(5250100002)(14444005)(5024004)(81166006)(229853002)(81156014)(6246003)(97736004)(256004)(105586002)(33656002)(106356001)(6116002)(3846002)(2906002)(25786009)(9686003)(55016002)(4326008)(6436002)(2501003)(53936002)(478600001)(76176011)(7696005)(99286004)(2900100001)(316002)(110136005)(54906003)(5660300001)(305945005)(486006)(14454004)(72206003)(476003)(446003)(11346002)(186003)(53546011)(7736002)(102836004)(55236004)(26005)(6506007)(8936002)(66066001)(74316002)(86362001)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB0861; H:VI1PR08MB3167.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-microsoft-antispam-message-info: 5YTk9vqiqTMkSJJVL1ZOvacybYB4N/EGjG3s3w6ES/MUy7lt3hT128cSksiK8zi/LWTtTY1cvGLhmWNepwsy+rU8SJ4zNb9RmIUyMCvhZC8WO7aJV2+ZLft6BxKWH821CfJ00sCZenEtvCqovd0T2ttzpM12nrsHEpuQs4qImLYkOORWrpVTwk7DsUCT0ltOkfLOvoRaLZfU2yc8WfcDdjb0fCekDOSlmmnAoqWxlnSsuz8/foMhQCo/FaOprVkY77qj5H7pGa0u/3kJOTa+ITtMVM0rJK6hfmEBqaGmiZd64I8UxIlESAKgSsp0QWy6cQWQM4GpoRGyZBn8mGbY90LX86eJ2er0V194hPAtrCE= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2ef077b1-8560-49a8-f64d-08d616ecf90f X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Sep 2018 07:13:56.4748 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB0861 Subject: Re: [dpdk-dev] [PATCH v5 07/11] net/virtio: implement transmit path for packed queues 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: , X-List-Received-Date: Mon, 10 Sep 2018 07:13:59 -0000 > -----Original Message----- > From: dev On Behalf Of Jens Freimann > Sent: Friday, September 7, 2018 2:20 AM > To: dev@dpdk.org > Cc: tiwei.bie@intel.com; maxime.coquelin@redhat.com > Subject: [dpdk-dev] [PATCH v5 07/11] net/virtio: implement transmit path > for packed queues > > This implements the transmit path for devices with support for packed > virtqueues. > > Add the feature bit and enable code to > add buffers to vring and mark descriptors as available. > > Signed-off-by: Jens Freiman > --- > drivers/net/virtio/virtio_ethdev.c | 8 +- > drivers/net/virtio/virtio_ethdev.h | 2 + > drivers/net/virtio/virtio_rxtx.c | 113 ++++++++++++++++++++++++++++- > 3 files changed, 121 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/virtio/virtio_ethdev.c > b/drivers/net/virtio/virtio_ethdev.c > index ad91f7f82..d2c5755bb 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -384,6 +384,8 @@ virtio_init_queue(struct rte_eth_dev *dev, uint16_t > vtpci_queue_idx) > vq->hw =3D hw; > vq->vq_queue_index =3D vtpci_queue_idx; > vq->vq_nentries =3D vq_size; > +if (vtpci_packed_queue(hw)) > +vq->vq_ring.avail_wrap_counter =3D 1; > > /* > * Reserve a memzone for vring elements @@ -1338,7 +1340,11 @@ > set_rxtx_funcs(struct rte_eth_dev *eth_dev) > eth_dev->rx_pkt_burst =3D &virtio_recv_pkts; > } > > -if (hw->use_inorder_tx) { > +if (vtpci_packed_queue(hw)) { > +PMD_INIT_LOG(INFO, "virtio: using virtio 1.1 Tx path on > port %u", > +eth_dev->data->port_id); > +eth_dev->tx_pkt_burst =3D virtio_xmit_pkts_packed; > +} else if (hw->use_inorder_tx) { > PMD_INIT_LOG(INFO, "virtio: using inorder Tx path on > port %u", > eth_dev->data->port_id); > eth_dev->tx_pkt_burst =3D virtio_xmit_pkts_inorder; diff --git > a/drivers/net/virtio/virtio_ethdev.h b/drivers/net/virtio/virtio_ethdev.h > index b726ad108..04161b461 100644 > --- a/drivers/net/virtio/virtio_ethdev.h > +++ b/drivers/net/virtio/virtio_ethdev.h > @@ -79,6 +79,8 @@ uint16_t virtio_recv_mergeable_pkts_inorder(void > *rx_queue, > > uint16_t virtio_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, > uint16_t nb_pkts); > +uint16_t virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf > **tx_pkts, > +uint16_t nb_pkts); > > uint16_t virtio_xmit_pkts_inorder(void *tx_queue, struct rte_mbuf > **tx_pkts, > uint16_t nb_pkts); > diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio= _rxtx.c > index eb891433e..12787070e 100644 > --- a/drivers/net/virtio/virtio_rxtx.c > +++ b/drivers/net/virtio/virtio_rxtx.c > @@ -38,6 +38,112 @@ > #define VIRTIO_DUMP_PACKET(m, len) do { } while (0) #endif > > + > +/* Cleanup from completed transmits. */ static void > +virtio_xmit_cleanup_packed(struct virtqueue *vq) { > +uint16_t idx; > +uint16_t size =3D vq->vq_nentries; > +struct vring_desc_packed *desc =3D vq->vq_ring.desc_packed; > +struct vq_desc_extra *dxp; > + > +idx =3D vq->vq_used_cons_idx; > +while (desc_is_used(&desc[idx], &vq->vq_ring) && > + vq->vq_free_cnt < size) { > +dxp =3D &vq->vq_descx[idx]; > +vq->vq_free_cnt +=3D dxp->ndescs; > +idx =3D dxp->ndescs; > +idx =3D idx >=3D size ? idx - size : idx; > +} > +} > + > +uint16_t > +virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts, > + uint16_t nb_pkts) > +{ > +struct virtnet_tx *txvq =3D tx_queue; > +struct virtqueue *vq =3D txvq->vq; > +uint16_t i; > +struct vring_desc_packed *desc =3D vq->vq_ring.desc_packed; > +uint16_t idx, prev; > +struct vq_desc_extra *dxp; > + > +if (unlikely(nb_pkts < 1)) > +return nb_pkts; > + > +PMD_TX_LOG(DEBUG, "%d packets to xmit", nb_pkts); > + > +if (likely(vq->vq_free_cnt < vq->vq_free_thresh)) > +virtio_xmit_cleanup_packed(vq); > + > +for (i =3D 0; i < nb_pkts; i++) { > +struct rte_mbuf *txm =3D tx_pkts[i]; > +struct virtio_tx_region *txr =3D txvq->virtio_net_hdr_mz->addr; > +uint16_t head_idx; > +int wrap_counter; > +int descs_used; > + > +if (unlikely(txm->nb_segs + 1 > vq->vq_free_cnt)) { > +virtio_xmit_cleanup_packed(vq); > + > +if (unlikely(txm->nb_segs + 1 > vq->vq_free_cnt)) { > +PMD_TX_LOG(ERR, > + "No free tx descriptors to transmit"); > +break; > +} > +} > + > +txvq->stats.bytes +=3D txm->pkt_len; > + > +vq->vq_free_cnt -=3D txm->nb_segs + 1; > + > +wrap_counter =3D vq->vq_ring.avail_wrap_counter; > +idx =3D vq->vq_avail_idx; > +head_idx =3D idx; > + > +dxp =3D &vq->vq_descx[idx]; > +if (dxp->cookie !=3D NULL) > +rte_pktmbuf_free(dxp->cookie); > +dxp->cookie =3D txm; > + > +desc[idx].addr =3D txvq->virtio_net_hdr_mem + > + RTE_PTR_DIFF(&txr[idx].tx_hdr, txr); > +desc[idx].len =3D vq->hw->vtnet_hdr_size; > +desc[idx].flags =3D VRING_DESC_F_NEXT | > +VRING_DESC_F_AVAIL(vq- > >vq_ring.avail_wrap_counter) | > +VRING_DESC_F_USED(!vq- > >vq_ring.avail_wrap_counter); > +descs_used =3D 1; > + > +do { > +idx =3D update_pq_avail_index(vq); > +desc[idx].addr =3D > VIRTIO_MBUF_DATA_DMA_ADDR(txm, vq); > +desc[idx].len =3D txm->data_len; > +desc[idx].flags =3D VRING_DESC_F_NEXT | > +VRING_DESC_F_AVAIL(vq- > >vq_ring.avail_wrap_counter) | > +VRING_DESC_F_USED(!vq- > >vq_ring.avail_wrap_counter); According to spec, all the flags update should be moved after the memory ba= rriers. > +descs_used++; > +} while ((txm =3D txm->next) !=3D NULL); > + > +desc[idx].flags &=3D ~VRING_DESC_F_NEXT; Ditto > + > +rte_smp_wmb(); > +prev =3D (idx > 0 ? idx : vq->vq_nentries) - 1; > +desc[prev].index =3D head_idx; //FIXME > +desc[head_idx].flags =3D > +(VRING_DESC_F_AVAIL(wrap_counter) | > + VRING_DESC_F_USED(!wrap_counter)); > + > +vq->vq_descx[head_idx].ndescs =3D descs_used; > +idx =3D update_pq_avail_index(vq); > +} > + > +txvq->stats.packets +=3D i; > +txvq->stats.errors +=3D nb_pkts - i; > + > +return i; > +} > + > int > virtio_dev_rx_queue_done(void *rxq, uint16_t offset) { @@ -736,7 +842,1= 2 > @@ virtio_dev_tx_queue_setup_finish(struct rte_eth_dev *dev, > if (hw->use_inorder_tx) > vq->vq_ring.desc[vq->vq_nentries - 1].next =3D 0; > > -VIRTQUEUE_DUMP(vq); > +if (vtpci_packed_queue(hw)) { > +vq->vq_ring.avail_wrap_counter =3D 1; > +} > + > +if (!vtpci_packed_queue(hw)) > +VIRTQUEUE_DUMP(vq); > > return 0; > } > -- > 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.