6#ifndef _RTE_LPM_ALTIVEC_H_
7#define _RTE_LPM_ALTIVEC_H_
25 uint64_t idx, pt, pt2;
28 const uint32_t mask = UINT8_MAX;
29 const xmm_t mask8 = (xmm_t){mask, mask, mask, mask};
35 const uint64_t mask_xv =
36 ((uint64_t)RTE_LPM_VALID_EXT_ENTRY_BITMASK |
37 (uint64_t)RTE_LPM_VALID_EXT_ENTRY_BITMASK << 32);
43 const uint64_t mask_v =
48 i24 = vec_sr((xmm_t) ip,
49 (__vector
unsigned int){CHAR_BIT, CHAR_BIT, CHAR_BIT, CHAR_BIT});
52 idx = (uint32_t)i24[0];
53 idx = idx < (1<<24) ? idx : (1<<24)-1;
54 ptbl = (
const uint32_t *)&lpm->tbl24[idx];
57 idx = (uint32_t) i24[1];
58 idx = idx < (1<<24) ? idx : (1<<24)-1;
59 ptbl = (
const uint32_t *)&lpm->tbl24[idx];
62 idx = (uint32_t) i24[2];
63 idx = idx < (1<<24) ? idx : (1<<24)-1;
64 ptbl = (
const uint32_t *)&lpm->tbl24[idx];
67 idx = (uint32_t) i24[3];
68 idx = idx < (1<<24) ? idx : (1<<24)-1;
69 ptbl = (
const uint32_t *)&lpm->tbl24[idx];
73 i8.x = vec_and(ip, mask8);
75 pt = (uint64_t)tbl[0] |
76 (uint64_t)tbl[1] << 32;
77 pt2 = (uint64_t)tbl[2] |
78 (uint64_t)tbl[3] << 32;
81 if (
likely((pt & mask_xv) == mask_v) &&
82 likely((pt2 & mask_xv) == mask_v)) {
83 *(uint64_t *)hop = pt & RTE_LPM_MASKX4_RES;
84 *(uint64_t *)(hop + 2) = pt2 & RTE_LPM_MASKX4_RES;
88 if (
unlikely((pt & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
89 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
90 i8.u32[0] = i8.u32[0] +
91 (tbl[0] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
92 ptbl = (
const uint32_t *)&lpm->tbl8[i8.u32[0]];
95 if (
unlikely((pt >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
96 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
97 i8.u32[1] = i8.u32[1] +
98 (tbl[1] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
99 ptbl = (
const uint32_t *)&lpm->tbl8[i8.u32[1]];
102 if (
unlikely((pt2 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
103 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
104 i8.u32[2] = i8.u32[2] +
105 (tbl[2] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
106 ptbl = (
const uint32_t *)&lpm->tbl8[i8.u32[2]];
109 if (
unlikely((pt2 >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
110 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
111 i8.u32[3] = i8.u32[3] +
112 (tbl[3] & 0x00FFFFFF) * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
113 ptbl = (
const uint32_t *)&lpm->tbl8[i8.u32[3]];
static void rte_lpm_lookupx4(const struct rte_lpm *lpm, xmm_t ip, uint32_t hop[4], uint32_t defv)
#define RTE_LPM_LOOKUP_SUCCESS