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, const uint8_t *ip, uint8_t depth,
101 * Check if a rule is present in the LPM table,
102 * and provide its next hop if it is.
107 * IP of the rule to be searched
109 * Depth of the rule to searched
111 * Next hop of the rule (valid only if it is found)
113 * 1 if the rule exists, 0 if it does not, a negative value on failure
116 rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth,
120 * Delete a rule from the LPM table.
125 * IP of the rule to be deleted from the LPM table
127 * Depth of the rule to be deleted from the LPM table
129 * 0 on success, negative value otherwise
132 rte_lpm6_delete(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth);
135 * Delete a rule from the LPM table.
140 * Array of IPs to be deleted from the LPM table
142 * Array of depths of the rules to be deleted from the LPM table
144 * Number of rules to be deleted from the LPM table
146 * 0 on success, negative value otherwise.
149 rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm,
150 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], uint8_t *depths, unsigned n);
153 * Delete all rules from the LPM table.
159 rte_lpm6_delete_all(struct rte_lpm6 *lpm);
162 * Lookup an IP into the LPM table.
167 * IP to be looked up in the LPM table
169 * Next hop of the most specific rule found for IP (valid on lookup hit only)
171 * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
174 rte_lpm6_lookup(const struct rte_lpm6 *lpm, const uint8_t *ip, uint32_t *next_hop);
177 * Lookup multiple IP addresses in an LPM table.
182 * Array of IPs to be looked up in the LPM table
184 * Next hop of the most specific rule found for IP (valid on lookup hit only).
185 * This is an array of two byte values. The next hop will be stored on
186 * each position on success; otherwise the position will be set to -1.
188 * Number of elements in ips (and next_hops) array to lookup.
190 * -EINVAL for incorrect arguments, otherwise 0
193 rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm,
194 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE],
195 int32_t *next_hops, unsigned int n);