Skip to content

Commit

Permalink
Adding Com Channel fast data path capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
EldarShalev committed Dec 10, 2023
1 parent 243ab9f commit 754d114
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions src/doca_cc_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
#include <doca_error.h>
#include <doca_log.h>
#include <doca_pe.h>
#include <doca_buf_inventory.h>
#include <doca_cc_consumer.h>
#include <doca_cc_producer.h>
#include <doca_mmap.h>

#include "os_abstract.h"

#define MSG_SIZE 4080
Expand All @@ -58,6 +63,25 @@ enum cc_client_state {
CONNECTION_IN_PROGRESS,
CC_CONNECTED
};
struct local_mem_bufs {
void *mem; /* Memory address for DOCA buf mmap */
struct doca_mmap *mmap; /* DOCA mmap object */
struct doca_buf_inventory *buf_inv; /* DOCA buf inventory object */
bool need_alloc_mem; /* Whether need to allocate memory */
};

struct cc_data_path_ctx {
struct doca_cc_consumer *consumer; /**< CC consumer object */
struct doca_pe *consumer_pe; /**< CC consumer's PE object */
struct local_mem_bufs consumer_mem; /**< Mmap and DOCA buf objects for consumer */
struct doca_cc_producer *producer; /**< CC producer object */
struct doca_pe *producer_pe; /**< CC producer's PE object */
struct local_mem_bufs producer_mem; /**< Mmap and DOCA buf objects for producer */
uint32_t remote_consumer_id; /**< Consumer ID on the peer side */
bool producer_finish; /**< Controls whether producer progress loop should be run */
bool consumer_finish; /**< Controls whether consumer progress loop should be run */
};

struct cc_ctx {
struct doca_dev *hw_dev; /**< Doca Device used per PCI address > */
struct doca_cc_connection *connection; /**< Connection object used for pairing a connection >*/
Expand All @@ -68,6 +92,7 @@ struct cc_ctx {
int fd; /**< File Descriptor >*/
os_mutex_t lock; /**< For underload mode only>*/
os_cond_t cond; /**< For underload mode only>*/
struct cc_data_path_ctx data_path; /**< Data path objects */
};

struct cc_ctx_server {
Expand Down Expand Up @@ -413,6 +438,36 @@ cc_server_state_changed_callback(const union doca_data user_data, struct doca_ct
}
}

/**
* Callback for new consumer arrival event
*
* @event [in]: New remote consumer event object
* @cc_connection [in]: The connection related to the consumer
* @id [in]: The ID of the new remote consumer
*/
static void
cc_server_new_consumer_callback(struct doca_cc_event_consumer *event, struct doca_cc_connection *cc_connection, uint32_t id)
{
union doca_data user_data;
struct doca_cc_server *cc_server;
doca_error_t result;

/* This argument is not in use */
(void)event;

cc_server = doca_cc_server_get_server_ctx(cc_connection);

result = doca_ctx_get_user_data(doca_cc_server_as_ctx(cc_server), &user_data);
if (result != DOCA_SUCCESS) {
DOCA_LOG_ERR("Failed to get user data from ctx with error = %s", doca_error_get_name(result));
return;
}
struct cc_ctx_server *ctx_server = (struct cc_ctx_server *)user_data.ptr;
ctx_server->ctx.data_path.remote_consumer_id = id;

DOCA_LOG_INFO("[fd=%d] Got a new remote consumer with ID = [%d]",ctx_server->ctx.fd, id);
}

static doca_error_t
cc_doca_server_set_params(struct cc_ctx_server *ctx_server)
{
Expand Down

0 comments on commit 754d114

Please sign in to comment.