1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2018 Vladimir Medvedkin <medvedkinv@gmail.com>
3 * Copyright(c) 2019 Intel Corporation
16 * All functions in this file may be changed or removed without prior notice.
18 * FIB (Forwarding information base) implementation
19 * for IPv4 Longest Prefix Match
22 #include <rte_compat.h>
31 /** Maximum depth value possible for IPv4 FIB. */
32 #define RTE_FIB_MAXDEPTH 32
34 /** Type of FIB struct */
36 RTE_FIB_DUMMY, /**< RIB tree based FIB */
37 RTE_FIB_DIR24_8, /**< DIR24_8 based FIB */
41 /** Modify FIB function */
42 typedef int (*rte_fib_modify_fn_t)(struct rte_fib *fib, uint32_t ip,
43 uint8_t depth, uint64_t next_hop, int op);
44 /** FIB bulk lookup function */
45 typedef void (*rte_fib_lookup_fn_t)(void *fib, const uint32_t *ips,
46 uint64_t *next_hops, const unsigned int n);
53 /** Size of nexthop (1 << nh_sz) bits for DIR24_8 based FIB */
54 enum rte_fib_dir24_8_nh_sz {
61 /** FIB configuration structure */
63 enum rte_fib_type type; /**< Type of FIB struct */
64 /** Default value returned on lookup if there is no route */
69 enum rte_fib_dir24_8_nh_sz nh_sz;
81 * NUMA socket ID for FIB table memory allocation
83 * Structure containing the configuration
85 * Handle to the FIB object on success
86 * NULL otherwise with rte_errno set to an appropriate values.
90 rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf);
93 * Find an existing FIB object and return a pointer to it.
96 * Name of the fib object as passed to rte_fib_create()
98 * Pointer to fib object or NULL if object not found with rte_errno
99 * set appropriately. Possible rte_errno values include:
100 * - ENOENT - required entry not available to return.
104 rte_fib_find_existing(const char *name);
107 * Free an FIB object.
116 rte_fib_free(struct rte_fib *fib);
119 * Add a route to the FIB.
124 * IPv4 prefix address to be added to the FIB
128 * Next hop to be added to the FIB
130 * 0 on success, negative value otherwise
134 rte_fib_add(struct rte_fib *fib, uint32_t ip, uint8_t depth, uint64_t next_hop);
137 * Delete a rule from the FIB.
142 * IPv4 prefix address to be deleted from the FIB
146 * 0 on success, negative value otherwise
150 rte_fib_delete(struct rte_fib *fib, uint32_t ip, uint8_t depth);
153 * Lookup multiple IP addresses in the FIB.
158 * Array of IPs to be looked up in the FIB
160 * Next hop of the most specific rule found for IP.
161 * This is an array of eight byte values.
162 * If the lookup for the given IP failed, then corresponding element would
163 * contain default nexthop value configured for a FIB.
165 * Number of elements in ips (and next_hops) array to lookup.
167 * -EINVAL for incorrect arguments, otherwise 0
171 rte_fib_lookup_bulk(struct rte_fib *fib, uint32_t *ips,
172 uint64_t *next_hops, int n);
174 * Get pointer to the dataplane specific struct
179 * Pointer on the dataplane struct on success
184 rte_fib_get_dp(struct rte_fib *fib);
187 * Get pointer to the RIB
192 * Pointer on the RIB on success
197 rte_fib_get_rib(struct rte_fib *fib);
203 #endif /* _RTE_FIB_H_ */