From 3929b790ffa5d9dc6f772c0b8aa93519bfd2d61a Mon Sep 17 00:00:00 2001 From: jmallett Date: Wed, 16 Mar 2011 22:51:34 +0000 Subject: [PATCH] o) Set MAC addresses starting at the MAC base for all management ports, not just the MR-730. o) Start MAC addresses for the non-management ports after the management ports. Submitted by: Bhanu Prakash (with modifications) --- sys/mips/cavium/if_octm.c | 29 +++++++------------------- sys/mips/cavium/octe/ethernet-common.c | 19 ++--------------- sys/mips/cavium/octe/ethernet-common.h | 2 ++ sys/mips/cavium/octe/ethernet.c | 23 ++++++++++++++++++++ 4 files changed, 34 insertions(+), 39 deletions(-) diff --git a/sys/mips/cavium/if_octm.c b/sys/mips/cavium/if_octm.c index 68969eea34c0..a753d663752a 100644 --- a/sys/mips/cavium/if_octm.c +++ b/sys/mips/cavium/if_octm.c @@ -175,28 +175,13 @@ octm_attach(device_t dev) return (ENXIO); } - switch (cvmx_sysinfo_get()->board_type) { -#if defined(OCTEON_VENDOR_LANNER) - case CVMX_BOARD_TYPE_CUST_LANNER_MR730: - /* - * The MR-730 uses its first two MACs for the management - * ports. - */ - mac = 0; - memcpy((u_int8_t *)&mac + 2, octeon_bootinfo->mac_addr_base, - 6); - mac += sc->sc_port; - cvmx_mgmt_port_set_mac(sc->sc_port, mac); - break; -#endif - default: - mac = cvmx_mgmt_port_get_mac(sc->sc_port); - if (mac == CVMX_MGMT_PORT_GET_MAC_ERROR) { - device_printf(dev, "unable to read MAC.\n"); - return (ENXIO); - } - break; - } + /* + * Set MAC address for this management port. + */ + mac = 0; + memcpy((u_int8_t *)&mac + 2, octeon_bootinfo->mac_addr_base, 6); + mac += sc->sc_port; + cvmx_mgmt_port_set_mac(sc->sc_port, mac); /* No watermark for input ring. */ mixx_irhwm.u64 = 0; diff --git a/sys/mips/cavium/octe/ethernet-common.c b/sys/mips/cavium/octe/ethernet-common.c index 415c3d43600f..73103cc4725a 100644 --- a/sys/mips/cavium/octe/ethernet-common.c +++ b/sys/mips/cavium/octe/ethernet-common.c @@ -269,34 +269,19 @@ void cvm_oct_common_poll(struct ifnet *ifp) */ int cvm_oct_common_init(struct ifnet *ifp) { - static int count; char mac[6] = { octeon_bootinfo->mac_addr_base[0], octeon_bootinfo->mac_addr_base[1], octeon_bootinfo->mac_addr_base[2], octeon_bootinfo->mac_addr_base[3], octeon_bootinfo->mac_addr_base[4], - octeon_bootinfo->mac_addr_base[5] + count}; + octeon_bootinfo->mac_addr_base[5] }; cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc; - switch (cvmx_sysinfo_get()->board_type) { -#if defined(OCTEON_VENDOR_LANNER) - case CVMX_BOARD_TYPE_CUST_LANNER_MR730: - /* - * The MR-730 uses its first two MACs for the management - * ports. - */ - mac[5] += 2; - break; -#endif - default: - break; - } + mac[5] += cvm_oct_mac_addr_offset++; ifp->if_mtu = ETHERMTU; - count++; - cvm_oct_mdio_setup_device(ifp); cvm_oct_common_set_mac_address(ifp, mac); diff --git a/sys/mips/cavium/octe/ethernet-common.h b/sys/mips/cavium/octe/ethernet-common.h index f9d4dc3ea3a6..cf23f5bd6d75 100644 --- a/sys/mips/cavium/octe/ethernet-common.h +++ b/sys/mips/cavium/octe/ethernet-common.h @@ -51,3 +51,5 @@ int cvm_oct_sgmii_init(struct ifnet *ifp); int cvm_oct_spi_init(struct ifnet *ifp); void cvm_oct_spi_uninit(struct ifnet *ifp); int cvm_oct_xaui_init(struct ifnet *ifp); + +extern unsigned int cvm_oct_mac_addr_offset; diff --git a/sys/mips/cavium/octe/ethernet.c b/sys/mips/cavium/octe/ethernet.c index 3b035faa8b03..50b91fcf0a7f 100644 --- a/sys/mips/cavium/octe/ethernet.c +++ b/sys/mips/cavium/octe/ethernet.c @@ -103,6 +103,15 @@ static struct taskqueue *cvm_oct_link_taskq; */ static int cvm_oct_num_output_buffers; +/* + * 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 + * this driver are numbered sequencially following any mgmt addresses + * that may exist. + */ +unsigned int cvm_oct_mac_addr_offset; + /** * Function to update link status. */ @@ -318,6 +327,20 @@ int cvm_oct_init_module(device_t bus) printf("cavium-ethernet: %s\n", OCTEON_SDK_VERSION_STRING); + /* + * MAC addresses for this driver start after the management + * ports. + * + * 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_rx_initialize(); cvm_oct_configure_common_hw(bus);