1160703Sthompsa/*	$NetBSD: if_bridgevar.h,v 1.4 2003/07/08 07:13:50 itojun Exp $	*/
2160703Sthompsa
3160703Sthompsa/*
4160703Sthompsa * Copyright 2001 Wasabi Systems, Inc.
5160703Sthompsa * All rights reserved.
6160703Sthompsa *
7160703Sthompsa * Written by Jason R. Thorpe for Wasabi Systems, Inc.
8160703Sthompsa *
9160703Sthompsa * Redistribution and use in source and binary forms, with or without
10160703Sthompsa * modification, are permitted provided that the following conditions
11160703Sthompsa * are met:
12160703Sthompsa * 1. Redistributions of source code must retain the above copyright
13160703Sthompsa *    notice, this list of conditions and the following disclaimer.
14160703Sthompsa * 2. Redistributions in binary form must reproduce the above copyright
15160703Sthompsa *    notice, this list of conditions and the following disclaimer in the
16160703Sthompsa *    documentation and/or other materials provided with the distribution.
17160703Sthompsa * 3. All advertising materials mentioning features or use of this software
18160703Sthompsa *    must display the following acknowledgement:
19160703Sthompsa *	This product includes software developed for the NetBSD Project by
20160703Sthompsa *	Wasabi Systems, Inc.
21160703Sthompsa * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22160703Sthompsa *    or promote products derived from this software without specific prior
23160703Sthompsa *    written permission.
24160703Sthompsa *
25160703Sthompsa * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26160703Sthompsa * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27160703Sthompsa * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28160703Sthompsa * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
29160703Sthompsa * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30160703Sthompsa * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31160703Sthompsa * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32160703Sthompsa * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33160703Sthompsa * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34160703Sthompsa * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35160703Sthompsa * POSSIBILITY OF SUCH DAMAGE.
36160703Sthompsa */
37160703Sthompsa
38160703Sthompsa/*
39160703Sthompsa * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net)
40160703Sthompsa * All rights reserved.
41160703Sthompsa *
42160703Sthompsa * Redistribution and use in source and binary forms, with or without
43160703Sthompsa * modification, are permitted provided that the following conditions
44160703Sthompsa * are met:
45160703Sthompsa * 1. Redistributions of source code must retain the above copyright
46160703Sthompsa *    notice, this list of conditions and the following disclaimer.
47160703Sthompsa * 2. Redistributions in binary form must reproduce the above copyright
48160703Sthompsa *    notice, this list of conditions and the following disclaimer in the
49160703Sthompsa *    documentation and/or other materials provided with the distribution.
50160703Sthompsa * 3. All advertising materials mentioning features or use of this software
51160703Sthompsa *    must display the following acknowledgement:
52160703Sthompsa *	This product includes software developed by Jason L. Wright
53160703Sthompsa * 4. The name of the author may not be used to endorse or promote products
54160703Sthompsa *    derived from this software without specific prior written permission.
55160703Sthompsa *
56160703Sthompsa * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
57160703Sthompsa * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
58160703Sthompsa * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
59160703Sthompsa * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
60160703Sthompsa * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
61160703Sthompsa * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
62160703Sthompsa * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
63160703Sthompsa * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
64160703Sthompsa * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
65160703Sthompsa * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
66160703Sthompsa * POSSIBILITY OF SUCH DAMAGE.
67160703Sthompsa *
68160703Sthompsa * OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp
69160703Sthompsa *
70160703Sthompsa * $FreeBSD$
71160703Sthompsa */
72160703Sthompsa
73160703Sthompsa/*
74160703Sthompsa * Data structure and control definitions for STP interfaces.
75160703Sthompsa */
76160703Sthompsa
77160703Sthompsa#include <sys/callout.h>
78160703Sthompsa#include <sys/queue.h>
79160703Sthompsa
80160703Sthompsa/* STP port states */
81160703Sthompsa#define	BSTP_IFSTATE_DISABLED	0
82160703Sthompsa#define	BSTP_IFSTATE_LISTENING	1
83160703Sthompsa#define	BSTP_IFSTATE_LEARNING	2
84160703Sthompsa#define	BSTP_IFSTATE_FORWARDING	3
85160703Sthompsa#define	BSTP_IFSTATE_BLOCKING	4
86163863Sthompsa#define	BSTP_IFSTATE_DISCARDING	5
87160703Sthompsa
88163863Sthompsa#define	BSTP_TCSTATE_ACTIVE	1
89163863Sthompsa#define	BSTP_TCSTATE_DETECTED	2
90163863Sthompsa#define	BSTP_TCSTATE_INACTIVE	3
91163863Sthompsa#define	BSTP_TCSTATE_LEARNING	4
92163863Sthompsa#define	BSTP_TCSTATE_PROPAG	5
93163863Sthompsa#define	BSTP_TCSTATE_ACK	6
94163863Sthompsa#define	BSTP_TCSTATE_TC		7
95163863Sthompsa#define	BSTP_TCSTATE_TCN	8
96163863Sthompsa
97163863Sthompsa#define	BSTP_ROLE_DISABLED	0
98163863Sthompsa#define	BSTP_ROLE_ROOT		1
99163863Sthompsa#define	BSTP_ROLE_DESIGNATED	2
100163863Sthompsa#define	BSTP_ROLE_ALTERNATE	3
101163863Sthompsa#define	BSTP_ROLE_BACKUP	4
102163863Sthompsa
103160703Sthompsa#ifdef _KERNEL
104160703Sthompsa
105163863Sthompsa/* STP port flags */
106163863Sthompsa#define	BSTP_PORT_CANMIGRATE	0x0001
107163863Sthompsa#define	BSTP_PORT_NEWINFO	0x0002
108163863Sthompsa#define	BSTP_PORT_DISPUTED	0x0004
109163863Sthompsa#define	BSTP_PORT_ADMCOST	0x0008
110163863Sthompsa#define	BSTP_PORT_AUTOEDGE	0x0010
111165105Sthompsa#define	BSTP_PORT_AUTOPTP	0x0020
112164880Ssyrinx#define	BSTP_PORT_ADMEDGE	0x0040
113171724Sthompsa#define	BSTP_PORT_PNDCOST	0x0080
114163863Sthompsa
115163863Sthompsa/* BPDU priority */
116163863Sthompsa#define	BSTP_PDU_SUPERIOR	1
117163863Sthompsa#define	BSTP_PDU_REPEATED	2
118163863Sthompsa#define	BSTP_PDU_INFERIOR	3
119163863Sthompsa#define	BSTP_PDU_INFERIORALT	4
120163863Sthompsa#define	BSTP_PDU_OTHER		5
121163863Sthompsa
122163863Sthompsa/* BPDU flags */
123163863Sthompsa#define	BSTP_PDU_PRMASK		0x0c		/* Port Role */
124163863Sthompsa#define	BSTP_PDU_PRSHIFT	2		/* Port Role offset */
125163863Sthompsa#define	BSTP_PDU_F_UNKN		0x00		/* Unknown port    (00) */
126163863Sthompsa#define	BSTP_PDU_F_ALT		0x01		/* Alt/Backup port (01) */
127163863Sthompsa#define	BSTP_PDU_F_ROOT		0x02		/* Root port       (10) */
128163863Sthompsa#define	BSTP_PDU_F_DESG		0x03		/* Designated port (11) */
129163863Sthompsa
130163863Sthompsa#define	BSTP_PDU_STPMASK	0x81		/* strip unused STP flags */
131163863Sthompsa#define	BSTP_PDU_RSTPMASK	0x7f		/* strip unused RSTP flags */
132163863Sthompsa#define	BSTP_PDU_F_TC		0x01		/* Topology change */
133163863Sthompsa#define	BSTP_PDU_F_P		0x02		/* Proposal flag */
134163863Sthompsa#define	BSTP_PDU_F_L		0x10		/* Learning flag */
135163863Sthompsa#define	BSTP_PDU_F_F		0x20		/* Forwarding flag */
136163863Sthompsa#define	BSTP_PDU_F_A		0x40		/* Agreement flag */
137163863Sthompsa#define	BSTP_PDU_F_TCA		0x80		/* Topology change ack */
138163863Sthompsa
139160703Sthompsa/*
140160703Sthompsa * Spanning tree defaults.
141160703Sthompsa */
142160703Sthompsa#define	BSTP_DEFAULT_MAX_AGE		(20 * 256)
143160703Sthompsa#define	BSTP_DEFAULT_HELLO_TIME		(2 * 256)
144160703Sthompsa#define	BSTP_DEFAULT_FORWARD_DELAY	(15 * 256)
145160703Sthompsa#define	BSTP_DEFAULT_HOLD_TIME		(1 * 256)
146163863Sthompsa#define	BSTP_DEFAULT_MIGRATE_DELAY	(3 * 256)
147163863Sthompsa#define	BSTP_DEFAULT_HOLD_COUNT		6
148160703Sthompsa#define	BSTP_DEFAULT_BRIDGE_PRIORITY	0x8000
149160703Sthompsa#define	BSTP_DEFAULT_PORT_PRIORITY	0x80
150160703Sthompsa#define	BSTP_DEFAULT_PATH_COST		55
151163863Sthompsa#define	BSTP_MIN_HELLO_TIME		(1 * 256)
152163863Sthompsa#define	BSTP_MIN_MAX_AGE		(6 * 256)
153163863Sthompsa#define	BSTP_MIN_FORWARD_DELAY		(4 * 256)
154163863Sthompsa#define	BSTP_MIN_HOLD_COUNT		1
155163863Sthompsa#define	BSTP_MAX_HELLO_TIME		(2 * 256)
156163863Sthompsa#define	BSTP_MAX_MAX_AGE		(40 * 256)
157163863Sthompsa#define	BSTP_MAX_FORWARD_DELAY		(30 * 256)
158163863Sthompsa#define	BSTP_MAX_HOLD_COUNT		10
159163863Sthompsa#define	BSTP_MAX_PRIORITY		61440
160163863Sthompsa#define	BSTP_MAX_PORT_PRIORITY		240
161163863Sthompsa#define	BSTP_MAX_PATH_COST		200000000
162160703Sthompsa
163160703Sthompsa/* BPDU message types */
164160703Sthompsa#define	BSTP_MSGTYPE_CFG	0x00		/* Configuration */
165163863Sthompsa#define	BSTP_MSGTYPE_RSTP	0x02		/* Rapid STP */
166160703Sthompsa#define	BSTP_MSGTYPE_TCN	0x80		/* Topology chg notification */
167160703Sthompsa
168163863Sthompsa/* Protocol versions */
169163863Sthompsa#define	BSTP_PROTO_ID		0x00
170163863Sthompsa#define	BSTP_PROTO_STP		0x00
171163863Sthompsa#define	BSTP_PROTO_RSTP		0x02
172163863Sthompsa#define	BSTP_PROTO_MAX		BSTP_PROTO_RSTP
173160703Sthompsa
174174493Sthompsa#define	BSTP_INFO_RECEIVED	1
175163863Sthompsa#define	BSTP_INFO_MINE		2
176163863Sthompsa#define	BSTP_INFO_AGED		3
177163863Sthompsa#define	BSTP_INFO_DISABLED	4
178163863Sthompsa
179163863Sthompsa
180160703Sthompsa#define	BSTP_MESSAGE_AGE_INCR	(1 * 256)	/* in 256ths of a second */
181160703Sthompsa#define	BSTP_TICK_VAL		(1 * 256)	/* in 256ths of a second */
182163863Sthompsa#define	BSTP_LINK_TIMER		(BSTP_TICK_VAL * 15)
183160703Sthompsa
184160703Sthompsa/*
185163863Sthompsa * Driver callbacks for STP state changes
186163863Sthompsa */
187160899Sthompsatypedef void (*bstp_state_cb_t)(struct ifnet *, int);
188163863Sthompsatypedef void (*bstp_rtage_cb_t)(struct ifnet *, int);
189167379Sthompsastruct bstp_cb_ops {
190167379Sthompsa	bstp_state_cb_t	bcb_state;
191167379Sthompsa	bstp_rtage_cb_t	bcb_rtage;
192167379Sthompsa};
193160899Sthompsa
194160899Sthompsa/*
195160703Sthompsa * Because BPDU's do not make nicely aligned structures, two different
196160703Sthompsa * declarations are used: bstp_?bpdu (wire representation, packed) and
197160703Sthompsa * bstp_*_unit (internal, nicely aligned version).
198160703Sthompsa */
199160703Sthompsa
200160703Sthompsa/* configuration bridge protocol data unit */
201160703Sthompsastruct bstp_cbpdu {
202160703Sthompsa	uint8_t		cbu_dsap;		/* LLC: destination sap */
203160703Sthompsa	uint8_t		cbu_ssap;		/* LLC: source sap */
204160703Sthompsa	uint8_t		cbu_ctl;		/* LLC: control */
205160703Sthompsa	uint16_t	cbu_protoid;		/* protocol id */
206160703Sthompsa	uint8_t		cbu_protover;		/* protocol version */
207160703Sthompsa	uint8_t		cbu_bpdutype;		/* message type */
208160703Sthompsa	uint8_t		cbu_flags;		/* flags (below) */
209160703Sthompsa
210160703Sthompsa	/* root id */
211160703Sthompsa	uint16_t	cbu_rootpri;		/* root priority */
212163863Sthompsa	uint8_t		cbu_rootaddr[6];	/* root address */
213160703Sthompsa
214160703Sthompsa	uint32_t	cbu_rootpathcost;	/* root path cost */
215160703Sthompsa
216160703Sthompsa	/* bridge id */
217160703Sthompsa	uint16_t	cbu_bridgepri;		/* bridge priority */
218160703Sthompsa	uint8_t		cbu_bridgeaddr[6];	/* bridge address */
219160703Sthompsa
220160703Sthompsa	uint16_t	cbu_portid;		/* port id */
221160703Sthompsa	uint16_t	cbu_messageage;		/* current message age */
222160703Sthompsa	uint16_t	cbu_maxage;		/* maximum age */
223160703Sthompsa	uint16_t	cbu_hellotime;		/* hello time */
224160703Sthompsa	uint16_t	cbu_forwarddelay;	/* forwarding delay */
225163863Sthompsa	uint8_t		cbu_versionlen;		/* version 1 length */
226164807Simp} __packed;
227163863Sthompsa#define	BSTP_BPDU_STP_LEN	(3 + 35)	/* LLC + STP pdu */
228163863Sthompsa#define	BSTP_BPDU_RSTP_LEN	(3 + 36)	/* LLC + RSTP pdu */
229160703Sthompsa
230160703Sthompsa/* topology change notification bridge protocol data unit */
231160703Sthompsastruct bstp_tbpdu {
232160703Sthompsa	uint8_t		tbu_dsap;		/* LLC: destination sap */
233160703Sthompsa	uint8_t		tbu_ssap;		/* LLC: source sap */
234160703Sthompsa	uint8_t		tbu_ctl;		/* LLC: control */
235160703Sthompsa	uint16_t	tbu_protoid;		/* protocol id */
236160703Sthompsa	uint8_t		tbu_protover;		/* protocol version */
237160703Sthompsa	uint8_t		tbu_bpdutype;		/* message type */
238164806Simp} __packed;
239160703Sthompsa
240160703Sthompsa/*
241160703Sthompsa * Timekeeping structure used in spanning tree code.
242160703Sthompsa */
243160703Sthompsastruct bstp_timer {
244163863Sthompsa	int		active;
245163863Sthompsa	int		latched;
246163863Sthompsa	int		value;
247160703Sthompsa};
248160703Sthompsa
249163863Sthompsastruct bstp_pri_vector {
250163863Sthompsa	uint64_t		pv_root_id;
251163863Sthompsa	uint32_t		pv_cost;
252163863Sthompsa	uint64_t		pv_dbridge_id;
253163863Sthompsa	uint16_t		pv_dport_id;
254163863Sthompsa	uint16_t		pv_port_id;
255163863Sthompsa};
256163863Sthompsa
257160703Sthompsastruct bstp_config_unit {
258163863Sthompsa	struct bstp_pri_vector	cu_pv;
259160703Sthompsa	uint16_t	cu_message_age;
260160703Sthompsa	uint16_t	cu_max_age;
261163863Sthompsa	uint16_t	cu_forward_delay;
262160703Sthompsa	uint16_t	cu_hello_time;
263160703Sthompsa	uint8_t		cu_message_type;
264163863Sthompsa	uint8_t		cu_topology_change_ack;
265160703Sthompsa	uint8_t		cu_topology_change;
266163863Sthompsa	uint8_t		cu_proposal;
267163863Sthompsa	uint8_t		cu_agree;
268163863Sthompsa	uint8_t		cu_learning;
269163863Sthompsa	uint8_t		cu_forwarding;
270163863Sthompsa	uint8_t		cu_role;
271160703Sthompsa};
272160703Sthompsa
273160703Sthompsastruct bstp_tcn_unit {
274160703Sthompsa	uint8_t		tu_message_type;
275160703Sthompsa};
276160703Sthompsa
277160703Sthompsastruct bstp_port {
278160703Sthompsa	LIST_ENTRY(bstp_port)	bp_next;
279160703Sthompsa	struct ifnet		*bp_ifp;	/* parent if */
280160703Sthompsa	struct bstp_state	*bp_bs;
281163863Sthompsa	uint8_t			bp_active;
282163863Sthompsa	uint8_t			bp_protover;
283163863Sthompsa	uint32_t		bp_flags;
284160703Sthompsa	uint32_t		bp_path_cost;
285163863Sthompsa	uint16_t		bp_port_msg_age;
286163863Sthompsa	uint16_t		bp_port_max_age;
287163863Sthompsa	uint16_t		bp_port_fdelay;
288163863Sthompsa	uint16_t		bp_port_htime;
289163863Sthompsa	uint16_t		bp_desg_msg_age;
290163863Sthompsa	uint16_t		bp_desg_max_age;
291163863Sthompsa	uint16_t		bp_desg_fdelay;
292163863Sthompsa	uint16_t		bp_desg_htime;
293163863Sthompsa	struct bstp_timer	bp_edge_delay_timer;
294163863Sthompsa	struct bstp_timer	bp_forward_delay_timer;
295163863Sthompsa	struct bstp_timer	bp_hello_timer;
296160703Sthompsa	struct bstp_timer	bp_message_age_timer;
297163863Sthompsa	struct bstp_timer	bp_migrate_delay_timer;
298163863Sthompsa	struct bstp_timer	bp_recent_backup_timer;
299163863Sthompsa	struct bstp_timer	bp_recent_root_timer;
300163863Sthompsa	struct bstp_timer	bp_tc_timer;
301163863Sthompsa	struct bstp_config_unit bp_msg_cu;
302163863Sthompsa	struct bstp_pri_vector	bp_desg_pv;
303163863Sthompsa	struct bstp_pri_vector	bp_port_pv;
304160703Sthompsa	uint16_t		bp_port_id;
305160703Sthompsa	uint8_t			bp_state;
306163863Sthompsa	uint8_t			bp_tcstate;
307163863Sthompsa	uint8_t			bp_role;
308163863Sthompsa	uint8_t			bp_infois;
309163863Sthompsa	uint8_t			bp_tc_ack;
310163863Sthompsa	uint8_t			bp_tc_prop;
311163863Sthompsa	uint8_t			bp_fdbflush;
312160703Sthompsa	uint8_t			bp_priority;
313165105Sthompsa	uint8_t			bp_ptp_link;
314163863Sthompsa	uint8_t			bp_agree;
315163863Sthompsa	uint8_t			bp_agreed;
316163863Sthompsa	uint8_t			bp_sync;
317163863Sthompsa	uint8_t			bp_synced;
318163863Sthompsa	uint8_t			bp_proposing;
319163863Sthompsa	uint8_t			bp_proposed;
320163863Sthompsa	uint8_t			bp_operedge;
321163863Sthompsa	uint8_t			bp_reroot;
322163863Sthompsa	uint8_t			bp_rcvdtc;
323163863Sthompsa	uint8_t			bp_rcvdtca;
324163863Sthompsa	uint8_t			bp_rcvdtcn;
325160867Sthompsa	uint32_t		bp_forward_transitions;
326163863Sthompsa	uint8_t			bp_txcount;
327160899Sthompsa	struct task		bp_statetask;
328163863Sthompsa	struct task		bp_rtagetask;
329234488Sthompsa	struct task		bp_mediatask;
330160703Sthompsa};
331160703Sthompsa
332160703Sthompsa/*
333160703Sthompsa * Software state for each bridge STP.
334160703Sthompsa */
335160703Sthompsastruct bstp_state {
336160703Sthompsa	LIST_ENTRY(bstp_state)	bs_list;
337164141Sthompsa	uint8_t			bs_running;
338160703Sthompsa	struct mtx		bs_mtx;
339163863Sthompsa	struct bstp_pri_vector	bs_bridge_pv;
340163863Sthompsa	struct bstp_pri_vector	bs_root_pv;
341160703Sthompsa	struct bstp_port	*bs_root_port;
342163863Sthompsa	uint8_t			bs_protover;
343163863Sthompsa	uint16_t		bs_migration_delay;
344163863Sthompsa	uint16_t		bs_edge_delay;
345160703Sthompsa	uint16_t		bs_bridge_max_age;
346163863Sthompsa	uint16_t		bs_bridge_fdelay;
347163863Sthompsa	uint16_t		bs_bridge_htime;
348163863Sthompsa	uint16_t		bs_root_msg_age;
349163863Sthompsa	uint16_t		bs_root_max_age;
350163863Sthompsa	uint16_t		bs_root_fdelay;
351163863Sthompsa	uint16_t		bs_root_htime;
352160703Sthompsa	uint16_t		bs_hold_time;
353160703Sthompsa	uint16_t		bs_bridge_priority;
354163863Sthompsa	uint8_t			bs_txholdcount;
355163863Sthompsa	uint8_t			bs_allsynced;
356160703Sthompsa	struct callout		bs_bstpcallout;	/* STP callout */
357160703Sthompsa	struct bstp_timer	bs_link_timer;
358160867Sthompsa	struct timeval		bs_last_tc_time;
359160703Sthompsa	LIST_HEAD(, bstp_port)	bs_bplist;
360160899Sthompsa	bstp_state_cb_t		bs_state_cb;
361163863Sthompsa	bstp_rtage_cb_t		bs_rtage_cb;
362222834Szec	struct vnet		*bs_vnet;
363160703Sthompsa};
364160703Sthompsa
365163863Sthompsa#define	BSTP_LOCK_INIT(_bs)	mtx_init(&(_bs)->bs_mtx, "bstp", NULL, MTX_DEF)
366163863Sthompsa#define	BSTP_LOCK_DESTROY(_bs)	mtx_destroy(&(_bs)->bs_mtx)
367163863Sthompsa#define	BSTP_LOCK(_bs)		mtx_lock(&(_bs)->bs_mtx)
368163863Sthompsa#define	BSTP_UNLOCK(_bs)	mtx_unlock(&(_bs)->bs_mtx)
369163863Sthompsa#define	BSTP_LOCK_ASSERT(_bs)	mtx_assert(&(_bs)->bs_mtx, MA_OWNED)
370160703Sthompsa
371160703Sthompsaextern const uint8_t bstp_etheraddr[];
372160703Sthompsa
373167379Sthompsavoid	bstp_attach(struct bstp_state *, struct bstp_cb_ops *);
374160703Sthompsavoid	bstp_detach(struct bstp_state *);
375160703Sthompsavoid	bstp_init(struct bstp_state *);
376160703Sthompsavoid	bstp_stop(struct bstp_state *);
377164626Sthompsaint	bstp_create(struct bstp_state *, struct bstp_port *, struct ifnet *);
378164626Sthompsaint	bstp_enable(struct bstp_port *);
379164626Sthompsavoid	bstp_disable(struct bstp_port *);
380164626Sthompsavoid	bstp_destroy(struct bstp_port *);
381234487Sthompsavoid	bstp_linkstate(struct bstp_port *);
382163863Sthompsaint	bstp_set_htime(struct bstp_state *, int);
383163863Sthompsaint	bstp_set_fdelay(struct bstp_state *, int);
384163863Sthompsaint	bstp_set_maxage(struct bstp_state *, int);
385163863Sthompsaint	bstp_set_holdcount(struct bstp_state *, int);
386163863Sthompsaint	bstp_set_protocol(struct bstp_state *, int);
387163863Sthompsaint	bstp_set_priority(struct bstp_state *, int);
388163863Sthompsaint	bstp_set_port_priority(struct bstp_port *, int);
389163863Sthompsaint	bstp_set_path_cost(struct bstp_port *, uint32_t);
390163863Sthompsaint	bstp_set_edge(struct bstp_port *, int);
391163863Sthompsaint	bstp_set_autoedge(struct bstp_port *, int);
392165105Sthompsaint	bstp_set_ptp(struct bstp_port *, int);
393165105Sthompsaint	bstp_set_autoptp(struct bstp_port *, int);
394232014Sthompsavoid	bstp_input(struct bstp_port *, struct ifnet *, struct mbuf *);
395160703Sthompsa
396160703Sthompsa#endif /* _KERNEL */
397