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

Function gso_do_segment

dpdk/lib/gso/gso_common.c:40–123  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

38}
39
40int
41gso_do_segment(struct rte_mbuf *pkt,
42 uint16_t pkt_hdr_offset,
43 uint16_t pyld_unit_size,
44 struct rte_mempool *direct_pool,
45 struct rte_mempool *indirect_pool,
46 struct rte_mbuf **pkts_out,
47 uint16_t nb_pkts_out)
48{
49 struct rte_mbuf *pkt_in;
50 struct rte_mbuf *hdr_segment, *pyld_segment, *prev_segment;
51 uint16_t pkt_in_data_pos, segment_bytes_remaining;
52 uint16_t pyld_len, nb_segs;
53 bool more_in_pkt, more_out_segs;
54
55 pkt_in = pkt;
56 nb_segs = 0;
57 more_in_pkt = 1;
58 pkt_in_data_pos = pkt_hdr_offset;
59
60 while (more_in_pkt) {
61 if (unlikely(nb_segs >= nb_pkts_out)) {
62 free_gso_segment(pkts_out, nb_segs);
63 return -EINVAL;
64 }
65
66 /* Allocate a direct MBUF */
67 hdr_segment = rte_pktmbuf_alloc(direct_pool);
68 if (unlikely(hdr_segment == NULL)) {
69 free_gso_segment(pkts_out, nb_segs);
70 return -ENOMEM;
71 }
72 /* Fill the packet header */
73 hdr_segment_init(hdr_segment, pkt, pkt_hdr_offset);
74
75 prev_segment = hdr_segment;
76 segment_bytes_remaining = pyld_unit_size;
77 more_out_segs = 1;
78
79 while (more_out_segs && more_in_pkt) {
80 /* Allocate an indirect MBUF */
81 pyld_segment = rte_pktmbuf_alloc(indirect_pool);
82 if (unlikely(pyld_segment == NULL)) {
83 rte_pktmbuf_free(hdr_segment);
84 free_gso_segment(pkts_out, nb_segs);
85 return -ENOMEM;
86 }
87 /* Attach to current MBUF segment of pkt */
88 rte_pktmbuf_attach(pyld_segment, pkt_in);
89
90 prev_segment->next = pyld_segment;
91 prev_segment = pyld_segment;
92
93 pyld_len = segment_bytes_remaining;
94 if (pyld_len + pkt_in_data_pos > pkt_in->data_len)
95 pyld_len = pkt_in->data_len - pkt_in_data_pos;
96
97 pyld_segment->data_off = pkt_in_data_pos +

Callers 4

gso_tunnel_udp4_segmentFunction · 0.85
gso_tcp4_segmentFunction · 0.85
gso_udp4_segmentFunction · 0.85
gso_tunnel_tcp4_segmentFunction · 0.85

Calls 5

free_gso_segmentFunction · 0.85
rte_pktmbuf_allocFunction · 0.85
hdr_segment_initFunction · 0.85
rte_pktmbuf_freeFunction · 0.85
rte_pktmbuf_attachFunction · 0.85

Tested by

no test coverage detected