Date: Tue, 16 Apr 2013 00:28:01 GMT From: Luiz Otavio O Souza <loos.br@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: kern/177878: [rtl8366rb] [patch] Update rtl8366rb switch driver to match changes on kern/177873 Message-ID: <201304160028.r3G0S1qK013462@red.freebsd.org> Resent-Message-ID: <201304160030.r3G0U0hd016677@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201304160028.r3G0S1qK013462>