xref: /dpdk/lib/net/rte_gre.h (revision fba9875559906e04eaeb74532f4cfd51194259a2)
199a2dd95SBruce Richardson /* SPDX-License-Identifier: BSD-3-Clause
299a2dd95SBruce Richardson  * Copyright 2016 6WIND S.A.
399a2dd95SBruce Richardson  */
499a2dd95SBruce Richardson 
599a2dd95SBruce Richardson #ifndef _RTE_GRE_H_
699a2dd95SBruce Richardson #define _RTE_GRE_H_
799a2dd95SBruce Richardson 
899a2dd95SBruce Richardson #include <stdint.h>
999a2dd95SBruce Richardson #include <rte_byteorder.h>
1099a2dd95SBruce Richardson 
1199a2dd95SBruce Richardson /**
1299a2dd95SBruce Richardson  * @file
1399a2dd95SBruce Richardson  *
1499a2dd95SBruce Richardson  * GRE headers definition.
1599a2dd95SBruce Richardson  *
1699a2dd95SBruce Richardson  * Generic Routing Encapsulation (GRE) is a tunneling protocol
1799a2dd95SBruce Richardson  * that can encapsulate a wide variety of network layer protocols
1899a2dd95SBruce Richardson  * inside virtual point-to-point links or point-to-multipoint links
1999a2dd95SBruce Richardson  * over an Internet Protocol network.
2099a2dd95SBruce Richardson  */
2199a2dd95SBruce Richardson 
2299a2dd95SBruce Richardson /**
2399a2dd95SBruce Richardson  * GRE Header
2499a2dd95SBruce Richardson  */
2599a2dd95SBruce Richardson __extension__
26*fba98755SAndre Muezerie struct __rte_packed_begin rte_gre_hdr {
2799a2dd95SBruce Richardson #if RTE_BYTE_ORDER == RTE_LITTLE_ENDIAN
2899a2dd95SBruce Richardson 	uint16_t res2:4; /**< Reserved */
2999a2dd95SBruce Richardson 	uint16_t s:1;    /**< Sequence Number Present bit */
3099a2dd95SBruce Richardson 	uint16_t k:1;    /**< Key Present bit */
3199a2dd95SBruce Richardson 	uint16_t res1:1; /**< Reserved */
3299a2dd95SBruce Richardson 	uint16_t c:1;    /**< Checksum Present bit */
3399a2dd95SBruce Richardson 	uint16_t ver:3;  /**< Version Number */
3499a2dd95SBruce Richardson 	uint16_t res3:5; /**< Reserved */
3599a2dd95SBruce Richardson #elif RTE_BYTE_ORDER == RTE_BIG_ENDIAN
3699a2dd95SBruce Richardson 	uint16_t c:1;    /**< Checksum Present bit */
3799a2dd95SBruce Richardson 	uint16_t res1:1; /**< Reserved */
3899a2dd95SBruce Richardson 	uint16_t k:1;    /**< Key Present bit */
3999a2dd95SBruce Richardson 	uint16_t s:1;    /**< Sequence Number Present bit */
4099a2dd95SBruce Richardson 	uint16_t res2:4; /**< Reserved */
4199a2dd95SBruce Richardson 	uint16_t res3:5; /**< Reserved */
4299a2dd95SBruce Richardson 	uint16_t ver:3;  /**< Version Number */
4399a2dd95SBruce Richardson #endif
447f9cf804SThomas Monjalon 	rte_be16_t proto;  /**< Protocol Type */
45*fba98755SAndre Muezerie } __rte_packed_end;
4699a2dd95SBruce Richardson 
477786991fSSean Zhang /**
487786991fSSean Zhang  * Optional field checksum in GRE header
497786991fSSean Zhang  */
50*fba98755SAndre Muezerie struct __rte_packed_begin rte_gre_hdr_opt_checksum_rsvd {
517786991fSSean Zhang 	rte_be16_t checksum;
527786991fSSean Zhang 	rte_be16_t reserved1;
53*fba98755SAndre Muezerie } __rte_packed_end;
547786991fSSean Zhang 
557786991fSSean Zhang /**
567786991fSSean Zhang  * Optional field key in GRE header
577786991fSSean Zhang  */
58*fba98755SAndre Muezerie struct __rte_packed_begin rte_gre_hdr_opt_key {
597786991fSSean Zhang 	rte_be32_t key;
60*fba98755SAndre Muezerie } __rte_packed_end;
617786991fSSean Zhang 
627786991fSSean Zhang /**
637786991fSSean Zhang  * Optional field sequence in GRE header
647786991fSSean Zhang  */
65*fba98755SAndre Muezerie struct __rte_packed_begin rte_gre_hdr_opt_sequence {
667786991fSSean Zhang 	rte_be32_t sequence;
67*fba98755SAndre Muezerie } __rte_packed_end;
687786991fSSean Zhang 
6999a2dd95SBruce Richardson #endif /* RTE_GRE_H_ */
70