summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2013-05-08 20:46:54 +0000
committeradrian <adrian@FreeBSD.org>2013-05-08 20:46:54 +0000
commit2284dfb917913d5262d695b04785ef0f2e3ca6da (patch)
treef46e6a9e51654bb8eb5453d71ae3f0af8f087b23
parenta38b8c6c252417ff4d701081d252439a1f46057c (diff)
downloadFreeBSD-src-2284dfb917913d5262d695b04785ef0f2e3ca6da.zip
FreeBSD-src-2284dfb917913d5262d695b04785ef0f2e3ca6da.tar.gz
Add the ability to change the vlan operation mode.
This adds a vlan capability field to etherswitch_info structure and some definitions of ports flags. It adds the support to global config parameters which right now is used only to switch between the vlan modes, but it is intended to be extended to support the setup of others parameters (STP, mirror, etc.). Submitted by: Luiz Otavio O Souza <loos.br@gmail.com> Reviewed by: ray
-rw-r--r--sys/dev/etherswitch/etherswitch.c11
-rw-r--r--sys/dev/etherswitch/etherswitch.h33
-rw-r--r--sys/dev/etherswitch/etherswitch_if.m28
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;
OpenPOWER on IntegriCloud