37 #include "libflexio/flexio_ver.h"
38 #define PCC_FLEXIO_MAJOR_VERSION (25)
39 #define PCC_FLEXIO_MINOR_VERSION (4)
40 #define PCC_FLEXIO_PATCH_VERSION (0)
41 #define FLEXIO_VER_USED FLEXIO_VER(PCC_FLEXIO_MAJOR_VERSION, PCC_FLEXIO_MINOR_VERSION, PCC_FLEXIO_PATCH_VERSION)
42 #include "libflexio/flexio.h"
48 "format 0 - user init: port num = %#lx, algo index = %#lx, algo slot = %#lx, algo enable = %#lx, disable event bitmask = %#lx\n",
49 "format 1 - user algo: algo slot = %#lx, result rate = %#lx, result rtt req = %#lx, port num = %#lx, timestamp = %#lx\n",
50 "format 2 - pcc_np dev: thread_idx = %#lx, debug_init = %#lx, cnt_enter = %#lx, cnt_arm = %#lx. end %u\n",
51 "format 3 - pcc_np dev: thread_idx = %#lx, cnt_recv_packet = %#lx, cnt_sent_packet = %#lx, cnt_user_func_err = %#lx. end %u\n",
52 "format 4 - pcc_np dev: thread_idx = %#lx, rq = %#lx, rq_pi = %#lx, rqcq = %#lx, rqcq_ci = %#lx\n",
53 "format 5 - pcc_np dev: thread_idx = %#lx, sq = %#lx, sq_pi = %#lx, sqcq = %#lx. end %u\n",
58 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 192, 193, 194, 195, 196,
59 197, 198, 199, 200, 201, 202, 203, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217,
60 218, 219, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 240};
63 {16, 17, 18, 19, 20, 21, 22, 23, 32, 33, 34, 35, 36, 37, 38, 39};
92 file = fopen(
path,
"rb");
96 if (fseek(file, 0, SEEK_END) != 0) {
101 nb_file_bytes = ftell(file);
104 if (nb_file_bytes == -1)
107 if (nb_file_bytes == 0)
110 *file_size = (
size_t)nb_file_bytes;
125 size_t read_byte_count;
127 file = fopen(
path,
"rb");
131 read_byte_count = fread(buffer, 1, *bytes_read, file);
134 if (read_byte_count != *bytes_read)
137 *bytes_read = read_byte_count;
150 struct doca_devinfo **dev_list;
151 uint32_t nb_devs = 0;
164 for (i = 0; i < nb_devs; i++) {
191 struct doca_devinfo **dev_list;
192 uint32_t nb_devs = 0;
204 for (i = 0; i < nb_devs; i++) {
207 PRINT_ERROR(
"Error: could not get DOCA device name\n");
221 PRINT_ERROR(
"Error: DOCA device %s does not support PCC %s role\n",
238 if (*doca_device ==
NULL) {
239 PRINT_ERROR(
"Error: Couldn't get DOCA device %s\n", device_name);
249 uint32_t min_num_threads, max_num_threads;
254 "Error: Cannot specify both threads list and DPA resources. Use either threads list or DPA resources (with application key).\n");
262 struct flexio_resource *res;
272 file_buffer = (
char *)malloc(bytes_read);
273 if (file_buffer ==
NULL) {
274 PRINT_ERROR(
"Error: Failed to allocate memory for DPA resources file\n");
287 const char *app_key =
cfg->dpa_application_key;
288 if (app_key ==
NULL || strlen(app_key) == 0) {
289 struct flexio_app *pcc_app = (
struct flexio_app *)(
cfg->app);
290 const char *app_name = flexio_app_get_name(pcc_app);
295 flexio_status res_created = flexio_resources_create(app_key, file_buffer, bytes_read, &res);
296 if (res_created != FLEXIO_STATUS_SUCCESS) {
297 PRINT_ERROR(
"Error: Failed creating DPA resources object!\n");
303 int num_eu_groups = flexio_resources_get_eugs_num(res);
304 if (num_eu_groups > 0) {
305 PRINT_ERROR(
"Error: Execution unit groups are currently unsupported!\n");
307 flexio_resources_destroy(res);
312 uint32_t num_eus = flexio_resources_get_eus_num(res);
313 uint32_t *eus = flexio_resources_get_eus(res);
316 PRINT_DEBUG(
"Debug: Found %d execution units in DPA resources file\n", num_eus);
318 for (uint32_t i = 0; i < num_eus; i++) {
319 cfg->threads_list[i] = eus[i];
321 cfg->threads_num = num_eus;
323 flexio_resources_destroy(res);
330 PRINT_ERROR(
"Error: Failed to open DOCA device that supports PCC\n");
341 PRINT_ERROR(
"Error: Failed to create DOCA PCC context\n");
346 if (use_default_threads) {
358 PRINT_ERROR(
"Failed to get minimum DOCA PCC number of threads\n");
364 PRINT_ERROR(
"Failed to get maximum DOCA PCC number of threads\n");
368 if (
cfg->threads_num < min_num_threads ||
cfg->threads_num > max_num_threads) {
370 "Invalid number of PCC threads: %u. The Minimum number of PCC threads is %d and the maximum number of PCC threads is %d\n",
380 PRINT_ERROR(
"Error: Failed to set DOCA PCC app\n");
387 PRINT_ERROR(
"Error: Failed to set thread affinity for DOCA PCC\n");
392 switch (
cfg->probe_packet_format) {
396 PRINT_ERROR(
"Error: Failed to set CCMAD probe packet format for DOCA PCC\n");
403 PRINT_ERROR(
"Error: Failed to set CCMAD remote SW handler for DOCA PCC\n");
411 PRINT_ERROR(
"Error: Failed to set IFA1 probe packet format for DOCA PCC\n");
418 PRINT_ERROR(
"Error: Failed to set IFA2 probe packet format for DOCA PCC\n");
424 PRINT_ERROR(
"Error: Failed to set IFA2 GNS for DOCA PCC\n");
429 PRINT_ERROR(
"Error: Failed to set IFA2 hop limit for DOCA PCC\n");
435 cfg->gns_ignore_mask,
436 cfg->gns_ignore_value);
438 PRINT_ERROR(
"Error: Failed to set IFA2 GNS ignore for DOCA PCC\n");
448 PRINT_ERROR(
"Error: Failed to set print buffer size for DOCA PCC\n");
455 PRINT_ERROR(
"Error: Failed to set trace message for DOCA PCC\n");
462 PRINT_ERROR(
"Error: Failed to set coredump file for DOCA PCC\n");
469 PRINT_ERROR(
"Error: Failed to set mailbox for DOCA PCC\n");
494 uint32_t *request_buf;
495 uint32_t response_size, cb_ret_val;
503 PRINT_ERROR(
"Error: Failed to get the request buffer of the PCC mailbox\n");
508 *request_buf =
cfg->hop_limit;
513 PRINT_ERROR(
"Error: Failed to send the PCC mailbox request buffer\n");
517 if (cb_ret_val != 0) {
518 PRINT_ERROR(
"Error: Mailbox callback returned error status\n");
557 PRINT_ERROR(
"Error: Entered IB device name exceeding the maximum size of %d\n",
581 bool np_nic_telemetry = *((
bool *)param);
584 PRINT_ERROR(
"Error: Can not set multiple runtime application.\n");
588 if (np_nic_telemetry) {
593 PRINT_INFO(
"Info: Set DOCA PCC NP NIC Telemetry application\n");
608 bool rp_switch_telemetry = *((
bool *)param);
611 PRINT_ERROR(
"Error: Can not set multiple runtime application.\n");
615 if (rp_switch_telemetry) {
620 PRINT_INFO(
"Info: Set DOCA PCC RP Switch Telemetry application\n");
635 bool np_switch_telemetry = *((
bool *)param);
638 PRINT_ERROR(
"Error: Can not set multiple runtime application.\n");
642 if (np_switch_telemetry) {
648 PRINT_INFO(
"Info: Set DOCA PCC RP Switch Telemetry application\n");
663 char *threads_list_string = (
char *)param;
664 static const char delim[2] =
" ";
665 char *curr_pcc_string;
666 int curr_pcc_check, i,
len;
680 curr_pcc_string = strtok(threads_list_string, delim);
681 if (curr_pcc_string ==
NULL) {
682 PRINT_ERROR(
"Error: Invalid PCC threads list: %s\n", threads_list_string);
687 while (curr_pcc_string !=
NULL) {
690 for (i = 0; i <
len; i++) {
691 if (!isdigit(curr_pcc_string[i])) {
692 PRINT_ERROR(
"Error: Invalid PCC thread number: %s\n", curr_pcc_string);
698 curr_pcc_check = (int)atoi(curr_pcc_string);
699 if (curr_pcc_check < 0) {
700 PRINT_ERROR(
"Error: Invalid PCC thread number %d. PCC threads numbers must be non-negative\n",
705 curr_pcc = (uint32_t)atoi(curr_pcc_string);
707 curr_pcc_string = strtok(
NULL, delim);
728 "Error: Entered wait time can't be zero. Must be either positive or infinity (meaning negative value)\n");
764 pcc_cfg->
hop_limit = *((uint8_t *)param);
780 pcc_cfg->
gns = *((uint8_t *)param);
827 const char *
path = (
char *)param;
851 const char *
path = (
char *)param;
863 FILE *file = fopen(
path,
"r");
865 PRINT_ERROR(
"Error: DPA resources file '%s' does not exist or cannot be accessed\n",
path);
885 const char *app_key = (
char *)param;
900 struct doca_argp_param *device_param;
901 struct doca_argp_param *np_nic_telemetry_param;
902 struct doca_argp_param *rp_switch_telemetry_param;
903 struct doca_argp_param *np_switch_telemetry_param;
904 struct doca_argp_param *threads_list_param;
905 struct doca_argp_param *wait_time_param;
906 struct doca_argp_param *remote_sw_handler_param;
907 struct doca_argp_param *hop_limit_param;
908 struct doca_argp_param *gns_param;
909 struct doca_argp_param *gns_ignore_mask_param;
910 struct doca_argp_param *gns_ignore_value_param;
911 struct doca_argp_param *coredump_file_param;
912 struct doca_argp_param *dpa_resources_file;
913 struct doca_argp_param *dpa_application_key;
944 np_nic_telemetry_param,
945 "Flag to indicate running as a Notification Point NIC Telemetry (optional). The application will generate CCMAD probe packets. By default the flag is set to false.");
964 rp_switch_telemetry_param,
965 "Flag to indicate running as a Reaction Point Switch Telemetry (optional). The application will generate IFA2 probe packets. By default the flag is set to false.");
984 np_switch_telemetry_param,
985 "Flag to indicate running as a Notification Point Switch Telemetry (optional). The application will generate IFA2 probe packets. By default the flag is set to false.");
1005 "A list of the PCC threads numbers to be chosen for the DOCA PCC context to run on (optional). Must be provided as a string, such that the number are separated by a space.");
1025 "The duration of the DOCA PCC wait (optional), can provide negative values which means infinity. If not provided then -1 will be chosen.");
1044 remote_sw_handler_param,
1045 "CCMAD remote SW handler flag (optional). If not provided then false will be chosen.");
1065 "The IFA2 probe packet hop limit (optional). If not provided then 0XFE will be chosen.");
1085 "The IFA2 probe packet global namespace (optional). If not provided then 0XF will be chosen.");
1104 gns_ignore_mask_param,
1105 "The IFA2 probe packet global namespace ignore mask (optional). If not provided then 0 will be chosen.");
1124 gns_ignore_value_param,
1125 "The IFA2 probe packet global namespace ignore value (optional). If not provided then 0 will be chosen.");
1144 coredump_file_param,
1145 "A pathname to the file to write coredump data in case of unrecoverable error on the device (optional). Must be provided as a string.");
char path[MAX_PATH_LEN+1]
struct rdma_resources resources
DOCA_EXPERIMENTAL void doca_argp_param_set_description(struct doca_argp_param *param, const char *description)
Set the description of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_long_name(struct doca_argp_param *param, const char *name)
Set the long name of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_arguments(struct doca_argp_param *param, const char *arguments)
Set the description of the expected arguments of the program param, used during program usage.
DOCA_EXPERIMENTAL void doca_argp_param_set_callback(struct doca_argp_param *param, doca_argp_param_cb_t callback)
Set the callback function of the program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_mandatory(struct doca_argp_param *param)
Mark the program param as mandatory.
DOCA_EXPERIMENTAL doca_error_t doca_argp_param_create(struct doca_argp_param **param)
Create new program param.
DOCA_EXPERIMENTAL void doca_argp_param_set_type(struct doca_argp_param *param, enum doca_argp_type type)
Set the type of the param arguments.
DOCA_EXPERIMENTAL void doca_argp_param_set_short_name(struct doca_argp_param *param, const char *name)
Set the short name of the program param.
DOCA_EXPERIMENTAL doca_error_t doca_argp_register_param(struct doca_argp_param *input_param)
Register a program flag.
DOCA_STABLE doca_error_t doca_devinfo_create_list(struct doca_devinfo ***dev_list, uint32_t *nb_devs)
Creates list of all available local devices.
DOCA_STABLE doca_error_t doca_devinfo_get_ibdev_name(const struct doca_devinfo *devinfo, char *ibdev_name, uint32_t size)
Get the name of the IB device represented by a DOCA devinfo.
#define DOCA_DEVINFO_IBDEV_NAME_SIZE
Buffer size to hold Infiniband/RoCE device name. Including a null terminator.
DOCA_STABLE doca_error_t doca_devinfo_destroy_list(struct doca_devinfo **dev_list)
Destroy list of local device info structures.
DOCA_STABLE doca_error_t doca_dev_open(struct doca_devinfo *devinfo, struct doca_dev **dev)
Initialize local device for use.
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
#define DOCA_ERROR_PROPAGATE(r, t)
Save the first encountered doca_error_t.
enum doca_error doca_error_t
DOCA API return codes.
DOCA_STABLE const char * doca_error_get_descr(doca_error_t error)
Returns the description string of an error code.
@ DOCA_ERROR_INVALID_VALUE
@ DOCA_ERROR_INITIALIZATION
@ DOCA_ERROR_NOT_SUPPORTED
DOCA_STABLE doca_error_t doca_pcc_create(struct doca_dev *doca_dev, struct doca_pcc **pcc)
Create programmable CC Reaction Point context.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_set_ifa1_probe_packet_format(struct doca_pcc *pcc, uint32_t probe_format_slot)
Set ifa1 probe packet format for the pcc process.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_mailbox_send(struct doca_pcc *pcc, uint32_t request_size, uint32_t *response_size, uint32_t *cb_ret_val)
Send mailbox request data to device.
DOCA_STABLE doca_error_t doca_pcc_set_trace_message(struct doca_pcc *pcc, char **trace_message)
Set message for trace printing.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_rp_set_ccmad_remote_sw_handler(struct doca_pcc *pcc, uint32_t probe_format_slot, bool sw_handler)
Set sw remote handler for CCMAD probe type.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_mailbox_get_request_buffer(struct doca_pcc *pcc, void **request_buffer)
Get mailbox request data buffer address to fill and transfer to device.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_set_mailbox(struct doca_pcc *pcc, uint32_t max_request_size, uint32_t max_response_size)
Set mailbox attributes to obtain and pass data from and to the device.
DOCA_STABLE doca_error_t doca_pcc_destroy(struct doca_pcc *pcc)
Destroy a DOCA PCC context.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_set_ccmad_probe_packet_format(struct doca_pcc *pcc, uint32_t probe_format_slot)
Set CCMAD probe packet format for the pcc process.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_set_ifa2_probe_packet_format(struct doca_pcc *pcc, uint32_t probe_format_slot)
Set ifa2 probe packet format for the pcc process.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_rp_set_ifa2_hop_limit(struct doca_pcc *pcc, uint32_t probe_format_slot, uint8_t hop_limit)
Set hop_limit field in the metadata header for IFA2 packets.
DOCA_STABLE doca_error_t doca_pcc_set_app(struct doca_pcc *pcc, struct doca_pcc_app *app)
Set program app for PCC context.
DOCA_STABLE doca_error_t doca_pcc_get_min_num_threads(struct doca_pcc *pcc, uint32_t *min_num_threads)
Get a minimal required number of threads handling CC events.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_np_create(struct doca_dev *doca_dev, struct doca_pcc **pcc)
Create programmable CC Notification Point context.
DOCA_STABLE doca_error_t doca_devinfo_get_is_pcc_supported(const struct doca_devinfo *devinfo)
Get whether the DOCA device supports PCC reaction point.
DOCA_STABLE doca_error_t doca_pcc_get_max_num_threads(struct doca_pcc *pcc, uint32_t *max_num_threads)
Get a maximal allowed number of threads handling CC events.
DOCA_STABLE doca_error_t doca_pcc_set_thread_affinity(struct doca_pcc *pcc, uint32_t num_threads, uint32_t *affinity_configs)
Configure affinity of threads handling CC events.
DOCA_STABLE doca_error_t doca_pcc_set_print_buffer_size(struct doca_pcc *pcc, size_t buffer_size)
Set buffer size of DPA print message.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_rp_set_ifa2_gns(struct doca_pcc *pcc, uint32_t probe_format_slot, uint8_t gns)
Set GNS value for IFA2 packets.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_np_cap_is_supported(const struct doca_devinfo *devinfo)
Get whether the DOCA device supports PCC notification point.
DOCA_STABLE doca_error_t doca_pcc_set_dev_coredump_file(struct doca_pcc *pcc, const char *file_name)
Set output file to write crash data and coredump in case of unrecoverable error on the device.
DOCA_EXPERIMENTAL doca_error_t doca_pcc_np_set_ifa2_gns_ignore(struct doca_pcc *pcc, uint32_t probe_format_slot, uint8_t ignore_mask, uint8_t ignore_value)
Set GNS ignore for IFA2 packets.
const struct ip_frag_config * cfg
const uint32_t default_pcc_rp_threads_list[PCC_RP_THREADS_NUM_DEFAULT_VALUE]
static doca_error_t open_pcc_device(const char *device_name, pcc_role_t role, struct doca_dev **doca_device)
static doca_error_t rp_switch_telemetry_callback(void *param, void *config)
doca_error_t pcc_init(struct pcc_config *cfg, struct pcc_resources *resources)
static doca_error_t np_switch_telemetry_callback(void *param, void *config)
static doca_error_t ifa2_hop_limit_callback(void *param, void *config)
static doca_error_t coredump_file_callback(void *param, void *config)
static doca_error_t device_name_callback(void *param, void *config)
static bool use_threads_list
static doca_error_t dpa_application_key_callback(void *param, void *config)
static doca_error_t dpa_resources_file_callback(void *param, void *config)
static doca_error_t ccmad_remote_sw_handler_callback(void *param, void *config)
static doca_error_t threads_list_callback(void *param, void *config)
const uint32_t default_pcc_np_threads_list[PCC_NP_THREADS_NUM_DEFAULT_VALUE]
static doca_error_t np_nic_telemetry_callback(void *param, void *config)
static doca_error_t read_file_into_buffer(const char *path, char *buffer, size_t *bytes_read)
Read file content into a pre-allocated buffer.
static doca_error_t ifa2_gns_callback(void *param, void *config)
static doca_error_t ifa2_gns_ignore_mask_callback(void *param, void *config)
static doca_error_t ifa2_gns_ignore_value_callback(void *param, void *config)
static bool pcc_device_exists_check(const char *device_name)
static doca_error_t get_file_size(const char *path, size_t *file_size)
Get the size of a file.
static doca_error_t wait_time_callback(void *param, void *config)
doca_error_t register_pcc_params(void)
static bool use_dpa_resources
doca_error_t pcc_mailbox_send(struct pcc_config *cfg, struct pcc_resources *resources)
doca_error_t pcc_destroy(struct pcc_resources *resources)
static char * trace_message_formats[]
#define PCC_MAILBOX_RESPONSE_SIZE
struct doca_pcc_app * pcc_np_nic_telemetry_app
pcc_role_t
intelemetry request packet format
#define PCC_PRINT_BUFFER_SIZE_DEFAULT_VALUE
#define PCC_RP_THREADS_NUM_DEFAULT_VALUE
struct doca_pcc_app * pcc_rp_switch_telemetry_app
struct doca_pcc_app * pcc_np_switch_telemetry_app
#define PCC_NP_THREADS_NUM_DEFAULT_VALUE
@ PCC_DEV_PROBE_PACKET_IFA1
@ PCC_DEV_PROBE_PACKET_IFA2
@ PCC_DEV_PROBE_PACKET_CCMAD
#define MAX_USER_ARG_SIZE
#define PCC_MAILBOX_REQUEST_SIZE
char coredump_file[MAX_ARG_SIZE]
uint32_t threads_list[MAX_ARG_SIZE]
struct doca_pcc_app * app
char dpa_application_key[MAX_ARG_SIZE]
char device_name[DOCA_DEVINFO_IBDEV_NAME_SIZE]
char dpa_resources_file[MAX_ARG_SIZE]
pcc_dev_probe_packet_type_t probe_packet_format
struct doca_dev * doca_device