Lines Matching refs:bs
218 bstp_transmit(struct bstp_state *bs, struct bstp_port *bp) in bstp_transmit() argument
220 if (bs->bs_running == 0) { in bstp_transmit()
230 bstp_hello_timer_expiry(bs, bp); in bstp_transmit()
233 if (bp->bp_txcount > bs->bs_txholdcount) { in bstp_transmit()
239 bstp_transmit_bpdu(bs, bp); in bstp_transmit()
244 bstp_transmit_bpdu(bs, bp); in bstp_transmit()
249 bstp_transmit_tcn(bs, bp); in bstp_transmit()
258 bstp_transmit_bpdu(struct bstp_state *bs, struct bstp_port *bp) in bstp_transmit_bpdu() argument
262 BSTP_LOCK_ASSERT(bs); in bstp_transmit_bpdu()
290 bstp_send_bpdu(bs, bp, &bpdu); in bstp_transmit_bpdu()
294 bstp_transmit_tcn(struct bstp_state *bs, struct bstp_port *bp) in bstp_transmit_tcn() argument
300 int touched = bs ? 1 : 0; in bstp_transmit_tcn()
304 KASSERT(bp == bs->bs_root_port, ("%s: bad root port\n", __func__)); in bstp_transmit_tcn()
411 bstp_send_bpdu(struct bstp_state *bs, struct bstp_port *bp, in bstp_send_bpdu() argument
418 BSTP_LOCK_ASSERT(bs); in bstp_send_bpdu()
548 struct bstp_state *bs = bp->bp_bs; in bstp_input() local
558 BSTP_LOCK(bs); in bstp_input()
616 bstp_received_stp(bs, bp, &m, &tpdu); in bstp_input()
620 bstp_received_rstp(bs, bp, &m, &tpdu); in bstp_input()
624 BSTP_UNLOCK(bs); in bstp_input()
632 bstp_received_stp(struct bstp_state *bs, struct bstp_port *bp, in bstp_received_stp() argument
642 bstp_received_tcn(bs, bp, &tu); in bstp_received_stp()
652 bstp_received_bpdu(bs, bp, cu); in bstp_received_stp()
658 bstp_received_rstp(struct bstp_state *bs, struct bstp_port *bp, in bstp_received_rstp() argument
675 bstp_received_bpdu(bs, bp, cu); in bstp_received_rstp()
679 bstp_received_tcn(__unused struct bstp_state *bs, struct bstp_port *bp, in bstp_received_tcn() argument
687 bstp_received_bpdu(struct bstp_state *bs, struct bstp_port *bp, in bstp_received_bpdu() argument
692 BSTP_LOCK_ASSERT(bs); in bstp_received_bpdu()
705 bs->bs_allsynced = 0; in bstp_received_bpdu()
737 bstp_assign_roles(bs); in bstp_received_bpdu()
786 bstp_update_state(bs, bp); in bstp_received_bpdu()
909 bstp_assign_roles(struct bstp_state *bs) in bstp_assign_roles() argument
915 bs->bs_root_pv = bs->bs_bridge_pv; in bstp_assign_roles()
916 bs->bs_root_msg_age = 0; in bstp_assign_roles()
917 bs->bs_root_max_age = bs->bs_bridge_max_age; in bstp_assign_roles()
918 bs->bs_root_fdelay = bs->bs_bridge_fdelay; in bstp_assign_roles()
919 bs->bs_root_htime = bs->bs_bridge_htime; in bstp_assign_roles()
920 bs->bs_root_port = NULL; in bstp_assign_roles()
923 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_assign_roles()
937 bs->bs_bridge_pv.pv_dbridge_id) == 0 && in bstp_assign_roles()
938 bstp_info_cmp(&bs->bs_root_pv, &pv) == INFO_BETTER) { in bstp_assign_roles()
940 bs->bs_root_pv = pv; in bstp_assign_roles()
941 bs->bs_root_msg_age = bp->bp_port_msg_age + in bstp_assign_roles()
943 bs->bs_root_max_age = bp->bp_port_max_age; in bstp_assign_roles()
944 bs->bs_root_fdelay = bp->bp_port_fdelay; in bstp_assign_roles()
945 bs->bs_root_htime = bp->bp_port_htime; in bstp_assign_roles()
950 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_assign_roles()
952 bp->bp_desg_pv.pv_root_id = bs->bs_root_pv.pv_root_id; in bstp_assign_roles()
953 bp->bp_desg_pv.pv_cost = bs->bs_root_pv.pv_cost; in bstp_assign_roles()
954 bp->bp_desg_pv.pv_dbridge_id = bs->bs_bridge_pv.pv_dbridge_id; in bstp_assign_roles()
959 bp->bp_desg_msg_age = bs->bs_root_msg_age; in bstp_assign_roles()
960 bp->bp_desg_max_age = bs->bs_root_max_age; in bstp_assign_roles()
961 bp->bp_desg_fdelay = bs->bs_root_fdelay; in bstp_assign_roles()
962 bp->bp_desg_htime = bs->bs_bridge_htime; in bstp_assign_roles()
996 bs->bs_root_port = bp; in bstp_assign_roles()
1008 bs->bs_bridge_pv.pv_dbridge_id)) { in bstp_assign_roles()
1030 bstp_update_state(struct bstp_state *bs, struct bstp_port *bp) in bstp_update_state() argument
1035 BSTP_LOCK_ASSERT(bs); in bstp_update_state()
1038 if (!bs->bs_allsynced) { in bstp_update_state()
1040 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) { in bstp_update_state()
1047 bs->bs_allsynced = synced; in bstp_update_state()
1050 bstp_update_roles(bs, bp); in bstp_update_state()
1055 bstp_update_roles(struct bstp_state *bs, struct bstp_port *bp) in bstp_update_roles() argument
1069 if ((bs->bs_allsynced && !bp->bp_agree) || in bstp_update_roles()
1079 bstp_set_all_sync(bs); in bstp_update_roles()
1096 bstp_set_all_reroot(bs); in bstp_update_roles()
1100 if ((bs->bs_allsynced && !bp->bp_agree) || in bstp_update_roles()
1110 bstp_set_all_sync(bs); in bstp_update_roles()
1117 (bstp_rerooted(bs, bp) && in bstp_update_roles()
1207 bstp_transmit(bs, bp); in bstp_update_roles()
1278 struct bstp_state *bs = bp->bp_bs; in bstp_update_info() local
1289 bs->bs_allsynced = 0; in bstp_update_info()
1308 struct bstp_state *bs = bp->bp_bs; in bstp_set_other_tcprop() local
1311 BSTP_LOCK_ASSERT(bs); in bstp_set_other_tcprop()
1313 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) { in bstp_set_other_tcprop()
1322 bstp_set_all_reroot(struct bstp_state *bs) in bstp_set_all_reroot() argument
1326 BSTP_LOCK_ASSERT(bs); in bstp_set_all_reroot()
1328 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) in bstp_set_all_reroot()
1333 bstp_set_all_sync(struct bstp_state *bs) in bstp_set_all_sync() argument
1337 BSTP_LOCK_ASSERT(bs); in bstp_set_all_sync()
1339 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_set_all_sync()
1344 bs->bs_allsynced = 0; in bstp_set_all_sync()
1388 struct bstp_state *bs = bp->bp_bs; in bstp_set_port_role() local
1422 bs->bs_allsynced = 0; in bstp_set_port_role()
1463 struct bstp_state *bs = bp->bp_bs; in bstp_set_port_proto() local
1480 bs->bs_migration_delay); in bstp_set_port_proto()
1495 struct bstp_state *bs = bp->bp_bs; in bstp_set_port_tc() local
1528 bstp_transmit(bs, bp); in bstp_set_port_tc()
1530 getmicrotime(&bs->bs_last_tc_time); in bstp_set_port_tc()
1573 struct bstp_state *bs = bp->bp_bs; in bstp_set_timer_tc() local
1588 bs->bs_root_max_age + bs->bs_root_fdelay); in bstp_set_timer_tc()
1607 bstp_rerooted(struct bstp_state *bs, struct bstp_port *bp) in bstp_rerooted() argument
1612 LIST_FOREACH(bp2, &bs->bs_bplist, bp_next) { in bstp_rerooted()
1625 bstp_set_htime(struct bstp_state *bs, int t) in bstp_set_htime() argument
1631 if (bs->bs_protover != BSTP_PROTO_STP) { in bstp_set_htime()
1639 BSTP_LOCK(bs); in bstp_set_htime()
1640 bs->bs_bridge_htime = t; in bstp_set_htime()
1641 bstp_reinit(bs); in bstp_set_htime()
1642 BSTP_UNLOCK(bs); in bstp_set_htime()
1647 bstp_set_fdelay(struct bstp_state *bs, int t) in bstp_set_fdelay() argument
1656 BSTP_LOCK(bs); in bstp_set_fdelay()
1657 bs->bs_bridge_fdelay = t; in bstp_set_fdelay()
1658 bstp_reinit(bs); in bstp_set_fdelay()
1659 BSTP_UNLOCK(bs); in bstp_set_fdelay()
1664 bstp_set_maxage(struct bstp_state *bs, int t) in bstp_set_maxage() argument
1673 BSTP_LOCK(bs); in bstp_set_maxage()
1674 bs->bs_bridge_max_age = t; in bstp_set_maxage()
1675 bstp_reinit(bs); in bstp_set_maxage()
1676 BSTP_UNLOCK(bs); in bstp_set_maxage()
1681 bstp_set_holdcount(struct bstp_state *bs, int count) in bstp_set_holdcount() argument
1690 BSTP_LOCK(bs); in bstp_set_holdcount()
1691 bs->bs_txholdcount = count; in bstp_set_holdcount()
1692 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) in bstp_set_holdcount()
1694 BSTP_UNLOCK(bs); in bstp_set_holdcount()
1699 bstp_set_protocol(struct bstp_state *bs, int proto) in bstp_set_protocol() argument
1713 BSTP_LOCK(bs); in bstp_set_protocol()
1714 bs->bs_protover = proto; in bstp_set_protocol()
1715 bs->bs_bridge_htime = BSTP_DEFAULT_HELLO_TIME; in bstp_set_protocol()
1716 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_set_protocol()
1720 bstp_set_port_proto(bp, bs->bs_protover); in bstp_set_protocol()
1725 bstp_reinit(bs); in bstp_set_protocol()
1726 BSTP_UNLOCK(bs); in bstp_set_protocol()
1731 bstp_set_priority(struct bstp_state *bs, int pri) in bstp_set_priority() argument
1740 BSTP_LOCK(bs); in bstp_set_priority()
1741 bs->bs_bridge_priority = pri; in bstp_set_priority()
1742 bstp_reinit(bs); in bstp_set_priority()
1743 BSTP_UNLOCK(bs); in bstp_set_priority()
1750 struct bstp_state *bs = bp->bp_bs; in bstp_set_port_priority() local
1759 BSTP_LOCK(bs); in bstp_set_port_priority()
1761 bstp_reinit(bs); in bstp_set_port_priority()
1762 BSTP_UNLOCK(bs); in bstp_set_port_priority()
1769 struct bstp_state *bs = bp->bp_bs; in bstp_set_path_cost() local
1780 BSTP_LOCK(bs); in bstp_set_path_cost()
1789 bstp_reinit(bs); in bstp_set_path_cost()
1790 BSTP_UNLOCK(bs); in bstp_set_path_cost()
1797 struct bstp_state *bs = bp->bp_bs; in bstp_set_edge() local
1799 BSTP_LOCK(bs); in bstp_set_edge()
1805 BSTP_UNLOCK(bs); in bstp_set_edge()
1812 struct bstp_state *bs = bp->bp_bs; in bstp_set_autoedge() local
1814 BSTP_LOCK(bs); in bstp_set_autoedge()
1819 bstp_edge_delay_expiry(bs, bp); in bstp_set_autoedge()
1824 BSTP_UNLOCK(bs); in bstp_set_autoedge()
1831 struct bstp_state *bs = bp->bp_bs; in bstp_set_ptp() local
1833 BSTP_LOCK(bs); in bstp_set_ptp()
1835 BSTP_UNLOCK(bs); in bstp_set_ptp()
1842 struct bstp_state *bs = bp->bp_bs; in bstp_set_autoptp() local
1844 BSTP_LOCK(bs); in bstp_set_autoptp()
1848 bstp_ifupdstatus(bs, bp); in bstp_set_autoptp()
1853 BSTP_UNLOCK(bs); in bstp_set_autoptp()
1904 struct bstp_state *bs = bp->bp_bs; in bstp_notify_state() local
1906 if (bp->bp_active == 1 && bs->bs_state_cb != NULL) { in bstp_notify_state()
1907 (*bs->bs_state_cb)(bp->bp_ifp, bp->bp_state); in bstp_notify_state()
1919 struct bstp_state *bs = bp->bp_bs; in bstp_notify_rtage() local
1922 BSTP_LOCK(bs); in bstp_notify_rtage()
1933 BSTP_UNLOCK(bs); in bstp_notify_rtage()
1935 if (bp->bp_active == 1 && bs->bs_rtage_cb != NULL) { in bstp_notify_rtage()
1936 (*bs->bs_rtage_cb)(bp->bp_ifp, age); in bstp_notify_rtage()
1940 BSTP_LOCK(bs); in bstp_notify_rtage()
1942 BSTP_UNLOCK(bs); in bstp_notify_rtage()
1948 struct bstp_state *bs; in bstp_linkstate() local
1953 LIST_FOREACH(bs, &bstp_list, bs_list) { in bstp_linkstate()
1954 BSTP_LOCK(bs); in bstp_linkstate()
1955 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_linkstate()
1957 bstp_ifupdstatus(bs, bp); in bstp_linkstate()
1958 bstp_update_state(bs, bp); in bstp_linkstate()
1960 BSTP_UNLOCK(bs); in bstp_linkstate()
1965 BSTP_UNLOCK(bs); in bstp_linkstate()
1971 bstp_ifupdstatus(struct bstp_state *bs, struct bstp_port *bp) in bstp_ifupdstatus() argument
1977 BSTP_LOCK_ASSERT(bs); in bstp_ifupdstatus()
1997 bstp_enable_port(bs, bp); in bstp_ifupdstatus()
2001 bstp_disable_port(bs, bp); in bstp_ifupdstatus()
2012 bstp_disable_port(bs, bp); in bstp_ifupdstatus()
2017 bstp_enable_port(struct bstp_state *bs, struct bstp_port *bp) in bstp_enable_port() argument
2020 bstp_assign_roles(bs); in bstp_enable_port()
2024 bstp_disable_port(struct bstp_state *bs, struct bstp_port *bp) in bstp_disable_port() argument
2027 bstp_assign_roles(bs); in bstp_disable_port()
2033 struct bstp_state *bs = arg; in bstp_tick() local
2037 BSTP_LOCK(bs); in bstp_tick()
2039 if (bs->bs_running == 0) { in bstp_tick()
2044 if (bstp_timer_expired(&bs->bs_link_timer)) { in bstp_tick()
2045 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) in bstp_tick()
2046 bstp_ifupdstatus(bs, bp); in bstp_tick()
2047 bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER); in bstp_tick()
2050 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_tick()
2058 bstp_hello_timer_expiry(bs, bp); in bstp_tick()
2062 bstp_message_age_expiry(bs, bp); in bstp_tick()
2066 bstp_migrate_delay_expiry(bs, bp); in bstp_tick()
2070 bstp_edge_delay_expiry(bs, bp); in bstp_tick()
2074 bstp_update_state(bs, bp); in bstp_tick()
2081 BSTP_UNLOCK(bs); in bstp_tick()
2085 bsd_timeout(bstp_tick, bs, &ts); in bstp_tick()
2126 bstp_hello_timer_expiry(struct bstp_state *bs, struct bstp_port *bp) in bstp_hello_timer_expiry() argument
2134 bstp_transmit(bs, bp); in bstp_hello_timer_expiry()
2139 bstp_message_age_expiry(struct bstp_state *bs, struct bstp_port *bp) in bstp_message_age_expiry() argument
2143 bstp_assign_roles(bs); in bstp_message_age_expiry()
2149 bstp_migrate_delay_expiry(__unused struct bstp_state *bs, struct bstp_port *bp) in bstp_migrate_delay_expiry() argument
2155 bstp_edge_delay_expiry(__unused struct bstp_state *bs, struct bstp_port *bp) in bstp_edge_delay_expiry() argument
2197 bstp_reinit(struct bstp_state *bs) in bstp_reinit() argument
2204 BSTP_LOCK_ASSERT(bs); in bstp_reinit()
2234 if (LIST_EMPTY(&bs->bs_bplist) || mif == NULL) { in bstp_reinit()
2236 bs->bs_bridge_pv.pv_dbridge_id = in bstp_reinit()
2237 ((uint64_t)bs->bs_bridge_priority) << 48; in bstp_reinit()
2238 bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id; in bstp_reinit()
2239 bs->bs_root_pv = bs->bs_bridge_pv; in bstp_reinit()
2241 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_reinit()
2245 bsd_untimeout(bstp_tick, bs); in bstp_reinit()
2250 bs->bs_bridge_pv.pv_dbridge_id = in bstp_reinit()
2251 (((uint64_t)bs->bs_bridge_priority) << 48) | in bstp_reinit()
2259 bs->bs_bridge_pv.pv_root_id = bs->bs_bridge_pv.pv_dbridge_id; in bstp_reinit()
2260 bs->bs_bridge_pv.pv_cost = 0; in bstp_reinit()
2261 bs->bs_bridge_pv.pv_dport_id = 0; in bstp_reinit()
2262 bs->bs_bridge_pv.pv_port_id = 0; in bstp_reinit()
2264 if (bs->bs_running) { in bstp_reinit()
2265 bsd_untimeout(bstp_tick, bs); in bstp_reinit()
2268 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_reinit()
2271 bstp_ifupdstatus(bs, bp); in bstp_reinit()
2274 bstp_assign_roles(bs); in bstp_reinit()
2275 bstp_timer_start(&bs->bs_link_timer, BSTP_LINK_TIMER); in bstp_reinit()
2279 bstp_attach(struct bstp_state *bs, struct bstp_cb_ops *cb) in bstp_attach() argument
2281 BSTP_LOCK_INIT(bs); in bstp_attach()
2282 LIST_INIT(&bs->bs_bplist); in bstp_attach()
2284 bs->bs_bridge_max_age = BSTP_DEFAULT_MAX_AGE; in bstp_attach()
2285 bs->bs_bridge_htime = BSTP_DEFAULT_HELLO_TIME; in bstp_attach()
2286 bs->bs_bridge_fdelay = BSTP_DEFAULT_FORWARD_DELAY; in bstp_attach()
2287 bs->bs_bridge_priority = BSTP_DEFAULT_BRIDGE_PRIORITY; in bstp_attach()
2288 bs->bs_hold_time = BSTP_DEFAULT_HOLD_TIME; in bstp_attach()
2289 bs->bs_migration_delay = BSTP_DEFAULT_MIGRATE_DELAY; in bstp_attach()
2290 bs->bs_txholdcount = BSTP_DEFAULT_HOLD_COUNT; in bstp_attach()
2291 bs->bs_protover = BSTP_PROTO_RSTP; in bstp_attach()
2292 bs->bs_state_cb = cb->bcb_state; in bstp_attach()
2293 bs->bs_rtage_cb = cb->bcb_rtage; in bstp_attach()
2296 getmicrotime(&bs->bs_last_tc_time); in bstp_attach()
2299 LIST_INSERT_HEAD(&bstp_list, bs, bs_list); in bstp_attach()
2304 bstp_detach(struct bstp_state *bs) in bstp_detach() argument
2306 KASSERT(LIST_EMPTY(&bs->bs_bplist), ("bstp still active")); in bstp_detach()
2309 LIST_REMOVE(bs, bs_list); in bstp_detach()
2311 bsd_untimeout(bstp_tick, bs); in bstp_detach()
2312 BSTP_LOCK_DESTROY(bs); in bstp_detach()
2316 bstp_init(struct bstp_state *bs) in bstp_init() argument
2323 BSTP_LOCK(bs); in bstp_init()
2324 bsd_timeout(bstp_tick, bs, &ts); in bstp_init()
2325 bs->bs_running = 1; in bstp_init()
2326 bstp_reinit(bs); in bstp_init()
2327 BSTP_UNLOCK(bs); in bstp_init()
2331 bstp_stop(struct bstp_state *bs) in bstp_stop() argument
2335 BSTP_LOCK(bs); in bstp_stop()
2337 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) in bstp_stop()
2340 bs->bs_running = 0; in bstp_stop()
2341 bsd_untimeout(bstp_tick, bs); in bstp_stop()
2342 BSTP_UNLOCK(bs); in bstp_stop()
2346 bstp_create(struct bstp_state *bs, struct bstp_port *bp, struct ifnet *ifp) in bstp_create() argument
2350 BSTP_LOCK(bs); in bstp_create()
2352 bp->bp_bs = bs; in bstp_create()
2361 bstp_set_port_proto(bp, bs->bs_protover); in bstp_create()
2365 BSTP_UNLOCK(bs); in bstp_create()
2372 struct bstp_state *bs = bp->bp_bs; in bstp_enable() local
2385 BSTP_LOCK(bs); in bstp_enable()
2386 LIST_INSERT_HEAD(&bs->bs_bplist, bp, bp_next); in bstp_enable()
2389 bstp_reinit(bs); in bstp_enable()
2390 bstp_update_roles(bs, bp); in bstp_enable()
2391 BSTP_UNLOCK(bs); in bstp_enable()
2398 struct bstp_state *bs = bp->bp_bs; in bstp_disable() local
2402 BSTP_LOCK(bs); in bstp_disable()
2403 bstp_disable_port(bs, bp); in bstp_disable()
2406 bstp_reinit(bs); in bstp_disable()
2407 BSTP_UNLOCK(bs); in bstp_disable()