26 #include <rte_ether.h>
33 #include <rte_vxlan.h>
41 #define GTP_ESPN_FLAGS_ON(p) (p & 0x7)
42 #define GTP_EXT_FLAGS_ON(p) (p & 0x4)
46 return ((
struct rte_ether_hdr *)pinfo->
outer.
l2)->dst_addr.addr_bytes;
51 return ((
struct rte_ether_hdr *)pinfo->
outer.
l2)->src_addr.addr_bytes;
56 return ((
struct rte_ipv4_hdr *)pinfo->
outer.
l3)->dst_addr;
61 return ((
struct rte_ipv4_hdr *)pinfo->
outer.
l3)->src_addr;
66 return ((
struct rte_ipv4_hdr *)pinfo->
inner.
l3)->dst_addr;
71 return ((
struct rte_ipv4_hdr *)pinfo->
inner.
l3)->src_addr;
86 return ((
struct rte_tcp_hdr *)fmt->
l4)->src_port;
88 return ((
struct rte_udp_hdr *)fmt->
l4)->src_port;
106 return ((
struct rte_tcp_hdr *)fmt->
l4)->dst_port;
108 return ((
struct rte_udp_hdr *)fmt->
l4)->dst_port;
145 struct rte_ether_hdr *
eth =
NULL;
146 struct rte_ipv4_hdr *iphdr;
153 eth = (
struct rte_ether_hdr *)data;
155 switch (rte_be_to_cpu_16(
eth->ether_type)) {
156 case RTE_ETHER_TYPE_IPV4:
157 l3_off =
sizeof(
struct rte_ether_hdr);
159 case RTE_ETHER_TYPE_IPV6:
160 l3_off =
sizeof(
struct rte_ether_hdr);
163 case RTE_ETHER_TYPE_ARP:
171 iphdr = (
struct rte_ipv4_hdr *)(data + l3_off);
172 if ((iphdr->version_ihl >> 4) != 4)
174 if (iphdr->src_addr == 0 || iphdr->dst_addr == 0)
176 fmt->
l3 = (data + l3_off);
178 l4_off = l3_off + rte_ipv4_hdr_len(iphdr);
179 fmt->
l4 = data + l4_off;
180 switch (iphdr->next_proto_id) {
182 struct rte_tcp_hdr *tcphdr = (
struct rte_tcp_hdr *)(data + l4_off);
184 l7_off = l4_off + ((tcphdr->data_off & 0xf0) >> 2);
188 fmt->
l7 = (data + l7_off);
192 struct rte_udp_hdr *udphdr = (
struct rte_udp_hdr *)(data + l4_off);
194 l7_off = l4_off +
sizeof(*udphdr);
198 fmt->
l7 = (data + l7_off);
226 int optional_off = 0;
227 struct rte_gre_hdr *gre_hdr = (
struct rte_gre_hdr *)pinfo->
outer.
l4;
232 pinfo->
tun.
gre_key = *(uint32_t *)(pinfo->
outer.
l4 +
sizeof(
struct rte_gre_hdr));
233 pinfo->
tun.
l2 =
true;
239 return sizeof(
struct rte_gre_hdr) + optional_off;
243 struct rte_udp_hdr *udphdr = (
struct rte_udp_hdr *)pinfo->
outer.
l4;
244 uint8_t *udp_data = pinfo->
outer.
l4 +
sizeof(
struct rte_udp_hdr);
246 switch (rte_cpu_to_be_16(udphdr->dst_port)) {
248 struct rte_vxlan_gpe_hdr *vxlanhdr = (
struct rte_vxlan_gpe_hdr *)udp_data;
250 if (vxlanhdr->vx_flags & 0x08) {
253 pinfo->
tun.
vni = vxlanhdr->vx_vni;
254 pinfo->
tun.
l2 =
true;
256 return sizeof(
struct rte_vxlan_gpe_hdr) + sizeof(struct rte_udp_hdr);
259 int off =
sizeof(
struct rte_gtp_hdr) + sizeof(struct rte_udp_hdr);
260 struct rte_gtp_hdr *gtphdr = (
struct rte_gtp_hdr *)udp_data;
263 pinfo->
tun.
teid = gtphdr->teid;
266 pinfo->
tun.
l2 =
false;
298 inner_off = (pinfo->
outer.
l4 - data) + off;
303 inner_off = (pinfo->
outer.
l4 - data) + off;
308 inner_off = (pinfo->
outer.
l4 - data) + off;
if(bitoffset % 64+bitlength > 64) result|
#define DOCA_FLOW_VXLAN_DEFAULT_PORT
#define DOCA_FLOW_PROTO_GRE
#define DOCA_FLOW_PROTO_UDP
#define DOCA_FLOW_PROTO_TCP
#define DOCA_FLOW_GTPU_DEFAULT_PORT
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_WARN(format,...)
Generates a WARNING application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
#define DOCA_LOG_DBG(format,...)
Generates a DEBUG application log message.
uint16_t doca_be16_t
Declare DOCA endianity types.
doca_be16_t simple_fwd_pinfo_inner_dst_port(struct simple_fwd_pkt_info *pinfo)
doca_be16_t simple_fwd_pinfo_outer_dst_port(struct simple_fwd_pkt_info *pinfo)
static int simple_fwd_parse_is_tun(struct simple_fwd_pkt_info *pinfo)
void simple_fwd_pinfo_decap(struct simple_fwd_pkt_info *pinfo)
doca_be32_t simple_fwd_pinfo_outer_ipv4_src(struct simple_fwd_pkt_info *pinfo)
#define GTP_ESPN_FLAGS_ON(p)
DOCA_LOG_REGISTER(SIMPLE_FWD_PKT)
doca_be16_t simple_fwd_pinfo_inner_src_port(struct simple_fwd_pkt_info *pinfo)
doca_be16_t simple_fwd_pinfo_outer_src_port(struct simple_fwd_pkt_info *pinfo)
doca_be32_t simple_fwd_pinfo_inner_ipv4_src(struct simple_fwd_pkt_info *pinfo)
doca_be32_t simple_fwd_pinfo_inner_ipv4_dst(struct simple_fwd_pkt_info *pinfo)
static doca_be16_t simple_fwd_pinfo_dst_port(struct simple_fwd_pkt_format *fmt)
static doca_be16_t simple_fwd_pinfo_src_port(struct simple_fwd_pkt_format *fmt)
int simple_fwd_parse_packet(uint8_t *data, int len, struct simple_fwd_pkt_info *pinfo)
uint8_t * simple_fwd_pinfo_outer_mac_src(struct simple_fwd_pkt_info *pinfo)
doca_be32_t simple_fwd_pinfo_outer_ipv4_dst(struct simple_fwd_pkt_info *pinfo)
static int simple_fwd_parse_pkt_format(uint8_t *data, int len, bool l2, struct simple_fwd_pkt_format *fmt)
uint8_t * simple_fwd_pinfo_outer_mac_dst(struct simple_fwd_pkt_info *pinfo)
struct simple_fwd_pkt_format outer
enum doca_flow_tun_type tun_type
struct simple_fwd_pkt_format inner
struct simple_fwd_pkt_tun_format tun