1 /* 2 * $FreeBSD$ 3 */ 4 5 #ifndef __SYS_DEV_ETHERSWITCH_ETHERSWITCH_H 6 #define __SYS_DEV_ETHERSWITCH_ETHERSWITCH_H 7 8 #include <sys/ioccom.h> 9 10 #ifdef _KERNEL 11 extern devclass_t etherswitch_devclass; 12 extern driver_t etherswitch_driver; 13 #endif /* _KERNEL */ 14 15 struct etherswitch_reg { 16 uint16_t reg; 17 uint16_t val; 18 }; 19 typedef struct etherswitch_reg etherswitch_reg_t; 20 21 struct etherswitch_phyreg { 22 uint16_t phy; 23 uint16_t reg; 24 uint16_t val; 25 }; 26 typedef struct etherswitch_phyreg etherswitch_phyreg_t; 27 28 #define ETHERSWITCH_NAMEMAX 64 29 #define ETHERSWITCH_VLAN_ISL (1 << 0) /* ISL */ 30 #define ETHERSWITCH_VLAN_PORT (1 << 1) /* Port based vlan */ 31 #define ETHERSWITCH_VLAN_DOT1Q (1 << 2) /* 802.1q */ 32 #define ETHERSWITCH_VLAN_DOT1Q_4K (1 << 3) /* 4k support on 802.1q */ 33 #define ETHERSWITCH_VLAN_DOUBLE_TAG (1 << 4) /* Q-in-Q */ 34 #define ETHERSWITCH_VLAN_CAPS_BITS \ 35 "\020\1ISL\2PORT\3DOT1Q\4DOT1Q4K\5QinQ" 36 37 struct etherswitch_info { 38 int es_nports; 39 int es_nvlangroups; 40 char es_name[ETHERSWITCH_NAMEMAX]; 41 uint32_t es_vlan_caps; 42 }; 43 typedef struct etherswitch_info etherswitch_info_t; 44 45 #define ETHERSWITCH_CONF_FLAGS (1 << 0) 46 #define ETHERSWITCH_CONF_MIRROR (1 << 1) 47 #define ETHERSWITCH_CONF_VLAN_MODE (1 << 2) 48 49 struct etherswitch_conf { 50 uint32_t cmd; /* What to configure */ 51 uint32_t vlan_mode; /* Switch VLAN mode */ 52 }; 53 typedef struct etherswitch_conf etherswitch_conf_t; 54 55 #define ETHERSWITCH_PORT_CPU (1 << 0) 56 #define ETHERSWITCH_PORT_STRIPTAG (1 << 1) 57 #define ETHERSWITCH_PORT_ADDTAG (1 << 2) 58 #define ETHERSWITCH_PORT_FIRSTLOCK (1 << 3) 59 #define ETHERSWITCH_PORT_DROPUNTAGGED (1 << 4) 60 #define ETHERSWITCH_PORT_DOUBLE_TAG (1 << 5) 61 #define ETHERSWITCH_PORT_INGRESS (1 << 6) 62 #define ETHERSWITCH_PORT_FLAGS_BITS \ 63 "\020\1CPUPORT\2STRIPTAG\3ADDTAG\4FIRSTLOCK\5DROPUNTAGGED\6QinQ\7INGRESS" 64 65 struct etherswitch_port { 66 int es_port; 67 int es_pvid; 68 uint32_t es_flags; 69 union { 70 struct ifreq es_uifr; 71 struct ifmediareq es_uifmr; 72 } es_ifu; 73 #define es_ifr es_ifu.es_uifr 74 #define es_ifmr es_ifu.es_uifmr 75 }; 76 typedef struct etherswitch_port etherswitch_port_t; 77 78 struct etherswitch_vlangroup { 79 int es_vlangroup; 80 int es_vid; 81 int es_member_ports; 82 int es_untagged_ports; 83 int es_fid; 84 }; 85 typedef struct etherswitch_vlangroup etherswitch_vlangroup_t; 86 87 #define ETHERSWITCH_PORTMASK(_port) (1 << (_port)) 88 89 #define IOETHERSWITCHGETINFO _IOR('i', 1, etherswitch_info_t) 90 #define IOETHERSWITCHGETREG _IOWR('i', 2, etherswitch_reg_t) 91 #define IOETHERSWITCHSETREG _IOW('i', 3, etherswitch_reg_t) 92 #define IOETHERSWITCHGETPORT _IOWR('i', 4, etherswitch_port_t) 93 #define IOETHERSWITCHSETPORT _IOW('i', 5, etherswitch_port_t) 94 #define IOETHERSWITCHGETVLANGROUP _IOWR('i', 6, etherswitch_vlangroup_t) 95 #define IOETHERSWITCHSETVLANGROUP _IOW('i', 7, etherswitch_vlangroup_t) 96 #define IOETHERSWITCHGETPHYREG _IOWR('i', 8, etherswitch_phyreg_t) 97 #define IOETHERSWITCHSETPHYREG _IOW('i', 9, etherswitch_phyreg_t) 98 #define IOETHERSWITCHGETCONF _IOR('i', 10, etherswitch_conf_t) 99 #define IOETHERSWITCHSETCONF _IOW('i', 11, etherswitch_conf_t) 100 101 #endif 102