Deleted Added
full compact
31c31
< __FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet-common.c 226024 2011-10-04 20:17:43Z marcel $");
---
> __FBSDID("$FreeBSD: head/sys/mips/cavium/octe/ethernet-common.c 231987 2012-02-22 01:30:25Z gonzo $");
48a49,50
> static uint64_t mac_addr = 0;
> static uint32_t mac_offset = 0;
92a95,125
> * 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 Filled in with the assigned address if non-NULL
> * @param octets Filled in with the assigned address if non-NULL
> * @return Zero on success
> */
> 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)
> return ENXIO;
> }
>
> if (mac_offset >= cvmx_sysinfo_get()->mac_addr_count)
> return ENXIO; /* Out of addresses to assign */
>
> if (macp)
> *macp = mac_addr;
> if (octets)
> memcpy(octets, (u_int8_t *)&mac_addr + 2, 6);
>
> mac_addr++;
> mac_offset++;
>
> return 0;
> }
>
> /**
271,277c304
< char mac[6] = {
< cvmx_sysinfo_get()->mac_addr_base[0],
< cvmx_sysinfo_get()->mac_addr_base[1],
< cvmx_sysinfo_get()->mac_addr_base[2],
< cvmx_sysinfo_get()->mac_addr_base[3],
< cvmx_sysinfo_get()->mac_addr_base[4],
< cvmx_sysinfo_get()->mac_addr_base[5] };
---
> uint8_t mac[6];
280c307,308
< mac[5] += cvm_oct_mac_addr_offset++;
---
> if (cvm_assign_mac_address(NULL, mac) != 0)
> return ENXIO;