CNDP  22.08.0
pktmbuf_ptype.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright (c) 2010-2022 Intel Corporation.
3  * Copyright 2014-2016 6WIND S.A.
4  */
5 
6 #include <net/cne_ip.h>
7 #include <net/cne_udp.h>
8 #include <net/cne_tcp.h>
9 #include <net/cne_sctp.h>
10 
11 #ifndef _PKTMBUF_PTYPE_H_
12 #define _PKTMBUF_PTYPE_H_
13 
70 #include <stddef.h>
71 #include <stdint.h>
72 
73 #ifdef __cplusplus
74 extern "C" {
75 #endif
76 
82  uint8_t l2_len;
83  uint8_t inner_l2_len;
84  uint16_t l3_len;
85  uint16_t inner_l3_len;
86  uint16_t tunnel_len;
87  uint8_t l4_len;
88  uint8_t inner_l4_len;
89 };
90 
94 #define CNE_PTYPE_UNKNOWN 0x00000000
102 #define CNE_PTYPE_L2_ETHER 0x00000001
109 #define CNE_PTYPE_L2_ETHER_TIMESYNC 0x00000002
116 #define CNE_PTYPE_L2_ETHER_ARP 0x00000003
123 #define CNE_PTYPE_L2_ETHER_LLDP 0x00000004
130 #define CNE_PTYPE_L2_ETHER_NSH 0x00000005
137 #define CNE_PTYPE_L2_ETHER_VLAN 0x00000006
144 #define CNE_PTYPE_L2_ETHER_QINQ 0x00000007
151 #define CNE_PTYPE_L2_ETHER_PPPOE 0x00000008
158 #define CNE_PTYPE_L2_ETHER_FCOE 0x00000009
165 #define CNE_PTYPE_L2_ETHER_MPLS 0x0000000a
170 #define CNE_PTYPE_L2_MASK 0x0000000f
180 #define CNE_PTYPE_L3_IPV4 0x00000010
190 #define CNE_PTYPE_L3_IPV4_EXT 0x00000030
200 #define CNE_PTYPE_L3_IPV6 0x00000040
210 #define CNE_PTYPE_L3_IPV4_EXT_UNKNOWN 0x00000090
221 #define CNE_PTYPE_L3_IPV6_EXT 0x000000c0
232 #define CNE_PTYPE_L3_IPV6_EXT_UNKNOWN 0x000000e0
237 #define CNE_PTYPE_L3_MASK 0x000000f0
249 #define CNE_PTYPE_L4_TCP 0x00000100
261 #define CNE_PTYPE_L4_UDP 0x00000200
281 #define CNE_PTYPE_L4_FRAG 0x00000300
293 #define CNE_PTYPE_L4_SCTP 0x00000400
305 #define CNE_PTYPE_L4_ICMP 0x00000500
321 #define CNE_PTYPE_L4_NONFRAG 0x00000600
329 #define CNE_PTYPE_L4_IGMP 0x00000700
334 #define CNE_PTYPE_L4_MASK 0x00000f00
345 #define CNE_PTYPE_TUNNEL_IP 0x00001000
356 #define CNE_PTYPE_TUNNEL_GRE 0x00002000
369 #define CNE_PTYPE_TUNNEL_VXLAN 0x00003000
383 #define CNE_PTYPE_TUNNEL_NVGRE 0x00004000
396 #define CNE_PTYPE_TUNNEL_GENEVE 0x00005000
403 #define CNE_PTYPE_TUNNEL_GRENAT 0x00006000
423 #define CNE_PTYPE_TUNNEL_GTPC 0x00007000
435 #define CNE_PTYPE_TUNNEL_GTPU 0x00008000
446 #define CNE_PTYPE_TUNNEL_ESP 0x00009000
465 #define CNE_PTYPE_TUNNEL_L2TP 0x0000a000
478 #define CNE_PTYPE_TUNNEL_VXLAN_GPE 0x0000b000
499 #define CNE_PTYPE_TUNNEL_MPLS_IN_GRE 0x0000c000
512 #define CNE_PTYPE_TUNNEL_MPLS_IN_UDP 0x0000d000
516 #define CNE_PTYPE_TUNNEL_MASK 0x0000f000
524 #define CNE_PTYPE_INNER_L2_ETHER 0x00010000
531 #define CNE_PTYPE_INNER_L2_ETHER_VLAN 0x00020000
538 #define CNE_PTYPE_INNER_L2_ETHER_QINQ 0x00030000
542 #define CNE_PTYPE_INNER_L2_MASK 0x000f0000
551 #define CNE_PTYPE_INNER_L3_IPV4 0x00100000
560 #define CNE_PTYPE_INNER_L3_IPV4_EXT 0x00200000
569 #define CNE_PTYPE_INNER_L3_IPV6 0x00300000
578 #define CNE_PTYPE_INNER_L3_IPV4_EXT_UNKNOWN 0x00400000
588 #define CNE_PTYPE_INNER_L3_IPV6_EXT 0x00500000
599 #define CNE_PTYPE_INNER_L3_IPV6_EXT_UNKNOWN 0x00600000
603 #define CNE_PTYPE_INNER_L3_MASK 0x00f00000
615 #define CNE_PTYPE_INNER_L4_TCP 0x01000000
627 #define CNE_PTYPE_INNER_L4_UDP 0x02000000
642 #define CNE_PTYPE_INNER_L4_FRAG 0x03000000
654 #define CNE_PTYPE_INNER_L4_SCTP 0x04000000
666 #define CNE_PTYPE_INNER_L4_ICMP 0x05000000
679 #define CNE_PTYPE_INNER_L4_NONFRAG 0x06000000
683 #define CNE_PTYPE_INNER_L4_MASK 0x0f000000
687 #define CNE_PTYPE_ALL_MASK 0x0fffffff
688 
694 #define CNE_ETH_IS_IPV4_HDR(ptype) ((ptype)&CNE_PTYPE_L3_IPV4)
695 
701 #define CNE_ETH_IS_IPV6_HDR(ptype) ((ptype)&CNE_PTYPE_L3_IPV6)
702 
703 /* Check if it is a tunneling packet */
704 #define CNE_ETH_IS_TUNNEL_PKT(ptype) \
705  ((ptype) & (CNE_PTYPE_TUNNEL_MASK | CNE_PTYPE_INNER_L2_MASK | CNE_PTYPE_INNER_L3_MASK | \
706  CNE_PTYPE_INNER_L4_MASK))
707 
739 CNDP_API uint32_t cne_get_ptype(const pktmbuf_t *m, struct cne_net_hdr_lens *hdr_lens,
740  uint32_t layers);
741 
750 CNDP_API const char *cne_get_ptype_l2_name(uint32_t ptype);
751 
760 CNDP_API const char *cne_get_ptype_l3_name(uint32_t ptype);
761 
770 CNDP_API const char *cne_get_ptype_l4_name(uint32_t ptype);
771 
780 CNDP_API const char *cne_get_ptype_tunnel_name(uint32_t ptype);
781 
790 CNDP_API const char *cne_get_ptype_inner_l2_name(uint32_t ptype);
791 
800 CNDP_API const char *cne_get_ptype_inner_l3_name(uint32_t ptype);
801 
810 CNDP_API const char *cne_get_ptype_inner_l4_name(uint32_t ptype);
811 
825 CNDP_API int cne_get_ptype_name(uint32_t ptype, char *buf, size_t buflen);
826 
827 #ifdef __cplusplus
828 }
829 #endif
830 
831 #endif /* _PKTMBUF_PTYPE_H_ */
CNDP_API int cne_get_ptype_name(uint32_t ptype, char *buf, size_t buflen)
CNDP_API const char * cne_get_ptype_l4_name(uint32_t ptype)
CNDP_API const char * cne_get_ptype_inner_l3_name(uint32_t ptype)
CNDP_API uint32_t cne_get_ptype(const pktmbuf_t *m, struct cne_net_hdr_lens *hdr_lens, uint32_t layers)
CNDP_API const char * cne_get_ptype_l3_name(uint32_t ptype)
CNDP_API const char * cne_get_ptype_inner_l2_name(uint32_t ptype)
CNDP_API const char * cne_get_ptype_l2_name(uint32_t ptype)
CNDP_API const char * cne_get_ptype_inner_l4_name(uint32_t ptype)
CNDP_API const char * cne_get_ptype_tunnel_name(uint32_t ptype)
uint8_t inner_l2_len
Definition: pktmbuf_ptype.h:83
uint16_t inner_l3_len
Definition: pktmbuf_ptype.h:85
uint8_t inner_l4_len
Definition: pktmbuf_ptype.h:88
uint16_t tunnel_len
Definition: pktmbuf_ptype.h:86