| 340 | #define HASH(n, m) ((((n) >> 8) ^ ((n) >> 4) ^ (n)) & (m)) |
| 341 | |
| 342 | static void |
| 343 | vlan_inithash(struct ifvlantrunk *trunk) |
| 344 | { |
| 345 | int i, n; |
| 346 | |
| 347 | /* |
| 348 | * The trunk must not be locked here since we call malloc(M_WAITOK). |
| 349 | * It is OK in case this function is called before the trunk struct |
| 350 | * gets hooked up and becomes visible from other threads. |
| 351 | */ |
| 352 | |
| 353 | KASSERT(trunk->hwidth == 0 && trunk->hash == NULL, |
| 354 | ("%s: hash already initialized", __func__)); |
| 355 | |
| 356 | trunk->hwidth = VLAN_DEF_HWIDTH; |
| 357 | n = 1 << trunk->hwidth; |
| 358 | trunk->hmask = n - 1; |
| 359 | trunk->hash = malloc(sizeof(struct ifvlanhead) * n, M_VLAN, M_WAITOK); |
| 360 | for (i = 0; i < n; i++) |
| 361 | CK_SLIST_INIT(&trunk->hash[i]); |
| 362 | } |
| 363 | |
| 364 | static void |
| 365 | vlan_freehash(struct ifvlantrunk *trunk) |