Lines Matching defs:bs
155 bstp_transmit(struct bstp_state *bs, struct bstp_port *bp)
157 if (bs->bs_running == 0)
166 bstp_hello_timer_expiry(bs, bp);
169 if (bp->bp_txcount > bs->bs_txholdcount)
174 bstp_transmit_bpdu(bs, bp);
179 bstp_transmit_bpdu(bs, bp);
184 bstp_transmit_tcn(bs, bp);
193 bstp_transmit_bpdu(struct bstp_state *bs, struct bstp_port *bp)
197 BSTP_LOCK_ASSERT(bs);
225 bstp_send_bpdu(bs, bp, &bpdu);
229 bstp_transmit_tcn(struct bstp_state *bs, struct bstp_port *bp)
236 KASSERT(bp == bs->bs_root_port, ("%s: bad root port\n", __func__));
341 bstp_send_bpdu(struct bstp_state *bs, struct bstp_port *bp,
348 BSTP_LOCK_ASSERT(bs);
456 struct bstp_state *bs = bp->bp_bs;
466 BSTP_LOCK(bs);
517 bstp_received_stp(bs, bp, &m, &tpdu);
521 bstp_received_rstp(bs, bp, &m, &tpdu);
525 BSTP_UNLOCK(bs);
531 bstp_received_stp(struct bstp_state *bs, struct bstp_port *bp,
541 bstp_received_tcn(bs, bp, &tu);
550 bstp_received_bpdu(bs, bp, cu);
556 bstp_received_rstp(struct bstp_state *bs, struct bstp_port *bp,
571 bstp_received_bpdu(bs, bp, cu);
575 bstp_received_tcn(struct bstp_state *bs, struct bstp_port *bp,
583 bstp_received_bpdu(struct bstp_state *bs, struct bstp_port *bp,
588 BSTP_LOCK_ASSERT(bs);
618 bs->bs_allsynced = 0;
646 bstp_assign_roles(bs);
689 bstp_update_state(bs, bp);
798 bstp_assign_roles(struct bstp_state *bs)
804 bs->bs_root_pv = bs->bs_bridge_pv;
805 bs->bs_root_msg_age = 0;
806 bs->bs_root_max_age = bs->bs_bridge_max_age;
807 bs->bs_root_fdelay = bs->bs_bridge_fdelay;
808 bs->bs_root_htime = bs->bs_bridge_htime;
809 bs->bs_root_port = NULL;
812 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
825 bs->bs_bridge_pv.pv_dbridge_id) == 0 &&
826 bstp_info_cmp(&bs->bs_root_pv, &pv) == INFO_BETTER) {
828 bs->bs_root_pv = pv;
829 bs->bs_root_msg_age = bp->bp_port_msg_age +
831 bs->bs_root_max_age = bp->bp_port_max_age;
832 bs->bs_root_fdelay = bp->bp_port_fdelay;
833 bs->bs_root_htime = bp->bp_port_htime;
838 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
840 bp->bp_desg_pv.pv_root_id = bs->bs_root_pv.pv_root_id;
841 bp->bp_desg_pv.pv_cost = bs->bs_root_pv.pv_cost;
842 bp->bp_desg_pv.pv_dbridge_id = bs->bs_bridge_pv.pv_dbridge_id;
847 bp->bp_desg_msg_age = bs->bs_root_msg_age;
848 bp->bp_desg_max_age = bs->bs_root_max_age;
849 bp->bp_desg_fdelay = bs->bs_root_fdelay;
850 bp->bp_desg_htime = bs->bs_bridge_htime;
883 bs->bs_root_port = bp;
895 bs->bs_bridge_pv.pv_dbridge_id)) {
917 bstp_update_state(struct bstp_state *bs, struct bstp_port *bp)
922 BSTP_LOCK_ASSERT(bs);
925 if (!bs->bs_allsynced) {
927 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) {
934 bs->bs_allsynced = synced;
937 bstp_update_roles(bs, bp);
942 bstp_update_roles(struct bstp_state *bs, struct bstp_port *bp)
956 if ((bs->bs_allsynced && !bp->bp_agree) ||
966 bstp_set_all_sync(bs);
983 bstp_set_all_reroot(bs);
987 if ((bs->bs_allsynced && !bp->bp_agree) ||
997 bstp_set_all_sync(bs);
1004 (bstp_rerooted(bs, bp) &&
1090 bstp_transmit(bs, bp);
1153 struct bstp_state *bs = bp->bp_bs;
1163 bs->bs_allsynced = 0;
1182 struct bstp_state *bs = bp->bp_bs;
1185 BSTP_LOCK_ASSERT(bs);
1187 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) {
1195 bstp_set_all_reroot(struct bstp_state *bs)
1199 BSTP_LOCK_ASSERT(bs);
1201 LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
1206 bstp_set_all_sync(struct bstp_state *bs)
1210 BSTP_LOCK_ASSERT(bs);
1212 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
1217 bs->bs_allsynced = 0;
1260 struct bstp_state *bs = bp->bp_bs;
1293 bs->bs_allsynced = 0;
1334 struct bstp_state *bs = bp->bp_bs;
1350 bs->bs_migration_delay);
1365 struct bstp_state *bs = bp->bp_bs;
1398 bstp_transmit(bs, bp);
1399 getmicrotime(&bs->bs_last_tc_time);
1441 struct bstp_state *bs = bp->bp_bs;
1455 bs->bs_root_max_age + bs->bs_root_fdelay);
1473 bstp_rerooted(struct bstp_state *bs, struct bstp_port *bp)
1478 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) {
1490 bstp_set_htime(struct bstp_state *bs, int t)
1496 if (bs->bs_protover != BSTP_PROTO_STP)
1502 BSTP_LOCK(bs);
1503 bs->bs_bridge_htime = t;
1504 bstp_reinit(bs);
1505 BSTP_UNLOCK(bs);
1510 bstp_set_fdelay(struct bstp_state *bs, int t)
1518 BSTP_LOCK(bs);
1519 bs->bs_bridge_fdelay = t;
1520 bstp_reinit(bs);
1521 BSTP_UNLOCK(bs);
1526 bstp_set_maxage(struct bstp_state *bs, int t)
1534 BSTP_LOCK(bs);
1535 bs->bs_bridge_max_age = t;
1536 bstp_reinit(bs);
1537 BSTP_UNLOCK(bs);
1542 bstp_set_holdcount(struct bstp_state *bs, int count)
1550 BSTP_LOCK(bs);
1551 bs->bs_txholdcount = count;
1552 LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
1554 BSTP_UNLOCK(bs);
1559 bstp_set_protocol(struct bstp_state *bs, int proto)
1573 BSTP_LOCK(bs);
1574 bs->bs_protover = proto;
1575 bs->bs_bridge_htime = BSTP_DEFAULT_HELLO_TIME;
1576 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
1580 bstp_set_port_proto(bp, bs->bs_protover);
1585 bstp_reinit(bs);
1586 BSTP_UNLOCK(bs);
1591 bstp_set_priority(struct bstp_state *bs, int pri)
1599 BSTP_LOCK(bs);
1600 bs->bs_bridge_priority = pri;
1601 bstp_reinit(bs);
1602 BSTP_UNLOCK(bs);
1609 struct bstp_state *bs = bp->bp_bs;
1617 BSTP_LOCK(bs);
1619 bstp_reinit(bs);
1620 BSTP_UNLOCK(bs);
1627 struct bstp_state *bs = bp->bp_bs;
1636 BSTP_LOCK(bs);
1645 bstp_reinit(bs);
1646 BSTP_UNLOCK(bs);
1653 struct bstp_state *bs = bp->bp_bs;
1655 BSTP_LOCK(bs);
1660 BSTP_UNLOCK(bs);
1667 struct bstp_state *bs = bp->bp_bs;
1669 BSTP_LOCK(bs);
1674 bstp_edge_delay_expiry(bs, bp);
1677 BSTP_UNLOCK(bs);
1684 struct bstp_state *bs = bp->bp_bs;
1686 BSTP_LOCK(bs);
1688 BSTP_UNLOCK(bs);
1695 struct bstp_state *bs = bp->bp_bs;
1697 BSTP_LOCK(bs);
1704 BSTP_UNLOCK(bs);
1751 struct bstp_state *bs = bp->bp_bs;
1753 if (bp->bp_active == 1 && bs->bs_state_cb != NULL)
1754 (*bs->bs_state_cb)(bp->bp_ifp, bp->bp_state);
1765 struct bstp_state *bs = bp->bp_bs;
1768 BSTP_LOCK(bs);
1779 BSTP_UNLOCK(bs);
1781 if (bp->bp_active == 1 && bs->bs_rtage_cb != NULL)
1782 (*bs->bs_rtage_cb)(bp->bp_ifp, age);
1785 BSTP_LOCK(bs);
1787 BSTP_UNLOCK(bs);
1793 struct bstp_state *bs = bp->bp_bs;
1799 BSTP_LOCK(bs);
1800 bstp_update_state(bs, bp);
1801 BSTP_UNLOCK(bs);
1808 struct bstp_state *bs = bp->bp_bs;
1819 BSTP_LOCK(bs);
1847 bstp_enable_port(bs, bp);
1852 bstp_disable_port(bs, bp);
1860 bstp_disable_port(bs, bp);
1864 bstp_assign_roles(bs);
1865 BSTP_UNLOCK(bs);
1869 bstp_enable_port(struct bstp_state *bs, struct bstp_port *bp)
1875 bstp_disable_port(struct bstp_state *bs, struct bstp_port *bp)
1883 struct bstp_state *bs = arg;
1886 BSTP_LOCK_ASSERT(bs);
1888 if (bs->bs_running == 0)
1892 CURVNET_SET(bs->bs_vnet);
1895 if (bstp_timer_dectest(&bs->bs_link_timer)) {
1896 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
1900 bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
1903 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
1911 bstp_hello_timer_expiry(bs, bp);
1914 bstp_message_age_expiry(bs, bp);
1917 bstp_migrate_delay_expiry(bs, bp);
1920 bstp_edge_delay_expiry(bs, bp);
1923 bstp_update_state(bs, bp);
1932 callout_reset(&bs->bs_bstpcallout, hz, bstp_tick, bs);
1972 bstp_hello_timer_expiry(struct bstp_state *bs, struct bstp_port *bp)
1980 bstp_transmit(bs, bp);
1985 bstp_message_age_expiry(struct bstp_state *bs, struct bstp_port *bp)
1989 bstp_assign_roles(bs);
1995 bstp_migrate_delay_expiry(struct bstp_state *bs, struct bstp_port *bp)
2001 bstp_edge_delay_expiry(struct bstp_state *bs, struct bstp_port *bp)
2042 bstp_reinit(struct bstp_state *bs)
2050 BSTP_LOCK_ASSERT(bs);
2052 if (LIST_EMPTY(&bs->bs_bplist))
2056 bridgeptr = LIST_FIRST(&bs->bs_bplist)->bp_ifp->if_bridge;
2089 bs->bs_bridge_pv.pv_dbridge_id =
2090 (((uint64_t)bs->bs_bridge_priority) << 48) |
2098 bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
2099 bs->bs_bridge_pv.pv_cost = 0;
2100 bs->bs_bridge_pv.pv_dport_id = 0;
2101 bs->bs_bridge_pv.pv_port_id = 0;
2103 if (bs->bs_running && callout_pending(&bs->bs_bstpcallout) == 0)
2104 callout_reset(&bs->bs_bstpcallout, hz, bstp_tick, bs);
2106 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
2112 bstp_assign_roles(bs);
2113 bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
2118 bs->bs_bridge_pv.pv_dbridge_id =
2119 ((uint64_t)bs->bs_bridge_priority) << 48;
2120 bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
2121 bs->bs_root_pv = bs->bs_bridge_pv;
2123 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
2127 callout_stop(&bs->bs_bstpcallout);
2157 bstp_attach(struct bstp_state *bs, struct bstp_cb_ops *cb)
2159 BSTP_LOCK_INIT(bs);
2160 callout_init_mtx(&bs->bs_bstpcallout, &bs->bs_mtx, 0);
2161 LIST_INIT(&bs->bs_bplist);
2163 bs->bs_bridge_max_age = BSTP_DEFAULT_MAX_AGE;
2164 bs->bs_bridge_htime = BSTP_DEFAULT_HELLO_TIME;
2165 bs->bs_bridge_fdelay = BSTP_DEFAULT_FORWARD_DELAY;
2166 bs->bs_bridge_priority = BSTP_DEFAULT_BRIDGE_PRIORITY;
2167 bs->bs_hold_time = BSTP_DEFAULT_HOLD_TIME;
2168 bs->bs_migration_delay = BSTP_DEFAULT_MIGRATE_DELAY;
2169 bs->bs_txholdcount = BSTP_DEFAULT_HOLD_COUNT;
2170 bs->bs_protover = BSTP_PROTO_RSTP;
2171 bs->bs_state_cb = cb->bcb_state;
2172 bs->bs_rtage_cb = cb->bcb_rtage;
2173 bs->bs_vnet = curvnet;
2175 getmicrotime(&bs->bs_last_tc_time);
2178 LIST_INSERT_HEAD(&bstp_list, bs, bs_list);
2183 bstp_detach(struct bstp_state *bs)
2185 KASSERT(LIST_EMPTY(&bs->bs_bplist), ("bstp still active"));
2188 LIST_REMOVE(bs, bs_list);
2190 callout_drain(&bs->bs_bstpcallout);
2191 BSTP_LOCK_DESTROY(bs);
2195 bstp_init(struct bstp_state *bs)
2197 BSTP_LOCK(bs);
2198 callout_reset(&bs->bs_bstpcallout, hz, bstp_tick, bs);
2199 bs->bs_running = 1;
2200 bstp_reinit(bs);
2201 BSTP_UNLOCK(bs);
2205 bstp_stop(struct bstp_state *bs)
2209 BSTP_LOCK(bs);
2211 LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
2214 bs->bs_running = 0;
2215 callout_stop(&bs->bs_bstpcallout);
2216 BSTP_UNLOCK(bs);
2220 bstp_create(struct bstp_state *bs, struct bstp_port *bp, struct ifnet *ifp)
2224 BSTP_LOCK(bs);
2226 bp->bp_bs = bs;
2236 bstp_set_port_proto(bp, bs->bs_protover);
2240 BSTP_UNLOCK(bs);
2247 struct bstp_state *bs = bp->bp_bs;
2261 BSTP_LOCK(bs);
2262 LIST_INSERT_HEAD(&bs->bs_bplist, bp, bp_next);
2265 bstp_reinit(bs);
2266 bstp_update_roles(bs, bp);
2267 BSTP_UNLOCK(bs);
2274 struct bstp_state *bs = bp->bp_bs;
2278 BSTP_LOCK(bs);
2279 bstp_disable_port(bs, bp);
2282 bstp_reinit(bs);
2283 BSTP_UNLOCK(bs);