From owner-svn-src-head@FreeBSD.ORG Sat Mar 1 10:09:02 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 6E5673DE; Sat, 1 Mar 2014 10:09:02 +0000 (UTC) Received: from mail-qc0-x22e.google.com (mail-qc0-x22e.google.com [IPv6:2607:f8b0:400d:c01::22e]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 0A57311A4; Sat, 1 Mar 2014 10:09:01 +0000 (UTC) Received: by mail-qc0-f174.google.com with SMTP id x13so1863733qcv.5 for ; Sat, 01 Mar 2014 02:09:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:content-type; bh=rIBG4NnJbjitu2ANnds16OpaloT8ioy0z3Bhz2Hbo9M=; b=IzpJR4+HLgTeC9MuqDh7kuVNbu40GvqmUoo1EE8OYn4bUZEHgbHF4X0rxze8+odaWJ 2g2jq3RpTQjWdysTGDEAyyMz0e66fNLKrf5JZbY8zJ6a7+riz53QSER4UMmiT5MM30+D F6z1XM2skj28KCsQeAJOoAd/fPyo5qw5yxb+CWKYCdGZWm7oMkDFscur7M2ZkQRML9Ej Ed+cpx3B8QyuGsoVuQmhOK/jIcetAk5K+n14g1HQgaeKE5j3oqVzlbKefiTOJWjGAnAV zXXcXTZfqbDd5Nh0nJXO1H5fZ7F6tQlBRnMZ01A+r58QMX9W1mMNF0OVyHb2MnTyW6++ kzfg== MIME-Version: 1.0 X-Received: by 10.224.57.142 with SMTP id c14mr9954341qah.55.1393668541141; Sat, 01 Mar 2014 02:09:01 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.224.16.10 with HTTP; Sat, 1 Mar 2014 02:09:01 -0800 (PST) In-Reply-To: <201403011004.s21A4VTM097197@svn.freebsd.org> References: <201403011004.s21A4VTM097197@svn.freebsd.org> Date: Sat, 1 Mar 2014 02:09:01 -0800 X-Google-Sender-Auth: y4cR7jigE4n74azcSYRXdwbkK5Y Message-ID: Subject: Re: svn commit: r262653 - head/sys/dev/etherswitch/arswitch From: Adrian Chadd To: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset=ISO-8859-1 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.17 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: Sat, 01 Mar 2014 10:09:02 -0000 Source: OpenWRT; much reading of the AR8327 datasheet. -a On 1 March 2014 02:04, Adrian Chadd wrote: > Author: adrian > Date: Sat Mar 1 10:04:31 2014 > New Revision: 262653 > URL: http://svnweb.freebsd.org/changeset/base/262653 > > Log: > (I think!) make the AR8327 switch correctly handle traffic. > > This patch does four things: > > * it globally disables mirroring; > * it globally sets the mirroring on each port to be disabled; > * the initial port setup now programs a portmask for the port to allow > transmission (forwarding) to all other ports bar itself; > * the vlan setup path now programs the portmask for the port to > allow transmission (forwarding) to all other ports bar itself. > > Before this, I hard-coded the portmask to 0x3f which would mean all > ports (bar port 6, which currently isn't hooked up to anything.) > This means that traffic would be duplicated back out the port it > received it. I bet this wasn't .. optimal. > > In any case, this _seems_ to make DHCP from my macosx laptop > work through this access point. I'll do some further testing > to ensure it's actually working correctly on all my devices. > > Tested: > > * DB120, AR8327 switch > > Modified: > head/sys/dev/etherswitch/arswitch/arswitch_8327.c > > Modified: head/sys/dev/etherswitch/arswitch/arswitch_8327.c > ============================================================================== > --- head/sys/dev/etherswitch/arswitch/arswitch_8327.c Sat Mar 1 04:49:55 2014 (r262652) > +++ head/sys/dev/etherswitch/arswitch/arswitch_8327.c Sat Mar 1 10:04:31 2014 (r262653) > @@ -665,8 +665,19 @@ ar8327_port_init(struct arswitch_softc * > t = AR8327_PORT_VLAN1_OUT_MODE_UNTOUCH << AR8327_PORT_VLAN1_OUT_MODE_S; > arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_VLAN1(port), t); > > + /* > + * This doesn't configure any ports which this port can "see". > + * bits 0-6 control which ports a frame coming into this port > + * can be sent out to. > + * > + * So by doing this, we're making it impossible to send frames out > + * to that port. > + */ > t = AR8327_PORT_LOOKUP_LEARN; > t |= AR8X16_PORT_CTRL_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; > + > + /* So this allows traffic to any port except ourselves */ > + t |= (0x3f & ~(1 << port)); > arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_LOOKUP(port), t); > } > > @@ -695,6 +706,13 @@ ar8327_reset_vlans(struct arswitch_softc > uint32_t mode, t; > > /* > + * Disable mirroring. > + */ > + arswitch_modifyreg(sc->sc_dev, AR8327_REG_FWD_CTRL0, > + AR8327_FWD_CTRL0_MIRROR_PORT, > + (0xF << AR8327_FWD_CTRL0_MIRROR_PORT_S)); > + > + /* > * For now, let's default to one portgroup, just so traffic > * flows. All ports can see other ports. > */ > @@ -713,13 +731,25 @@ ar8327_reset_vlans(struct arswitch_softc > > /* Set ingress = out_keep; members = 0x3f for all ports */ > > - t = 0x3f; /* all ports */ > + t = (0x3f & ~(1 << i)); /* all ports besides us */ > t |= AR8327_PORT_LOOKUP_LEARN; > > /* in_port_only, forward */ > t |= AR8X16_PORT_VLAN_MODE_PORT_ONLY << AR8327_PORT_LOOKUP_IN_MODE_S; > t |= AR8X16_PORT_CTRL_STATE_FORWARD << AR8327_PORT_LOOKUP_STATE_S; > arswitch_writereg(sc->sc_dev, AR8327_REG_PORT_LOOKUP(i), t); > + > + /* > + * Disable port mirroring entirely. > + */ > + arswitch_modifyreg(sc->sc_dev, > + AR8327_REG_PORT_LOOKUP(i), > + AR8327_PORT_LOOKUP_ING_MIRROR_EN, > + 0); > + arswitch_modifyreg(sc->sc_dev, > + AR8327_REG_PORT_HOL_CTRL1(i), > + AR8327_PORT_HOL_CTRL1_EG_MIRROR_EN, > + 0); > } > } > >