4 * Copyright(c) 2010-2013 Intel Corporation. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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
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.
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.
39 * RTE Longest Prefix Match for IPv6 (LPM6)
47 #define RTE_LPM6_MAX_DEPTH 128
48 #define RTE_LPM6_IPV6_ADDR_SIZE 16
49 /** Max number of characters in LPM name. */
50 #define RTE_LPM6_NAMESIZE 32
55 /** LPM configuration structure. */
56 struct rte_lpm6_config {
57 uint32_t max_rules; /**< Max number of rules. */
58 uint32_t number_tbl8s; /**< Number of tbl8s to allocate. */
59 int flags; /**< This field is currently unused. */
63 * Create an LPM object.
68 * NUMA socket ID for LPM table memory allocation
70 * Structure containing the configuration
72 * Handle to LPM object on success, NULL otherwise with rte_errno set
73 * to an appropriate values. Possible rte_errno values include:
74 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
75 * - E_RTE_SECONDARY - function was called from a secondary process instance
76 * - E_RTE_NO_TAILQ - no tailq list could be got for the lpm object list
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
83 rte_lpm6_create(const char *name, int socket_id,
84 const struct rte_lpm6_config *config);
87 * Find an existing LPM object and return a pointer to it.
90 * Name of the lpm object as passed to rte_lpm6_create()
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.
97 rte_lpm6_find_existing(const char *name);
100 * Free an LPM object.
108 rte_lpm6_free(struct rte_lpm6 *lpm);
111 * Add a rule to the LPM table.
116 * IP of the rule to be added to the LPM table
118 * Depth of the rule to be added to the LPM table
120 * Next hop of the rule to be added to the LPM table
122 * 0 on success, negative value otherwise
125 rte_lpm6_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
129 * Delete a rule from the LPM table.
134 * IP of the rule to be deleted from the LPM table
136 * Depth of the rule to be deleted from the LPM table
138 * 0 on success, negative value otherwise
141 rte_lpm6_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth);
144 * Delete a rule from the LPM table.
149 * Array of IPs to be deleted from the LPM table
151 * Array of depths of the rules to be deleted from the LPM table
153 * Number of rules to be deleted from the LPM table
155 * 0 on success, negative value otherwise.
158 rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm,
159 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], uint8_t *depths, unsigned n);
162 * Delete all rules from the LPM table.
168 rte_lpm6_delete_all(struct rte_lpm6 *lpm);
171 * Lookup an IP into the LPM table.
176 * IP to be looked up in the LPM table
178 * Next hop of the most specific rule found for IP (valid on lookup hit only)
180 * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
183 rte_lpm6_lookup(const struct rte_lpm6 *lpm, uint8_t *ip, uint8_t *next_hop);
186 * Lookup multiple IP addresses in an LPM table.
191 * Array of IPs to be looked up in the LPM table
193 * Next hop of the most specific rule found for IP (valid on lookup hit only).
194 * This is an array of two byte values. The next hop will be stored on
195 * each position on success; otherwise the position will be set to -1.
197 * Number of elements in ips (and next_hops) array to lookup.
199 * -EINVAL for incorrect arguments, otherwise 0
202 rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm,
203 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE],
204 int16_t * next_hops, unsigned n);