MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vhost_dequeue_offload_legacy

Function vhost_dequeue_offload_legacy

dpdk/lib/vhost/virtio_net.c:2705–2782  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2703}
2704
2705static __rte_always_inline void
2706vhost_dequeue_offload_legacy(struct virtio_net *dev, struct virtio_net_hdr *hdr,
2707 struct rte_mbuf *m)
2708{
2709 uint8_t l4_proto = 0;
2710 struct rte_tcp_hdr *tcp_hdr = NULL;
2711 uint16_t tcp_len;
2712 uint16_t data_len = rte_pktmbuf_data_len(m);
2713
2714 if (parse_headers(m, &l4_proto) < 0)
2715 return;
2716
2717 if (hdr->flags == VIRTIO_NET_HDR_F_NEEDS_CSUM) {
2718 if (hdr->csum_start == (m->l2_len + m->l3_len)) {
2719 switch (hdr->csum_offset) {
2720 case (offsetof(struct rte_tcp_hdr, cksum)):
2721 if (l4_proto != IPPROTO_TCP)
2722 goto error;
2723 m->ol_flags |= RTE_MBUF_F_TX_TCP_CKSUM;
2724 break;
2725 case (offsetof(struct rte_udp_hdr, dgram_cksum)):
2726 if (l4_proto != IPPROTO_UDP)
2727 goto error;
2728 m->ol_flags |= RTE_MBUF_F_TX_UDP_CKSUM;
2729 break;
2730 case (offsetof(struct rte_sctp_hdr, cksum)):
2731 if (l4_proto != IPPROTO_SCTP)
2732 goto error;
2733 m->ol_flags |= RTE_MBUF_F_TX_SCTP_CKSUM;
2734 break;
2735 default:
2736 goto error;
2737 }
2738 } else {
2739 goto error;
2740 }
2741 }
2742
2743 if (hdr->gso_type != VIRTIO_NET_HDR_GSO_NONE) {
2744 if (hdr->gso_size == 0)
2745 goto error;
2746
2747 switch (hdr->gso_type & ~VIRTIO_NET_HDR_GSO_ECN) {
2748 case VIRTIO_NET_HDR_GSO_TCPV4:
2749 case VIRTIO_NET_HDR_GSO_TCPV6:
2750 if (l4_proto != IPPROTO_TCP)
2751 goto error;
2752 tcp_hdr = rte_pktmbuf_mtod_offset(m,
2753 struct rte_tcp_hdr *,
2754 m->l2_len + m->l3_len);
2755 tcp_len = (tcp_hdr->data_off & 0xf0) >> 2;
2756 if (data_len < m->l2_len + m->l3_len + tcp_len)
2757 goto error;
2758 m->ol_flags |= RTE_MBUF_F_TX_TCP_SEG;
2759 m->tso_segsz = hdr->gso_size;
2760 m->l4_len = tcp_len;
2761 break;
2762 case VIRTIO_NET_HDR_GSO_UDP:

Callers 1

vhost_dequeue_offloadFunction · 0.85

Calls 1

parse_headersFunction · 0.85

Tested by

no test coverage detected