]>
git.proxmox.com Git - ceph.git/blob - ceph/src/spdk/dpdk/lib/librte_gso/gso_udp4.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Intel Corporation
5 #include "gso_common.h"
8 #define IPV4_HDR_MF_BIT (1U << 13)
11 update_ipv4_udp_headers(struct rte_mbuf
*pkt
, struct rte_mbuf
**segs
,
14 struct ipv4_hdr
*ipv4_hdr
;
15 uint16_t frag_offset
= 0, is_mf
;
16 uint16_t l2_hdrlen
= pkt
->l2_len
, l3_hdrlen
= pkt
->l3_len
;
17 uint16_t tail_idx
= nb_segs
- 1, length
, i
;
20 * Update IP header fields for output segments. Specifically,
21 * keep the same IP id, update fragment offset and total
24 for (i
= 0; i
< nb_segs
; i
++) {
25 ipv4_hdr
= rte_pktmbuf_mtod_offset(segs
[i
], struct ipv4_hdr
*,
27 length
= segs
[i
]->pkt_len
- l2_hdrlen
;
28 ipv4_hdr
->total_length
= rte_cpu_to_be_16(length
);
30 is_mf
= i
< tail_idx
? IPV4_HDR_MF_BIT
: 0;
31 ipv4_hdr
->fragment_offset
=
32 rte_cpu_to_be_16(frag_offset
| is_mf
);
33 frag_offset
+= ((length
- l3_hdrlen
) >> 3);
38 gso_udp4_segment(struct rte_mbuf
*pkt
,
40 struct rte_mempool
*direct_pool
,
41 struct rte_mempool
*indirect_pool
,
42 struct rte_mbuf
**pkts_out
,
45 struct ipv4_hdr
*ipv4_hdr
;
46 uint16_t pyld_unit_size
, hdr_offset
;
50 /* Don't process the fragmented packet */
51 ipv4_hdr
= rte_pktmbuf_mtod_offset(pkt
, struct ipv4_hdr
*,
53 frag_off
= rte_be_to_cpu_16(ipv4_hdr
->fragment_offset
);
54 if (unlikely(IS_FRAGMENTED(frag_off
))) {
60 * UDP fragmentation is the same as IP fragmentation.
61 * Except the first one, other output packets just have l2
64 hdr_offset
= pkt
->l2_len
+ pkt
->l3_len
;
66 /* Don't process the packet without data. */
67 if (unlikely(hdr_offset
+ pkt
->l4_len
>= pkt
->pkt_len
)) {
72 pyld_unit_size
= gso_size
- hdr_offset
;
74 /* Segment the payload */
75 ret
= gso_do_segment(pkt
, hdr_offset
, pyld_unit_size
, direct_pool
,
76 indirect_pool
, pkts_out
, nb_pkts_out
);
78 update_ipv4_udp_headers(pkt
, pkts_out
, ret
);