NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
tcp_cpu_rss_func.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023-2024 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_GPU_PACKET_PROCESSING_TCP_RSS_H
27 #define DOCA_GPU_PACKET_PROCESSING_TCP_RSS_H
28 
29 #include <stdbool.h>
30 #include <arpa/inet.h>
31 
32 #include <rte_ethdev.h>
33 #include <rte_malloc.h>
34 
35 #include <doca_flow.h>
36 #include <doca_log.h>
37 
38 #include <common.h>
39 
40 #define TCP_PACKET_MAX_BURST_SIZE 4096
41 
42 /*
43  * Launch CPU thread to manage TCP 3way handshake
44  *
45  * @args [in]: thread input args
46  * @return: 0 on success and 1 otherwise
47  */
48 int tcp_cpu_rss_func(void *args);
49 
50 /*
51  * Extract the address of the IPv4 TCP header contained in the
52  * raw ethernet frame packet buffer if present; otherwise null.
53  *
54  * @packet [in]: Packet to extract TCP hdr
55  * @return: ptr on success and NULL otherwise
56  */
57 const struct rte_tcp_hdr *extract_tcp_hdr(const struct rte_mbuf *packet);
58 
59 /*
60  * Create TCP session
61  *
62  * @queue_id [in]: DPDK queue id for TCP control packets
63  * @pkt [in]: pkt triggering the TCP session creation
64  * @port [in]: DOCA Flow port
65  * @gpu_rss_pipe [in]: DOCA Flow GPU RSS pipe
66  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
67  */
69  const struct rte_mbuf *pkt,
70  struct doca_flow_port *port,
71  struct doca_flow_pipe *gpu_rss_pipe);
72 
73 /*
74  * Destroy TCP session
75  *
76  * @queue_id [in]: DPDK queue id for TCP control packets
77  * @pkt [in]: pkt triggering the TCP session destruction
78  * @port [in]: DOCA Flow port
79  */
80 void destroy_tcp_session(const uint16_t queue_id, const struct rte_mbuf *pkt, struct doca_flow_port *port);
81 
82 /*
83  * Log TCP flags
84  *
85  * @packet [in]: Packet to report TCP flags
86  * @flags [in]: TCP Flags
87  */
88 void log_tcp_flag(const struct rte_mbuf *packet, const char *flags);
89 
90 /*
91  * Create TCP ACK packet
92  *
93  * @src_packet [in]: Src packet to use to create ACK packet
94  * @tcp_ack_pkt_pool [in]: DPDK mempool to create ACK packets
95  * @return: ptr on success and NULL otherwise
96  */
97 struct rte_mbuf *create_ack_packet(const struct rte_mbuf *src_packet, struct rte_mempool *tcp_ack_pkt_pool);
98 
99 /*
100  * Extract TCP session key
101  *
102  * @packet [in]: Extract session key from this packet
103  * @return: object
104  */
105 struct tcp_session_key extract_session_key(const struct rte_mbuf *packet);
106 
107 #endif
enum doca_error doca_error_t
DOCA API return codes.
uint16_t queue_id
Definition: ip_frag_dp.c:1
const struct rte_tcp_hdr * extract_tcp_hdr(const struct rte_mbuf *packet)
doca_error_t create_tcp_session(const uint16_t queue_id, const struct rte_mbuf *pkt, struct doca_flow_port *port, struct doca_flow_pipe *gpu_rss_pipe)
void destroy_tcp_session(const uint16_t queue_id, const struct rte_mbuf *pkt, struct doca_flow_port *port)
struct tcp_session_key extract_session_key(const struct rte_mbuf *packet)
int tcp_cpu_rss_func(void *args)
void log_tcp_flag(const struct rte_mbuf *packet, const char *flags)
struct rte_mbuf * create_ack_packet(const struct rte_mbuf *src_packet, struct rte_mempool *tcp_ack_pkt_pool)