Move the body of dir24_8_modify() into dir24_8_modify_dp(), taking the dataplane table and the RIB directly, and expose it in the internal header so that another dataplane can drive a DIR24_8 table.
Signed-off-by: Vladimir Medvedkin <[email protected]> --- lib/fib/dir24_8.c | 34 +++++++++++++++++++++------------- lib/fib/dir24_8.h | 4 ++++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/lib/fib/dir24_8.c b/lib/fib/dir24_8.c index 9b14693320..48be1c0617 100644 --- a/lib/fib/dir24_8.c +++ b/lib/fib/dir24_8.c @@ -465,26 +465,15 @@ modify_fib(struct dir24_8_tbl *dp, struct rte_rib *rib, uint32_t ip, } int -dir24_8_modify(struct rte_fib *fib, uint16_t vrf_id, uint32_t ip, uint8_t depth, - uint64_t next_hop, int op) +dir24_8_modify_dp(struct dir24_8_tbl *dp, struct rte_rib *rib, uint32_t ip, + uint8_t depth, uint64_t next_hop, int op) { - struct dir24_8_tbl *dp; - struct rte_rib *rib; struct rte_rib_node *tmp = NULL; struct rte_rib_node *node; struct rte_rib_node *parent; int ret = 0; uint64_t par_nh, node_nh; - RTE_SET_USED(vrf_id); - - if ((fib == NULL) || (depth > RTE_FIB_MAXDEPTH)) - return -EINVAL; - - dp = rte_fib_get_dp(fib); - rib = rte_fib_get_rib(fib); - RTE_ASSERT((dp != NULL) && (rib != NULL)); - if (next_hop > get_max_nh(dp->nh_sz)) return -EINVAL; @@ -557,6 +546,25 @@ dir24_8_modify(struct rte_fib *fib, uint16_t vrf_id, uint32_t ip, uint8_t depth, return -EINVAL; } +int +dir24_8_modify(struct rte_fib *fib, uint16_t vrf_id, uint32_t ip, uint8_t depth, + uint64_t next_hop, int op) +{ + struct dir24_8_tbl *dp; + struct rte_rib *rib; + + RTE_SET_USED(vrf_id); + + if ((fib == NULL) || (depth > RTE_FIB_MAXDEPTH)) + return -EINVAL; + + dp = rte_fib_get_dp(fib); + rib = rte_fib_get_rib(fib); + RTE_ASSERT((dp != NULL) && (rib != NULL)); + + return dir24_8_modify_dp(dp, rib, ip, depth, next_hop, op); +} + void * dir24_8_create(const char *name, int socket_id, struct rte_fib_conf *fib_conf) { diff --git a/lib/fib/dir24_8.h b/lib/fib/dir24_8.h index 88c47072d9..99e8be660e 100644 --- a/lib/fib/dir24_8.h +++ b/lib/fib/dir24_8.h @@ -308,6 +308,10 @@ int dir24_8_modify(struct rte_fib *fib, uint16_t vrf_id, uint32_t ip, uint8_t depth, uint64_t next_hop, int op); +int +dir24_8_modify_dp(struct dir24_8_tbl *dp, struct rte_rib *rib, uint32_t ip, + uint8_t depth, uint64_t next_hop, int op); + int dir24_8_rcu_qsbr_add(struct dir24_8_tbl *dp, struct rte_fib_rcu_config *cfg, const char *name); -- 2.43.0

