From owner-freebsd-bugs@FreeBSD.ORG Tue Apr 16 00:30:00 2013 Return-Path: Delivered-To: freebsd-bugs@smarthost.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id B5915109 for ; Tue, 16 Apr 2013 00:30:00 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:1900:2254:206c::16:87]) by mx1.freebsd.org (Postfix) with ESMTP id 9843D1B2 for ; Tue, 16 Apr 2013 00:30:00 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.6/8.14.6) with ESMTP id r3G0U07Q016683 for ; Tue, 16 Apr 2013 00:30:00 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.6/8.14.6/Submit) id r3G0U0hd016677; Tue, 16 Apr 2013 00:30:00 GMT (envelope-from gnats) Resent-Date: Tue, 16 Apr 2013 00:30:00 GMT Resent-Message-Id: <201304160030.r3G0U0hd016677@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Luiz Otavio O Souza Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 87D42F3 for ; Tue, 16 Apr 2013 00:28:02 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22]) by mx1.freebsd.org (Postfix) with ESMTP id 795AC1A5 for ; Tue, 16 Apr 2013 00:28:02 +0000 (UTC) Received: from red.freebsd.org (localhost [127.0.0.1]) by red.freebsd.org (8.14.5/8.14.5) with ESMTP id r3G0S1dA013463 for ; Tue, 16 Apr 2013 00:28:01 GMT (envelope-from nobody@red.freebsd.org) Received: (from nobody@localhost) by red.freebsd.org (8.14.5/8.14.5/Submit) id r3G0S1qK013462; Tue, 16 Apr 2013 00:28:01 GMT (envelope-from nobody) Message-Id: <201304160028.r3G0S1qK013462@red.freebsd.org> Date: Tue, 16 Apr 2013 00:28:01 GMT From: Luiz Otavio O Souza To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Subject: kern/177878: [rtl8366rb] [patch] Update rtl8366rb switch driver to match changes on kern/177873 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Apr 2013 00:30:00 -0000 >Number: 177878 >Category: kern >Synopsis: [rtl8366rb] [patch] Update rtl8366rb switch driver to match changes on kern/177873 >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Tue Apr 16 00:30:00 UTC 2013 >Closed-Date: >Last-Modified: >Originator: Luiz Otavio O Souza >Release: -HEAD r248943 >Organization: >Environment: FreeBSD rb433 10.0-CURRENT FreeBSD 10.0-CURRENT #88 r248943M: Sat Apr 13 10:04:43 BRT 2013 root@devel:/data/rb/rb433/obj/mips.mips/data/rb/rb433/src/sys/RB433U mips >Description: As part of kern/177873, there is no more the notion of vlangroups when setting the port PVID. In the case of rtl8366rb, vlangroups were used internally by the driver so we need to track them with a new integer array which is now part of the device softc data. No functional changes. >How-To-Repeat: >Fix: Apply the attached patch. Patch attached with submission follows: Index: dev/etherswitch/rtl8366/rtl8366rb.c =================================================================== --- dev/etherswitch/rtl8366/rtl8366rb.c (revision 248943) +++ dev/etherswitch/rtl8366/rtl8366rb.c (working copy) @@ -63,6 +63,7 @@ int smi_acquired; /* serialize access to SMI/I2C bus */ struct mtx callout_mtx; /* serialize callout */ device_t dev; + int vid[RTL8366RB_NUM_VLANS]; char *ifname[RTL8366RB_NUM_PHYS]; device_t miibus[RTL8366RB_NUM_PHYS]; struct ifnet *ifp[RTL8366RB_NUM_PHYS]; @@ -70,8 +71,8 @@ }; static etherswitch_info_t etherswitch_info = { - .es_nports = 6, - .es_nvlangroups = 16, + .es_nports = RTL8366RB_NUM_PORTS, + .es_nvlangroups = RTL8366RB_NUM_VLANS, .es_name = "Realtek RTL8366RB" }; @@ -550,15 +551,16 @@ struct mii_data *mii; struct ifmediareq *ifmr = &p->es_ifmr; uint16_t v; - int err; + int err, vlangroup; if (p->es_port < 0 || p->es_port >= RTL8366RB_NUM_PORTS) return (ENXIO); - p->es_vlangroup = RTL8366RB_PVCR_GET(p->es_port, + sc = device_get_softc(dev); + vlangroup = RTL8366RB_PVCR_GET(p->es_port, rtl_readreg(dev, RTL8366RB_PVCR_REG(p->es_port))); + p->es_pvid = sc->vid[vlangroup]; if (p->es_port < RTL8366RB_NUM_PHYS) { - sc = device_get_softc(dev); mii = device_get_softc(sc->miibus[p->es_port]); ifm = &mii->mii_media; err = ifmedia_ioctl(sc->ifp[p->es_port], &p->es_ifr, ifm, SIOCGIFMEDIA); @@ -580,19 +582,28 @@ static int rtl_setport(device_t dev, etherswitch_port_t *p) { - int err; + int i, err, vlangroup; struct rtl8366rb_softc *sc; struct ifmedia *ifm; struct mii_data *mii; if (p->es_port < 0 || p->es_port >= RTL8366RB_NUM_PHYS) return (ENXIO); + sc = device_get_softc(dev); + vlangroup = -1; + for (i = 0; i < RTL8366RB_NUM_VLANS; i++) { + if (sc->vid[i] == p->es_pvid) { + vlangroup = i; + break; + } + } + if (vlangroup == -1) + return (ENXIO); err = smi_rmw(dev, RTL8366RB_PVCR_REG(p->es_port), RTL8366RB_PVCR_VAL(p->es_port, RTL8366RB_PVCR_PORT_MASK), - RTL8366RB_PVCR_VAL(p->es_port, p->es_vlangroup), RTL_WAITOK); + RTL8366RB_PVCR_VAL(p->es_port, vlangroup), RTL_WAITOK); if (err) return (err); - sc = device_get_softc(dev); mii = device_get_softc(sc->miibus[p->es_port]); ifm = &mii->mii_media; err = ifmedia_ioctl(sc->ifp[p->es_port], &p->es_ifr, ifm, SIOCSIFMEDIA); @@ -618,8 +629,11 @@ static int rtl_setvgroup(device_t dev, etherswitch_vlangroup_t *vg) { + struct rtl8366rb_softc *sc; int g = vg->es_vlangroup; + sc = device_get_softc(dev); + sc->vid[g] = vg->es_vid; rtl_writereg(dev, RTL8366RB_VMCR(RTL8366RB_VMCR_DOT1Q_REG, g), (vg->es_vid << RTL8366RB_VMCR_DOT1Q_VID_SHIFT) & RTL8366RB_VMCR_DOT1Q_VID_MASK); rtl_writereg(dev, RTL8366RB_VMCR(RTL8366RB_VMCR_MU_REG, g), >Release-Note: >Audit-Trail: >Unformatted: