1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
10 * Interface to GSO library
20 /* Minimum GSO segment size. */
21 #define RTE_GSO_SEG_SIZE_MIN (sizeof(struct ether_hdr) + \
22 sizeof(struct ipv4_hdr) + sizeof(struct tcp_hdr) + 1)
24 /* GSO flags for rte_gso_ctx. */
25 #define RTE_GSO_FLAG_IPID_FIXED (1ULL << 0)
26 /**< Use fixed IP ids for output GSO segments. Setting
27 * 0 indicates using incremental IP ids.
31 * GSO context structure.
34 struct rte_mempool *direct_pool;
35 /**< MBUF pool for allocating direct buffers, which are used
36 * to store packet headers for GSO segments.
38 struct rte_mempool *indirect_pool;
39 /**< MBUF pool for allocating indirect buffers, which are used
40 * to locate packet payloads for GSO segments. The indirect
41 * buffer doesn't contain any data, but simply points to an
42 * offset within the packet to segment.
45 /**< flag that controls specific attributes of output segments,
46 * such as the type of IP ID generated (i.e. fixed or incremental).
49 /**< the bit mask of required GSO types. The GSO library
50 * uses the same macros as that of describing device TX
51 * offloading capabilities (i.e. DEV_TX_OFFLOAD_*_TSO) for
54 * For example, if applications want to segment TCP/IPv4
55 * packets, set DEV_TX_OFFLOAD_TCP_TSO in gso_types.
58 /**< maximum size of an output GSO segment, including packet
59 * header and payload, measured in bytes. Must exceed
60 * RTE_GSO_SEG_SIZE_MIN.
65 * Segmentation function, which supports processing of both single- and
66 * multi- MBUF packets.
68 * Note that we refer to the packets that are segmented from the input
69 * packet as 'GSO segments'. rte_gso_segment() doesn't check if the
70 * input packet has correct checksums, and doesn't update checksums for
71 * output GSO segments. Additionally, it doesn't process IP fragment
74 * Before calling rte_gso_segment(), applications must set proper ol_flags
75 * for the packet. The GSO library uses the same macros as that of TSO.
76 * For example, set PKT_TX_TCP_SEG and PKT_TX_IPV4 in ol_flags to segment
77 * a TCP/IPv4 packet. If rte_gso_segment() succeeds, the PKT_TX_TCP_SEG
78 * flag is removed for all GSO segments and the input packet.
80 * Each of the newly-created GSO segments is organized as a two-segment
81 * MBUF, where the first segment is a standard MBUF, which stores a copy
82 * of packet header, and the second is an indirect MBUF which points to
83 * a section of data in the input packet. Since each GSO segment has
84 * multiple MBUFs (i.e. typically 2 MBUFs), the driver of the interface which
85 * the GSO segments are sent to should support transmission of multi-segment
88 * If the input packet is GSO'd, its mbuf refcnt reduces by 1. Therefore,
89 * when all GSO segments are freed, the input packet is freed automatically.
91 * If the memory space in pkts_out or MBUF pools is insufficient, this
92 * function fails, and it returns (-1) * errno. Otherwise, GSO succeeds,
93 * and this function returns the number of output GSO segments filled in
97 * The packet mbuf to segment.
99 * GSO context object pointer.
101 * Pointer array used to store the MBUF addresses of output GSO
102 * segments, when rte_gso_segment() succeeds.
104 * The max number of items that pkts_out can keep.
107 * - The number of GSO segments filled in pkts_out on success.
108 * - Return -ENOMEM if run out of memory in MBUF pools.
109 * - Return -EINVAL for invalid parameters.
111 int rte_gso_segment(struct rte_mbuf *pkt,
112 const struct rte_gso_ctx *ctx,
113 struct rte_mbuf **pkts_out,
114 uint16_t nb_pkts_out);
119 #endif /* _RTE_GSO_H_ */