1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
3 * Copyright(c) 2019 Intel Corporation
11 * FIB (Forwarding information base) implementation
12 * for IPv6 Longest Prefix Match
15 #include <rte_compat.h>
21 #define RTE_FIB6_IPV6_ADDR_SIZE 16
22 /** Maximum depth value possible for IPv6 FIB. */
23 #define RTE_FIB6_MAXDEPTH 128
28 /** Type of FIB struct */
30 RTE_FIB6_DUMMY, /**< RIB6 tree based FIB */
31 RTE_FIB6_TRIE, /**< TRIE based fib */
35 /** Modify FIB function */
36 typedef int (*rte_fib6_modify_fn_t)(struct rte_fib6 *fib,
37 const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE], uint8_t depth,
38 uint64_t next_hop, int op);
39 /** FIB bulk lookup function */
40 typedef void (*rte_fib6_lookup_fn_t)(void *fib,
41 uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
42 uint64_t *next_hops, const unsigned int n);
49 enum rte_fib_trie_nh_sz {
55 /** FIB configuration structure */
56 struct rte_fib6_conf {
57 enum rte_fib6_type type; /**< Type of FIB struct */
58 /** Default value returned on lookup if there is no route */
63 enum rte_fib_trie_nh_sz nh_sz;
75 * NUMA socket ID for FIB table memory allocation
77 * Structure containing the configuration
79 * Handle to FIB object on success
80 * NULL otherwise with rte_errno set to an appropriate values.
84 rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf);
87 * Find an existing FIB object and return a pointer to it.
90 * Name of the fib object as passed to rte_fib6_create()
92 * Pointer to fib 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.
98 rte_fib6_find_existing(const char *name);
101 * Free an FIB object.
110 rte_fib6_free(struct rte_fib6 *fib);
113 * Add a route to the FIB.
118 * IPv6 prefix address to be added to the FIB
122 * Next hop to be added to the FIB
124 * 0 on success, negative value otherwise
128 rte_fib6_add(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
129 uint8_t depth, uint64_t next_hop);
132 * Delete a rule from the FIB.
137 * IPv6 prefix address to be deleted from the FIB
141 * 0 on success, negative value otherwise
145 rte_fib6_delete(struct rte_fib6 *fib,
146 const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE], uint8_t depth);
149 * Lookup multiple IP addresses in the FIB.
154 * Array of IPv6s to be looked up in the FIB
156 * Next hop of the most specific rule found for IP.
157 * This is an array of eight byte values.
158 * If the lookup for the given IP failed, then corresponding element would
159 * contain default nexthop value configured for a FIB.
161 * Number of elements in ips (and next_hops) array to lookup.
163 * -EINVAL for incorrect arguments, otherwise 0
167 rte_fib6_lookup_bulk(struct rte_fib6 *fib,
168 uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
169 uint64_t *next_hops, int n);
172 * Get pointer to the dataplane specific struct
177 * Pointer on the dataplane struct on success
182 rte_fib6_get_dp(struct rte_fib6 *fib);
185 * Get pointer to the RIB6
190 * Pointer on the RIB6 on success
195 rte_fib6_get_rib(struct rte_fib6 *fib);
201 #endif /* _RTE_FIB6_H_ */