| 161 | } |
| 162 | |
| 163 | static inline uint32_t |
| 164 | get_rev_poly(uint32_t poly, int degree) |
| 165 | { |
| 166 | int i; |
| 167 | /* |
| 168 | * The implicit highest coefficient of the polynomial |
| 169 | * becomes the lowest after reversal. |
| 170 | */ |
| 171 | uint32_t rev_poly = 1; |
| 172 | uint32_t mask = (1 << degree) - 1; |
| 173 | |
| 174 | /* |
| 175 | * Here we assume "poly" argument is an irreducible polynomial, |
| 176 | * thus the lowest coefficient of the "poly" must always be equal to "1". |
| 177 | * After the reversal, this the lowest coefficient becomes the highest and |
| 178 | * it is omitted since the highest coefficient is implicitly determined by |
| 179 | * degree of the polynomial. |
| 180 | */ |
| 181 | for (i = 1; i < degree; i++) |
| 182 | rev_poly |= ((poly >> i) & 0x1) << (degree - i); |
| 183 | |
| 184 | return rev_poly & mask; |
| 185 | } |
| 186 | |
| 187 | static struct thash_lfsr * |
| 188 | alloc_lfsr(struct rte_thash_ctx *ctx) |