> -----Original Message-----
> From: dev [mailto:dev-bounces at dpdk.org] On Behalf Of Jijiang Liu
> Sent: Monday, August 31, 2015 5:42 PM
> To: dev at dpdk.org
> Subject: [dpdk-dev] [RFC PATCH 5/8] lib/librte_vhost:dequeue vhost TSO
> offload
> 
> Dequeue vhost TSO offload
> 
> Signed-off-by: Jijiang Liu <jijiang.liu at intel.com>
> ---
>  lib/librte_vhost/vhost_rxtx.c |   29 ++++++++++++++++++++++++++++-
>  1 files changed, 28 insertions(+), 1 deletions(-)
> 
> diff --git a/lib/librte_vhost/vhost_rxtx.c b/lib/librte_vhost/vhost_rxtx.c
> index 0d07338..9adfdb1 100644
> --- a/lib/librte_vhost/vhost_rxtx.c
> +++ b/lib/librte_vhost/vhost_rxtx.c
> @@ -545,6 +545,30 @@ rte_vhost_enqueue_burst(struct virtio_net *dev,
> uint16_t queue_id,
>               return virtio_dev_rx(dev, queue_id, pkts, count);  }
> 
> +static inline void __attribute__((always_inline))
> +vhost_dequeue_offload(uint64_t addr, struct rte_mbuf *m) {
> +     struct virtio_net_hdr *hdr =
> +             (struct virtio_net_hdr *)((uintptr_t)addr);
> +
> +     if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
> +             switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
> +             case VIRTIO_NET_HDR_GSO_TCPV4:
> +                     m->ol_flags |= (PKT_TX_IPV4 | PKT_TX_TCP_SEG);
> +                     m->tso_segsz = hdr->gso_size;
> +                     break;
> +             case VIRTIO_NET_HDR_GSO_TCPV6:
> +                     m->ol_flags |= (PKT_TX_IPV6 | PKT_TX_TCP_SEG);
> +                     m->tso_segsz = hdr->gso_size;
> +                     break;
> +             default:
> +                     RTE_LOG(ERR, VHOST_DATA,
> +                             "bad gso type %u.\n", hdr->gso_type);
> +                     break;

Do we need special handling for the bad gso type? 

> +             }
> +     }
> +}
> +
>  uint16_t
>  rte_vhost_dequeue_burst(struct virtio_net *dev, uint16_t queue_id,
>       struct rte_mempool *mbuf_pool, struct rte_mbuf **pkts, uint16_t
> count) @@ -553,6 +577,7 @@ rte_vhost_dequeue_burst(struct virtio_net
> *dev, uint16_t queue_id,
>       struct vhost_virtqueue *vq;
>       struct vring_desc *desc;
>       uint64_t vb_addr = 0;
> +     uint64_t vb_net_hdr_addr = 0;
>       uint32_t head[MAX_PKT_BURST];
>       uint32_t used_idx;
>       uint32_t i;
> @@ -604,6 +629,8 @@ rte_vhost_dequeue_burst(struct virtio_net *dev,
> uint16_t queue_id,
> 
>               desc = &vq->desc[head[entry_success]];
> 
> +             vb_net_hdr_addr = gpa_to_vva(dev, desc->addr);
> +
>               /* Discard first buffer as it is the virtio header */
>               if (desc->flags & VRING_DESC_F_NEXT) {
>                       desc = &vq->desc[desc->next];
> @@ -742,7 +769,7 @@ rte_vhost_dequeue_burst(struct virtio_net *dev,
> uint16_t queue_id,
>                       break;
> 
>               m->nb_segs = seg_num;
> -
> +             vhost_dequeue_offload(vb_net_hdr_addr, m);
>               pkts[entry_success] = m;
>               vq->last_used_idx++;
>               entry_success++;
> --
> 1.7.7.6

Reply via email to