NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
eth_l2_fwd_core.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 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 ETH_L2_FWD_CORE_H_
27 #define ETH_L2_FWD_CORE_H_
28 
29 #include <doca_dev.h>
30 #include <doca_mmap.h>
31 
33 
34 #define ETH_L2_FWD_MAX_PKT_SIZE_DEFAULT 1600
35 #define ETH_L2_FWD_PKTS_RECV_RATE_DEFAULT 12500
36 #define ETH_L2_FWD_PKT_MAX_PROCESS_TIME_DEFAULT 1
37 #define ETH_L2_FWD_LOG_MAX_LRO_DEFAULT 15
38 #define ETH_L2_FWD_NUM_TASK_BATCHES_DEFAULT 32
39 #define ETH_L2_FWD_NUM_TASKS_PER_BATCH 128
40 
41 /* Ethernet L2 Forwarding application configuration */
43  char mlxdev_name1[DOCA_DEVINFO_IBDEV_NAME_SIZE]; /* First IB device name */
44  char mlxdev_name2[DOCA_DEVINFO_IBDEV_NAME_SIZE]; /* Second IB device name */
45  uint32_t max_burst_size; /* Max burst size for DOCA ETH contexts creation and memory buffer size estimation */
46  uint32_t pkts_recv_rate; /* Packets receive rate for ETH RXQ memory buffer size estimation */
47  uint32_t max_pkt_size; /* Max packet size for ETH RXQ context creation and memory buffer size estimation */
48  uint16_t pkt_max_process_time; /* Packet max process time for ETH RXQ memory buffer size estimation */
49  uint16_t num_task_batches; /* Number of task batches */
50  uint8_t one_sided_fwd; /* One-sided forwarding flag:
51  * 0 - two-sided forwarding
52  * 1 - device 1 -> device 2
53  * 2 - device 2 -> device 1
54  */
55 };
56 
57 /* DOCA mmap resources */
59  struct doca_mmap *mmap; /* DOCA mmap */
60  uint8_t *mmap_buffer; /* Memory buffer for mmap */
61  uint32_t mmap_size; /* Size of mmap's memory buffer */
62 };
63 
64 /* Ethernet L2 Forwarding application single device resources */
66  struct doca_dev *mlxdev; /* DOCA device */
67 
68  struct doca_eth_rxq *eth_rxq; /* DOCA Ethernet RXQ context */
69  struct doca_ctx *eth_rxq_ctx; /* DOCA Ethernet RXQ context as DOCA context */
70 
71  struct doca_eth_txq *eth_txq; /* DOCA Ethernet TXQ context */
72  struct doca_ctx *eth_txq_ctx; /* DOCA Ethernet TXQ context as DOCA context */
73 
74  struct eth_rxq_flow_resources flow_resrc; /* DOCA flow resources for mlxdev */
75 
76  struct mmap_resources mmap_resrc; /* Memory resources to set for the ETH RXQ context */
77 
78  uint16_t rxq_flow_queue_id; /* Flow queue ID for the ETH RXQ context */
79 };
80 
81 /* Ethernet L2 Forwarding application resources */
83  struct doca_pe *pe; /* DOCA progress engine */
84 
85  struct eth_l2_fwd_dev_resources dev_resrc1; /* First IB device resources */
86  struct eth_l2_fwd_dev_resources dev_resrc2; /* Second IB device resources */
87 };
88 
89 /*
90  * Executes the application's logic
91  *
92  * @cfg [in]: Ethernet L2 Forwarding application configuration
93  * @state [in]: Ethernet L2 Forwarding application resources
94  * @return: DOCA_SUCCESS on success and DOCA_ERROR_... otherwise
95  */
97 
98 /*
99  * Stops the application forcefully during execution
100  */
101 void eth_l2_fwd_force_stop(void);
102 
103 /*
104  * Clean up the application's resources
105  *
106  * @state [in]: Ethernet L2 Forwarding application resources to clean up
107  * @return: DOCA_SUCCESS on success and DOCA_ERROR_... otherwise
108  */
110 
111 #endif /* ETH_L2_FWD_CORE_H_ */
doca_error_t eth_l2_fwd_cleanup(struct eth_l2_fwd_resources *state)
doca_error_t eth_l2_fwd_execute(struct eth_l2_fwd_cfg *cfg, struct eth_l2_fwd_resources *state)
void eth_l2_fwd_force_stop(void)
#define DOCA_DEVINFO_IBDEV_NAME_SIZE
Buffer size to hold Infiniband/RoCE device name. Including a null terminator.
Definition: doca_dev.h:309
enum doca_error doca_error_t
DOCA API return codes.
const struct ip_frag_config * cfg
Definition: ip_frag_dp.c:0
uint16_t num_task_batches
uint32_t max_burst_size
char mlxdev_name1[DOCA_DEVINFO_IBDEV_NAME_SIZE]
char mlxdev_name2[DOCA_DEVINFO_IBDEV_NAME_SIZE]
uint8_t one_sided_fwd
uint32_t max_pkt_size
uint32_t pkts_recv_rate
uint16_t pkt_max_process_time
struct doca_eth_txq * eth_txq
struct doca_ctx * eth_rxq_ctx
struct doca_ctx * eth_txq_ctx
struct doca_eth_rxq * eth_rxq
struct mmap_resources mmap_resrc
struct eth_rxq_flow_resources flow_resrc
struct doca_dev * mlxdev
struct eth_l2_fwd_dev_resources dev_resrc1
struct eth_l2_fwd_dev_resources dev_resrc2
struct doca_pe * pe
uint8_t * mmap_buffer
struct doca_mmap * mmap
uint32_t mmap_size