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 IPv4 Longest Prefix Match
15 #include <rte_compat.h>
19 /** Maximum depth value possible for IPv4 FIB. */
20 #define RTE_FIB_MAXDEPTH 32
22 /** Type of FIB struct */
24 RTE_FIB_DUMMY, /**< RIB tree based FIB */
28 /** Modify FIB function */
29 typedef int (*rte_fib_modify_fn_t)(struct rte_fib *fib, uint32_t ip,
30 uint8_t depth, uint64_t next_hop, int op);
31 /** FIB bulk lookup function */
32 typedef void (*rte_fib_lookup_fn_t)(void *fib, const uint32_t *ips,
33 uint64_t *next_hops, const unsigned int n);
40 /** FIB configuration structure */
42 enum rte_fib_type type; /**< Type of FIB struct */
43 /** Default value returned on lookup if there is no route */
54 * NUMA socket ID for FIB table memory allocation
56 * Structure containing the configuration
58 * Handle to the FIB object on success
59 * NULL otherwise with rte_errno set to an appropriate values.
63 rte_fib_create(const char *name, int socket_id, struct rte_fib_conf *conf);
66 * Find an existing FIB object and return a pointer to it.
69 * Name of the fib object as passed to rte_fib_create()
71 * Pointer to fib object or NULL if object not found with rte_errno
72 * set appropriately. Possible rte_errno values include:
73 * - ENOENT - required entry not available to return.
77 rte_fib_find_existing(const char *name);
89 rte_fib_free(struct rte_fib *fib);
92 * Add a route to the FIB.
97 * IPv4 prefix address to be added to the FIB
101 * Next hop to be added to the FIB
103 * 0 on success, negative value otherwise
107 rte_fib_add(struct rte_fib *fib, uint32_t ip, uint8_t depth, uint64_t next_hop);
110 * Delete a rule from the FIB.
115 * IPv4 prefix address to be deleted from the FIB
119 * 0 on success, negative value otherwise
123 rte_fib_delete(struct rte_fib *fib, uint32_t ip, uint8_t depth);
126 * Lookup multiple IP addresses in the FIB.
131 * Array of IPs to be looked up in the FIB
133 * Next hop of the most specific rule found for IP.
134 * This is an array of eight byte values.
135 * If the lookup for the given IP failed, then corresponding element would
136 * contain default nexthop value configured for a FIB.
138 * Number of elements in ips (and next_hops) array to lookup.
140 * -EINVAL for incorrect arguments, otherwise 0
144 rte_fib_lookup_bulk(struct rte_fib *fib, uint32_t *ips,
145 uint64_t *next_hops, int n);
148 * Get pointer to the dataplane specific struct
153 * Pointer on the dataplane struct on success
158 rte_fib_get_dp(struct rte_fib *fib);
161 * Get pointer to the RIB
166 * Pointer on the RIB on success
171 rte_fib_get_rib(struct rte_fib *fib);
173 #endif /* _RTE_FIB_H_ */