1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 1982, 1986, 1990, 1993
3 * The Regents of the University of California.
4 * Copyright(c) 2010-2014 Intel Corporation.
18 #include <rte_byteorder.h>
25 * Simplified GTP protocol header.
26 * Contains 8-bit header info, 8-bit message type,
27 * 16-bit payload length after mandatory header, 32-bit TEID.
28 * No optional fields and next extension header.
33 uint8_t gtp_hdr_info; /**< GTP header info */
35 #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
36 uint8_t pn:1; /**< N-PDU Number present bit */
37 uint8_t s:1; /**< Sequence Number Present bit */
38 uint8_t e:1; /**< Extension Present bit */
39 uint8_t res1:1; /**< Reserved */
40 uint8_t pt:1; /**< Protocol Type bit */
41 uint8_t ver:3; /**< Version Number */
42 #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
43 uint8_t ver:3; /**< Version Number */
44 uint8_t pt:1; /**< Protocol Type bit */
45 uint8_t res1:1; /**< Reserved */
46 uint8_t e:1; /**< Extension Present bit */
47 uint8_t s:1; /**< Sequence Number Present bit */
48 uint8_t pn:1; /**< N-PDU Number present bit */
52 uint8_t msg_type; /**< GTP message type */
53 rte_be16_t plen; /**< Total payload length */
54 rte_be32_t teid; /**< Tunnel endpoint ID */
57 /* Optional word of GTP header, present if any of E, S, PN is set. */
58 struct rte_gtp_hdr_ext_word {
59 rte_be16_t sqn; /**< Sequence Number. */
60 uint8_t npdu; /**< N-PDU number. */
61 uint8_t next_ext; /**< Next Extension Header Type. */
65 * Optional extension for GTP with next_ext set to 0x85
66 * defined based on RFC 38415-g30.
69 struct rte_gtp_psc_generic_hdr {
70 uint8_t ext_hdr_len; /**< PDU ext hdr len in multiples of 4 bytes */
71 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
72 uint8_t type:4; /**< PDU type */
73 uint8_t qmp:1; /**< Qos Monitoring Packet */
74 uint8_t pad:3; /**< type specific pad bits */
75 uint8_t spare:2; /**< type specific spare bits */
76 uint8_t qfi:6; /**< Qos Flow Identifier */
78 uint8_t qfi:6; /**< Qos Flow Identifier */
79 uint8_t spare:2; /**< type specific spare bits */
80 uint8_t pad:3; /**< type specific pad bits */
81 uint8_t qmp:1; /**< Qos Monitoring Packet */
82 uint8_t type:4; /**< PDU type */
84 uint8_t data[0]; /**< variable length data fields */
88 * Optional extension for GTP with next_ext set to 0x85
89 * type0 defined based on RFC 38415-g30
92 struct rte_gtp_psc_type0_hdr {
93 uint8_t ext_hdr_len; /**< PDU ext hdr len in multiples of 4 bytes */
94 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
95 uint8_t type:4; /**< PDU type */
96 uint8_t qmp:1; /**< Qos Monitoring Packet */
97 uint8_t snp:1; /**< Sequence number presence */
98 uint8_t spare_dl1:2; /**< spare down link bits */
99 uint8_t ppp:1; /**< Paging policy presence */
100 uint8_t rqi:1; /**< Reflective Qos Indicator */
101 uint8_t qfi:6; /**< Qos Flow Identifier */
103 uint8_t qfi:6; /**< Qos Flow Identifier */
104 uint8_t rqi:1; /**< Reflective Qos Indicator */
105 uint8_t ppp:1; /**< Paging policy presence */
106 uint8_t spare_dl1:2; /**< spare down link bits */
107 uint8_t snp:1; /**< Sequence number presence */
108 uint8_t type:4; /**< PDU type */
110 uint8_t data[0]; /**< variable length data fields */
114 * Optional extension for GTP with next_ext set to 0x85
115 * type1 defined based on RFC 38415-g30
118 struct rte_gtp_psc_type1_hdr {
119 uint8_t ext_hdr_len; /**< PDU ext hdr len in multiples of 4 bytes */
120 #if RTE_BYTE_ORDER == RTE_BIG_ENDIAN
121 uint8_t type:4; /**< PDU type */
122 uint8_t qmp:1; /**< Qos Monitoring Packet */
123 uint8_t dl_delay_ind:1; /**< dl delay result presence */
124 uint8_t ul_delay_ind:1; /**< ul delay result presence */
125 uint8_t snp:1; /**< Sequence number presence ul */
126 uint8_t n_delay_ind:1; /**< N3/N9 delay result presence */
127 uint8_t spare_ul2:1; /**< spare up link bits */
128 uint8_t qfi:6; /**< Qos Flow Identifier */
130 uint8_t qfi:6; /**< Qos Flow Identifier */
131 uint8_t spare_ul2:1; /**< spare up link bits */
132 uint8_t n_delay_ind:1; /**< N3/N9 delay result presence */
133 uint8_t snp:1; /**< Sequence number presence ul */
134 uint8_t ul_delay_ind:1; /**< ul delay result presence */
135 uint8_t dl_delay_ind:1; /**< dl delay result presence */
136 uint8_t qmp:1; /**< Qos Monitoring Packet */
137 uint8_t type:4; /**< PDU type */
139 uint8_t data[0]; /**< variable length data fields */
142 /** GTP header length */
143 #define RTE_ETHER_GTP_HLEN \
144 (sizeof(struct rte_udp_hdr) + sizeof(struct rte_gtp_hdr))
145 /* GTP next protocal type */
146 #define RTE_GTP_TYPE_IPV4 0x40 /**< GTP next protocal type IPv4 */
147 #define RTE_GTP_TYPE_IPV6 0x60 /**< GTP next protocal type IPv6 */
148 /* GTP destination port number */
149 #define RTE_GTPC_UDP_PORT 2123 /**< GTP-C UDP destination port */
150 #define RTE_GTPU_UDP_PORT 2152 /**< GTP-U UDP destination port */
156 #endif /* RTE_GTP_H_ */