Mike Frysinger | 751e54c | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 1 | /* |
| 2 | * net.h - misc Blackfin network helpers |
| 3 | * |
| 4 | * Copyright (c) 2008-2009 Analog Devices Inc. |
| 5 | * |
| 6 | * Licensed under the GPL-2 or later. |
| 7 | */ |
| 8 | |
| 9 | #ifndef __ASM_BFIN_RAND_MAC__ |
| 10 | #define __ASM_BFIN_RAND_MAC__ |
| 11 | |
| 12 | /* If the board does not have a real MAC assigned to it, then generate a |
| 13 | * locally administrated pseudo-random one based on CYCLES and compile date. |
| 14 | */ |
| 15 | static inline void bfin_gen_rand_mac(uchar *mac_addr) |
| 16 | { |
| 17 | /* make something up */ |
| 18 | const char s[] = __DATE__; |
| 19 | size_t i; |
| 20 | u32 cycles; |
| 21 | for (i = 0; i < 6; ++i) { |
| 22 | asm("%0 = CYCLES;" : "=r" (cycles)); |
| 23 | mac_addr[i] = cycles ^ s[i]; |
| 24 | } |
| 25 | mac_addr[0] = (mac_addr[0] | 0x02) & ~0x01; /* make it local unicast */ |
| 26 | } |
| 27 | |
| 28 | #endif |