1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation
9 * RTE Longest Prefix Match for IPv6 (LPM6)
19 #define RTE_LPM6_MAX_DEPTH 128
20 #define RTE_LPM6_IPV6_ADDR_SIZE 16
21 /** Max number of characters in LPM name. */
22 #define RTE_LPM6_NAMESIZE 32
27 /** LPM configuration structure. */
28 struct rte_lpm6_config {
29 uint32_t max_rules; /**< Max number of rules. */
30 uint32_t number_tbl8s; /**< Number of tbl8s to allocate. */
31 int flags; /**< This field is currently unused. */
35 * Create an LPM object.
40 * NUMA socket ID for LPM table memory allocation
42 * Structure containing the configuration
44 * Handle to LPM object on success, NULL otherwise with rte_errno set
45 * to an appropriate values. Possible rte_errno values include:
46 * - E_RTE_NO_CONFIG - function could not get pointer to rte_config structure
47 * - E_RTE_SECONDARY - function was called from a secondary process instance
48 * - EINVAL - invalid parameter passed to function
49 * - ENOSPC - the maximum number of memzones has already been allocated
50 * - EEXIST - a memzone with the same name already exists
51 * - ENOMEM - no appropriate memory area found in which to create memzone
54 rte_lpm6_create(const char *name, int socket_id,
55 const struct rte_lpm6_config *config);
58 * Find an existing LPM object and return a pointer to it.
61 * Name of the lpm object as passed to rte_lpm6_create()
63 * Pointer to lpm object or NULL if object not found with rte_errno
64 * set appropriately. Possible rte_errno values include:
65 * - ENOENT - required entry not available to return.
68 rte_lpm6_find_existing(const char *name);
79 rte_lpm6_free(struct rte_lpm6 *lpm);
82 * Add a rule to the LPM table.
87 * IP of the rule to be added to the LPM table
89 * Depth of the rule to be added to the LPM table
91 * Next hop of the rule to be added to the LPM table
93 * 0 on success, negative value otherwise
96 rte_lpm6_add(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth,
100 * Check if a rule is present in the LPM table,
101 * and provide its next hop if it is.
106 * IP of the rule to be searched
108 * Depth of the rule to searched
110 * Next hop of the rule (valid only if it is found)
112 * 1 if the rule exists, 0 if it does not, a negative value on failure
115 rte_lpm6_is_rule_present(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth,
119 * Delete a rule from the LPM table.
124 * IP of the rule to be deleted from the LPM table
126 * Depth of the rule to be deleted from the LPM table
128 * 0 on success, negative value otherwise
131 rte_lpm6_delete(struct rte_lpm6 *lpm, const uint8_t *ip, uint8_t depth);
134 * Delete a rule from the LPM table.
139 * Array of IPs to be deleted from the LPM table
141 * Array of depths of the rules to be deleted from the LPM table
143 * Number of rules to be deleted from the LPM table
145 * 0 on success, negative value otherwise.
148 rte_lpm6_delete_bulk_func(struct rte_lpm6 *lpm,
149 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE], uint8_t *depths, unsigned n);
152 * Delete all rules from the LPM table.
158 rte_lpm6_delete_all(struct rte_lpm6 *lpm);
161 * Lookup an IP into the LPM table.
166 * IP to be looked up in the LPM table
168 * Next hop of the most specific rule found for IP (valid on lookup hit only)
170 * -EINVAL for incorrect arguments, -ENOENT on lookup miss, 0 on lookup hit
173 rte_lpm6_lookup(const struct rte_lpm6 *lpm, const uint8_t *ip, uint32_t *next_hop);
176 * Lookup multiple IP addresses in an LPM table.
181 * Array of IPs to be looked up in the LPM table
183 * Next hop of the most specific rule found for IP (valid on lookup hit only).
184 * This is an array of two byte values. The next hop will be stored on
185 * each position on success; otherwise the position will be set to -1.
187 * Number of elements in ips (and next_hops) array to lookup.
189 * -EINVAL for incorrect arguments, otherwise 0
192 rte_lpm6_lookup_bulk_func(const struct rte_lpm6 *lpm,
193 uint8_t ips[][RTE_LPM6_IPV6_ADDR_SIZE],
194 int32_t *next_hops, unsigned int n);