Lines Matching refs:bp
154 bstp_transmit(struct bstp_state *bs, struct bstp_port *bp) in bstp_transmit() argument
165 if (bp->bp_hello_timer.active == 0) { in bstp_transmit()
167 bstp_hello_timer_expiry(bs, bp); in bstp_transmit()
170 if (bp->bp_txcount > bs->bs_txholdcount) in bstp_transmit()
174 if (bp->bp_protover == BSTP_PROTO_RSTP) { in bstp_transmit()
175 bstp_transmit_bpdu(bs, bp); in bstp_transmit()
176 bp->bp_tc_ack = 0; in bstp_transmit()
178 switch (bp->bp_role) { in bstp_transmit()
180 bstp_transmit_bpdu(bs, bp); in bstp_transmit()
181 bp->bp_tc_ack = 0; in bstp_transmit()
185 bstp_transmit_tcn(bs, bp); in bstp_transmit()
189 bstp_timer_start(&bp->bp_hello_timer, bp->bp_desg_htime); in bstp_transmit()
190 bp->bp_flags &= ~BSTP_PORT_NEWINFO; in bstp_transmit()
194 bstp_transmit_bpdu(struct bstp_state *bs, struct bstp_port *bp) in bstp_transmit_bpdu() argument
200 bpdu.cbu_rootpri = htons(bp->bp_desg_pv.pv_root_id >> 48); in bstp_transmit_bpdu()
201 PV2ADDR(bp->bp_desg_pv.pv_root_id, bpdu.cbu_rootaddr); in bstp_transmit_bpdu()
203 bpdu.cbu_rootpathcost = htonl(bp->bp_desg_pv.pv_cost); in bstp_transmit_bpdu()
205 bpdu.cbu_bridgepri = htons(bp->bp_desg_pv.pv_dbridge_id >> 48); in bstp_transmit_bpdu()
206 PV2ADDR(bp->bp_desg_pv.pv_dbridge_id, bpdu.cbu_bridgeaddr); in bstp_transmit_bpdu()
208 bpdu.cbu_portid = htons(bp->bp_port_id); in bstp_transmit_bpdu()
209 bpdu.cbu_messageage = htons(bp->bp_desg_msg_age); in bstp_transmit_bpdu()
210 bpdu.cbu_maxage = htons(bp->bp_desg_max_age); in bstp_transmit_bpdu()
211 bpdu.cbu_hellotime = htons(bp->bp_desg_htime); in bstp_transmit_bpdu()
212 bpdu.cbu_forwarddelay = htons(bp->bp_desg_fdelay); in bstp_transmit_bpdu()
214 bpdu.cbu_flags = bstp_pdu_flags(bp); in bstp_transmit_bpdu()
216 switch (bp->bp_protover) { in bstp_transmit_bpdu()
226 bstp_send_bpdu(bs, bp, &bpdu); in bstp_transmit_bpdu()
230 bstp_transmit_tcn(struct bstp_state *bs, struct bstp_port *bp) in bstp_transmit_tcn() argument
233 struct ifnet *ifp = bp->bp_ifp; in bstp_transmit_tcn()
237 KASSERT(bp == bs->bs_root_port, ("%s: bad root port\n", __func__)); in bstp_transmit_tcn()
264 bp->bp_txcount++; in bstp_transmit_tcn()
269 bstp_decode_bpdu(struct bstp_port *bp, struct bstp_cbpdu *cpdu, in bstp_decode_bpdu() argument
298 cu->cu_pv.pv_port_id = bp->bp_port_id; in bstp_decode_bpdu()
342 bstp_send_bpdu(struct bstp_state *bs, struct bstp_port *bp, in bstp_send_bpdu() argument
352 ifp = bp->bp_ifp; in bstp_send_bpdu()
394 bp->bp_txcount++; in bstp_send_bpdu()
399 bstp_pdu_flags(struct bstp_port *bp) in bstp_pdu_flags() argument
403 if (bp->bp_proposing && bp->bp_state != BSTP_IFSTATE_FORWARDING) in bstp_pdu_flags()
406 if (bp->bp_agree) in bstp_pdu_flags()
409 if (bp->bp_tc_timer.active) in bstp_pdu_flags()
412 if (bp->bp_tc_ack) in bstp_pdu_flags()
415 switch (bp->bp_state) { in bstp_pdu_flags()
425 switch (bp->bp_role) { in bstp_pdu_flags()
444 switch (bp->bp_protover) { in bstp_pdu_flags()
456 bstp_input(struct bstp_port *bp, struct ifnet *ifp, struct mbuf *m) in bstp_input() argument
458 struct bstp_state *bs = bp->bp_bs; in bstp_input()
463 if (bp->bp_active == 0) { in bstp_input()
501 if (tpdu.tbu_protover != bp->bp_protover) { in bstp_input()
506 if (bp->bp_flags & BSTP_PORT_CANMIGRATE) in bstp_input()
507 bstp_set_port_proto(bp, tpdu.tbu_protover); in bstp_input()
513 bp->bp_operedge = 0; in bstp_input()
514 bstp_timer_start(&bp->bp_edge_delay_timer, in bstp_input()
519 bstp_received_stp(bs, bp, &m, &tpdu); in bstp_input()
523 bstp_received_rstp(bs, bp, &m, &tpdu); in bstp_input()
533 bstp_received_stp(struct bstp_state *bs, struct bstp_port *bp, in bstp_received_stp() argument
537 struct bstp_config_unit *cu = &bp->bp_msg_cu; in bstp_received_stp()
543 bstp_received_tcn(bs, bp, &tu); in bstp_received_stp()
551 bstp_decode_bpdu(bp, &cpdu, cu); in bstp_received_stp()
552 bstp_received_bpdu(bs, bp, cu); in bstp_received_stp()
558 bstp_received_rstp(struct bstp_state *bs, struct bstp_port *bp, in bstp_received_rstp() argument
562 struct bstp_config_unit *cu = &bp->bp_msg_cu; in bstp_received_rstp()
572 bstp_decode_bpdu(bp, &cpdu, cu); in bstp_received_rstp()
573 bstp_received_bpdu(bs, bp, cu); in bstp_received_rstp()
577 bstp_received_tcn(struct bstp_state *bs, struct bstp_port *bp, in bstp_received_tcn() argument
580 bp->bp_rcvdtcn = 1; in bstp_received_tcn()
581 bstp_update_tc(bp); in bstp_received_tcn()
585 bstp_received_bpdu(struct bstp_state *bs, struct bstp_port *bp, in bstp_received_bpdu() argument
593 switch (bp->bp_infois) { in bstp_received_bpdu()
616 type = bstp_pdu_rcvtype(bp, cu); in bstp_received_bpdu()
621 bp->bp_agreed = 0; in bstp_received_bpdu()
622 bp->bp_proposing = 0; in bstp_received_bpdu()
625 bp->bp_proposed = 1; in bstp_received_bpdu()
627 bp->bp_rcvdtc = 1; in bstp_received_bpdu()
629 bp->bp_rcvdtca = 1; in bstp_received_bpdu()
631 if (bp->bp_agree && in bstp_received_bpdu()
632 !bstp_pdu_bettersame(bp, BSTP_INFO_RECEIVED)) in bstp_received_bpdu()
633 bp->bp_agree = 0; in bstp_received_bpdu()
636 bp->bp_port_pv = cu->cu_pv; in bstp_received_bpdu()
637 bp->bp_port_msg_age = cu->cu_message_age; in bstp_received_bpdu()
638 bp->bp_port_max_age = cu->cu_max_age; in bstp_received_bpdu()
639 bp->bp_port_fdelay = cu->cu_forward_delay; in bstp_received_bpdu()
640 bp->bp_port_htime = in bstp_received_bpdu()
645 bstp_set_timer_msgage(bp); in bstp_received_bpdu()
647 bp->bp_infois = BSTP_INFO_RECEIVED; in bstp_received_bpdu()
653 bp->bp_proposed = 1; in bstp_received_bpdu()
655 bp->bp_rcvdtc = 1; in bstp_received_bpdu()
657 bp->bp_rcvdtca = 1; in bstp_received_bpdu()
660 bstp_set_timer_msgage(bp); in bstp_received_bpdu()
665 bp->bp_agreed = 1; in bstp_received_bpdu()
666 bp->bp_proposing = 0; in bstp_received_bpdu()
675 if (cu->cu_agree && bp->bp_ptp_link) { in bstp_received_bpdu()
676 bp->bp_agreed = 1; in bstp_received_bpdu()
677 bp->bp_proposing = 0; in bstp_received_bpdu()
679 bp->bp_agreed = 0; in bstp_received_bpdu()
682 bp->bp_rcvdtc = 1; in bstp_received_bpdu()
684 bp->bp_rcvdtca = 1; in bstp_received_bpdu()
691 bstp_update_state(bs, bp); in bstp_received_bpdu()
695 bstp_pdu_rcvtype(struct bstp_port *bp, struct bstp_config_unit *cu) in bstp_pdu_rcvtype() argument
704 if (bstp_info_superior(&bp->bp_port_pv, &cu->cu_pv)) in bstp_pdu_rcvtype()
707 else if (bstp_info_cmp(&bp->bp_port_pv, &cu->cu_pv) == in bstp_pdu_rcvtype()
709 if (bp->bp_port_msg_age != cu->cu_message_age || in bstp_pdu_rcvtype()
710 bp->bp_port_max_age != cu->cu_max_age || in bstp_pdu_rcvtype()
711 bp->bp_port_fdelay != cu->cu_forward_delay || in bstp_pdu_rcvtype()
712 bp->bp_port_htime != cu->cu_hello_time) in bstp_pdu_rcvtype()
727 if (bstp_info_cmp(&bp->bp_port_pv, &cu->cu_pv) <= INFO_SAME) in bstp_pdu_rcvtype()
740 bstp_pdu_bettersame(struct bstp_port *bp, int newinfo) in bstp_pdu_bettersame() argument
743 bp->bp_infois == BSTP_INFO_RECEIVED && in bstp_pdu_bettersame()
744 bstp_info_cmp(&bp->bp_port_pv, &bp->bp_msg_cu.cu_pv) >= INFO_SAME) in bstp_pdu_bettersame()
748 bp->bp_infois == BSTP_INFO_MINE && in bstp_pdu_bettersame()
749 bstp_info_cmp(&bp->bp_port_pv, &bp->bp_desg_pv) >= INFO_SAME) in bstp_pdu_bettersame()
802 struct bstp_port *bp, *rbp = NULL; in bstp_assign_roles() local
814 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_assign_roles()
815 if (bp->bp_infois != BSTP_INFO_RECEIVED) in bstp_assign_roles()
818 pv = bp->bp_port_pv; in bstp_assign_roles()
819 pv.pv_cost += bp->bp_path_cost; in bstp_assign_roles()
831 bs->bs_root_msg_age = bp->bp_port_msg_age + in bstp_assign_roles()
833 bs->bs_root_max_age = bp->bp_port_max_age; in bstp_assign_roles()
834 bs->bs_root_fdelay = bp->bp_port_fdelay; in bstp_assign_roles()
835 bs->bs_root_htime = bp->bp_port_htime; in bstp_assign_roles()
836 rbp = bp; in bstp_assign_roles()
840 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_assign_roles()
842 bp->bp_desg_pv.pv_root_id = bs->bs_root_pv.pv_root_id; in bstp_assign_roles()
843 bp->bp_desg_pv.pv_cost = bs->bs_root_pv.pv_cost; in bstp_assign_roles()
844 bp->bp_desg_pv.pv_dbridge_id = bs->bs_bridge_pv.pv_dbridge_id; in bstp_assign_roles()
845 bp->bp_desg_pv.pv_dport_id = bp->bp_port_id; in bstp_assign_roles()
846 bp->bp_desg_pv.pv_port_id = bp->bp_port_id; in bstp_assign_roles()
849 bp->bp_desg_msg_age = bs->bs_root_msg_age; in bstp_assign_roles()
850 bp->bp_desg_max_age = bs->bs_root_max_age; in bstp_assign_roles()
851 bp->bp_desg_fdelay = bs->bs_root_fdelay; in bstp_assign_roles()
852 bp->bp_desg_htime = bs->bs_bridge_htime; in bstp_assign_roles()
854 switch (bp->bp_infois) { in bstp_assign_roles()
856 bstp_set_port_role(bp, BSTP_ROLE_DISABLED); in bstp_assign_roles()
860 bstp_set_port_role(bp, BSTP_ROLE_DESIGNATED); in bstp_assign_roles()
861 bstp_update_info(bp); in bstp_assign_roles()
865 bstp_set_port_role(bp, BSTP_ROLE_DESIGNATED); in bstp_assign_roles()
867 if (bstp_info_cmp(&bp->bp_port_pv, in bstp_assign_roles()
868 &bp->bp_desg_pv) != INFO_SAME || in bstp_assign_roles()
870 (bp->bp_port_msg_age != rbp->bp_port_msg_age || in bstp_assign_roles()
871 bp->bp_port_max_age != rbp->bp_port_max_age || in bstp_assign_roles()
872 bp->bp_port_fdelay != rbp->bp_port_fdelay || in bstp_assign_roles()
873 bp->bp_port_htime != rbp->bp_port_htime))) in bstp_assign_roles()
874 bstp_update_info(bp); in bstp_assign_roles()
878 if (bp == rbp) { in bstp_assign_roles()
883 bstp_set_port_role(bp, BSTP_ROLE_ROOT); in bstp_assign_roles()
884 bs->bs_root_port = bp; in bstp_assign_roles()
885 } else if (bstp_info_cmp(&bp->bp_port_pv, in bstp_assign_roles()
886 &bp->bp_desg_pv) == INFO_BETTER) { in bstp_assign_roles()
891 bstp_set_port_role(bp, BSTP_ROLE_DESIGNATED); in bstp_assign_roles()
892 bstp_update_info(bp); in bstp_assign_roles()
895 bp->bp_port_pv.pv_dbridge_id, in bstp_assign_roles()
901 bstp_set_port_role(bp, in bstp_assign_roles()
908 bstp_set_port_role(bp, in bstp_assign_roles()
918 bstp_update_state(struct bstp_state *bs, struct bstp_port *bp) in bstp_update_state() argument
938 bstp_update_roles(bs, bp); in bstp_update_state()
939 bstp_update_tc(bp); in bstp_update_state()
943 bstp_update_roles(struct bstp_state *bs, struct bstp_port *bp) in bstp_update_roles() argument
947 switch (bp->bp_role) { in bstp_update_roles()
950 if (bp->bp_sync || !bp->bp_synced || bp->bp_reroot) { in bstp_update_roles()
951 bp->bp_sync = 0; in bstp_update_roles()
952 bp->bp_synced = 1; in bstp_update_roles()
953 bp->bp_reroot = 0; in bstp_update_roles()
959 if ((bs->bs_allsynced && !bp->bp_agree) || in bstp_update_roles()
960 (bp->bp_proposed && bp->bp_agree)) { in bstp_update_roles()
961 bp->bp_proposed = 0; in bstp_update_roles()
962 bp->bp_agree = 1; in bstp_update_roles()
963 bp->bp_flags |= BSTP_PORT_NEWINFO; in bstp_update_roles()
965 bp->bp_ifp->if_xname); in bstp_update_roles()
968 if (bp->bp_proposed && !bp->bp_agree) { in bstp_update_roles()
970 bp->bp_proposed = 0; in bstp_update_roles()
972 bp->bp_ifp->if_xname); in bstp_update_roles()
976 if (bp->bp_sync || !bp->bp_synced || bp->bp_reroot) { in bstp_update_roles()
977 bp->bp_sync = 0; in bstp_update_roles()
978 bp->bp_synced = 1; in bstp_update_roles()
979 bp->bp_reroot = 0; in bstp_update_roles()
980 DPRINTF("%s -> ALTERNATE_PORT\n", bp->bp_ifp->if_xname); in bstp_update_roles()
985 if (bp->bp_state != BSTP_IFSTATE_FORWARDING && !bp->bp_reroot) { in bstp_update_roles()
987 DPRINTF("%s -> ROOT_REROOT\n", bp->bp_ifp->if_xname); in bstp_update_roles()
990 if ((bs->bs_allsynced && !bp->bp_agree) || in bstp_update_roles()
991 (bp->bp_proposed && bp->bp_agree)) { in bstp_update_roles()
992 bp->bp_proposed = 0; in bstp_update_roles()
993 bp->bp_sync = 0; in bstp_update_roles()
994 bp->bp_agree = 1; in bstp_update_roles()
995 bp->bp_flags |= BSTP_PORT_NEWINFO; in bstp_update_roles()
996 DPRINTF("%s -> ROOT_AGREED\n", bp->bp_ifp->if_xname); in bstp_update_roles()
999 if (bp->bp_proposed && !bp->bp_agree) { in bstp_update_roles()
1001 bp->bp_proposed = 0; in bstp_update_roles()
1002 DPRINTF("%s -> ROOT_PROPOSED\n", bp->bp_ifp->if_xname); in bstp_update_roles()
1005 if (bp->bp_state != BSTP_IFSTATE_FORWARDING && in bstp_update_roles()
1006 (bp->bp_forward_delay_timer.active == 0 || in bstp_update_roles()
1007 (bstp_rerooted(bs, bp) && in bstp_update_roles()
1008 bp->bp_recent_backup_timer.active == 0 && in bstp_update_roles()
1009 bp->bp_protover == BSTP_PROTO_RSTP))) { in bstp_update_roles()
1010 switch (bp->bp_state) { in bstp_update_roles()
1012 bstp_set_port_state(bp, BSTP_IFSTATE_LEARNING); in bstp_update_roles()
1015 bstp_set_port_state(bp, in bstp_update_roles()
1021 if (bp->bp_state == BSTP_IFSTATE_FORWARDING && bp->bp_reroot) { in bstp_update_roles()
1022 bp->bp_reroot = 0; in bstp_update_roles()
1023 DPRINTF("%s -> ROOT_REROOTED\n", bp->bp_ifp->if_xname); in bstp_update_roles()
1028 if (bp->bp_recent_root_timer.active == 0 && bp->bp_reroot) { in bstp_update_roles()
1029 bp->bp_reroot = 0; in bstp_update_roles()
1031 bp->bp_ifp->if_xname); in bstp_update_roles()
1034 if ((bp->bp_state == BSTP_IFSTATE_DISCARDING && in bstp_update_roles()
1035 !bp->bp_synced) || (bp->bp_agreed && !bp->bp_synced) || in bstp_update_roles()
1036 (bp->bp_operedge && !bp->bp_synced) || in bstp_update_roles()
1037 (bp->bp_sync && bp->bp_synced)) { in bstp_update_roles()
1038 bstp_timer_stop(&bp->bp_recent_root_timer); in bstp_update_roles()
1039 bp->bp_synced = 1; in bstp_update_roles()
1040 bp->bp_sync = 0; in bstp_update_roles()
1042 bp->bp_ifp->if_xname); in bstp_update_roles()
1045 if (bp->bp_state != BSTP_IFSTATE_FORWARDING && in bstp_update_roles()
1046 !bp->bp_agreed && !bp->bp_proposing && in bstp_update_roles()
1047 !bp->bp_operedge) { in bstp_update_roles()
1048 bp->bp_proposing = 1; in bstp_update_roles()
1049 bp->bp_flags |= BSTP_PORT_NEWINFO; in bstp_update_roles()
1050 bstp_timer_start(&bp->bp_edge_delay_timer, in bstp_update_roles()
1051 (bp->bp_ptp_link ? BSTP_DEFAULT_MIGRATE_DELAY : in bstp_update_roles()
1052 bp->bp_desg_max_age)); in bstp_update_roles()
1054 bp->bp_ifp->if_xname); in bstp_update_roles()
1057 if (bp->bp_state != BSTP_IFSTATE_FORWARDING && in bstp_update_roles()
1058 (bp->bp_forward_delay_timer.active == 0 || bp->bp_agreed || in bstp_update_roles()
1059 bp->bp_operedge) && in bstp_update_roles()
1060 (bp->bp_recent_root_timer.active == 0 || !bp->bp_reroot) && in bstp_update_roles()
1061 !bp->bp_sync) { in bstp_update_roles()
1062 if (bp->bp_agreed) in bstp_update_roles()
1063 DPRINTF("%s -> AGREED\n", bp->bp_ifp->if_xname); in bstp_update_roles()
1068 if (bp->bp_agreed || bp->bp_operedge || in bstp_update_roles()
1069 bp->bp_state == BSTP_IFSTATE_LEARNING) { in bstp_update_roles()
1070 bstp_set_port_state(bp, in bstp_update_roles()
1072 bp->bp_agreed = bp->bp_protover; in bstp_update_roles()
1073 } else if (bp->bp_state == BSTP_IFSTATE_DISCARDING) in bstp_update_roles()
1074 bstp_set_port_state(bp, BSTP_IFSTATE_LEARNING); in bstp_update_roles()
1077 if (((bp->bp_sync && !bp->bp_synced) || in bstp_update_roles()
1078 (bp->bp_reroot && bp->bp_recent_root_timer.active) || in bstp_update_roles()
1079 (bp->bp_flags & BSTP_PORT_DISPUTED)) && !bp->bp_operedge && in bstp_update_roles()
1080 bp->bp_state != BSTP_IFSTATE_DISCARDING) { in bstp_update_roles()
1081 bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); in bstp_update_roles()
1082 bp->bp_flags &= ~BSTP_PORT_DISPUTED; in bstp_update_roles()
1083 bstp_timer_start(&bp->bp_forward_delay_timer, in bstp_update_roles()
1084 bp->bp_protover == BSTP_PROTO_RSTP ? in bstp_update_roles()
1085 bp->bp_desg_htime : bp->bp_desg_fdelay); in bstp_update_roles()
1087 bp->bp_ifp->if_xname); in bstp_update_roles()
1092 if (bp->bp_flags & BSTP_PORT_NEWINFO) in bstp_update_roles()
1093 bstp_transmit(bs, bp); in bstp_update_roles()
1097 bstp_update_tc(struct bstp_port *bp) in bstp_update_tc() argument
1099 switch (bp->bp_tcstate) { in bstp_update_tc()
1101 if ((bp->bp_role != BSTP_ROLE_DESIGNATED && in bstp_update_tc()
1102 bp->bp_role != BSTP_ROLE_ROOT) || bp->bp_operedge) in bstp_update_tc()
1103 bstp_set_port_tc(bp, BSTP_TCSTATE_LEARNING); in bstp_update_tc()
1105 if (bp->bp_rcvdtcn) in bstp_update_tc()
1106 bstp_set_port_tc(bp, BSTP_TCSTATE_TCN); in bstp_update_tc()
1107 if (bp->bp_rcvdtc) in bstp_update_tc()
1108 bstp_set_port_tc(bp, BSTP_TCSTATE_TC); in bstp_update_tc()
1110 if (bp->bp_tc_prop && !bp->bp_operedge) in bstp_update_tc()
1111 bstp_set_port_tc(bp, BSTP_TCSTATE_PROPAG); in bstp_update_tc()
1113 if (bp->bp_rcvdtca) in bstp_update_tc()
1114 bstp_set_port_tc(bp, BSTP_TCSTATE_ACK); in bstp_update_tc()
1118 if ((bp->bp_state == BSTP_IFSTATE_LEARNING || in bstp_update_tc()
1119 bp->bp_state == BSTP_IFSTATE_FORWARDING) && in bstp_update_tc()
1120 bp->bp_fdbflush == 0) in bstp_update_tc()
1121 bstp_set_port_tc(bp, BSTP_TCSTATE_LEARNING); in bstp_update_tc()
1125 if (bp->bp_rcvdtc || bp->bp_rcvdtcn || bp->bp_rcvdtca || in bstp_update_tc()
1126 bp->bp_tc_prop) in bstp_update_tc()
1127 bstp_set_port_tc(bp, BSTP_TCSTATE_LEARNING); in bstp_update_tc()
1128 else if (bp->bp_role != BSTP_ROLE_DESIGNATED && in bstp_update_tc()
1129 bp->bp_role != BSTP_ROLE_ROOT && in bstp_update_tc()
1130 bp->bp_state == BSTP_IFSTATE_DISCARDING) in bstp_update_tc()
1131 bstp_set_port_tc(bp, BSTP_TCSTATE_INACTIVE); in bstp_update_tc()
1133 if ((bp->bp_role == BSTP_ROLE_DESIGNATED || in bstp_update_tc()
1134 bp->bp_role == BSTP_ROLE_ROOT) && in bstp_update_tc()
1135 bp->bp_state == BSTP_IFSTATE_FORWARDING && in bstp_update_tc()
1136 !bp->bp_operedge) in bstp_update_tc()
1137 bstp_set_port_tc(bp, BSTP_TCSTATE_DETECTED); in bstp_update_tc()
1147 bp->bp_ifp->if_xname); in bstp_update_tc()
1154 bstp_update_info(struct bstp_port *bp) in bstp_update_info() argument
1156 struct bstp_state *bs = bp->bp_bs; in bstp_update_info()
1158 bp->bp_proposing = 0; in bstp_update_info()
1159 bp->bp_proposed = 0; in bstp_update_info()
1161 if (bp->bp_agreed && !bstp_pdu_bettersame(bp, BSTP_INFO_MINE)) in bstp_update_info()
1162 bp->bp_agreed = 0; in bstp_update_info()
1164 if (bp->bp_synced && !bp->bp_agreed) { in bstp_update_info()
1165 bp->bp_synced = 0; in bstp_update_info()
1170 bp->bp_port_pv = bp->bp_desg_pv; in bstp_update_info()
1171 bp->bp_port_msg_age = bp->bp_desg_msg_age; in bstp_update_info()
1172 bp->bp_port_max_age = bp->bp_desg_max_age; in bstp_update_info()
1173 bp->bp_port_fdelay = bp->bp_desg_fdelay; in bstp_update_info()
1174 bp->bp_port_htime = bp->bp_desg_htime; in bstp_update_info()
1175 bp->bp_infois = BSTP_INFO_MINE; in bstp_update_info()
1178 bp->bp_flags |= BSTP_PORT_NEWINFO; in bstp_update_info()
1183 bstp_set_other_tcprop(struct bstp_port *bp) in bstp_set_other_tcprop() argument
1185 struct bstp_state *bs = bp->bp_bs; in bstp_set_other_tcprop()
1191 if (bp2 == bp) in bstp_set_other_tcprop()
1200 struct bstp_port *bp; in bstp_set_all_reroot() local
1204 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) in bstp_set_all_reroot()
1205 bp->bp_reroot = 1; in bstp_set_all_reroot()
1211 struct bstp_port *bp; in bstp_set_all_sync() local
1215 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_set_all_sync()
1216 bp->bp_sync = 1; in bstp_set_all_sync()
1217 bp->bp_synced = 0; /* Not explicit in spec */ in bstp_set_all_sync()
1224 bstp_set_port_state(struct bstp_port *bp, int state) in bstp_set_port_state() argument
1226 if (bp->bp_state == state) in bstp_set_port_state()
1229 bp->bp_state = state; in bstp_set_port_state()
1231 switch (bp->bp_state) { in bstp_set_port_state()
1234 bp->bp_ifp->if_xname); in bstp_set_port_state()
1239 bp->bp_ifp->if_xname); in bstp_set_port_state()
1241 bstp_timer_start(&bp->bp_forward_delay_timer, in bstp_set_port_state()
1242 bp->bp_protover == BSTP_PROTO_RSTP ? in bstp_set_port_state()
1243 bp->bp_desg_htime : bp->bp_desg_fdelay); in bstp_set_port_state()
1248 bp->bp_ifp->if_xname); in bstp_set_port_state()
1250 bstp_timer_stop(&bp->bp_forward_delay_timer); in bstp_set_port_state()
1252 bp->bp_forward_transitions++; in bstp_set_port_state()
1257 taskqueue_enqueue(taskqueue_swi, &bp->bp_statetask); in bstp_set_port_state()
1261 bstp_set_port_role(struct bstp_port *bp, int role) in bstp_set_port_role() argument
1263 struct bstp_state *bs = bp->bp_bs; in bstp_set_port_role()
1265 if (bp->bp_role == role) in bstp_set_port_role()
1269 switch (bp->bp_role) { in bstp_set_port_role()
1271 bstp_timer_start(&bp->bp_forward_delay_timer, in bstp_set_port_role()
1272 bp->bp_desg_max_age); in bstp_set_port_role()
1276 bstp_timer_start(&bp->bp_recent_backup_timer, in bstp_set_port_role()
1277 bp->bp_desg_htime * 2); in bstp_set_port_role()
1280 bstp_timer_start(&bp->bp_forward_delay_timer, in bstp_set_port_role()
1281 bp->bp_desg_fdelay); in bstp_set_port_role()
1282 bp->bp_sync = 0; in bstp_set_port_role()
1283 bp->bp_synced = 1; in bstp_set_port_role()
1284 bp->bp_reroot = 0; in bstp_set_port_role()
1288 bstp_timer_start(&bp->bp_recent_root_timer, in bstp_set_port_role()
1293 bp->bp_role = role; in bstp_set_port_role()
1295 bp->bp_proposing = 0; in bstp_set_port_role()
1299 switch (bp->bp_role) { in bstp_set_port_role()
1304 bp->bp_ifp->if_xname); in bstp_set_port_role()
1305 bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); in bstp_set_port_role()
1306 bstp_timer_stop(&bp->bp_recent_root_timer); in bstp_set_port_role()
1307 bstp_timer_latch(&bp->bp_forward_delay_timer); in bstp_set_port_role()
1308 bp->bp_sync = 0; in bstp_set_port_role()
1309 bp->bp_synced = 1; in bstp_set_port_role()
1310 bp->bp_reroot = 0; in bstp_set_port_role()
1315 bp->bp_ifp->if_xname); in bstp_set_port_role()
1316 bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); in bstp_set_port_role()
1317 bstp_timer_latch(&bp->bp_recent_root_timer); in bstp_set_port_role()
1318 bp->bp_proposing = 0; in bstp_set_port_role()
1323 bp->bp_ifp->if_xname); in bstp_set_port_role()
1324 bstp_timer_start(&bp->bp_hello_timer, in bstp_set_port_role()
1325 bp->bp_desg_htime); in bstp_set_port_role()
1326 bp->bp_agree = 0; in bstp_set_port_role()
1331 bstp_update_tc(bp); in bstp_set_port_role()
1335 bstp_set_port_proto(struct bstp_port *bp, int proto) in bstp_set_port_proto() argument
1337 struct bstp_state *bs = bp->bp_bs; in bstp_set_port_proto()
1343 bstp_timer_stop(&bp->bp_migrate_delay_timer); in bstp_set_port_proto()
1345 bp->bp_operedge = 0; in bstp_set_port_proto()
1347 if (bp->bp_path_cost > 65535) in bstp_set_port_proto()
1348 bp->bp_path_cost = 65535; in bstp_set_port_proto()
1352 bstp_timer_start(&bp->bp_migrate_delay_timer, in bstp_set_port_proto()
1361 bp->bp_protover = proto; in bstp_set_port_proto()
1362 bp->bp_flags &= ~BSTP_PORT_CANMIGRATE; in bstp_set_port_proto()
1366 bstp_set_port_tc(struct bstp_port *bp, int state) in bstp_set_port_tc() argument
1368 struct bstp_state *bs = bp->bp_bs; in bstp_set_port_tc()
1370 bp->bp_tcstate = state; in bstp_set_port_tc()
1373 switch (bp->bp_tcstate) { in bstp_set_port_tc()
1375 DPRINTF("%s -> TC_ACTIVE\n", bp->bp_ifp->if_xname); in bstp_set_port_tc()
1380 bstp_timer_stop(&bp->bp_tc_timer); in bstp_set_port_tc()
1382 bp->bp_fdbflush = 1; in bstp_set_port_tc()
1383 taskqueue_enqueue(taskqueue_swi, &bp->bp_rtagetask); in bstp_set_port_tc()
1384 bp->bp_tc_ack = 0; in bstp_set_port_tc()
1385 DPRINTF("%s -> TC_INACTIVE\n", bp->bp_ifp->if_xname); in bstp_set_port_tc()
1389 bp->bp_rcvdtc = 0; in bstp_set_port_tc()
1390 bp->bp_rcvdtcn = 0; in bstp_set_port_tc()
1391 bp->bp_rcvdtca = 0; in bstp_set_port_tc()
1392 bp->bp_tc_prop = 0; in bstp_set_port_tc()
1393 DPRINTF("%s -> TC_LEARNING\n", bp->bp_ifp->if_xname); in bstp_set_port_tc()
1397 bstp_set_timer_tc(bp); in bstp_set_port_tc()
1398 bstp_set_other_tcprop(bp); in bstp_set_port_tc()
1400 bp->bp_flags |= BSTP_PORT_NEWINFO; in bstp_set_port_tc()
1401 bstp_transmit(bs, bp); in bstp_set_port_tc()
1403 DPRINTF("%s -> TC_DETECTED\n", bp->bp_ifp->if_xname); in bstp_set_port_tc()
1404 bp->bp_tcstate = BSTP_TCSTATE_ACTIVE; /* UCT */ in bstp_set_port_tc()
1408 bstp_set_timer_tc(bp); in bstp_set_port_tc()
1409 DPRINTF("%s -> TC_TCN\n", bp->bp_ifp->if_xname); in bstp_set_port_tc()
1412 bp->bp_rcvdtc = 0; in bstp_set_port_tc()
1413 bp->bp_rcvdtcn = 0; in bstp_set_port_tc()
1414 if (bp->bp_role == BSTP_ROLE_DESIGNATED) in bstp_set_port_tc()
1415 bp->bp_tc_ack = 1; in bstp_set_port_tc()
1417 bstp_set_other_tcprop(bp); in bstp_set_port_tc()
1418 DPRINTF("%s -> TC_TC\n", bp->bp_ifp->if_xname); in bstp_set_port_tc()
1419 bp->bp_tcstate = BSTP_TCSTATE_ACTIVE; /* UCT */ in bstp_set_port_tc()
1424 bp->bp_fdbflush = 1; in bstp_set_port_tc()
1425 taskqueue_enqueue(taskqueue_swi, &bp->bp_rtagetask); in bstp_set_port_tc()
1426 bp->bp_tc_prop = 0; in bstp_set_port_tc()
1427 bstp_set_timer_tc(bp); in bstp_set_port_tc()
1428 DPRINTF("%s -> TC_PROPAG\n", bp->bp_ifp->if_xname); in bstp_set_port_tc()
1429 bp->bp_tcstate = BSTP_TCSTATE_ACTIVE; /* UCT */ in bstp_set_port_tc()
1433 bstp_timer_stop(&bp->bp_tc_timer); in bstp_set_port_tc()
1434 bp->bp_rcvdtca = 0; in bstp_set_port_tc()
1435 DPRINTF("%s -> TC_ACK\n", bp->bp_ifp->if_xname); in bstp_set_port_tc()
1436 bp->bp_tcstate = BSTP_TCSTATE_ACTIVE; /* UCT */ in bstp_set_port_tc()
1442 bstp_set_timer_tc(struct bstp_port *bp) in bstp_set_timer_tc() argument
1444 struct bstp_state *bs = bp->bp_bs; in bstp_set_timer_tc()
1446 if (bp->bp_tc_timer.active) in bstp_set_timer_tc()
1449 switch (bp->bp_protover) { in bstp_set_timer_tc()
1451 bstp_timer_start(&bp->bp_tc_timer, in bstp_set_timer_tc()
1452 bp->bp_desg_htime + BSTP_TICK_VAL); in bstp_set_timer_tc()
1453 bp->bp_flags |= BSTP_PORT_NEWINFO; in bstp_set_timer_tc()
1457 bstp_timer_start(&bp->bp_tc_timer, in bstp_set_timer_tc()
1464 bstp_set_timer_msgage(struct bstp_port *bp) in bstp_set_timer_msgage() argument
1466 if (bp->bp_port_msg_age + BSTP_MESSAGE_AGE_INCR <= in bstp_set_timer_msgage()
1467 bp->bp_port_max_age) { in bstp_set_timer_msgage()
1468 bstp_timer_start(&bp->bp_message_age_timer, in bstp_set_timer_msgage()
1469 bp->bp_port_htime * 3); in bstp_set_timer_msgage()
1472 bstp_timer_start(&bp->bp_message_age_timer, 0); in bstp_set_timer_msgage()
1476 bstp_rerooted(struct bstp_state *bs, struct bstp_port *bp) in bstp_rerooted() argument
1482 if (bp2 == bp) in bstp_rerooted()
1547 struct bstp_port *bp; in bstp_set_holdcount() local
1555 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) in bstp_set_holdcount()
1556 bp->bp_txcount = 0; in bstp_set_holdcount()
1564 struct bstp_port *bp; in bstp_set_protocol() local
1579 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_set_protocol()
1581 bp->bp_infois = BSTP_INFO_DISABLED; in bstp_set_protocol()
1582 bp->bp_txcount = 0; in bstp_set_protocol()
1583 bstp_set_port_proto(bp, bs->bs_protover); in bstp_set_protocol()
1584 bstp_set_port_role(bp, BSTP_ROLE_DISABLED); in bstp_set_protocol()
1585 bstp_set_port_tc(bp, BSTP_TCSTATE_INACTIVE); in bstp_set_protocol()
1586 bstp_timer_stop(&bp->bp_recent_backup_timer); in bstp_set_protocol()
1610 bstp_set_port_priority(struct bstp_port *bp, int pri) in bstp_set_port_priority() argument
1612 struct bstp_state *bs = bp->bp_bs; in bstp_set_port_priority()
1621 bp->bp_priority = pri; in bstp_set_port_priority()
1628 bstp_set_path_cost(struct bstp_port *bp, uint32_t path_cost) in bstp_set_path_cost() argument
1630 struct bstp_state *bs = bp->bp_bs; in bstp_set_path_cost()
1636 if (bp->bp_protover == BSTP_PROTO_STP && path_cost > 65535) in bstp_set_path_cost()
1642 bp->bp_flags &= ~BSTP_PORT_ADMCOST; in bstp_set_path_cost()
1643 bp->bp_path_cost = bstp_calc_path_cost(bp); in bstp_set_path_cost()
1645 bp->bp_path_cost = path_cost; in bstp_set_path_cost()
1646 bp->bp_flags |= BSTP_PORT_ADMCOST; in bstp_set_path_cost()
1654 bstp_set_edge(struct bstp_port *bp, int set) in bstp_set_edge() argument
1656 struct bstp_state *bs = bp->bp_bs; in bstp_set_edge()
1659 if ((bp->bp_operedge = set) == 0) in bstp_set_edge()
1660 bp->bp_flags &= ~BSTP_PORT_ADMEDGE; in bstp_set_edge()
1662 bp->bp_flags |= BSTP_PORT_ADMEDGE; in bstp_set_edge()
1668 bstp_set_autoedge(struct bstp_port *bp, int set) in bstp_set_autoedge() argument
1670 struct bstp_state *bs = bp->bp_bs; in bstp_set_autoedge()
1674 bp->bp_flags |= BSTP_PORT_AUTOEDGE; in bstp_set_autoedge()
1676 if (bp->bp_edge_delay_timer.active == 0) in bstp_set_autoedge()
1677 bstp_edge_delay_expiry(bs, bp); in bstp_set_autoedge()
1679 bp->bp_flags &= ~BSTP_PORT_AUTOEDGE; in bstp_set_autoedge()
1685 bstp_set_ptp(struct bstp_port *bp, int set) in bstp_set_ptp() argument
1687 struct bstp_state *bs = bp->bp_bs; in bstp_set_ptp()
1690 bp->bp_ptp_link = set; in bstp_set_ptp()
1696 bstp_set_autoptp(struct bstp_port *bp, int set) in bstp_set_autoptp() argument
1698 struct bstp_state *bs = bp->bp_bs; in bstp_set_autoptp()
1702 bp->bp_flags |= BSTP_PORT_AUTOPTP; in bstp_set_autoptp()
1703 if (bp->bp_role != BSTP_ROLE_DISABLED) in bstp_set_autoptp()
1704 taskqueue_enqueue(taskqueue_swi, &bp->bp_mediatask); in bstp_set_autoptp()
1706 bp->bp_flags &= ~BSTP_PORT_AUTOPTP; in bstp_set_autoptp()
1715 bstp_calc_path_cost(struct bstp_port *bp) in bstp_calc_path_cost() argument
1717 struct ifnet *ifp = bp->bp_ifp; in bstp_calc_path_cost()
1721 if (bp->bp_flags & BSTP_PORT_ADMCOST) in bstp_calc_path_cost()
1722 return bp->bp_path_cost; in bstp_calc_path_cost()
1726 bp->bp_flags |= BSTP_PORT_PNDCOST; in bstp_calc_path_cost()
1740 if (bp->bp_protover == BSTP_PROTO_STP && path_cost > 65535) in bstp_calc_path_cost()
1753 struct bstp_port *bp = (struct bstp_port *)arg; in bstp_notify_state() local
1754 struct bstp_state *bs = bp->bp_bs; in bstp_notify_state()
1756 if (bp->bp_active == 1 && bs->bs_state_cb != NULL) in bstp_notify_state()
1757 (*bs->bs_state_cb)(bp->bp_ifp, bp->bp_state); in bstp_notify_state()
1767 struct bstp_port *bp = (struct bstp_port *)arg; in bstp_notify_rtage() local
1768 struct bstp_state *bs = bp->bp_bs; in bstp_notify_rtage()
1772 switch (bp->bp_protover) { in bstp_notify_rtage()
1775 age = bp->bp_desg_fdelay / BSTP_TICK_VAL; in bstp_notify_rtage()
1784 if (bp->bp_active == 1 && bs->bs_rtage_cb != NULL) in bstp_notify_rtage()
1785 (*bs->bs_rtage_cb)(bp->bp_ifp, age); in bstp_notify_rtage()
1789 bp->bp_fdbflush = 0; in bstp_notify_rtage()
1794 bstp_linkstate(struct bstp_port *bp) in bstp_linkstate() argument
1796 struct bstp_state *bs = bp->bp_bs; in bstp_linkstate()
1798 if (!bp->bp_active) in bstp_linkstate()
1801 bstp_ifupdstatus(bp, 0); in bstp_linkstate()
1803 bstp_update_state(bs, bp); in bstp_linkstate()
1810 struct bstp_port *bp = (struct bstp_port *)arg; in bstp_ifupdstatus() local
1811 struct bstp_state *bs = bp->bp_bs; in bstp_ifupdstatus()
1812 struct ifnet *ifp = bp->bp_ifp; in bstp_ifupdstatus()
1816 if (!bp->bp_active) in bstp_ifupdstatus()
1827 if (bp->bp_flags & BSTP_PORT_AUTOPTP) { in bstp_ifupdstatus()
1831 if (bp->bp_ptp_link ^ fdx) { in bstp_ifupdstatus()
1832 bp->bp_ptp_link = fdx; in bstp_ifupdstatus()
1838 if (bp->bp_flags & BSTP_PORT_PNDCOST) { in bstp_ifupdstatus()
1841 cost = bstp_calc_path_cost(bp); in bstp_ifupdstatus()
1842 if (bp->bp_path_cost != cost) { in bstp_ifupdstatus()
1843 bp->bp_path_cost = cost; in bstp_ifupdstatus()
1846 bp->bp_flags &= ~BSTP_PORT_PNDCOST; in bstp_ifupdstatus()
1849 if (bp->bp_role == BSTP_ROLE_DISABLED) { in bstp_ifupdstatus()
1850 bstp_enable_port(bs, bp); in bstp_ifupdstatus()
1854 if (bp->bp_role != BSTP_ROLE_DISABLED) { in bstp_ifupdstatus()
1855 bstp_disable_port(bs, bp); in bstp_ifupdstatus()
1857 if ((bp->bp_flags & BSTP_PORT_ADMEDGE) && in bstp_ifupdstatus()
1858 bp->bp_protover == BSTP_PROTO_RSTP) in bstp_ifupdstatus()
1859 bp->bp_operedge = 1; in bstp_ifupdstatus()
1862 } else if (bp->bp_infois != BSTP_INFO_DISABLED) { in bstp_ifupdstatus()
1863 bstp_disable_port(bs, bp); in bstp_ifupdstatus()
1872 bstp_enable_port(struct bstp_state *bs, struct bstp_port *bp) in bstp_enable_port() argument
1874 bp->bp_infois = BSTP_INFO_AGED; in bstp_enable_port()
1878 bstp_disable_port(struct bstp_state *bs, struct bstp_port *bp) in bstp_disable_port() argument
1880 bp->bp_infois = BSTP_INFO_DISABLED; in bstp_disable_port()
1888 struct bstp_port *bp; in bstp_tick() local
1900 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_tick()
1901 if (!(bp->bp_ifp->if_capabilities & IFCAP_LINKSTATE)) in bstp_tick()
1902 taskqueue_enqueue(taskqueue_swi, &bp->bp_mediatask); in bstp_tick()
1907 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_tick()
1909 bstp_timer_dectest(&bp->bp_tc_timer); in bstp_tick()
1910 bstp_timer_dectest(&bp->bp_recent_root_timer); in bstp_tick()
1911 bstp_timer_dectest(&bp->bp_forward_delay_timer); in bstp_tick()
1912 bstp_timer_dectest(&bp->bp_recent_backup_timer); in bstp_tick()
1914 if (bstp_timer_dectest(&bp->bp_hello_timer)) in bstp_tick()
1915 bstp_hello_timer_expiry(bs, bp); in bstp_tick()
1917 if (bstp_timer_dectest(&bp->bp_message_age_timer)) in bstp_tick()
1918 bstp_message_age_expiry(bs, bp); in bstp_tick()
1920 if (bstp_timer_dectest(&bp->bp_migrate_delay_timer)) in bstp_tick()
1921 bstp_migrate_delay_expiry(bs, bp); in bstp_tick()
1923 if (bstp_timer_dectest(&bp->bp_edge_delay_timer)) in bstp_tick()
1924 bstp_edge_delay_expiry(bs, bp); in bstp_tick()
1927 bstp_update_state(bs, bp); in bstp_tick()
1929 if (bp->bp_txcount > 0) in bstp_tick()
1930 bp->bp_txcount--; in bstp_tick()
1976 bstp_hello_timer_expiry(struct bstp_state *bs, struct bstp_port *bp) in bstp_hello_timer_expiry() argument
1978 if ((bp->bp_flags & BSTP_PORT_NEWINFO) || in bstp_hello_timer_expiry()
1979 bp->bp_role == BSTP_ROLE_DESIGNATED || in bstp_hello_timer_expiry()
1980 (bp->bp_role == BSTP_ROLE_ROOT && in bstp_hello_timer_expiry()
1981 bp->bp_tc_timer.active == 1)) { in bstp_hello_timer_expiry()
1982 bstp_timer_start(&bp->bp_hello_timer, bp->bp_desg_htime); in bstp_hello_timer_expiry()
1983 bp->bp_flags |= BSTP_PORT_NEWINFO; in bstp_hello_timer_expiry()
1984 bstp_transmit(bs, bp); in bstp_hello_timer_expiry()
1989 bstp_message_age_expiry(struct bstp_state *bs, struct bstp_port *bp) in bstp_message_age_expiry() argument
1991 if (bp->bp_infois == BSTP_INFO_RECEIVED) { in bstp_message_age_expiry()
1992 bp->bp_infois = BSTP_INFO_AGED; in bstp_message_age_expiry()
1994 DPRINTF("aged info on %s\n", bp->bp_ifp->if_xname); in bstp_message_age_expiry()
1999 bstp_migrate_delay_expiry(struct bstp_state *bs, struct bstp_port *bp) in bstp_migrate_delay_expiry() argument
2001 bp->bp_flags |= BSTP_PORT_CANMIGRATE; in bstp_migrate_delay_expiry()
2005 bstp_edge_delay_expiry(struct bstp_state *bs, struct bstp_port *bp) in bstp_edge_delay_expiry() argument
2007 if ((bp->bp_flags & BSTP_PORT_AUTOEDGE) && in bstp_edge_delay_expiry()
2008 bp->bp_protover == BSTP_PROTO_RSTP && bp->bp_proposing && in bstp_edge_delay_expiry()
2009 bp->bp_role == BSTP_ROLE_DESIGNATED) { in bstp_edge_delay_expiry()
2010 bp->bp_operedge = 1; in bstp_edge_delay_expiry()
2011 DPRINTF("%s -> edge port\n", bp->bp_ifp->if_xname); in bstp_edge_delay_expiry()
2049 struct bstp_port *bp; in bstp_reinit() local
2112 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_reinit()
2113 bp->bp_port_id = (bp->bp_priority << 8) | in bstp_reinit()
2114 (bp->bp_ifp->if_index & 0xfff); in bstp_reinit()
2115 taskqueue_enqueue(taskqueue_swi, &bp->bp_mediatask); in bstp_reinit()
2129 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) { in bstp_reinit()
2130 bp->bp_infois = BSTP_INFO_DISABLED; in bstp_reinit()
2131 bstp_set_port_role(bp, BSTP_ROLE_DISABLED); in bstp_reinit()
2212 struct bstp_port *bp; in bstp_stop() local
2216 LIST_FOREACH(bp, &bs->bs_bplist, bp_next) in bstp_stop()
2217 bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); in bstp_stop()
2225 bstp_create(struct bstp_state *bs, struct bstp_port *bp, struct ifnet *ifp) in bstp_create() argument
2227 bzero(bp, sizeof(struct bstp_port)); in bstp_create()
2230 bp->bp_ifp = ifp; in bstp_create()
2231 bp->bp_bs = bs; in bstp_create()
2232 bp->bp_priority = BSTP_DEFAULT_PORT_PRIORITY; in bstp_create()
2233 TASK_INIT(&bp->bp_statetask, 0, bstp_notify_state, bp); in bstp_create()
2234 TASK_INIT(&bp->bp_rtagetask, 0, bstp_notify_rtage, bp); in bstp_create()
2235 TASK_INIT(&bp->bp_mediatask, 0, bstp_ifupdstatus, bp); in bstp_create()
2238 bp->bp_infois = BSTP_INFO_DISABLED; in bstp_create()
2239 bp->bp_flags = BSTP_PORT_AUTOEDGE|BSTP_PORT_AUTOPTP; in bstp_create()
2240 bstp_set_port_state(bp, BSTP_IFSTATE_DISCARDING); in bstp_create()
2241 bstp_set_port_proto(bp, bs->bs_protover); in bstp_create()
2242 bstp_set_port_role(bp, BSTP_ROLE_DISABLED); in bstp_create()
2243 bstp_set_port_tc(bp, BSTP_TCSTATE_INACTIVE); in bstp_create()
2244 bp->bp_path_cost = bstp_calc_path_cost(bp); in bstp_create()
2250 bstp_enable(struct bstp_port *bp) in bstp_enable() argument
2252 struct bstp_state *bs = bp->bp_bs; in bstp_enable()
2253 struct ifnet *ifp = bp->bp_ifp; in bstp_enable()
2255 KASSERT(bp->bp_active == 0, ("already a bstp member")); in bstp_enable()
2268 LIST_INSERT_HEAD(&bs->bs_bplist, bp, bp_next); in bstp_enable()
2269 bp->bp_active = 1; in bstp_enable()
2270 bp->bp_flags |= BSTP_PORT_NEWINFO; in bstp_enable()
2272 bstp_update_roles(bs, bp); in bstp_enable()
2278 bstp_disable(struct bstp_port *bp) in bstp_disable() argument
2280 struct bstp_state *bs = bp->bp_bs; in bstp_disable()
2282 KASSERT(bp->bp_active == 1, ("not a bstp member")); in bstp_disable()
2285 bstp_disable_port(bs, bp); in bstp_disable()
2286 LIST_REMOVE(bp, bp_next); in bstp_disable()
2287 bp->bp_active = 0; in bstp_disable()
2296 bstp_destroy(struct bstp_port *bp) in bstp_destroy() argument
2298 KASSERT(bp->bp_active == 0, ("port is still attached")); in bstp_destroy()
2299 taskqueue_drain(taskqueue_swi, &bp->bp_statetask); in bstp_destroy()
2300 taskqueue_drain(taskqueue_swi, &bp->bp_rtagetask); in bstp_destroy()
2301 taskqueue_drain(taskqueue_swi, &bp->bp_mediatask); in bstp_destroy()
2303 if (bp->bp_bs->bs_root_port == bp) in bstp_destroy()
2304 bstp_assign_roles(bp->bp_bs); in bstp_destroy()