1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2024-12-22 15:06:46 +02:00
openwrt-xburst/target/linux/pxa/patches-2.6.21/015-smc-ether-addr.patch

63 lines
2.0 KiB
Diff
Raw Normal View History

Index: linux-2.6.21.7/drivers/net/smc91x.c
===================================================================
--- linux-2.6.21.7.orig/drivers/net/smc91x.c
+++ linux-2.6.21.7/drivers/net/smc91x.c
@@ -1815,6 +1815,39 @@ static int __init smc_findirq(void __iom
return probe_irq_off(cookie);
}
+static inline unsigned int is_gumstix_oui(u8 *addr)
+{
+ return (addr[0] == 0x00 && addr[1] == 0x15 && addr[2] == 0xC9);
+}
+
+/**
+ * gen_serial_ether_addr - Generate software assigned Ethernet address
+ * based on the system_serial number
+ * @addr: Pointer to a six-byte array containing the Ethernet address
+ *
+ * Generate an Ethernet address (MAC) that is not multicast
+ * and has the local assigned bit set, keyed on the system_serial
+ */
+static inline void gen_serial_ether_addr(u8 *addr)
+{
+ static u8 ether_serial_digit = 0;
+ addr [0] = system_serial_high >> 8;
+ addr [1] = system_serial_high;
+ addr [2] = system_serial_low >> 24;
+ addr [3] = system_serial_low >> 16;
+ addr [4] = system_serial_low >> 8;
+ addr [5] = (system_serial_low & 0xc0) | /* top bits are from system serial */
+ (1 << 4) | /* 2 bits identify interface type 1=ether, 2=usb, 3&4 undef */
+ ((ether_serial_digit++) & 0x0f); /* 15 possible interfaces of each type */
+
+ if(!is_gumstix_oui(addr))
+ {
+ addr [0] &= 0xfe; /* clear multicast bit */
+ addr [0] |= 0x02; /* set local assignment bit (IEEE802) */
+ }
+}
+
+
/*
* Function: smc_probe(unsigned long ioaddr)
*
@@ -2032,15 +2065,13 @@ static int __init smc_probe(struct net_d
THROTTLE_TX_PKTS ? " [throttle_tx]" : "");
if (!is_valid_ether_addr(dev->dev_addr)) {
- printk("%s: Invalid ethernet MAC address. Please "
- "set using ifconfig\n", dev->name);
- } else {
+ gen_serial_ether_addr(dev->dev_addr);
+ }
/* Print the Ethernet address */
printk("%s: Ethernet addr: ", dev->name);
for (i = 0; i < 5; i++)
printk("%2.2x:", dev->dev_addr[i]);
printk("%2.2x\n", dev->dev_addr[5]);
- }
if (lp->phy_type == 0) {
PRINTK("%s: No PHY found\n", dev->name);