32 #include "rdma_common.h"
36 #define EXAMPLE_SET_VALUE (0xD0CA)
78 DOCA_LOG_INFO(
"You can now copy %s to the responder",
cfg->local_connection_desc_path);
82 "Please copy %s and %s from the responder and then press enter after pressing enter in the responder side",
83 cfg->remote_connection_desc_path,
84 cfg->remote_resource_desc_path);
118 struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task,
133 free(successful_task_message);
148 struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task,
154 char *successful_task_message = (
char *)task_user_data.
ptr;
156 DOCA_LOG_INFO(
"RDMA remote net sync event notify set was done successfully");
190 struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task,
198 (void)task_user_data.
ptr;
232 struct doca_rdma_task_remote_net_sync_event_get *se_get_task,
238 struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task =
239 (
struct doca_rdma_task_remote_net_sync_event_notify_set *)task_user_data.
ptr;
241 struct doca_task *task, *set_task;
242 struct doca_buf *get_buf;
243 char *successful_task_message;
246 DOCA_LOG_INFO(
"RDMA remote net sync event get was done successfully");
255 goto propagate_error;
257 DOCA_LOG_INFO(
"Received sync event value 0x%X", *(
int *)buf_data);
264 goto propagate_error;
270 goto propagate_error;
283 goto propagate_error;
285 *(uint64_t *)buf_data = UINT64_MAX;
288 successful_task_message = (
char *)set_task_user_data.
ptr;
290 strncpy(successful_task_message,
291 "Remote sync event has been notified for completion successfully",
297 goto propagate_error;
319 DOCA_LOG_ERR(
"Failed to free remote_net_sync_event_notify_set task's resources: %s",
345 struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task =
346 (
struct doca_rdma_task_remote_net_sync_event_notify_set *)task_user_data.
ptr;
360 DOCA_LOG_ERR(
"Failed to free remote_net_sync_event_notify_set task's resources: %s",
387 struct doca_task *task =
NULL;
388 struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task;
389 struct doca_rdma_task_remote_net_sync_event_get *se_get_task;
393 char *successful_task_message;
402 DOCA_LOG_ERR(
"Failed to create remote sync event from export: %s",
409 if (successful_task_message ==
NULL) {
421 DOCA_LOG_ERR(
"Failed to allocate DOCA buffer to DOCA buffer inventory: %s",
423 goto free_successful_task_message;
429 goto destroy_set_buf;
434 task_user_data.
ptr = (
void *)successful_task_message;
445 goto destroy_set_buf;
448 task_user_data.
ptr = (
void *)se_set_task;
454 strncpy(successful_task_message,
455 "Remote sync event has been signaled successfully, now waiting for remote sync event to be signaled",
470 DOCA_LOG_ERR(
"Failed to allocate DOCA buffer to DOCA buffer inventory: %s",
479 goto destroy_get_buf;
491 goto destroy_get_buf;
501 goto destroy_get_buf;
523 free_successful_task_message:
524 free(successful_task_message);
555 DOCA_LOG_ERR(
"Failed to write and read connection details from the responder: %s",
566 DOCA_LOG_ERR(
"Failed to connect the requester's DOCA RDMA to the responder's DOCA RDMA: %s",
618 struct doca_ctx *
ctx,
627 switch (next_state) {
636 DOCA_LOG_ERR(
"rdma_sync_event_requestor_export_and_connect() failed: %s",
647 DOCA_LOG_ERR(
"rdma_sync_event_requestor_prepare_and_submit_tasks() failed: %s",
658 DOCA_LOG_INFO(
"RDMA context entered into stopping state. Any inflight tasks will be flushed");
695 struct timespec ts = {
715 DOCA_LOG_ERR(
"Unable to set configurations for RDMA sync event set task: %s",
717 goto destroy_resources;
725 DOCA_LOG_ERR(
"Unable to set configurations for RDMA sync event get task: %s",
727 goto destroy_resources;
733 goto destroy_resources;
740 goto destroy_resources;
747 goto destroy_buf_inventory;
755 goto stop_buf_inventory;
758 if (
cfg->use_rdma_cm ==
true) {
767 DOCA_LOG_ERR(
"Failed to config RDMA CM callbacks and negotiation functions: %s",
769 goto destroy_buf_inventory;
777 goto stop_buf_inventory;
799 destroy_buf_inventory:
doca_error_t destroy_rdma_resources(struct rdma_resources *resources)
void wait_for_enter(void)
doca_error_t write_file(const char *file_path, const char *string, size_t string_len)
doca_error_t rdma_cm_connect(struct rdma_resources *resources)
doca_error_t allocate_rdma_resources(struct rdma_config *cfg, const uint32_t mmap_permissions, const uint32_t rdma_permissions, task_check func, struct rdma_resources *resources)
doca_error_t config_rdma_cm_callback_and_negotiation_task(struct rdma_resources *resources, bool need_send_task, bool need_recv_task)
doca_error_t rdma_cm_disconnect(struct rdma_resources *resources)
#define INVENTORY_NUM_INITIAL_ELEMENTS
struct rdma_resources resources
DOCA_STABLE doca_error_t doca_buf_inventory_destroy(struct doca_buf_inventory *inventory)
Destroy buffer inventory structure.
static doca_error_t doca_buf_inventory_buf_get_by_addr(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *addr, size_t len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by addr & len argume...
static doca_error_t doca_buf_inventory_buf_get_by_data(struct doca_buf_inventory *inventory, struct doca_mmap *mmap, void *data, size_t data_len, struct doca_buf **buf)
Allocate single element from buffer inventory and point it to the buffer defined by data & data_len a...
DOCA_STABLE doca_error_t doca_buf_inventory_start(struct doca_buf_inventory *inventory)
Start element retrieval from inventory.
DOCA_STABLE doca_error_t doca_buf_inventory_create(size_t num_elements, struct doca_buf_inventory **inventory)
Allocates buffer inventory with default/unset attributes.
DOCA_STABLE doca_error_t doca_buf_inventory_stop(struct doca_buf_inventory *inventory)
Stop element retrieval from inventory.
DOCA_STABLE doca_error_t doca_buf_dec_refcount(struct doca_buf *buf, uint16_t *refcount)
Decrease the object reference count by 1, if 0 reached, return the element back to the inventory.
DOCA_STABLE doca_error_t doca_buf_get_data(const struct doca_buf *buf, void **data)
Get the buffer's data.
DOCA_STABLE doca_error_t doca_buf_reset_data_len(struct doca_buf *buf)
DOCA_STABLE doca_error_t doca_ctx_start(struct doca_ctx *ctx)
Finalizes all configurations, and starts the DOCA CTX.
DOCA_STABLE doca_error_t doca_ctx_set_state_changed_cb(struct doca_ctx *ctx, doca_ctx_state_changed_callback_t cb)
Set state changed callback.
DOCA_STABLE doca_error_t doca_ctx_set_user_data(struct doca_ctx *ctx, union doca_data user_data)
set user data to context
DOCA_STABLE doca_error_t doca_ctx_stop(struct doca_ctx *ctx)
Stops the context allowing reconfiguration.
doca_ctx_states
This enum defines the states of a context.
@ DOCA_CTX_STATE_STARTING
@ DOCA_CTX_STATE_STOPPING
#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.
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
DOCA_STABLE doca_error_t doca_task_get_status(const struct doca_task *task)
Get task status.
DOCA_STABLE doca_error_t doca_task_submit(struct doca_task *task)
Submit a task to a progress engine.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_STABLE union doca_data doca_task_get_user_data(const struct doca_task *task)
Get user data from a task.
DOCA_STABLE void doca_task_free(struct doca_task *task)
Free a task back to where it was allocated from.
DOCA_EXPERIMENTAL struct doca_task * doca_rdma_task_remote_net_sync_event_notify_set_as_task(struct doca_rdma_task_remote_net_sync_event_notify_set *task)
This method converts a remote_net_sync_event_notify_set task to a doca_task.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_task_remote_net_sync_event_get_set_conf(struct doca_rdma *rdma, doca_rdma_task_remote_net_sync_event_get_completion_cb_t successful_task_completion_cb, doca_rdma_task_remote_net_sync_event_get_completion_cb_t error_task_completion_cb, uint32_t num_tasks)
This method sets the remote_net_sync_event_get tasks configuration.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_cap_task_remote_net_sync_event_notify_set_is_supported(const struct doca_devinfo *devinfo)
DOCA_EXPERIMENTAL struct doca_task * doca_rdma_task_remote_net_sync_event_get_as_task(struct doca_rdma_task_remote_net_sync_event_get *task)
This method converts a remote_net_sync_event_get task to a doca_task.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_task_remote_net_sync_event_notify_set_set_conf(struct doca_rdma *rdma, doca_rdma_task_remote_net_sync_event_notify_set_completion_cb_t successful_task_completion_cb, doca_rdma_task_remote_net_sync_event_notify_set_completion_cb_t error_task_completion_cb, uint32_t num_tasks)
This method sets the remote_net_sync_event_notify_set tasks configuration.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_cap_task_remote_net_sync_event_get_is_supported(const struct doca_devinfo *devinfo)
DOCA_EXPERIMENTAL doca_error_t doca_rdma_export(struct doca_rdma *rdma, const void **local_rdma_conn_details, size_t *local_rdma_conn_details_size, struct doca_rdma_connection **rdma_connection)
Export doca_rdma connection details object The doca_rdma_conn_details are used in doca_rdma_connect()...
DOCA_EXPERIMENTAL doca_error_t doca_rdma_task_remote_net_sync_event_notify_set_allocate_init(struct doca_rdma *rdma, struct doca_rdma_connection *rdma_connection, struct doca_sync_event_remote_net *event, const struct doca_buf *src_buf, union doca_data user_data, struct doca_rdma_task_remote_net_sync_event_notify_set **task)
This method allocates and initializes a remote_net_sync_event_notify_set task.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_connect(struct doca_rdma *rdma, const void *remote_rdma_conn_details, size_t remote_rdma_conn_details_size, struct doca_rdma_connection *rdma_connection)
Connect to remote doca_rdma peer. Can only be called when the ctx is in DOCA_CTX_STATE_STARTING state...
DOCA_EXPERIMENTAL struct doca_buf * doca_rdma_task_remote_net_sync_event_get_get_dst_buf(const struct doca_rdma_task_remote_net_sync_event_get *task)
This method gets the destination buffer of a remote_net_sync_event_get task.
DOCA_EXPERIMENTAL doca_error_t doca_rdma_task_remote_net_sync_event_get_allocate_init(struct doca_rdma *rdma, struct doca_rdma_connection *rdma_connection, const struct doca_sync_event_remote_net *event, struct doca_buf *dst_buf, union doca_data user_data, struct doca_rdma_task_remote_net_sync_event_get **task)
This method allocates and initializes a remote_net_sync_event_get task.
@ DOCA_RDMA_TRANSPORT_TYPE_RC
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_remote_net_create_from_export(struct doca_dev *dev, const uint8_t *data, size_t sz, struct doca_sync_event_remote_net **event)
Create a remote Sync Event handle from an export.
DOCA_EXPERIMENTAL doca_error_t doca_sync_event_remote_net_destroy(struct doca_sync_event_remote_net *event)
Destroy a Sync Event instance.
@ DOCA_ACCESS_FLAG_LOCAL_READ_WRITE
const struct ip_frag_config * cfg
static void rdma_sync_event_requestor_state_change_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 rdma_sync_event_requestor_destroy_remote_sync_event(struct rdma_resources *resources)
static doca_error_t rdma_sync_event_requestor_export_and_connect(struct rdma_resources *resources)
static void rdma_remote_net_sync_event_get_completed_callback(struct doca_rdma_task_remote_net_sync_event_get *se_get_task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t rdma_remote_net_sync_event_notify_set_free_task_resources(struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task, union doca_data ctx_user_data)
static void rdma_remote_net_sync_event_notify_set_error_callback(struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t write_read_connection(struct rdma_config *cfg, struct rdma_resources *resources)
DOCA_LOG_REGISTER(RDMA_SYNC_EVENT_REQUESTER::SAMPLE)
static void rdma_remote_net_sync_event_notify_set_completed_callback(struct doca_rdma_task_remote_net_sync_event_notify_set *se_set_task, union doca_data task_user_data, union doca_data ctx_user_data)
static void rdma_remote_net_sync_event_get_error_callback(struct doca_rdma_task_remote_net_sync_event_get *se_get_task, union doca_data task_user_data, union doca_data ctx_user_data)
static doca_error_t rdma_sync_event_requestor_prepare_and_submit_tasks(struct rdma_resources *resources)
#define EXAMPLE_SET_VALUE
doca_error_t rdma_sync_event_requester(struct rdma_config *cfg)
static doca_error_t sync_event_tasks_supported(const struct doca_devinfo *devinfo)
size_t remote_rdma_conn_descriptor_size
doca_error_t first_encountered_error
struct doca_ctx * rdma_ctx
size_t sync_event_descriptor_size
size_t num_remaining_tasks
prepare_and_submit_task_fn task_fn
const void * rdma_conn_descriptor
bool recv_sync_event_desc
struct doca_sync_event_remote_net * remote_se
void * remote_rdma_conn_descriptor
struct doca_rdma_connection * connections[MAX_NUM_CONNECTIONS]
struct doca_buf * dst_buf
struct doca_dev * doca_device
struct doca_buf * src_buf
struct doca_buf_inventory * buf_inventory
size_t rdma_conn_descriptor_size
void * sync_event_descriptor
Convenience type for representing opaque data.
struct upf_accel_ctx * ctx
doca_error_t read_file(char const *path, char **out_bytes, size_t *out_bytes_len)