t4_l2t.c (de483253) | t4_l2t.c (3dde7c95) |
---|---|
1/* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at --- 125 unchanged lines hidden (view full) --- 134 struct l2t_entry l2tab[]; 135}; 136 137#define VLAN_NONE 0xfff 138#define SA(x) ((struct sockaddr *)(x)) 139#define SIN(x) ((struct sockaddr_in *)(x)) 140#define SINADDR(x) (SIN(x)->sin_addr.s_addr) 141#define atomic_read(x) atomic_add_int_nv(x, 0) | 1/* 2 * This file and its contents are supplied under the terms of the 3 * Common Development and Distribution License ("CDDL"), version 1.0. 4 * You may only use this file in accordance with the terms of version 5 * 1.0 of the CDDL. 6 * 7 * A full copy of the text of the CDDL should have accompanied this 8 * source. A copy of the CDDL is also available via the Internet at --- 125 unchanged lines hidden (view full) --- 134 struct l2t_entry l2tab[]; 135}; 136 137#define VLAN_NONE 0xfff 138#define SA(x) ((struct sockaddr *)(x)) 139#define SIN(x) ((struct sockaddr_in *)(x)) 140#define SINADDR(x) (SIN(x)->sin_addr.s_addr) 141#define atomic_read(x) atomic_add_int_nv(x, 0) |
142 143#ifdef TCP_OFFLOAD_ENABLE |
|
142/* 143 * Allocate a free L2T entry. 144 * Must be called with l2t_data.lockatomic_load_acq_int held. 145 */ 146static struct l2t_entry * 147alloc_l2e(struct l2t_data *d) 148{ 149 struct l2t_entry *end, *e, **p; --- 64 unchanged lines hidden (view full) --- 214 215 (void) t4_mgmt_tx(sc, m); 216 217 if (sync && e->state != L2T_STATE_SWITCHING) 218 e->state = L2T_STATE_SYNC_WRITE; 219 220 return (0); 221} | 144/* 145 * Allocate a free L2T entry. 146 * Must be called with l2t_data.lockatomic_load_acq_int held. 147 */ 148static struct l2t_entry * 149alloc_l2e(struct l2t_data *d) 150{ 151 struct l2t_entry *end, *e, **p; --- 64 unchanged lines hidden (view full) --- 216 217 (void) t4_mgmt_tx(sc, m); 218 219 if (sync && e->state != L2T_STATE_SWITCHING) 220 e->state = L2T_STATE_SYNC_WRITE; 221 222 return (0); 223} |
224#endif |
|
222 223struct l2t_data * 224t4_init_l2t(struct adapter *sc) 225{ 226 int i, l2t_size; 227 struct l2t_data *d; 228 229 l2t_size = sc->vres.l2t.size; --- 13 unchanged lines hidden (view full) --- 243 for (i = 0; i < l2t_size; i++) { 244 /* LINTED: E_ASSIGN_NARROW_CONV */ 245 d->l2tab[i].idx = i; 246 d->l2tab[i].state = L2T_STATE_UNUSED; 247 mutex_init(&d->l2tab[i].lock, NULL, MUTEX_DRIVER, NULL); 248 (void) atomic_swap_uint(&d->l2tab[i].refcnt, 0); 249 } 250 | 225 226struct l2t_data * 227t4_init_l2t(struct adapter *sc) 228{ 229 int i, l2t_size; 230 struct l2t_data *d; 231 232 l2t_size = sc->vres.l2t.size; --- 13 unchanged lines hidden (view full) --- 246 for (i = 0; i < l2t_size; i++) { 247 /* LINTED: E_ASSIGN_NARROW_CONV */ 248 d->l2tab[i].idx = i; 249 d->l2tab[i].state = L2T_STATE_UNUSED; 250 mutex_init(&d->l2tab[i].lock, NULL, MUTEX_DRIVER, NULL); 251 (void) atomic_swap_uint(&d->l2tab[i].refcnt, 0); 252 } 253 |
254#ifdef TCP_OFFLOAD_ENABLE |
|
251 (void) t4_register_cpl_handler(sc, CPL_L2T_WRITE_RPL, do_l2t_write_rpl); | 255 (void) t4_register_cpl_handler(sc, CPL_L2T_WRITE_RPL, do_l2t_write_rpl); |
256#endif |
|
252 253 return (d); 254} 255 256int 257t4_free_l2t(struct l2t_data *d) 258{ 259 int i; 260 261 for (i = 0; i < L2T_SIZE; i++) 262 mutex_destroy(&d->l2tab[i].lock); 263 rw_destroy(&d->lock); 264 kmem_free(d, sizeof (*d)); 265 266 return (0); 267} 268 | 257 258 return (d); 259} 260 261int 262t4_free_l2t(struct l2t_data *d) 263{ 264 int i; 265 266 for (i = 0; i < L2T_SIZE; i++) 267 mutex_destroy(&d->l2tab[i].lock); 268 rw_destroy(&d->lock); 269 kmem_free(d, sizeof (*d)); 270 271 return (0); 272} 273 |
269#ifndef TCP_OFFLOAD_DISABLE | 274#ifdef TCP_OFFLOAD_ENABLE |
270static inline void 271l2t_hold(struct l2t_data *d, struct l2t_entry *e) 272{ 273 if (atomic_inc_uint_nv(&e->refcnt) == 1) /* 0 -> 1 transition */ 274 atomic_dec_uint(&d->nfree); 275} 276 277/* --- 271 unchanged lines hidden --- | 275static inline void 276l2t_hold(struct l2t_data *d, struct l2t_entry *e) 277{ 278 if (atomic_inc_uint_nv(&e->refcnt) == 1) /* 0 -> 1 transition */ 279 atomic_dec_uint(&d->nfree); 280} 281 282/* --- 271 unchanged lines hidden --- |