NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
comch_ctrl_path_server_sample.c File Reference
#include <signal.h>
#include <stdbool.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <doca_comch.h>
#include <doca_ctx.h>
#include <doca_dev.h>
#include <doca_error.h>
#include <doca_log.h>
#include <doca_pe.h>
#include "comch_ctrl_path_common.h"
#include "common.h"
Include dependency graph for comch_ctrl_path_server_sample.c:

Go to the source code of this file.

Data Structures

struct  comch_ctrl_path_server_objects
 

Functions

 DOCA_LOG_REGISTER (COMCH_CTRL_PATH_SERVER)
 
static void send_task_completion_callback (struct doca_comch_task_send *task, union doca_data task_user_data, union doca_data ctx_user_data)
 
static void send_task_completion_err_callback (struct doca_comch_task_send *task, union doca_data task_user_data, union doca_data ctx_user_data)
 
static void server_connection_event_callback (struct doca_comch_event_connection_status_changed *event, struct doca_comch_connection *comch_conn, uint8_t change_success)
 
static void server_disconnection_event_callback (struct doca_comch_event_connection_status_changed *event, struct doca_comch_connection *comch_conn, uint8_t change_success)
 
static doca_error_t server_send_pong (struct comch_ctrl_path_server_objects *sample_objects)
 
static void message_recv_callback (struct doca_comch_event_msg_recv *event, uint8_t *recv_buffer, uint32_t msg_len, struct doca_comch_connection *comch_connection)
 
static void clean_comch_sample_objects (struct comch_ctrl_path_server_objects *sample_objects)
 
static void comch_server_state_changed_callback (const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
 
static doca_error_t init_comch_ctrl_path_server_objects (const char *server_name, const char *dev_pci_addr, const char *dev_rep_pci_addr, struct comch_ctrl_path_server_objects *sample_objects)
 
doca_error_t start_comch_ctrl_path_server_sample (const char *server_name, const char *dev_pci_addr, const char *rep_pci_addr, const char *text, const uint32_t text_len)
 

Function Documentation

◆ clean_comch_sample_objects()

static void clean_comch_sample_objects ( struct comch_ctrl_path_server_objects sample_objects)
static

Clean all sample resources

@sample_objects [in]: Sample objects struct to clean

Definition at line 274 of file comch_ctrl_path_server_sample.c.

◆ comch_server_state_changed_callback()

static void comch_server_state_changed_callback ( const union doca_data  user_data,
struct doca_ctx *  ctx,
enum doca_ctx_states  prev_state,
enum doca_ctx_states  next_state 
)
static

Callback triggered whenever CC server context state changes

@user_data [in]: User data associated with the CC server context. Will hold struct comch_ctrl_path_server_objects * @ctx [in]: The CC server context that had a state change @prev_state [in]: Previous context state @next_state [in]: Next context state (context is already in this state when the callback is called)

The context is in starting state, this is unexpected for CC server.

The context is in stopping, this can happen when fatal error encountered or when stopping context. doca_pe_progress() will cause all tasks to be flushed, and finally transition state to idle

Definition at line 320 of file comch_ctrl_path_server_sample.c.

◆ DOCA_LOG_REGISTER()

DOCA_LOG_REGISTER ( COMCH_CTRL_PATH_SERVER  )

◆ init_comch_ctrl_path_server_objects()

static doca_error_t init_comch_ctrl_path_server_objects ( const char *  server_name,
const char *  dev_pci_addr,
const char *  dev_rep_pci_addr,
struct comch_ctrl_path_server_objects sample_objects 
)
static

Initialize sample resources

@server_name [in]: Server name to connect to @dev_pci_addr [in]: PCI address to connect over @dev_rep_pci_addr [in]: PCI address for the representor @sample_objects [in]: Sample objects struct to initialize

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 366 of file comch_ctrl_path_server_sample.c.

◆ message_recv_callback()

static void message_recv_callback ( struct doca_comch_event_msg_recv *  event,
uint8_t *  recv_buffer,
uint32_t  msg_len,
struct doca_comch_connection *  comch_connection 
)
static

Callback for message recv event

@event [in]: Recv event object @recv_buffer [in]: Message buffer @msg_len [in]: Message len @comch_connection [in]: Connection the message was received on

Definition at line 236 of file comch_ctrl_path_server_sample.c.

◆ send_task_completion_callback()

static void send_task_completion_callback ( struct doca_comch_task_send *  task,
union doca_data  task_user_data,
union doca_data  ctx_user_data 
)
static

Callback for send task successful completion

@task [in]: Send task object @task_user_data [in]: User data for task @ctx_user_data [in]: User data for context

Definition at line 65 of file comch_ctrl_path_server_sample.c.

◆ send_task_completion_err_callback()

static void send_task_completion_err_callback ( struct doca_comch_task_send *  task,
union doca_data  task_user_data,
union doca_data  ctx_user_data 
)
static

Callback for send task completion with error

@task [in]: Send task object @task_user_data [in]: User data for task @ctx_user_data [in]: User data for context

Definition at line 89 of file comch_ctrl_path_server_sample.c.

◆ server_connection_event_callback()

static void server_connection_event_callback ( struct doca_comch_event_connection_status_changed *  event,
struct doca_comch_connection *  comch_conn,
uint8_t  change_success 
)
static

Callback for connection event

@event [in]: Connection event object @comch_conn [in]: Connection object @change_success [in]: Whether the connection was successful or not

Definition at line 113 of file comch_ctrl_path_server_sample.c.

◆ server_disconnection_event_callback()

static void server_disconnection_event_callback ( struct doca_comch_event_connection_status_changed *  event,
struct doca_comch_connection *  comch_conn,
uint8_t  change_success 
)
static

Callback for disconnection event

@event [in]: Connection event object @comch_conn [in]: Connection object @change_success [in]: Whether the disconnection was successful or not

Definition at line 151 of file comch_ctrl_path_server_sample.c.

◆ server_send_pong()

static doca_error_t server_send_pong ( struct comch_ctrl_path_server_objects sample_objects)
static

Send message on server

@sample_objects [in]: Sample objects struct @msg_buf [in]: Message to send @msg_len [in]: Length of message to send

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 188 of file comch_ctrl_path_server_sample.c.

◆ start_comch_ctrl_path_server_sample()

doca_error_t start_comch_ctrl_path_server_sample ( const char *  server_name,
const char *  dev_pci_addr,
const char *  rep_pci_addr,
const char *  text,
const uint32_t  text_len 
)

Run comch_server sample

@server_name [in]: Server name to connect to @dev_pci_addr [in]: PCI address to connect over @rep_pci_addr [in]: PCI address for the representor @text [in]: Message to send to the server @text_len [in]: Length of message

Returns
: DOCA_SUCCESS on success and DOCA_ERROR otherwise

Definition at line 428 of file comch_ctrl_path_server_sample.c.