From: Maxime Coquelin <maxime.coquelin@redhat.com>
To: Tiwei Bie <tiwei.bie@intel.com>, zhihong.wang@intel.com, dev@dpdk.org
Subject: Re: [dpdk-dev] [PATCH 5/5] net/virtio: optimize xmit enqueue for packed ring
Date: Thu, 21 Feb 2019 12:22:29 +0100 [thread overview]
Message-ID: <ded39d11-4697-9cd2-d9a2-f4fbf21f5732@redhat.com> (raw)
In-Reply-To: <20190219105951.31046-6-tiwei.bie@intel.com>
On 2/19/19 11:59 AM, Tiwei Bie wrote:
> This patch introduces an optimized enqueue function in packed
> ring for the case that virtio net header can be prepended to
> the unchained mbuf.
>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
> ---
> drivers/net/virtio/virtio_rxtx.c | 63 +++++++++++++++++++++++++++++++-
> 1 file changed, 61 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
> index 60fa3aa50..771d3c3f6 100644
> --- a/drivers/net/virtio/virtio_rxtx.c
> +++ b/drivers/net/virtio/virtio_rxtx.c
> @@ -623,6 +623,62 @@ virtqueue_enqueue_xmit_inorder(struct virtnet_tx *txvq,
> vq->vq_desc_head_idx = idx & (vq->vq_nentries - 1);
> }
>
> +static inline void
> +virtqueue_enqueue_xmit_packed_fast(struct virtnet_tx *txvq,
> + struct rte_mbuf *cookie,
> + int in_order)
> +{
> + struct virtqueue *vq = txvq->vq;
> + struct vring_packed_desc *dp;
> + struct vq_desc_extra *dxp;
> + uint16_t idx, id, flags;
> + uint16_t head_size = vq->hw->vtnet_hdr_size;
> + struct virtio_net_hdr *hdr;
> +
> + id = in_order ? vq->vq_avail_idx : vq->vq_desc_head_idx;
> + idx = vq->vq_avail_idx;
> + dp = &vq->ring_packed.desc_packed[idx];
> +
> + dxp = &vq->vq_descx[id];
> + dxp->ndescs = 1;
> + dxp->cookie = cookie;
> +
> + flags = vq->avail_used_flags;
> +
> + /* prepend cannot fail, checked by caller */
> + hdr = (struct virtio_net_hdr *)
> + rte_pktmbuf_prepend(cookie, head_size);
> + cookie->pkt_len -= head_size;
> +
> + /* if offload disabled, hdr is not zeroed yet, do it now */
> + if (!vq->hw->has_tx_offload)
> + virtqueue_clear_net_hdr(hdr);
> + else
> + virtqueue_xmit_offload(hdr, cookie, true);
> +
> + dp->addr = VIRTIO_MBUF_DATA_DMA_ADDR(cookie, vq);
> + dp->len = cookie->data_len;
> + dp->id = id;
> +
> + if (++vq->vq_avail_idx >= vq->vq_nentries) {
> + vq->vq_avail_idx -= vq->vq_nentries;
> + vq->avail_wrap_counter ^= 1;
> + vq->avail_used_flags ^=
> + VRING_DESC_F_AVAIL(1) | VRING_DESC_F_USED(1);
> + }
> +
> + vq->vq_free_cnt--;
> +
> + if (!in_order) {
> + vq->vq_desc_head_idx = dxp->next;
> + if (vq->vq_desc_head_idx == VQ_RING_DESC_CHAIN_END)
> + vq->vq_desc_tail_idx = VQ_RING_DESC_CHAIN_END;
> + }
> +
> + virtio_wmb(vq->hw->weak_barriers);
> + dp->flags = flags;
> +}
> +
> static inline void
> virtqueue_enqueue_xmit_packed(struct virtnet_tx *txvq, struct rte_mbuf *cookie,
> uint16_t needed, int can_push, int in_order)
> @@ -1979,8 +2035,11 @@ virtio_xmit_pkts_packed(void *tx_queue, struct rte_mbuf **tx_pkts,
> }
>
> /* Enqueue Packet buffers */
> - virtqueue_enqueue_xmit_packed(txvq, txm, slots, can_push,
> - in_order);
> + if (can_push)
> + virtqueue_enqueue_xmit_packed_fast(txvq, txm, in_order);
> + else
> + virtqueue_enqueue_xmit_packed(txvq, txm, slots, 0,
> + in_order);
>
> virtio_update_packet_stats(&txvq->stats, txm);
> }
>
I like this patch, but shouldn't virtqueue_enqueue_xmit_packed() be
simplified to get rid off "can_push" now that this case as a dedicated
function?
Regards,
Maxime
next prev parent reply other threads:[~2019-02-21 11:22 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-19 10:59 [dpdk-dev] [PATCH 0/5] Fixes and enhancements for Tx path in Virtio PMD Tiwei Bie
2019-02-19 10:59 ` [dpdk-dev] [PATCH 1/5] net/virtio: fix Tx desc cleanup for packed ring Tiwei Bie
2019-02-21 11:05 ` Maxime Coquelin
2019-02-19 10:59 ` [dpdk-dev] [PATCH 2/5] net/virtio: fix in-order Tx path for split ring Tiwei Bie
2019-02-21 11:08 ` Maxime Coquelin
2019-02-19 10:59 ` [dpdk-dev] [PATCH 3/5] net/virtio: fix in-order Tx path for packed ring Tiwei Bie
2019-02-21 11:16 ` Maxime Coquelin
2019-02-19 10:59 ` [dpdk-dev] [PATCH 4/5] net/virtio: introduce a helper for clearing net header Tiwei Bie
2019-02-21 11:18 ` Maxime Coquelin
2019-02-19 10:59 ` [dpdk-dev] [PATCH 5/5] net/virtio: optimize xmit enqueue for packed ring Tiwei Bie
2019-02-21 11:22 ` Maxime Coquelin [this message]
2019-02-21 12:25 ` Tiwei Bie
2019-02-21 12:31 ` Maxime Coquelin
2019-02-19 13:40 ` [dpdk-dev] [PATCH 0/5] Fixes and enhancements for Tx path in Virtio PMD Jason Wang
2019-02-20 2:23 ` Tiwei Bie
2019-02-21 17:45 ` Maxime Coquelin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ded39d11-4697-9cd2-d9a2-f4fbf21f5732@redhat.com \
--to=maxime.coquelin@redhat.com \
--cc=dev@dpdk.org \
--cc=tiwei.bie@intel.com \
--cc=zhihong.wang@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).