Author: jmallett
Date: Wed Mar 16 22:51:34 2011
New Revision: 219706
URL: http://svn.freebsd.org/changeset/base/219706

Log:
  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)

Modified:
  head/sys/mips/cavium/if_octm.c
  head/sys/mips/cavium/octe/ethernet-common.c
  head/sys/mips/cavium/octe/ethernet-common.h
  head/sys/mips/cavium/octe/ethernet.c

Modified: head/sys/mips/cavium/if_octm.c
==============================================================================
--- head/sys/mips/cavium/if_octm.c      Wed Mar 16 20:54:58 2011        
(r219705)
+++ head/sys/mips/cavium/if_octm.c      Wed Mar 16 22:51:34 2011        
(r219706)
@@ -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;

Modified: head/sys/mips/cavium/octe/ethernet-common.c
==============================================================================
--- head/sys/mips/cavium/octe/ethernet-common.c Wed Mar 16 20:54:58 2011        
(r219705)
+++ head/sys/mips/cavium/octe/ethernet-common.c Wed Mar 16 22:51:34 2011        
(r219706)
@@ -269,34 +269,19 @@ void cvm_oct_common_poll(struct ifnet *i
  */
 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);

Modified: head/sys/mips/cavium/octe/ethernet-common.h
==============================================================================
--- head/sys/mips/cavium/octe/ethernet-common.h Wed Mar 16 20:54:58 2011        
(r219705)
+++ head/sys/mips/cavium/octe/ethernet-common.h Wed Mar 16 22:51:34 2011        
(r219706)
@@ -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;

Modified: head/sys/mips/cavium/octe/ethernet.c
==============================================================================
--- head/sys/mips/cavium/octe/ethernet.c        Wed Mar 16 20:54:58 2011        
(r219705)
+++ head/sys/mips/cavium/octe/ethernet.c        Wed Mar 16 22:51:34 2011        
(r219706)
@@ -103,6 +103,15 @@ static struct taskqueue *cvm_oct_link_ta
  */
 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);
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to