33 #ifndef _RTE_LPM_ALTIVEC_H_
34 #define _RTE_LPM_ALTIVEC_H_
49 vector
signed int i24;
52 uint64_t idx, pt, pt2;
55 const uint32_t mask = UINT8_MAX;
56 const vector
signed int mask8 = (xmm_t){mask, mask, mask, mask};
62 const uint64_t mask_xv =
63 ((uint64_t)RTE_LPM_VALID_EXT_ENTRY_BITMASK |
64 (uint64_t)RTE_LPM_VALID_EXT_ENTRY_BITMASK << 32);
70 const uint64_t mask_v =
75 i24 = vec_sr((xmm_t) ip,
76 (vector
unsigned int){CHAR_BIT, CHAR_BIT, CHAR_BIT, CHAR_BIT});
79 idx = (uint32_t)i24[0];
80 idx = idx < (1<<24) ? idx : (1<<24)-1;
81 ptbl = (
const uint32_t *)&lpm->tbl24[idx];
84 idx = (uint32_t) i24[1];
85 idx = idx < (1<<24) ? idx : (1<<24)-1;
86 ptbl = (
const uint32_t *)&lpm->tbl24[idx];
89 idx = (uint32_t) i24[2];
90 idx = idx < (1<<24) ? idx : (1<<24)-1;
91 ptbl = (
const uint32_t *)&lpm->tbl24[idx];
94 idx = (uint32_t) i24[3];
95 idx = idx < (1<<24) ? idx : (1<<24)-1;
96 ptbl = (
const uint32_t *)&lpm->tbl24[idx];
100 i8.x = vec_and(ip, mask8);
102 pt = (uint64_t)tbl[0] |
103 (uint64_t)tbl[1] << 32;
104 pt2 = (uint64_t)tbl[2] |
105 (uint64_t)tbl[3] << 32;
108 if (
likely((pt & mask_xv) == mask_v) &&
109 likely((pt2 & mask_xv) == mask_v)) {
110 *(uint64_t *)hop = pt & RTE_LPM_MASKX4_RES;
111 *(uint64_t *)(hop + 2) = pt2 & RTE_LPM_MASKX4_RES;
115 if (
unlikely((pt & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
116 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
117 i8.u32[0] = i8.u32[0] +
118 (uint8_t)tbl[0] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
119 ptbl = (
const uint32_t *)&lpm->tbl8[i8.u32[0]];
122 if (
unlikely((pt >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
123 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
124 i8.u32[1] = i8.u32[1] +
125 (uint8_t)tbl[1] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
126 ptbl = (
const uint32_t *)&lpm->tbl8[i8.u32[1]];
129 if (
unlikely((pt2 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
130 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
131 i8.u32[2] = i8.u32[2] +
132 (uint8_t)tbl[2] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
133 ptbl = (
const uint32_t *)&lpm->tbl8[i8.u32[2]];
136 if (
unlikely((pt2 >> 32 & RTE_LPM_VALID_EXT_ENTRY_BITMASK) ==
137 RTE_LPM_VALID_EXT_ENTRY_BITMASK)) {
138 i8.u32[3] = i8.u32[3] +
139 (uint8_t)tbl[3] * RTE_LPM_TBL8_GROUP_NUM_ENTRIES;
140 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