1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-18 10:35:55 +00:00

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
This commit is contained in:
Adrian Chadd 2013-05-08 20:46:54 +00:00
parent b96e78e02c
commit a48a9355ef
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=250381
3 changed files with 71 additions and 1 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;