NVIDIA DOCA SDK Data Center on a Chip Framework Documentation
flow_pipes_manager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 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_PIPES_MANAGER_H_
27 #define COMMON_FLOW_PIPES_MANAGER_H_
28 
29 #include <doca_flow.h>
30 
31 struct pipe_info {
32  struct doca_flow_pipe *pipe; /* DOCA Flow pipe pointer */
33  struct rte_hash *entries_table; /* Pipe entries table */
34  struct rte_hash *port_id_to_pipes_table; /* Pipes table for the specific port on which the pipe was created */
35 };
36 
38  struct rte_hash *pipe_id_to_pipe_info_table; /* map pipe id to all relevant entries to support
39  doca_flow_destroy_port() */
40  struct rte_hash *entry_id_to_pipe_id_table; /* map entry id to pipe id to support
41  doca_flow_pipe_remove_entry() */
42  struct rte_hash *port_id_to_pipes_id_table; /* map port id to all relevant pipes to support
43  doca_flow_port_pipes_flush() */
44 };
45 
46 /*
47  * Create flow pipe manager structures
48  *
49  * @pipes_manager [out]: Pointer to the newly created pipes manager
50  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
51  */
53 
54 /*
55  * Destroy flow pipe manager
56  *
57  * @manager [in]: Pipes manager to destroy
58  */
59 void destroy_pipes_manager(struct flow_pipes_manager *manager);
60 
61 /*
62  * Save the given DOCA Flow pipe and generate an ID for it
63  *
64  * @manager [in]: Pipes manager pointer
65  * @pipe [in]: DOCA Flow pipe pointer
66  * @port_id [in]: ID of the relevant port to add pipe to
67  * @pipe_id [out]: Generated pipe ID
68  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
69  */
71  struct doca_flow_pipe *pipe,
72  uint16_t port_id,
73  uint64_t *pipe_id);
74 
75 /*
76  * Save the given DOCA Flow entry and generate an ID for it
77  *
78  * @manager [in]: Pipes manager pointer
79  * @entry [in]: DOCA Flow entry pointer
80  * @pipe_id [out]: ID of pipe to add entry to
81  * @entry_id [out]: Generated entry ID
82  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
83  */
85  struct doca_flow_pipe_entry *entry,
86  uint64_t pipe_id,
87  uint64_t *entry_id);
88 
89 /*
90  * Get the DOCA Flow pipe pointer of the given pipe ID
91  *
92  * @manager [in]: Pipes manager pointer
93  * @pipe_id [in]: ID of the needed pipe to get
94  * @pipe [out]: DOCA Flow pipe
95  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
96  */
97 doca_error_t pipes_manager_get_pipe(struct flow_pipes_manager *manager, uint64_t pipe_id, struct doca_flow_pipe **pipe);
98 
99 /*
100  * Get the DOCA Flow entry pointer of the given entry ID
101  *
102  * @manager [in]: Pipes manager pointer
103  * @entry_id [in]: ID of the needed entry
104  * @entry [out]: DOCA Flow entry
105  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
106  */
108  uint64_t entry_id,
109  struct doca_flow_pipe_entry **entry);
110 
111 /*
112  * Destroy a pipe and all of its entries
113  *
114  * @manager [in]: Pipes manager pointer
115  * @pipe_id [in]: ID of the needed pipe to destroy
116  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
117  */
118 doca_error_t pipes_manager_pipe_destroy(struct flow_pipes_manager *manager, uint64_t pipe_id);
119 
120 /*
121  * Remove an entry
122  *
123  * @manager [in]: Pipes manager pointer
124  * @entry_id [in]: ID of the needed entry to remove
125  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
126  */
127 doca_error_t pipes_manager_pipe_rm_entry(struct flow_pipes_manager *manager, uint64_t entry_id);
128 
129 /*
130  * Remove all pipes and their entries for a specific port ID
131  *
132  * @manager [in]: Pipes manager pointer
133  * @port_id [in]: ID of the needed port
134  * @return: DOCA_SUCCESS on success and DOCA_ERROR otherwise
135  */
136 doca_error_t pipes_manager_pipes_flush(struct flow_pipes_manager *manager, uint16_t port_id);
137 
138 #endif /* COMMON_FLOW_PIPES_MANAGER_H_ */
static struct doca_flow_pipe_entry * entry[MAX_ENTRIES]
doca_error_t pipes_manager_pipe_add_entry(struct flow_pipes_manager *manager, struct doca_flow_pipe_entry *entry, uint64_t pipe_id, uint64_t *entry_id)
doca_error_t pipes_manager_pipe_destroy(struct flow_pipes_manager *manager, uint64_t pipe_id)
doca_error_t pipes_manager_get_pipe(struct flow_pipes_manager *manager, uint64_t pipe_id, struct doca_flow_pipe **pipe)
doca_error_t create_pipes_manager(struct flow_pipes_manager **pipes_manager)
void destroy_pipes_manager(struct flow_pipes_manager *manager)
doca_error_t pipes_manager_pipe_create(struct flow_pipes_manager *manager, struct doca_flow_pipe *pipe, uint16_t port_id, uint64_t *pipe_id)
doca_error_t pipes_manager_get_entry(struct flow_pipes_manager *manager, uint64_t entry_id, struct doca_flow_pipe_entry **entry)
doca_error_t pipes_manager_pipe_rm_entry(struct flow_pipes_manager *manager, uint64_t entry_id)
doca_error_t pipes_manager_pipes_flush(struct flow_pipes_manager *manager, uint16_t port_id)
enum doca_error doca_error_t
DOCA API return codes.
struct rte_hash * pipe_id_to_pipe_info_table
struct rte_hash * port_id_to_pipes_id_table
struct rte_hash * entry_id_to_pipe_id_table
struct rte_hash * port_id_to_pipes_table
struct rte_hash * entries_table
struct doca_flow_pipe * pipe
static struct flow_pipes_manager * pipes_manager
Definition: switch_core.c:41