From 7a4fa1b0a7cedac12015168572aed39f263e2964 Mon Sep 17 00:00:00 2001 From: Hauke Mehrtens Date: Thu, 31 Jul 2014 21:42:59 +0000 Subject: brcm47xx: 3.14: update MIPS patches with versions sent upstream MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rafał Miłecki git-svn-id: svn://svn.openwrt.org/openwrt/trunk@41911 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- ...M47XX-fixup-broken-MAC-addresses-in-nvram.patch | 95 ++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 target/linux/brcm47xx/patches-3.14/145-MIPS-BCM47XX-fixup-broken-MAC-addresses-in-nvram.patch (limited to 'target/linux/brcm47xx/patches-3.14/145-MIPS-BCM47XX-fixup-broken-MAC-addresses-in-nvram.patch') diff --git a/target/linux/brcm47xx/patches-3.14/145-MIPS-BCM47XX-fixup-broken-MAC-addresses-in-nvram.patch b/target/linux/brcm47xx/patches-3.14/145-MIPS-BCM47XX-fixup-broken-MAC-addresses-in-nvram.patch new file mode 100644 index 0000000000..3e99a3b09a --- /dev/null +++ b/target/linux/brcm47xx/patches-3.14/145-MIPS-BCM47XX-fixup-broken-MAC-addresses-in-nvram.patch @@ -0,0 +1,95 @@ +From 103c0bf3ff46486466bc9138d70c25133d516003 Mon Sep 17 00:00:00 2001 +From: Hauke Mehrtens +Date: Tue, 29 Jul 2014 00:08:01 +0200 +Subject: [PATCH] MIPS: BCM47XX: fixup broken MAC addresses in nvram + +The address prefix 00:90:4C is used by Broadcom in their initial +configuration. When a mac address with the prefix 00:90:4C is used all +devices from the same series are sharing the same mac address. To +prevent mac address collisions we replace them with a mac address based +on the base address. To generate such addresses we take the main mac +address from et0macaddr and increase it by two for the first wifi +device and by 3 for the second one. This matches the printed mac +address on the device. The main mac address increased by one is used as +wan address by the vendor code. + +Signed-off-by: Hauke Mehrtens +Cc: zajec5@gmail.com +Cc: linux-mips@linux-mips.org +Patchwork: https://patchwork.linux-mips.org/patch/7489/ +Signed-off-by: Ralf Baechle +--- + arch/mips/bcm47xx/sprom.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 48 insertions(+) + +--- a/arch/mips/bcm47xx/sprom.c ++++ b/arch/mips/bcm47xx/sprom.c +@@ -28,6 +28,8 @@ + + #include + #include ++#include ++#include + + static void create_key(const char *prefix, const char *postfix, + const char *name, char *buf, int len) +@@ -631,6 +633,33 @@ static void bcm47xx_fill_sprom_path_r45( + } + } + ++static bool bcm47xx_is_valid_mac(u8 *mac) ++{ ++ return mac && !(mac[0] == 0x00 && mac[1] == 0x90 && mac[2] == 0x4c); ++} ++ ++static int bcm47xx_increase_mac_addr(u8 *mac, u8 num) ++{ ++ u8 *oui = mac + ETH_ALEN/2 - 1; ++ u8 *p = mac + ETH_ALEN - 1; ++ ++ do { ++ (*p) += num; ++ if (*p > num) ++ break; ++ p--; ++ num = 1; ++ } while (p != oui); ++ ++ if (p == oui) { ++ pr_err("unable to fetch mac address\n"); ++ return -ENOENT; ++ } ++ return 0; ++} ++ ++static int mac_addr_used = 2; ++ + static void bcm47xx_fill_sprom_ethernet(struct ssb_sprom *sprom, + const char *prefix, bool fallback) + { +@@ -648,6 +677,25 @@ static void bcm47xx_fill_sprom_ethernet( + + nvram_read_macaddr(prefix, "macaddr", sprom->il0mac, fallback); + nvram_read_macaddr(prefix, "il0macaddr", sprom->il0mac, fallback); ++ ++ /* The address prefix 00:90:4C is used by Broadcom in their initial ++ configuration. When a mac address with the prefix 00:90:4C is used ++ all devices from the same series are sharing the same mac address. ++ To prevent mac address collisions we replace them with a mac address ++ based on the base address. */ ++ if (!bcm47xx_is_valid_mac(sprom->il0mac)) { ++ u8 mac[6]; ++ ++ nvram_read_macaddr(NULL, "et0macaddr", mac, false); ++ if (bcm47xx_is_valid_mac(mac)) { ++ int err = bcm47xx_increase_mac_addr(mac, mac_addr_used); ++ ++ if (!err) { ++ ether_addr_copy(sprom->il0mac, mac); ++ mac_addr_used++; ++ } ++ } ++ } + } + + static void bcm47xx_fill_board_data(struct ssb_sprom *sprom, const char *prefix, -- cgit v1.2.3