Lines Matching refs:d
69 const struct l2t_data *d) in arp_hash() argument
71 return jhash_2words(key, ifindex, 0) & (d->nentries - 1); in arp_hash()
218 static struct l2t_entry *alloc_l2e(struct l2t_data *d) in alloc_l2e() argument
222 if (!atomic_read(&d->nfree)) in alloc_l2e()
226 for (e = d->rover, end = &d->l2tab[d->nentries]; e != end; ++e) in alloc_l2e()
230 for (e = &d->l2tab[1]; atomic_read(&e->refcnt); ++e) ; in alloc_l2e()
232 d->rover = e + 1; in alloc_l2e()
233 atomic_dec(&d->nfree); in alloc_l2e()
240 int hash = arp_hash(e->addr, e->ifindex, d); in alloc_l2e()
242 for (p = &d->l2tab[hash].first; *p; p = &(*p)->next) in alloc_l2e()
263 void t3_l2e_free(struct l2t_data *d, struct l2t_entry *e) in t3_l2e_free() argument
273 atomic_inc(&d->nfree); in t3_l2e_free()
307 struct l2t_data *d; in t3_l2t_get() local
326 d = L2DATA(cdev); in t3_l2t_get()
327 if (!d) in t3_l2t_get()
330 hash = arp_hash(addr, ifidx, d); in t3_l2t_get()
332 write_lock_bh(&d->lock); in t3_l2t_get()
333 for (e = d->l2tab[hash].first; e; e = e->next) in t3_l2t_get()
336 l2t_hold(d, e); in t3_l2t_get()
343 e = alloc_l2e(d); in t3_l2t_get()
346 e->next = d->l2tab[hash].first; in t3_l2t_get()
347 d->l2tab[hash].first = e; in t3_l2t_get()
361 write_unlock_bh(&d->lock); in t3_l2t_get()
402 struct l2t_data *d = L2DATA(dev); in t3_l2t_update() local
405 int hash = arp_hash(addr, ifidx, d); in t3_l2t_update()
407 read_lock_bh(&d->lock); in t3_l2t_update()
408 for (e = d->l2tab[hash].first; e; e = e->next) in t3_l2t_update()
413 read_unlock_bh(&d->lock); in t3_l2t_update()
419 read_unlock(&d->lock); in t3_l2t_update()
444 struct l2t_data *d; in t3_init_l2t() local
445 int i, size = sizeof(*d) + l2t_capacity * sizeof(struct l2t_entry); in t3_init_l2t()
447 d = cxgb_alloc_mem(size); in t3_init_l2t()
448 if (!d) in t3_init_l2t()
451 d->nentries = l2t_capacity; in t3_init_l2t()
452 d->rover = &d->l2tab[1]; /* entry 0 is not used */ in t3_init_l2t()
453 atomic_set(&d->nfree, l2t_capacity - 1); in t3_init_l2t()
454 rwlock_init(&d->lock); in t3_init_l2t()
457 d->l2tab[i].idx = i; in t3_init_l2t()
458 d->l2tab[i].state = L2T_STATE_UNUSED; in t3_init_l2t()
459 __skb_queue_head_init(&d->l2tab[i].arpq); in t3_init_l2t()
460 spin_lock_init(&d->l2tab[i].lock); in t3_init_l2t()
461 atomic_set(&d->l2tab[i].refcnt, 0); in t3_init_l2t()
463 return d; in t3_init_l2t()
466 void t3_free_l2t(struct l2t_data *d) in t3_free_l2t() argument
468 cxgb_free_mem(d); in t3_free_l2t()