NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_skeleton.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 COMMON_FLOW_SKELETON_H_
27 #define COMMON_FLOW_SKELETON_H_
28 
29 #include <doca_flow.h>
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
36  enum doca_flow_entry_op op; /* doca flow entry operation */
37  enum doca_flow_pipe_type type; /* pipe type for adding the entry */
38  struct doca_flow_pipe *pipe; /* pointer to the pipe of the entry */
39  uint32_t priority; /* priority value */
40  struct doca_flow_match *match; /* pointer to match */
41  struct doca_flow_match *match_mask; /* pointer to match mask */
42  struct doca_flow_actions *actions; /* pointer to modify actions */
43  struct doca_flow_actions *actions_mask; /* pointer to modify actions' mask */
44  const struct doca_flow_action_descs *action_descs; /* pointer to action descriptions */
45  struct doca_flow_monitor *monitor; /* pointer to monitor actions */
46  struct doca_flow_fwd *fwd; /* pointer to fwd actions */
47  uint32_t idx; /* unique entry index for ordered list entry */
48  const struct doca_flow_ordered_list *ordered_list; /* pointer to ordered list struct */
49  void *usr_ctx; /* pointer to user context */
50  struct doca_flow_pipe_entry **entry; /* created pipe entry handler */
51 };
52 
54  struct doca_flow_match match; /* match struct, indicate specific packet match information */
55  struct doca_flow_match match_mask; /* match mask information */
56  struct doca_flow_actions actions; /* modify actions, indicate specific modify information */
57  const struct doca_flow_action_descs action_descs; /* action descriptions */
58  struct doca_flow_monitor monitor; /* monitor actions, indicate specific monitor information */
59  struct doca_flow_fwd fwd; /* fwd actions */
60  const struct doca_flow_ordered_list ordered_list; /* ordered list with pointers to actions and monitor */
61 };
62 
64  struct flow_skeleton_entry_ctx ctx; /* context to sent to add entry API */
65  struct flow_skeleton_entry_mem mem; /* memory to fill */
66 };
67 
69  bool to_remove; /* Whether to remove the aged entry or not */
70 };
71 
75 typedef void (*flow_skeleton_process_cb)(struct doca_flow_pipe_entry *entry,
76  uint16_t pipe_queue,
77  enum doca_flow_entry_status status,
78  void *user_ctx,
79  void *program_ctx);
80 
85  uint16_t port_id,
86  void *program_ctx,
87  uint32_t *nb_entries);
88 
93  uint16_t port_id,
94  void *program_ctx,
95  uint32_t *nb_entries);
96 
100 typedef void (*flow_skeleton_aging_cb)(struct doca_flow_pipe_entry *entry, struct flow_skeleton_aging_op *aging_op);
101 
105 typedef void (*flow_skeleton_failure_cb)(void);
106 
108  uint32_t nb_ports; /* number of ports */
109  uint32_t nb_entries; /* number of entries to fill in entries acquisition cb */
110  uint32_t queue_depth; /* DOCA Flow queue depth */
111  uint16_t nb_queues; /* pipe's queue id for each offload thread */
112  bool handle_aging; /* true if application wants to handle aging */
113  flow_skeleton_process_cb add_cb; /* process callback for add operation */
114  flow_skeleton_process_cb remove_cb; /* process callback for remove operation */
116  flow_skeleton_initialize_cb init_cb; /* initialization callback */
117  flow_skeleton_aging_cb aging_cb; /* aging callback */
118  flow_skeleton_failure_cb failure_cb; /* Failure callback */
119 };
120 
122  bool initialization; /* Whether to call the init_cb on this core or not */
123  uint16_t pipe_queue; /* pipe queue for adding entries - lcore ID */
124  void *program_ctx; /* application context */
125  int nb_ports; /* number of initialized ports */
126  struct doca_flow_port *ports[]; /* array of DOCA Flow ports */
127 };
128 
129 /*
130  * Initialize DOCA Flow and the skeleton resources
131  *
132  * @flow_cfg [in]: DOCA Flow configuration struct
133  * @skeleton_cfg [in]: skeleton configuration struct
134  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
135  */
136 doca_error_t flow_skeleton_init(struct doca_flow_cfg *flow_cfg, struct flow_skeleton_cfg *skeleton_cfg);
137 
138 /*
139  * Destroy DOCA Flow and free the skeleton resources
140  */
141 void flow_skeleton_destroy(void);
142 
143 /*
144  * Run the skeleton main loop
145  *
146  * @main_loop_params [in]: pointer of type struct flow_skeleton_main_loop_params
147  */
149 
150 /*
151  * Notify the skeleton to exit from main loop
152  */
154 
155 #ifdef __cplusplus
156 } /* extern "C" */
157 #endif
158 
159 #endif /* COMMON_FLOW_SKELETON_H_ */
static int nb_entries
static struct doca_flow_pipe_entry * entries[NB_ENTRIES]
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
void(* flow_skeleton_initialize_cb)(struct flow_skeleton_entry *entries, uint16_t port_id, void *program_ctx, uint32_t *nb_entries)
Definition: flow_skeleton.h:92
void(* flow_skeleton_process_cb)(struct doca_flow_pipe_entry *entry, uint16_t pipe_queue, enum doca_flow_entry_status status, void *user_ctx, void *program_ctx)
Definition: flow_skeleton.h:75
doca_error_t flow_skeleton_init(struct doca_flow_cfg *flow_cfg, struct flow_skeleton_cfg *skeleton_cfg)
void(* flow_skeleton_aging_cb)(struct doca_flow_pipe_entry *entry, struct flow_skeleton_aging_op *aging_op)
void flow_skeleton_main_loop(void *main_loop_params)
void flow_skeleton_destroy(void)
void(* flow_skeleton_entries_acquisition_cb)(struct flow_skeleton_entry *entries, uint16_t port_id, void *program_ctx, uint32_t *nb_entries)
Definition: flow_skeleton.h:84
void flow_skeleton_notify_exit(void)
void(* flow_skeleton_failure_cb)(void)
enum doca_error doca_error_t
DOCA API return codes.
doca_flow_entry_op
doca flow entry operation
Definition: doca_flow.h:146
doca_flow_pipe_type
doca flow pipe type
Definition: doca_flow.h:220
doca_flow_entry_status
doca flow entry status
Definition: doca_flow.h:160
action descriptor array
Definition: doca_flow.h:1033
doca flow actions information
Definition: doca_flow.h:684
forwarding configuration
Definition: doca_flow.h:779
doca flow matcher information
Definition: doca_flow.h:491
doca monitor action configuration
Definition: doca_flow.h:968
Ordered list configuration.
Definition: doca_flow.h:1077
flow_skeleton_aging_cb aging_cb
flow_skeleton_entries_acquisition_cb entries_acquisition_cb
flow_skeleton_failure_cb failure_cb
flow_skeleton_process_cb add_cb
flow_skeleton_process_cb remove_cb
flow_skeleton_initialize_cb init_cb
Definition: flow_skeleton.h:35
struct doca_flow_fwd * fwd
Definition: flow_skeleton.h:46
enum doca_flow_pipe_type type
Definition: flow_skeleton.h:37
struct doca_flow_pipe * pipe
Definition: flow_skeleton.h:38
struct doca_flow_monitor * monitor
Definition: flow_skeleton.h:45
uint32_t idx
Definition: flow_skeleton.h:47
void * usr_ctx
Definition: flow_skeleton.h:49
uint32_t priority
Definition: flow_skeleton.h:39
struct doca_flow_match * match_mask
Definition: flow_skeleton.h:41
struct doca_flow_pipe_entry ** entry
Definition: flow_skeleton.h:50
struct doca_flow_actions * actions_mask
Definition: flow_skeleton.h:43
const struct doca_flow_ordered_list * ordered_list
Definition: flow_skeleton.h:48
struct doca_flow_match * match
Definition: flow_skeleton.h:40
enum doca_flow_entry_op op
Definition: flow_skeleton.h:36
const struct doca_flow_action_descs * action_descs
Definition: flow_skeleton.h:44
struct doca_flow_actions * actions
Definition: flow_skeleton.h:42
Definition: flow_skeleton.h:53
struct doca_flow_monitor monitor
Definition: flow_skeleton.h:58
struct doca_flow_match match
Definition: flow_skeleton.h:54
struct doca_flow_match match_mask
Definition: flow_skeleton.h:55
const struct doca_flow_ordered_list ordered_list
Definition: flow_skeleton.h:60
const struct doca_flow_action_descs action_descs
Definition: flow_skeleton.h:57
struct doca_flow_fwd fwd
Definition: flow_skeleton.h:59
struct doca_flow_actions actions
Definition: flow_skeleton.h:56
Definition: flow_skeleton.h:63
struct flow_skeleton_entry_ctx ctx
Definition: flow_skeleton.h:64
struct flow_skeleton_entry_mem mem
Definition: flow_skeleton.h:65
struct doca_flow_port * ports[]