NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
psp_gw_config.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024-2025 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 _PSP_GW_CONFIG_H_
27 #define _PSP_GW_CONFIG_H_
28 
29 #include <set>
30 #include <string>
31 #include <vector>
32 #include <map>
33 
34 #include <rte_ether.h>
35 #include <rte_hash.h>
36 
37 #include <doca_types.h>
38 #include <doca_flow.h>
39 #include <dpdk_utils.h>
40 
41 // 0: PSP Header Version 0, AES-GCM-128
42 // 1: PSP Header Version 1, AES-GCM-256
43 // 2: PSP Header Version 2, AES-GMAC-128
44 // 3: PSP Header Version 3, AES-GMAC-256
45 inline const std::set<uint32_t> SUPPORTED_PSP_VERSIONS = {0, 1};
46 static const uint32_t DEFAULT_PSP_VERSION = 1;
47 
48 // "The offset from the end of the Initialization Vector to
49 // the start of the encrypted portion of the payload,
50 // measured in 4-octet units."
51 // By default, leave the inner IPv4 header in cleartext.
52 // Add 2 if the 64-bit VC is enabled.
53 static constexpr uint32_t DEFAULT_CRYPT_OFFSET_IPV4 = 5;
54 static constexpr uint32_t DEFAULT_CRYPT_OFFSET_VC_ENABLED_IPV4 = 7;
55 
56 static constexpr uint32_t DEFAULT_CRYPT_OFFSET_IPV6 = 10;
57 static constexpr uint32_t DEFAULT_CRYPT_OFFSET_VC_ENABLED_IPV6 = 12;
58 
59 static constexpr uint16_t PSP_PERF_KEY_GEN_PRINT = 1 << 0;
60 static constexpr uint16_t PSP_PERF_INSERTION_PRINT = 1 << 1;
62 
63 static const uint32_t PSP_MAX_PEERS = 1 << 20; /* Maximum number of peers supported by the PSP Gateway */
64 static const uint32_t PSP_MAX_SESSIONS = 1 << 20; /* Maximum number of sessions supported by the PSP Gateway for each
65  host */
66 
67 static const std::string PSP_PERF_KEY_GEN_PRINT_STR = "key-gen";
68 static const std::string PSP_PERF_INSERTION_PRINT_STR = "insertion";
69 static const std::string PSP_PERF_ALL_STR = "all";
70 
71 static const std::map<std::string, uint16_t> PSP_PERF_MAP = {
75 };
76 
77 static constexpr uint32_t IPV6_ADDR_LEN = 16;
78 typedef uint8_t ipv6_addr_t[IPV6_ADDR_LEN];
79 using session_key = std::pair<std::string, std::string> /* src_ip, dst_ip */;
80 
81 struct ip_pair {
82  doca_flow_ip_addr src_vip; /* The source IP address of the traffic flow */
83  doca_flow_ip_addr dst_vip; /* The destination IP address of the traffic flow */
84 };
85 
89 };
90 
98 struct psp_gw_peer {
99  uint32_t psp_proto_ver; /* 0 for 128-bit AES-GCM, 1 for 256-bit */
100  std::vector<ip_pair> vip_pairs; /* The list of traffic flows to be tunneled */
101  std::string svc_addr; /* Control plane gRPC service address */
102 };
103 
109  std::vector<psp_gw_peer> peers; /* The list of participating peers and their interfaces */
110 
111  bool vc_enabled; /* Whether Virtualization Cookies shall be included in the PSP headers */
112  uint32_t crypt_offset; /* The number of words to skip when performing encryption */
113  uint32_t default_psp_proto_ver; /* 0 for 128-bit AES-GCM, 1 for 256-bit */
114 };
115 
119 struct entries_status {
120  bool failure; /* will be set to true if some entry status will not be success */
121  int nb_processed; /* number of entries that was already processed */
122  int entries_in_queue; /* number of entries in queue that is waiting to process */
123 };
124 
130  struct application_dpdk_config dpdk_config; /* Configuration details of DPDK ports and queues */
131 
132  std::string pf_pcie_addr; /* PCI domain:bus:device:function string of the host PF */
133  std::string pf_repr_indices; /* Representor list string, such as vf0 or pf[0-1] */
134  std::string core_mask; /* EAL core mask */
135 
136  std::string local_svc_addr; /* The IPv4 addr (and optional port number) of the locally running gRPC service */
137  std::string json_path; /* The path to the JSON file containing the sessions configuration */
138 
139  rte_ether_addr dcap_dmac; /* The dst MAC to apply on decap */
140 
141  bool nexthop_enable; /* Whether to override the dmac in the tunnel request with a nexthop MAC addr */
142  rte_ether_addr nexthop_dmac; /* The dst MAC to apply on encap, if enabled */
143 
144  uint32_t max_tunnels; /* The maximum number of outgoing tunnel connections supported on this host */
145 
146  struct psp_gw_net_config net_config; /* List of remote peers supporting PSP connections */
147 
161 
162  uint32_t ingress_sample_meta_indicator; /* Value to assign pkt_meta when sampling incoming packets */
163  uint32_t egress_sample_meta_indicator; /* Value to assign pkt_meta when sampling outgoing packets */
164  uint32_t return_to_vf_indicator; /* Value to assign pkt_meta when receiving outgoing ARP and NS packets */
165 
166  bool create_tunnels_at_startup; /* Create PSP tunnels at startup vs. on demand */
167  bool show_sampled_packets; /* Display to the console any packets marked for sampling */
168  bool show_rss_rx_packets; /* Display to the console any packets received via RSS */
169  bool show_rss_durations; /* Display performance information for RSS processing */
170  bool disable_ingress_acl; /* Allow any ingress packet that successfully decrypts */
171  bool debug_keys; /* Print the contents of PSP encryption keys to the console */
172  bool print_stats; /* Print session and pipeline statistics to the console */
173  bool maintain_order; /* Maintain packet ordering when sampling enabled */
174  uint16_t print_perf_flags; /* Print performance information to the console */
175  enum doca_flow_l3_type outer; /* Indicate outer tunnel IP type */
176  enum doca_flow_l3_type inner; /* Indicate inner tunnel IP type */
177  struct rte_hash *ip6_table; /* Hash table with ipv6 addressess */
178  enum psp_gw_mode mode; /* Indicate PSP mode */
179  std::vector<entries_status> status; /* Status variable for entries process per queue */
180 };
181 
182 #endif // _PSP_GW_CONFIG_H_
doca_flow_l3_type
doca flow layer 3 packet type
static constexpr uint16_t PSP_PERF_KEY_GEN_PRINT
Definition: psp_gw_config.h:59
static const uint32_t PSP_MAX_SESSIONS
Definition: psp_gw_config.h:64
static const std::map< std::string, uint16_t > PSP_PERF_MAP
Definition: psp_gw_config.h:71
static constexpr uint16_t PSP_PERF_INSERTION_PRINT
Definition: psp_gw_config.h:60
static constexpr uint32_t DEFAULT_CRYPT_OFFSET_IPV6
Definition: psp_gw_config.h:56
static const std::string PSP_PERF_KEY_GEN_PRINT_STR
Definition: psp_gw_config.h:67
static const uint32_t DEFAULT_PSP_VERSION
Definition: psp_gw_config.h:46
static constexpr uint32_t DEFAULT_CRYPT_OFFSET_VC_ENABLED_IPV6
Definition: psp_gw_config.h:57
static const std::string PSP_PERF_ALL_STR
Definition: psp_gw_config.h:69
const std::set< uint32_t > SUPPORTED_PSP_VERSIONS
Definition: psp_gw_config.h:45
static const std::string PSP_PERF_INSERTION_PRINT_STR
Definition: psp_gw_config.h:68
static constexpr uint16_t PSP_PERF_ALL
Definition: psp_gw_config.h:61
uint8_t ipv6_addr_t[IPV6_ADDR_LEN]
Definition: psp_gw_config.h:78
std::pair< std::string, std::string > session_key
Definition: psp_gw_config.h:79
static constexpr uint32_t DEFAULT_CRYPT_OFFSET_VC_ENABLED_IPV4
Definition: psp_gw_config.h:54
static constexpr uint32_t IPV6_ADDR_LEN
Definition: psp_gw_config.h:77
static const uint32_t PSP_MAX_PEERS
Definition: psp_gw_config.h:63
psp_gw_mode
Definition: psp_gw_config.h:86
@ PSP_GW_MODE_TUNNEL
Definition: psp_gw_config.h:87
@ PSP_GW_MODE_TRANSPORT
Definition: psp_gw_config.h:88
static constexpr uint32_t DEFAULT_CRYPT_OFFSET_IPV4
Definition: psp_gw_config.h:53
doca flow ip address
user context struct that will be used in entries process callback
Definition: flow_common.h:78
int entries_in_queue
Definition: flow_common.h:81
doca_flow_ip_addr dst_vip
Definition: psp_gw_config.h:83
doca_flow_ip_addr src_vip
Definition: psp_gw_config.h:82
describes the configuration of the PSP networking service on the local host.
enum doca_flow_l3_type inner
std::string local_svc_addr
rte_ether_addr nexthop_dmac
bool create_tunnels_at_startup
std::vector< entries_status > status
enum psp_gw_mode mode
uint32_t egress_sample_meta_indicator
std::string json_path
enum doca_flow_l3_type outer
uint32_t ingress_sample_meta_indicator
uint16_t print_perf_flags
rte_ether_addr dcap_dmac
std::string pf_pcie_addr
struct application_dpdk_config dpdk_config
uint16_t log2_sample_rate
struct psp_gw_net_config net_config
struct rte_hash * ip6_table
std::string pf_repr_indices
std::string core_mask
uint32_t return_to_vf_indicator
describes a network of peers which participate in a network of PSP tunnel connections.
std::vector< psp_gw_peer > peers
uint32_t default_psp_proto_ver
Describes a peer which is capable of exchanging traffic flows over a PSP tunnel.
Definition: psp_gw_config.h:98
uint32_t psp_proto_ver
Definition: psp_gw_config.h:99
std::string svc_addr
std::vector< ip_pair > vip_pairs