MCPcopy Create free account
hub / github.com/F-Stack/f-stack / write_edge

Function write_edge

dpdk/lib/fib/trie.c:316–353  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

314}
315
316static int
317write_edge(struct rte_trie_tbl *dp, const uint8_t *ip_part, uint64_t next_hop,
318 int len, enum edge edge, void *ent)
319{
320 uint64_t val = next_hop << 1;
321 int tbl8_idx;
322 int ret = 0;
323 void *p;
324
325 if (len != 0) {
326 val = get_val_by_p(ent, dp->nh_sz);
327 if ((val & TRIE_EXT_ENT) == TRIE_EXT_ENT)
328 tbl8_idx = val >> 1;
329 else {
330 tbl8_idx = tbl8_alloc(dp, val);
331 if (tbl8_idx < 0)
332 return tbl8_idx;
333 val = (tbl8_idx << 1)|TRIE_EXT_ENT;
334 }
335 p = get_tbl_p_by_idx(dp->tbl8, (tbl8_idx *
336 TRIE_TBL8_GRP_NUM_ENT) + *ip_part, dp->nh_sz);
337 ret = write_edge(dp, ip_part + 1, next_hop, len - 1, edge, p);
338 if (ret < 0)
339 return ret;
340 if (edge == LEDGE) {
341 write_to_dp((uint8_t *)p + (1 << dp->nh_sz),
342 next_hop << 1, dp->nh_sz, UINT8_MAX - *ip_part);
343 } else {
344 write_to_dp(get_tbl_p_by_idx(dp->tbl8, tbl8_idx *
345 TRIE_TBL8_GRP_NUM_ENT, dp->nh_sz),
346 next_hop << 1, dp->nh_sz, *ip_part);
347 }
348 tbl8_recycle(dp, &val, tbl8_idx);
349 }
350
351 write_to_dp(ent, val, dp->nh_sz, 1);
352 return ret;
353}
354
355#define IPV6_MAX_IDX (RTE_FIB6_IPV6_ADDR_SIZE - 1)
356#define TBL24_BYTES 3

Callers 1

install_to_dpFunction · 0.85

Calls 5

get_val_by_pFunction · 0.85
get_tbl_p_by_idxFunction · 0.85
write_to_dpFunction · 0.85
tbl8_allocFunction · 0.70
tbl8_recycleFunction · 0.70

Tested by

no test coverage detected