On 18 Apr 2014, at 14:28 , Ian Lepore <i...@freebsd.org> wrote:

> On Fri, 2014-04-18 at 14:21 +0000, Bjoern A. Zeeb wrote:
>> Author: bz
>> Date: Fri Apr 18 14:21:10 2014
>> New Revision: 264646
>> URL: http://svnweb.freebsd.org/changeset/base/264646
>> 
>> Log:
>>  Now that I figured out where the ethernet addresses come from
>>  on NetFPGA-10G, assign one to the interface by default in a very
>>  similar way.
>> 
>>  MFC after:          6 days
>>  X-Easter-Egg-Hunt:  yes
>> 
>> Modified:
>>  head/sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c
>> 
>> Modified: head/sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c
>> ==============================================================================
>> --- head/sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c   Fri Apr 18 12:51:30 
>> 2014        (r264645)
>> +++ head/sys/dev/netfpga10g/nf10bmac/if_nf10bmac.c   Fri Apr 18 14:21:10 
>> 2014        (r264646)
>> @@ -446,7 +446,25 @@ static int
>> nf10bmac_reset(struct nf10bmac_softc *sc)
>> {
>> 
>> -    /* Currently we cannot do anything. */
>> +    /*
>> +     * If we do not have an ether address set, initialize to the same
>> +     * OUI as NetFPGA-10G Linux driver does (which luckily seems
>> +     * unallocated).  We just change the NIC specific part from
>> +     * the slightly long "\0NF10C0" to "\0NFBSD".
>> +     * Oh and we keep the way of setting it from a string as they do.
>> +     * It's an amazing way to hide it.
>> +     * XXX-BZ If NetFPGA gets their own OUI we should fix this.
>> +     */
>> +    if (sc->nf10bmac_eth_addr[0] == 0x00 &&
>> +        sc->nf10bmac_eth_addr[1] == 0x00 &&
>> +        sc->nf10bmac_eth_addr[2] == 0x00 &&
>> +        sc->nf10bmac_eth_addr[3] == 0x00 &&
>> +        sc->nf10bmac_eth_addr[4] == 0x00 &&
>> +        sc->nf10bmac_eth_addr[5] == 0x00) {
>> +            memcpy(&sc->nf10bmac_eth_addr, "\0NFBSD", ETHER_ADDR_LEN);
>> +            sc->nf10bmac_eth_addr[5] += sc->nf10bmac_unit;
>> +    }
>> +
>>      return (0);
>> }
>> 
>> 
> 
> For other drivers/socs where we need to cook up an address on the fly,
> we've used "bsd" as the OUI and a 24-bit random for the low order.
> Aside from the nice aesthetic, 'bsd' has the "locally administered" bit
> set and thus is g'teed to not clash with any globally assigned OUI.

This is, as the comment, the commit message, and the XXX-BZ indicates, to be 
consistent with that platform.  The change is only to not conflict with the 
host driver to avoid duplicate ethernet addresses when host PCI/DMA interfaces, 
and the “inside” PIO interfaces all talk to each other.

If I’d do this another way, I’d (a) get a tiny slice from the official FreeBSD 
OUI and (b) put some random bits on the NIC part + the unit number.


And, as we have learnt elsewhere, sys/net-admins are not always happy if you 
set the locally administered bit by default, as it’s them to assign the 
addresses and not the user.  It’s a game you cannot globally win.  This is 
about providing a “matching” default for the environment, and that’s why it 
sticks with what the platform is doing for now.

/bz

— 
Bjoern A. Zeeb             "Come on. Learn, goddamn it.", WarGames, 1983

_______________________________________________
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