1ac93838fSSimon Schubert /* 2ac93838fSSimon Schubert * Copyright 2001 Wasabi Systems, Inc. 3ac93838fSSimon Schubert * All rights reserved. 4ac93838fSSimon Schubert * 5ac93838fSSimon Schubert * Written by Jason R. Thorpe for Wasabi Systems, Inc. 6ac93838fSSimon Schubert * 7ac93838fSSimon Schubert * Redistribution and use in source and binary forms, with or without 8ac93838fSSimon Schubert * modification, are permitted provided that the following conditions 9ac93838fSSimon Schubert * are met: 10ac93838fSSimon Schubert * 1. Redistributions of source code must retain the above copyright 11ac93838fSSimon Schubert * notice, this list of conditions and the following disclaimer. 12ac93838fSSimon Schubert * 2. Redistributions in binary form must reproduce the above copyright 13ac93838fSSimon Schubert * notice, this list of conditions and the following disclaimer in the 14ac93838fSSimon Schubert * documentation and/or other materials provided with the distribution. 15ac93838fSSimon Schubert * 3. All advertising materials mentioning features or use of this software 16ac93838fSSimon Schubert * must display the following acknowledgement: 17ac93838fSSimon Schubert * This product includes software developed for the NetBSD Project by 18ac93838fSSimon Schubert * Wasabi Systems, Inc. 19ac93838fSSimon Schubert * 4. The name of Wasabi Systems, Inc. may not be used to endorse 20ac93838fSSimon Schubert * or promote products derived from this software without specific prior 21ac93838fSSimon Schubert * written permission. 22ac93838fSSimon Schubert * 23ac93838fSSimon Schubert * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 24ac93838fSSimon Schubert * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 25ac93838fSSimon Schubert * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 26ac93838fSSimon Schubert * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 27ac93838fSSimon Schubert * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 28ac93838fSSimon Schubert * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 29ac93838fSSimon Schubert * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 30ac93838fSSimon Schubert * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 31ac93838fSSimon Schubert * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32ac93838fSSimon Schubert * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 33ac93838fSSimon Schubert * POSSIBILITY OF SUCH DAMAGE. 34ac93838fSSimon Schubert */ 35ac93838fSSimon Schubert 36ac93838fSSimon Schubert /* 37ac93838fSSimon Schubert * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) 38ac93838fSSimon Schubert * All rights reserved. 39ac93838fSSimon Schubert * 40ac93838fSSimon Schubert * Redistribution and use in source and binary forms, with or without 41ac93838fSSimon Schubert * modification, are permitted provided that the following conditions 42ac93838fSSimon Schubert * are met: 43ac93838fSSimon Schubert * 1. Redistributions of source code must retain the above copyright 44ac93838fSSimon Schubert * notice, this list of conditions and the following disclaimer. 45ac93838fSSimon Schubert * 2. Redistributions in binary form must reproduce the above copyright 46ac93838fSSimon Schubert * notice, this list of conditions and the following disclaimer in the 47ac93838fSSimon Schubert * documentation and/or other materials provided with the distribution. 48ac93838fSSimon Schubert * 3. All advertising materials mentioning features or use of this software 49ac93838fSSimon Schubert * must display the following acknowledgement: 50ac93838fSSimon Schubert * This product includes software developed by Jason L. Wright 51ac93838fSSimon Schubert * 4. The name of the author may not be used to endorse or promote products 52ac93838fSSimon Schubert * derived from this software without specific prior written permission. 53ac93838fSSimon Schubert * 54ac93838fSSimon Schubert * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 55ac93838fSSimon Schubert * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 56ac93838fSSimon Schubert * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 57ac93838fSSimon Schubert * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 58ac93838fSSimon Schubert * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 59ac93838fSSimon Schubert * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 60ac93838fSSimon Schubert * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 61ac93838fSSimon Schubert * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 62ac93838fSSimon Schubert * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 63ac93838fSSimon Schubert * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 64ac93838fSSimon Schubert * POSSIBILITY OF SUCH DAMAGE. 65ac93838fSSimon Schubert * 66ac93838fSSimon Schubert * $OpenBSD: if_bridge.h,v 1.14 2001/03/22 03:48:29 jason Exp $ 67ac93838fSSimon Schubert * $NetBSD: if_bridgevar.h,v 1.4 2003/07/08 07:13:50 itojun Exp $ 68ac93838fSSimon Schubert * $FreeBSD: src/sys/net/if_bridgevar.h,v 1.4 2005/07/06 01:24:45 thompsa Exp $ 69ac93838fSSimon Schubert */ 70ac93838fSSimon Schubert 718f7b13efSSepherosa Ziehau #ifndef _NET_IF_BRIDGEVAR_H 728f7b13efSSepherosa Ziehau #define _NET_IF_BRIDGEVAR_H 738f7b13efSSepherosa Ziehau 74ac93838fSSimon Schubert /* 75ac93838fSSimon Schubert * Data structure and control definitions for bridge interfaces. 76ac93838fSSimon Schubert */ 77ac93838fSSimon Schubert 78ac93838fSSimon Schubert #include <sys/callout.h> 79ac93838fSSimon Schubert #include <sys/queue.h> 80d7f8e381SSascha Wildner #ifdef _KERNEL 815337421cSSepherosa Ziehau #include <net/netisr2.h> 82d7f8e381SSascha Wildner #endif 83ac93838fSSimon Schubert 84ac93838fSSimon Schubert /* 85ac93838fSSimon Schubert * Commands used in the SIOCSDRVSPEC ioctl. Note the lookup of the 86ac93838fSSimon Schubert * bridge interface itself is keyed off the ifdrv structure. 87ac93838fSSimon Schubert */ 88ac93838fSSimon Schubert #define BRDGADD 0 /* add bridge member (ifbreq) */ 89ac93838fSSimon Schubert #define BRDGDEL 1 /* delete bridge member (ifbreq) */ 90ac93838fSSimon Schubert #define BRDGGIFFLGS 2 /* get member if flags (ifbreq) */ 91ac93838fSSimon Schubert #define BRDGSIFFLGS 3 /* set member if flags (ifbreq) */ 92ac93838fSSimon Schubert #define BRDGSCACHE 4 /* set cache size (ifbrparam) */ 93ac93838fSSimon Schubert #define BRDGGCACHE 5 /* get cache size (ifbrparam) */ 94ac93838fSSimon Schubert #define BRDGGIFS 6 /* get member list (ifbifconf) */ 95ac93838fSSimon Schubert #define BRDGRTS 7 /* get address list (ifbaconf) */ 96ac93838fSSimon Schubert #define BRDGSADDR 8 /* set static address (ifbareq) */ 97ac93838fSSimon Schubert #define BRDGSTO 9 /* set cache timeout (ifbrparam) */ 98ac93838fSSimon Schubert #define BRDGGTO 10 /* get cache timeout (ifbrparam) */ 99ac93838fSSimon Schubert #define BRDGDADDR 11 /* delete address (ifbareq) */ 100ac93838fSSimon Schubert #define BRDGFLUSH 12 /* flush address cache (ifbreq) */ 101ac93838fSSimon Schubert 102ac93838fSSimon Schubert #define BRDGGPRI 13 /* get priority (ifbrparam) */ 103ac93838fSSimon Schubert #define BRDGSPRI 14 /* set priority (ifbrparam) */ 104ac93838fSSimon Schubert #define BRDGGHT 15 /* get hello time (ifbrparam) */ 105ac93838fSSimon Schubert #define BRDGSHT 16 /* set hello time (ifbrparam) */ 106ac93838fSSimon Schubert #define BRDGGFD 17 /* get forward delay (ifbrparam) */ 107ac93838fSSimon Schubert #define BRDGSFD 18 /* set forward delay (ifbrparam) */ 108ac93838fSSimon Schubert #define BRDGGMA 19 /* get max age (ifbrparam) */ 109ac93838fSSimon Schubert #define BRDGSMA 20 /* set max age (ifbrparam) */ 110ac93838fSSimon Schubert #define BRDGSIFPRIO 21 /* set if priority (ifbreq) */ 111ac93838fSSimon Schubert #define BRDGSIFCOST 22 /* set if path cost (ifbreq) */ 112d217f5e5SScott Ullrich #define BRDGADDS 23 /* add bridge span member (ifbreq) */ 113d217f5e5SScott Ullrich #define BRDGDELS 24 /* delete bridge span member (ifbreq) */ 1141e858374SMatthew Dillon #define BRDGSBONDWGHT 25 /* set bonding weighting (ifbreq) */ 115ac93838fSSimon Schubert 116ac93838fSSimon Schubert /* 117ac93838fSSimon Schubert * Generic bridge control request. 118ac93838fSSimon Schubert */ 119ac93838fSSimon Schubert struct ifbreq { 120ac93838fSSimon Schubert char ifbr_ifsname[IFNAMSIZ]; /* member if name */ 121ac93838fSSimon Schubert uint32_t ifbr_ifsflags; /* member if flags */ 122ac93838fSSimon Schubert uint8_t ifbr_state; /* member if STP state */ 123ac93838fSSimon Schubert uint8_t ifbr_priority; /* member if STP priority */ 124ac93838fSSimon Schubert uint8_t ifbr_path_cost; /* member if STP cost */ 125ac93838fSSimon Schubert uint8_t ifbr_portno; /* member if port number */ 12670d9a675SMatthew Dillon uint64_t ifbr_designated_root; /* synthesized */ 12770d9a675SMatthew Dillon uint64_t ifbr_designated_bridge; 12870d9a675SMatthew Dillon uint32_t ifbr_designated_cost; 12970d9a675SMatthew Dillon uint16_t ifbr_designated_port; 1303677aae9SMatthew Dillon uint16_t unused01; 13170d9a675SMatthew Dillon uint64_t ifbr_peer_root; /* from peer */ 13270d9a675SMatthew Dillon uint64_t ifbr_peer_bridge; /* from peer */ 13370d9a675SMatthew Dillon uint32_t ifbr_peer_cost; /* from peer */ 13470d9a675SMatthew Dillon uint16_t ifbr_peer_port; /* from peer */ 13570d9a675SMatthew Dillon uint16_t unused02; 1361e858374SMatthew Dillon uint16_t ifbr_bond_weight; 1371e858374SMatthew Dillon uint16_t unused03; 1381e858374SMatthew Dillon uint32_t unused04[8]; 139ac93838fSSimon Schubert }; 140ac93838fSSimon Schubert 141ac93838fSSimon Schubert /* BRDGGIFFLAGS, BRDGSIFFLAGS */ 142ac93838fSSimon Schubert #define IFBIF_LEARNING 0x01 /* if can learn */ 143ac93838fSSimon Schubert #define IFBIF_DISCOVER 0x02 /* if sends packets w/ unknown dest. */ 144ac93838fSSimon Schubert #define IFBIF_STP 0x04 /* if participates in spanning tree */ 145d217f5e5SScott Ullrich #define IFBIF_SPAN 0x08 /* if is a span port */ 14670d9a675SMatthew Dillon #define IFBIF_DESIGNATED 0x10 /* mostly age timer expired */ 14770d9a675SMatthew Dillon #define IFBIF_ROOT 0x20 /* selected root or near-root */ 148ac93838fSSimon Schubert 14970d9a675SMatthew Dillon #define IFBIF_KEEPMASK (IFBIF_SPAN | IFBIF_DESIGNATED | IFBIF_ROOT) 15070d9a675SMatthew Dillon 15170d9a675SMatthew Dillon #define IFBIFBITS "\020\1LEARNING\2DISCOVER\3STP\4SPAN\5DESIGNATED" \ 15270d9a675SMatthew Dillon "\6ROOT" 153ac93838fSSimon Schubert 154ac93838fSSimon Schubert /* BRDGFLUSH */ 155ac93838fSSimon Schubert #define IFBF_FLUSHDYN 0x00 /* flush learned addresses only */ 156ac93838fSSimon Schubert #define IFBF_FLUSHALL 0x01 /* flush all addresses */ 15730ced003SSepherosa Ziehau #define IFBF_FLUSHSYNC 0x02 /* synchronized flush */ 158ac93838fSSimon Schubert 159ac93838fSSimon Schubert /* STP port states */ 160ac93838fSSimon Schubert #define BSTP_IFSTATE_DISABLED 0 161ac93838fSSimon Schubert #define BSTP_IFSTATE_LISTENING 1 162ac93838fSSimon Schubert #define BSTP_IFSTATE_LEARNING 2 163ac93838fSSimon Schubert #define BSTP_IFSTATE_FORWARDING 3 164ac93838fSSimon Schubert #define BSTP_IFSTATE_BLOCKING 4 1651e858374SMatthew Dillon #define BSTP_IFSTATE_BONDED 5 /* link2 bonding mode */ 1661e858374SMatthew Dillon #define BSTP_IFSTATE_L1BLOCKING 6 /* link1 blocking mode no-activity */ 167ac93838fSSimon Schubert 168ac93838fSSimon Schubert /* 169ac93838fSSimon Schubert * Interface list structure. 170ac93838fSSimon Schubert */ 171ac93838fSSimon Schubert struct ifbifconf { 172ac93838fSSimon Schubert uint32_t ifbic_len; /* buffer size */ 173ac93838fSSimon Schubert union { 174ac93838fSSimon Schubert caddr_t ifbicu_buf; 175ac93838fSSimon Schubert struct ifbreq *ifbicu_req; 176ac93838fSSimon Schubert } ifbic_ifbicu; 177ac93838fSSimon Schubert #define ifbic_buf ifbic_ifbicu.ifbicu_buf 178ac93838fSSimon Schubert #define ifbic_req ifbic_ifbicu.ifbicu_req 179ac93838fSSimon Schubert }; 180ac93838fSSimon Schubert 181ac93838fSSimon Schubert /* 182ac93838fSSimon Schubert * Bridge address request. 183ac93838fSSimon Schubert */ 184ac93838fSSimon Schubert struct ifbareq { 185ac93838fSSimon Schubert char ifba_ifsname[IFNAMSIZ]; /* member if name */ 186cec73927SMatthew Dillon time_t ifba_expire; /* address expire time */ 187ac93838fSSimon Schubert uint8_t ifba_flags; /* address flags */ 188ac93838fSSimon Schubert uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */ 189ac93838fSSimon Schubert }; 190ac93838fSSimon Schubert 191ac93838fSSimon Schubert #define IFBAF_TYPEMASK 0x03 /* address type mask */ 192ac93838fSSimon Schubert #define IFBAF_DYNAMIC 0x00 /* dynamically learned address */ 193ac93838fSSimon Schubert #define IFBAF_STATIC 0x01 /* static address */ 194ac93838fSSimon Schubert 195ac93838fSSimon Schubert #define IFBAFBITS "\020\1STATIC" 196ac93838fSSimon Schubert 197ac93838fSSimon Schubert /* 198ac93838fSSimon Schubert * Address list structure. 199ac93838fSSimon Schubert */ 200ac93838fSSimon Schubert struct ifbaconf { 201ac93838fSSimon Schubert uint32_t ifbac_len; /* buffer size */ 202ac93838fSSimon Schubert union { 203ac93838fSSimon Schubert caddr_t ifbacu_buf; 204ac93838fSSimon Schubert struct ifbareq *ifbacu_req; 205ac93838fSSimon Schubert } ifbac_ifbacu; 206ac93838fSSimon Schubert #define ifbac_buf ifbac_ifbacu.ifbacu_buf 207ac93838fSSimon Schubert #define ifbac_req ifbac_ifbacu.ifbacu_req 208ac93838fSSimon Schubert }; 209ac93838fSSimon Schubert 210ac93838fSSimon Schubert /* 211ac93838fSSimon Schubert * Bridge parameter structure. 212ac93838fSSimon Schubert */ 213ac93838fSSimon Schubert struct ifbrparam { 214ac93838fSSimon Schubert union { 215ac93838fSSimon Schubert uint32_t ifbrpu_int32; 216ac93838fSSimon Schubert uint16_t ifbrpu_int16; 217ac93838fSSimon Schubert uint8_t ifbrpu_int8; 218ac93838fSSimon Schubert } ifbrp_ifbrpu; 219ac93838fSSimon Schubert }; 220ac93838fSSimon Schubert #define ifbrp_csize ifbrp_ifbrpu.ifbrpu_int32 /* cache size */ 221ac93838fSSimon Schubert #define ifbrp_ctime ifbrp_ifbrpu.ifbrpu_int32 /* cache time (sec) */ 222ac93838fSSimon Schubert #define ifbrp_prio ifbrp_ifbrpu.ifbrpu_int16 /* bridge priority */ 223ac93838fSSimon Schubert #define ifbrp_hellotime ifbrp_ifbrpu.ifbrpu_int8 /* hello time (sec) */ 224ac93838fSSimon Schubert #define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */ 225ac93838fSSimon Schubert #define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */ 226ac93838fSSimon Schubert 227ac93838fSSimon Schubert #ifdef _KERNEL 228ac93838fSSimon Schubert /* 229ac93838fSSimon Schubert * Timekeeping structure used in spanning tree code. 230ac93838fSSimon Schubert */ 231ac93838fSSimon Schubert struct bridge_timer { 232ac93838fSSimon Schubert uint16_t active; 233ac93838fSSimon Schubert uint16_t value; 234ac93838fSSimon Schubert }; 235ac93838fSSimon Schubert 236ac93838fSSimon Schubert struct bstp_config_unit { 237ac93838fSSimon Schubert uint64_t cu_rootid; 238ac93838fSSimon Schubert uint64_t cu_bridge_id; 239ac93838fSSimon Schubert uint32_t cu_root_path_cost; 240ac93838fSSimon Schubert uint16_t cu_message_age; 241ac93838fSSimon Schubert uint16_t cu_max_age; 242ac93838fSSimon Schubert uint16_t cu_hello_time; 243ac93838fSSimon Schubert uint16_t cu_forward_delay; 244ac93838fSSimon Schubert uint16_t cu_port_id; 245ac93838fSSimon Schubert uint8_t cu_message_type; 246ac93838fSSimon Schubert uint8_t cu_topology_change_acknowledgment; 247ac93838fSSimon Schubert uint8_t cu_topology_change; 248ac93838fSSimon Schubert }; 249ac93838fSSimon Schubert 250ac93838fSSimon Schubert struct bstp_tcn_unit { 251ac93838fSSimon Schubert uint8_t tu_message_type; 252ac93838fSSimon Schubert }; 253ac93838fSSimon Schubert 254ac93838fSSimon Schubert /* 2558f7b13efSSepherosa Ziehau * Bridge interface entry. 2568f7b13efSSepherosa Ziehau */ 2578f7b13efSSepherosa Ziehau struct bridge_ifinfo { 25870d9a675SMatthew Dillon uint64_t bifi_peer_root; 25970d9a675SMatthew Dillon uint64_t bifi_peer_bridge; 26070d9a675SMatthew Dillon uint32_t bifi_peer_cost; 26170d9a675SMatthew Dillon uint16_t bifi_peer_port; 26270d9a675SMatthew Dillon uint16_t bifi_unused02; 26370d9a675SMatthew Dillon uint16_t bifi_port_id; 2648f7b13efSSepherosa Ziehau uint32_t bifi_path_cost; 2658f7b13efSSepherosa Ziehau struct bridge_timer bifi_hold_timer; 2668f7b13efSSepherosa Ziehau struct bridge_timer bifi_message_age_timer; 2678f7b13efSSepherosa Ziehau struct bridge_timer bifi_forward_delay_timer; 2683677aae9SMatthew Dillon struct bridge_timer bifi_link1_timer; 2698f7b13efSSepherosa Ziehau struct bstp_config_unit bifi_config_bpdu; 27070d9a675SMatthew Dillon uint32_t bifi_flags; /* member if flags */ 2718f7b13efSSepherosa Ziehau uint8_t bifi_state; 2728f7b13efSSepherosa Ziehau uint8_t bifi_topology_change_acknowledge; 2738f7b13efSSepherosa Ziehau uint8_t bifi_config_pending; 2748f7b13efSSepherosa Ziehau uint8_t bifi_change_detection_enabled; 2758f7b13efSSepherosa Ziehau uint8_t bifi_priority; 2768f7b13efSSepherosa Ziehau struct ifnet *bifi_ifp; /* member if */ 2778f7b13efSSepherosa Ziehau int bifi_mutecap; /* member muted caps */ 2781e858374SMatthew Dillon int bifi_bond_weight; /* when link2 active */ 2798f7b13efSSepherosa Ziehau }; 2808f7b13efSSepherosa Ziehau 28170d9a675SMatthew Dillon #define bif_peer_root bif_info->bifi_peer_root 28270d9a675SMatthew Dillon #define bif_peer_bridge bif_info->bifi_peer_bridge 28370d9a675SMatthew Dillon #define bif_peer_cost bif_info->bifi_peer_cost 28470d9a675SMatthew Dillon #define bif_peer_port bif_info->bifi_peer_port 2858f7b13efSSepherosa Ziehau #define bif_path_cost bif_info->bifi_path_cost 2868f7b13efSSepherosa Ziehau #define bif_hold_timer bif_info->bifi_hold_timer 2878f7b13efSSepherosa Ziehau #define bif_message_age_timer bif_info->bifi_message_age_timer 2888f7b13efSSepherosa Ziehau #define bif_forward_delay_timer bif_info->bifi_forward_delay_timer 2893677aae9SMatthew Dillon #define bif_link1_timer bif_info->bifi_link1_timer 2908f7b13efSSepherosa Ziehau #define bif_config_bpdu bif_info->bifi_config_bpdu 2918f7b13efSSepherosa Ziehau #define bif_port_id bif_info->bifi_port_id 2928f7b13efSSepherosa Ziehau #define bif_state bif_info->bifi_state 29370d9a675SMatthew Dillon #define bif_flags bif_info->bifi_flags 2948f7b13efSSepherosa Ziehau #define bif_topology_change_acknowledge \ 2958f7b13efSSepherosa Ziehau bif_info->bifi_topology_change_acknowledge 2968f7b13efSSepherosa Ziehau #define bif_config_pending bif_info->bifi_config_pending 2978f7b13efSSepherosa Ziehau #define bif_change_detection_enabled bif_info->bifi_change_detection_enabled 2988f7b13efSSepherosa Ziehau #define bif_priority bif_info->bifi_priority 29970d9a675SMatthew Dillon #define bif_message_age_timer bif_info->bifi_message_age_timer 3001e858374SMatthew Dillon #define bif_bond_weight bif_info->bifi_bond_weight 3018f7b13efSSepherosa Ziehau 3028f7b13efSSepherosa Ziehau /* 303ac93838fSSimon Schubert * Bridge interface list entry. 304ac93838fSSimon Schubert */ 305ac93838fSSimon Schubert struct bridge_iflist { 30670d9a675SMatthew Dillon TAILQ_ENTRY(bridge_iflist) bif_next; 307ac93838fSSimon Schubert struct ifnet *bif_ifp; /* member if */ 3088f7b13efSSepherosa Ziehau int bif_onlist; 3098f7b13efSSepherosa Ziehau struct bridge_ifinfo *bif_info; 3101e858374SMatthew Dillon int bif_bond_count; /* when link2 active */ 311ac93838fSSimon Schubert }; 31270d9a675SMatthew Dillon TAILQ_HEAD(bridge_iflist_head, bridge_iflist); 313ac93838fSSimon Schubert 314ac93838fSSimon Schubert /* 3154394693cSSepherosa Ziehau * Bridge route info. 3164394693cSSepherosa Ziehau */ 3174394693cSSepherosa Ziehau struct bridge_rtinfo { 3184394693cSSepherosa Ziehau struct ifnet *bri_ifp; /* destination if */ 319cec73927SMatthew Dillon time_t bri_expire; /* expiration time */ 3204394693cSSepherosa Ziehau uint8_t bri_flags; /* address flags */ 3214394693cSSepherosa Ziehau uint8_t bri_dead; 3224394693cSSepherosa Ziehau uint8_t bri_pad[2]; 323*e41e076dSMatthew Dillon uint32_t bri_refs; 3244394693cSSepherosa Ziehau }; 3254394693cSSepherosa Ziehau 3264394693cSSepherosa Ziehau /* 327ac93838fSSimon Schubert * Bridge route node. 328ac93838fSSimon Schubert */ 329ac93838fSSimon Schubert struct bridge_rtnode { 330ac93838fSSimon Schubert LIST_ENTRY(bridge_rtnode) brt_hash; /* hash table linkage */ 331ac93838fSSimon Schubert LIST_ENTRY(bridge_rtnode) brt_list; /* list linkage */ 332ac93838fSSimon Schubert uint8_t brt_addr[ETHER_ADDR_LEN]; 3334394693cSSepherosa Ziehau uint8_t brt_pad[2]; 3344394693cSSepherosa Ziehau struct bridge_rtinfo *brt_info; 335ac93838fSSimon Schubert }; 3364394693cSSepherosa Ziehau LIST_HEAD(bridge_rtnode_head, bridge_rtnode); 337ac93838fSSimon Schubert 338ac93838fSSimon Schubert /* 339ac93838fSSimon Schubert * Software state for each bridge. 340ac93838fSSimon Schubert */ 341ac93838fSSimon Schubert struct bridge_softc { 342ac93838fSSimon Schubert struct arpcom sc_arp; 343ac93838fSSimon Schubert struct ifnet *sc_ifp; /* make this an interface */ 344ac93838fSSimon Schubert LIST_ENTRY(bridge_softc) sc_list; 345ac93838fSSimon Schubert uint64_t sc_bridge_id; 34670d9a675SMatthew Dillon uint64_t sc_designated_root; 34770d9a675SMatthew Dillon uint64_t sc_designated_bridge; 34870d9a675SMatthew Dillon uint32_t sc_designated_cost; /* root path cost */ 34970d9a675SMatthew Dillon uint16_t sc_designated_port; 35070d9a675SMatthew Dillon uint16_t sc_unused01; 35170d9a675SMatthew Dillon struct bridge_iflist *sc_root_port; 352ac93838fSSimon Schubert uint16_t sc_max_age; 353ac93838fSSimon Schubert uint16_t sc_hello_time; 354ac93838fSSimon Schubert uint16_t sc_forward_delay; 355ac93838fSSimon Schubert uint16_t sc_bridge_max_age; 356ac93838fSSimon Schubert uint16_t sc_bridge_hello_time; 357ac93838fSSimon Schubert uint16_t sc_bridge_forward_delay; 358ac93838fSSimon Schubert uint16_t sc_topology_change_time; 359ac93838fSSimon Schubert uint16_t sc_hold_time; 360ac93838fSSimon Schubert uint16_t sc_bridge_priority; 361ac93838fSSimon Schubert uint8_t sc_topology_change_detected; 362ac93838fSSimon Schubert uint8_t sc_topology_change; 363ac93838fSSimon Schubert struct bridge_timer sc_hello_timer; 364ac93838fSSimon Schubert struct bridge_timer sc_topology_change_timer; 365ac93838fSSimon Schubert struct bridge_timer sc_tcn_timer; 366ac93838fSSimon Schubert uint32_t sc_brtmax; /* max # of addresses */ 367ac93838fSSimon Schubert uint32_t sc_brtcnt; /* cur. # of addresses */ 368ac93838fSSimon Schubert uint32_t sc_brttimeout; /* rt timeout in seconds */ 369ac93838fSSimon Schubert struct callout sc_brcallout; /* bridge callout */ 370002c1265SMatthew Dillon struct netmsg_base sc_brtimemsg; /* bridge callout msg */ 371ac93838fSSimon Schubert struct callout sc_bstpcallout; /* STP callout */ 372002c1265SMatthew Dillon struct netmsg_base sc_bstptimemsg; /* STP callout msg */ 3738f7b13efSSepherosa Ziehau struct bridge_iflist_head *sc_iflists; /* percpu member if lists */ 3748f7b13efSSepherosa Ziehau struct bridge_rtnode_head **sc_rthashs; /* percpu forwarding tables */ 3758f7b13efSSepherosa Ziehau struct bridge_rtnode_head *sc_rtlists; /* percpu lists of the above */ 376ac93838fSSimon Schubert uint32_t sc_rthash_key; /* key for hash */ 3778f7b13efSSepherosa Ziehau struct bridge_iflist_head sc_spanlist; /* span ports list */ 378d895303bSSepherosa Ziehau int sc_span; /* has span ports */ 379d217f5e5SScott Ullrich struct bridge_timer sc_link_timer; 3809b42fdc9SMatthew Dillon int sc_copy_flags; /* copy if_flags */ 381ac93838fSSimon Schubert }; 382ac93838fSSimon Schubert #define sc_if sc_arp.ac_if 383ac93838fSSimon Schubert 384e9d22060SSepherosa Ziehau #define BRIDGE_CFGCPU 0 385ec7f7fc8SSepherosa Ziehau #define BRIDGE_CFGPORT netisr_cpuport(BRIDGE_CFGCPU) 386e9d22060SSepherosa Ziehau 387ac93838fSSimon Schubert extern const uint8_t bstp_etheraddr[]; 388ac93838fSSimon Schubert 389ac93838fSSimon Schubert void bridge_rtdelete(struct bridge_softc *, struct ifnet *ifp, int); 390ac93838fSSimon Schubert 391ac93838fSSimon Schubert extern void (*bstp_linkstate_p)(struct ifnet *ifp, int state); 392ac93838fSSimon Schubert 393ac93838fSSimon Schubert void bstp_initialization(struct bridge_softc *); 394ac93838fSSimon Schubert void bstp_linkstate(struct ifnet *, int); 395ac93838fSSimon Schubert void bstp_stop(struct bridge_softc *); 396b2417333SSepherosa Ziehau void bstp_input(struct bridge_softc *, struct bridge_iflist *, 39789ea766dSSepherosa Ziehau struct mbuf *); 398002c1265SMatthew Dillon void bstp_tick_handler(netmsg_t); 39970d9a675SMatthew Dillon int bstp_supersedes_port_info(struct bridge_softc *, 40070d9a675SMatthew Dillon struct bridge_iflist *); 40170d9a675SMatthew Dillon 402ac93838fSSimon Schubert 403708a3bfaSSepherosa Ziehau void bridge_enqueue(struct ifnet *, struct mbuf *); 404ac93838fSSimon Schubert 405ac93838fSSimon Schubert #endif /* _KERNEL */ 4068f7b13efSSepherosa Ziehau 4078f7b13efSSepherosa Ziehau #endif /* !_NET_IF_BRIDGEVAR_H */ 408