NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
comch_ctrl_path_common.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 NVIDIA CORPORATION AND AFFILIATES. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification, are permitted
5  * provided that the following conditions are met:
6  * * Redistributions of source code must retain the above copyright notice, this list of
7  * conditions and the following disclaimer.
8  * * Redistributions in binary form must reproduce the above copyright notice, this list of
9  * conditions and the following disclaimer in the documentation and/or other materials
10  * provided with the distribution.
11  * * Neither the name of the NVIDIA CORPORATION nor the names of its contributors may be used
12  * to endorse or promote products derived from this software without specific prior written
13  * permission.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
17  * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NVIDIA CORPORATION BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
20  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
21  * STRICT LIABILITY, OR TOR (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23  *
24  */
25 
26 #ifndef COMCH_COMMON_H_
27 #define COMCH_COMMON_H_
28 
29 #include <stdbool.h>
30 
31 #include <doca_comch.h>
32 #include <doca_ctx.h>
33 #include <doca_dev.h>
34 #include <doca_error.h>
35 #include <doca_pe.h>
36 
37 #define MAX_SAMPLE_TXT_SIZE 4080 /* Maximum size of user input text for the sample */
38 #define MAX_TXT_SIZE (MAX_SAMPLE_TXT_SIZE + 1) /* Maximum size of input text */
39 #define SLEEP_IN_NANOS (10 * 1000) /* Sample tasks every 10 microseconds */
40 
41 struct comch_config {
42  char comch_dev_pci_addr[DOCA_DEVINFO_PCI_ADDR_SIZE]; /* Comm Channel DOCA device PCI address */
43  char comch_dev_rep_pci_addr[DOCA_DEVINFO_REP_PCI_ADDR_SIZE]; /* Comm Channel DOCA device representor PCI address
44  */
45  char text[MAX_TXT_SIZE]; /* Text to send to Comm Channel server */
46  uint32_t text_size; /* Text size to send to Comm Channel server */
47 };
48 
50  /* User specified callback when task completed successfully */
52  /* User specified callback when task completed with error */
54  /* User specified callback when a message is received */
56  /* Whether need to configure data_path related event callback */
58  /* User specified callback when a new consumer registered */
60  /* User specified callback when a consumer expired event occurs */
62  /* User specified context data */
64  /* User specified PE context state changed event callback */
66 };
67 
69  /* User specified callback when task completed successfully */
71  /* User specified callback when task completed with error */
73  /* User specified callback when a message is received */
75  /* User specified callback when server receives a new connection */
77  /* User specified callback when server finds a disconnected connection */
79  /* Whether need to configure data_path related event callback */
81  /* User specified callback when a new consumer registered */
83  /* User specified callback when a consumer expired event occurs */
85  /* User specified context data */
87  /* User specified PE context state changed event callback */
89 };
90 
91 /*
92  * Register the command line parameters for the DOCA CC samples
93  *
94  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
95  */
97 
104 void clean_comch_ctrl_path_client(struct doca_comch_client *client, struct doca_pe *pe);
105 
116 doca_error_t init_comch_ctrl_path_client(const char *server_name,
117  struct doca_dev *hw_dev,
118  struct comch_ctrl_path_client_cb_config *cb_cfg,
119  struct doca_comch_client **client,
120  struct doca_pe **pe);
121 
128 void clean_comch_ctrl_path_server(struct doca_comch_server *server, struct doca_pe *pe);
129 
141 doca_error_t init_comch_ctrl_path_server(const char *server_name,
142  struct doca_dev *hw_dev,
143  struct doca_dev_rep *rep_dev,
144  struct comch_ctrl_path_server_cb_config *cb_cfg,
145  struct doca_comch_server **server,
146  struct doca_pe **pe);
147 
148 #endif // COMCH_COMMON_H_
doca_error_t register_comch_params(void)
#define MAX_TXT_SIZE
doca_error_t init_comch_ctrl_path_client(const char *server_name, struct doca_dev *hw_dev, struct comch_ctrl_path_client_cb_config *cb_cfg, struct doca_comch_client **client, struct doca_pe **pe)
void clean_comch_ctrl_path_client(struct doca_comch_client *client, struct doca_pe *pe)
void clean_comch_ctrl_path_server(struct doca_comch_server *server, struct doca_pe *pe)
doca_error_t init_comch_ctrl_path_server(const char *server_name, struct doca_dev *hw_dev, struct doca_dev_rep *rep_dev, struct comch_ctrl_path_server_cb_config *cb_cfg, struct doca_comch_server **server, struct doca_pe **pe)
static struct doca_pe * pe
void(* doca_comch_event_consumer_cb_t)(struct doca_comch_event_consumer *event, struct doca_comch_connection *comch_connection, uint32_t id)
Definition: doca_comch.h:874
void(* doca_comch_event_msg_recv_cb_t)(struct doca_comch_event_msg_recv *event, uint8_t *recv_buffer, uint32_t msg_len, struct doca_comch_connection *comch_connection)
Definition: doca_comch.h:718
void(* doca_comch_task_send_completion_cb_t)(struct doca_comch_task_send *task, union doca_data task_user_data, union doca_data ctx_user_data)
Definition: doca_comch.h:563
void(* doca_comch_event_connection_status_changed_cb_t)(struct doca_comch_event_connection_status_changed *event, struct doca_comch_connection *comch_connection, uint8_t change_successful)
Definition: doca_comch.h:778
void(* doca_ctx_state_changed_callback_t)(const union doca_data user_data, struct doca_ctx *ctx, enum doca_ctx_states prev_state, enum doca_ctx_states next_state)
Function to execute on context state change.
Definition: doca_ctx.h:123
#define DOCA_DEVINFO_REP_PCI_ADDR_SIZE
Buffer size to hold PCI BDF format: "XXXX:XX:XX.X". Including a null terminator.
Definition: doca_dev.h:665
#define DOCA_DEVINFO_PCI_ADDR_SIZE
Buffer size to hold PCI BDF format: "XXXX:XX:XX.X". Including a null terminator.
Definition: doca_dev.h:313
enum doca_error doca_error_t
DOCA API return codes.
char comch_dev_pci_addr[DOCA_DEVINFO_PCI_ADDR_SIZE]
char text[MAX_TXT_SIZE]
char comch_dev_rep_pci_addr[DOCA_DEVINFO_REP_PCI_ADDR_SIZE]
doca_comch_task_send_completion_cb_t send_task_comp_cb
doca_comch_event_consumer_cb_t new_consumer_cb
doca_comch_event_msg_recv_cb_t msg_recv_cb
doca_ctx_state_changed_callback_t ctx_state_changed_cb
doca_comch_event_consumer_cb_t expired_consumer_cb
doca_comch_task_send_completion_cb_t send_task_comp_err_cb
doca_comch_event_connection_status_changed_cb_t server_connection_event_cb
doca_comch_task_send_completion_cb_t send_task_comp_err_cb
doca_comch_event_msg_recv_cb_t msg_recv_cb
doca_comch_task_send_completion_cb_t send_task_comp_cb
doca_comch_event_consumer_cb_t expired_consumer_cb
doca_ctx_state_changed_callback_t ctx_state_changed_cb
doca_comch_event_connection_status_changed_cb_t server_disconnection_event_cb
doca_comch_event_consumer_cb_t new_consumer_cb