]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - sys/dev/etherswitch/etherswitch.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / sys / dev / etherswitch / etherswitch.h
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_VID_MASK            0xfff
30 #define ETHERSWITCH_VID_VALID           (1 << 12)
31 #define ETHERSWITCH_VLAN_ISL            (1 << 0)        /* ISL */
32 #define ETHERSWITCH_VLAN_PORT           (1 << 1)        /* Port based vlan */
33 #define ETHERSWITCH_VLAN_DOT1Q          (1 << 2)        /* 802.1q */
34 #define ETHERSWITCH_VLAN_DOT1Q_4K       (1 << 3)        /* 4k support on 802.1q */
35 #define ETHERSWITCH_VLAN_DOUBLE_TAG     (1 << 4)        /* Q-in-Q */
36 #define ETHERSWITCH_VLAN_CAPS_BITS      \
37 "\020\1ISL\2PORT\3DOT1Q\4DOT1Q4K\5QinQ"
38
39 struct etherswitch_info {
40         int             es_nports;
41         int             es_nvlangroups;
42         char            es_name[ETHERSWITCH_NAMEMAX];
43         uint32_t        es_vlan_caps;
44 };
45 typedef struct etherswitch_info etherswitch_info_t;
46
47 #define ETHERSWITCH_CONF_FLAGS          (1 << 0)
48 #define ETHERSWITCH_CONF_MIRROR         (1 << 1)
49 #define ETHERSWITCH_CONF_VLAN_MODE      (1 << 2)
50
51 struct etherswitch_conf {
52         uint32_t        cmd;            /* What to configure */
53         uint32_t        vlan_mode;      /* Switch VLAN mode */
54 };
55 typedef struct etherswitch_conf etherswitch_conf_t;
56
57 #define ETHERSWITCH_PORT_CPU            (1 << 0)
58 #define ETHERSWITCH_PORT_STRIPTAG       (1 << 1)
59 #define ETHERSWITCH_PORT_ADDTAG         (1 << 2)
60 #define ETHERSWITCH_PORT_FIRSTLOCK      (1 << 3)
61 #define ETHERSWITCH_PORT_DROPUNTAGGED   (1 << 4)
62 #define ETHERSWITCH_PORT_DOUBLE_TAG     (1 << 5)
63 #define ETHERSWITCH_PORT_INGRESS        (1 << 6)
64 #define ETHERSWITCH_PORT_FLAGS_BITS     \
65 "\020\1CPUPORT\2STRIPTAG\3ADDTAG\4FIRSTLOCK\5DROPUNTAGGED\6QinQ\7INGRESS"
66
67 struct etherswitch_port {
68         int             es_port;
69         int             es_pvid;
70         uint32_t        es_flags;
71         union {
72                 struct ifreq            es_uifr;
73                 struct ifmediareq       es_uifmr;
74         } es_ifu;
75 #define es_ifr          es_ifu.es_uifr
76 #define es_ifmr         es_ifu.es_uifmr
77 };
78 typedef struct etherswitch_port etherswitch_port_t;
79
80 struct etherswitch_vlangroup {
81         int             es_vlangroup;
82         int             es_vid;
83         int             es_member_ports;
84         int             es_untagged_ports;
85         int             es_fid;
86 };
87 typedef struct etherswitch_vlangroup etherswitch_vlangroup_t;
88
89 #define ETHERSWITCH_PORTMASK(_port)     (1 << (_port))
90
91 #define IOETHERSWITCHGETINFO            _IOR('i', 1, etherswitch_info_t)
92 #define IOETHERSWITCHGETREG             _IOWR('i', 2, etherswitch_reg_t)
93 #define IOETHERSWITCHSETREG             _IOW('i', 3, etherswitch_reg_t)
94 #define IOETHERSWITCHGETPORT            _IOWR('i', 4, etherswitch_port_t)
95 #define IOETHERSWITCHSETPORT            _IOW('i', 5, etherswitch_port_t)
96 #define IOETHERSWITCHGETVLANGROUP       _IOWR('i', 6, etherswitch_vlangroup_t)
97 #define IOETHERSWITCHSETVLANGROUP       _IOW('i', 7, etherswitch_vlangroup_t)
98 #define IOETHERSWITCHGETPHYREG          _IOWR('i', 8, etherswitch_phyreg_t)
99 #define IOETHERSWITCHSETPHYREG          _IOW('i', 9, etherswitch_phyreg_t)
100 #define IOETHERSWITCHGETCONF            _IOR('i', 10, etherswitch_conf_t)
101 #define IOETHERSWITCHSETCONF            _IOW('i', 11, etherswitch_conf_t)
102
103 #endif