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
23 /** Type of FIB struct */
25 RTE_FIB6_DUMMY, /**< RIB6 tree based FIB */
29 /** Modify FIB function */
30 typedef int (*rte_fib6_modify_fn_t)(struct rte_fib6 *fib,
31 const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE], uint8_t depth,
32 uint64_t next_hop, int op);
33 /** FIB bulk lookup function */
34 typedef void (*rte_fib6_lookup_fn_t)(void *fib,
35 uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
36 uint64_t *next_hops, const unsigned int n);
43 /** FIB configuration structure */
44 struct rte_fib6_conf {
45 enum rte_fib6_type type; /**< Type of FIB struct */
46 /** Default value returned on lookup if there is no route */
57 * NUMA socket ID for FIB table memory allocation
59 * Structure containing the configuration
61 * Handle to FIB object on success
62 * NULL otherwise with rte_errno set to an appropriate values.
66 rte_fib6_create(const char *name, int socket_id, struct rte_fib6_conf *conf);
69 * Find an existing FIB object and return a pointer to it.
72 * Name of the fib object as passed to rte_fib6_create()
74 * Pointer to fib object or NULL if object not found with rte_errno
75 * set appropriately. Possible rte_errno values include:
76 * - ENOENT - required entry not available to return.
80 rte_fib6_find_existing(const char *name);
92 rte_fib6_free(struct rte_fib6 *fib);
95 * Add a route to the FIB.
100 * IPv6 prefix address to be added to the FIB
104 * Next hop to be added to the FIB
106 * 0 on success, negative value otherwise
110 rte_fib6_add(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
111 uint8_t depth, uint64_t next_hop);
114 * Delete a rule from the FIB.
119 * IPv6 prefix address to be deleted from the FIB
123 * 0 on success, negative value otherwise
127 rte_fib6_delete(struct rte_fib6 *fib,
128 const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE], uint8_t depth);
131 * Lookup multiple IP addresses in the FIB.
136 * Array of IPv6s to be looked up in the FIB
138 * Next hop of the most specific rule found for IP.
139 * This is an array of eight byte values.
140 * If the lookup for the given IP failed, then corresponding element would
141 * contain default nexthop value configured for a FIB.
143 * Number of elements in ips (and next_hops) array to lookup.
145 * -EINVAL for incorrect arguments, otherwise 0
149 rte_fib6_lookup_bulk(struct rte_fib6 *fib,
150 uint8_t ips[][RTE_FIB6_IPV6_ADDR_SIZE],
151 uint64_t *next_hops, int n);
154 * Get pointer to the dataplane specific struct
159 * Pointer on the dataplane struct on success
164 rte_fib6_get_dp(struct rte_fib6 *fib);
167 * Get pointer to the RIB6
172 * Pointer on the RIB6 on success
177 rte_fib6_get_rib(struct rte_fib6 *fib);
179 #endif /* _RTE_FIB6_H_ */