28 #include <rte_ethdev.h>
34 #define SLEEP_IN_NANOS (10 * 1000)
41 static struct doca_dev *
ddev;
48 static struct doca_pe *
pe;
60 uint16_t packet_index;
63 DOCA_LOG_INFO(
"Error in send queue %ld, packet %d. Gracefully killing the app",
79 uint16_t packet_index;
80 uint64_t packet_timestamp;
89 DOCA_LOG_INFO(
"ICMP debug event: Queue %ld packet %d sent at %ld time from last ICMP is %.6f sec",
93 (
double)((ts_diff > 0 ? ((
double)ts_diff) / 1000000000.0 : 0)));
109 ret = clock_gettime(CLOCK_REALTIME, &t);
113 (*sec) = (uint64_t)t.tv_sec;
115 return (uint64_t)t.tv_nsec + (uint64_t)t.tv_sec * 1000 * 1000 * 1000;
128 enum doca_gpu_semaphore_status status;
133 uint64_t start_time_sec = 0;
134 uint64_t interval_print = 0;
135 uint64_t interval_sec = 0;
139 DOCA_LOG_INFO(
"Core %u is reporting filter stats", rte_lcore_id());
141 interval_print =
get_ns(&interval_sec);
142 while (DOCA_GPUNETIO_VOLATILE(
force_quit) ==
false) {
152 if (status == DOCA_GPU_SEMAPHORE_STATUS_READY) {
155 (
void **)&(custom_udp_st));
162 udp_st[idxq].
dns += custom_udp_st->
dns;
168 DOCA_GPU_SEMAPHORE_STATUS_FREE);
170 DOCA_LOG_ERR(
"UDP semaphore %d error", sem_idx_udp[idxq]);
188 if (status == DOCA_GPU_SEMAPHORE_STATUS_READY) {
191 (
void **)&(custom_tcp_st));
198 tcp_st[idxq].
http += custom_tcp_st->
http;
210 DOCA_GPU_SEMAPHORE_STATUS_FREE);
212 DOCA_LOG_ERR(
"TCP semaphore %d error", sem_idx_tcp[idxq]);
221 if ((
get_ns(&interval_sec) - interval_print) > 5000000000) {
222 printf(
"\nSeconds %ld\n", interval_sec - start_time_sec);
225 printf(
"[UDP] QUEUE: %d DNS: %ld OTHER: %ld TOTAL: %ld\n",
233 printf(
"[TCP] QUEUE: %d HTTP: %d HTTP HEAD: %d HTTP GET: %d HTTP POST: %d TCP [SYN: %d FIN: %d ACK: %d] OTHER: %d TOTAL: %d\n",
246 interval_print =
get_ns(&interval_sec);
258 if (signum == SIGINT || signum == SIGTERM) {
259 DOCA_LOG_INFO(
"Signal %d received, preparing to exit!", signum);
271 int main(
int argc,
char **argv)
274 int current_lcore = 0;
276 cudaError_t cuda_ret;
277 struct doca_log_backend *sdk_log;
278 struct timespec ts = {
296 DOCA_LOG_INFO(
"===========================================================");
298 DOCA_LOG_INFO(
"===========================================================");
319 DOCA_LOG_INFO(
"Options enabled:\n\tGPU %s\n\tNIC %s\n\tGPU Rx queues %d\n\tGPU HTTP server enabled %s",
327 if (cuda_ret != cudaSuccess) {
333 cudaSetDevice(cuda_id);
406 cudaStream_t rx_tcp_stream, rx_udp_stream, rx_icmp_stream, tx_http_server;
407 cudaError_t res_rt = cudaSuccess;
408 uint32_t *cpu_exit_condition;
409 uint32_t *gpu_exit_condition;
411 res_rt = cudaStreamCreateWithFlags(&rx_udp_stream, cudaStreamNonBlocking);
412 if (res_rt != cudaSuccess) {
413 DOCA_LOG_ERR(
"Function cudaStreamCreateWithFlags error %d", res_rt);
417 res_rt = cudaStreamCreateWithFlags(&rx_tcp_stream, cudaStreamNonBlocking);
418 if (res_rt != cudaSuccess) {
419 DOCA_LOG_ERR(
"Function cudaStreamCreateWithFlags error %d", res_rt);
423 res_rt = cudaStreamCreateWithFlags(&rx_icmp_stream, cudaStreamNonBlocking);
424 if (res_rt != cudaSuccess) {
425 DOCA_LOG_ERR(
"Function cudaStreamCreateWithFlags error %d", res_rt);
430 res_rt = cudaStreamCreateWithFlags(&tx_http_server, cudaStreamNonBlocking);
431 if (res_rt != cudaSuccess) {
432 DOCA_LOG_ERR(
"Function cudaStreamCreateWithFlags error %d", res_rt);
441 (
void **)&gpu_exit_condition,
442 (
void **)&cpu_exit_condition);
447 cpu_exit_condition[0] = 0;
453 DOCA_GPUNETIO_VOLATILE(*cpu_exit_condition) = 1;
460 cudaStreamSynchronize(rx_udp_stream);
461 cudaStreamSynchronize(rx_tcp_stream);
462 cudaStreamSynchronize(rx_icmp_stream);
464 cudaStreamSynchronize(tx_http_server);
465 DOCA_GPUNETIO_VOLATILE(*cpu_exit_condition) = 0;
476 current_lcore = rte_get_next_lcore(current_lcore,
true,
false);
477 if (rte_eal_remote_launch((
void *)
stats_core,
NULL, current_lcore) != 0) {
487 RTE_MBUF_DEFAULT_BUF_SIZE,
490 DOCA_LOG_ERR(
"%s: failed to allocate tcp-ack packet pool", __func__);
497 current_lcore = rte_get_next_lcore(current_lcore,
true,
false);
507 while (DOCA_GPUNETIO_VOLATILE(
force_quit) ==
false) {
512 DOCA_GPUNETIO_VOLATILE(*cpu_exit_condition) = 1;
513 cudaStreamSynchronize(rx_udp_stream);
514 cudaStreamDestroy(rx_udp_stream);
515 cudaStreamSynchronize(rx_tcp_stream);
516 cudaStreamDestroy(rx_tcp_stream);
517 cudaStreamSynchronize(rx_icmp_stream);
518 cudaStreamDestroy(rx_icmp_stream);
520 cudaStreamSynchronize(tx_http_server);
521 cudaStreamDestroy(tx_http_server);
524 doca_gpu_mem_free(
gpu_dev, gpu_exit_condition);
529 RTE_LCORE_FOREACH_WORKER(current_lcore)
531 if (rte_eal_wait_lcore(current_lcore) < 0) {
doca_error_t kernel_receive_icmp(cudaStream_t stream, uint32_t *exit_cond, struct rxq_icmp_queues *icmp_queues)
struct doca_flow_port * init_doca_flow(uint16_t port_id, uint8_t rxq_num)
doca_error_t destroy_flow_queue(struct doca_flow_port *port_df, struct rxq_icmp_queues *icmp_queues, struct rxq_udp_queues *udp_queues, struct rxq_tcp_queues *tcp_queues, bool http_server, struct txq_http_queues *http_queues)
doca_error_t kernel_receive_udp(cudaStream_t stream, uint32_t *exit_cond, struct rxq_udp_queues *udp_queues)
doca_error_t create_root_pipe(struct rxq_udp_queues *udp_queues, struct rxq_tcp_queues *tcp_queues, struct rxq_icmp_queues *icmp_queues, struct doca_flow_port *port)
doca_error_t init_doca_device(char *nic_pcie_addr, struct doca_dev **ddev, uint16_t *dpdk_port_id)
doca_error_t create_icmp_queues(struct rxq_icmp_queues *icmp_queues, struct doca_flow_port *df_port, struct doca_gpu *gpu_dev, struct doca_dev *ddev, uint32_t queue_num, struct doca_pe *pe, doca_eth_txq_gpu_event_error_send_packet_cb_t event_error_send_packet_cb, doca_eth_txq_gpu_event_notify_send_packet_cb_t event_notify_send_packet_cb)
doca_error_t kernel_http_server(cudaStream_t stream, uint32_t *exit_cond, struct rxq_tcp_queues *tcp_queues, struct txq_http_queues *http_queues)
doca_error_t kernel_receive_tcp(cudaStream_t stream, uint32_t *exit_cond, struct rxq_tcp_queues *tcp_queues, bool http_server)
doca_error_t create_udp_queues(struct rxq_udp_queues *udp_queues, struct doca_flow_port *df_port, struct doca_gpu *gpu_dev, struct doca_dev *ddev, uint32_t queue_num, uint32_t sem_num)
doca_error_t create_tcp_queues(struct rxq_tcp_queues *tcp_queues, struct doca_flow_port *df_port, struct doca_gpu *gpu_dev, struct doca_dev *ddev, uint32_t queue_num, uint32_t sem_num, bool http_server, struct txq_http_queues *http_queues, struct doca_pe *pe, doca_eth_txq_gpu_event_error_send_packet_cb_t event_error_send_packet_cb)
doca_error_t register_application_params(void)
#define SEMAPHORES_PER_QUEUE
static struct doca_pe * pe
static struct rxq_icmp_queues icmp_queues
int main(int argc, char **argv)
static struct doca_flow_port * df_port
static uint64_t get_ns(uint64_t *sec)
static struct rxq_tcp_queues tcp_queues
void debug_send_packet_icmp_cb(struct doca_eth_txq_gpu_event_notify_send_packet *event_notify, union doca_data event_user_data)
static uint16_t dpdk_dev_port_id
static struct app_gpu_cfg app_cfg
static struct rxq_udp_queues udp_queues
static struct doca_gpu * gpu_dev
static struct txq_http_queues http_queues
DOCA_LOG_REGISTER(GPU_PACKET_PROCESSING)
static struct doca_dev * ddev
void error_send_packet_cb(struct doca_eth_txq_gpu_event_error_send_packet *event_error, union doca_data event_user_data)
static void stats_core(void *args)
static void signal_handler(int signum)
static uint64_t icmp_last_ping
DOCA_EXPERIMENTAL doca_error_t doca_argp_start(int argc, char **argv)
Parse incoming arguments (cmd line/json).
DOCA_EXPERIMENTAL doca_error_t doca_argp_init(const char *program_name, void *program_config)
Initialize the parser interface.
DOCA_STABLE doca_error_t doca_dev_close(struct doca_dev *dev)
Destroy allocated local device instance.
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_EXPERIMENTAL doca_error_t doca_eth_txq_gpu_event_notify_send_packet_get_position(const struct doca_eth_txq_gpu_event_notify_send_packet *event_notify, uint16_t *packet_index)
This method returns the index in the send queue of the packet which reported the notify info.
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_gpu_event_notify_send_packet_get_timestamp(const struct doca_eth_txq_gpu_event_notify_send_packet *event_notify, uint64_t *packet_timestamp)
This method returns the timestamp at which the packet in the send queue was actually sent (fired over...
DOCA_EXPERIMENTAL doca_error_t doca_eth_txq_gpu_event_error_send_packet_get_position(const struct doca_eth_txq_gpu_event_error_send_packet *event_error, uint16_t *packet_index)
This method returns the index in the send queue of the packet which caused the error.
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_create_standard(void)
Create default, non configurable backend for application messages.
#define DOCA_LOG_ERR(format,...)
Generates an ERROR application log message.
#define DOCA_LOG_INFO(format,...)
Generates an INFO application log message.
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_create_with_file_sdk(FILE *fptr, struct doca_log_backend **backend)
Create a logging backend with a FILE* stream for SDK messages.
DOCA_EXPERIMENTAL doca_error_t doca_log_backend_set_sdk_level(struct doca_log_backend *backend, uint32_t level)
Set the log level limit for SDK logging backends.
DOCA_STABLE doca_error_t doca_pe_destroy(struct doca_pe *pe)
Destroy doca progress engine.
DOCA_STABLE uint8_t doca_pe_progress(struct doca_pe *pe)
Run the progress engine.
DOCA_STABLE doca_error_t doca_pe_create(struct doca_pe **pe)
Creates DOCA progress engine.
@ DOCA_GPU_MEM_TYPE_GPU_CPU
static const char * doca_version(void)
Function returning DOCA's (SDK) exact version string.
char nic_pcie_addr[DOCA_DEVINFO_PCI_ADDR_SIZE]
char gpu_pcie_addr[DOCA_DEVINFO_PCI_ADDR_SIZE]
struct rte_mempool * tcp_ack_pkt_pool
struct doca_gpu_semaphore * sem_cpu[MAX_QUEUES]
struct doca_gpu_semaphore * sem_cpu[MAX_QUEUES]
Convenience type for representing opaque data.