196e47153SAndrew Thompson /* $NetBSD: if_bridgevar.h,v 1.4 2003/07/08 07:13:50 itojun Exp $ */ 296e47153SAndrew Thompson 3*fe267a55SPedro F. Giffuni /*- 4*fe267a55SPedro F. Giffuni * SPDX-License-Identifier: BSD-4-Clause 5*fe267a55SPedro F. Giffuni * 696e47153SAndrew Thompson * Copyright 2001 Wasabi Systems, Inc. 796e47153SAndrew Thompson * All rights reserved. 896e47153SAndrew Thompson * 996e47153SAndrew Thompson * Written by Jason R. Thorpe for Wasabi Systems, Inc. 1096e47153SAndrew Thompson * 1196e47153SAndrew Thompson * Redistribution and use in source and binary forms, with or without 1296e47153SAndrew Thompson * modification, are permitted provided that the following conditions 1396e47153SAndrew Thompson * are met: 1496e47153SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 1596e47153SAndrew Thompson * notice, this list of conditions and the following disclaimer. 1696e47153SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 1796e47153SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 1896e47153SAndrew Thompson * documentation and/or other materials provided with the distribution. 1996e47153SAndrew Thompson * 3. All advertising materials mentioning features or use of this software 2096e47153SAndrew Thompson * must display the following acknowledgement: 2196e47153SAndrew Thompson * This product includes software developed for the NetBSD Project by 2296e47153SAndrew Thompson * Wasabi Systems, Inc. 2396e47153SAndrew Thompson * 4. The name of Wasabi Systems, Inc. may not be used to endorse 2496e47153SAndrew Thompson * or promote products derived from this software without specific prior 2596e47153SAndrew Thompson * written permission. 2696e47153SAndrew Thompson * 2796e47153SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 2896e47153SAndrew Thompson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 2996e47153SAndrew Thompson * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 3096e47153SAndrew Thompson * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 3196e47153SAndrew Thompson * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 3296e47153SAndrew Thompson * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 3396e47153SAndrew Thompson * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 3496e47153SAndrew Thompson * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 3596e47153SAndrew Thompson * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 3696e47153SAndrew Thompson * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 3796e47153SAndrew Thompson * POSSIBILITY OF SUCH DAMAGE. 3896e47153SAndrew Thompson */ 3996e47153SAndrew Thompson 40*fe267a55SPedro F. Giffuni /*- 4196e47153SAndrew Thompson * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) 4296e47153SAndrew Thompson * All rights reserved. 4396e47153SAndrew Thompson * 4496e47153SAndrew Thompson * Redistribution and use in source and binary forms, with or without 4596e47153SAndrew Thompson * modification, are permitted provided that the following conditions 4696e47153SAndrew Thompson * are met: 4796e47153SAndrew Thompson * 1. Redistributions of source code must retain the above copyright 4896e47153SAndrew Thompson * notice, this list of conditions and the following disclaimer. 4996e47153SAndrew Thompson * 2. Redistributions in binary form must reproduce the above copyright 5096e47153SAndrew Thompson * notice, this list of conditions and the following disclaimer in the 5196e47153SAndrew Thompson * documentation and/or other materials provided with the distribution. 5296e47153SAndrew Thompson * 3. All advertising materials mentioning features or use of this software 5396e47153SAndrew Thompson * must display the following acknowledgement: 5496e47153SAndrew Thompson * This product includes software developed by Jason L. Wright 5596e47153SAndrew Thompson * 4. The name of the author may not be used to endorse or promote products 5696e47153SAndrew Thompson * derived from this software without specific prior written permission. 5796e47153SAndrew Thompson * 5896e47153SAndrew Thompson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 5996e47153SAndrew Thompson * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 6096e47153SAndrew Thompson * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 6196e47153SAndrew Thompson * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 6296e47153SAndrew Thompson * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 6396e47153SAndrew Thompson * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 6496e47153SAndrew Thompson * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 6596e47153SAndrew Thompson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 6696e47153SAndrew Thompson * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 6796e47153SAndrew Thompson * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 6896e47153SAndrew Thompson * POSSIBILITY OF SUCH DAMAGE. 6996e47153SAndrew Thompson * 7096e47153SAndrew Thompson * OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp 7196e47153SAndrew Thompson */ 7296e47153SAndrew Thompson 7396e47153SAndrew Thompson /* 7496e47153SAndrew Thompson * Data structure and control definitions for STP interfaces. 7596e47153SAndrew Thompson */ 7696e47153SAndrew Thompson 7796e47153SAndrew Thompson #include <sys/callout.h> 7896e47153SAndrew Thompson #include <sys/queue.h> 7996e47153SAndrew Thompson 8096e47153SAndrew Thompson /* STP port states */ 8196e47153SAndrew Thompson #define BSTP_IFSTATE_DISABLED 0 8296e47153SAndrew Thompson #define BSTP_IFSTATE_LISTENING 1 8396e47153SAndrew Thompson #define BSTP_IFSTATE_LEARNING 2 8496e47153SAndrew Thompson #define BSTP_IFSTATE_FORWARDING 3 8596e47153SAndrew Thompson #define BSTP_IFSTATE_BLOCKING 4 863fab7669SAndrew Thompson #define BSTP_IFSTATE_DISCARDING 5 873fab7669SAndrew Thompson 883fab7669SAndrew Thompson #define BSTP_TCSTATE_ACTIVE 1 893fab7669SAndrew Thompson #define BSTP_TCSTATE_DETECTED 2 903fab7669SAndrew Thompson #define BSTP_TCSTATE_INACTIVE 3 913fab7669SAndrew Thompson #define BSTP_TCSTATE_LEARNING 4 923fab7669SAndrew Thompson #define BSTP_TCSTATE_PROPAG 5 933fab7669SAndrew Thompson #define BSTP_TCSTATE_ACK 6 943fab7669SAndrew Thompson #define BSTP_TCSTATE_TC 7 953fab7669SAndrew Thompson #define BSTP_TCSTATE_TCN 8 963fab7669SAndrew Thompson 973fab7669SAndrew Thompson #define BSTP_ROLE_DISABLED 0 983fab7669SAndrew Thompson #define BSTP_ROLE_ROOT 1 993fab7669SAndrew Thompson #define BSTP_ROLE_DESIGNATED 2 1003fab7669SAndrew Thompson #define BSTP_ROLE_ALTERNATE 3 1013fab7669SAndrew Thompson #define BSTP_ROLE_BACKUP 4 10296e47153SAndrew Thompson 10396e47153SAndrew Thompson #ifdef _KERNEL 10496e47153SAndrew Thompson 1053fab7669SAndrew Thompson /* STP port flags */ 1063fab7669SAndrew Thompson #define BSTP_PORT_CANMIGRATE 0x0001 1073fab7669SAndrew Thompson #define BSTP_PORT_NEWINFO 0x0002 1083fab7669SAndrew Thompson #define BSTP_PORT_DISPUTED 0x0004 1093fab7669SAndrew Thompson #define BSTP_PORT_ADMCOST 0x0008 1103fab7669SAndrew Thompson #define BSTP_PORT_AUTOEDGE 0x0010 11178709605SAndrew Thompson #define BSTP_PORT_AUTOPTP 0x0020 112daacddcaSShteryana Shopova #define BSTP_PORT_ADMEDGE 0x0040 113dd040130SAndrew Thompson #define BSTP_PORT_PNDCOST 0x0080 1143fab7669SAndrew Thompson 1153fab7669SAndrew Thompson /* BPDU priority */ 1163fab7669SAndrew Thompson #define BSTP_PDU_SUPERIOR 1 1173fab7669SAndrew Thompson #define BSTP_PDU_REPEATED 2 1183fab7669SAndrew Thompson #define BSTP_PDU_INFERIOR 3 1193fab7669SAndrew Thompson #define BSTP_PDU_INFERIORALT 4 1203fab7669SAndrew Thompson #define BSTP_PDU_OTHER 5 1213fab7669SAndrew Thompson 1223fab7669SAndrew Thompson /* BPDU flags */ 1233fab7669SAndrew Thompson #define BSTP_PDU_PRMASK 0x0c /* Port Role */ 1243fab7669SAndrew Thompson #define BSTP_PDU_PRSHIFT 2 /* Port Role offset */ 1253fab7669SAndrew Thompson #define BSTP_PDU_F_UNKN 0x00 /* Unknown port (00) */ 1263fab7669SAndrew Thompson #define BSTP_PDU_F_ALT 0x01 /* Alt/Backup port (01) */ 1273fab7669SAndrew Thompson #define BSTP_PDU_F_ROOT 0x02 /* Root port (10) */ 1283fab7669SAndrew Thompson #define BSTP_PDU_F_DESG 0x03 /* Designated port (11) */ 1293fab7669SAndrew Thompson 1303fab7669SAndrew Thompson #define BSTP_PDU_STPMASK 0x81 /* strip unused STP flags */ 1313fab7669SAndrew Thompson #define BSTP_PDU_RSTPMASK 0x7f /* strip unused RSTP flags */ 1323fab7669SAndrew Thompson #define BSTP_PDU_F_TC 0x01 /* Topology change */ 1333fab7669SAndrew Thompson #define BSTP_PDU_F_P 0x02 /* Proposal flag */ 1343fab7669SAndrew Thompson #define BSTP_PDU_F_L 0x10 /* Learning flag */ 1353fab7669SAndrew Thompson #define BSTP_PDU_F_F 0x20 /* Forwarding flag */ 1363fab7669SAndrew Thompson #define BSTP_PDU_F_A 0x40 /* Agreement flag */ 1373fab7669SAndrew Thompson #define BSTP_PDU_F_TCA 0x80 /* Topology change ack */ 1383fab7669SAndrew Thompson 13996e47153SAndrew Thompson /* 14096e47153SAndrew Thompson * Spanning tree defaults. 14196e47153SAndrew Thompson */ 14296e47153SAndrew Thompson #define BSTP_DEFAULT_MAX_AGE (20 * 256) 14396e47153SAndrew Thompson #define BSTP_DEFAULT_HELLO_TIME (2 * 256) 14496e47153SAndrew Thompson #define BSTP_DEFAULT_FORWARD_DELAY (15 * 256) 14596e47153SAndrew Thompson #define BSTP_DEFAULT_HOLD_TIME (1 * 256) 1463fab7669SAndrew Thompson #define BSTP_DEFAULT_MIGRATE_DELAY (3 * 256) 1473fab7669SAndrew Thompson #define BSTP_DEFAULT_HOLD_COUNT 6 14896e47153SAndrew Thompson #define BSTP_DEFAULT_BRIDGE_PRIORITY 0x8000 14996e47153SAndrew Thompson #define BSTP_DEFAULT_PORT_PRIORITY 0x80 15096e47153SAndrew Thompson #define BSTP_DEFAULT_PATH_COST 55 1513fab7669SAndrew Thompson #define BSTP_MIN_HELLO_TIME (1 * 256) 1523fab7669SAndrew Thompson #define BSTP_MIN_MAX_AGE (6 * 256) 1533fab7669SAndrew Thompson #define BSTP_MIN_FORWARD_DELAY (4 * 256) 1543fab7669SAndrew Thompson #define BSTP_MIN_HOLD_COUNT 1 1553fab7669SAndrew Thompson #define BSTP_MAX_HELLO_TIME (2 * 256) 1563fab7669SAndrew Thompson #define BSTP_MAX_MAX_AGE (40 * 256) 1573fab7669SAndrew Thompson #define BSTP_MAX_FORWARD_DELAY (30 * 256) 1583fab7669SAndrew Thompson #define BSTP_MAX_HOLD_COUNT 10 1593fab7669SAndrew Thompson #define BSTP_MAX_PRIORITY 61440 1603fab7669SAndrew Thompson #define BSTP_MAX_PORT_PRIORITY 240 1613fab7669SAndrew Thompson #define BSTP_MAX_PATH_COST 200000000 16296e47153SAndrew Thompson 16396e47153SAndrew Thompson /* BPDU message types */ 16496e47153SAndrew Thompson #define BSTP_MSGTYPE_CFG 0x00 /* Configuration */ 1653fab7669SAndrew Thompson #define BSTP_MSGTYPE_RSTP 0x02 /* Rapid STP */ 16696e47153SAndrew Thompson #define BSTP_MSGTYPE_TCN 0x80 /* Topology chg notification */ 16796e47153SAndrew Thompson 1683fab7669SAndrew Thompson /* Protocol versions */ 1693fab7669SAndrew Thompson #define BSTP_PROTO_ID 0x00 1703fab7669SAndrew Thompson #define BSTP_PROTO_STP 0x00 1713fab7669SAndrew Thompson #define BSTP_PROTO_RSTP 0x02 1723fab7669SAndrew Thompson #define BSTP_PROTO_MAX BSTP_PROTO_RSTP 1733fab7669SAndrew Thompson 1749ddd3624SAndrew Thompson #define BSTP_INFO_RECEIVED 1 1753fab7669SAndrew Thompson #define BSTP_INFO_MINE 2 1763fab7669SAndrew Thompson #define BSTP_INFO_AGED 3 1773fab7669SAndrew Thompson #define BSTP_INFO_DISABLED 4 1783fab7669SAndrew Thompson 17996e47153SAndrew Thompson #define BSTP_MESSAGE_AGE_INCR (1 * 256) /* in 256ths of a second */ 18096e47153SAndrew Thompson #define BSTP_TICK_VAL (1 * 256) /* in 256ths of a second */ 1813fab7669SAndrew Thompson #define BSTP_LINK_TIMER (BSTP_TICK_VAL * 15) 18296e47153SAndrew Thompson 18396e47153SAndrew Thompson /* 1843fab7669SAndrew Thompson * Driver callbacks for STP state changes 1853fab7669SAndrew Thompson */ 1866f2abce0SAndrew Thompson typedef void (*bstp_state_cb_t)(struct ifnet *, int); 1873fab7669SAndrew Thompson typedef void (*bstp_rtage_cb_t)(struct ifnet *, int); 188e5bda9fbSAndrew Thompson struct bstp_cb_ops { 189e5bda9fbSAndrew Thompson bstp_state_cb_t bcb_state; 190e5bda9fbSAndrew Thompson bstp_rtage_cb_t bcb_rtage; 191e5bda9fbSAndrew Thompson }; 1926f2abce0SAndrew Thompson 1936f2abce0SAndrew Thompson /* 19496e47153SAndrew Thompson * Because BPDU's do not make nicely aligned structures, two different 19596e47153SAndrew Thompson * declarations are used: bstp_?bpdu (wire representation, packed) and 19696e47153SAndrew Thompson * bstp_*_unit (internal, nicely aligned version). 19796e47153SAndrew Thompson */ 19896e47153SAndrew Thompson 19996e47153SAndrew Thompson /* configuration bridge protocol data unit */ 20096e47153SAndrew Thompson struct bstp_cbpdu { 20196e47153SAndrew Thompson uint8_t cbu_dsap; /* LLC: destination sap */ 20296e47153SAndrew Thompson uint8_t cbu_ssap; /* LLC: source sap */ 20396e47153SAndrew Thompson uint8_t cbu_ctl; /* LLC: control */ 20496e47153SAndrew Thompson uint16_t cbu_protoid; /* protocol id */ 20596e47153SAndrew Thompson uint8_t cbu_protover; /* protocol version */ 20696e47153SAndrew Thompson uint8_t cbu_bpdutype; /* message type */ 20796e47153SAndrew Thompson uint8_t cbu_flags; /* flags (below) */ 20896e47153SAndrew Thompson 20996e47153SAndrew Thompson /* root id */ 21096e47153SAndrew Thompson uint16_t cbu_rootpri; /* root priority */ 21196e47153SAndrew Thompson uint8_t cbu_rootaddr[6]; /* root address */ 21296e47153SAndrew Thompson 21396e47153SAndrew Thompson uint32_t cbu_rootpathcost; /* root path cost */ 21496e47153SAndrew Thompson 21596e47153SAndrew Thompson /* bridge id */ 21696e47153SAndrew Thompson uint16_t cbu_bridgepri; /* bridge priority */ 21796e47153SAndrew Thompson uint8_t cbu_bridgeaddr[6]; /* bridge address */ 21896e47153SAndrew Thompson 21996e47153SAndrew Thompson uint16_t cbu_portid; /* port id */ 22096e47153SAndrew Thompson uint16_t cbu_messageage; /* current message age */ 22196e47153SAndrew Thompson uint16_t cbu_maxage; /* maximum age */ 22296e47153SAndrew Thompson uint16_t cbu_hellotime; /* hello time */ 22396e47153SAndrew Thompson uint16_t cbu_forwarddelay; /* forwarding delay */ 2243fab7669SAndrew Thompson uint8_t cbu_versionlen; /* version 1 length */ 22548f395a6SWarner Losh } __packed; 2263fab7669SAndrew Thompson #define BSTP_BPDU_STP_LEN (3 + 35) /* LLC + STP pdu */ 2273fab7669SAndrew Thompson #define BSTP_BPDU_RSTP_LEN (3 + 36) /* LLC + RSTP pdu */ 22896e47153SAndrew Thompson 22996e47153SAndrew Thompson /* topology change notification bridge protocol data unit */ 23096e47153SAndrew Thompson struct bstp_tbpdu { 23196e47153SAndrew Thompson uint8_t tbu_dsap; /* LLC: destination sap */ 23296e47153SAndrew Thompson uint8_t tbu_ssap; /* LLC: source sap */ 23396e47153SAndrew Thompson uint8_t tbu_ctl; /* LLC: control */ 23496e47153SAndrew Thompson uint16_t tbu_protoid; /* protocol id */ 23596e47153SAndrew Thompson uint8_t tbu_protover; /* protocol version */ 23696e47153SAndrew Thompson uint8_t tbu_bpdutype; /* message type */ 237a0858e10SWarner Losh } __packed; 23896e47153SAndrew Thompson 23996e47153SAndrew Thompson /* 24096e47153SAndrew Thompson * Timekeeping structure used in spanning tree code. 24196e47153SAndrew Thompson */ 24296e47153SAndrew Thompson struct bstp_timer { 2433fab7669SAndrew Thompson int active; 2443fab7669SAndrew Thompson int latched; 2453fab7669SAndrew Thompson int value; 2463fab7669SAndrew Thompson }; 2473fab7669SAndrew Thompson 2483fab7669SAndrew Thompson struct bstp_pri_vector { 2493fab7669SAndrew Thompson uint64_t pv_root_id; 2503fab7669SAndrew Thompson uint32_t pv_cost; 2513fab7669SAndrew Thompson uint64_t pv_dbridge_id; 2523fab7669SAndrew Thompson uint16_t pv_dport_id; 2533fab7669SAndrew Thompson uint16_t pv_port_id; 25496e47153SAndrew Thompson }; 25596e47153SAndrew Thompson 25696e47153SAndrew Thompson struct bstp_config_unit { 2573fab7669SAndrew Thompson struct bstp_pri_vector cu_pv; 25896e47153SAndrew Thompson uint16_t cu_message_age; 25996e47153SAndrew Thompson uint16_t cu_max_age; 26096e47153SAndrew Thompson uint16_t cu_forward_delay; 2613fab7669SAndrew Thompson uint16_t cu_hello_time; 26296e47153SAndrew Thompson uint8_t cu_message_type; 2633fab7669SAndrew Thompson uint8_t cu_topology_change_ack; 26496e47153SAndrew Thompson uint8_t cu_topology_change; 2653fab7669SAndrew Thompson uint8_t cu_proposal; 2663fab7669SAndrew Thompson uint8_t cu_agree; 2673fab7669SAndrew Thompson uint8_t cu_learning; 2683fab7669SAndrew Thompson uint8_t cu_forwarding; 2693fab7669SAndrew Thompson uint8_t cu_role; 27096e47153SAndrew Thompson }; 27196e47153SAndrew Thompson 27296e47153SAndrew Thompson struct bstp_tcn_unit { 27396e47153SAndrew Thompson uint8_t tu_message_type; 27496e47153SAndrew Thompson }; 27596e47153SAndrew Thompson 27696e47153SAndrew Thompson struct bstp_port { 27796e47153SAndrew Thompson LIST_ENTRY(bstp_port) bp_next; 27896e47153SAndrew Thompson struct ifnet *bp_ifp; /* parent if */ 27996e47153SAndrew Thompson struct bstp_state *bp_bs; 2803fab7669SAndrew Thompson uint8_t bp_active; 2813fab7669SAndrew Thompson uint8_t bp_protover; 2823fab7669SAndrew Thompson uint32_t bp_flags; 28396e47153SAndrew Thompson uint32_t bp_path_cost; 2843fab7669SAndrew Thompson uint16_t bp_port_msg_age; 2853fab7669SAndrew Thompson uint16_t bp_port_max_age; 2863fab7669SAndrew Thompson uint16_t bp_port_fdelay; 2873fab7669SAndrew Thompson uint16_t bp_port_htime; 2883fab7669SAndrew Thompson uint16_t bp_desg_msg_age; 2893fab7669SAndrew Thompson uint16_t bp_desg_max_age; 2903fab7669SAndrew Thompson uint16_t bp_desg_fdelay; 2913fab7669SAndrew Thompson uint16_t bp_desg_htime; 2923fab7669SAndrew Thompson struct bstp_timer bp_edge_delay_timer; 29396e47153SAndrew Thompson struct bstp_timer bp_forward_delay_timer; 2943fab7669SAndrew Thompson struct bstp_timer bp_hello_timer; 2953fab7669SAndrew Thompson struct bstp_timer bp_message_age_timer; 2963fab7669SAndrew Thompson struct bstp_timer bp_migrate_delay_timer; 2973fab7669SAndrew Thompson struct bstp_timer bp_recent_backup_timer; 2983fab7669SAndrew Thompson struct bstp_timer bp_recent_root_timer; 2993fab7669SAndrew Thompson struct bstp_timer bp_tc_timer; 3003fab7669SAndrew Thompson struct bstp_config_unit bp_msg_cu; 3013fab7669SAndrew Thompson struct bstp_pri_vector bp_desg_pv; 3023fab7669SAndrew Thompson struct bstp_pri_vector bp_port_pv; 30396e47153SAndrew Thompson uint16_t bp_port_id; 30496e47153SAndrew Thompson uint8_t bp_state; 3053fab7669SAndrew Thompson uint8_t bp_tcstate; 3063fab7669SAndrew Thompson uint8_t bp_role; 3073fab7669SAndrew Thompson uint8_t bp_infois; 3083fab7669SAndrew Thompson uint8_t bp_tc_ack; 3093fab7669SAndrew Thompson uint8_t bp_tc_prop; 3103fab7669SAndrew Thompson uint8_t bp_fdbflush; 31196e47153SAndrew Thompson uint8_t bp_priority; 31278709605SAndrew Thompson uint8_t bp_ptp_link; 3133fab7669SAndrew Thompson uint8_t bp_agree; 3143fab7669SAndrew Thompson uint8_t bp_agreed; 3153fab7669SAndrew Thompson uint8_t bp_sync; 3163fab7669SAndrew Thompson uint8_t bp_synced; 3173fab7669SAndrew Thompson uint8_t bp_proposing; 3183fab7669SAndrew Thompson uint8_t bp_proposed; 3193fab7669SAndrew Thompson uint8_t bp_operedge; 3203fab7669SAndrew Thompson uint8_t bp_reroot; 3213fab7669SAndrew Thompson uint8_t bp_rcvdtc; 3223fab7669SAndrew Thompson uint8_t bp_rcvdtca; 3233fab7669SAndrew Thompson uint8_t bp_rcvdtcn; 32451383c37SAndrew Thompson uint32_t bp_forward_transitions; 3253fab7669SAndrew Thompson uint8_t bp_txcount; 3266f2abce0SAndrew Thompson struct task bp_statetask; 3273fab7669SAndrew Thompson struct task bp_rtagetask; 3282885c19eSAndrew Thompson struct task bp_mediatask; 32996e47153SAndrew Thompson }; 33096e47153SAndrew Thompson 33196e47153SAndrew Thompson /* 33296e47153SAndrew Thompson * Software state for each bridge STP. 33396e47153SAndrew Thompson */ 33496e47153SAndrew Thompson struct bstp_state { 33596e47153SAndrew Thompson LIST_ENTRY(bstp_state) bs_list; 336c25789ccSAndrew Thompson uint8_t bs_running; 33796e47153SAndrew Thompson struct mtx bs_mtx; 3383fab7669SAndrew Thompson struct bstp_pri_vector bs_bridge_pv; 3393fab7669SAndrew Thompson struct bstp_pri_vector bs_root_pv; 34096e47153SAndrew Thompson struct bstp_port *bs_root_port; 3413fab7669SAndrew Thompson uint8_t bs_protover; 3423fab7669SAndrew Thompson uint16_t bs_migration_delay; 3433fab7669SAndrew Thompson uint16_t bs_edge_delay; 34496e47153SAndrew Thompson uint16_t bs_bridge_max_age; 3453fab7669SAndrew Thompson uint16_t bs_bridge_fdelay; 3463fab7669SAndrew Thompson uint16_t bs_bridge_htime; 3473fab7669SAndrew Thompson uint16_t bs_root_msg_age; 3483fab7669SAndrew Thompson uint16_t bs_root_max_age; 3493fab7669SAndrew Thompson uint16_t bs_root_fdelay; 3503fab7669SAndrew Thompson uint16_t bs_root_htime; 35196e47153SAndrew Thompson uint16_t bs_hold_time; 35296e47153SAndrew Thompson uint16_t bs_bridge_priority; 3533fab7669SAndrew Thompson uint8_t bs_txholdcount; 3543fab7669SAndrew Thompson uint8_t bs_allsynced; 35596e47153SAndrew Thompson struct callout bs_bstpcallout; /* STP callout */ 35696e47153SAndrew Thompson struct bstp_timer bs_link_timer; 35751383c37SAndrew Thompson struct timeval bs_last_tc_time; 35896e47153SAndrew Thompson LIST_HEAD(, bstp_port) bs_bplist; 3596f2abce0SAndrew Thompson bstp_state_cb_t bs_state_cb; 3603fab7669SAndrew Thompson bstp_rtage_cb_t bs_rtage_cb; 3612fe7ca2cSMarko Zec struct vnet *bs_vnet; 36296e47153SAndrew Thompson }; 36396e47153SAndrew Thompson 3643fab7669SAndrew Thompson #define BSTP_LOCK_INIT(_bs) mtx_init(&(_bs)->bs_mtx, "bstp", NULL, MTX_DEF) 36596e47153SAndrew Thompson #define BSTP_LOCK_DESTROY(_bs) mtx_destroy(&(_bs)->bs_mtx) 36696e47153SAndrew Thompson #define BSTP_LOCK(_bs) mtx_lock(&(_bs)->bs_mtx) 36796e47153SAndrew Thompson #define BSTP_UNLOCK(_bs) mtx_unlock(&(_bs)->bs_mtx) 36896e47153SAndrew Thompson #define BSTP_LOCK_ASSERT(_bs) mtx_assert(&(_bs)->bs_mtx, MA_OWNED) 36996e47153SAndrew Thompson 37096e47153SAndrew Thompson extern const uint8_t bstp_etheraddr[]; 37196e47153SAndrew Thompson 372e5bda9fbSAndrew Thompson void bstp_attach(struct bstp_state *, struct bstp_cb_ops *); 37396e47153SAndrew Thompson void bstp_detach(struct bstp_state *); 37496e47153SAndrew Thompson void bstp_init(struct bstp_state *); 37596e47153SAndrew Thompson void bstp_stop(struct bstp_state *); 376071fff62SAndrew Thompson int bstp_create(struct bstp_state *, struct bstp_port *, struct ifnet *); 377071fff62SAndrew Thompson int bstp_enable(struct bstp_port *); 378071fff62SAndrew Thompson void bstp_disable(struct bstp_port *); 379071fff62SAndrew Thompson void bstp_destroy(struct bstp_port *); 3807702d401SAndrew Thompson void bstp_linkstate(struct bstp_port *); 3813fab7669SAndrew Thompson int bstp_set_htime(struct bstp_state *, int); 3823fab7669SAndrew Thompson int bstp_set_fdelay(struct bstp_state *, int); 3833fab7669SAndrew Thompson int bstp_set_maxage(struct bstp_state *, int); 3843fab7669SAndrew Thompson int bstp_set_holdcount(struct bstp_state *, int); 3853fab7669SAndrew Thompson int bstp_set_protocol(struct bstp_state *, int); 3863fab7669SAndrew Thompson int bstp_set_priority(struct bstp_state *, int); 3873fab7669SAndrew Thompson int bstp_set_port_priority(struct bstp_port *, int); 3883fab7669SAndrew Thompson int bstp_set_path_cost(struct bstp_port *, uint32_t); 3893fab7669SAndrew Thompson int bstp_set_edge(struct bstp_port *, int); 3903fab7669SAndrew Thompson int bstp_set_autoedge(struct bstp_port *, int); 39178709605SAndrew Thompson int bstp_set_ptp(struct bstp_port *, int); 39278709605SAndrew Thompson int bstp_set_autoptp(struct bstp_port *, int); 3934661f862SAndrew Thompson void bstp_input(struct bstp_port *, struct ifnet *, struct mbuf *); 39496e47153SAndrew Thompson 39596e47153SAndrew Thompson #endif /* _KERNEL */ 396