summaryrefslogtreecommitdiff
path: root/include/asm-blackfin/net.h
blob: 97cb46691e4636ad8ec4d9de27424272ee01aeb4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
/*
 * net.h - misc Blackfin network helpers
 *
 * Copyright (c) 2008-2009 Analog Devices Inc.
 *
 * Licensed under the GPL-2 or later.
 */

#ifndef __ASM_BFIN_RAND_MAC__
#define __ASM_BFIN_RAND_MAC__

/* If the board does not have a real MAC assigned to it, then generate a
 * locally administrated pseudo-random one based on CYCLES and compile date.
 */
static inline void bfin_gen_rand_mac(uchar *mac_addr)
{
	/* make something up */
	const char s[] = __DATE__;
	size_t i;
	u32 cycles;
	for (i = 0; i < 6; ++i) {
		asm("%0 = CYCLES;" : "=r" (cycles));
		mac_addr[i] = cycles ^ s[i];
	}
	mac_addr[0] = (mac_addr[0] | 0x02) & ~0x01; /* make it local unicast */
}

#endif