Lines Matching refs:bs

214 bstp_transmit(struct bstp_state *bs, struct bstp_port *bp)
216 if (bs->bs_running == 0)
225 bstp_hello_timer_expiry(bs, bp);
228 if (bp->bp_txcount > bs->bs_txholdcount)
233 bstp_transmit_bpdu(bs, bp);
238 bstp_transmit_bpdu(bs, bp);
243 bstp_transmit_tcn(bs, bp);
252 bstp_transmit_bpdu(struct bstp_state *bs, struct bstp_port *bp)
256 BSTP_LOCK_ASSERT(bs);
284 bstp_send_bpdu(bs, bp, &bpdu);
288 bstp_transmit_tcn(struct bstp_state *bs, struct bstp_port *bp)
294 int touched = bs ? 1 : 0;
298 KASSERT(bp == bs->bs_root_port, ("%s: bad root port\n", __func__));
403 bstp_send_bpdu(struct bstp_state *bs, struct bstp_port *bp,
410 BSTP_LOCK_ASSERT(bs);
534 struct bstp_state *bs = bp->bp_bs;
544 BSTP_LOCK(bs);
595 bstp_received_stp(bs, bp, &m, &tpdu);
599 bstp_received_rstp(bs, bp, &m, &tpdu);
603 BSTP_UNLOCK(bs);
610 bstp_received_stp(struct bstp_state *bs, struct bstp_port *bp,
620 bstp_received_tcn(bs, bp, &tu);
629 bstp_received_bpdu(bs, bp, cu);
635 bstp_received_rstp(struct bstp_state *bs, struct bstp_port *bp,
650 bstp_received_bpdu(bs, bp, cu);
654 bstp_received_tcn(__unused struct bstp_state *bs, struct bstp_port *bp,
662 bstp_received_bpdu(struct bstp_state *bs, struct bstp_port *bp,
667 BSTP_LOCK_ASSERT(bs);
680 bs->bs_allsynced = 0;
708 bstp_assign_roles(bs);
751 bstp_update_state(bs, bp);
860 bstp_assign_roles(struct bstp_state *bs)
866 bs->bs_root_pv = bs->bs_bridge_pv;
867 bs->bs_root_msg_age = 0;
868 bs->bs_root_max_age = bs->bs_bridge_max_age;
869 bs->bs_root_fdelay = bs->bs_bridge_fdelay;
870 bs->bs_root_htime = bs->bs_bridge_htime;
871 bs->bs_root_port = NULL;
874 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
887 bs->bs_bridge_pv.pv_dbridge_id) == 0 &&
888 bstp_info_cmp(&bs->bs_root_pv, &pv) == INFO_BETTER) {
890 bs->bs_root_pv = pv;
891 bs->bs_root_msg_age = bp->bp_port_msg_age +
893 bs->bs_root_max_age = bp->bp_port_max_age;
894 bs->bs_root_fdelay = bp->bp_port_fdelay;
895 bs->bs_root_htime = bp->bp_port_htime;
900 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
902 bp->bp_desg_pv.pv_root_id = bs->bs_root_pv.pv_root_id;
903 bp->bp_desg_pv.pv_cost = bs->bs_root_pv.pv_cost;
904 bp->bp_desg_pv.pv_dbridge_id = bs->bs_bridge_pv.pv_dbridge_id;
909 bp->bp_desg_msg_age = bs->bs_root_msg_age;
910 bp->bp_desg_max_age = bs->bs_root_max_age;
911 bp->bp_desg_fdelay = bs->bs_root_fdelay;
912 bp->bp_desg_htime = bs->bs_bridge_htime;
945 bs->bs_root_port = bp;
957 bs->bs_bridge_pv.pv_dbridge_id)) {
979 bstp_update_state(struct bstp_state *bs, struct bstp_port *bp)
984 BSTP_LOCK_ASSERT(bs);
987 if (!bs->bs_allsynced) {
989 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) {
996 bs->bs_allsynced = synced;
999 bstp_update_roles(bs, bp);
1004 bstp_update_roles(struct bstp_state *bs, struct bstp_port *bp)
1018 if ((bs->bs_allsynced && !bp->bp_agree) ||
1028 bstp_set_all_sync(bs);
1045 bstp_set_all_reroot(bs);
1049 if ((bs->bs_allsynced && !bp->bp_agree) ||
1059 bstp_set_all_sync(bs);
1066 (bstp_rerooted(bs, bp) &&
1154 bstp_transmit(bs, bp);
1217 struct bstp_state *bs = bp->bp_bs;
1227 bs->bs_allsynced = 0;
1246 struct bstp_state *bs = bp->bp_bs;
1249 BSTP_LOCK_ASSERT(bs);
1251 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) {
1259 bstp_set_all_reroot(struct bstp_state *bs)
1263 BSTP_LOCK_ASSERT(bs);
1265 LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
1270 bstp_set_all_sync(struct bstp_state *bs)
1274 BSTP_LOCK_ASSERT(bs);
1276 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
1281 bs->bs_allsynced = 0;
1324 struct bstp_state *bs = bp->bp_bs;
1357 bs->bs_allsynced = 0;
1398 struct bstp_state *bs = bp->bp_bs;
1414 bs->bs_migration_delay);
1429 struct bstp_state *bs = bp->bp_bs;
1462 bstp_transmit(bs, bp);
1464 getmicrotime(&bs->bs_last_tc_time);
1506 struct bstp_state *bs = bp->bp_bs;
1520 bs->bs_root_max_age + bs->bs_root_fdelay);
1538 bstp_rerooted(struct bstp_state *bs, struct bstp_port *bp)
1543 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) {
1555 bstp_set_htime(struct bstp_state *bs, int t)
1561 if (bs->bs_protover != BSTP_PROTO_STP)
1567 BSTP_LOCK(bs);
1568 bs->bs_bridge_htime = t;
1569 bstp_reinit(bs);
1570 BSTP_UNLOCK(bs);
1575 bstp_set_fdelay(struct bstp_state *bs, int t)
1583 BSTP_LOCK(bs);
1584 bs->bs_bridge_fdelay = t;
1585 bstp_reinit(bs);
1586 BSTP_UNLOCK(bs);
1591 bstp_set_maxage(struct bstp_state *bs, int t)
1599 BSTP_LOCK(bs);
1600 bs->bs_bridge_max_age = t;
1601 bstp_reinit(bs);
1602 BSTP_UNLOCK(bs);
1607 bstp_set_holdcount(struct bstp_state *bs, int count)
1615 BSTP_LOCK(bs);
1616 bs->bs_txholdcount = count;
1617 LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
1619 BSTP_UNLOCK(bs);
1624 bstp_set_protocol(struct bstp_state *bs, int proto)
1638 BSTP_LOCK(bs);
1639 bs->bs_protover = proto;
1640 bs->bs_bridge_htime = BSTP_DEFAULT_HELLO_TIME;
1641 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
1645 bstp_set_port_proto(bp, bs->bs_protover);
1650 bstp_reinit(bs);
1651 BSTP_UNLOCK(bs);
1656 bstp_set_priority(struct bstp_state *bs, int pri)
1664 BSTP_LOCK(bs);
1665 bs->bs_bridge_priority = pri;
1666 bstp_reinit(bs);
1667 BSTP_UNLOCK(bs);
1674 struct bstp_state *bs = bp->bp_bs;
1682 BSTP_LOCK(bs);
1684 bstp_reinit(bs);
1685 BSTP_UNLOCK(bs);
1692 struct bstp_state *bs = bp->bp_bs;
1701 BSTP_LOCK(bs);
1710 bstp_reinit(bs);
1711 BSTP_UNLOCK(bs);
1718 struct bstp_state *bs = bp->bp_bs;
1720 BSTP_LOCK(bs);
1725 BSTP_UNLOCK(bs);
1732 struct bstp_state *bs = bp->bp_bs;
1734 BSTP_LOCK(bs);
1739 bstp_edge_delay_expiry(bs, bp);
1742 BSTP_UNLOCK(bs);
1749 struct bstp_state *bs = bp->bp_bs;
1751 BSTP_LOCK(bs);
1753 BSTP_UNLOCK(bs);
1760 struct bstp_state *bs = bp->bp_bs;
1762 BSTP_LOCK(bs);
1766 bstp_ifupdstatus(bs, bp);
1769 BSTP_UNLOCK(bs);
1816 struct bstp_state *bs = bp->bp_bs;
1818 if (bp->bp_active == 1 && bs->bs_state_cb != NULL)
1819 (*bs->bs_state_cb)(bp->bp_ifp, bp->bp_state);
1830 struct bstp_state *bs = bp->bp_bs;
1833 BSTP_LOCK(bs);
1844 BSTP_UNLOCK(bs);
1846 if (bp->bp_active == 1 && bs->bs_rtage_cb != NULL)
1847 (*bs->bs_rtage_cb)(bp->bp_ifp, age);
1850 BSTP_LOCK(bs);
1852 BSTP_UNLOCK(bs);
1858 struct bstp_state *bs;
1863 LIST_FOREACH(bs, &bstp_list, bs_list) {
1864 BSTP_LOCK(bs);
1865 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
1867 bstp_ifupdstatus(bs, bp);
1868 bstp_update_state(bs, bp);
1870 BSTP_UNLOCK(bs);
1875 BSTP_UNLOCK(bs);
1881 bstp_ifupdstatus(struct bstp_state *bs, struct bstp_port *bp)
1887 BSTP_LOCK_ASSERT(bs);
1907 bstp_enable_port(bs, bp);
1910 bstp_disable_port(bs, bp);
1920 bstp_disable_port(bs, bp);
1924 bstp_enable_port(struct bstp_state *bs, struct bstp_port *bp)
1927 bstp_assign_roles(bs);
1931 bstp_disable_port(struct bstp_state *bs, struct bstp_port *bp)
1934 bstp_assign_roles(bs);
1940 struct bstp_state *bs = arg;
1944 BSTP_LOCK(bs);
1946 if (bs->bs_running == 0)
1950 if (bstp_timer_expired(&bs->bs_link_timer)) {
1951 LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
1952 bstp_ifupdstatus(bs, bp);
1953 bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
1956 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
1964 bstp_hello_timer_expiry(bs, bp);
1967 bstp_message_age_expiry(bs, bp);
1970 bstp_migrate_delay_expiry(bs, bp);
1973 bstp_edge_delay_expiry(bs, bp);
1976 bstp_update_state(bs, bp);
1982 BSTP_UNLOCK(bs);
1986 bsd_timeout(bstp_tick, bs, &ts);
2026 bstp_hello_timer_expiry(struct bstp_state *bs, struct bstp_port *bp)
2034 bstp_transmit(bs, bp);
2039 bstp_message_age_expiry(struct bstp_state *bs, struct bstp_port *bp)
2043 bstp_assign_roles(bs);
2049 bstp_migrate_delay_expiry(__unused struct bstp_state *bs, struct bstp_port *bp)
2055 bstp_edge_delay_expiry(__unused struct bstp_state *bs, struct bstp_port *bp)
2096 bstp_reinit(struct bstp_state *bs)
2103 BSTP_LOCK_ASSERT(bs);
2131 if (LIST_EMPTY(&bs->bs_bplist) || mif == NULL) {
2133 bs->bs_bridge_pv.pv_dbridge_id =
2134 ((uint64_t)bs->bs_bridge_priority) << 48;
2135 bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
2136 bs->bs_root_pv = bs->bs_bridge_pv;
2138 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
2142 bsd_untimeout(bstp_tick, bs);
2147 bs->bs_bridge_pv.pv_dbridge_id =
2148 (((uint64_t)bs->bs_bridge_priority) << 48) |
2156 bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id;
2157 bs->bs_bridge_pv.pv_cost = 0;
2158 bs->bs_bridge_pv.pv_dport_id = 0;
2159 bs->bs_bridge_pv.pv_port_id = 0;
2161 if (bs->bs_running)
2162 bsd_untimeout(bstp_tick, bs);
2164 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) {
2167 bstp_ifupdstatus(bs, bp);
2170 bstp_assign_roles(bs);
2171 bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER);
2175 bstp_attach(struct bstp_state *bs, struct bstp_cb_ops *cb)
2177 BSTP_LOCK_INIT(bs);
2178 LIST_INIT(&bs->bs_bplist);
2180 bs->bs_bridge_max_age = BSTP_DEFAULT_MAX_AGE;
2181 bs->bs_bridge_htime = BSTP_DEFAULT_HELLO_TIME;
2182 bs->bs_bridge_fdelay = BSTP_DEFAULT_FORWARD_DELAY;
2183 bs->bs_bridge_priority = BSTP_DEFAULT_BRIDGE_PRIORITY;
2184 bs->bs_hold_time = BSTP_DEFAULT_HOLD_TIME;
2185 bs->bs_migration_delay = BSTP_DEFAULT_MIGRATE_DELAY;
2186 bs->bs_txholdcount = BSTP_DEFAULT_HOLD_COUNT;
2187 bs->bs_protover = BSTP_PROTO_RSTP;
2188 bs->bs_state_cb = cb->bcb_state;
2189 bs->bs_rtage_cb = cb->bcb_rtage;
2192 getmicrotime(&bs->bs_last_tc_time);
2195 LIST_INSERT_HEAD(&bstp_list, bs, bs_list);
2200 bstp_detach(struct bstp_state *bs)
2202 KASSERT(LIST_EMPTY(&bs->bs_bplist), ("bstp still active"));
2205 LIST_REMOVE(bs, bs_list);
2207 bsd_untimeout(bstp_tick, bs);
2208 BSTP_LOCK_DESTROY(bs);
2212 bstp_init(struct bstp_state *bs)
2219 BSTP_LOCK(bs);
2220 bsd_timeout(bstp_tick, bs, &ts);
2221 bs->bs_running = 1;
2222 bstp_reinit(bs);
2223 BSTP_UNLOCK(bs);
2227 bstp_stop(struct bstp_state *bs)
2231 BSTP_LOCK(bs);
2233 LIST_FOREACH(bp, &bs->bs_bplist, bp_next)
2236 bs->bs_running = 0;
2237 bsd_untimeout(bstp_tick, bs);
2238 BSTP_UNLOCK(bs);
2242 bstp_create(struct bstp_state *bs, struct bstp_port *bp, struct ifnet *ifp)
2246 BSTP_LOCK(bs);
2248 bp->bp_bs = bs;
2257 bstp_set_port_proto(bp, bs->bs_protover);
2261 BSTP_UNLOCK(bs);
2268 struct bstp_state *bs = bp->bp_bs;
2281 BSTP_LOCK(bs);
2282 LIST_INSERT_HEAD(&bs->bs_bplist, bp, bp_next);
2285 bstp_reinit(bs);
2286 bstp_update_roles(bs, bp);
2287 BSTP_UNLOCK(bs);
2294 struct bstp_state *bs = bp->bp_bs;
2298 BSTP_LOCK(bs);
2299 bstp_disable_port(bs, bp);
2302 bstp_reinit(bs);
2303 BSTP_UNLOCK(bs);