Lines Matching refs:d
72 static inline void l2t_hold(struct l2t_data *d, struct l2t_entry *e) in l2t_hold() argument
75 atomic_dec(&d->nfree); in l2t_hold()
88 static inline unsigned int arp_hash(struct l2t_data *d, const u32 *key, in arp_hash() argument
91 unsigned int l2t_size_half = d->l2t_size / 2; in arp_hash()
96 static inline unsigned int ipv6_hash(struct l2t_data *d, const u32 *key, in ipv6_hash() argument
99 unsigned int l2t_size_half = d->l2t_size / 2; in ipv6_hash()
106 static unsigned int addr_hash(struct l2t_data *d, const u32 *addr, in addr_hash() argument
109 return addr_len == 4 ? arp_hash(d, addr, ifindex) : in addr_hash()
110 ipv6_hash(d, addr, ifindex); in addr_hash()
142 struct l2t_data *d = adap->l2t; in write_l2e() local
143 unsigned int l2t_idx = e->idx + d->l2t_start; in write_l2e()
195 struct l2t_data *d = adap->l2t; in do_l2t_write_rpl() local
207 struct l2t_entry *e = &d->l2tab[l2t_idx - d->l2t_start]; in do_l2t_write_rpl()
274 static struct l2t_entry *alloc_l2e(struct l2t_data *d) in alloc_l2e() argument
278 if (!atomic_read(&d->nfree)) in alloc_l2e()
282 for (e = d->rover, end = &d->l2tab[d->l2t_size]; e != end; ++e) in alloc_l2e()
286 for (e = d->l2tab; atomic_read(&e->refcnt); ++e) in alloc_l2e()
289 d->rover = e + 1; in alloc_l2e()
290 atomic_dec(&d->nfree); in alloc_l2e()
297 for (p = &d->l2tab[e->hash].first; *p; p = &(*p)->next) in alloc_l2e()
313 struct l2t_data *d; in t4_l2e_free() local
331 d = container_of(e, struct l2t_data, l2tab[e->idx]); in t4_l2e_free()
332 atomic_inc(&d->nfree); in t4_l2e_free()
364 struct l2t_entry *cxgb4_l2t_get(struct l2t_data *d, struct neighbour *neigh, in cxgb4_l2t_get() argument
374 int hash = addr_hash(d, addr, addr_len, ifidx); in cxgb4_l2t_get()
386 write_lock_bh(&d->lock); in cxgb4_l2t_get()
387 for (e = d->l2tab[hash].first; e; e = e->next) in cxgb4_l2t_get()
390 l2t_hold(d, e); in cxgb4_l2t_get()
397 e = alloc_l2e(d); in cxgb4_l2t_get()
411 e->next = d->l2tab[hash].first; in cxgb4_l2t_get()
412 d->l2tab[hash].first = e; in cxgb4_l2t_get()
416 write_unlock_bh(&d->lock); in cxgb4_l2t_get()
483 struct l2t_data *d = adap->l2t; in t4_l2t_update() local
487 int hash = addr_hash(d, addr, addr_len, ifidx); in t4_l2t_update()
489 read_lock_bh(&d->lock); in t4_l2t_update()
490 for (e = d->l2tab[hash].first; e; e = e->next) in t4_l2t_update()
498 read_unlock_bh(&d->lock); in t4_l2t_update()
502 read_unlock(&d->lock); in t4_l2t_update()
532 struct l2t_entry *t4_l2t_alloc_switching(struct l2t_data *d) in t4_l2t_alloc_switching() argument
536 write_lock_bh(&d->lock); in t4_l2t_alloc_switching()
537 e = alloc_l2e(d); in t4_l2t_alloc_switching()
544 write_unlock_bh(&d->lock); in t4_l2t_alloc_switching()
564 struct l2t_data *d; in t4_init_l2t() local
572 d = t4_alloc_mem(sizeof(*d) + l2t_size * sizeof(struct l2t_entry)); in t4_init_l2t()
573 if (!d) in t4_init_l2t()
576 d->l2t_start = l2t_start; in t4_init_l2t()
577 d->l2t_size = l2t_size; in t4_init_l2t()
579 d->rover = d->l2tab; in t4_init_l2t()
580 atomic_set(&d->nfree, l2t_size); in t4_init_l2t()
581 rwlock_init(&d->lock); in t4_init_l2t()
583 for (i = 0; i < d->l2t_size; ++i) { in t4_init_l2t()
584 d->l2tab[i].idx = i; in t4_init_l2t()
585 d->l2tab[i].state = L2T_STATE_UNUSED; in t4_init_l2t()
586 spin_lock_init(&d->l2tab[i].lock); in t4_init_l2t()
587 atomic_set(&d->l2tab[i].refcnt, 0); in t4_init_l2t()
589 return d; in t4_init_l2t()
594 struct l2t_data *d = seq->private; in l2t_get_idx() local
596 return pos >= d->l2t_size ? NULL : &d->l2tab[pos]; in l2t_get_idx()
636 struct l2t_data *d = seq->private; in l2t_seq_show() local
645 e->idx + d->l2t_start, ip, e->dmac, in l2t_seq_show()