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>
17 #define RTE_FIB6_IPV6_ADDR_SIZE 16
18 /** Maximum depth value possible for IPv6 FIB. */
19 #define RTE_FIB6_MAXDEPTH 128
24 /** Type of FIB struct */
26 RTE_FIB6_DUMMY, /**< RIB6 tree based FIB */
27 RTE_FIB6_TRIE, /**< TRIE based fib */
31 /** Modify FIB function */
32 typedef int (*rte_fib6_modify_fn_t)(struct rte_fib6 *fib,
33 const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE], uint8_t depth,
34 uint64_t next_hop, int op);
35 /** FIB bulk lookup function */
36 typedef void (*rte_fib6_lookup_fn_t)(void *fib,
37 uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
38 uint64_t *next_hops, const unsigned int n);
45 enum rte_fib_trie_nh_sz {
51 /** FIB configuration structure */
52 struct rte_fib6_conf {
53 enum rte_fib6_type type; /**< Type of FIB struct */
54 /** Default value returned on lookup if there is no route */
59 enum rte_fib_trie_nh_sz nh_sz;
71 * NUMA socket ID for FIB table memory allocation
73 * Structure containing the configuration
75 * Handle to FIB object on success
76 * NULL otherwise with rte_errno set to an appropriate values.
80 rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf);
83 * Find an existing FIB object and return a pointer to it.
86 * Name of the fib object as passed to rte_fib6_create()
88 * Pointer to fib object or NULL if object not found with rte_errno
89 * set appropriately. Possible rte_errno values include:
90 * - ENOENT - required entry not available to return.
94 rte_fib6_find_existing(const char *name);
106 rte_fib6_free(struct rte_fib6 *fib);
109 * Add a route to the FIB.
114 * IPv6 prefix address to be added to the FIB
118 * Next hop to be added to the FIB
120 * 0 on success, negative value otherwise
124 rte_fib6_add(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
125 uint8_t depth, uint64_t next_hop);
128 * Delete a rule from the FIB.
133 * IPv6 prefix address to be deleted from the FIB
137 * 0 on success, negative value otherwise
141 rte_fib6_delete(struct rte_fib6 *fib,
142 const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE], uint8_t depth);
145 * Lookup multiple IP addresses in the FIB.
150 * Array of IPv6s to be looked up in the FIB
152 * Next hop of the most specific rule found for IP.
153 * This is an array of eight byte values.
154 * If the lookup for the given IP failed, then corresponding element would
155 * contain default nexthop value configured for a FIB.
157 * Number of elements in ips (and next_hops) array to lookup.
159 * -EINVAL for incorrect arguments, otherwise 0
163 rte_fib6_lookup_bulk(struct rte_fib6 *fib,
164 uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
165 uint64_t *next_hops, int n);
168 * Get pointer to the dataplane specific struct
173 * Pointer on the dataplane struct on success
178 rte_fib6_get_dp(struct rte_fib6 *fib);
181 * Get pointer to the RIB6
186 * Pointer on the RIB6 on success
191 rte_fib6_get_rib(struct rte_fib6 *fib);
193 #endif /* _RTE_FIB6_H_ */