From owner-svn-src-head@FreeBSD.ORG Fri Feb 24 08:39:00 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1C3211065673 for ; Fri, 24 Feb 2012 08:39:00 +0000 (UTC) (envelope-from juli@clockworksquid.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 914A78FC17 for ; Fri, 24 Feb 2012 08:38:59 +0000 (UTC) Received: by wgbdq11 with SMTP id dq11so1801115wgb.31 for ; Fri, 24 Feb 2012 00:38:58 -0800 (PST) Received-SPF: pass (google.com: domain of juli@clockworksquid.com designates 10.216.135.37 as permitted sender) client-ip=10.216.135.37; Authentication-Results: mr.google.com; spf=pass (google.com: domain of juli@clockworksquid.com designates 10.216.135.37 as permitted sender) smtp.mail=juli@clockworksquid.com Received: from mr.google.com ([10.216.135.37]) by 10.216.135.37 with SMTP id t37mr614110wei.44.1330072738540 (num_hops = 1); Fri, 24 Feb 2012 00:38:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding:x-gm-message-state; bh=c+q1Svd7z22mOuAltEm+JkF1Iir8332TOrtEKnFcxeE=; b=LHmrNBu0EI1PIAjp9YBGAtGDICAv75ZC2YyWvsIH2s2QMT+zCUldNew6iaHpDuZUQ+ Rof0TAZMbApUThgZiXqPYg34Xt8qsIG7tGApO76P9NTRt/UKTmQIICNfwLxCgPaC79Iu lj7RDRhWxMShwPaMMQz8QdXeiHnRpiQ5O+nUo= Received: by 10.216.135.37 with SMTP id t37mr461102wei.44.1330071383199; Fri, 24 Feb 2012 00:16:23 -0800 (PST) MIME-Version: 1.0 Sender: juli@clockworksquid.com Received: by 10.227.209.78 with HTTP; Fri, 24 Feb 2012 00:16:03 -0800 (PST) In-Reply-To: <201202220130.q1M1UQ30028591@svn.freebsd.org> References: <201202220130.q1M1UQ30028591@svn.freebsd.org> From: Juli Mallett Date: Fri, 24 Feb 2012 00:16:03 -0800 X-Google-Sender-Auth: bkTN8CZPuRsW7BeZpgYYS70gl3M Message-ID: To: Oleksandr Tymoshenko Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkj612qKti+V8OJpaOQiQulv88Oh0vbmgkD61ekdPo+pJe/Oa8D91IAC6DCbAb5cPzKcz5W Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r231987 - in head/sys/mips/cavium: . octe X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Fri, 24 Feb 2012 08:39:00 -0000 On Tue, Feb 21, 2012 at 17:30, Oleksandr Tymoshenko wro= te: > Author: gonzo > Date: Wed Feb 22 01:30:25 2012 > New Revision: 231987 > URL: http://svn.freebsd.org/changeset/base/231987 > > Log: > =C2=A0Refctor address assignment for Octeon's ethernet ports: > > =C2=A0- Centralize address assignment > =C2=A0- Make sure managment ports get first MAC address in pool It was the case that this would happen, now we're relying on object link order to do the right thing, which I think is a mistake. This is a fix for a bug introduced by this patch. I don't like the idea of handing out MAC addresses to ports as they're configured, as this *does* break things if you don't have the octm driver in your kernel, but do have management ports. Your bootloader comes up, uses the same logic we were using to assign MACs (which is the gold standard in publicly-available Octeonland, even if there are private bootloaders and kernels which did differently), and then when the kernel boots, the MAC assigned to the physical ports is different. If you use DHCP + bootp on the management port to boot up, and then configure octe0 via DHCP, your lease moves from one physical port to another. In my experience, before I fixed things to match bootloader behavior, this could result in mysterious and exciting behavior involving long delays in connectivity at boot. And of course, now you'll get a different MAC for octe0 based on whether octm is in your kernel or not. Which is its own set of fun. The Octeon hardware doesn't need a per-port MAC you can read because there is a consistent way to allocate them to ports that is easy to follow. I don't see the benefit in handing them out dynamically, especially relying in link order to get it right. The previous method had shortcomings and a load of comments since there were dragons in the vicinity. This introduces a lot more magic, actually-confusing behavior, etc., and has few comments, and none that catch eyes in the right places. If we want to abstract this out into cvm_assign_mac_address so that downstream consumers of this code (or upstream, as the case may be) can do their own thing, I'd suggest passing down the interface number, whether it's a management port, etc., and restoring the original, consistent logic, in that function. This has the potential to be markedly-astonishing. What happens if we add support for loading octe and octm as modules (which has been requested by consumers of the Octeon code in the past)? Yikes! > =C2=A0- Properly propagate fail if address allocation failed > > =C2=A0Submitted by: Andrew Duane > > Modified: > =C2=A0head/sys/mips/cavium/files.octeon1 > =C2=A0head/sys/mips/cavium/if_octm.c > =C2=A0head/sys/mips/cavium/octe/ethernet-common.c > =C2=A0head/sys/mips/cavium/octe/ethernet-common.h > =C2=A0head/sys/mips/cavium/octe/ethernet-rgmii.c > =C2=A0head/sys/mips/cavium/octe/ethernet-sgmii.c > =C2=A0head/sys/mips/cavium/octe/ethernet-spi.c > =C2=A0head/sys/mips/cavium/octe/ethernet-xaui.c > =C2=A0head/sys/mips/cavium/octe/ethernet.c > > Modified: head/sys/mips/cavium/files.octeon1 > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/files.octeon1 =C2=A0Wed Feb 22 01:23:14 2012 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/files.octeon1 =C2=A0Wed Feb 22 01:30:25 2012 =C2= =A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -24,6 +24,10 @@ mips/cavium/cryptocteon/cryptocteon.c =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0o > =C2=A0mips/mips/octeon_cop2_swtch.S =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0standard > =C2=A0mips/mips/octeon_cop2.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0standa= rd > > +# octm must be first, so management ports get the first MAC addresses > +mips/cavium/if_octm.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0optional octm > +contrib/octeon-sdk/cvmx-mgmt-port.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0optional octm > + > =C2=A0mips/cavium/octe/ethernet.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0optional octe > =C2=A0mips/cavium/octe/ethernet-mv88e61xx.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0optional octe octeon_vendor_lanner > =C2=A0mips/cavium/octe/ethernet-common.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 optional octe > @@ -39,10 +43,6 @@ mips/cavium/octe/mv88e61xxphy.c =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0option > =C2=A0mips/cavium/octe/octe.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0option= al octe > =C2=A0mips/cavium/octe/octebus.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 optional octe > > -mips/cavium/if_octm.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0optional octm > - > -contrib/octeon-sdk/cvmx-mgmt-port.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0optional octm > - > =C2=A0mips/cavium/octopci.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0optional pci > =C2=A0mips/cavium/octopci_bus_space.c =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0optional pci > > > Modified: head/sys/mips/cavium/if_octm.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/if_octm.c =C2=A0 =C2=A0 =C2=A0Wed Feb 22 01:23:1= 4 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/if_octm.c =C2=A0 =C2=A0 =C2=A0Wed Feb 22 01:30:2= 5 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -63,6 +63,7 @@ > =C2=A0#include > =C2=A0#include > =C2=A0#include > +#include "octe/ethernet-common.h" > > =C2=A0struct octm_softc { > =C2=A0 =C2=A0 =C2=A0 =C2=A0struct ifnet *sc_ifp; > @@ -176,9 +177,10 @@ octm_attach(device_t dev) > =C2=A0 =C2=A0 =C2=A0 =C2=A0/* > =C2=A0 =C2=A0 =C2=A0 =C2=A0 * Set MAC address for this management port. > =C2=A0 =C2=A0 =C2=A0 =C2=A0 */ > - =C2=A0 =C2=A0 =C2=A0 mac =3D 0; > - =C2=A0 =C2=A0 =C2=A0 memcpy((u_int8_t *)&mac + 2, cvmx_sysinfo_get()->m= ac_addr_base, 6); > - =C2=A0 =C2=A0 =C2=A0 mac +=3D sc->sc_port; > + =C2=A0 =C2=A0 =C2=A0 if (cvm_assign_mac_address(&mac, NULL) !=3D 0) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 device_printf(dev, "un= able to allocate MAC address.\n"); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return (ENXIO); > + =C2=A0 =C2=A0 =C2=A0 } > =C2=A0 =C2=A0 =C2=A0 =C2=A0cvmx_mgmt_port_set_mac(sc->sc_port, mac); > > =C2=A0 =C2=A0 =C2=A0 =C2=A0/* No watermark for input ring. =C2=A0*/ > > Modified: head/sys/mips/cavium/octe/ethernet-common.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/octe/ethernet-common.c Wed Feb 22 01:23:14 2012 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/octe/ethernet-common.c Wed Feb 22 01:30:25 2012 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$"); > > =C2=A0extern int octeon_is_simulation(void); > > +static uint64_t mac_addr =3D 0; > +static uint32_t mac_offset =3D 0; > > =C2=A0/** > =C2=A0* Set the multicast list. Currently unimplemented. > @@ -90,6 +92,37 @@ void cvm_oct_common_set_multicast_list(s > > > =C2=A0/** > + * Assign a MAC addres from the pool of available MAC addresses > + * Can return as either a 64-bit value and/or 6 octets. > + * > + * @param macp =C2=A0 =C2=A0Filled in with the assigned address if non-N= ULL > + * @param octets =C2=A0Filled in with the assigned address if non-NULL > + * @return Zero on success > + */ > +int cvm_assign_mac_address(uint64_t *macp, uint8_t *octets) > +{ > + =C2=A0 =C2=A0 =C2=A0 /* Initialize from global MAC address base; fail i= f not set */ > + =C2=A0 =C2=A0 =C2=A0 if (mac_addr =3D=3D 0) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memcpy((uint8_t *)&mac= _addr + 2, cvmx_sysinfo_get()->mac_addr_base, 6); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (mac_addr =3D=3D 0) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 return ENXIO; > + =C2=A0 =C2=A0 =C2=A0 } > + > + =C2=A0 =C2=A0 =C2=A0 if (mac_offset >=3D cvmx_sysinfo_get()->mac_addr_c= ount) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return ENXIO; =C2=A0 = =C2=A0 =C2=A0 /* Out of addresses to assign */ > + > + =C2=A0 =C2=A0 =C2=A0 if (macp) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 *macp =3D mac_addr; > + =C2=A0 =C2=A0 =C2=A0 if (octets) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 memcpy(octets, (u_int8= _t *)&mac_addr + 2, 6); > + > + =C2=A0 =C2=A0 =C2=A0 mac_addr++; > + =C2=A0 =C2=A0 =C2=A0 mac_offset++; > + > + =C2=A0 =C2=A0 =C2=A0 return 0; > +} > + > +/** > =C2=A0* Set the hardware MAC address for a device > =C2=A0* > =C2=A0* @param dev =C2=A0 =C2=A0Device to change the MAC address for > @@ -268,16 +301,11 @@ void cvm_oct_common_poll(struct ifnet *i > =C2=A0*/ > =C2=A0int cvm_oct_common_init(struct ifnet *ifp) > =C2=A0{ > - =C2=A0 =C2=A0 =C2=A0 char mac[6] =3D { > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvmx_sysinfo_get()->ma= c_addr_base[0], > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvmx_sysinfo_get()->ma= c_addr_base[1], > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvmx_sysinfo_get()->ma= c_addr_base[2], > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvmx_sysinfo_get()->ma= c_addr_base[3], > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvmx_sysinfo_get()->ma= c_addr_base[4], > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvmx_sysinfo_get()->ma= c_addr_base[5] }; > + =C2=A0 =C2=A0 =C2=A0 uint8_t mac[6]; > =C2=A0 =C2=A0 =C2=A0 =C2=A0cvm_oct_private_t *priv =3D (cvm_oct_private_t= *)ifp->if_softc; > > - =C2=A0 =C2=A0 =C2=A0 mac[5] +=3D cvm_oct_mac_addr_offset++; > + =C2=A0 =C2=A0 =C2=A0 if (cvm_assign_mac_address(NULL, mac) !=3D 0) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return ENXIO; > > =C2=A0 =C2=A0 =C2=A0 =C2=A0ifp->if_mtu =3D ETHERMTU; > > > Modified: head/sys/mips/cavium/octe/ethernet-common.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/octe/ethernet-common.h Wed Feb 22 01:23:14 2012 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/octe/ethernet-common.h Wed Feb 22 01:30:25 2012 = =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -37,6 +37,7 @@ void cvm_oct_common_uninit(struct ifnet > =C2=A0int cvm_oct_common_change_mtu(struct ifnet *ifp, int new_mtu); > =C2=A0void cvm_oct_common_set_multicast_list(struct ifnet *ifp); > =C2=A0void cvm_oct_common_set_mac_address(struct ifnet *ifp, const void *= ); > +int cvm_assign_mac_address(uint64_t *, uint8_t *); > > =C2=A0int cvm_oct_init_module(device_t); > =C2=A0void cvm_oct_cleanup_module(device_t); > @@ -52,4 +53,3 @@ int cvm_oct_spi_init(struct ifnet *ifp); > =C2=A0void cvm_oct_spi_uninit(struct ifnet *ifp); > =C2=A0int cvm_oct_xaui_init(struct ifnet *ifp); > > -extern unsigned int cvm_oct_mac_addr_offset; > > Modified: head/sys/mips/cavium/octe/ethernet-rgmii.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/octe/ethernet-rgmii.c =C2=A0Wed Feb 22 01:23:14 = 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/octe/ethernet-rgmii.c =C2=A0Wed Feb 22 01:30:25 = 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -215,7 +215,9 @@ int cvm_oct_rgmii_init(struct ifnet *ifp > =C2=A0 =C2=A0 =C2=A0 =C2=A0int error; > =C2=A0 =C2=A0 =C2=A0 =C2=A0int rid; > > - =C2=A0 =C2=A0 =C2=A0 cvm_oct_common_init(ifp); > + =C2=A0 =C2=A0 =C2=A0 if (cvm_oct_common_init(ifp) !=3D 0) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return ENXIO; > + > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->open =3D cvm_oct_common_open; > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->stop =3D cvm_oct_common_stop; > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->stop(ifp); > > Modified: head/sys/mips/cavium/octe/ethernet-sgmii.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/octe/ethernet-sgmii.c =C2=A0Wed Feb 22 01:23:14 = 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/octe/ethernet-sgmii.c =C2=A0Wed Feb 22 01:30:25 = 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -49,7 +49,10 @@ extern int octeon_is_simulation(void); > =C2=A0int cvm_oct_sgmii_init(struct ifnet *ifp) > =C2=A0{ > =C2=A0 =C2=A0 =C2=A0 =C2=A0cvm_oct_private_t *priv =3D (cvm_oct_private_t= *)ifp->if_softc; > - =C2=A0 =C2=A0 =C2=A0 cvm_oct_common_init(ifp); > + > + =C2=A0 =C2=A0 =C2=A0 if (cvm_oct_common_init(ifp) !=3D 0) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return ENXIO; > + > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->open =3D cvm_oct_common_open; > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->stop =3D cvm_oct_common_stop; > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->stop(ifp); > > Modified: head/sys/mips/cavium/octe/ethernet-spi.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/octe/ethernet-spi.c =C2=A0 =C2=A0Wed Feb 22 01:2= 3:14 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/octe/ethernet-spi.c =C2=A0 =C2=A0Wed Feb 22 01:3= 0:25 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -289,7 +289,8 @@ int cvm_oct_spi_init(struct ifnet *ifp) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cvm_oct_spi_enable= _error_reporting(INTERFACE(priv->port)); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->poll =3D cvm= _oct_spi_poll; > =C2=A0 =C2=A0 =C2=A0 =C2=A0} > - =C2=A0 =C2=A0 =C2=A0 cvm_oct_common_init(ifp); > + =C2=A0 =C2=A0 =C2=A0 if (cvm_oct_common_init(ifp) !=3D 0) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return ENXIO; > =C2=A0 =C2=A0 =C2=A0 =C2=A0return 0; > =C2=A0} > > > Modified: head/sys/mips/cavium/octe/ethernet-xaui.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/octe/ethernet-xaui.c =C2=A0 Wed Feb 22 01:23:14 = 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/octe/ethernet-xaui.c =C2=A0 Wed Feb 22 01:30:25 = 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -49,7 +49,10 @@ extern int octeon_is_simulation(void); > =C2=A0int cvm_oct_xaui_init(struct ifnet *ifp) > =C2=A0{ > =C2=A0 =C2=A0 =C2=A0 =C2=A0cvm_oct_private_t *priv =3D (cvm_oct_private_t= *)ifp->if_softc; > - =C2=A0 =C2=A0 =C2=A0 cvm_oct_common_init(ifp); > + > + =C2=A0 =C2=A0 =C2=A0 if (cvm_oct_common_init(ifp) !=3D 0) > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 return ENXIO; > + > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->open =3D cvm_oct_common_open; > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->stop =3D cvm_oct_common_stop; > =C2=A0 =C2=A0 =C2=A0 =C2=A0priv->stop(ifp); > > Modified: head/sys/mips/cavium/octe/ethernet.c > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/sys/mips/cavium/octe/ethernet.c =C2=A0 =C2=A0 =C2=A0 =C2=A0Wed F= eb 22 01:23:14 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231986) > +++ head/sys/mips/cavium/octe/ethernet.c =C2=A0 =C2=A0 =C2=A0 =C2=A0Wed F= eb 22 01:30:25 2012 =C2=A0 =C2=A0 =C2=A0 =C2=A0(r231987) > @@ -97,15 +97,6 @@ static struct taskqueue *cvm_oct_link_ta > =C2=A0*/ > =C2=A0static int cvm_oct_num_output_buffers; > > -/* > - * The offset from mac_addr_base that should be used for the next port > - * that is configured. =C2=A0By convention, if any mgmt ports exist on t= he > - * chip, they get the first mac addresses. =C2=A0The ports controlled by > - * this driver are numbered sequencially following any mgmt addresses > - * that may exist. > - */ > -unsigned int cvm_oct_mac_addr_offset; > - > =C2=A0/** > =C2=A0* Function to update link status. > =C2=A0*/ > @@ -321,20 +312,6 @@ int cvm_oct_init_module(device_t bus) > > =C2=A0 =C2=A0 =C2=A0 =C2=A0printf("cavium-ethernet: %s\n", OCTEON_SDK_VER= SION_STRING); > > - =C2=A0 =C2=A0 =C2=A0 /* > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* MAC addresses for this driver start after = the management > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* ports. > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* XXX Would be nice if __cvmx_mgmt_port_num_= ports() were > - =C2=A0 =C2=A0 =C2=A0 =C2=A0* =C2=A0 =C2=A0 not static to cvmx-mgmt-port= .c. > - =C2=A0 =C2=A0 =C2=A0 =C2=A0*/ > - =C2=A0 =C2=A0 =C2=A0 if (OCTEON_IS_MODEL(OCTEON_CN56XX)) > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvm_oct_mac_addr_offse= t =3D 1; > - =C2=A0 =C2=A0 =C2=A0 else if (OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_= IS_MODEL(OCTEON_CN63XX)) > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvm_oct_mac_addr_offse= t =3D 2; > - =C2=A0 =C2=A0 =C2=A0 else > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 cvm_oct_mac_addr_offse= t =3D 0; > - > =C2=A0 =C2=A0 =C2=A0 =C2=A0cvm_oct_rx_initialize(); > =C2=A0 =C2=A0 =C2=A0 =C2=A0cvm_oct_configure_common_hw(bus); > > @@ -375,15 +352,17 @@ int cvm_oct_init_module(device_t bus) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int num_ports =3D = cvmx_helper_ports_on_interface(interface); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0int port; > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (port =3D cvmx_hel= per_get_ipd_port(interface, 0); port < cvmx_helper_get_ipd_port(interface, = num_ports); port++) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 for (port =3D cvmx_hel= per_get_ipd_port(interface, 0); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0po= rt < cvmx_helper_get_ipd_port(interface, num_ports); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if= num++, port++) { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0cvm_oct_private_t *priv; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0struct ifnet *ifp; > > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 dev =3D BUS_ADD_CHILD(bus, 0, "octe", ifnum++); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 dev =3D BUS_ADD_CHILD(bus, 0, "octe", ifnum); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if (dev !=3D NULL) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ifp =3D if_alloc(IFT_ETHER); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if (dev =3D=3D NULL || ifp =3D=3D NULL) { > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("\t\tFailed to allocate ethernet = device for port %d\n", port); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("Failed to allocate ethernet devi= ce for interface %d port %d\n", interface, port); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0continue; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0} > > @@ -454,12 +433,13 @@ int cvm_oct_init_module(device_t bus) > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0ifp->if_softc =3D priv; > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0if (!priv->init) { > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 panic("%s: unsupported device type, need= to free ifp.", __func__); > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 } else > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 if (priv->init(ifp) < 0) { > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("\t\tFailed to register ethernet = device for interface %d, port %d\n", > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 interface, priv->port); > - =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 panic("%s: init failed, need to free ifp= .", __func__); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("octe%d: unsupported device type = interface %d, port %d\n", > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ifnum, interf= ace, priv->port); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if_free(ifp); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 } else if (priv->init(ifp) !=3D 0) { > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 printf("octe%d: failed to register devic= e for interface %d, port %d\n", > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0ifnum, interf= ace, priv->port); > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if_free(ifp); > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0} else { > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0cvm_oct_device[priv->port] =3D ifp; > =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fau -=3D cvmx_pko_get_num_queues(priv= ->port) * sizeof(uint32_t);