Lines Matching defs:fat

166 /*!\brief allocate a fat pointer from a collection.
169 fatp_alloc(fatp_ctl_t *fat)
173 if (fat->nfree) {
174 fp = fat->free;
176 fat->free = fatp_next(fat, fp);
177 --fat->nfree;
178 ++fat->nalloc;
188 /*!\brief free a fat pointer.
191 fatp_free(fatp_ctl_t *fat, fatp_t *fp)
197 fp->nxt = fatp_index(fat, fat->free);
198 fat->free = fp;
200 ++fat->nfree;
201 --fat->nalloc;
205 /*!\brief initialise a collection of fat pointers.
208 *\param m total # fat pointers to allocate
213 fatp_init(fatp_ctl_t *fat, uint32_t n, uint32_t m,
220 fat->hash = fat_hash;
221 fat->base = fat_base;
223 fat->port = &fat->hash[m];
225 fat->mask = m - 1; // ASSERT is power of 2 (m)
226 fat->lim = fat->base + 2*n - 1;
227 fat->nfree = 0;
228 fat->nalloc = 2*n;
232 for (fp = fat->lim; fp >= fat->base; --fp) {
233 fatp_free(fat, fp);
257 fatp_key(fatp_ctl_t *fat, fatp_t *fp, uint32_t slot)
266 return (fatp_index(fat, fp) << 3) | slot;
268 return (fatp_index(fat, fp) << 4) | slot;
270 return (fatp_index(fat, fp) << 5) | slot;
278 fatp_slot_from_key(fatp_ctl_t *fat, uint32_t key)
299 fatp_from_key(fatp_ctl_t *fat, uint32_t key)
321 return key ? fat->base + key - 1 : 0;
355 fatp_vtw_inshash(fatp_ctl_t *fat, uint32_t idx, uint32_t tag, int which,
359 fatp_t **hash = (which ? fat->port : fat->hash);
362 fp = hash[tag & fat->mask];
375 fq = fatp_alloc(fat);
377 vtw_age(fat->vtw, 0);
378 fp = hash[tag & fat->mask];
383 fq->nxt = fatp_index(fat, fp);
385 hash[tag & fat->mask] = fq;
401 fp->tag[i] = tag ^ idx_encode(fat->vtw, idx) ^ fatp_xtra[i];
404 , (fp, "fat: inuse %5.5x tag[%x] %8.8x"
408 return fatp_key(fat, fp, i);
516 fatp_ctl_t *fat = ctl->fat;
528 if (fat->vtw->is_v4) {
530 } else if (fat->vtw->is_v6) {
537 /* Remove from fat->hash[]
539 slot = fatp_slot_from_key(fat, key);
540 fp = fatp_from_key(fat, key);
544 , (fp, "fat: del inuse %5.5x slot %x idx %x key %x tag %x"
563 uint32_t hi = tag & fat->mask;
565 fatp_t *fr = fat->hash[hi];
568 fr = fatp_next(fat, fq = fr);
575 fatp_free(fat, fp);
577 KASSERT(fat->hash[hi] == fp);
580 fat->hash[hi]
581 = fatp_next(fat, fp);
583 fatp_free(fat, fp);
591 fr = fat->hash[hi];
596 , "fat:*del inuse %5.5x"
600 fr = fatp_next(fat, fq = fr);
609 if (fat->vtw->is_v4) {
611 } else if (fat->vtw->is_v6) {
615 /* Remove from fat->port[]
618 slot = fatp_slot_from_key(fat, key);
619 fp = fatp_from_key(fat, key);
638 uint32_t hi = tag & fat->mask;
640 fatp_t *fr = fat->port[hi];
643 fr = fatp_next(fat, fq = fr);
650 fatp_free(fat, fp);
652 KASSERT(fat->port[hi] == fp);
655 fat->port[hi]
656 = fatp_next(fat, fp);
658 fatp_free(fat, fp);
720 vtw->key = fatp_vtw_inshash(ctl->fat, idx, tag, 0, vtw);
731 vtw->port_key = fatp_vtw_inshash(ctl->fat, idx, tag, 1, vtw);
759 vtw->key = fatp_vtw_inshash(ctl->fat, idx, tag, 0, vtw);
762 vtw->port_key = fatp_vtw_inshash(ctl->fat, idx, tag, 1, vtw);
784 if (!ctl || !ctl->fat)
791 fp = ctl->fat->port[tag & ctl->fat->mask];
794 fp = ctl->fat->hash[tag & ctl->fat->mask];
835 == fatp_key(ctl->fat, fp, i))
862 , fatp_key(ctl->fat, fp, i)
874 if (vtw->key == fatp_key(ctl->fat, fp, i)) {
891 , fatp_key(ctl->fat, fp, i)
907 fp = fatp_next(ctl->fat, fp);
939 if (!ctl || !ctl->fat)
944 fp = ctl->fat->port[tag & ctl->fat->mask];
947 fp = ctl->fat->hash[tag & ctl->fat->mask];
986 == fatp_key(ctl->fat, fp, i))
1004 fp = fatp_next(ctl->fat, fp);
1038 it->fp = ctl->fat->port[tag & ctl->fat->mask];
1074 && vtw->port_key == fatp_key(ctl->fat, fp, i)
1115 it->fp = fp = fatp_next(ctl->fat, fp);
1152 it->fp = ctl->fat->port[tag & ctl->fat->mask];
1194 && vtw->port_key == fatp_key(ctl->fat, fp, i)
1243 it->fp = fp = fatp_next(ctl->fat, fp);
1280 vtw_init(fatp_ctl_t *fat, vtw_ctl_t *ctl, const uint32_t n, vtw_t *ctl_base_v)
1308 ctl->fat = fat;
1309 fat->vtw = ctl;
1584 * need to get to the fat, and there is one
1585 * shared fat.
1587 if (vtw_tcpv4[0].fat) {
1683 * need to get to the fat, and there is one
1684 * shared fat.
1686 if (vtw_tcpv6[0].fat) {
1783 fatp_ctl_t *fat;
1788 fat = &fat_tcpv4;
1792 fat = &fat_tcpv6;
1799 *fatp = fat;
1810 fatp_ctl_t *fat;
1820 if (!vtw_select(af, &fat, &ctl))
1823 if (fat->hash != NULL) {
1824 KASSERT(fat->base != NULL && ctl->base.v != NULL);
1828 /* Allocate 10% more capacity in the fat pointers.
1831 * sparse fat pointer utilisation.
1840 fatp_init(fat, n, m, fat_base, fat_hash);
1841 vtw_init(fat, ctl, tcp_vtw_entries, ctl_base_v);
1851 fatp_ctl_t *fat;
1855 if (!vtw_select(af, &fat, &ctl))
1858 if (!fat->base || !ctl->base.v)