Message ID | 1427309006-26590-1-git-send-email-zoltan.kiss@linaro.org (mailing list archive) |
---|---|
State | Rejected, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 18B1A9ACD; Wed, 25 Mar 2015 23:52:37 +0100 (CET) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by dpdk.org (Postfix) with ESMTP id B71F29AB7 for <dev@dpdk.org>; Wed, 25 Mar 2015 19:43:39 +0100 (CET) Received: by wibgn9 with SMTP id gn9so52463119wib.1 for <dev@dpdk.org>; Wed, 25 Mar 2015 11:43:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=g5F2E8NjkQDnoVDPqomMRZXb6oxt1vgUqfxZbYGs83E=; b=Hez2s1rr4AFbtzYaAsJpq17Ifdt+gFm4KANCoCBHKcr27KyIcudulh2Alg6d0rEQ10 4jmP/gpi2G1yACFjgVrkHoA9AjmdlSLt/RCOWPOD0mlvZgnDFw55auct/gZyBeHMC05t 7MZY8VSAICqD68mZoN5oC/WPIHO1stCOxwXdQ6mq4PunAepFM3qLFgruDpesO6mThCLQ jSaqKqQaozFmp7N0MyzK6eW5DCshcowGbex/gSvBEF1WpaY06/ryYaH+RQd2lsMDtzI6 2Ou3PHVCC6vhiEvAoap/Nh+0nSQ5NfGsKsSX7Lvk+WNAaqDH+lKm8uV8PU9eIiPWOBer Ihog== X-Gm-Message-State: ALoCoQmnNnfgv4N0V/QgzWksb98Y0YIYVUPXi3T9OtPGxlJsgb5HCwGx4k2B9wRZdvV/TPiwCt5Y X-Received: by 10.194.110.233 with SMTP id id9mr20858450wjb.136.1427309019504; Wed, 25 Mar 2015 11:43:39 -0700 (PDT) Received: from localhost.localdomain ([90.152.119.35]) by mx.google.com with ESMTPSA id dq8sm5486332wib.9.2015.03.25.11.43.38 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 Mar 2015 11:43:38 -0700 (PDT) From: Zoltan Kiss <zoltan.kiss@linaro.org> To: dev@dpdk.org Date: Wed, 25 Mar 2015 18:43:26 +0000 Message-Id: <1427309006-26590-1-git-send-email-zoltan.kiss@linaro.org> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Wed, 25 Mar 2015 23:52:36 +0100 Cc: Zoltan Kiss <zoltan.kiss@linaro.org> Subject: [dpdk-dev] [PATCH] examples/vhost: use library routines instead of local copies X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Zoltan Kiss
March 25, 2015, 6:43 p.m. UTC
This macro and function were copies from the mbuf library, no reason to keep
them.
Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org>
---
examples/vhost/main.c | 38 +++++---------------------------------
1 file changed, 5 insertions(+), 33 deletions(-)
Comments
> -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Zoltan Kiss > Sent: Wednesday, March 25, 2015 6:43 PM > To: dev@dpdk.org > Cc: Zoltan Kiss > Subject: [dpdk-dev] [PATCH] examples/vhost: use library routines instead of local copies > > This macro and function were copies from the mbuf library, no reason to keep > them. NACK You can't use RTE_MBUF_INDIRECT macro here. If you'll look at vhost code carefully, you'll realise that we don't use standard rte_pktmbuf_attach() here. As we attach mbuf not to another mbuf but to external memory buffer, passed to us by virtio device. Look at attach_rxmbuf_zcp(). Though I suppose, we can replace pktmbuf_detach_zcp() , with rte_pktmbuf_detach() - they are doing identical things. BTW, I wonder did you ever test your patch? My guess it would cause vhost with '--zero-copy' to crash or corrupt the packets straightway. Konstantin > > Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> > --- > examples/vhost/main.c | 38 +++++--------------------------------- > 1 file changed, 5 insertions(+), 33 deletions(-) > > diff --git a/examples/vhost/main.c b/examples/vhost/main.c > index c3fcb80..1c998a5 100644 > --- a/examples/vhost/main.c > +++ b/examples/vhost/main.c > @@ -139,8 +139,6 @@ > /* Number of descriptors per cacheline. */ > #define DESC_PER_CACHELINE (RTE_CACHE_LINE_SIZE / sizeof(struct vring_desc)) > > -#define MBUF_EXT_MEM(mb) (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb)) > - > /* mask of enabled ports */ > static uint32_t enabled_port_mask = 0; > > @@ -1538,32 +1536,6 @@ attach_rxmbuf_zcp(struct virtio_net *dev) > return; > } > > -/* > - * Detach an attched packet mbuf - > - * - restore original mbuf address and length values. > - * - reset pktmbuf data and data_len to their default values. > - * All other fields of the given packet mbuf will be left intact. > - * > - * @param m > - * The attached packet mbuf. > - */ > -static inline void pktmbuf_detach_zcp(struct rte_mbuf *m) > -{ > - const struct rte_mempool *mp = m->pool; > - void *buf = RTE_MBUF_TO_BADDR(m); > - uint32_t buf_ofs; > - uint32_t buf_len = mp->elt_size - sizeof(*m); > - m->buf_physaddr = rte_mempool_virt2phy(mp, m) + sizeof(*m); > - > - m->buf_addr = buf; > - m->buf_len = (uint16_t)buf_len; > - > - buf_ofs = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ? > - RTE_PKTMBUF_HEADROOM : m->buf_len; > - m->data_off = buf_ofs; > - > - m->data_len = 0; > -} > > /* > * This function is called after packets have been transimited. It fetchs mbuf > @@ -1590,8 +1562,8 @@ txmbuf_clean_zcp(struct virtio_net *dev, struct vpool *vpool) > > for (index = 0; index < mbuf_count; index++) { > mbuf = __rte_mbuf_raw_alloc(vpool->pool); > - if (likely(MBUF_EXT_MEM(mbuf))) > - pktmbuf_detach_zcp(mbuf); > + if (likely(RTE_MBUF_INDIRECT(mbuf))) > + rte_pktmbuf_detach(mbuf); > rte_ring_sp_enqueue(vpool->ring, mbuf); > > /* Update used index buffer information. */ > @@ -1653,8 +1625,8 @@ static void mbuf_destroy_zcp(struct vpool *vpool) > for (index = 0; index < mbuf_count; index++) { > mbuf = __rte_mbuf_raw_alloc(vpool->pool); > if (likely(mbuf != NULL)) { > - if (likely(MBUF_EXT_MEM(mbuf))) > - pktmbuf_detach_zcp(mbuf); > + if (likely(RTE_MBUF_INDIRECT(mbuf))) > + rte_pktmbuf_detach(mbuf); > rte_ring_sp_enqueue(vpool->ring, (void *)mbuf); > } > } > @@ -2149,7 +2121,7 @@ switch_worker_zcp(__attribute__((unused)) void *arg) > } > while (likely(rx_count)) { > rx_count--; > - pktmbuf_detach_zcp( > + rte_pktmbuf_detach( > pkts_burst[rx_count]); > rte_ring_sp_enqueue( > vpool_array[index].ring, > -- > 1.9.1
> -----Original Message----- > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Ananyev, > Konstantin > Sent: Thursday, March 26, 2015 9:21 AM > To: Zoltan Kiss; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] examples/vhost: use library routines > instead of local copies > > > > > -----Original Message----- > > From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Zoltan Kiss > > Sent: Wednesday, March 25, 2015 6:43 PM > > To: dev@dpdk.org > > Cc: Zoltan Kiss > > Subject: [dpdk-dev] [PATCH] examples/vhost: use library routines > > instead of local copies > > > > This macro and function were copies from the mbuf library, no reason > > to keep them. > > NACK > You can't use RTE_MBUF_INDIRECT macro here. > If you'll look at vhost code carefully, you'll realise that we don't use standard > rte_pktmbuf_attach() here. > As we attach mbuf not to another mbuf but to external memory buffer, > passed to us by virtio device. > Look at attach_rxmbuf_zcp(). > Though I suppose, we can replace pktmbuf_detach_zcp() , with > rte_pktmbuf_detach() - they are doing identical things. > BTW, I wonder did you ever test your patch? > My guess it would cause vhost with '--zero-copy' to crash or corrupt the > packets straightway. > > Konstantin > > > > > Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> NACK this patch, Same reason with Konstantin. Changchun
On 26/03/15 01:20, Ananyev, Konstantin wrote: > > >> -----Original Message----- >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Zoltan Kiss >> Sent: Wednesday, March 25, 2015 6:43 PM >> To: dev@dpdk.org >> Cc: Zoltan Kiss >> Subject: [dpdk-dev] [PATCH] examples/vhost: use library routines instead of local copies >> >> This macro and function were copies from the mbuf library, no reason to keep >> them. > > NACK > You can't use RTE_MBUF_INDIRECT macro here. > If you'll look at vhost code carefully, you'll realise that we don't use standard rte_pktmbuf_attach() here. > As we attach mbuf not to another mbuf but to external memory buffer, passed to us by virtio device. > Look at attach_rxmbuf_zcp(). Yes, I think the proper fix is to set the flag in attach_rxmbuf_zcp() and virtio_tx_route_zcp(), then you can use the library macro here. > Though I suppose, we can replace pktmbuf_detach_zcp() , with rte_pktmbuf_detach() - they are doing identical things. Yes, the only difference is that the latter do "m->ol_flags = 0" as well. > BTW, I wonder did you ever test your patch? Indeed I did not, shame on me. I don't have a KVM setup at hand. This fix were born as a side effect of the cleaning up in the library, and I'm afraid I don't have the time right now to create a KVM setup. Could anyone who has it at hand help out to run a quick test? (for the v2 of this patch, which I'll send in shortly) Regards, Zoltan > My guess it would cause vhost with '--zero-copy' to crash or corrupt the packets straightway. > > Konstantin > >> >> Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> >> --- >> examples/vhost/main.c | 38 +++++--------------------------------- >> 1 file changed, 5 insertions(+), 33 deletions(-) >> >> diff --git a/examples/vhost/main.c b/examples/vhost/main.c >> index c3fcb80..1c998a5 100644 >> --- a/examples/vhost/main.c >> +++ b/examples/vhost/main.c >> @@ -139,8 +139,6 @@ >> /* Number of descriptors per cacheline. */ >> #define DESC_PER_CACHELINE (RTE_CACHE_LINE_SIZE / sizeof(struct vring_desc)) >> >> -#define MBUF_EXT_MEM(mb) (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb)) >> - >> /* mask of enabled ports */ >> static uint32_t enabled_port_mask = 0; >> >> @@ -1538,32 +1536,6 @@ attach_rxmbuf_zcp(struct virtio_net *dev) >> return; >> } >> >> -/* >> - * Detach an attched packet mbuf - >> - * - restore original mbuf address and length values. >> - * - reset pktmbuf data and data_len to their default values. >> - * All other fields of the given packet mbuf will be left intact. >> - * >> - * @param m >> - * The attached packet mbuf. >> - */ >> -static inline void pktmbuf_detach_zcp(struct rte_mbuf *m) >> -{ >> - const struct rte_mempool *mp = m->pool; >> - void *buf = RTE_MBUF_TO_BADDR(m); >> - uint32_t buf_ofs; >> - uint32_t buf_len = mp->elt_size - sizeof(*m); >> - m->buf_physaddr = rte_mempool_virt2phy(mp, m) + sizeof(*m); >> - >> - m->buf_addr = buf; >> - m->buf_len = (uint16_t)buf_len; >> - >> - buf_ofs = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ? >> - RTE_PKTMBUF_HEADROOM : m->buf_len; >> - m->data_off = buf_ofs; >> - >> - m->data_len = 0; >> -} >> >> /* >> * This function is called after packets have been transimited. It fetchs mbuf >> @@ -1590,8 +1562,8 @@ txmbuf_clean_zcp(struct virtio_net *dev, struct vpool *vpool) >> >> for (index = 0; index < mbuf_count; index++) { >> mbuf = __rte_mbuf_raw_alloc(vpool->pool); >> - if (likely(MBUF_EXT_MEM(mbuf))) >> - pktmbuf_detach_zcp(mbuf); >> + if (likely(RTE_MBUF_INDIRECT(mbuf))) >> + rte_pktmbuf_detach(mbuf); >> rte_ring_sp_enqueue(vpool->ring, mbuf); >> >> /* Update used index buffer information. */ >> @@ -1653,8 +1625,8 @@ static void mbuf_destroy_zcp(struct vpool *vpool) >> for (index = 0; index < mbuf_count; index++) { >> mbuf = __rte_mbuf_raw_alloc(vpool->pool); >> if (likely(mbuf != NULL)) { >> - if (likely(MBUF_EXT_MEM(mbuf))) >> - pktmbuf_detach_zcp(mbuf); >> + if (likely(RTE_MBUF_INDIRECT(mbuf))) >> + rte_pktmbuf_detach(mbuf); >> rte_ring_sp_enqueue(vpool->ring, (void *)mbuf); >> } >> } >> @@ -2149,7 +2121,7 @@ switch_worker_zcp(__attribute__((unused)) void *arg) >> } >> while (likely(rx_count)) { >> rx_count--; >> - pktmbuf_detach_zcp( >> + rte_pktmbuf_detach( >> pkts_burst[rx_count]); >> rte_ring_sp_enqueue( >> vpool_array[index].ring, >> -- >> 1.9.1 >
> -----Original Message----- > From: Zoltan Kiss [mailto:zoltan.kiss@linaro.org] > Sent: Thursday, March 26, 2015 4:46 PM > To: Ananyev, Konstantin; dev@dpdk.org > Subject: Re: [dpdk-dev] [PATCH] examples/vhost: use library routines instead of local copies > > > > On 26/03/15 01:20, Ananyev, Konstantin wrote: > > > > > >> -----Original Message----- > >> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Zoltan Kiss > >> Sent: Wednesday, March 25, 2015 6:43 PM > >> To: dev@dpdk.org > >> Cc: Zoltan Kiss > >> Subject: [dpdk-dev] [PATCH] examples/vhost: use library routines instead of local copies > >> > >> This macro and function were copies from the mbuf library, no reason to keep > >> them. > > > > NACK > > You can't use RTE_MBUF_INDIRECT macro here. > > If you'll look at vhost code carefully, you'll realise that we don't use standard rte_pktmbuf_attach() here. > > As we attach mbuf not to another mbuf but to external memory buffer, passed to us by virtio device. > > Look at attach_rxmbuf_zcp(). > Yes, I think the proper fix is to set the flag in attach_rxmbuf_zcp() > and virtio_tx_route_zcp(), then you can use the library macro here. No, it is not. IND_ATTACHED_MBUF flag indicates that that mbuf attached to another mbuf and __rte_pktmbuf_prefree_seg() would try to do mbuf detach. We definetly don't want to set IND_ATTACHED_MBUF here. I think there is no need to fix anything here. Konstantin > > > Though I suppose, we can replace pktmbuf_detach_zcp() , with rte_pktmbuf_detach() - they are doing identical things. > Yes, the only difference is that the latter do "m->ol_flags = 0" as well. > > > BTW, I wonder did you ever test your patch? > Indeed I did not, shame on me. I don't have a KVM setup at hand. This > fix were born as a side effect of the cleaning up in the library, > and I'm afraid I don't have the time right now to create a KVM setup. > Could anyone who has it at hand help out to run a quick test? (for the > v2 of this patch, which I'll send in shortly) > > Regards, > > Zoltan > > > My guess it would cause vhost with '--zero-copy' to crash or corrupt the packets straightway. > > > > Konstantin > > > >> > >> Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> > >> --- > >> examples/vhost/main.c | 38 +++++--------------------------------- > >> 1 file changed, 5 insertions(+), 33 deletions(-) > >> > >> diff --git a/examples/vhost/main.c b/examples/vhost/main.c > >> index c3fcb80..1c998a5 100644 > >> --- a/examples/vhost/main.c > >> +++ b/examples/vhost/main.c > >> @@ -139,8 +139,6 @@ > >> /* Number of descriptors per cacheline. */ > >> #define DESC_PER_CACHELINE (RTE_CACHE_LINE_SIZE / sizeof(struct vring_desc)) > >> > >> -#define MBUF_EXT_MEM(mb) (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb)) > >> - > >> /* mask of enabled ports */ > >> static uint32_t enabled_port_mask = 0; > >> > >> @@ -1538,32 +1536,6 @@ attach_rxmbuf_zcp(struct virtio_net *dev) > >> return; > >> } > >> > >> -/* > >> - * Detach an attched packet mbuf - > >> - * - restore original mbuf address and length values. > >> - * - reset pktmbuf data and data_len to their default values. > >> - * All other fields of the given packet mbuf will be left intact. > >> - * > >> - * @param m > >> - * The attached packet mbuf. > >> - */ > >> -static inline void pktmbuf_detach_zcp(struct rte_mbuf *m) > >> -{ > >> - const struct rte_mempool *mp = m->pool; > >> - void *buf = RTE_MBUF_TO_BADDR(m); > >> - uint32_t buf_ofs; > >> - uint32_t buf_len = mp->elt_size - sizeof(*m); > >> - m->buf_physaddr = rte_mempool_virt2phy(mp, m) + sizeof(*m); > >> - > >> - m->buf_addr = buf; > >> - m->buf_len = (uint16_t)buf_len; > >> - > >> - buf_ofs = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ? > >> - RTE_PKTMBUF_HEADROOM : m->buf_len; > >> - m->data_off = buf_ofs; > >> - > >> - m->data_len = 0; > >> -} > >> > >> /* > >> * This function is called after packets have been transimited. It fetchs mbuf > >> @@ -1590,8 +1562,8 @@ txmbuf_clean_zcp(struct virtio_net *dev, struct vpool *vpool) > >> > >> for (index = 0; index < mbuf_count; index++) { > >> mbuf = __rte_mbuf_raw_alloc(vpool->pool); > >> - if (likely(MBUF_EXT_MEM(mbuf))) > >> - pktmbuf_detach_zcp(mbuf); > >> + if (likely(RTE_MBUF_INDIRECT(mbuf))) > >> + rte_pktmbuf_detach(mbuf); > >> rte_ring_sp_enqueue(vpool->ring, mbuf); > >> > >> /* Update used index buffer information. */ > >> @@ -1653,8 +1625,8 @@ static void mbuf_destroy_zcp(struct vpool *vpool) > >> for (index = 0; index < mbuf_count; index++) { > >> mbuf = __rte_mbuf_raw_alloc(vpool->pool); > >> if (likely(mbuf != NULL)) { > >> - if (likely(MBUF_EXT_MEM(mbuf))) > >> - pktmbuf_detach_zcp(mbuf); > >> + if (likely(RTE_MBUF_INDIRECT(mbuf))) > >> + rte_pktmbuf_detach(mbuf); > >> rte_ring_sp_enqueue(vpool->ring, (void *)mbuf); > >> } > >> } > >> @@ -2149,7 +2121,7 @@ switch_worker_zcp(__attribute__((unused)) void *arg) > >> } > >> while (likely(rx_count)) { > >> rx_count--; > >> - pktmbuf_detach_zcp( > >> + rte_pktmbuf_detach( > >> pkts_burst[rx_count]); > >> rte_ring_sp_enqueue( > >> vpool_array[index].ring, > >> -- > >> 1.9.1 > >
On 26/03/15 17:34, Ananyev, Konstantin wrote: > > >> -----Original Message----- >> From: Zoltan Kiss [mailto:zoltan.kiss@linaro.org] >> Sent: Thursday, March 26, 2015 4:46 PM >> To: Ananyev, Konstantin; dev@dpdk.org >> Subject: Re: [dpdk-dev] [PATCH] examples/vhost: use library routines instead of local copies >> >> >> >> On 26/03/15 01:20, Ananyev, Konstantin wrote: >>> >>> >>>> -----Original Message----- >>>> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Zoltan Kiss >>>> Sent: Wednesday, March 25, 2015 6:43 PM >>>> To: dev@dpdk.org >>>> Cc: Zoltan Kiss >>>> Subject: [dpdk-dev] [PATCH] examples/vhost: use library routines instead of local copies >>>> >>>> This macro and function were copies from the mbuf library, no reason to keep >>>> them. >>> >>> NACK >>> You can't use RTE_MBUF_INDIRECT macro here. >>> If you'll look at vhost code carefully, you'll realise that we don't use standard rte_pktmbuf_attach() here. >>> As we attach mbuf not to another mbuf but to external memory buffer, passed to us by virtio device. >>> Look at attach_rxmbuf_zcp(). >> Yes, I think the proper fix is to set the flag in attach_rxmbuf_zcp() >> and virtio_tx_route_zcp(), then you can use the library macro here. > > No, it is not. > IND_ATTACHED_MBUF flag indicates that that mbuf attached to another mbuf and __rte_pktmbuf_prefree_seg() > would try to do mbuf detach. > We definetly don't want to set IND_ATTACHED_MBUF here. I see. Quite confusing how vhost reuse some library code to do something slightly different. > I think there is no need to fix anything here. > > Konstantin > >> >>> Though I suppose, we can replace pktmbuf_detach_zcp() , with rte_pktmbuf_detach() - they are doing identical things. >> Yes, the only difference is that the latter do "m->ol_flags = 0" as well. >> >>> BTW, I wonder did you ever test your patch? >> Indeed I did not, shame on me. I don't have a KVM setup at hand. This >> fix were born as a side effect of the cleaning up in the library, >> and I'm afraid I don't have the time right now to create a KVM setup. >> Could anyone who has it at hand help out to run a quick test? (for the >> v2 of this patch, which I'll send in shortly) > > >> >> Regards, >> >> Zoltan >> >>> My guess it would cause vhost with '--zero-copy' to crash or corrupt the packets straightway. >>> >>> Konstantin >>> >>>> >>>> Signed-off-by: Zoltan Kiss <zoltan.kiss@linaro.org> >>>> --- >>>> examples/vhost/main.c | 38 +++++--------------------------------- >>>> 1 file changed, 5 insertions(+), 33 deletions(-) >>>> >>>> diff --git a/examples/vhost/main.c b/examples/vhost/main.c >>>> index c3fcb80..1c998a5 100644 >>>> --- a/examples/vhost/main.c >>>> +++ b/examples/vhost/main.c >>>> @@ -139,8 +139,6 @@ >>>> /* Number of descriptors per cacheline. */ >>>> #define DESC_PER_CACHELINE (RTE_CACHE_LINE_SIZE / sizeof(struct vring_desc)) >>>> >>>> -#define MBUF_EXT_MEM(mb) (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb)) >>>> - >>>> /* mask of enabled ports */ >>>> static uint32_t enabled_port_mask = 0; >>>> >>>> @@ -1538,32 +1536,6 @@ attach_rxmbuf_zcp(struct virtio_net *dev) >>>> return; >>>> } >>>> >>>> -/* >>>> - * Detach an attched packet mbuf - >>>> - * - restore original mbuf address and length values. >>>> - * - reset pktmbuf data and data_len to their default values. >>>> - * All other fields of the given packet mbuf will be left intact. >>>> - * >>>> - * @param m >>>> - * The attached packet mbuf. >>>> - */ >>>> -static inline void pktmbuf_detach_zcp(struct rte_mbuf *m) >>>> -{ >>>> - const struct rte_mempool *mp = m->pool; >>>> - void *buf = RTE_MBUF_TO_BADDR(m); >>>> - uint32_t buf_ofs; >>>> - uint32_t buf_len = mp->elt_size - sizeof(*m); >>>> - m->buf_physaddr = rte_mempool_virt2phy(mp, m) + sizeof(*m); >>>> - >>>> - m->buf_addr = buf; >>>> - m->buf_len = (uint16_t)buf_len; >>>> - >>>> - buf_ofs = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ? >>>> - RTE_PKTMBUF_HEADROOM : m->buf_len; >>>> - m->data_off = buf_ofs; >>>> - >>>> - m->data_len = 0; >>>> -} >>>> >>>> /* >>>> * This function is called after packets have been transimited. It fetchs mbuf >>>> @@ -1590,8 +1562,8 @@ txmbuf_clean_zcp(struct virtio_net *dev, struct vpool *vpool) >>>> >>>> for (index = 0; index < mbuf_count; index++) { >>>> mbuf = __rte_mbuf_raw_alloc(vpool->pool); >>>> - if (likely(MBUF_EXT_MEM(mbuf))) >>>> - pktmbuf_detach_zcp(mbuf); >>>> + if (likely(RTE_MBUF_INDIRECT(mbuf))) >>>> + rte_pktmbuf_detach(mbuf); >>>> rte_ring_sp_enqueue(vpool->ring, mbuf); >>>> >>>> /* Update used index buffer information. */ >>>> @@ -1653,8 +1625,8 @@ static void mbuf_destroy_zcp(struct vpool *vpool) >>>> for (index = 0; index < mbuf_count; index++) { >>>> mbuf = __rte_mbuf_raw_alloc(vpool->pool); >>>> if (likely(mbuf != NULL)) { >>>> - if (likely(MBUF_EXT_MEM(mbuf))) >>>> - pktmbuf_detach_zcp(mbuf); >>>> + if (likely(RTE_MBUF_INDIRECT(mbuf))) >>>> + rte_pktmbuf_detach(mbuf); >>>> rte_ring_sp_enqueue(vpool->ring, (void *)mbuf); >>>> } >>>> } >>>> @@ -2149,7 +2121,7 @@ switch_worker_zcp(__attribute__((unused)) void *arg) >>>> } >>>> while (likely(rx_count)) { >>>> rx_count--; >>>> - pktmbuf_detach_zcp( >>>> + rte_pktmbuf_detach( >>>> pkts_burst[rx_count]); >>>> rte_ring_sp_enqueue( >>>> vpool_array[index].ring, >>>> -- >>>> 1.9.1 >>>
diff --git a/examples/vhost/main.c b/examples/vhost/main.c index c3fcb80..1c998a5 100644 --- a/examples/vhost/main.c +++ b/examples/vhost/main.c @@ -139,8 +139,6 @@ /* Number of descriptors per cacheline. */ #define DESC_PER_CACHELINE (RTE_CACHE_LINE_SIZE / sizeof(struct vring_desc)) -#define MBUF_EXT_MEM(mb) (RTE_MBUF_FROM_BADDR((mb)->buf_addr) != (mb)) - /* mask of enabled ports */ static uint32_t enabled_port_mask = 0; @@ -1538,32 +1536,6 @@ attach_rxmbuf_zcp(struct virtio_net *dev) return; } -/* - * Detach an attched packet mbuf - - * - restore original mbuf address and length values. - * - reset pktmbuf data and data_len to their default values. - * All other fields of the given packet mbuf will be left intact. - * - * @param m - * The attached packet mbuf. - */ -static inline void pktmbuf_detach_zcp(struct rte_mbuf *m) -{ - const struct rte_mempool *mp = m->pool; - void *buf = RTE_MBUF_TO_BADDR(m); - uint32_t buf_ofs; - uint32_t buf_len = mp->elt_size - sizeof(*m); - m->buf_physaddr = rte_mempool_virt2phy(mp, m) + sizeof(*m); - - m->buf_addr = buf; - m->buf_len = (uint16_t)buf_len; - - buf_ofs = (RTE_PKTMBUF_HEADROOM <= m->buf_len) ? - RTE_PKTMBUF_HEADROOM : m->buf_len; - m->data_off = buf_ofs; - - m->data_len = 0; -} /* * This function is called after packets have been transimited. It fetchs mbuf @@ -1590,8 +1562,8 @@ txmbuf_clean_zcp(struct virtio_net *dev, struct vpool *vpool) for (index = 0; index < mbuf_count; index++) { mbuf = __rte_mbuf_raw_alloc(vpool->pool); - if (likely(MBUF_EXT_MEM(mbuf))) - pktmbuf_detach_zcp(mbuf); + if (likely(RTE_MBUF_INDIRECT(mbuf))) + rte_pktmbuf_detach(mbuf); rte_ring_sp_enqueue(vpool->ring, mbuf); /* Update used index buffer information. */ @@ -1653,8 +1625,8 @@ static void mbuf_destroy_zcp(struct vpool *vpool) for (index = 0; index < mbuf_count; index++) { mbuf = __rte_mbuf_raw_alloc(vpool->pool); if (likely(mbuf != NULL)) { - if (likely(MBUF_EXT_MEM(mbuf))) - pktmbuf_detach_zcp(mbuf); + if (likely(RTE_MBUF_INDIRECT(mbuf))) + rte_pktmbuf_detach(mbuf); rte_ring_sp_enqueue(vpool->ring, (void *)mbuf); } } @@ -2149,7 +2121,7 @@ switch_worker_zcp(__attribute__((unused)) void *arg) } while (likely(rx_count)) { rx_count--; - pktmbuf_detach_zcp( + rte_pktmbuf_detach( pkts_burst[rx_count]); rte_ring_sp_enqueue( vpool_array[index].ring,