summaryrefslogtreecommitdiffstats
path: root/sys/mips/cavium/octe
diff options
context:
space:
mode:
authorgonzo <gonzo@FreeBSD.org>2012-02-29 05:48:29 +0000
committergonzo <gonzo@FreeBSD.org>2012-02-29 05:48:29 +0000
commit3fb62bfe0205ce57ed13c8e891aa15fead2f8eed (patch)
treea482d640a351f57c54cef2580ccb0d688c7e1cbc /sys/mips/cavium/octe
parent54c1d2e89ae3474ab82015cb6b3f6d53e899e322 (diff)
downloadFreeBSD-src-3fb62bfe0205ce57ed13c8e891aa15fead2f8eed.zip
FreeBSD-src-3fb62bfe0205ce57ed13c8e891aa15fead2f8eed.tar.gz
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
Diffstat (limited to 'sys/mips/cavium/octe')
-rw-r--r--sys/mips/cavium/octe/ethernet-common.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/sys/mips/cavium/octe/ethernet-common.c b/sys/mips/cavium/octe/ethernet-common.c
index 3a39b55..c57744b 100644
--- a/sys/mips/cavium/octe/ethernet-common.c
+++ b/sys/mips/cavium/octe/ethernet-common.c
@@ -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(struct ifnet *ifp)
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;
}
OpenPOWER on IntegriCloud