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 D4A42A2E1B for ; Thu, 5 Sep 2019 12:31:11 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9849A2C19; Thu, 5 Sep 2019 12:31:10 +0200 (CEST) Received: from mailout1.w1.samsung.com (mailout1.w1.samsung.com [210.118.77.11]) by dpdk.org (Postfix) with ESMTP id 118D12C08 for ; Thu, 5 Sep 2019 12:31:09 +0200 (CEST) Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20190905103108euoutp01b06160cd4a9818abf55868ccc227a259~BhCuruItr2113121131euoutp01i for ; Thu, 5 Sep 2019 10:31:08 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20190905103108euoutp01b06160cd4a9818abf55868ccc227a259~BhCuruItr2113121131euoutp01i DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1567679468; bh=Cbd9W2zDizgSf5lxVZG1f5FTWr4O+o5p754M6JJKzr4=; h=Subject:To:From:Date:In-Reply-To:References:From; b=bOp1ZM6TP5g56X7kb3sIP9PVTsNN9LqQqWq7Rn69SRpxojKwShIIh7S/+55eomBPS 424asf8FHdDC1orsTVFKQU2tU6hi+nsAKw8PgGIass3R2IL15m7lVKoqw2j5riwmWV D5bDr7mMe99pC7qM8B32xJWGAsKCagPBcpbxWMRo= Received: from eusmges3new.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20190905103107eucas1p28d9f4e36dc30589868415bfc2bd7744d~BhCuJ1m0I0674106741eucas1p2g; Thu, 5 Sep 2019 10:31:07 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges3new.samsung.com (EUCPMTA) with SMTP id F5.9F.04374.BE3E07D5; Thu, 5 Sep 2019 11:31:07 +0100 (BST) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20190905103107eucas1p2296feb0cc7be0538332dc698a72585bb~BhCtcdQGd0687306873eucas1p2O; Thu, 5 Sep 2019 10:31:07 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20190905103107eusmtrp1169e3635136904079cf3e6d26431437a~BhCtbwlgm2738527385eusmtrp1v; Thu, 5 Sep 2019 10:31:07 +0000 (GMT) X-AuditID: cbfec7f5-4f7ff70000001116-5a-5d70e3eb9de1 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id DB.21.04117.AE3E07D5; Thu, 5 Sep 2019 11:31:06 +0100 (BST) Received: from [106.109.129.180] (unknown [106.109.129.180]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20190905103106eusmtip1bbd0b382708ca3a62a0fafeb71520cdd~BhCtBgxAJ2814528145eusmtip14; Thu, 5 Sep 2019 10:31:06 +0000 (GMT) To: Marvin Liu , tiwei.bie@intel.com, maxime.coquelin@redhat.com, dev@dpdk.org From: Ilya Maximets Message-ID: <9674491d-4ce0-ea60-e92c-4be2e3d540b8@samsung.com> Date: Thu, 5 Sep 2019 13:31:05 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190905161421.55981-3-yong.liu@intel.com> Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Brightmail-Tracker: H4sIAAAAAAAAA02SbUhTYRTHfXbv3a4vk8dpeDJpNUxIdKZFDQrN6MMgoj6FpGLL3abkXtic ZQmJma8RqdiaJVlmpr2Im86yoTRF2YwRYWUIJiroFA11fpiW5XaV/PY7/3POc/5/eGhC8IiK oHNUeYxWJc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hdbFyMXUM17RokFr9+ydDGy cwgLxEjscgMpERFIkdgzfSo7xBhziY3rGlhAbDYBHYlTq48wdjFycPAK2ElM7wTbxCKgInHq 8VQmEFtUIELi8I5ZjCA2r4CgxMmZT8BaOQUsJC7c2wpmMwuoS/yZd4kZwhaXaPqykhXClpfY /nYO8wRGwVlI2mchaZmFpGUWkpYFjCyrGEVSS4tz03OLjfSKE3OLS/PS9ZLzczcxAuNm27Gf W3Ywdr0LPsQowMGoxMP7YG5+rBBrYllxZe4hRgkOZiUR3vUbC2KFeFMSK6tSi/Lji0pzUosP MZoCPTeRWUo0OR8Y03kl8YamhuYWlobmxubGZhZK4rwdAgdjhATSE0tSs1NTC1KLYPqYODil Ghi1Gv/WCnv+0Fn/qubb+5KyZTEHj9rV3Qw11pjKpcL0g6E1ZsLPjMk7W46kaUbNPsXGsY9T 6IOjROLXnhym4OUBxRpnnKetD6j623Oq9+dkVd8nl76v12sRMZS41nLh8cPvwUWdnT3tdQds 89YGCb99uvfVpnnzH4lPNrEsNxTM3imfWn/Z7Y4SS3FGoqEWc1FxIgB2obCssQIAAA== X-CMS-MailID: 20190905103107eucas1p2296feb0cc7be0538332dc698a72585bb X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20190905103107eucas1p2296feb0cc7be0538332dc698a72585bb X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20190905103107eucas1p2296feb0cc7be0538332dc698a72585bb References: <20190905161421.55981-3-yong.liu@intel.com> Subject: Re: [dpdk-dev] [PATCH v1 02/14] vhost: add burst enqueue function for packed ring 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" On 05.09.2019 19:14, Marvin Liu wrote: > Burst enqueue function will first check whether descriptors are cache > aligned. It will also check prerequisites in the beginning. Burst > enqueue function not support chained mbufs, single packet enqueue > function will handle it. > > Signed-off-by: Marvin Liu Hi. Can we rely on loop unrolling by compiler instead of repeating each command 4 times? For example: uint64_t len[PACKED_DESCS_BURST]; for (i = 0; i < PACKED_DESCS_BURST; i++) len[i] = descs[avail_idx + i].len; For 'if's: res = false; for (i = 0; i < PACKED_DESCS_BURST; i++) res |= pkts[i]->next != NULL; if (unlikely(res)) return -1; or just for (i = 0; i < PACKED_DESCS_BURST; i++) if (unlikely(pkts[i]->next != NULL)) return -1; Since PACKED_DESCS_BURST is a fairly small constant, loops should be unrolled by compiler producing almost same code. This will significantly reduce code size and will also allow to play with PACKED_DESCS_BURST value without massive code changes. Same is applicable to other patches in the series. What do you think? Best regards, Ilya Maximets. > > diff --git a/lib/librte_vhost/vhost.h b/lib/librte_vhost/vhost.h > index 884befa85..ed8b4aabf 100644 > --- a/lib/librte_vhost/vhost.h > +++ b/lib/librte_vhost/vhost.h > @@ -39,6 +39,8 @@ > > #define VHOST_LOG_CACHE_NR 32 > > +#define PACKED_DESCS_BURST 4 > +#define PACKED_BURST_MASK (PACKED_DESCS_BURST - 1) > /** > * Structure contains buffer address, length and descriptor index > * from vring to do scatter RX. > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c > index 5ad0a8175..51ed20543 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -896,6 +896,106 @@ virtio_dev_rx_split(struct virtio_net *dev, struct vhost_virtqueue *vq, > return pkt_idx; > } > > +static __rte_unused uint16_t > +virtio_dev_rx_burst_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > + struct rte_mbuf **pkts) > +{ > + bool wrap_counter = vq->avail_wrap_counter; > + struct vring_packed_desc *descs = vq->desc_packed; > + uint16_t avail_idx = vq->last_avail_idx; > + uint64_t desc_addr, desc_addr1, desc_addr2, desc_addr3; > + uint64_t len, len1, len2, len3; > + struct virtio_net_hdr_mrg_rxbuf *hdr, *hdr1, *hdr2, *hdr3; > + uint32_t buf_offset = dev->vhost_hlen; > + > + if (unlikely(avail_idx & PACKED_BURST_MASK)) > + return -1; > + > + if (unlikely((pkts[0]->next != NULL) | > + (pkts[1]->next != NULL) | > + (pkts[2]->next != NULL) | > + (pkts[3]->next != NULL))) > + return -1; > + > + if (unlikely(!desc_is_avail(&descs[avail_idx], wrap_counter)) | > + unlikely(!desc_is_avail(&descs[avail_idx + 1], wrap_counter)) | > + unlikely(!desc_is_avail(&descs[avail_idx + 2], wrap_counter)) | > + unlikely(!desc_is_avail(&descs[avail_idx + 3], wrap_counter))) > + return 1; > + > + rte_smp_rmb(); > + > + len = descs[avail_idx].len; > + len1 = descs[avail_idx + 1].len; > + len2 = descs[avail_idx + 2].len; > + len3 = descs[avail_idx + 3].len; > + > + if (unlikely((pkts[0]->pkt_len > (len - buf_offset)) | > + (pkts[1]->pkt_len > (len1 - buf_offset)) | > + (pkts[2]->pkt_len > (len2 - buf_offset)) | > + (pkts[3]->pkt_len > (len3 - buf_offset)))) > + return -1; > + > + desc_addr = vhost_iova_to_vva(dev, vq, descs[avail_idx].addr, &len, > + VHOST_ACCESS_RW); > + > + desc_addr1 = vhost_iova_to_vva(dev, vq, descs[avail_idx + 1].addr, > + &len1, VHOST_ACCESS_RW); > + > + desc_addr2 = vhost_iova_to_vva(dev, vq, descs[avail_idx + 2].addr, > + &len2, VHOST_ACCESS_RW); > + > + desc_addr3 = vhost_iova_to_vva(dev, vq, descs[avail_idx + 3].addr, > + &len3, VHOST_ACCESS_RW); > + > + if (unlikely((len != descs[avail_idx].len) | > + (len1 != descs[avail_idx + 1].len) | > + (len2 != descs[avail_idx + 2].len) | > + (len3 != descs[avail_idx + 3].len))) > + return -1; > + > + rte_prefetch0((void *)(uintptr_t)desc_addr); > + rte_prefetch0((void *)(uintptr_t)desc_addr1); > + rte_prefetch0((void *)(uintptr_t)desc_addr2); > + rte_prefetch0((void *)(uintptr_t)desc_addr3); > + > + hdr = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr; > + hdr1 = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr1; > + hdr2 = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr2; > + hdr3 = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)desc_addr3; > + > + virtio_enqueue_offload(pkts[0], &hdr->hdr); > + virtio_enqueue_offload(pkts[1], &hdr1->hdr); > + virtio_enqueue_offload(pkts[2], &hdr2->hdr); > + virtio_enqueue_offload(pkts[3], &hdr3->hdr); > + > + len = pkts[0]->pkt_len + dev->vhost_hlen; > + len1 = pkts[1]->pkt_len + dev->vhost_hlen; > + len2 = pkts[2]->pkt_len + dev->vhost_hlen; > + len3 = pkts[3]->pkt_len + dev->vhost_hlen; > + > + vq->last_avail_idx += PACKED_DESCS_BURST; > + if (vq->last_avail_idx >= vq->size) { > + vq->last_avail_idx -= vq->size; > + vq->avail_wrap_counter ^= 1; > + } > + > + rte_memcpy((void *)(uintptr_t)(desc_addr + buf_offset), > + rte_pktmbuf_mtod_offset(pkts[0], void *, 0), > + pkts[0]->pkt_len); > + rte_memcpy((void *)(uintptr_t)(desc_addr1 + buf_offset), > + rte_pktmbuf_mtod_offset(pkts[1], void *, 0), > + pkts[1]->pkt_len); > + rte_memcpy((void *)(uintptr_t)(desc_addr2 + buf_offset), > + rte_pktmbuf_mtod_offset(pkts[2], void *, 0), > + pkts[2]->pkt_len); > + rte_memcpy((void *)(uintptr_t)(desc_addr3 + buf_offset), > + rte_pktmbuf_mtod_offset(pkts[3], void *, 0), > + pkts[3]->pkt_len); > + > + return 0; > +} > + > static __rte_unused int16_t > virtio_dev_rx_single_packed(struct virtio_net *dev, struct vhost_virtqueue *vq, > struct rte_mbuf *pkt) >