NVIDIA DOCA SDK
Data Center on a Chip Framework Documentation
packets.h
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2023 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3
*
4
* Redistribution and use in source and binary forms, with or without modification, are permitted
5
* provided that the following conditions are met:
6
* * Redistributions of source code must retain the above copyright notice, this list of
7
* conditions and the following disclaimer.
8
* * Redistributions in binary form must reproduce the above copyright notice, this list of
9
* conditions and the following disclaimer in the documentation and/or other materials
10
* provided with the distribution.
11
* * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12
* to endorse or promote products derived from this software without specific prior written
13
* permission.
14
*
15
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21
* STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
*
24
*/
25
26
#ifndef DOCA_GPUNETIO_PACKETS_H
27
#define DOCA_GPUNETIO_PACKETS_H
28
29
#include "
common.h
"
30
31
#define TCP_PROTOCOL_ID 0x6
32
#define UDP_PROTOCOL_ID 0x11
33
34
#define DNS_POST 0x35
35
#define WHITESPACE_ASCII 0x20
36
37
/* ICMP packet types */
38
#define ICMP_ECHO_REPLY 0
39
#define ICMP_ECHO_REQUEST 8
40
41
enum
tcp_flags
{
42
TCP_FLAG_FIN
= (1 << 0),
43
/* set tcp packet with Fin flag */
44
TCP_FLAG_SYN
= (1 << 1),
45
/* set tcp packet with Syn flag */
46
TCP_FLAG_RST
= (1 << 2),
47
/* set tcp packet with Rst flag */
48
TCP_FLAG_PSH
= (1 << 3),
49
/* set tcp packet with Psh flag */
50
TCP_FLAG_ACK
= (1 << 4),
51
/* set tcp packet with Ack flag */
52
TCP_FLAG_URG
= (1 << 5),
53
/* set tcp packet with Urg flag */
54
TCP_FLAG_ECE
= (1 << 6),
55
/* set tcp packet with ECE flag */
56
TCP_FLAG_CWR
= (1 << 7),
57
/* set tcp packet with CQE flag */
58
};
59
60
struct
ether_hdr
{
61
uint8_t
d_addr_bytes
[
ETHER_ADDR_LEN
];
/* Destination addr bytes in tx order */
62
uint8_t
s_addr_bytes
[
ETHER_ADDR_LEN
];
/* Source addr bytes in tx order */
63
uint16_t
ether_type
;
/* Frame type */
64
}
__attribute__
((__packed__));
65
66
struct
ipv4_hdr
{
67
uint8_t
version_ihl
;
/* version and header length */
68
uint8_t
type_of_service
;
/* type of service */
69
uint16_t
total_length
;
/* length of packet */
70
uint16_t
packet_id
;
/* packet ID */
71
uint16_t
fragment_offset
;
/* fragmentation offset */
72
uint8_t
time_to_live
;
/* time to live */
73
uint8_t
next_proto_id
;
/* protocol ID */
74
uint16_t
hdr_checksum
;
/* header checksum */
75
uint32_t
src_addr
;
/* source address */
76
uint32_t
dst_addr
;
/* destination address */
77
}
__attribute__
((__packed__));
78
79
struct
tcp_hdr
{
80
uint16_t
src_port
;
/* TCP source port */
81
uint16_t
dst_port
;
/* TCP destination port */
82
uint32_t
sent_seq
;
/* TX data sequence number */
83
uint32_t
recv_ack
;
/* RX data acknowledgment sequence number */
84
uint8_t
dt_off
;
/* Data offset */
85
uint8_t
tcp_flags
;
/* TCP flags */
86
uint16_t
rx_win
;
/* RX flow control window */
87
uint16_t
cksum
;
/* TCP checksum */
88
uint16_t
tcp_urp
;
/* TCP urgent pointer, if any */
89
}
__attribute__
((__packed__));
90
91
struct
eth_ip_tcp_hdr
{
92
struct
ether_hdr
l2_hdr
;
/* Ethernet header */
93
struct
ipv4_hdr
l3_hdr
;
/* IP header */
94
struct
tcp_hdr
l4_hdr
;
/* TCP header */
95
}
__attribute__
((__packed__));
96
97
struct
udp_hdr
{
98
uint16_t
src_port
;
/* UDP source port */
99
uint16_t
dst_port
;
/* UDP destination port */
100
uint16_t
dgram_len
;
/* UDP datagram length */
101
uint16_t
dgram_cksum
;
/* UDP datagram checksum */
102
}
__attribute__
((__packed__));
103
104
struct
eth_ip_udp_hdr
{
105
struct
ether_hdr
l2_hdr
;
/* Ethernet header */
106
struct
ipv4_hdr
l3_hdr
;
/* IP header */
107
struct
udp_hdr
l4_hdr
;
/* UDP header */
108
}
__attribute__
((__packed__));
109
113
struct
icmp_hdr
{
114
uint8_t
type
;
/* ICMP packet type */
115
uint8_t
code
;
/* ICMP packet code */
116
uint16_t
cksum
;
/* ICMP packet checksum */
117
uint16_t
ident
;
/* ICMP packet identifier */
118
uint16_t
seq_nb
;
/* ICMP packet sequence number */
119
}
__attribute__
((__packed__));
120
121
struct
eth_ip_icmp_hdr
{
122
struct
ether_hdr
l2_hdr
;
/* Ethernet header */
123
struct
ipv4_hdr
l3_hdr
;
/* IP header */
124
struct
icmp_hdr
l4_hdr
;
/* ICMP header */
125
}
__attribute__
((__packed__));
126
127
#endif
/* DOCA_GPUNETIO_PACKETS_H */
ETHER_ADDR_LEN
#define ETHER_ADDR_LEN
Definition:
defines.h:77
__attribute__
struct ether_hdr __attribute__((__packed__))
Definition:
doca_flow.h:267
tcp_flags
tcp_flags
Definition:
packets.h:41
TCP_FLAG_RST
@ TCP_FLAG_RST
Definition:
packets.h:46
TCP_FLAG_FIN
@ TCP_FLAG_FIN
Definition:
packets.h:42
TCP_FLAG_PSH
@ TCP_FLAG_PSH
Definition:
packets.h:48
TCP_FLAG_CWR
@ TCP_FLAG_CWR
Definition:
packets.h:56
TCP_FLAG_ACK
@ TCP_FLAG_ACK
Definition:
packets.h:50
TCP_FLAG_ECE
@ TCP_FLAG_ECE
Definition:
packets.h:54
TCP_FLAG_URG
@ TCP_FLAG_URG
Definition:
packets.h:52
TCP_FLAG_SYN
@ TCP_FLAG_SYN
Definition:
packets.h:44
common.h
eth_ip_icmp_hdr
Definition:
packets.h:121
eth_ip_icmp_hdr::l4_hdr
struct icmp_hdr l4_hdr
Definition:
packets.h:124
eth_ip_icmp_hdr::l2_hdr
struct ether_hdr l2_hdr
Definition:
packets.h:122
eth_ip_icmp_hdr::l3_hdr
struct ipv4_hdr l3_hdr
Definition:
packets.h:123
eth_ip_tcp_hdr
Definition:
packets.h:91
eth_ip_tcp_hdr::l3_hdr
struct ipv4_hdr l3_hdr
Definition:
packets.h:93
eth_ip_tcp_hdr::l4_hdr
struct tcp_hdr l4_hdr
Definition:
packets.h:94
eth_ip_tcp_hdr::l2_hdr
struct ether_hdr l2_hdr
Definition:
packets.h:92
eth_ip_udp_hdr
Definition:
packets.h:104
eth_ip_udp_hdr::l3_hdr
struct ipv4_hdr l3_hdr
Definition:
packets.h:106
eth_ip_udp_hdr::l2_hdr
struct ether_hdr l2_hdr
Definition:
packets.h:105
eth_ip_udp_hdr::l4_hdr
struct udp_hdr l4_hdr
Definition:
packets.h:107
ether_hdr
Definition:
packets.h:60
ether_hdr::s_addr_bytes
uint8_t s_addr_bytes[ETHER_ADDR_LEN]
Definition:
packets.h:62
ether_hdr::d_addr_bytes
uint8_t d_addr_bytes[ETHER_ADDR_LEN]
Definition:
packets.h:61
ether_hdr::ether_type
uint16_t ether_type
Definition:
packets.h:63
icmp_hdr
Definition:
packets.h:113
icmp_hdr::ident
uint16_t ident
Definition:
packets.h:117
icmp_hdr::type
uint8_t type
Definition:
packets.h:114
icmp_hdr::seq_nb
uint16_t seq_nb
Definition:
packets.h:118
icmp_hdr::code
uint8_t code
Definition:
packets.h:115
icmp_hdr::cksum
uint16_t cksum
Definition:
packets.h:116
ipv4_hdr
Definition:
packets.h:66
ipv4_hdr::fragment_offset
uint16_t fragment_offset
Definition:
packets.h:71
ipv4_hdr::src_addr
uint32_t src_addr
Definition:
packets.h:75
ipv4_hdr::packet_id
uint16_t packet_id
Definition:
packets.h:70
ipv4_hdr::dst_addr
uint32_t dst_addr
Definition:
packets.h:76
ipv4_hdr::type_of_service
uint8_t type_of_service
Definition:
packets.h:68
ipv4_hdr::time_to_live
uint8_t time_to_live
Definition:
packets.h:72
ipv4_hdr::total_length
uint16_t total_length
Definition:
packets.h:69
ipv4_hdr::hdr_checksum
uint16_t hdr_checksum
Definition:
packets.h:74
ipv4_hdr::version_ihl
uint8_t version_ihl
Definition:
packets.h:67
ipv4_hdr::next_proto_id
uint8_t next_proto_id
Definition:
packets.h:73
tcp_hdr
Definition:
packets.h:79
tcp_hdr::recv_ack
uint32_t recv_ack
Definition:
packets.h:83
tcp_hdr::src_port
uint16_t src_port
Definition:
packets.h:80
tcp_hdr::sent_seq
uint32_t sent_seq
Definition:
packets.h:82
tcp_hdr::tcp_flags
uint8_t tcp_flags
Definition:
packets.h:85
tcp_hdr::dst_port
uint16_t dst_port
Definition:
packets.h:81
tcp_hdr::cksum
uint16_t cksum
Definition:
packets.h:87
tcp_hdr::tcp_urp
uint16_t tcp_urp
Definition:
packets.h:88
tcp_hdr::dt_off
uint8_t dt_off
Definition:
packets.h:84
tcp_hdr::rx_win
uint16_t rx_win
Definition:
packets.h:86
udp_hdr
Definition:
packets.h:97
udp_hdr::dst_port
uint16_t dst_port
Definition:
packets.h:99
udp_hdr::dgram_len
uint16_t dgram_len
Definition:
packets.h:100
udp_hdr::dgram_cksum
uint16_t dgram_cksum
Definition:
packets.h:101
udp_hdr::src_port
uint16_t src_port
Definition:
packets.h:98
applications
gpu_packet_processing
config_queues
packets.h
Generated on Wed Aug 13 2025 09:23:36 for NVIDIA DOCA SDK by
1.9.1