From owner-svn-src-head@freebsd.org Mon Feb 20 08:10:43 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 686B4CE5D90; Mon, 20 Feb 2017 08:10:43 +0000 (UTC) (envelope-from sgalabov@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1C8301458; Mon, 20 Feb 2017 08:10:43 +0000 (UTC) (envelope-from sgalabov@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1K8Agch065312; Mon, 20 Feb 2017 08:10:42 GMT (envelope-from sgalabov@FreeBSD.org) Received: (from sgalabov@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1K8AgXF065311; Mon, 20 Feb 2017 08:10:42 GMT (envelope-from sgalabov@FreeBSD.org) Message-Id: <201702200810.v1K8AgXF065311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: sgalabov set sender to sgalabov@FreeBSD.org using -f From: Stanislav Galabov Date: Mon, 20 Feb 2017 08:10:42 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313988 - head/sys/dev/etherswitch/mtkswitch 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.23 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: Mon, 20 Feb 2017 08:10:43 -0000 Author: sgalabov Date: Mon Feb 20 08:10:41 2017 New Revision: 313988 URL: https://svnweb.freebsd.org/changeset/base/313988 Log: etherswitch: Fix RT305x vlan group operation Fix an issue which prevents proper operation (addition/removal of members) of RT305x vlan groups. Tested by: yamori813@yahoo.co.jp Submitted by: yamori813@yahoo.co.jp (initial version) Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D9607 Modified: head/sys/dev/etherswitch/mtkswitch/mtkswitch_rt3050.c Modified: head/sys/dev/etherswitch/mtkswitch/mtkswitch_rt3050.c ============================================================================== --- head/sys/dev/etherswitch/mtkswitch/mtkswitch_rt3050.c Mon Feb 20 08:04:06 2017 (r313987) +++ head/sys/dev/etherswitch/mtkswitch/mtkswitch_rt3050.c Mon Feb 20 08:10:41 2017 (r313988) @@ -405,11 +405,38 @@ mtkswitch_vlan_setvgroup(struct mtkswitc MTKSWITCH_LOCK(sc); /* First, see if we can accomodate the request at all */ val = MTKSWITCH_READ(sc, MTKSWITCH_POC2); - if ((val & POC2_UNTAG_VLAN) == 0 || - sc->sc_switchtype == MTK_SWITCH_RT3050) { + if (sc->sc_switchtype == MTK_SWITCH_RT3050 || + (val & POC2_UNTAG_VLAN) == 0) { + /* + * There are 2 things we can't support in per-port untagging + * mode: + * 1. Adding a port as an untagged member if the port is not + * set up to do untagging. + * 2. Adding a port as a tagged member if the port is set up + * to do untagging. + */ val &= VUB_MASK; + + /* get all untagged members from the member list */ tmp = v->es_untagged_ports & v->es_member_ports; - if (val != tmp) { + /* fail if untagged members are not a subset of all members */ + if (tmp != v->es_untagged_ports) { + /* Cannot accomodate request */ + MTKSWITCH_UNLOCK(sc); + return (ENOTSUP); + } + + /* fail if any untagged member is set up to do tagging */ + if ((tmp & val) != tmp) { + /* Cannot accomodate request */ + MTKSWITCH_UNLOCK(sc); + return (ENOTSUP); + } + + /* now, get the list of all tagged members */ + tmp = v->es_member_ports & ~tmp; + /* fail if any tagged member is set up to do untagging */ + if ((tmp & val) != 0) { /* Cannot accomodate request */ MTKSWITCH_UNLOCK(sc); return (ENOTSUP);