NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
psp_gw_params.cpp File Reference
#include <ctype.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <fstream>
#include <functional>
#include <sstream>
#include <json-c/json.h>
#include <rte_hash_crc.h>
#include <doca_argp.h>
#include <doca_dev.h>
#include <doca_log.h>
#include <psp_gw_config.h>
#include <psp_gw_params.h>
#include <psp_gw_utils.h>
Include dependency graph for psp_gw_params.cpp:

Go to the source code of this file.

Data Structures

struct  psp_json_field_handler
 

Typedefs

using psp_parse_json_object_cb = std::function< doca_error_t(json_object *, psp_gw_app_config *, std::vector< void * > &)>
 
using psp_json_field_handlers = std::vector< psp_json_field_handler >
 

Functions

 DOCA_LOG_REGISTER (PSP_Gateway_Params)
 
static doca_error_t create_ip6_table (psp_gw_app_config *app_config)
 
static doca_error_t handle_pci_addr_param (void *param, void *config)
 Configures the dst-mac to apply on decap. More...
 
static doca_error_t handle_repr_param (void *param, void *config)
 Configures the device representors parameter. More...
 
static doca_error_t handle_core_mask_param (void *param, void *config)
 Configures the DPDK eal_init core mask parameter. More...
 
static doca_error_t handle_decap_dmac_param (void *param, void *config)
 Configures the dst-mac to apply on decap. More...
 
static doca_error_t handle_nexthop_dmac_param (void *param, void *config)
 Configures the next-hop dst-mac to apply on encap. More...
 
static doca_error_t parse_subnet_mask (std::string &ip, uint32_t &mask_len)
 Parses a host string with optional subnet mask suffix (i.e. /24). More...
 
static doca_error_t handle_vc_param (void *param, void *config)
 Indicates the application should include the VC in the PSP tunnel header. More...
 
static doca_error_t handle_ingress_acl_param (void *param, void *config)
 Indicates the application should skip ACL checks on ingress. More...
 
static doca_error_t handle_sample_param (void *param, void *config)
 Configures the sampling rate of packets. More...
 
static doca_error_t handle_static_tunnels_param (void *param, void *config)
 Indicates the application should create all PSP tunnels at startup. More...
 
static doca_error_t handle_max_tunnels_param (void *param, void *config)
 Configures the max number of tunnels to be supported. More...
 
static doca_error_t handle_psp_crypt_offset_param (void *param, void *config)
 Configures the PSP crypt-offset. More...
 
static doca_error_t handle_psp_version_param (void *param, void *config)
 Configures the PSP version to use for outgoing connections. More...
 
static doca_error_t handle_debug_keys_param (void *param, void *config)
 Indicates the application should log all encryption keys. More...
 
static doca_error_t handle_vf_name_param (void *param, void *config)
 Indicates the name of the netdev used as the unsecured port. More...
 
static doca_error_t handle_stats_print_param (void *param, void *config)
 Indicates whether statistics should be printed. More...
 
static void get_supported_perf_types (std::string &supported_types)
 Returns supported perf types as a string. More...
 
static doca_error_t handle_perf_print_param (void *param, void *config)
 Indicates what performance printing should be enabled. More...
 
static doca_error_t handle_show_rss_rx_packets_param (void *param, void *config)
 Indicates the application should log all received packets to RSS. More...
 
static doca_error_t handle_maintain_order_param (void *param, void *config)
 Indicates if the application should maintain the order of original packets. More...
 
static doca_error_t handle_outer_param (void *param, void *config)
 Handle outer IP type param. More...
 
static doca_error_t handle_inner_param (void *param, void *config)
 Handle inner IP type param. More...
 
static doca_error_t handle_mode_param (void *param, void *config)
 Handle the mode param. More...
 
static doca_error_t handle_config_file_param (void *param, void *config)
 Configures the JSON config file path. More...
 
static doca_error_t json_object_ver_get_string (json_object *json_obj, std::string &value)
 Verifies and extracts the string from the json object. More...
 
static doca_error_t json_object_ver_array_length (json_object *json_obj, int &length)
 Verifies and extracts the array length from the json object. More...
 
static doca_error_t handle_json_level_fields (psp_json_field_handlers &handlers, json_object *json_obj, psp_gw_app_config *app_config)
 Handles a JSON object with all of its keys. More...
 
static doca_error_t parse_local_grpc_address (json_object *json_obj_local_addr, psp_gw_app_config *app_config, std::vector< void * > &params)
 Parse the local gRPC address. More...
 
static doca_error_t parse_json_config (json_object *json_obj_config, psp_gw_app_config *app_config, std::vector< void * > &params)
 Parses the remote gRPC address. More...
 
