Home | History | Annotate | Line # | Download | only in net
if_bridgevar.h revision 1.20.4.2
      1  1.20.4.2     skrll /*	$NetBSD: if_bridgevar.h,v 1.20.4.2 2015/06/06 14:40:25 skrll Exp $	*/
      2       1.1   thorpej 
      3       1.1   thorpej /*
      4       1.1   thorpej  * Copyright 2001 Wasabi Systems, Inc.
      5       1.1   thorpej  * All rights reserved.
      6       1.1   thorpej  *
      7       1.1   thorpej  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8       1.1   thorpej  *
      9       1.1   thorpej  * Redistribution and use in source and binary forms, with or without
     10       1.1   thorpej  * modification, are permitted provided that the following conditions
     11       1.1   thorpej  * are met:
     12       1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     13       1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     14       1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     15       1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     16       1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     17       1.1   thorpej  * 3. All advertising materials mentioning features or use of this software
     18       1.1   thorpej  *    must display the following acknowledgement:
     19       1.1   thorpej  *	This product includes software developed for the NetBSD Project by
     20       1.1   thorpej  *	Wasabi Systems, Inc.
     21       1.1   thorpej  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22       1.1   thorpej  *    or promote products derived from this software without specific prior
     23       1.1   thorpej  *    written permission.
     24       1.1   thorpej  *
     25       1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26       1.1   thorpej  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27       1.1   thorpej  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28       1.1   thorpej  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29       1.1   thorpej  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30       1.1   thorpej  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31       1.1   thorpej  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32       1.1   thorpej  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33       1.1   thorpej  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34       1.1   thorpej  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35       1.1   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     36       1.1   thorpej  */
     37       1.1   thorpej 
     38       1.6     perry /*
     39       1.1   thorpej  * Copyright (c) 1999, 2000 Jason L. Wright (jason (at) thought.net)
     40       1.6     perry  * All rights reserved.
     41       1.1   thorpej  *
     42       1.6     perry  * Redistribution and use in source and binary forms, with or without
     43       1.6     perry  * modification, are permitted provided that the following conditions
     44       1.1   thorpej  * are met:
     45       1.1   thorpej  * 1. Redistributions of source code must retain the above copyright
     46       1.1   thorpej  *    notice, this list of conditions and the following disclaimer.
     47       1.1   thorpej  * 2. Redistributions in binary form must reproduce the above copyright
     48       1.1   thorpej  *    notice, this list of conditions and the following disclaimer in the
     49       1.1   thorpej  *    documentation and/or other materials provided with the distribution.
     50       1.1   thorpej  * 3. All advertising materials mentioning features or use of this software
     51       1.1   thorpej  *    must display the following acknowledgement:
     52       1.1   thorpej  *	This product includes software developed by Jason L. Wright
     53       1.1   thorpej  * 4. The name of the author may not be used to endorse or promote products
     54       1.1   thorpej  *    derived from this software without specific prior written permission.
     55       1.1   thorpej  *
     56       1.1   thorpej  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     57       1.1   thorpej  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     58       1.1   thorpej  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     59       1.1   thorpej  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
     60       1.1   thorpej  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
     61       1.1   thorpej  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     62       1.1   thorpej  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     63       1.1   thorpej  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
     64       1.1   thorpej  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
     65       1.1   thorpej  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     66       1.1   thorpej  * POSSIBILITY OF SUCH DAMAGE.
     67       1.1   thorpej  *
     68       1.1   thorpej  * OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp
     69       1.1   thorpej  */
     70       1.1   thorpej 
     71       1.1   thorpej /*
     72       1.1   thorpej  * Data structure and control definitions for bridge interfaces.
     73       1.1   thorpej  */
     74       1.1   thorpej 
     75       1.8      elad #ifndef _NET_IF_BRIDGEVAR_H_
     76       1.8      elad #define _NET_IF_BRIDGEVAR_H_
     77       1.8      elad 
     78       1.1   thorpej #include <sys/callout.h>
     79       1.1   thorpej #include <sys/queue.h>
     80      1.20     ozaki #include <sys/mutex.h>
     81      1.20     ozaki #include <sys/condvar.h>
     82       1.1   thorpej 
     83       1.1   thorpej /*
     84       1.1   thorpej  * Commands used in the SIOCSDRVSPEC ioctl.  Note the lookup of the
     85       1.1   thorpej  * bridge interface itself is keyed off the ifdrv structure.
     86       1.1   thorpej  */
     87       1.1   thorpej #define	BRDGADD			0	/* add bridge member (ifbreq) */
     88       1.1   thorpej #define	BRDGDEL			1	/* delete bridge member (ifbreq) */
     89       1.1   thorpej #define	BRDGGIFFLGS		2	/* get member if flags (ifbreq) */
     90       1.1   thorpej #define	BRDGSIFFLGS		3	/* set member if flags (ifbreq) */
     91       1.1   thorpej #define	BRDGSCACHE		4	/* set cache size (ifbrparam) */
     92       1.1   thorpej #define	BRDGGCACHE		5	/* get cache size (ifbrparam) */
     93  1.20.4.2     skrll #define	OBRDGGIFS		6	/* get member list (ifbifconf) */
     94  1.20.4.2     skrll #define	OBRDGRTS		7	/* get address list (ifbaconf) */
     95       1.1   thorpej #define	BRDGSADDR		8	/* set static address (ifbareq) */
     96       1.1   thorpej #define	BRDGSTO			9	/* set cache timeout (ifbrparam) */
     97       1.1   thorpej #define	BRDGGTO			10	/* get cache timeout (ifbrparam) */
     98       1.1   thorpej #define	BRDGDADDR		11	/* delete address (ifbareq) */
     99       1.1   thorpej #define	BRDGFLUSH		12	/* flush address cache (ifbreq) */
    100       1.1   thorpej 
    101       1.1   thorpej #define	BRDGGPRI		13	/* get priority (ifbrparam) */
    102       1.1   thorpej #define	BRDGSPRI		14	/* set priority (ifbrparam) */
    103       1.1   thorpej #define	BRDGGHT			15	/* get hello time (ifbrparam) */
    104       1.1   thorpej #define	BRDGSHT			16	/* set hello time (ifbrparam) */
    105       1.1   thorpej #define	BRDGGFD			17	/* get forward delay (ifbrparam) */
    106       1.1   thorpej #define	BRDGSFD			18	/* set forward delay (ifbrparam) */
    107       1.1   thorpej #define	BRDGGMA			19	/* get max age (ifbrparam) */
    108       1.1   thorpej #define	BRDGSMA			20	/* set max age (ifbrparam) */
    109       1.1   thorpej #define	BRDGSIFPRIO		21	/* set if priority (ifbreq) */
    110       1.3    bouyer #define BRDGSIFCOST		22	/* set if path cost (ifbreq) */
    111       1.3    bouyer #define BRDGGFILT	        23	/* get filter flags (ifbrparam) */
    112       1.3    bouyer #define BRDGSFILT	        24	/* set filter flags (ifbrparam) */
    113       1.1   thorpej 
    114  1.20.4.2     skrll #define	BRDGGIFS		25	/* get member list */
    115  1.20.4.2     skrll #define	BRDGRTS			26	/* get address list */
    116  1.20.4.2     skrll 
    117       1.1   thorpej /*
    118       1.1   thorpej  * Generic bridge control request.
    119       1.1   thorpej  */
    120       1.1   thorpej struct ifbreq {
    121       1.1   thorpej 	char		ifbr_ifsname[IFNAMSIZ];	/* member if name */
    122       1.1   thorpej 	uint32_t	ifbr_ifsflags;		/* member if flags */
    123       1.1   thorpej 	uint8_t		ifbr_state;		/* member if STP state */
    124       1.1   thorpej 	uint8_t		ifbr_priority;		/* member if STP priority */
    125       1.3    bouyer 	uint8_t		ifbr_path_cost;		/* member if STP cost */
    126       1.1   thorpej 	uint8_t		ifbr_portno;		/* member if port number */
    127       1.1   thorpej };
    128       1.1   thorpej 
    129       1.1   thorpej /* BRDGGIFFLAGS, BRDGSIFFLAGS */
    130       1.1   thorpej #define	IFBIF_LEARNING		0x01	/* if can learn */
    131       1.1   thorpej #define	IFBIF_DISCOVER		0x02	/* if sends packets w/ unknown dest. */
    132       1.1   thorpej #define	IFBIF_STP		0x04	/* if participates in spanning tree */
    133       1.1   thorpej 
    134       1.1   thorpej #define	IFBIFBITS	"\020\1LEARNING\2DISCOVER\3STP"
    135       1.1   thorpej 
    136       1.1   thorpej /* BRDGFLUSH */
    137       1.1   thorpej #define	IFBF_FLUSHDYN		0x00	/* flush learned addresses only */
    138       1.1   thorpej #define	IFBF_FLUSHALL		0x01	/* flush all addresses */
    139       1.1   thorpej 
    140       1.2  perseant /* BRDGSFILT */
    141       1.2  perseant #define IFBF_FILT_USEIPF	0x00000001 /* enable ipf on bridge */
    142       1.2  perseant #define IFBF_FILT_MASK		0x00000001 /* mask of valid values */
    143       1.2  perseant 
    144       1.1   thorpej /* STP port states */
    145       1.1   thorpej #define	BSTP_IFSTATE_DISABLED	0
    146       1.1   thorpej #define	BSTP_IFSTATE_LISTENING	1
    147       1.1   thorpej #define	BSTP_IFSTATE_LEARNING	2
    148       1.1   thorpej #define	BSTP_IFSTATE_FORWARDING	3
    149       1.1   thorpej #define	BSTP_IFSTATE_BLOCKING	4
    150       1.1   thorpej 
    151       1.1   thorpej /*
    152       1.1   thorpej  * Interface list structure.
    153       1.1   thorpej  */
    154       1.1   thorpej struct ifbifconf {
    155       1.1   thorpej 	uint32_t	ifbic_len;	/* buffer size */
    156       1.1   thorpej 	union {
    157      1.10  christos 		void *	ifbicu_buf;
    158       1.1   thorpej 		struct ifbreq *ifbicu_req;
    159       1.1   thorpej 	} ifbic_ifbicu;
    160       1.1   thorpej #define	ifbic_buf	ifbic_ifbicu.ifbicu_buf
    161       1.1   thorpej #define	ifbic_req	ifbic_ifbicu.ifbicu_req
    162       1.1   thorpej };
    163       1.1   thorpej 
    164       1.1   thorpej /*
    165       1.1   thorpej  * Bridge address request.
    166       1.1   thorpej  */
    167       1.1   thorpej struct ifbareq {
    168       1.1   thorpej 	char		ifba_ifsname[IFNAMSIZ];	/* member if name */
    169  1.20.4.2     skrll 	time_t		ifba_expire;		/* address expire time */
    170       1.1   thorpej 	uint8_t		ifba_flags;		/* address flags */
    171       1.1   thorpej 	uint8_t		ifba_dst[ETHER_ADDR_LEN];/* destination address */
    172       1.1   thorpej };
    173       1.1   thorpej 
    174       1.1   thorpej #define	IFBAF_TYPEMASK	0x03	/* address type mask */
    175       1.1   thorpej #define	IFBAF_DYNAMIC	0x00	/* dynamically learned address */
    176       1.1   thorpej #define	IFBAF_STATIC	0x01	/* static address */
    177       1.1   thorpej 
    178       1.1   thorpej #define	IFBAFBITS	"\020\1STATIC"
    179       1.1   thorpej 
    180       1.1   thorpej /*
    181       1.1   thorpej  * Address list structure.
    182       1.1   thorpej  */
    183       1.1   thorpej struct ifbaconf {
    184       1.1   thorpej 	uint32_t	ifbac_len;	/* buffer size */
    185       1.1   thorpej 	union {
    186      1.10  christos 		void *ifbacu_buf;
    187       1.1   thorpej 		struct ifbareq *ifbacu_req;
    188       1.1   thorpej 	} ifbac_ifbacu;
    189       1.1   thorpej #define	ifbac_buf	ifbac_ifbacu.ifbacu_buf
    190       1.1   thorpej #define	ifbac_req	ifbac_ifbacu.ifbacu_req
    191       1.1   thorpej };
    192       1.1   thorpej 
    193       1.1   thorpej /*
    194       1.1   thorpej  * Bridge parameter structure.
    195       1.1   thorpej  */
    196       1.1   thorpej struct ifbrparam {
    197       1.1   thorpej 	union {
    198       1.1   thorpej 		uint32_t ifbrpu_int32;
    199       1.1   thorpej 		uint16_t ifbrpu_int16;
    200       1.1   thorpej 		uint8_t ifbrpu_int8;
    201       1.1   thorpej 	} ifbrp_ifbrpu;
    202       1.1   thorpej };
    203       1.1   thorpej #define	ifbrp_csize	ifbrp_ifbrpu.ifbrpu_int32	/* cache size */
    204       1.1   thorpej #define	ifbrp_ctime	ifbrp_ifbrpu.ifbrpu_int32	/* cache time (sec) */
    205       1.1   thorpej #define	ifbrp_prio	ifbrp_ifbrpu.ifbrpu_int16	/* bridge priority */
    206       1.1   thorpej #define	ifbrp_hellotime	ifbrp_ifbrpu.ifbrpu_int8	/* hello time (sec) */
    207       1.1   thorpej #define	ifbrp_fwddelay	ifbrp_ifbrpu.ifbrpu_int8	/* fwd time (sec) */
    208       1.1   thorpej #define	ifbrp_maxage	ifbrp_ifbrpu.ifbrpu_int8	/* max age (sec) */
    209       1.2  perseant #define	ifbrp_filter	ifbrp_ifbrpu.ifbrpu_int32	/* filtering flags */
    210       1.1   thorpej 
    211       1.1   thorpej #ifdef _KERNEL
    212  1.20.4.1     skrll #ifdef _KERNEL_OPT
    213  1.20.4.1     skrll #include "opt_net_mpsafe.h"
    214  1.20.4.1     skrll #endif /* _KERNEL_OPT */
    215  1.20.4.1     skrll 
    216  1.20.4.1     skrll #include <sys/pserialize.h>
    217  1.20.4.1     skrll #include <sys/workqueue.h>
    218  1.20.4.1     skrll 
    219      1.17     ozaki #include <net/pktqueue.h>
    220      1.17     ozaki 
    221       1.1   thorpej /*
    222       1.1   thorpej  * Timekeeping structure used in spanning tree code.
    223       1.1   thorpej  */
    224       1.1   thorpej struct bridge_timer {
    225       1.1   thorpej 	uint16_t	active;
    226       1.1   thorpej 	uint16_t	value;
    227       1.1   thorpej };
    228       1.1   thorpej 
    229       1.1   thorpej struct bstp_config_unit {
    230       1.1   thorpej 	uint64_t	cu_rootid;
    231       1.1   thorpej 	uint64_t	cu_bridge_id;
    232       1.1   thorpej 	uint32_t	cu_root_path_cost;
    233       1.1   thorpej 	uint16_t	cu_message_age;
    234       1.1   thorpej 	uint16_t	cu_max_age;
    235       1.1   thorpej 	uint16_t	cu_hello_time;
    236       1.1   thorpej 	uint16_t	cu_forward_delay;
    237       1.1   thorpej 	uint16_t	cu_port_id;
    238       1.1   thorpej 	uint8_t		cu_message_type;
    239       1.1   thorpej 	uint8_t		cu_topology_change_acknowledgment;
    240       1.1   thorpej 	uint8_t		cu_topology_change;
    241       1.1   thorpej };
    242       1.1   thorpej 
    243       1.1   thorpej struct bstp_tcn_unit {
    244       1.1   thorpej 	uint8_t		tu_message_type;
    245       1.1   thorpej };
    246       1.1   thorpej 
    247       1.1   thorpej /*
    248       1.1   thorpej  * Bridge interface list entry.
    249       1.1   thorpej  */
    250       1.1   thorpej struct bridge_iflist {
    251       1.1   thorpej 	LIST_ENTRY(bridge_iflist) bif_next;
    252       1.1   thorpej 	uint64_t		bif_designated_root;
    253       1.1   thorpej 	uint64_t		bif_designated_bridge;
    254       1.1   thorpej 	uint32_t		bif_path_cost;
    255       1.1   thorpej 	uint32_t		bif_designated_cost;
    256       1.1   thorpej 	struct bridge_timer	bif_hold_timer;
    257       1.1   thorpej 	struct bridge_timer	bif_message_age_timer;
    258       1.1   thorpej 	struct bridge_timer	bif_forward_delay_timer;
    259       1.1   thorpej 	uint16_t		bif_port_id;
    260       1.1   thorpej 	uint16_t		bif_designated_port;
    261       1.7     seanb 	struct bstp_config_unit	bif_config_bpdu;
    262       1.1   thorpej 	uint8_t			bif_state;
    263       1.1   thorpej 	uint8_t			bif_topology_change_acknowledge;
    264       1.1   thorpej 	uint8_t			bif_config_pending;
    265       1.1   thorpej 	uint8_t			bif_change_detection_enabled;
    266       1.1   thorpej 	uint8_t			bif_priority;
    267       1.1   thorpej 	struct ifnet		*bif_ifp;	/* member if */
    268       1.1   thorpej 	uint32_t		bif_flags;	/* member if flags */
    269      1.20     ozaki 	uint32_t		bif_refs;	/* reference count */
    270      1.20     ozaki 	bool			bif_waiting;	/* waiting for released  */
    271       1.1   thorpej };
    272       1.1   thorpej 
    273       1.1   thorpej /*
    274       1.1   thorpej  * Bridge route node.
    275       1.1   thorpej  */
    276       1.1   thorpej struct bridge_rtnode {
    277       1.1   thorpej 	LIST_ENTRY(bridge_rtnode) brt_hash;	/* hash table linkage */
    278       1.1   thorpej 	LIST_ENTRY(bridge_rtnode) brt_list;	/* list linkage */
    279       1.1   thorpej 	struct ifnet		*brt_ifp;	/* destination if */
    280      1.12  christos 	time_t			brt_expire;	/* expiration time */
    281       1.1   thorpej 	uint8_t			brt_flags;	/* address flags */
    282       1.1   thorpej 	uint8_t			brt_addr[ETHER_ADDR_LEN];
    283       1.1   thorpej };
    284       1.1   thorpej 
    285       1.1   thorpej /*
    286       1.1   thorpej  * Software state for each bridge.
    287       1.1   thorpej  */
    288       1.1   thorpej struct bridge_softc {
    289       1.1   thorpej 	struct ifnet		sc_if;
    290       1.1   thorpej 	LIST_ENTRY(bridge_softc) sc_list;
    291       1.1   thorpej 	uint64_t		sc_designated_root;
    292       1.1   thorpej 	uint64_t		sc_bridge_id;
    293       1.1   thorpej 	struct bridge_iflist	*sc_root_port;
    294       1.1   thorpej 	uint32_t		sc_root_path_cost;
    295       1.1   thorpej 	uint16_t		sc_max_age;
    296       1.1   thorpej 	uint16_t		sc_hello_time;
    297       1.1   thorpej 	uint16_t		sc_forward_delay;
    298       1.1   thorpej 	uint16_t		sc_bridge_max_age;
    299       1.1   thorpej 	uint16_t		sc_bridge_hello_time;
    300       1.1   thorpej 	uint16_t		sc_bridge_forward_delay;
    301       1.1   thorpej 	uint16_t		sc_topology_change_time;
    302       1.1   thorpej 	uint16_t		sc_hold_time;
    303       1.1   thorpej 	uint16_t		sc_bridge_priority;
    304       1.1   thorpej 	uint8_t			sc_topology_change_detected;
    305       1.1   thorpej 	uint8_t			sc_topology_change;
    306       1.1   thorpej 	struct bridge_timer	sc_hello_timer;
    307       1.1   thorpej 	struct bridge_timer	sc_topology_change_timer;
    308       1.1   thorpej 	struct bridge_timer	sc_tcn_timer;
    309       1.1   thorpej 	uint32_t		sc_brtmax;	/* max # of addresses */
    310       1.1   thorpej 	uint32_t		sc_brtcnt;	/* cur. # of addresses */
    311       1.1   thorpej 	uint32_t		sc_brttimeout;	/* rt timeout in seconds */
    312      1.11        ad 	callout_t		sc_brcallout;	/* bridge callout */
    313      1.11        ad 	callout_t		sc_bstpcallout;	/* STP callout */
    314       1.1   thorpej 	LIST_HEAD(, bridge_iflist) sc_iflist;	/* member interface list */
    315  1.20.4.1     skrll 	kmutex_t		*sc_iflist_intr_lock;
    316      1.20     ozaki 	kcondvar_t		sc_iflist_cv;
    317  1.20.4.1     skrll 	pserialize_t		sc_iflist_psz;
    318  1.20.4.1     skrll 	kmutex_t		*sc_iflist_lock;
    319       1.1   thorpej 	LIST_HEAD(, bridge_rtnode) *sc_rthash;	/* our forwarding table */
    320       1.1   thorpej 	LIST_HEAD(, bridge_rtnode) sc_rtlist;	/* list version of above */
    321  1.20.4.1     skrll 	kmutex_t		*sc_rtlist_intr_lock;
    322      1.20     ozaki 	kmutex_t		*sc_rtlist_lock;
    323  1.20.4.1     skrll 	pserialize_t		sc_rtlist_psz;
    324  1.20.4.1     skrll 	struct workqueue	*sc_rtage_wq;
    325       1.1   thorpej 	uint32_t		sc_rthash_key;	/* key for hash */
    326       1.2  perseant 	uint32_t		sc_filter_flags; /* ipf and flags */
    327      1.16     ozaki 	pktqueue_t *		sc_fwd_pktq;
    328       1.1   thorpej };
    329       1.1   thorpej 
    330       1.1   thorpej extern const uint8_t bstp_etheraddr[];
    331       1.1   thorpej 
    332       1.4    itojun void	bridge_ifdetach(struct ifnet *);
    333       1.1   thorpej 
    334       1.9    dyoung int	bridge_output(struct ifnet *, struct mbuf *, const struct sockaddr *,
    335       1.1   thorpej 	    struct rtentry *);
    336       1.1   thorpej 
    337       1.1   thorpej void	bstp_initialization(struct bridge_softc *);
    338       1.1   thorpej void	bstp_stop(struct bridge_softc *);
    339      1.18     ozaki void	bstp_input(struct bridge_softc *, struct bridge_iflist *, struct mbuf *);
    340       1.1   thorpej 
    341       1.5       jdc void	bridge_enqueue(struct bridge_softc *, struct ifnet *, struct mbuf *,
    342       1.5       jdc 	    int);
    343       1.1   thorpej 
    344      1.20     ozaki #ifdef NET_MPSAFE
    345      1.20     ozaki #define BRIDGE_MPSAFE	1
    346      1.20     ozaki #endif
    347      1.20     ozaki 
    348      1.20     ozaki #define BRIDGE_LOCK(_sc)	if ((_sc)->sc_iflist_lock) \
    349      1.20     ozaki 					mutex_enter((_sc)->sc_iflist_lock)
    350      1.20     ozaki #define BRIDGE_UNLOCK(_sc)	if ((_sc)->sc_iflist_lock) \
    351      1.20     ozaki 					mutex_exit((_sc)->sc_iflist_lock)
    352      1.20     ozaki #define BRIDGE_LOCKED(_sc)	(!(_sc)->sc_iflist_lock || \
    353      1.20     ozaki 				 mutex_owned((_sc)->sc_iflist_lock))
    354      1.20     ozaki 
    355  1.20.4.1     skrll #define BRIDGE_INTR_LOCK(_sc)	if ((_sc)->sc_iflist_intr_lock) \
    356  1.20.4.1     skrll 					mutex_enter((_sc)->sc_iflist_intr_lock)
    357  1.20.4.1     skrll #define BRIDGE_INTR_UNLOCK(_sc)	if ((_sc)->sc_iflist_intr_lock) \
    358  1.20.4.1     skrll 					mutex_exit((_sc)->sc_iflist_intr_lock)
    359  1.20.4.1     skrll #define BRIDGE_INTR_LOCKED(_sc)	(!(_sc)->sc_iflist_intr_lock || \
    360  1.20.4.1     skrll 				 mutex_owned((_sc)->sc_iflist_intr_lock))
    361  1.20.4.1     skrll 
    362  1.20.4.1     skrll #ifdef BRIDGE_MPSAFE
    363  1.20.4.1     skrll /*
    364  1.20.4.1     skrll  * These macros can be used in both HW interrupt and softint contexts.
    365  1.20.4.1     skrll  */
    366  1.20.4.1     skrll #define BRIDGE_PSZ_RENTER(__s)	do { \
    367  1.20.4.1     skrll 					if (!cpu_intr_p()) \
    368  1.20.4.1     skrll 						__s = pserialize_read_enter(); \
    369  1.20.4.1     skrll 					else \
    370  1.20.4.1     skrll 						__s = splhigh(); \
    371  1.20.4.1     skrll 				} while (0)
    372  1.20.4.1     skrll #define BRIDGE_PSZ_REXIT(__s)	do { \
    373  1.20.4.1     skrll 					if (!cpu_intr_p()) \
    374  1.20.4.1     skrll 						pserialize_read_exit(__s); \
    375  1.20.4.1     skrll 					else \
    376  1.20.4.1     skrll 						splx(__s); \
    377  1.20.4.1     skrll 				} while (0)
    378  1.20.4.1     skrll #else /* BRIDGE_MPSAFE */
    379  1.20.4.1     skrll #define BRIDGE_PSZ_RENTER(__s)	do { __s = 0; } while (0)
    380  1.20.4.1     skrll #define BRIDGE_PSZ_REXIT(__s)	do { (void)__s; } while (0)
    381  1.20.4.1     skrll #endif /* BRIDGE_MPSAFE */
    382  1.20.4.1     skrll 
    383  1.20.4.1     skrll #define BRIDGE_PSZ_PERFORM(_sc)	if ((_sc)->sc_iflist_psz) \
    384  1.20.4.1     skrll 					pserialize_perform((_sc)->sc_iflist_psz);
    385  1.20.4.1     skrll 
    386  1.20.4.1     skrll /*
    387  1.20.4.1     skrll  * Locking notes:
    388  1.20.4.1     skrll  * - Updates of sc_iflist are serialized by sc_iflist_lock (an adaptive mutex)
    389  1.20.4.1     skrll  * - Items of sc_iflist (bridge_iflist) is protected by both pserialize
    390  1.20.4.1     skrll  *   (sc_iflist_psz) and reference counting (bridge_iflist#bif_refs)
    391  1.20.4.1     skrll  * - Before destroying an item of sc_iflist, we have to do pserialize_perform
    392  1.20.4.1     skrll  *   and synchronize with the reference counting via a conditional variable
    393  1.20.4.1     skrll  *   (sc_iflist_cz)
    394  1.20.4.1     skrll  * - sc_iflist_intr_lock (a spin mutex) is used for the CV
    395  1.20.4.1     skrll  *   - A spin mutex is required because the reference counting can be used
    396  1.20.4.1     skrll  *     in HW interrupt context
    397  1.20.4.1     skrll  *   - The mutex is also used for STP
    398  1.20.4.1     skrll  *   - Once we change to execute entire Layer 2 in softint context,
    399  1.20.4.1     skrll  *     we can get rid of sc_iflist_intr_lock
    400  1.20.4.1     skrll  * - Updates of sc_rtlist are serialized by sc_rtlist_intr_lock (a spin mutex)
    401  1.20.4.1     skrll  *   - The sc_rtlist can be modified in HW interrupt context for now
    402  1.20.4.1     skrll  * - sc_rtlist_lock (an adaptive mutex) is only for pserialize
    403  1.20.4.1     skrll  *   - Once we change to execute entire Layer 2 in softint context,
    404  1.20.4.1     skrll  *     we can get rid of sc_rtlist_intr_lock
    405  1.20.4.1     skrll  * - A workqueue is used to run bridge_rtage in LWP context via bridge_timer callout
    406  1.20.4.1     skrll  *   - bridge_rtage uses pserialize that requires non-interrupt context
    407  1.20.4.1     skrll  */
    408       1.1   thorpej #endif /* _KERNEL */
    409       1.8      elad #endif /* !_NET_IF_BRIDGEVAR_H_ */
    410