From owner-svn-src-all@FreeBSD.ORG Wed Feb 29 05:48:30 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 783C8106566B; Wed, 29 Feb 2012 05:48:30 +0000 (UTC) (envelope-from gonzo@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 631578FC15; Wed, 29 Feb 2012 05:48:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q1T5mUjg011234; Wed, 29 Feb 2012 05:48:30 GMT (envelope-from gonzo@svn.freebsd.org) Received: (from gonzo@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q1T5mUfd011230; Wed, 29 Feb 2012 05:48:30 GMT (envelope-from gonzo@svn.freebsd.org) Message-Id: <201202290548.q1T5mUfd011230@svn.freebsd.org> From: Oleksandr Tymoshenko Date: Wed, 29 Feb 2012 05:48:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r232289 - in head/sys/mips/cavium: . octe X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Feb 2012 05:48:30 -0000 Author: gonzo Date: Wed Feb 29 05:48:29 2012 New Revision: 232289 URL: http://svn.freebsd.org/changeset/base/232289 Log: Revert part of old logic of assigning MAC addressess: - Reserver respective number of addresses for managment port - octm uses base address directly - other drivers get MACs on "first come first served" basis Reviewed by: juli Modified: head/sys/mips/cavium/files.octeon1 head/sys/mips/cavium/if_octm.c head/sys/mips/cavium/octe/ethernet-common.c Modified: head/sys/mips/cavium/files.octeon1 ============================================================================== --- head/sys/mips/cavium/files.octeon1 Wed Feb 29 05:41:29 2012 (r232288) +++ head/sys/mips/cavium/files.octeon1 Wed Feb 29 05:48:29 2012 (r232289) @@ -24,7 +24,6 @@ mips/cavium/cryptocteon/cryptocteon.c o mips/mips/octeon_cop2_swtch.S standard mips/mips/octeon_cop2.c standard -# octm must be first, so management ports get the first MAC addresses mips/cavium/if_octm.c optional octm contrib/octeon-sdk/cvmx-mgmt-port.c optional octm Modified: head/sys/mips/cavium/if_octm.c ============================================================================== --- head/sys/mips/cavium/if_octm.c Wed Feb 29 05:41:29 2012 (r232288) +++ head/sys/mips/cavium/if_octm.c Wed Feb 29 05:48:29 2012 (r232289) @@ -63,7 +63,6 @@ #include #include #include -#include "octe/ethernet-common.h" struct octm_softc { struct ifnet *sc_ifp; @@ -177,10 +176,10 @@ octm_attach(device_t dev) /* * Set MAC address for this management port. */ - if (cvm_assign_mac_address(&mac, NULL) != 0) { - device_printf(dev, "unable to allocate MAC address.\n"); - return (ENXIO); - } + mac = 0; + memcpy((u_int8_t *)&mac + 2, cvmx_sysinfo_get()->mac_addr_base, 6); + mac += sc->sc_port; + cvmx_mgmt_port_set_mac(sc->sc_port, mac); /* No watermark for input ring. */ Modified: head/sys/mips/cavium/octe/ethernet-common.c ============================================================================== --- head/sys/mips/cavium/octe/ethernet-common.c Wed Feb 29 05:41:29 2012 (r232288) +++ head/sys/mips/cavium/octe/ethernet-common.c Wed Feb 29 05:48:29 2012 (r232289) @@ -46,8 +46,8 @@ __FBSDID("$FreeBSD$"); extern int octeon_is_simulation(void); -static uint64_t mac_addr = 0; -static uint32_t mac_offset = 0; +static uint64_t cvm_oct_mac_addr = 0; +static uint32_t cvm_oct_mac_addr_offset = 0; /** * Set the multicast list. Currently unimplemented. @@ -102,22 +102,42 @@ void cvm_oct_common_set_multicast_list(s int cvm_assign_mac_address(uint64_t *macp, uint8_t *octets) { /* Initialize from global MAC address base; fail if not set */ - if (mac_addr == 0) { - memcpy((uint8_t *)&mac_addr + 2, cvmx_sysinfo_get()->mac_addr_base, 6); - if (mac_addr == 0) + if (cvm_oct_mac_addr == 0) { + memcpy((uint8_t *)&cvm_oct_mac_addr + 2, + cvmx_sysinfo_get()->mac_addr_base, 6); + + if (cvm_oct_mac_addr == 0) return ENXIO; + + /* + * The offset from mac_addr_base that should be used for the next port + * that is configured. By convention, if any mgmt ports exist on the + * chip, they get the first mac addresses. The ports controlled by + * driver that use this function are numbered sequencially following + * any mgmt addresses that may exist. + * + * XXX Would be nice if __cvmx_mgmt_port_num_ports() were + * not static to cvmx-mgmt-port.c. + */ + if (OCTEON_IS_MODEL(OCTEON_CN56XX)) + cvm_oct_mac_addr_offset = 1; + else if (OCTEON_IS_MODEL(OCTEON_CN52XX) || OCTEON_IS_MODEL(OCTEON_CN63XX)) + cvm_oct_mac_addr_offset = 2; + else + cvm_oct_mac_addr_offset = 0; + cvm_oct_mac_addr += cvm_oct_mac_addr_offset; } - if (mac_offset >= cvmx_sysinfo_get()->mac_addr_count) + if (cvm_oct_mac_addr_offset >= cvmx_sysinfo_get()->mac_addr_count) return ENXIO; /* Out of addresses to assign */ if (macp) - *macp = mac_addr; + *macp = cvm_oct_mac_addr; if (octets) - memcpy(octets, (u_int8_t *)&mac_addr + 2, 6); + memcpy(octets, (u_int8_t *)&cvm_oct_mac_addr + 2, 6); - mac_addr++; - mac_offset++; + cvm_oct_mac_addr++; + cvm_oct_mac_addr_offset++; return 0; }