From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00042.outbound.protection.outlook.com [40.107.0.42]) by dpdk.org (Postfix) with ESMTP id 6D730378B for ; Mon, 10 Sep 2018 11:39:53 +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=akrLSgvp8XxrLNC2pDg4GJFCqecBBc3eaSl8VcY1RpU=; b=hhvWqgqMT9lG8aJijq1DcabEpdjOGtLdkR5Kd8DQkqNCpGbWqvzuGtGTc5leo9zZoZ8ZrcVYcs+T3kNRO1my6D8fT6CfjQxURvY5RZCNQofTd4/zvgh1NawowrV/aQBc8QPNUwEVsd57JdR+QQHBZ60ci9YNoiRbKR0Evb+g/9Q= Received: from VI1PR08MB3167.eurprd08.prod.outlook.com (52.133.15.142) by VI1PR08MB3166.eurprd08.prod.outlook.com (52.133.15.141) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1122.15; Mon, 10 Sep 2018 09:39:52 +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 09:39:52 +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+a6TpSBUA Date: Mon, 10 Sep 2018 09:39:52 +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; VI1PR08MB3166; 6:Yh9n0PBvZCuEpoPsBfCc3FKLUgkKaF5I9dXIdw8Eb8BAH2heD2aGCuL7njy5PoS42p9czfKy7wEUB5a33u8f6ntxy88lidypVYUauRj375o15bL21b+mrRgdv/ajaHYOZ2NjmFuHXIjG+vsJJkdmEUh5UAq8O1PPqdyi1hYo9cUNy4yAiViz1X07NLea6hsZ4abwXsGYmFovHmrEo+o2yo8cU64xwraa/Wbdw4E61Sz5CUiJ8wgFZDMfQR2p28XggSW+jWPo24TQfS2t9sDH5zh7aTciI39ymm0Gf/kq6l1/rvvOzzhcTflihF56elcNuVqboDii8lSwqnKG/5ZCEUt8GSfGaB0lz3/IXMYL30Ci/uLtcHf5yLEl38HY+tb23OdrlQIBWE8tsx8BNZViuAilxEkDdHeKemsGMpXKjkfyrSa+vdA6UTwearss9kPlR8FTVqOhywXSNphvW/2Wlg==; 5:ahiA+sEfyLRrQNYZD2pS1kfgxNv6NBuX0ur+MX6wx5c5s7J+sIwDotPuBRNUwcyYy6uUL530UqJ0a1ZCuaTzEWQAZkVlQtKhqe068Lxnv5orOibRXnijPlhJgQYoQP2Dj9qxb8FfTHsSIFm51BjfYIID8GvdNXo4gnHrwqUJTkc=; 7:E4/TKot++KwQZnRJ1pTtp2gSfDOPmtmuAVMVyBK708b7vrJnHh9p8sWVWNQ4A0fEn5XzXGC8rF2D8UenjsEjA3KKu39VBWnaYKGG/FLoz31QhPB/3FKEhkHBrYUosG/1Buai06MeUP5opHVF+18kih/qzczOwwcMlcketCMi+jcdve3Si8dbQPAIBzGSJZO0RXFI6vbks/tTBFOJ95UzHZ7TgUEbjbovQA0xcgGvzofHDUt3ggbwbENcKW1tIBFV x-ms-exchange-antispam-srfa-diagnostics: SOS; x-ms-office365-filtering-correlation-id: 522d257d-ebf9-4f92-185b-08d617015bed x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:VI1PR08MB3166; x-ms-traffictypediagnostic: VI1PR08MB3166: 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)(3002001)(93006095)(93001095)(3231311)(944501410)(52105095)(10201501046)(6055026)(149027)(150027)(6041310)(20161123562045)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123564045)(201708071742011)(7699050); SRVR:VI1PR08MB3166; BCL:0; PCL:0; RULEID:; SRVR:VI1PR08MB3166; x-forefront-prvs: 07915F544A x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(346002)(396003)(136003)(366004)(376002)(39850400004)(189003)(199004)(13464003)(40434004)(106356001)(81156014)(5660300001)(316002)(110136005)(54906003)(6116002)(105586002)(8936002)(486006)(14454004)(72206003)(256004)(14444005)(186003)(81166006)(4326008)(3846002)(446003)(11346002)(476003)(86362001)(25786009)(5024004)(478600001)(33656002)(97736004)(305945005)(7696005)(26005)(9686003)(53546011)(6246003)(2906002)(6506007)(76176011)(74316002)(99286004)(55016002)(66066001)(102836004)(229853002)(6436002)(2900100001)(2501003)(53936002)(7736002)(5250100002)(68736007); DIR:OUT; SFP:1101; SCL:1; SRVR:VI1PR08MB3166; H:VI1PR08MB3167.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-microsoft-antispam-message-info: 3M+E+irxm3XRODUQU/4K+3My7Qg2lg5qB3ZAPsW//yGdLiWH7ElEkLaG+h3ZhnjLXwsTwnQh/xX/PwXhFevc00ozP6yVy04dGLyaqPYjOpUg+TU7Iat4hog69tIG4HJ8JBimrC57ucLC30f//dWNDXqmSZsATJlEEKn/eq+Zo4m/vBSoVHuQghqQSY8b3sNfRZVYRryy+up0GqxBwyDCt84uCCUAUESUS8eS7qXzxMZM1aBnHk/lVfVl8nWYHoEGfEu6T9K/TMRD0YbnGA2UQUdY4tFpppK3uo36hKBMSbL3UZV3gWEjzQnjQsow7NXePSPzVvLPuLx9mynXMQ5OS4bvevkLAphG6myiGIfvfxQ= 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: 522d257d-ebf9-4f92-185b-08d617015bed X-MS-Exchange-CrossTenant-originalarrivaltime: 10 Sep 2018 09:39:52.1152 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3166 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 09:39:53 -0000 One more comment: > -----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; Should be "+=3D" here? > +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); > +descs_used++; > +} while ((txm =3D txm->next) !=3D NULL); > + > +desc[idx].flags &=3D ~VRING_DESC_F_NEXT; > + > +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.