static doca_error_t parse_remote_grpc_address (json_object *json_obj_remote_addr, psp_gw_app_config *app_config, std::vector< void * > &params)
 Parses the remote gRPC address. More...
 
static doca_error_t parse_local_vip (json_object *json_obj_local_vip, psp_gw_app_config *app_config, std::vector< void * > &params)
 Parses the local VIP. More...
 
static doca_error_t parse_remote_vips (json_object *json_obj_remote_vips, psp_gw_app_config *app_config, std::vector< void * > &params)
 Parses the remote VIPs. More...
 
static doca_error_t parse_sessions (json_object *json_obj_sessions, psp_gw_app_config *app_config, std::vector< void * > &params)
 Parses the sessions. More...
 
static doca_error_t parse_json_peers (json_object *json_obj_peers, psp_gw_app_config *app_config, std::vector< void * > &params)
 Parses the peers. More...
 
doca_error_t psp_gw_parse_config_file (psp_gw_app_config *app_config)
 Parses the configuration JSON file that was passed to the application. More...
 
static doca_error_t psp_gw_register_single_param (const char *short_name, const char *long_name, const char *description, doca_argp_param_cb_t cb, enum doca_argp_type arg_type, bool required, bool accept_multiple)
 Utility function to create a single argp parameter. More...
 
static doca_error_t psp_gw_register_params (void)
 Registers command-line arguments to the application. More...
 
doca_error_t psp_gw_argp_exec (int &argc, char *argv[], psp_gw_app_config *app_config)
 Parses command-line arguments to the application. More...
 

Variables

doca_flow_ip_addr interface_vf_addr
 

Typedef Documentation

◆ psp_json_field_handlers

Definition at line 75 of file psp_gw_params.cpp.

◆ psp_parse_json_object_cb

using psp_parse_json_object_cb = std::function<doca_error_t(json_object *, psp_gw_app_config *, std::vector<void *> &)>

Definition at line 51 of file psp_gw_params.cpp.

Function Documentation

◆ create_ip6_table()

static doca_error_t create_ip6_table ( psp_gw_app_config app_config)
static

Definition at line 83 of file psp_gw_params.cpp.

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( PSP_Gateway_Params  )

◆ get_supported_perf_types()

static void get_supported_perf_types ( std::string &  supported_types)
static

Returns supported perf types as a string.

@supported_types [out]: string to store supported types

Definition at line 489 of file psp_gw_params.cpp.

◆ handle_config_file_param()

static doca_error_t handle_config_file_param ( void *  param,
void *  config 
)
static

Configures the JSON config file path.

Parameters
[in]

Definition at line 649 of file psp_gw_params.cpp.

◆ handle_core_mask_param()

static doca_error_t handle_core_mask_param ( void *  param,
void *  config 
)
static

Configures the DPDK eal_init core mask parameter.

Parameters
[in]

Definition at line 151 of file psp_gw_params.cpp.

◆ handle_debug_keys_param()

static doca_error_t handle_debug_keys_param ( void *  param,
void *  config 
)
static

Indicates the application should log all encryption keys.

Parameters
[in]

Definition at line 397 of file psp_gw_params.cpp.

◆ handle_decap_dmac_param()

static doca_error_t handle_decap_dmac_param ( void *  param,
void *  config 
)
static

Configures the dst-mac to apply on decap.

Parameters
[in]

Definition at line 168 of file psp_gw_params.cpp.

◆ handle_ingress_acl_param()

static doca_error_t handle_ingress_acl_param ( void *  param,
void *  config 
)
static

Indicates the application should skip ACL checks on ingress.

Parameters
[in]

Definition at line 276 of file psp_gw_params.cpp.

◆ handle_inner_param()

static doca_error_t handle_inner_param ( void *  param,
void *  config 
)
static

Handle inner IP type param.

Parameters
[in]

Definition at line 595 of file psp_gw_params.cpp.

◆ handle_json_level_fields()

static doca_error_t handle_json_level_fields ( psp_json_field_handlers handlers,
json_object *  json_obj,
psp_gw_app_config app_config 
)
static

Handles a JSON object with all of its keys.

@handlers [in]: JSON handlers (expected keys and handlers) @json_obj [in]: JSON object @app_config [in/out]: Application config

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 713 of file psp_gw_params.cpp.

◆ handle_maintain_order_param()

static doca_error_t handle_maintain_order_param ( void *  param,
void *  config 
)
static

Indicates if the application should maintain the order of original packets.

Parameters
[in]

Definition at line 552 of file psp_gw_params.cpp.

◆ handle_max_tunnels_param()

static doca_error_t handle_max_tunnels_param ( void *  param,
void *  config 
)
static

