From owner-svn-src-head@FreeBSD.ORG Wed May 8 20:46:55 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 31351B6F; Wed, 8 May 2013 20:46:55 +0000 (UTC) (envelope-from adrian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 12758B62; Wed, 8 May 2013 20:46:55 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r48KksIs076928; Wed, 8 May 2013 20:46:54 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r48KksB9076925; Wed, 8 May 2013 20:46:54 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201305082046.r48KksB9076925@svn.freebsd.org> From: Adrian Chadd Date: Wed, 8 May 2013 20:46:54 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250381 - head/sys/dev/etherswitch X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2013 20:46:55 -0000 Author: adrian Date: Wed May 8 20:46:54 2013 New Revision: 250381 URL: http://svnweb.freebsd.org/changeset/base/250381 Log: 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 Reviewed by: ray Modified: head/sys/dev/etherswitch/etherswitch.c head/sys/dev/etherswitch/etherswitch.h head/sys/dev/etherswitch/etherswitch_if.m Modified: head/sys/dev/etherswitch/etherswitch.c ============================================================================== --- head/sys/dev/etherswitch/etherswitch.c Wed May 8 20:04:32 2013 (r250380) +++ head/sys/dev/etherswitch/etherswitch.c Wed May 8 20:46:54 2013 (r250381) @@ -200,6 +200,7 @@ etherswitchioctl(struct cdev *cdev, u_lo 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_lo 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; } Modified: head/sys/dev/etherswitch/etherswitch.h ============================================================================== --- head/sys/dev/etherswitch/etherswitch.h Wed May 8 20:04:32 2013 (r250380) +++ head/sys/dev/etherswitch/etherswitch.h Wed May 8 20:46:54 2013 (r250381) @@ -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 eth #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 Modified: head/sys/dev/etherswitch/etherswitch_if.m ============================================================================== --- head/sys/dev/etherswitch/etherswitch_if.m Wed May 8 20:04:32 2013 (r250380) +++ head/sys/dev/etherswitch/etherswitch_if.m Wed May 8 20:46:54 2013 (r250381) @@ -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;