fib->dp = trie_create(dp_name, socket_id, conf);
if (fib->dp == NULL)
return -rte_errno;
- fib->lookup = rte_trie_get_lookup_fn(conf);
+ fib->lookup = trie_get_lookup_fn(fib->dp, RTE_FIB6_LOOKUP_TRIE_SCALAR);
fib->modify = trie_modify;
return 0;
default:
{
return (fib == NULL) ? NULL : fib->rib;
}
+
+int
+rte_fib6_select_lookup(struct rte_fib6 *fib,
+ enum rte_fib6_lookup_type type)
+{
+ rte_fib6_lookup_fn_t fn;
+
+ switch (fib->type) {
+ case RTE_FIB6_TRIE:
+ fn = trie_get_lookup_fn(fib->dp, type);
+ if (fn == NULL)
+ return -EINVAL;
+ fib->lookup = fn;
+ return 0;
+ default:
+ return -EINVAL;
+ }
+}
RTE_FIB6_DEL,
};
+/** Size of nexthop (1 << nh_sz) bits for TRIE based FIB */
enum rte_fib_trie_nh_sz {
RTE_FIB6_TRIE_2B = 1,
RTE_FIB6_TRIE_4B,
RTE_FIB6_TRIE_8B
};
+/** Type of lookup function implementation */
+enum rte_fib6_lookup_type {
+ RTE_FIB6_LOOKUP_TRIE_SCALAR /**< Scalar lookup function implementation*/
+};
+
/** FIB configuration structure */
struct rte_fib6_conf {
enum rte_fib6_type type; /**< Type of FIB struct */
struct rte_rib6 *
rte_fib6_get_rib(struct rte_fib6 *fib);
+/**
+ * Set lookup function based on type
+ *
+ * @param fib
+ * FIB object handle
+ * @param type
+ * type of lookup function
+ *
+ * @return
+ * 0 on success
+ * -EINVAL on failure
+ */
+__rte_experimental
+int
+rte_fib6_select_lookup(struct rte_fib6 *fib, enum rte_fib6_lookup_type type);
+
#ifdef __cplusplus
}
#endif
REDGE
};
-enum lookup_type {
- MACRO,
- INLINE,
- UNI
-};
-static enum lookup_type test_lookup = MACRO;
-
static inline uint32_t
get_tbl24_idx(const uint8_t *ip)
{
LOOKUP_FUNC(4b, uint32_t, 2)
LOOKUP_FUNC(8b, uint64_t, 3)
-rte_fib6_lookup_fn_t
-rte_trie_get_lookup_fn(struct rte_fib6_conf *conf)
+static inline rte_fib6_lookup_fn_t
+get_scalar_fn(enum rte_fib_trie_nh_sz nh_sz)
{
- enum rte_fib_trie_nh_sz nh_sz = conf->trie.nh_sz;
-
- if (test_lookup == MACRO) {
- switch (nh_sz) {
- case RTE_FIB6_TRIE_2B:
- return rte_trie_lookup_bulk_2b;
- case RTE_FIB6_TRIE_4B:
- return rte_trie_lookup_bulk_4b;
- case RTE_FIB6_TRIE_8B:
- return rte_trie_lookup_bulk_8b;
- }
+ switch (nh_sz) {
+ case RTE_FIB6_TRIE_2B:
+ return rte_trie_lookup_bulk_2b;
+ case RTE_FIB6_TRIE_4B:
+ return rte_trie_lookup_bulk_4b;
+ case RTE_FIB6_TRIE_8B:
+ return rte_trie_lookup_bulk_8b;
+ default:
+ return NULL;
}
+}
+
+rte_fib6_lookup_fn_t
+trie_get_lookup_fn(void *p, enum rte_fib6_lookup_type type)
+{
+ enum rte_fib_trie_nh_sz nh_sz;
+ struct rte_trie_tbl *dp = p;
+
+ if (dp == NULL)
+ return NULL;
+
+ nh_sz = dp->nh_sz;
+ switch (type) {
+ case RTE_FIB6_LOOKUP_TRIE_SCALAR:
+ return get_scalar_fn(nh_sz);
+ default:
+ return NULL;
+ }
return NULL;
}
trie_free(void *p);
rte_fib6_lookup_fn_t
-rte_trie_get_lookup_fn(struct rte_fib6_conf *fib_conf);
+trie_get_lookup_fn(void *p, enum rte_fib6_lookup_type type);
int
trie_modify(struct rte_fib6 *fib, const uint8_t ip[RTE_FIB6_IPV6_ADDR_SIZE],
rte_fib6_lookup_bulk;
rte_fib6_get_dp;
rte_fib6_get_rib;
+ rte_fib6_select_lookup;
local: *;
};