Lines Matching refs:port

70 	aggr_port_t *port = buf;
72 ASSERT(port->lp_mnh == NULL);
73 ASSERT(port->lp_mphp == NULL);
74 ASSERT(!port->lp_rx_grp_added && !port->lp_tx_grp_added);
75 ASSERT(port->lp_hwgh == NULL);
86 * Allocate a id space to manage port identification. The range of
108 aggr_port_init_callbacks(aggr_port_t *port)
110 /* add the port's receive callback */
111 port->lp_mnh = mac_notify_add(port->lp_mh, aggr_port_notify_cb, port);
113 * Hold a reference of the grp and the port and this reference will
116 * The reference on the port is used for aggr_port_delete() to
123 * the aggr_port_notify_cb() callback when the port is deleted
126 aggr_grp_port_hold(port);
137 aggr_port_t *port;
214 port = kmem_cache_alloc(aggr_port_cache, KM_SLEEP);
216 port->lp_refs = 1;
217 port->lp_next = NULL;
218 port->lp_mh = mh;
219 port->lp_mch = mch;
220 port->lp_mip = mip;
221 port->lp_linkid = linkid;
222 port->lp_closing = B_FALSE;
223 port->lp_mah = mah;
225 /* get the port's original MAC address */
226 mac_unicast_primary_get(port->lp_mh, port->lp_addr);
229 port->lp_state = AGGR_PORT_STATE_STANDBY;
230 port->lp_link_state = LINK_STATE_UNKNOWN;
231 port->lp_ifspeed = 0;
232 port->lp_link_duplex = LINK_DUPLEX_UNKNOWN;
233 port->lp_started = B_FALSE;
234 port->lp_tx_enabled = B_FALSE;
235 port->lp_promisc_on = B_FALSE;
236 port->lp_no_link_update = no_link_update;
237 port->lp_portid = portid;
238 port->lp_margin = margin;
239 port->lp_prom_addr = NULL;
242 * Save the current statistics of the port. They will be used
247 port->lp_stat[i] =
248 aggr_port_stat(port, i + MAC_STAT_MIN);
251 port->lp_ether_stat[i] =
252 aggr_port_stat(port, i + MACTYPE_STAT_MIN);
256 port->lp_collector_enabled = B_FALSE;
258 *pp = port;
269 aggr_port_delete(aggr_port_t *port)
271 aggr_lacp_port_t *pl = &port->lp_lacp;
273 ASSERT(port->lp_mphp == NULL);
274 ASSERT(!port->lp_promisc_on);
276 port->lp_closing = B_TRUE;
278 VERIFY(mac_margin_remove(port->lp_mh, port->lp_margin) == 0);
279 mac_rx_clear(port->lp_mch);
286 if ((port->lp_mnh != NULL) &&
287 (mac_notify_remove(port->lp_mnh, B_FALSE) == 0)) {
288 aggr_grp_port_rele(port);
290 port->lp_mnh = NULL;
293 * Inform the the port lacp timer thread to exit. Note that waiting
297 * is holding a reference of the port.
305 * Restore the port MAC address. Note it is called after the
306 * port's notification callback being removed. This prevent
307 * port's MAC_NOTE_UNICST notify callback function being called.
309 (void) mac_unicast_primary_set(port->lp_mh, port->lp_addr);
310 if (port->lp_mah != NULL)
311 (void) mac_unicast_remove(port->lp_mch, port->lp_mah);
312 mac_client_close(port->lp_mch, MAC_CLOSE_FLAGS_EXCLUSIVE);
313 mac_close(port->lp_mh);
314 AGGR_PORT_REFRELE(port);
318 aggr_port_free(aggr_port_t *port)
320 ASSERT(port->lp_refs == 0);
321 if (port->lp_grp != NULL)
322 AGGR_GRP_REFRELE(port->lp_grp);
323 port->lp_grp = NULL;
324 id_free(aggr_portids, port->lp_portid);
325 port->lp_portid = 0;
326 mutex_destroy(&port->lp_lacp.lacp_timer_lock);
327 cv_destroy(&port->lp_lacp.lacp_timer_cv);
328 kmem_cache_free(aggr_port_cache, port);
336 aggr_port_notify_link(aggr_grp_t *grp, aggr_port_t *port)
347 mac_perim_enter_by_mh(port->lp_mh, &mph);
353 link_state = port->lp_no_link_update ? LINK_STATE_UP :
354 mac_link_get(port->lp_mh);
355 if (port->lp_link_state != link_state) {
357 do_attach = (port->lp_link_state != LINK_STATE_UP);
359 do_detach = (port->lp_link_state == LINK_STATE_UP);
361 port->lp_link_state = link_state;
364 link_duplex = aggr_port_stat(port, ETHER_STAT_LINK_DUPLEX);
365 if (port->lp_link_duplex != link_duplex) {
367 do_attach |= (port->lp_link_duplex != LINK_DUPLEX_FULL);
369 do_detach |= (port->lp_link_duplex == LINK_DUPLEX_FULL);
371 port->lp_link_duplex = link_duplex;
374 ifspeed = aggr_port_stat(port, MAC_STAT_IFSPEED);
375 if (port->lp_ifspeed != ifspeed) {
376 if (port->lp_state == AGGR_PORT_STATE_ATTACHED)
381 port->lp_ifspeed = ifspeed;
384 /* attempt to attach the port to the aggregation */
385 link_state_changed = aggr_grp_attach_port(grp, port);
387 /* detach the port from the aggregation */
388 link_state_changed = aggr_grp_detach_port(grp, port);
400 aggr_port_notify_unicst(aggr_grp_t *grp, aggr_port_t *port,
411 mac_perim_enter_by_mh(port->lp_mh, &mph);
417 mac_unicast_primary_get(port->lp_mh, mac_addr);
423 /* save the new port MAC address */
424 bcopy(mac_addr, port->lp_addr, ETHERADDRL);
426 aggr_grp_port_mac_changed(grp, port, &mac_addr_changed,
432 * If this port was used to determine the MAC address of
446 * a particular MAC port.
451 aggr_port_t *port = arg;
452 aggr_grp_t *grp = port->lp_grp;
457 if (port->lp_closing) {
464 aggr_grp_port_rele(port);
473 if (aggr_port_notify_link(grp, port))
477 aggr_port_notify_unicst(grp, port, &mac_addr_changed,
492 aggr_port_start(aggr_port_t *port)
494 ASSERT(MAC_PERIM_HELD(port->lp_mh));
496 if (port->lp_started)
499 port->lp_started = B_TRUE;
500 aggr_grp_multicst_port(port, B_TRUE);
505 aggr_port_stop(aggr_port_t *port)
507 ASSERT(MAC_PERIM_HELD(port->lp_mh));
509 if (!port->lp_started)
512 aggr_grp_multicst_port(port, B_FALSE);
514 /* update the port state */
515 port->lp_started = B_FALSE;
519 aggr_port_promisc(aggr_port_t *port, boolean_t on)
523 ASSERT(MAC_PERIM_HELD(port->lp_mh));
525 if (on == port->lp_promisc_on)
530 mac_rx_clear(port->lp_mch);
531 rc = mac_promisc_add(port->lp_mch, MAC_CLIENT_PROMISC_ALL,
532 aggr_recv_cb, port, &port->lp_mphp,
535 mac_rx_set(port->lp_mch, aggr_recv_cb, port);
539 mac_promisc_remove(port->lp_mphp);
540 port->lp_mphp = NULL;
541 mac_rx_set(port->lp_mch, aggr_recv_cb, port);
544 port->lp_promisc_on = on;
550 * Set the MAC address of a port.
553 aggr_port_unicst(aggr_port_t *port)
555 aggr_grp_t *grp = port->lp_grp;
558 ASSERT(MAC_PERIM_HELD(port->lp_mh));
560 return (mac_unicast_primary_set(port->lp_mh, grp->lg_addr));
564 * Add or remove a multicast address to/from a port.
569 aggr_port_t *port = arg;
572 return (mac_multicast_add(port->lp_mch, addrp));
574 mac_multicast_remove(port->lp_mch, addrp);
580 aggr_port_stat(aggr_port_t *port, uint_t stat)
582 return (mac_stat_get(port->lp_mh, stat));
586 * Add a non-primary unicast address to the underlying port. If the port
588 * the port first. If that fails, or if the port does not support HW Rx
589 * group, enable the port's promiscous mode.
592 aggr_port_addmac(aggr_port_t *port, const uint8_t *mac_addr)
598 ASSERT(MAC_PERIM_HELD(port->lp_grp->lg_mh));
599 mac_perim_enter_by_mh(port->lp_mh, &pmph);
602 * If the underlying port support HW Rx group, add the mac to its
605 if ((port->lp_hwgh != NULL) &&
606 ((mac_hwgroup_addmac(port->lp_hwgh, mac_addr)) == 0)) {
612 * If that fails, or if the port does not support HW Rx group, enable
613 * the port's promiscous mode. (Note that we turn on the promiscous
614 * mode only if the port is already started.
616 if (port->lp_started &&
617 ((err = aggr_port_promisc(port, B_TRUE)) != 0)) {
624 * enabled on this port, and add this address to the end of the list.
626 pprev = &port->lp_prom_addr;
640 * Remove a non-primary unicast address from the underlying port. This address
642 * remove the address from the port's HW Rx group, or to disable the port's
646 aggr_port_remmac(aggr_port_t *port, const uint8_t *mac_addr)
648 aggr_grp_t *grp = port->lp_grp;
653 mac_perim_enter_by_mh(port->lp_mh, &pmph);
657 * the port being promiscous mode.
659 pprev = &port->lp_prom_addr;
667 * This unicast address put the port into the promiscous mode,
674 if (port->lp_prom_addr == NULL && !grp->lg_promisc)
675 (void) aggr_port_promisc(port, B_FALSE);
677 ASSERT(port->lp_hwgh != NULL);
678 (void) mac_hwgroup_remmac(port->lp_hwgh, mac_addr);