]> git.proxmox.com Git - ceph.git/blob - ceph/src/dpdk/lib/librte_lpm/rte_lpm6.h
bump version to 12.2.12-pve1
[ceph.git] / ceph / src / dpdk / lib / librte_lpm / rte_lpm6.h
1 /*-
2 * BSD LICENSE
3 *
4 * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 #ifndef _RTE_LPM6_H_
34 #define _RTE_LPM6_H_
35
36 /**
37 * @file
38 * RTE Longest Prefix Match for IPv6 (LPM6)
39 */
40
41 #include <stdint.h>
42
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46
47
48 #define RTE_LPM6_MAX_DEPTH 128
49 #define RTE_LPM6_IPV6_ADDR_SIZE 16
50 /** Max number of characters in LPM name. */
51 #define RTE_LPM6_NAMESIZE 32
52
53 /** LPM structure. */
54 struct rte_lpm6;
55
56 /** LPM configuration structure. */
57 struct rte_lpm6_config {
58 uint32_t max_rules; /**< Max number of rules. */
59 uint32_t number_tbl8s; /**< Number of tbl8s to allocate. */
60 int flags; /**< This field is currently unused. */
61 };
62
63 /**
64 * Create an LPM object.
65 *
66 * @param name
67 * LPM object name
68 * @param socket_id
69 * NUMA socket ID for LPM table memory allocation
70 * @param config
71 * Structure containing the configuration
72 * @return
73 * Handle to LPM object on success, NULL otherwise with rte_errno set
74 * to an appropriate values. Possible rte_errno values include:
75 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
76 * - E_RTE_SECONDARY - function was called from a secondary process instance
77 * - EINVAL - invalid parameter passed to function
78 * - ENOSPC - the maximum number of memzones has already been allocated
79 * - EEXIST - a memzone with the same name already exists
80 * - ENOMEM - no appropriate memory area found in which to create memzone
81 */
82 struct rte_lpm6 *
83 rte_lpm6_create(const char *name, int socket_id,
84 const struct rte_lpm6_config *config);
85
86 /**
87 * Find an existing LPM object and return a pointer to it.
88 *
89 * @param name
90 * Name of the lpm object as passed to rte_lpm6_create()
91 * @return
92 * Pointer to lpm object or NULL if object not found with rte_errno
93 * set appropriately. Possible rte_errno values include:
94 * - ENOENT - required entry not available to return.
95 */
96 struct rte_lpm6 *
97 rte_lpm6_find_existing(const char *name);
98
99 /**
100 * Free an LPM object.
101 *
102 * @param lpm
103 * LPM object handle
104 * @return
105 * None
106 */
107 void
108 rte_lpm6_free(struct rte_lpm6 *lpm);
109
110 /**
111 * Add a rule to the LPM table.
112 *
113 * @param lpm
114 * LPM object handle
115 * @param ip
116 * IP of the rule to be added to the LPM table
117 * @param depth
118 * Depth of the rule to be added to the LPM table
119 * @param next_hop
120 * Next hop of the rule to be added to the LPM table
121 * @return
122 * 0 on success, negative value otherwise
123 */
124 int
125 rte_lpm6_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
126 uint8_t next_hop);
127
128 /**
129 * Check if a rule is present in the LPM table,
130 * and provide its next hop if it is.
131 *
132 * @param lpm
133 * LPM object handle
134 * @param ip
135 * IP of the rule to be searched
136 * @param depth
137 * Depth of the rule to searched
138 * @param next_hop
139 * Next hop of the rule (valid only if it is found)
140 * @return
141 * 1 if the rule exists, 0 if it does not, a negative value on failure
142 */
143 int
144 rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
145 uint8_t *next_hop);
146
147 /**
148 * Delete a rule from the LPM table.
149 *
150 * @param lpm
151 * LPM object handle
152 * @param ip
153 * IP of the rule to be deleted from the LPM table
154 * @param depth
155 * Depth of the rule to be deleted from the LPM table
156 * @return
157 * 0 on success, negative value otherwise
158 */
159 int
160 rte_lpm6_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth);
161
162 /**
163 * Delete a rule from the LPM table.
164 *
165 * @param lpm
166 * LPM object handle
167 * @param ips
168 * Array of IPs to be deleted from the LPM table
169 * @param depths
170 * Array of depths of the rules to be deleted from the LPM table
171 * @param n
172 * Number of rules to be deleted from the LPM table
173 * @return
174 * 0 on success, negative value otherwise.
175 */
176 int
177 rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm,
178 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], uint8_t *depths, unsigned n);
179
180 /**
181 * Delete all rules from the LPM table.
182 *
183 * @param lpm
184 * LPM object handle
185 */
186 void
187 rte_lpm6_delete_all(struct rte_lpm6 *lpm);
188
189 /**
190 * Lookup an IP into the LPM table.
191 *
192 * @param lpm
193 * LPM object handle
194 * @param ip
195 * IP to be looked up in the LPM table
196 * @param next_hop
197 * Next hop of the most specific rule found for IP (valid on lookup hit only)
198 * @return
199 * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
200 */
201 int
202 rte_lpm6_lookup(const struct rte_lpm6 *lpm, uint8_t *ip, uint8_t *next_hop);
203
204 /**
205 * Lookup multiple IP addresses in an LPM table.
206 *
207 * @param lpm
208 * LPM object handle
209 * @param ips
210 * Array of IPs to be looked up in the LPM table
211 * @param next_hops
212 * Next hop of the most specific rule found for IP (valid on lookup hit only).
213 * This is an array of two byte values. The next hop will be stored on
214 * each position on success; otherwise the position will be set to -1.
215 * @param n
216 * Number of elements in ips (and next_hops) array to lookup.
217 * @return
218 * -EINVAL for incorrect arguments, otherwise 0
219 */
220 int
221 rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm,
222 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE],
223 int16_t * next_hops, unsigned n);
224
225 #ifdef __cplusplus
226 }
227 #endif
228
229 #endif