* [dpdk-dev] [PATCH] vhost: remove unnecessary memset for virtio net hdr
@ 2016-03-16 6:44 Yuanhan Liu
2016-03-17 1:19 ` Xie, Huawei
0 siblings, 1 reply; 3+ messages in thread
From: Yuanhan Liu @ 2016-03-16 6:44 UTC (permalink / raw)
To: dev; +Cc: huawei.xie, Thomas Monjalon, Yuanhan Liu
We have to reset the virtio net hdr at virtio_enqueue_offload()
before, due to all mbufs share a single virtio_hdr structure:
struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, }, 0};
foreach (mbuf) {
virtio_enqueue_offload(mbuf, &virtio_hdr.hdr);
copy net hdr and mbuf to desc buf
}
However, after the vhost rxtx refactor, the code looks like:
copy_mbuf_to_desc(mbuf)
{
struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, }, 0}
virtio_enqueue_offload(mbuf, &virtio_hdr.hdr);
copy net hdr and mbuf to desc buf
}
foreach (mbuf) {
copy_mbuf_to_desc(mbuf);
}
Therefore, the memset at virtio_enqueue_offload() is not necessary
any more; remove it.
Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
---
lib/librte_vhost/vhost_rxtx.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
index a6330f8..b4da665 100644
--- a/lib/librte_vhost/vhost_rxtx.c
+++ b/lib/librte_vhost/vhost_rxtx.c
@@ -94,8 +94,6 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t qp_nb)
static void
virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr)
{
- memset(net_hdr, 0, sizeof(struct virtio_net_hdr));
-
if (m_buf->ol_flags & PKT_TX_L4_MASK) {
net_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
net_hdr->csum_start = m_buf->l2_len + m_buf->l3_len;
--
1.9.0
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] vhost: remove unnecessary memset for virtio net hdr
2016-03-16 6:44 [dpdk-dev] [PATCH] vhost: remove unnecessary memset for virtio net hdr Yuanhan Liu
@ 2016-03-17 1:19 ` Xie, Huawei
2016-03-17 20:52 ` Thomas Monjalon
0 siblings, 1 reply; 3+ messages in thread
From: Xie, Huawei @ 2016-03-17 1:19 UTC (permalink / raw)
To: Yuanhan Liu, dev; +Cc: Thomas Monjalon
On 3/16/2016 2:44 PM, Yuanhan Liu wrote:
> We have to reset the virtio net hdr at virtio_enqueue_offload()
> before, due to all mbufs share a single virtio_hdr structure:
>
> struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, }, 0};
>
> foreach (mbuf) {
> virtio_enqueue_offload(mbuf, &virtio_hdr.hdr);
>
> copy net hdr and mbuf to desc buf
> }
>
> However, after the vhost rxtx refactor, the code looks like:
>
> copy_mbuf_to_desc(mbuf)
> {
> struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, }, 0}
>
> virtio_enqueue_offload(mbuf, &virtio_hdr.hdr);
>
> copy net hdr and mbuf to desc buf
> }
>
> foreach (mbuf) {
> copy_mbuf_to_desc(mbuf);
> }
>
> Therefore, the memset at virtio_enqueue_offload() is not necessary
> any more; remove it.
>
> Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
> ---
> lib/librte_vhost/vhost_rxtx.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
> index a6330f8..b4da665 100644
> --- a/lib/librte_vhost/vhost_rxtx.c
> +++ b/lib/librte_vhost/vhost_rxtx.c
> @@ -94,8 +94,6 @@ is_valid_virt_queue_idx(uint32_t idx, int is_tx, uint32_t qp_nb)
> static void
> virtio_enqueue_offload(struct rte_mbuf *m_buf, struct virtio_net_hdr *net_hdr)
> {
> - memset(net_hdr, 0, sizeof(struct virtio_net_hdr));
> -
> if (m_buf->ol_flags & PKT_TX_L4_MASK) {
> net_hdr->flags = VIRTIO_NET_HDR_F_NEEDS_CSUM;
> net_hdr->csum_start = m_buf->l2_len + m_buf->l3_len;
Acked-by: Huawei Xie <huawei.xie@intel.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [dpdk-dev] [PATCH] vhost: remove unnecessary memset for virtio net hdr
2016-03-17 1:19 ` Xie, Huawei
@ 2016-03-17 20:52 ` Thomas Monjalon
0 siblings, 0 replies; 3+ messages in thread
From: Thomas Monjalon @ 2016-03-17 20:52 UTC (permalink / raw)
To: Yuanhan Liu; +Cc: Xie, Huawei, dev
2016-03-17 01:19, Xie, Huawei:
> On 3/16/2016 2:44 PM, Yuanhan Liu wrote:
> > We have to reset the virtio net hdr at virtio_enqueue_offload()
> > before, due to all mbufs share a single virtio_hdr structure:
> >
> > struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, }, 0};
> >
> > foreach (mbuf) {
> > virtio_enqueue_offload(mbuf, &virtio_hdr.hdr);
> >
> > copy net hdr and mbuf to desc buf
> > }
> >
> > However, after the vhost rxtx refactor, the code looks like:
> >
> > copy_mbuf_to_desc(mbuf)
> > {
> > struct virtio_net_hdr_mrg_rxbuf virtio_hdr = {{0, }, 0}
> >
> > virtio_enqueue_offload(mbuf, &virtio_hdr.hdr);
> >
> > copy net hdr and mbuf to desc buf
> > }
> >
> > foreach (mbuf) {
> > copy_mbuf_to_desc(mbuf);
> > }
> >
> > Therefore, the memset at virtio_enqueue_offload() is not necessary
> > any more; remove it.
> >
> > Signed-off-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
>
> Acked-by: Huawei Xie <huawei.xie@intel.com>
Applied, thanks
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-03-17 20:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-16 6:44 [dpdk-dev] [PATCH] vhost: remove unnecessary memset for virtio net hdr Yuanhan Liu
2016-03-17 1:19 ` Xie, Huawei
2016-03-17 20:52 ` Thomas Monjalon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).