diff options
-rw-r--r-- | sys/dev/etherswitch/etherswitch.c | 11 | ||||
-rw-r--r-- | sys/dev/etherswitch/etherswitch.h | 33 | ||||
-rw-r--r-- | sys/dev/etherswitch/etherswitch_if.m | 28 |
3 files changed, 71 insertions, 1 deletions
diff --git a/sys/dev/etherswitch/etherswitch.c b/sys/dev/etherswitch/etherswitch.c index 01a94af..c2f2860 100644 --- a/sys/dev/etherswitch/etherswitch.c +++ b/sys/dev/etherswitch/etherswitch.c @@ -200,6 +200,7 @@ etherswitchioctl(struct cdev *cdev, u_long cmd, caddr_t data, int flags, struct struct etherswitch_softc *sc = cdev->si_drv1; device_t dev = sc->sc_dev; device_t etherswitch = device_get_parent(dev); + etherswitch_conf_t conf; etherswitch_info_t *info; etherswitch_reg_t *reg; etherswitch_phyreg_t *phyreg; @@ -251,6 +252,16 @@ etherswitchioctl(struct cdev *cdev, u_long cmd, caddr_t data, int flags, struct error = ETHERSWITCH_WRITEPHYREG(etherswitch, phyreg->phy, phyreg->reg, phyreg->val); break; + case IOETHERSWITCHGETCONF: + bzero(&conf, sizeof(etherswitch_conf_t)); + error = ETHERSWITCH_GETCONF(etherswitch, &conf); + bcopy(&conf, data, sizeof(etherswitch_conf_t)); + break; + + case IOETHERSWITCHSETCONF: + error = ETHERSWITCH_SETCONF(etherswitch, (etherswitch_conf_t *)data); + break; + default: error = ENOTTY; } diff --git a/sys/dev/etherswitch/etherswitch.h b/sys/dev/etherswitch/etherswitch.h index b570039..bb0167b 100644 --- a/sys/dev/etherswitch/etherswitch.h +++ b/sys/dev/etherswitch/etherswitch.h @@ -25,18 +25,47 @@ struct etherswitch_phyreg { }; typedef struct etherswitch_phyreg etherswitch_phyreg_t; -#define ETHERSWITCH_NAMEMAX 64 +#define ETHERSWITCH_NAMEMAX 64 +#define ETHERSWITCH_VLAN_ISL (1 << 0) /* ISL */ +#define ETHERSWITCH_VLAN_PORT (1 << 1) /* Port based vlan */ +#define ETHERSWITCH_VLAN_DOT1Q (1 << 2) /* 802.1q */ +#define ETHERSWITCH_VLAN_DOT1Q_4K (1 << 3) /* 4k support on 802.1q */ +#define ETHERSWITCH_VLAN_DOUBLE_TAG (1 << 4) /* Q-in-Q */ +#define ETHERSWITCH_VLAN_CAPS_BITS \ +"\020\1ISL\2PORT\3DOT1Q\4DOT1Q4K\5QinQ" struct etherswitch_info { int es_nports; int es_nvlangroups; char es_name[ETHERSWITCH_NAMEMAX]; + uint32_t es_vlan_caps; }; typedef struct etherswitch_info etherswitch_info_t; +#define ETHERSWITCH_CONF_FLAGS (1 << 0) +#define ETHERSWITCH_CONF_MIRROR (1 << 1) +#define ETHERSWITCH_CONF_VLAN_MODE (1 << 2) + +struct etherswitch_conf { + uint32_t cmd; /* What to configure */ + uint32_t vlan_mode; /* Switch VLAN mode */ +}; +typedef struct etherswitch_conf etherswitch_conf_t; + +#define ETHERSWITCH_PORT_CPU (1 << 0) +#define ETHERSWITCH_PORT_STRIPTAG (1 << 1) +#define ETHERSWITCH_PORT_ADDTAG (1 << 2) +#define ETHERSWITCH_PORT_FIRSTLOCK (1 << 3) +#define ETHERSWITCH_PORT_DROPUNTAGGED (1 << 4) +#define ETHERSWITCH_PORT_DOUBLE_TAG (1 << 5) +#define ETHERSWITCH_PORT_INGRESS (1 << 6) +#define ETHERSWITCH_PORT_FLAGS_BITS \ +"\020\1CPUPORT\2STRIPTAG\3ADDTAG\4FIRSTLOCK\5DROPUNTAGGED\6QinQ\7INGRESS" + struct etherswitch_port { int es_port; int es_pvid; + uint32_t es_flags; union { struct ifreq es_uifr; struct ifmediareq es_uifmr; @@ -66,5 +95,7 @@ typedef struct etherswitch_vlangroup etherswitch_vlangroup_t; #define IOETHERSWITCHSETVLANGROUP _IOW('i', 7, etherswitch_vlangroup_t) #define IOETHERSWITCHGETPHYREG _IOWR('i', 8, etherswitch_phyreg_t) #define IOETHERSWITCHSETPHYREG _IOW('i', 9, etherswitch_phyreg_t) +#define IOETHERSWITCHGETCONF _IOR('i', 10, etherswitch_conf_t) +#define IOETHERSWITCHSETCONF _IOW('i', 11, etherswitch_conf_t) #endif diff --git a/sys/dev/etherswitch/etherswitch_if.m b/sys/dev/etherswitch/etherswitch_if.m index 20970d7..a2aea02 100644 --- a/sys/dev/etherswitch/etherswitch_if.m +++ b/sys/dev/etherswitch/etherswitch_if.m @@ -23,6 +23,18 @@ CODE { null_etherswitch_unlock(device_t dev) { } + + static int + null_etherswitch_getconf(device_t dev, etherswitch_conf_t *conf) + { + return (0); + } + + static int + null_etherswitch_setconf(device_t dev, etherswitch_conf_t *conf) + { + return (0); + } }; # @@ -113,3 +125,19 @@ METHOD int setvgroup { device_t dev; etherswitch_vlangroup_t *vg; } + +# +# Get the Switch configuration +# +METHOD int getconf { + device_t dev; + etherswitch_conf_t *conf; +} DEFAULT null_etherswitch_getconf; + +# +# Set the Switch configuration +# +METHOD int setconf { + device_t dev; + etherswitch_conf_t *conf; +} DEFAULT null_etherswitch_setconf; |