| 357 | #define TBL8_LEN (RTE_FIB6_IPV6_ADDR_SIZE - TBL24_BYTES) |
| 358 | |
| 359 | static int |
| 360 | install_to_dp(struct rte_trie_tbl *dp, const uint8_t *ledge, const uint8_t *r, |
| 361 | uint64_t next_hop) |
| 362 | { |
| 363 | void *common_root_tbl; |
| 364 | void *ent; |
| 365 | int ret; |
| 366 | int i; |
| 367 | int common_bytes; |
| 368 | int llen, rlen; |
| 369 | uint8_t redge[16]; |
| 370 | |
| 371 | /* decrement redge by 1*/ |
| 372 | rte_rib6_copy_addr(redge, r); |
| 373 | for (i = 15; i >= 0; i--) { |
| 374 | redge[i]--; |
| 375 | if (redge[i] != 0xff) |
| 376 | break; |
| 377 | } |
| 378 | |
| 379 | for (common_bytes = 0; common_bytes < 15; common_bytes++) { |
| 380 | if (ledge[common_bytes] != redge[common_bytes]) |
| 381 | break; |
| 382 | } |
| 383 | |
| 384 | ret = build_common_root(dp, ledge, common_bytes, &common_root_tbl); |
| 385 | if (unlikely(ret != 0)) |
| 386 | return ret; |
| 387 | /*first uncommon tbl8 byte idx*/ |
| 388 | uint8_t first_tbl8_byte = RTE_MAX(common_bytes, TBL24_BYTES); |
| 389 | |
| 390 | for (i = IPV6_MAX_IDX; i > first_tbl8_byte; i--) { |
| 391 | if (ledge[i] != 0) |
| 392 | break; |
| 393 | } |
| 394 | |
| 395 | llen = i - first_tbl8_byte + (common_bytes < 3); |
| 396 | |
| 397 | for (i = IPV6_MAX_IDX; i > first_tbl8_byte; i--) { |
| 398 | if (redge[i] != UINT8_MAX) |
| 399 | break; |
| 400 | } |
| 401 | rlen = i - first_tbl8_byte + (common_bytes < 3); |
| 402 | |
| 403 | /*first noncommon byte*/ |
| 404 | uint8_t first_byte_idx = (common_bytes < 3) ? 0 : common_bytes; |
| 405 | uint8_t first_idx_len = (common_bytes < 3) ? 3 : 1; |
| 406 | |
| 407 | uint32_t left_idx = get_idx(ledge, 0, first_idx_len, first_byte_idx); |
| 408 | uint32_t right_idx = get_idx(redge, 0, first_idx_len, first_byte_idx); |
| 409 | |
| 410 | ent = get_tbl_p_by_idx(common_root_tbl, left_idx, dp->nh_sz); |
| 411 | ret = write_edge(dp, &ledge[first_tbl8_byte + !(common_bytes < 3)], |
| 412 | next_hop, llen, LEDGE, ent); |
| 413 | if (ret < 0) |
| 414 | return ret; |
| 415 | |
| 416 | if (right_idx > left_idx + 1) { |
no test coverage detected