NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_switch_common.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 FLOW_SWITCH_COMMON_H_
27 #define FLOW_SWITCH_COMMON_H_
28 
29 #include <rte_byteorder.h>
30 
31 #include <doca_flow.h>
32 #include <doca_dev.h>
33 #include <common.h>
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define FLOW_SWITCH_PORTS_MAX (128)
40 
41 /* doca flow switch context */
43  bool is_expert; /* switch expert mode */
44  uint16_t nb_ports; /* switch port number */
45  uint16_t nb_reps; /* switch port number */
46  const char *dev_arg[FLOW_SWITCH_PORTS_MAX]; /* dpdk dev_arg */
47  const char *rep_arg[FLOW_SWITCH_PORTS_MAX]; /* dpdk rep_arg */
48  struct doca_dev *doca_dev[FLOW_SWITCH_PORTS_MAX]; /* port doca_dev */
49  tasks_check port_cap; /* Optional port capability callback */
50  void *usr_ctx; /* user context */
51 };
52 
53 /*
54  * Init DOCA Flow switch
55  *
56  * @argc [in]: dpdk argc
57  * @dpdk_argv [in]: dpdk argv
58  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
59  */
60 doca_error_t init_flow_switch_dpdk(int argc, char **dpdk_argv);
61 
62 /*
63  * Register DOCA Flow switch parameter
64  *
65  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
66  */
68 
69 /*
70  * Init DOCA Flow switch
71  *
72  * @ctx [in]: flow switch context
73  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise.
74  */
76 
77 /*
78  * Destroy dOCA Flow switch context
79  *
80  * @ctx [in]: flow switch context
81  */
83 
84 /*
85  * Get number of DPDK ports created during EAL init according to user arguments.
86  *
87  * @return: number of created DPDK ports.
88  */
89 uint8_t get_dpdk_nb_ports(void);
90 
91 #ifdef __cplusplus
92 }
93 #endif
94 #endif /* FLOW_SWITCH_COMMON_H_ */
doca_error_t init_doca_flow_switch_common(struct flow_switch_ctx *ctx)
uint8_t get_dpdk_nb_ports(void)
void destroy_doca_flow_switch_common(struct flow_switch_ctx *ctx)
#define FLOW_SWITCH_PORTS_MAX
doca_error_t register_doca_flow_switch_param(void)
doca_error_t init_flow_switch_dpdk(int argc, char **dpdk_argv)
enum doca_error doca_error_t
DOCA API return codes.
doca_error_t(* tasks_check)(struct doca_devinfo *)
Definition: common.h:42
const char * rep_arg[FLOW_SWITCH_PORTS_MAX]
tasks_check port_cap
struct doca_dev * doca_dev[FLOW_SWITCH_PORTS_MAX]
const char * dev_arg[FLOW_SWITCH_PORTS_MAX]
struct upf_accel_ctx * ctx