257 new_ports = kmem_zalloc(new_size * sizeof (aggr_port_t *),
258 KM_SLEEP);
259
260 if (grp->lg_tx_ports_size > 0) {
261 ASSERT(grp->lg_tx_ports != NULL);
262 bcopy(grp->lg_tx_ports, new_ports,
263 grp->lg_ntx_ports * sizeof (aggr_port_t *));
264 kmem_free(grp->lg_tx_ports,
265 grp->lg_tx_ports_size * sizeof (aggr_port_t *));
266 }
267
268 grp->lg_tx_ports = new_ports;
269 grp->lg_tx_ports_size = new_size;
270 }
271
272 grp->lg_tx_ports[grp->lg_ntx_ports++] = port;
273 port->lp_tx_idx = grp->lg_ntx_ports-1;
274 rw_exit(&grp->lg_tx_lock);
275
276 port->lp_tx_enabled = B_TRUE;
277 }
278
279 /*
280 * Disable sending from the specified port.
281 */
282 void
283 aggr_send_port_disable(aggr_port_t *port)
284 {
285 uint_t idx, ntx;
286 aggr_grp_t *grp = port->lp_grp;
287
288 ASSERT(MAC_PERIM_HELD(grp->lg_mh));
289 ASSERT(MAC_PERIM_HELD(port->lp_mh));
290
291 if (!port->lp_tx_enabled) {
292 /* not yet enabled */
293 return;
294 }
295
296 rw_enter(&grp->lg_tx_lock, RW_WRITER);
299 ASSERT(idx < ntx);
300
301 /* remove from array of attached ports */
302 if (idx == (ntx - 1)) {
303 grp->lg_tx_ports[idx] = NULL;
304 } else {
305 /* not the last entry, replace with last one */
306 aggr_port_t *victim;
307
308 victim = grp->lg_tx_ports[ntx - 1];
309 grp->lg_tx_ports[ntx - 1] = NULL;
310 victim->lp_tx_idx = idx;
311 grp->lg_tx_ports[idx] = victim;
312 }
313
314 port->lp_tx_idx = 0;
315 grp->lg_ntx_ports--;
316 rw_exit(&grp->lg_tx_lock);
317
318 port->lp_tx_enabled = B_FALSE;
319 }
|
257 new_ports = kmem_zalloc(new_size * sizeof (aggr_port_t *),
258 KM_SLEEP);
259
260 if (grp->lg_tx_ports_size > 0) {
261 ASSERT(grp->lg_tx_ports != NULL);
262 bcopy(grp->lg_tx_ports, new_ports,
263 grp->lg_ntx_ports * sizeof (aggr_port_t *));
264 kmem_free(grp->lg_tx_ports,
265 grp->lg_tx_ports_size * sizeof (aggr_port_t *));
266 }
267
268 grp->lg_tx_ports = new_ports;
269 grp->lg_tx_ports_size = new_size;
270 }
271
272 grp->lg_tx_ports[grp->lg_ntx_ports++] = port;
273 port->lp_tx_idx = grp->lg_ntx_ports-1;
274 rw_exit(&grp->lg_tx_lock);
275
276 port->lp_tx_enabled = B_TRUE;
277
278 aggr_grp_update_default(grp);
279 }
280
281 /*
282 * Disable sending from the specified port.
283 */
284 void
285 aggr_send_port_disable(aggr_port_t *port)
286 {
287 uint_t idx, ntx;
288 aggr_grp_t *grp = port->lp_grp;
289
290 ASSERT(MAC_PERIM_HELD(grp->lg_mh));
291 ASSERT(MAC_PERIM_HELD(port->lp_mh));
292
293 if (!port->lp_tx_enabled) {
294 /* not yet enabled */
295 return;
296 }
297
298 rw_enter(&grp->lg_tx_lock, RW_WRITER);
301 ASSERT(idx < ntx);
302
303 /* remove from array of attached ports */
304 if (idx == (ntx - 1)) {
305 grp->lg_tx_ports[idx] = NULL;
306 } else {
307 /* not the last entry, replace with last one */
308 aggr_port_t *victim;
309
310 victim = grp->lg_tx_ports[ntx - 1];
311 grp->lg_tx_ports[ntx - 1] = NULL;
312 victim->lp_tx_idx = idx;
313 grp->lg_tx_ports[idx] = victim;
314 }
315
316 port->lp_tx_idx = 0;
317 grp->lg_ntx_ports--;
318 rw_exit(&grp->lg_tx_lock);
319
320 port->lp_tx_enabled = B_FALSE;
321
322 aggr_grp_update_default(grp);
323 }
|