26 #include <arpa/inet.h>
27 #include <rte_ethdev.h>
30 #include <doca_gpunetio.h>
40 "Date: Sun, 30 Apr 2023 20:30:40 GMT\r\n"
41 "Content-Type: text/html; charset=UTF-8\r\n"
42 "Content-Length: 158\r\n"
43 "Last-Modified: Sun, 30 Apr 2023 22:38:34 GMT\r\n"
44 "Server: GPUNetIO\r\n"
45 "Accept-Ranges: bytes\r\n"
46 "Connection: keep-alive\r\n"
47 "Keep-Alive: timeout=5\r\n"
51 " <title>GPUNetIO index page</title>\r\n"
54 " <p>Hello World, the GPUNetIO server Index page!</p>\r\n"
60 "Date: Sun, 30 Apr 2023 20:30:40 GMT\r\n"
61 "Content-Type: text/html; charset=UTF-8\r\n"
62 "Content-Length: 175\r\n"
63 "Last-Modified: Sun, 30 Apr 2023 22:38:34 GMT\r\n"
64 "Server: GPUNetIO\r\n"
65 "Accept-Ranges: bytes\r\n"
66 "Connection: keep-alive\r\n"
67 "Keep-Alive: timeout=5\r\n"
71 " <title>GPUNetIO Contact page</title>\r\n"
74 " <p>For any GPUNetIO question please contact support@nvidia.com</p>\r\n"
80 "Date: Sun, 30 Apr 2023 20:30:40 GMT\r\n"
81 "Content-Type: text/html; charset=UTF-8\r\n"
82 "Content-Length: 152\r\n"
83 "Last-Modified: Sun, 30 Apr 2023 22:38:34 GMT\r\n"
84 "Server: GPUNetIO\r\n"
85 "Connection: close\r\n"
89 " <title>GPUNetIO 404 page</title>\r\n"
92 " <p>Hello! Page you requested doesn't exist!</p>\r\n"
99 struct doca_dev *
ddev,
100 uint32_t num_packets,
117 DOCA_LOG_ERR(
"Unable to create doca_buf: failed to create mmap");
123 DOCA_LOG_ERR(
"Unable to add dev to buf: doca mmap internal error");
127 status = doca_gpu_mem_alloc(buf->
gpu_dev,
134 DOCA_LOG_ERR(
"Unable to alloc txbuf: failed to allocate gpu memory");
139 status = doca_gpu_dmabuf_fd(buf->
gpu_dev,
144 DOCA_LOG_INFO(
"Mapping send queue buffer (0x%p size %dB) with legacy nvidia-peermem mode",
151 DOCA_LOG_ERR(
"Unable to start buf: doca mmap internal error");
155 DOCA_LOG_INFO(
"Mapping send queue buffer (0x%p size %dB dmabuf fd %d) with dmabuf mode",
174 DOCA_LOG_ERR(
"Unable to start buf: doca mmap internal error");
180 DOCA_LOG_ERR(
"Unable to start buf: doca mmap internal error");
186 DOCA_LOG_ERR(
"Unable to start buf: doca buf_arr internal error");
192 DOCA_LOG_ERR(
"Unable to start buf: doca buf_arr internal error");
198 DOCA_LOG_ERR(
"Unable to start buf: doca buf_arr internal error");
204 DOCA_LOG_ERR(
"Unable to start buf: doca buf_arr internal error");
219 uint8_t *cpu_pkt_addr;
223 cudaError_t res_cuda;
235 if (cpu_pkt_addr ==
NULL) {
236 DOCA_LOG_ERR(
"Error in txbuf preparation, failed to allocate memory");
240 for (uint32_t idx = 0; idx < buf->
num_packets; idx++) {
246 hdr->l3_hdr.version_ihl = 0x45;
247 hdr->l3_hdr.type_of_service = 0x0;
248 hdr->l3_hdr.total_length =
250 hdr->l3_hdr.packet_id = 0;
251 hdr->l3_hdr.fragment_offset = 0;
252 hdr->l3_hdr.time_to_live = 60;
253 hdr->l3_hdr.next_proto_id = 6;
254 hdr->l3_hdr.hdr_checksum = 0;
255 hdr->l3_hdr.src_addr = 0;
256 hdr->l3_hdr.dst_addr = 0;
258 hdr->l4_hdr.src_port = 0;
259 hdr->l4_hdr.dst_port = 0;
260 hdr->l4_hdr.sent_seq = 0;
261 hdr->l4_hdr.recv_ack = 0;
263 hdr->l4_hdr.dt_off = 0x50;
267 hdr->l4_hdr.cksum = 0;
268 hdr->l4_hdr.tcp_urp = 0;
279 if (res_cuda != cudaSuccess) {
280 DOCA_LOG_ERR(
"Function CUDA Memcpy cqe_addr failed with %s", cudaGetErrorString(res_cuda));
298 DOCA_LOG_ERR(
"Unable to stop buf: unable to stop mmap");
304 DOCA_LOG_ERR(
"Unable to remove dev from buf: doca mmap internal error");
310 DOCA_LOG_ERR(
"Unable to destroy doca_buf: failed to destroy mmap");
316 DOCA_LOG_ERR(
"Unable to stop buf: failed to free gpu memory");
322 DOCA_LOG_ERR(
"Unable to stop buf: failed to destroy doca_buf_arr");
328 DOCA_LOG_ERR(
"Unable to stop buf: failed to destroy doca_buf_arr");
static struct doca_gpu * gpu_dev
static struct doca_dev * ddev
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_destroy(struct doca_buf_arr *buf_arr)
Destroys a doca buf array instance.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_set_params(struct doca_buf_arr *buf_arr, struct doca_mmap *mmap, size_t elem_size, uint64_t start_offset)
Sets the buf array params.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_stop(struct doca_buf_arr *buf_arr)
Stops a started doca buf array.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_set_target_gpu(struct doca_buf_arr *buf_arr, struct doca_gpu *gpu_handler)
Configures the buf array to be created on the gpu device.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_get_gpu_handle(const struct doca_buf_arr *buf_arr, struct doca_gpu_buf_arr **gpu_buf_arr)
Retrieves the handle in the gpu memory space of a doca_buf_arr.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_create(size_t num_elem, struct doca_buf_arr **buf_arr)
Allocates a doca_buf_arr.
DOCA_EXPERIMENTAL doca_error_t doca_buf_arr_start(struct doca_buf_arr *buf_arr)
This method enables the allocation of doca_bufs.
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
#define DOCA_FLOW_ETHER_TYPE_IPV4
#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_mmap_set_memrange(struct doca_mmap *mmap, void *addr, size_t len)
Set the memory range of DOCA memory map.
DOCA_STABLE doca_error_t doca_mmap_rm_dev(struct doca_mmap *mmap, struct doca_dev *dev)
Deregister given device from DOCA memory map.
DOCA_STABLE doca_error_t doca_mmap_destroy(struct doca_mmap *mmap)
Destroy DOCA Memory Map structure.
DOCA_STABLE doca_error_t doca_mmap_create(struct doca_mmap **mmap)
Allocates zero size memory map object with default/unset attributes.
DOCA_STABLE doca_error_t doca_mmap_set_permissions(struct doca_mmap *mmap, uint32_t access_mask)
Set access flags of the registered memory.
DOCA_STABLE doca_error_t doca_mmap_start(struct doca_mmap *mmap)
Start DOCA Memory Map.
DOCA_STABLE doca_error_t doca_mmap_stop(struct doca_mmap *mmap)
Stop DOCA Memory Map.
DOCA_STABLE doca_error_t doca_mmap_add_dev(struct doca_mmap *mmap, struct doca_dev *dev)
Register DOCA memory map on a given device.
DOCA_STABLE doca_error_t doca_mmap_set_dmabuf_memrange(struct doca_mmap *mmap, int dmabuf_fd, void *addr, size_t dmabuf_offset, size_t len)
Set the memory range of DOCA memory map using dmabuf.
@ DOCA_ACCESS_FLAG_LOCAL_READ_WRITE
@ DOCA_ACCESS_FLAG_PCI_RELAXED_ORDERING
doca_error_t create_tx_buf(struct tx_buf *buf, struct doca_gpu *gpu_dev, struct doca_dev *ddev, uint32_t num_packets, uint32_t max_pkt_sz)
const char * payload_page_index
const char * payload_page_contacts
doca_error_t destroy_tx_buf(struct tx_buf *buf)
DOCA_LOG_REGISTER(GPU_PACKET_PROCESSING_TXBUF)
const char * payload_page_not_found
doca_error_t prepare_tx_buf(struct tx_buf *buf, enum http_page_get page_type)
struct doca_buf_arr * buf_arr
struct doca_gpu_buf_arr * buf_arr_gpu
struct doca_gpu * gpu_dev