1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
9 * RTE Longest Prefix Match for IPv6 (LPM6)
13 #include <rte_compat.h>
20 #define RTE_LPM6_MAX_DEPTH 128
21 #define RTE_LPM6_IPV6_ADDR_SIZE 16
22 /** Max number of characters in LPM name. */
23 #define RTE_LPM6_NAMESIZE 32
28 /** LPM configuration structure. */
29 struct rte_lpm6_config {
30 uint32_t max_rules; /**< Max number of rules. */
31 uint32_t number_tbl8s; /**< Number of tbl8s to allocate. */
32 int flags; /**< This field is currently unused. */
36 * Create an LPM object.
41 * NUMA socket ID for LPM table memory allocation
43 * Structure containing the configuration
45 * Handle to LPM object on success, NULL otherwise with rte_errno set
46 * to an appropriate values. Possible rte_errno values include:
47 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
48 * - E_RTE_SECONDARY - function was called from a secondary process instance
49 * - EINVAL - invalid parameter passed to function
50 * - ENOSPC - the maximum number of memzones has already been allocated
51 * - EEXIST - a memzone with the same name already exists
52 * - ENOMEM - no appropriate memory area found in which to create memzone
55 rte_lpm6_create(const char *name, int socket_id,
56 const struct rte_lpm6_config *config);
59 * Find an existing LPM object and return a pointer to it.
62 * Name of the lpm object as passed to rte_lpm6_create()
64 * Pointer to lpm object or NULL if object not found with rte_errno
65 * set appropriately. Possible rte_errno values include:
66 * - ENOENT - required entry not available to return.
69 rte_lpm6_find_existing(const char *name);
80 rte_lpm6_free(struct rte_lpm6 *lpm);
83 * Add a rule to the LPM table.
88 * IP of the rule to be added to the LPM table
90 * Depth of the rule to be added to the LPM table
92 * Next hop of the rule to be added to the LPM table
94 * 0 on success, negative value otherwise
97 rte_lpm6_add(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
100 rte_lpm6_add_v20(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
103 rte_lpm6_add_v1705(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
107 * Check if a rule is present in the LPM table,
108 * and provide its next hop if it is.
113 * IP of the rule to be searched
115 * Depth of the rule to searched
117 * Next hop of the rule (valid only if it is found)
119 * 1 if the rule exists, 0 if it does not, a negative value on failure
122 rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
125 rte_lpm6_is_rule_present_v20(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
128 rte_lpm6_is_rule_present_v1705(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth,
132 * Delete a rule from the LPM table.
137 * IP of the rule to be deleted from the LPM table
139 * Depth of the rule to be deleted from the LPM table
141 * 0 on success, negative value otherwise
144 rte_lpm6_delete(struct rte_lpm6 *lpm, uint8_t *ip, uint8_t depth);
147 * Delete a rule from the LPM table.
152 * Array of IPs to be deleted from the LPM table
154 * Array of depths of the rules to be deleted from the LPM table
156 * Number of rules to be deleted from the LPM table
158 * 0 on success, negative value otherwise.
161 rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm,
162 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], uint8_t *depths, unsigned n);
165 * Delete all rules from the LPM table.
171 rte_lpm6_delete_all(struct rte_lpm6 *lpm);
174 * Lookup an IP into the LPM table.
179 * IP to be looked up in the LPM table
181 * Next hop of the most specific rule found for IP (valid on lookup hit only)
183 * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
186 rte_lpm6_lookup(const struct rte_lpm6 *lpm, uint8_t *ip, uint32_t *next_hop);
188 rte_lpm6_lookup_v20(const struct rte_lpm6 *lpm, uint8_t *ip, uint8_t *next_hop);
190 rte_lpm6_lookup_v1705(const struct rte_lpm6 *lpm, uint8_t *ip,
194 * Lookup multiple IP addresses in an LPM table.
199 * Array of IPs to be looked up in the LPM table
201 * Next hop of the most specific rule found for IP (valid on lookup hit only).
202 * This is an array of two byte values. The next hop will be stored on
203 * each position on success; otherwise the position will be set to -1.
205 * Number of elements in ips (and next_hops) array to lookup.
207 * -EINVAL for incorrect arguments, otherwise 0
210 rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm,
211 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE],
212 int32_t *next_hops, unsigned int n);
214 rte_lpm6_lookup_bulk_func_v20(const struct rte_lpm6 *lpm,
215 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE],
216 int16_t *next_hops, unsigned int n);
218 rte_lpm6_lookup_bulk_func_v1705(const struct rte_lpm6 *lpm,
219 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE],
220 int32_t *next_hops, unsigned int n);