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 $ 6930ced003SSepherosa Ziehau * $DragonFly: src/sys/net/bridge/if_bridgevar.h,v 1.10 2008/11/26 12:49:43 sephe Exp $ 70ac93838fSSimon Schubert */ 71ac93838fSSimon Schubert 728f7b13efSSepherosa Ziehau #ifndef _NET_IF_BRIDGEVAR_H 738f7b13efSSepherosa Ziehau #define _NET_IF_BRIDGEVAR_H 748f7b13efSSepherosa Ziehau 75ac93838fSSimon Schubert /* 76ac93838fSSimon Schubert * Data structure and control definitions for bridge interfaces. 77ac93838fSSimon Schubert */ 78ac93838fSSimon Schubert 79ac93838fSSimon Schubert #include <sys/callout.h> 80ac93838fSSimon Schubert #include <sys/queue.h> 81ac93838fSSimon Schubert 82ac93838fSSimon Schubert /* 83ac93838fSSimon Schubert * Commands used in the SIOCSDRVSPEC ioctl. Note the lookup of the 84ac93838fSSimon Schubert * bridge interface itself is keyed off the ifdrv structure. 85ac93838fSSimon Schubert */ 86ac93838fSSimon Schubert #define BRDGADD 0 /* add bridge member (ifbreq) */ 87ac93838fSSimon Schubert #define BRDGDEL 1 /* delete bridge member (ifbreq) */ 88ac93838fSSimon Schubert #define BRDGGIFFLGS 2 /* get member if flags (ifbreq) */ 89ac93838fSSimon Schubert #define BRDGSIFFLGS 3 /* set member if flags (ifbreq) */ 90ac93838fSSimon Schubert #define BRDGSCACHE 4 /* set cache size (ifbrparam) */ 91ac93838fSSimon Schubert #define BRDGGCACHE 5 /* get cache size (ifbrparam) */ 92ac93838fSSimon Schubert #define BRDGGIFS 6 /* get member list (ifbifconf) */ 93ac93838fSSimon Schubert #define BRDGRTS 7 /* get address list (ifbaconf) */ 94ac93838fSSimon Schubert #define BRDGSADDR 8 /* set static address (ifbareq) */ 95ac93838fSSimon Schubert #define BRDGSTO 9 /* set cache timeout (ifbrparam) */ 96ac93838fSSimon Schubert #define BRDGGTO 10 /* get cache timeout (ifbrparam) */ 97ac93838fSSimon Schubert #define BRDGDADDR 11 /* delete address (ifbareq) */ 98ac93838fSSimon Schubert #define BRDGFLUSH 12 /* flush address cache (ifbreq) */ 99ac93838fSSimon Schubert 100ac93838fSSimon Schubert #define BRDGGPRI 13 /* get priority (ifbrparam) */ 101ac93838fSSimon Schubert #define BRDGSPRI 14 /* set priority (ifbrparam) */ 102ac93838fSSimon Schubert #define BRDGGHT 15 /* get hello time (ifbrparam) */ 103ac93838fSSimon Schubert #define BRDGSHT 16 /* set hello time (ifbrparam) */ 104ac93838fSSimon Schubert #define BRDGGFD 17 /* get forward delay (ifbrparam) */ 105ac93838fSSimon Schubert #define BRDGSFD 18 /* set forward delay (ifbrparam) */ 106ac93838fSSimon Schubert #define BRDGGMA 19 /* get max age (ifbrparam) */ 107ac93838fSSimon Schubert #define BRDGSMA 20 /* set max age (ifbrparam) */ 108ac93838fSSimon Schubert #define BRDGSIFPRIO 21 /* set if priority (ifbreq) */ 109ac93838fSSimon Schubert #define BRDGSIFCOST 22 /* set if path cost (ifbreq) */ 110d217f5e5SScott Ullrich #define BRDGADDS 23 /* add bridge span member (ifbreq) */ 111d217f5e5SScott Ullrich #define BRDGDELS 24 /* delete bridge span member (ifbreq) */ 112*1e858374SMatthew Dillon #define BRDGSBONDWGHT 25 /* set bonding weighting (ifbreq) */ 113ac93838fSSimon Schubert 114ac93838fSSimon Schubert /* 115ac93838fSSimon Schubert * Generic bridge control request. 116ac93838fSSimon Schubert */ 117ac93838fSSimon Schubert struct ifbreq { 118ac93838fSSimon Schubert char ifbr_ifsname[IFNAMSIZ]; /* member if name */ 119ac93838fSSimon Schubert uint32_t ifbr_ifsflags; /* member if flags */ 120ac93838fSSimon Schubert uint8_t ifbr_state; /* member if STP state */ 121ac93838fSSimon Schubert uint8_t ifbr_priority; /* member if STP priority */ 122ac93838fSSimon Schubert uint8_t ifbr_path_cost; /* member if STP cost */ 123ac93838fSSimon Schubert uint8_t ifbr_portno; /* member if port number */ 12470d9a675SMatthew Dillon uint64_t ifbr_designated_root; /* synthesized */ 12570d9a675SMatthew Dillon uint64_t ifbr_designated_bridge; 12670d9a675SMatthew Dillon uint32_t ifbr_designated_cost; 12770d9a675SMatthew Dillon uint16_t ifbr_designated_port; 1283677aae9SMatthew Dillon uint16_t unused01; 12970d9a675SMatthew Dillon uint64_t ifbr_peer_root; /* from peer */ 13070d9a675SMatthew Dillon uint64_t ifbr_peer_bridge; /* from peer */ 13170d9a675SMatthew Dillon uint32_t ifbr_peer_cost; /* from peer */ 13270d9a675SMatthew Dillon uint16_t ifbr_peer_port; /* from peer */ 13370d9a675SMatthew Dillon uint16_t unused02; 134*1e858374SMatthew Dillon uint16_t ifbr_bond_weight; 135*1e858374SMatthew Dillon uint16_t unused03; 136*1e858374SMatthew Dillon uint32_t unused04[8]; 137ac93838fSSimon Schubert }; 138ac93838fSSimon Schubert 139ac93838fSSimon Schubert /* BRDGGIFFLAGS, BRDGSIFFLAGS */ 140ac93838fSSimon Schubert #define IFBIF_LEARNING 0x01 /* if can learn */ 141ac93838fSSimon Schubert #define IFBIF_DISCOVER 0x02 /* if sends packets w/ unknown dest. */ 142ac93838fSSimon Schubert #define IFBIF_STP 0x04 /* if participates in spanning tree */ 143d217f5e5SScott Ullrich #define IFBIF_SPAN 0x08 /* if is a span port */ 14470d9a675SMatthew Dillon #define IFBIF_DESIGNATED 0x10 /* mostly age timer expired */ 14570d9a675SMatthew Dillon #define IFBIF_ROOT 0x20 /* selected root or near-root */ 146ac93838fSSimon Schubert 14770d9a675SMatthew Dillon #define IFBIF_KEEPMASK (IFBIF_SPAN | IFBIF_DESIGNATED | IFBIF_ROOT) 14870d9a675SMatthew Dillon 14970d9a675SMatthew Dillon #define IFBIFBITS "\020\1LEARNING\2DISCOVER\3STP\4SPAN\5DESIGNATED" \ 15070d9a675SMatthew Dillon "\6ROOT" 151ac93838fSSimon Schubert 152ac93838fSSimon Schubert /* BRDGFLUSH */ 153ac93838fSSimon Schubert #define IFBF_FLUSHDYN 0x00 /* flush learned addresses only */ 154ac93838fSSimon Schubert #define IFBF_FLUSHALL 0x01 /* flush all addresses */ 15530ced003SSepherosa Ziehau #define IFBF_FLUSHSYNC 0x02 /* synchronized flush */ 156ac93838fSSimon Schubert 157ac93838fSSimon Schubert /* STP port states */ 158ac93838fSSimon Schubert #define BSTP_IFSTATE_DISABLED 0 159ac93838fSSimon Schubert #define BSTP_IFSTATE_LISTENING 1 160ac93838fSSimon Schubert #define BSTP_IFSTATE_LEARNING 2 161ac93838fSSimon Schubert #define BSTP_IFSTATE_FORWARDING 3 162ac93838fSSimon Schubert #define BSTP_IFSTATE_BLOCKING 4 163*1e858374SMatthew Dillon #define BSTP_IFSTATE_BONDED 5 /* link2 bonding mode */ 164*1e858374SMatthew Dillon #define BSTP_IFSTATE_L1BLOCKING 6 /* link1 blocking mode no-activity */ 165ac93838fSSimon Schubert 166ac93838fSSimon Schubert /* 167ac93838fSSimon Schubert * Interface list structure. 168ac93838fSSimon Schubert */ 169ac93838fSSimon Schubert struct ifbifconf { 170ac93838fSSimon Schubert uint32_t ifbic_len; /* buffer size */ 171ac93838fSSimon Schubert union { 172ac93838fSSimon Schubert caddr_t ifbicu_buf; 173ac93838fSSimon Schubert struct ifbreq *ifbicu_req; 174ac93838fSSimon Schubert } ifbic_ifbicu; 175ac93838fSSimon Schubert #define ifbic_buf ifbic_ifbicu.ifbicu_buf 176ac93838fSSimon Schubert #define ifbic_req ifbic_ifbicu.ifbicu_req 177ac93838fSSimon Schubert }; 178ac93838fSSimon Schubert 179ac93838fSSimon Schubert /* 180ac93838fSSimon Schubert * Bridge address request. 181ac93838fSSimon Schubert */ 182ac93838fSSimon Schubert struct ifbareq { 183ac93838fSSimon Schubert char ifba_ifsname[IFNAMSIZ]; /* member if name */ 184ac93838fSSimon Schubert unsigned long ifba_expire; /* address expire time */ 185ac93838fSSimon Schubert uint8_t ifba_flags; /* address flags */ 186ac93838fSSimon Schubert uint8_t ifba_dst[ETHER_ADDR_LEN];/* destination address */ 187ac93838fSSimon Schubert }; 188ac93838fSSimon Schubert 189ac93838fSSimon Schubert #define IFBAF_TYPEMASK 0x03 /* address type mask */ 190ac93838fSSimon Schubert #define IFBAF_DYNAMIC 0x00 /* dynamically learned address */ 191ac93838fSSimon Schubert #define IFBAF_STATIC 0x01 /* static address */ 192ac93838fSSimon Schubert 193ac93838fSSimon Schubert #define IFBAFBITS "\020\1STATIC" 194ac93838fSSimon Schubert 195ac93838fSSimon Schubert /* 196ac93838fSSimon Schubert * Address list structure. 197ac93838fSSimon Schubert */ 198ac93838fSSimon Schubert struct ifbaconf { 199ac93838fSSimon Schubert uint32_t ifbac_len; /* buffer size */ 200ac93838fSSimon Schubert union { 201ac93838fSSimon Schubert caddr_t ifbacu_buf; 202ac93838fSSimon Schubert struct ifbareq *ifbacu_req; 203ac93838fSSimon Schubert } ifbac_ifbacu; 204ac93838fSSimon Schubert #define ifbac_buf ifbac_ifbacu.ifbacu_buf 205ac93838fSSimon Schubert #define ifbac_req ifbac_ifbacu.ifbacu_req 206ac93838fSSimon Schubert }; 207ac93838fSSimon Schubert 208ac93838fSSimon Schubert /* 209ac93838fSSimon Schubert * Bridge parameter structure. 210ac93838fSSimon Schubert */ 211ac93838fSSimon Schubert struct ifbrparam { 212ac93838fSSimon Schubert union { 213ac93838fSSimon Schubert uint32_t ifbrpu_int32; 214ac93838fSSimon Schubert uint16_t ifbrpu_int16; 215ac93838fSSimon Schubert uint8_t ifbrpu_int8; 216ac93838fSSimon Schubert } ifbrp_ifbrpu; 217ac93838fSSimon Schubert }; 218ac93838fSSimon Schubert #define ifbrp_csize ifbrp_ifbrpu.ifbrpu_int32 /* cache size */ 219ac93838fSSimon Schubert #define ifbrp_ctime ifbrp_ifbrpu.ifbrpu_int32 /* cache time (sec) */ 220ac93838fSSimon Schubert #define ifbrp_prio ifbrp_ifbrpu.ifbrpu_int16 /* bridge priority */ 221ac93838fSSimon Schubert #define ifbrp_hellotime ifbrp_ifbrpu.ifbrpu_int8 /* hello time (sec) */ 222ac93838fSSimon Schubert #define ifbrp_fwddelay ifbrp_ifbrpu.ifbrpu_int8 /* fwd time (sec) */ 223ac93838fSSimon Schubert #define ifbrp_maxage ifbrp_ifbrpu.ifbrpu_int8 /* max age (sec) */ 224ac93838fSSimon Schubert 225ac93838fSSimon Schubert #ifdef _KERNEL 226ac93838fSSimon Schubert /* 227ac93838fSSimon Schubert * Timekeeping structure used in spanning tree code. 228ac93838fSSimon Schubert */ 229ac93838fSSimon Schubert struct bridge_timer { 230ac93838fSSimon Schubert uint16_t active; 231ac93838fSSimon Schubert uint16_t value; 232ac93838fSSimon Schubert }; 233ac93838fSSimon Schubert 234ac93838fSSimon Schubert struct bstp_config_unit { 235ac93838fSSimon Schubert uint64_t cu_rootid; 236ac93838fSSimon Schubert uint64_t cu_bridge_id; 237ac93838fSSimon Schubert uint32_t cu_root_path_cost; 238ac93838fSSimon Schubert uint16_t cu_message_age; 239ac93838fSSimon Schubert uint16_t cu_max_age; 240ac93838fSSimon Schubert uint16_t cu_hello_time; 241ac93838fSSimon Schubert uint16_t cu_forward_delay; 242ac93838fSSimon Schubert uint16_t cu_port_id; 243ac93838fSSimon Schubert uint8_t cu_message_type; 244ac93838fSSimon Schubert uint8_t cu_topology_change_acknowledgment; 245ac93838fSSimon Schubert uint8_t cu_topology_change; 246ac93838fSSimon Schubert }; 247ac93838fSSimon Schubert 248ac93838fSSimon Schubert struct bstp_tcn_unit { 249ac93838fSSimon Schubert uint8_t tu_message_type; 250ac93838fSSimon Schubert }; 251ac93838fSSimon Schubert 252ac93838fSSimon Schubert /* 2538f7b13efSSepherosa Ziehau * Bridge interface entry. 2548f7b13efSSepherosa Ziehau */ 2558f7b13efSSepherosa Ziehau struct bridge_ifinfo { 25670d9a675SMatthew Dillon uint64_t bifi_peer_root; 25770d9a675SMatthew Dillon uint64_t bifi_peer_bridge; 25870d9a675SMatthew Dillon uint32_t bifi_peer_cost; 25970d9a675SMatthew Dillon uint16_t bifi_peer_port; 26070d9a675SMatthew Dillon uint16_t bifi_unused02; 26170d9a675SMatthew Dillon uint16_t bifi_port_id; 2628f7b13efSSepherosa Ziehau uint32_t bifi_path_cost; 2638f7b13efSSepherosa Ziehau struct bridge_timer bifi_hold_timer; 2648f7b13efSSepherosa Ziehau struct bridge_timer bifi_message_age_timer; 2658f7b13efSSepherosa Ziehau struct bridge_timer bifi_forward_delay_timer; 2663677aae9SMatthew Dillon struct bridge_timer bifi_link1_timer; 2678f7b13efSSepherosa Ziehau struct bstp_config_unit bifi_config_bpdu; 26870d9a675SMatthew Dillon uint32_t bifi_flags; /* member if flags */ 2698f7b13efSSepherosa Ziehau uint8_t bifi_state; 2708f7b13efSSepherosa Ziehau uint8_t bifi_topology_change_acknowledge; 2718f7b13efSSepherosa Ziehau uint8_t bifi_config_pending; 2728f7b13efSSepherosa Ziehau uint8_t bifi_change_detection_enabled; 2738f7b13efSSepherosa Ziehau uint8_t bifi_priority; 2748f7b13efSSepherosa Ziehau struct ifnet *bifi_ifp; /* member if */ 2758f7b13efSSepherosa Ziehau int bifi_mutecap; /* member muted caps */ 276*1e858374SMatthew Dillon int bifi_bond_weight; /* when link2 active */ 2778f7b13efSSepherosa Ziehau }; 2788f7b13efSSepherosa Ziehau 27970d9a675SMatthew Dillon #define bif_peer_root bif_info->bifi_peer_root 28070d9a675SMatthew Dillon #define bif_peer_bridge bif_info->bifi_peer_bridge 28170d9a675SMatthew Dillon #define bif_peer_cost bif_info->bifi_peer_cost 28270d9a675SMatthew Dillon #define bif_peer_port bif_info->bifi_peer_port 2838f7b13efSSepherosa Ziehau #define bif_path_cost bif_info->bifi_path_cost 2848f7b13efSSepherosa Ziehau #define bif_hold_timer bif_info->bifi_hold_timer 2858f7b13efSSepherosa Ziehau #define bif_message_age_timer bif_info->bifi_message_age_timer 2868f7b13efSSepherosa Ziehau #define bif_forward_delay_timer bif_info->bifi_forward_delay_timer 2873677aae9SMatthew Dillon #define bif_link1_timer bif_info->bifi_link1_timer 2888f7b13efSSepherosa Ziehau #define bif_config_bpdu bif_info->bifi_config_bpdu 2898f7b13efSSepherosa Ziehau #define bif_port_id bif_info->bifi_port_id 2908f7b13efSSepherosa Ziehau #define bif_state bif_info->bifi_state 29170d9a675SMatthew Dillon #define bif_flags bif_info->bifi_flags 2928f7b13efSSepherosa Ziehau #define bif_topology_change_acknowledge \ 2938f7b13efSSepherosa Ziehau bif_info->bifi_topology_change_acknowledge 2948f7b13efSSepherosa Ziehau #define bif_config_pending bif_info->bifi_config_pending 2958f7b13efSSepherosa Ziehau #define bif_change_detection_enabled bif_info->bifi_change_detection_enabled 2968f7b13efSSepherosa Ziehau #define bif_priority bif_info->bifi_priority 29770d9a675SMatthew Dillon #define bif_message_age_timer bif_info->bifi_message_age_timer 298*1e858374SMatthew Dillon #define bif_bond_weight bif_info->bifi_bond_weight 2998f7b13efSSepherosa Ziehau 3008f7b13efSSepherosa Ziehau /* 301ac93838fSSimon Schubert * Bridge interface list entry. 302ac93838fSSimon Schubert */ 303ac93838fSSimon Schubert struct bridge_iflist { 30470d9a675SMatthew Dillon TAILQ_ENTRY(bridge_iflist) bif_next; 305ac93838fSSimon Schubert struct ifnet *bif_ifp; /* member if */ 3068f7b13efSSepherosa Ziehau int bif_onlist; 3078f7b13efSSepherosa Ziehau struct bridge_ifinfo *bif_info; 308*1e858374SMatthew Dillon int bif_bond_count; /* when link2 active */ 309ac93838fSSimon Schubert }; 31070d9a675SMatthew Dillon TAILQ_HEAD(bridge_iflist_head, bridge_iflist); 311ac93838fSSimon Schubert 312ac93838fSSimon Schubert /* 3134394693cSSepherosa Ziehau * Bridge route info. 3144394693cSSepherosa Ziehau */ 3154394693cSSepherosa Ziehau struct bridge_rtinfo { 3164394693cSSepherosa Ziehau struct ifnet *bri_ifp; /* destination if */ 3174394693cSSepherosa Ziehau unsigned long bri_expire; /* expiration time */ 3184394693cSSepherosa Ziehau uint8_t bri_flags; /* address flags */ 3194394693cSSepherosa Ziehau uint8_t bri_dead; 3204394693cSSepherosa Ziehau uint8_t bri_pad[2]; 3214394693cSSepherosa Ziehau }; 3224394693cSSepherosa Ziehau 3234394693cSSepherosa Ziehau /* 324ac93838fSSimon Schubert * Bridge route node. 325ac93838fSSimon Schubert */ 326ac93838fSSimon Schubert struct bridge_rtnode { 327ac93838fSSimon Schubert LIST_ENTRY(bridge_rtnode) brt_hash; /* hash table linkage */ 328ac93838fSSimon Schubert LIST_ENTRY(bridge_rtnode) brt_list; /* list linkage */ 329ac93838fSSimon Schubert uint8_t brt_addr[ETHER_ADDR_LEN]; 3304394693cSSepherosa Ziehau uint8_t brt_pad[2]; 3314394693cSSepherosa Ziehau struct bridge_rtinfo *brt_info; 332ac93838fSSimon Schubert }; 3334394693cSSepherosa Ziehau LIST_HEAD(bridge_rtnode_head, bridge_rtnode); 334ac93838fSSimon Schubert 335ac93838fSSimon Schubert /* 336ac93838fSSimon Schubert * Software state for each bridge. 337ac93838fSSimon Schubert */ 338ac93838fSSimon Schubert struct bridge_softc { 339ac93838fSSimon Schubert struct arpcom sc_arp; 340ac93838fSSimon Schubert struct ifnet *sc_ifp; /* make this an interface */ 341ac93838fSSimon Schubert LIST_ENTRY(bridge_softc) sc_list; 342ac93838fSSimon Schubert uint64_t sc_bridge_id; 34370d9a675SMatthew Dillon uint64_t sc_designated_root; 34470d9a675SMatthew Dillon uint64_t sc_designated_bridge; 34570d9a675SMatthew Dillon uint32_t sc_designated_cost; /* root path cost */ 34670d9a675SMatthew Dillon uint16_t sc_designated_port; 34770d9a675SMatthew Dillon uint16_t sc_unused01; 34870d9a675SMatthew Dillon struct bridge_iflist *sc_root_port; 349ac93838fSSimon Schubert uint16_t sc_max_age; 350ac93838fSSimon Schubert uint16_t sc_hello_time; 351ac93838fSSimon Schubert uint16_t sc_forward_delay; 352ac93838fSSimon Schubert uint16_t sc_bridge_max_age; 353ac93838fSSimon Schubert uint16_t sc_bridge_hello_time; 354ac93838fSSimon Schubert uint16_t sc_bridge_forward_delay; 355ac93838fSSimon Schubert uint16_t sc_topology_change_time; 356ac93838fSSimon Schubert uint16_t sc_hold_time; 357ac93838fSSimon Schubert uint16_t sc_bridge_priority; 358ac93838fSSimon Schubert uint8_t sc_topology_change_detected; 359ac93838fSSimon Schubert uint8_t sc_topology_change; 360ac93838fSSimon Schubert struct bridge_timer sc_hello_timer; 361ac93838fSSimon Schubert struct bridge_timer sc_topology_change_timer; 362ac93838fSSimon Schubert struct bridge_timer sc_tcn_timer; 363ac93838fSSimon Schubert uint32_t sc_brtmax; /* max # of addresses */ 364ac93838fSSimon Schubert uint32_t sc_brtcnt; /* cur. # of addresses */ 365ac93838fSSimon Schubert uint32_t sc_brttimeout; /* rt timeout in seconds */ 366ac93838fSSimon Schubert struct callout sc_brcallout; /* bridge callout */ 367002c1265SMatthew Dillon struct netmsg_base sc_brtimemsg; /* bridge callout msg */ 368ac93838fSSimon Schubert struct callout sc_bstpcallout; /* STP callout */ 369002c1265SMatthew Dillon struct netmsg_base sc_bstptimemsg; /* STP callout msg */ 3708f7b13efSSepherosa Ziehau struct bridge_iflist_head *sc_iflists; /* percpu member if lists */ 3718f7b13efSSepherosa Ziehau struct bridge_rtnode_head **sc_rthashs; /* percpu forwarding tables */ 3728f7b13efSSepherosa Ziehau struct bridge_rtnode_head *sc_rtlists; /* percpu lists of the above */ 373ac93838fSSimon Schubert uint32_t sc_rthash_key; /* key for hash */ 3748f7b13efSSepherosa Ziehau struct bridge_iflist_head sc_spanlist; /* span ports list */ 375d895303bSSepherosa Ziehau int sc_span; /* has span ports */ 376d217f5e5SScott Ullrich struct bridge_timer sc_link_timer; 377ac93838fSSimon Schubert }; 378ac93838fSSimon Schubert #define sc_if sc_arp.ac_if 379ac93838fSSimon Schubert 380e9d22060SSepherosa Ziehau #define BRIDGE_CFGCPU 0 381e9d22060SSepherosa Ziehau #define BRIDGE_CFGPORT cpu_portfn(BRIDGE_CFGCPU) 382e9d22060SSepherosa Ziehau 383ac93838fSSimon Schubert extern const uint8_t bstp_etheraddr[]; 384ac93838fSSimon Schubert 385ac93838fSSimon Schubert void bridge_rtdelete(struct bridge_softc *, struct ifnet *ifp, int); 386ac93838fSSimon Schubert 387ac93838fSSimon Schubert extern void (*bstp_linkstate_p)(struct ifnet *ifp, int state); 388ac93838fSSimon Schubert 389ac93838fSSimon Schubert void bstp_initialization(struct bridge_softc *); 390ac93838fSSimon Schubert void bstp_linkstate(struct ifnet *, int); 391ac93838fSSimon Schubert void bstp_stop(struct bridge_softc *); 392b2417333SSepherosa Ziehau void bstp_input(struct bridge_softc *, struct bridge_iflist *, 39389ea766dSSepherosa Ziehau struct mbuf *); 394002c1265SMatthew Dillon void bstp_tick_handler(netmsg_t); 39570d9a675SMatthew Dillon int bstp_supersedes_port_info(struct bridge_softc *, 39670d9a675SMatthew Dillon struct bridge_iflist *); 39770d9a675SMatthew Dillon 398ac93838fSSimon Schubert 399708a3bfaSSepherosa Ziehau void bridge_enqueue(struct ifnet *, struct mbuf *); 400ac93838fSSimon Schubert 401ac93838fSSimon Schubert #endif /* _KERNEL */ 4028f7b13efSSepherosa Ziehau 4038f7b13efSSepherosa Ziehau #endif /* !_NET_IF_BRIDGEVAR_H */ 404