Configures the max number of tunnels to be supported.

Parameters
[in]

Definition at line 326 of file psp_gw_params.cpp.

◆ handle_mode_param()

static doca_error_t handle_mode_param ( void *  param,
void *  config 
)
static

Handle the mode param.

Parameters
[in]

Definition at line 624 of file psp_gw_params.cpp.

◆ handle_nexthop_dmac_param()

static doca_error_t handle_nexthop_dmac_param ( void *  param,
void *  config 
)
static

Configures the next-hop dst-mac to apply on encap.

Parameters
[in]

Definition at line 194 of file psp_gw_params.cpp.

◆ handle_outer_param()

static doca_error_t handle_outer_param ( void *  param,
void *  config 
)
static

Handle outer IP type param.

Parameters
[in]

Definition at line 570 of file psp_gw_params.cpp.

◆ handle_pci_addr_param()

static doca_error_t handle_pci_addr_param ( void *  param,
void *  config 
)
static

Configures the dst-mac to apply on decap.

Parameters
[in]

Definition at line 107 of file psp_gw_params.cpp.

◆ handle_perf_print_param()

static doca_error_t handle_perf_print_param ( void *  param,
void *  config 
)
static

Indicates what performance printing should be enabled.

Parameters
[in]

Definition at line 505 of file psp_gw_params.cpp.

◆ handle_psp_crypt_offset_param()

static doca_error_t handle_psp_crypt_offset_param ( void *  param,
void *  config 
)
static

Configures the PSP crypt-offset.

The offset determines the number of words (4-byte chunks) in the packet header that will be transmitted as cleartext.

Parameters
[in]

Definition at line 353 of file psp_gw_params.cpp.

◆ handle_psp_version_param()

static doca_error_t handle_psp_version_param ( void *  param,
void *  config 
)
static

Configures the PSP version to use for outgoing connections.

Parameters
[in]

Definition at line 375 of file psp_gw_params.cpp.

◆ handle_repr_param()

static doca_error_t handle_repr_param ( void *  param,
void *  config 
)
static

Configures the device representors parameter.

Parameters
[in]

Definition at line 134 of file psp_gw_params.cpp.

◆ handle_sample_param()

static doca_error_t handle_sample_param ( void *  param,
void *  config 
)
static

Configures the sampling rate of packets.

Parameters
[in]

Definition at line 292 of file psp_gw_params.cpp.

◆ handle_show_rss_rx_packets_param()

static doca_error_t handle_show_rss_rx_packets_param ( void *  param,
void *  config 
)
static

Indicates the application should log all received packets to RSS.

Parameters
[in]

Definition at line 533 of file psp_gw_params.cpp.

◆ handle_static_tunnels_param()

static doca_error_t handle_static_tunnels_param ( void *  param,
void *  config 
)
static

Indicates the application should create all PSP tunnels at startup.

Parameters
[in]

Definition at line 308 of file psp_gw_params.cpp.

◆ handle_stats_print_param()

static doca_error_t handle_stats_print_param ( void *  param,
void *  config 
)
static

Indicates whether statistics should be printed.

Parameters
[in]

Definition at line 475 of file psp_gw_params.cpp.

◆ handle_vc_param()

static doca_error_t handle_vc_param ( void *  param,
void *  config 
)
static

Indicates the application should include the VC in the PSP tunnel header.

Parameters
[in]

Definition at line 260 of file psp_gw_params.cpp.

◆ handle_vf_name_param()

static doca_error_t handle_vf_name_param ( void *  param,
void *  config 
)
static

Indicates the name of the netdev used as the unsecured port.

The MAC and IP addresses will be derived from this interface.

Parameters
[in]

Definition at line 417 of file psp_gw_params.cpp.

◆ json_object_ver_array_length()

static doca_error_t json_object_ver_array_length ( json_object *  json_obj,
int &  length 
)
static

Verifies and extracts the array length from the json object.

@NOTE: Does not return the array itself, only the length.

@json_obj [in]: json object @length [out]: array length to extract

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 695 of file psp_gw_params.cpp.

◆ json_object_ver_get_string()

static doca_error_t json_object_ver_get_string ( json_object *  json_obj,
std::string &  value 
)
static

Verifies and extracts the string from the json object.

@json_obj [in]: json object @value [out]: string value to extract

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 676 of file psp_gw_params.cpp.

◆ parse_json_config()

static doca_error_t parse_json_config ( json_object *  json_obj_config,
psp_gw_app_config app_config,
std::vector< void * > &  params 
)
static

Parses the remote gRPC address.

@json_obj_config [in]: JSON object @app_config [in/out]: Application config @params [in/out]: Custom data to pass to the handler

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 810 of file psp_gw_params.cpp.

