Assign mac addresses to each pci/pcie device and avoid getting new ones.

Signed-off-by: Jonas Gorski <jonas.gor...@gmail.com>
Signed-off-by: Álvaro Fernández Rojas <nolt...@gmail.com>

Index: target/linux/brcm63xx/patches-3.3/900-bcm63xx_nvram_sprom_mac.patch
===================================================================
--- target/linux/brcm63xx/patches-3.3/900-bcm63xx_nvram_sprom_mac.patch 
(revisión: 0)
+++ target/linux/brcm63xx/patches-3.3/900-bcm63xx_nvram_sprom_mac.patch 
(revisión: 0)
@@ -0,0 +1,68 @@
+--- a/arch/mips/bcm63xx/nvram.c
++++ b/arch/mips/bcm63xx/nvram.c
+@@ -93,6 +93,45 @@ int bcm63xx_nvram_get_mac_address(u8 *ma
+ }
+ EXPORT_SYMBOL(bcm63xx_nvram_get_mac_address);
+
++static int num_sproms;
++static struct pci_sprom wifi_sproms[NVRAM_MAX_SPROMS];
++
++int bcm63xx_nvram_get_sprom_mac_address(int bus, int slot, u8 *mac)
++{
++      int i;
++      struct pci_sprom *sprom = NULL;
++
++      for (i = 0; i < num_sproms; i++) {
++              if (wifi_sproms[i].bus == bus && wifi_sproms[i].slot == slot) {
++                      *sprom = &wifi_sproms[i];
++                      break;
++              }
++      }
++
++      if (!sprom) {
++              if (num_sproms == NVRAM_MAX_SPROMS) {
++                      pr_err("exceeded number of sproms\n");
++                      return -EINVAL;
++              }
++
++              sprom = &wifi_sprom[num_sproms];
++
++              if (bcm63xx_nvram_get_mac_address(sprom->macaddr)) {
++                      pr_err("unable to get mac address\n");
++                      return -EINVAL;
++              }
++
++              sprom->bus = bus;
++              sprom->slot = slot;
++              num_sproms++;
++      }
++
++      memcpy(mac, sprom->macaddr, ETH_ALEN);
++
++      return 0;
++}
++EXPORT_SYMBOL(bcm63xx_nvram_get_sprom_mac_address);
++
+ int bcm63xx_nvram_get_psi_size(void)
+ {
+       if (nvram.psi_size > 0)
+--- a/arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h
++++ b/arch/mips/include/asm/mach-bcm63xx/bcm63xx_nvram.h
+@@ -33,4 +33,17 @@ int bcm63xx_nvram_get_mac_address(u8 *ma
+
+ int bcm63xx_nvram_get_psi_size(void);
+
++/*
++ * SPROM MAC Addresses
++ */
++#define NVRAM_MAX_SPROMS 2
++
++struct pci_sprom {
++      int bus;
++      int slot;
++      u8 macaddr[ETH_ALEN];
++};
++
++int bcm63xx_nvram_get_sprom_mac_address(int bus, int slot, u8 *mac);
++
+ #endif /* BCM63XX_NVRAM_H */

_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to