bridgestp.h revision 164626
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: head/sys/net/bridgestp.h 164626 2006-11-26 18:43:48Z thompsa $
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
111163863Sthompsa
112163863Sthompsa/* BPDU priority */
113163863Sthompsa#define	BSTP_PDU_SUPERIOR	1
114163863Sthompsa#define	BSTP_PDU_REPEATED	2
115163863Sthompsa#define	BSTP_PDU_INFERIOR	3
116163863Sthompsa#define	BSTP_PDU_INFERIORALT	4
117163863Sthompsa#define	BSTP_PDU_OTHER		5
118163863Sthompsa
119163863Sthompsa/* BPDU flags */
120163863Sthompsa#define	BSTP_PDU_PRMASK		0x0c		/* Port Role */
121163863Sthompsa#define	BSTP_PDU_PRSHIFT	2		/* Port Role offset */
122163863Sthompsa#define	BSTP_PDU_F_UNKN		0x00		/* Unknown port    (00) */
123163863Sthompsa#define	BSTP_PDU_F_ALT		0x01		/* Alt/Backup port (01) */
124163863Sthompsa#define	BSTP_PDU_F_ROOT		0x02		/* Root port       (10) */
125163863Sthompsa#define	BSTP_PDU_F_DESG		0x03		/* Designated port (11) */
126163863Sthompsa
127163863Sthompsa#define	BSTP_PDU_STPMASK	0x81		/* strip unused STP flags */
128163863Sthompsa#define	BSTP_PDU_RSTPMASK	0x7f		/* strip unused RSTP flags */
129163863Sthompsa#define	BSTP_PDU_F_TC		0x01		/* Topology change */
130163863Sthompsa#define	BSTP_PDU_F_P		0x02		/* Proposal flag */
131163863Sthompsa#define	BSTP_PDU_F_L		0x10		/* Learning flag */
132163863Sthompsa#define	BSTP_PDU_F_F		0x20		/* Forwarding flag */
133163863Sthompsa#define	BSTP_PDU_F_A		0x40		/* Agreement flag */
134163863Sthompsa#define	BSTP_PDU_F_TCA		0x80		/* Topology change ack */
135163863Sthompsa
136160703Sthompsa/*
137160703Sthompsa * Spanning tree defaults.
138160703Sthompsa */
139160703Sthompsa#define	BSTP_DEFAULT_MAX_AGE		(20 * 256)
140160703Sthompsa#define	BSTP_DEFAULT_HELLO_TIME		(2 * 256)
141160703Sthompsa#define	BSTP_DEFAULT_FORWARD_DELAY	(15 * 256)
142160703Sthompsa#define	BSTP_DEFAULT_HOLD_TIME		(1 * 256)
143163863Sthompsa#define	BSTP_DEFAULT_MIGRATE_DELAY	(3 * 256)
144163863Sthompsa#define	BSTP_DEFAULT_HOLD_COUNT		6
145160703Sthompsa#define	BSTP_DEFAULT_BRIDGE_PRIORITY	0x8000
146160703Sthompsa#define	BSTP_DEFAULT_PORT_PRIORITY	0x80
147160703Sthompsa#define	BSTP_DEFAULT_PATH_COST		55
148163863Sthompsa#define	BSTP_MIN_HELLO_TIME		(1 * 256)
149163863Sthompsa#define	BSTP_MIN_MAX_AGE		(6 * 256)
150163863Sthompsa#define	BSTP_MIN_FORWARD_DELAY		(4 * 256)
151163863Sthompsa#define	BSTP_MIN_HOLD_COUNT		1
152163863Sthompsa#define	BSTP_MAX_HELLO_TIME		(2 * 256)
153163863Sthompsa#define	BSTP_MAX_MAX_AGE		(40 * 256)
154163863Sthompsa#define	BSTP_MAX_FORWARD_DELAY		(30 * 256)
155163863Sthompsa#define	BSTP_MAX_HOLD_COUNT		10
156163863Sthompsa#define	BSTP_MAX_PRIORITY		61440
157163863Sthompsa#define	BSTP_MAX_PORT_PRIORITY		240
158163863Sthompsa#define	BSTP_MAX_PATH_COST		200000000
159160703Sthompsa
160160703Sthompsa/* BPDU message types */
161160703Sthompsa#define	BSTP_MSGTYPE_CFG	0x00		/* Configuration */
162163863Sthompsa#define	BSTP_MSGTYPE_RSTP	0x02		/* Rapid STP */
163160703Sthompsa#define	BSTP_MSGTYPE_TCN	0x80		/* Topology chg notification */
164160703Sthompsa
165163863Sthompsa/* Protocol versions */
166163863Sthompsa#define	BSTP_PROTO_ID		0x00
167163863Sthompsa#define	BSTP_PROTO_STP		0x00
168163863Sthompsa#define	BSTP_PROTO_RSTP		0x02
169163863Sthompsa#define	BSTP_PROTO_MAX		BSTP_PROTO_RSTP
170160703Sthompsa
171163863Sthompsa#define	BSTP_INFO_RECIEVED	1
172163863Sthompsa#define	BSTP_INFO_MINE		2
173163863Sthompsa#define	BSTP_INFO_AGED		3
174163863Sthompsa#define	BSTP_INFO_DISABLED	4
175163863Sthompsa
176163863Sthompsa
177160703Sthompsa#define	BSTP_MESSAGE_AGE_INCR	(1 * 256)	/* in 256ths of a second */
178160703Sthompsa#define	BSTP_TICK_VAL		(1 * 256)	/* in 256ths of a second */
179163863Sthompsa#define	BSTP_LINK_TIMER		(BSTP_TICK_VAL * 15)
180160703Sthompsa
181160703Sthompsa/*
182163863Sthompsa * Driver callbacks for STP state changes
183163863Sthompsa */
184160899Sthompsatypedef void (*bstp_state_cb_t)(struct ifnet *, int);
185163863Sthompsatypedef void (*bstp_rtage_cb_t)(struct ifnet *, int);
186160899Sthompsa
187160899Sthompsa/*
188160703Sthompsa * Because BPDU's do not make nicely aligned structures, two different
189160703Sthompsa * declarations are used: bstp_?bpdu (wire representation, packed) and
190160703Sthompsa * bstp_*_unit (internal, nicely aligned version).
191160703Sthompsa */
192160703Sthompsa
193160703Sthompsa/* configuration bridge protocol data unit */
194160703Sthompsastruct bstp_cbpdu {
195160703Sthompsa	uint8_t		cbu_dsap;		/* LLC: destination sap */
196160703Sthompsa	uint8_t		cbu_ssap;		/* LLC: source sap */
197160703Sthompsa	uint8_t		cbu_ctl;		/* LLC: control */
198160703Sthompsa	uint16_t	cbu_protoid;		/* protocol id */
199160703Sthompsa	uint8_t		cbu_protover;		/* protocol version */
200160703Sthompsa	uint8_t		cbu_bpdutype;		/* message type */
201160703Sthompsa	uint8_t		cbu_flags;		/* flags (below) */
202160703Sthompsa
203160703Sthompsa	/* root id */
204160703Sthompsa	uint16_t	cbu_rootpri;		/* root priority */
205163863Sthompsa	uint8_t		cbu_rootaddr[6];	/* root address */
206160703Sthompsa
207160703Sthompsa	uint32_t	cbu_rootpathcost;	/* root path cost */
208160703Sthompsa
209160703Sthompsa	/* bridge id */
210160703Sthompsa	uint16_t	cbu_bridgepri;		/* bridge priority */
211160703Sthompsa	uint8_t		cbu_bridgeaddr[6];	/* bridge address */
212160703Sthompsa
213160703Sthompsa	uint16_t	cbu_portid;		/* port id */
214160703Sthompsa	uint16_t	cbu_messageage;		/* current message age */
215160703Sthompsa	uint16_t	cbu_maxage;		/* maximum age */
216160703Sthompsa	uint16_t	cbu_hellotime;		/* hello time */
217160703Sthompsa	uint16_t	cbu_forwarddelay;	/* forwarding delay */
218163863Sthompsa	uint8_t		cbu_versionlen;		/* version 1 length */
219160703Sthompsa} __attribute__((__packed__));
220163863Sthompsa#define	BSTP_BPDU_STP_LEN	(3 + 35)	/* LLC + STP pdu */
221163863Sthompsa#define	BSTP_BPDU_RSTP_LEN	(3 + 36)	/* LLC + RSTP pdu */
222160703Sthompsa
223160703Sthompsa/* topology change notification bridge protocol data unit */
224160703Sthompsastruct bstp_tbpdu {
225160703Sthompsa	uint8_t		tbu_dsap;		/* LLC: destination sap */
226160703Sthompsa	uint8_t		tbu_ssap;		/* LLC: source sap */
227160703Sthompsa	uint8_t		tbu_ctl;		/* LLC: control */
228160703Sthompsa	uint16_t	tbu_protoid;		/* protocol id */
229160703Sthompsa	uint8_t		tbu_protover;		/* protocol version */
230160703Sthompsa	uint8_t		tbu_bpdutype;		/* message type */
231160703Sthompsa} __attribute__((__packed__));
232160703Sthompsa
233160703Sthompsa/*
234160703Sthompsa * Timekeeping structure used in spanning tree code.
235160703Sthompsa */
236160703Sthompsastruct bstp_timer {
237163863Sthompsa	int		active;
238163863Sthompsa	int		latched;
239163863Sthompsa	int		value;
240160703Sthompsa};
241160703Sthompsa
242163863Sthompsastruct bstp_pri_vector {
243163863Sthompsa	uint64_t		pv_root_id;
244163863Sthompsa	uint32_t		pv_cost;
245163863Sthompsa	uint64_t		pv_dbridge_id;
246163863Sthompsa	uint16_t		pv_dport_id;
247163863Sthompsa	uint16_t		pv_port_id;
248163863Sthompsa};
249163863Sthompsa
250160703Sthompsastruct bstp_config_unit {
251163863Sthompsa	struct bstp_pri_vector	cu_pv;
252160703Sthompsa	uint16_t	cu_message_age;
253160703Sthompsa	uint16_t	cu_max_age;
254163863Sthompsa	uint16_t	cu_forward_delay;
255160703Sthompsa	uint16_t	cu_hello_time;
256160703Sthompsa	uint8_t		cu_message_type;
257163863Sthompsa	uint8_t		cu_topology_change_ack;
258160703Sthompsa	uint8_t		cu_topology_change;
259163863Sthompsa	uint8_t		cu_proposal;
260163863Sthompsa	uint8_t		cu_agree;
261163863Sthompsa	uint8_t		cu_learning;
262163863Sthompsa	uint8_t		cu_forwarding;
263163863Sthompsa	uint8_t		cu_role;
264160703Sthompsa};
265160703Sthompsa
266160703Sthompsastruct bstp_tcn_unit {
267160703Sthompsa	uint8_t		tu_message_type;
268160703Sthompsa};
269160703Sthompsa
270160703Sthompsastruct bstp_port {
271160703Sthompsa	LIST_ENTRY(bstp_port)	bp_next;
272160703Sthompsa	struct ifnet		*bp_ifp;	/* parent if */
273160703Sthompsa	struct bstp_state	*bp_bs;
274163863Sthompsa	uint8_t			bp_active;
275163863Sthompsa	uint8_t			bp_protover;
276163863Sthompsa	uint32_t		bp_flags;
277160703Sthompsa	uint32_t		bp_path_cost;
278163863Sthompsa	uint16_t		bp_port_msg_age;
279163863Sthompsa	uint16_t		bp_port_max_age;
280163863Sthompsa	uint16_t		bp_port_fdelay;
281163863Sthompsa	uint16_t		bp_port_htime;
282163863Sthompsa	uint16_t		bp_desg_msg_age;
283163863Sthompsa	uint16_t		bp_desg_max_age;
284163863Sthompsa	uint16_t		bp_desg_fdelay;
285163863Sthompsa	uint16_t		bp_desg_htime;
286163863Sthompsa	struct bstp_timer	bp_edge_delay_timer;
287163863Sthompsa	struct bstp_timer	bp_forward_delay_timer;
288163863Sthompsa	struct bstp_timer	bp_hello_timer;
289160703Sthompsa	struct bstp_timer	bp_message_age_timer;
290163863Sthompsa	struct bstp_timer	bp_migrate_delay_timer;
291163863Sthompsa	struct bstp_timer	bp_recent_backup_timer;
292163863Sthompsa	struct bstp_timer	bp_recent_root_timer;
293163863Sthompsa	struct bstp_timer	bp_tc_timer;
294163863Sthompsa	struct bstp_config_unit bp_msg_cu;
295163863Sthompsa	struct bstp_pri_vector	bp_desg_pv;
296163863Sthompsa	struct bstp_pri_vector	bp_port_pv;
297160703Sthompsa	uint16_t		bp_port_id;
298160703Sthompsa	uint8_t			bp_state;
299163863Sthompsa	uint8_t			bp_tcstate;
300163863Sthompsa	uint8_t			bp_role;
301163863Sthompsa	uint8_t			bp_infois;
302163863Sthompsa	uint8_t			bp_tc_ack;
303163863Sthompsa	uint8_t			bp_tc_prop;
304163863Sthompsa	uint8_t			bp_fdbflush;
305160703Sthompsa	uint8_t			bp_priority;
306163863Sthompsa	uint8_t			bp_p2p_link;
307163863Sthompsa	uint8_t			bp_agree;
308163863Sthompsa	uint8_t			bp_agreed;
309163863Sthompsa	uint8_t			bp_sync;
310163863Sthompsa	uint8_t			bp_synced;
311163863Sthompsa	uint8_t			bp_proposing;
312163863Sthompsa	uint8_t			bp_proposed;
313163863Sthompsa	uint8_t			bp_operedge;
314163863Sthompsa	uint8_t			bp_reroot;
315163863Sthompsa	uint8_t			bp_rcvdtc;
316163863Sthompsa	uint8_t			bp_rcvdtca;
317163863Sthompsa	uint8_t			bp_rcvdtcn;
318160867Sthompsa	uint32_t		bp_forward_transitions;
319163863Sthompsa	uint8_t			bp_txcount;
320160899Sthompsa	struct task		bp_statetask;
321163863Sthompsa	struct task		bp_rtagetask;
322160703Sthompsa};
323160703Sthompsa
324160703Sthompsa/*
325160703Sthompsa * Software state for each bridge STP.
326160703Sthompsa */
327160703Sthompsastruct bstp_state {
328160703Sthompsa	LIST_ENTRY(bstp_state)	bs_list;
329164141Sthompsa	uint8_t			bs_running;
330160703Sthompsa	struct mtx		bs_mtx;
331163863Sthompsa	struct bstp_pri_vector	bs_bridge_pv;
332163863Sthompsa	struct bstp_pri_vector	bs_root_pv;
333160703Sthompsa	struct bstp_port	*bs_root_port;
334163863Sthompsa	uint8_t			bs_protover;
335163863Sthompsa	uint16_t		bs_migration_delay;
336163863Sthompsa	uint16_t		bs_edge_delay;
337160703Sthompsa	uint16_t		bs_bridge_max_age;
338163863Sthompsa	uint16_t		bs_bridge_fdelay;
339163863Sthompsa	uint16_t		bs_bridge_htime;
340163863Sthompsa	uint16_t		bs_root_msg_age;
341163863Sthompsa	uint16_t		bs_root_max_age;
342163863Sthompsa	uint16_t		bs_root_fdelay;
343163863Sthompsa	uint16_t		bs_root_htime;
344160703Sthompsa	uint16_t		bs_hold_time;
345160703Sthompsa	uint16_t		bs_bridge_priority;
346163863Sthompsa	uint8_t			bs_txholdcount;
347163863Sthompsa	uint8_t			bs_allsynced;
348160703Sthompsa	struct callout		bs_bstpcallout;	/* STP callout */
349160703Sthompsa	struct bstp_timer	bs_link_timer;
350160867Sthompsa	struct timeval		bs_last_tc_time;
351160703Sthompsa	LIST_HEAD(, bstp_port)	bs_bplist;
352160899Sthompsa	bstp_state_cb_t		bs_state_cb;
353163863Sthompsa	bstp_rtage_cb_t		bs_rtage_cb;
354160703Sthompsa};
355160703Sthompsa
356163863Sthompsa#define	BSTP_LOCK_INIT(_bs)	mtx_init(&(_bs)->bs_mtx, "bstp", NULL, MTX_DEF)
357163863Sthompsa#define	BSTP_LOCK_DESTROY(_bs)	mtx_destroy(&(_bs)->bs_mtx)
358163863Sthompsa#define	BSTP_LOCK(_bs)		mtx_lock(&(_bs)->bs_mtx)
359163863Sthompsa#define	BSTP_UNLOCK(_bs)	mtx_unlock(&(_bs)->bs_mtx)
360163863Sthompsa#define	BSTP_LOCK_ASSERT(_bs)	mtx_assert(&(_bs)->bs_mtx, MA_OWNED)
361160703Sthompsa
362160703Sthompsaextern const uint8_t bstp_etheraddr[];
363160703Sthompsa
364160703Sthompsaextern	void (*bstp_linkstate_p)(struct ifnet *ifp, int state);
365160703Sthompsa
366163863Sthompsavoid	bstp_attach(struct bstp_state *, bstp_state_cb_t, bstp_rtage_cb_t);
367160703Sthompsavoid	bstp_detach(struct bstp_state *);
368160703Sthompsavoid	bstp_init(struct bstp_state *);
369160703Sthompsavoid	bstp_stop(struct bstp_state *);
370164626Sthompsaint	bstp_create(struct bstp_state *, struct bstp_port *, struct ifnet *);
371164626Sthompsaint	bstp_enable(struct bstp_port *);
372164626Sthompsavoid	bstp_disable(struct bstp_port *);
373164626Sthompsavoid	bstp_destroy(struct bstp_port *);
374160703Sthompsavoid	bstp_linkstate(struct ifnet *, int);
375163863Sthompsaint	bstp_set_htime(struct bstp_state *, int);
376163863Sthompsaint	bstp_set_fdelay(struct bstp_state *, int);
377163863Sthompsaint	bstp_set_maxage(struct bstp_state *, int);
378163863Sthompsaint	bstp_set_holdcount(struct bstp_state *, int);
379163863Sthompsaint	bstp_set_protocol(struct bstp_state *, int);
380163863Sthompsaint	bstp_set_priority(struct bstp_state *, int);
381163863Sthompsaint	bstp_set_port_priority(struct bstp_port *, int);
382163863Sthompsaint	bstp_set_path_cost(struct bstp_port *, uint32_t);
383163863Sthompsaint	bstp_set_edge(struct bstp_port *, int);
384163863Sthompsaint	bstp_set_autoedge(struct bstp_port *, int);
385160703Sthompsastruct mbuf *bstp_input(struct bstp_port *, struct ifnet *, struct mbuf *);
386160703Sthompsa
387160703Sthompsa#endif /* _KERNEL */
388