◆ parse_json_peers()

static doca_error_t parse_json_peers ( json_object *  json_obj_peers,
psp_gw_app_config app_config,
std::vector< void * > &  params 
)
static

Parses the peers.

@json_obj_peers [in]: JSON object @app_config [in/out]: Application config @params [in/out]: Custom data to pass to the handler

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1051 of file psp_gw_params.cpp.

◆ parse_local_grpc_address()

static doca_error_t parse_local_grpc_address ( json_object *  json_obj_local_addr,
psp_gw_app_config app_config,
std::vector< void * > &  params 
)
static

Parse the local gRPC address.

@json_obj_local_addr [in]: JSON object @app_config [in/out]: Application config @params [in/out]: Custom data to pass to the handler

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 765 of file psp_gw_params.cpp.

◆ parse_local_vip()

static doca_error_t parse_local_vip ( json_object *  json_obj_local_vip,
psp_gw_app_config app_config,
std::vector< void * > &  params 
)
static

Parses the local VIP.

@json_obj_local_vip [in]: JSON object @app_config [in/out]: Application config @params [in/out]: Custom data to pass to the handler

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 861 of file psp_gw_params.cpp.

◆ parse_remote_grpc_address()

static doca_error_t parse_remote_grpc_address ( json_object *  json_obj_remote_addr,
psp_gw_app_config app_config,
std::vector< void * > &  params 
)
static

Parses the remote gRPC address.

@json_obj_remote_addr [in]: JSON object @app_config [in/out]: Application config @params [in/out]: Custom data to pass to the handler

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 835 of file psp_gw_params.cpp.

◆ parse_remote_vips()

static doca_error_t parse_remote_vips ( json_object *  json_obj_remote_vips,
psp_gw_app_config app_config,
std::vector< void * > &  params 
)
static

Parses the remote VIPs.

@json_obj_remote_vips [in]: JSON object @app_config [in/out]: Application config @params [in/out]: Custom data to pass to the handler

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 890 of file psp_gw_params.cpp.

◆ parse_sessions()

static doca_error_t parse_sessions ( json_object *  json_obj_sessions,
psp_gw_app_config app_config,
std::vector< void * > &  params 
)
static

Parses the sessions.

@json_obj_sessions [in]: JSON object @app_config [in/out]: Application config @params [in/out]: Custom data to pass to the handler

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 993 of file psp_gw_params.cpp.

◆ parse_subnet_mask()

static doca_error_t parse_subnet_mask ( std::string &  ip,
uint32_t &  mask_len 
)
static

Parses a host string with optional subnet mask suffix (i.e. /24).

@ip [in/out]: host string, returned with subnet mask suffix removed (and applied) @mask_len [out]: the subnet mask length if one was found; 32 (single host) otherwise

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 217 of file psp_gw_params.cpp.

◆ psp_gw_argp_exec()

doca_error_t psp_gw_argp_exec ( int &  argc,
char *  argv[],
psp_gw_app_config app_config 
)

Parses command-line arguments to the application.

During processing of arguments, both DPDK and the application may remove arguments from argv, and argc will reflect the new size.

@argc [in/out]: The number of args passed to main() @argv [in/out]: The args passed to main @app_config [out]: The configuration of the application

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1425 of file psp_gw_params.cpp.

◆ psp_gw_parse_config_file()

doca_error_t psp_gw_parse_config_file ( psp_gw_app_config app_config)

Parses the configuration JSON file that was passed to the application.

@app_config [in/out]: The configuration of the application

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1094 of file psp_gw_params.cpp.

◆ psp_gw_register_params()

static doca_error_t psp_gw_register_params ( void  )
static

Registers command-line arguments to the application.

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1200 of file psp_gw_params.cpp.

◆ psp_gw_register_single_param()

static doca_error_t psp_gw_register_single_param ( const char *  short_name,
const char *  long_name,
const char *  description,
doca_argp_param_cb_t  cb,
enum doca_argp_type  arg_type,
bool  required,
bool  accept_multiple 
)
static

Utility function to create a single argp parameter.

@short_name [in]: The single-letter command-line flag @long_name [in]: The spelled-out command-line flag @description [in]: Describes the option @cb [in]: Called when the option is parsed @arg_type [in]: How the option string should be parsed @required [in]: Whether the program should terminate if the option is omitted @accept_multiple [in]: Whether the program should accept multiple instances of the option

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 1156 of file psp_gw_params.cpp.

Variable Documentation

◆ interface_vf_addr

doca_flow_ip_addr interface_vf_addr

Definition at line 48 of file psp_gw_params.cpp.