add support for board specific vlan matrix, should fix #2132
authorGabor Juhos <juhosg@openwrt.org>
Wed, 1 Aug 2007 16:54:51 +0000 (16:54 +0000)
committerGabor Juhos <juhosg@openwrt.org>
Wed, 1 Aug 2007 16:54:51 +0000 (16:54 +0000)
SVN-Revision: 8309

12 files changed:
target/linux/adm5120-2.6/files/arch/mips/adm5120/board.c
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/cellvision.c
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/compex.c
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/edimax.c
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/generic.c
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/infineon.c
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/mikrotik.c
target/linux/adm5120-2.6/files/arch/mips/adm5120/boards/zyxel.c
target/linux/adm5120-2.6/files/arch/mips/adm5120/platform.c
target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c
target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_board.h
target/linux/adm5120-2.6/files/include/asm-mips/mach-adm5120/adm5120_info.h

index 17b88c00110f64114f6029eb20a8790a5aa3bb1b..f106009527b13eb5e95a73eaa4d61c48a42733f5 100644 (file)
@@ -82,8 +82,13 @@ static int __init adm5120_board_setup(void)
        memcpy(&adm5120_board_name, board->name, ADM5120_BOARD_NAMELEN);
 
        adm5120_board_reset = board->board_reset;
-       if (board->num_eth_ports > 0)
-               adm5120_eth_num_ports = board->num_eth_ports;
+       if (board->eth_num_ports > 0)
+               adm5120_eth_num_ports = board->eth_num_ports;
+
+       if (board->eth_vlans)
+               memcpy(adm5120_eth_vlans, board->eth_vlans,
+                       sizeof(adm5120_eth_vlans));
+
 
        if (board->board_setup)
                board->board_setup();
index fa82b93a111c995c1bb652f4ff457fc26e5ce4fd..40e2acfbc7aee2bdd6679fde05c08f00e89c403c 100644 (file)
@@ -128,7 +128,7 @@ static struct adm5120_board cas630_board __initdata = {
        .mach_type      = MACH_ADM5120_CAS630,
        .name           = "Cellvision CAS-630/630W",
        .board_setup    = cas6xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
        .num_devices    = ARRAY_SIZE(cas6xx_devices),
        .devices        = cas6xx_devices,
 };
@@ -137,7 +137,7 @@ static struct adm5120_board cas670_board __initdata = {
        .mach_type      = MACH_ADM5120_CAS670,
        .name           = "Cellvision CAS-670/670W",
        .board_setup    = cas6xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
        .num_devices    = ARRAY_SIZE(cas6xx_devices),
        .devices        = cas6xx_devices,
 };
@@ -146,7 +146,7 @@ static struct adm5120_board cas700_board __initdata = {
        .mach_type      = MACH_ADM5120_CAS700,
        .name           = "Cellvision CAS-700/700W",
        .board_setup    = cas7xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
        .num_devices    = ARRAY_SIZE(cas7xx_devices),
        .devices        = cas7xx_devices,
 };
@@ -155,7 +155,7 @@ static struct adm5120_board cas771_board __initdata = {
        .mach_type      = MACH_ADM5120_CAS771,
        .name           = "Cellvision CAS-771/771W",
        .board_setup    = cas7xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
        .num_devices    = ARRAY_SIZE(cas7xx_devices),
        .devices        = cas7xx_devices,
 };
@@ -164,7 +164,7 @@ static struct adm5120_board cas790_board __initdata = {
        .mach_type      = MACH_ADM5120_CAS790,
        .name           = "Cellvision CAS-790",
        .board_setup    = cas7xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
        .num_devices    = ARRAY_SIZE(cas7xx_devices),
        .devices        = cas7xx_devices,
 };
@@ -173,7 +173,7 @@ static struct adm5120_board cas861_board __initdata = {
        .mach_type      = MACH_ADM5120_CAS861,
        .name           = "Cellvision CAS-861/861W",
        .board_setup    = cas7xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
        .num_devices    = ARRAY_SIZE(cas7xx_devices),
        .devices        = cas7xx_devices,
 };
index 7a48cb04c568ddcc9d4f2dc93b31354fb7ecf903..a59e08f4348b18fe68453e34d0d12d59f30459ab 100644 (file)
@@ -117,11 +117,27 @@ static void __init wp54_wrt_setup(void)
        /* TODO: setup mac address */
 }
 
+unsigned char np27g_vlans[6] __initdata = {
+       /* FIXME: untested */
+       0x41, 0x42, 0x44, 0x48, 0x50, 0x00
+};
+
+unsigned char np28g_vlans[6] __initdata = {
+       /* FIXME: untested */
+       0x41, 0x42, 0x44, 0x48, 0x00, 0x00
+};
+
+unsigned char wp54_vlans[6] __initdata = {
+       /* FIXME: untested */
+       0x41, 0x42, 0x00, 0x00, 0x00, 0x00
+};
+
 static struct adm5120_board np27g_board __initdata = {
        .mach_type      = MACH_ADM5120_NP27G,
        .name           = "Compex NetPassage 27G",
        .board_setup    = np2xg_setup,
-       .num_eth_ports  = 4,
+       .eth_num_ports  = 5,
+       .eth_vlans      = np27g_vlans,
        .num_devices    = ARRAY_SIZE(np2xg_devices),
        .devices        = np2xg_devices,
 };
@@ -130,7 +146,8 @@ static struct adm5120_board np28g_board __initdata = {
        .mach_type      = MACH_ADM5120_NP28G,
        .name           = "Compex NetPassage 28G",
        .board_setup    = np2xg_setup,
-       .num_eth_ports  = 3,
+       .eth_num_ports  = 4,
+       .eth_vlans      = np28g_vlans,
        .num_devices    = ARRAY_SIZE(np2xg_devices),
        .devices        = np2xg_devices,
 };
@@ -140,7 +157,8 @@ static struct adm5120_board wp54ag_board __initdata = {
        .name           = "Compex WP54AG",
        .board_setup    = wp54_setup,
        .board_reset    = wp54_reset,
-       .num_eth_ports  = 2,
+       .eth_num_ports  = 2,
+       .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
 };
@@ -150,7 +168,8 @@ static struct adm5120_board wp54g_board __initdata = {
        .name           = "Compex WP54G",
        .board_setup    = wp54_setup,
        .board_reset    = wp54_reset,
-       .num_eth_ports  = 2,
+       .eth_num_ports  = 2,
+       .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
 };
@@ -160,7 +179,8 @@ static struct adm5120_board wp54g_wrt_board __initdata = {
        .name           = "Compex WP54G-WRT",
        .board_setup    = wp54_wrt_setup,
        .board_reset    = wp54_reset,
-       .num_eth_ports  = 2,
+       .eth_num_ports  = 2,
+       .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
 };
@@ -170,7 +190,8 @@ static struct adm5120_board wpp54ag_board __initdata = {
        .name           = "Compex WPP54AG",
        .board_setup    = wp54_setup,
        .board_reset    = wp54_reset,
-       .num_eth_ports  = 2,
+       .eth_num_ports  = 2,
+       .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
 };
@@ -180,7 +201,8 @@ static struct adm5120_board wpp54g_board __initdata = {
        .name           = "Compex WPP54G",
        .board_setup    = wp54_setup,
        .board_reset    = wp54_reset,
-       .num_eth_ports  = 2,
+       .eth_num_ports  = 2,
+       .eth_vlans      = wp54_vlans,
        .num_devices    = ARRAY_SIZE(wp54_devices),
        .devices        = wp54_devices,
 };
index f39d5c763d3fa9539953658d2ca57c1369281e5a..30efdf553d37a8b8887a776c856043399d077066 100644 (file)
@@ -61,11 +61,16 @@ static void __init br6104k_setup(void) {
        /* TODO: setup mac addresses, if possible */
 }
 
+unsigned char br6104k_vlans[6] = {
+       0x41, 0x42, 0x44, 0x48, 0x50, 0x00
+};
+
 static struct adm5120_board br6104k_board __initdata = {
        .mach_type      = MACH_ADM5120_BR6104K,
        .name           = "Edimax BR-6104K",
        .board_setup    = br6104k_setup,
-       .num_eth_ports  = 5,
+       .eth_num_ports  = 5,
+       .eth_vlans      = br6104k_vlans,
        .num_devices    = ARRAY_SIZE(br6104k_devices),
        .devices        = br6104k_devices,
 };
index 8d795a88168950b4fd03b913e3d68fdb681844e4..78a8f557b5b4c016d336bcbb82c9a2d89f727e1f 100644 (file)
@@ -39,7 +39,7 @@ static struct platform_device *generic_devices[] __initdata = {
 static struct adm5120_board generic_board __initdata = {
        .mach_type      = MACH_ADM5120_GENERIC,
        .name           = "Generic ADM5120 board",
-       .num_eth_ports  = 6,
+       .eth_num_ports  = 6,
        .num_devices    = ARRAY_SIZE(generic_devices),
        .devices        = generic_devices,
 };
index e1426cca9d932309af602b6a42946d0124a113c6..6873ac0b4edcdd07e63dcf4261918455ed8f332d 100644 (file)
@@ -123,7 +123,7 @@ static struct adm5120_board easy5120pata_board __initdata = {
        .mach_type      = MACH_ADM5120_EASY5120PATA,
        .name           = "Infineon EASY 5120P-ATA Reference Board",
        .board_setup    = easy_setup_pqfp,
-       .num_eth_ports  = 6,
+       .eth_num_ports  = 6,
        .num_devices    = ARRAY_SIZE(easy5120pata_devices),
        .devices        = easy5120pata_devices,
 };
@@ -132,7 +132,7 @@ static struct adm5120_board easy5120rt_board __initdata = {
        .mach_type      = MACH_ADM5120_EASY5120RT,
        .name           = "Infineon EASY 5120-RT Reference Board",
        .board_setup    = easy_setup_bga,
-       .num_eth_ports  = 5,
+       .eth_num_ports  = 5,
        .num_devices    = ARRAY_SIZE(easy5120rt_devices),
        .devices        = easy5120rt_devices,
 };
@@ -141,7 +141,7 @@ static struct adm5120_board easy5120wvoip_board __initdata = {
        .mach_type      = MACH_ADM5120_EASY5120WVOIP,
        .name           = "Infineon EASY 5120-WVoIP Reference Board",
        .board_setup    = easy_setup_bga,
-       .num_eth_ports  = 6,
+       .eth_num_ports  = 6,
        .num_devices    = ARRAY_SIZE(easy5120wvoip_devices),
        .devices        = easy5120wvoip_devices,
 };
@@ -150,7 +150,7 @@ static struct adm5120_board easy83000_board __initdata = {
        .mach_type      = MACH_ADM5120_EASY83000,
        .name           = "Infineon EASY 83000 Reference Board",
        .board_setup    = easy_setup_pqfp,
-       .num_eth_ports  = 6,
+       .eth_num_ports  = 6,
        .num_devices    = ARRAY_SIZE(easy83000_devices),
        .devices        = easy83000_devices,
 };
index fccb284d6c2c0371f292dbdf59494961d4d8cdfa..c1b203f7cca843a3088d1000a34f1422d1b54dc0 100644 (file)
@@ -59,11 +59,32 @@ static void __init rb1xx_setup(void)
        /* TODO: setup mac address */
 }
 
+static unsigned char rb11x_vlans[6] __initdata = {
+       /* FIXME: untested */
+       0x41, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static unsigned char rb133_vlans[6] __initdata = {
+       /* FIXME: untested */
+       0x41, 0x42, 0x44, 0x00, 0x00, 0x00
+};
+
+static unsigned char rb133c_vlans[6] __initdata = {
+       /* FIXME: untested */
+       0x44, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+static unsigned char rb153_vlans[6] __initdata = {
+       /* FIXME: untested */
+       0x41, 0x42, 0x44, 0x48, 0x50, 0x00
+};
+
 static struct adm5120_board rb111_board __initdata = {
        .mach_type      = MACH_ADM5120_RB_111,
        .name           = "Mikrotik RouterBOARD 111",
        .board_setup    = rb1xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
+       .eth_vlans      = rb11x_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
 };
@@ -72,7 +93,8 @@ static struct adm5120_board rb112_board __initdata = {
        .mach_type      = MACH_ADM5120_RB_112,
        .name           = "Mikrotik RouterBOARD 112",
        .board_setup    = rb1xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
+       .eth_vlans      = rb11x_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
 };
@@ -81,7 +103,8 @@ static struct adm5120_board rb133_board __initdata = {
        .mach_type      = MACH_ADM5120_RB_133,
        .name           = "Mikrotik RouterBOARD 133",
        .board_setup    = rb1xx_setup,
-       .num_eth_ports  = 3,
+       .eth_num_ports  = 3,
+       .eth_vlans      = rb133_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
 };
@@ -90,7 +113,8 @@ static struct adm5120_board rb133c_board __initdata = {
        .mach_type      = MACH_ADM5120_RB_133C,
        .name           = "Mikrotik RouterBOARD 133C",
        .board_setup    = rb1xx_setup,
-       .num_eth_ports  = 1,
+       .eth_num_ports  = 1,
+       .eth_vlans      = rb133c_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
 };
@@ -99,7 +123,8 @@ static struct adm5120_board rb153_board __initdata = {
        .mach_type      = MACH_ADM5120_RB_153,
        .name           = "Mikrotik RouterBOARD 153",
        .board_setup    = rb1xx_setup,
-       .num_eth_ports  = 5,
+       .eth_num_ports  = 5,
+       .eth_vlans      = rb153_vlans,
        .num_devices    = ARRAY_SIZE(rb1xx_devices),
        .devices        = rb1xx_devices,
 };
index f6cdc8af4a0dbffe9e1898f918e3f8993fb26e20..25e5a319bead5f4d6bb489397ca20a30a38d90da 100644 (file)
@@ -55,9 +55,18 @@ static struct mtd_partition p33x_partitions[] = {
                .offset = MTDPART_OFS_APPEND,
                .size   = 16*1024,
        } , {
-               .name   = "firmware",
+               .name   = "bootext",
+               .offset = MTDPART_OFS_APPEND,
+               .size   = 96*1024,
+               .mask_flags = MTD_WRITEABLE,
+       } , {
+               .name   = "trx",
                .offset = MTDPART_OFS_APPEND,
                .size   = MTDPART_SIZ_FULL,
+       } , {
+               .name   = "firmware",
+               .offset = 32*1024,
+               .size   = MTDPART_SIZ_FULL,
        }
 };
 
@@ -83,10 +92,17 @@ static void __init p33x_setup(void)
        /* TODO: setup mac address */
 }
 
+unsigned char p33x_vlans[6] __initdata = {
+       /* FIXME: untested */
+       0x50, 0x48, 0x44, 0x42, 0x41, 0x00
+};
+
 static struct adm5120_board p334wt_board __initdata = {
        .mach_type      = MACH_ADM5120_P334WT,
        .name           = "ZyXEL Prestige 334WT",
        .board_setup    = p33x_setup,
+       .eth_num_ports  = 5,
+       .eth_vlans      = p33x_vlans,
        .num_devices    = ARRAY_SIZE(p334_devices),
        .devices        = p334_devices,
 };
@@ -95,6 +111,8 @@ static struct adm5120_board p335_board __initdata = {
        .mach_type      = MACH_ADM5120_P335,
        .name           = "ZyXEL Prestige 335/335WT",
        .board_setup    = p33x_setup,
+       .eth_num_ports  = 5,
+       .eth_vlans      = p33x_vlans,
        .num_devices    = ARRAY_SIZE(p335_devices),
        .devices        = p335_devices,
 };
index 723f27fe703f4293f5feeb3734e6ead4e4480ad5..e3d05136056720b8f5d7b07c63c740f442eed422 100644 (file)
@@ -47,6 +47,8 @@ static void adm5120_uart_set_mctrl(struct amba_device *dev, void __iomem *base,
  *     converted into a real platform driver
  */
 unsigned int adm5120_eth_num_ports = 6;
+EXPORT_SYMBOL_GPL(adm5120_eth_num_ports);
+
 unsigned char adm5120_eth_macs[6][6] = {
        {'\00', 'A', 'D', 'M', '\x51', '\x20' },
        {'\00', 'A', 'D', 'M', '\x51', '\x21' },
@@ -55,9 +57,13 @@ unsigned char adm5120_eth_macs[6][6] = {
        {'\00', 'A', 'D', 'M', '\x51', '\x24' },
        {'\00', 'A', 'D', 'M', '\x51', '\x25' }
 };
-
-EXPORT_SYMBOL_GPL(adm5120_eth_num_ports);
 EXPORT_SYMBOL_GPL(adm5120_eth_macs);
+
+unsigned char adm5120_eth_vlans[6] = {
+       0x41, 0x42, 0x44, 0x48, 0x50, 0x60
+};
+EXPORT_SYMBOL_GPL(adm5120_eth_vlans);
+
 #else
 /* Built-in ethernet switch */
 struct adm5120_switch_platform_data adm5120_switch_data;
index 2714577c8e5873b6a4432ab2e71042ec9f6c085a..80c81abf7430e5f1172fa478c046717ebc384123 100644 (file)
@@ -33,19 +33,6 @@ MODULE_AUTHOR("Jeroen Vreeken (pe1rxq@amsat.org)");
 MODULE_DESCRIPTION("ADM5120 ethernet switch driver");
 MODULE_LICENSE("GPL");
 
-/*
- *     The ADM5120 uses an internal matrix to determine which ports
- *     belong to which VLAN.
- *     The default generates a VLAN (and device) for each port
- *     (including MII port) and the CPU port is part of all of them.
- *
- *     Another example, one big switch and everything mapped to eth0:
- *     0x7f, 0x00, 0x00, 0x00, 0x00, 0x00
- */
-static unsigned char vlan_matrix[SW_DEVS] = {
-       0x41, 0x42, 0x44, 0x48, 0x50, 0x60
-};
-
 /* default settings - unlimited TX and RX on all ports, default shaper mode */
 static unsigned char bw_matrix[SW_DEVS] = {
        0, 0, 0, 0, 0, 0
@@ -274,7 +261,7 @@ static int adm5120_sw_open(struct net_device *dev)
        val = adm5120_get_reg(ADM5120_PORT_CONF0);
        for (i=0; i<SW_DEVS; i++) {
                if (dev == adm5120_devs[i])
-                       val &= ~vlan_matrix[i];
+                       val &= ~adm5120_eth_vlans[i];
        }
        adm5120_set_reg(ADM5120_PORT_CONF0, val);
        return 0;
@@ -292,7 +279,7 @@ static int adm5120_sw_stop(struct net_device *dev)
        val = adm5120_get_reg(ADM5120_PORT_CONF0) | ADM5120_PORTDISALL;
        for (i=0; i<SW_DEVS; i++) {
                if ((dev != adm5120_devs[i]) && netif_running(adm5120_devs[i]))
-                       val &= ~vlan_matrix[i];
+                       val &= ~adm5120_eth_vlans[i];
        }
        adm5120_set_reg(ADM5120_PORT_CONF0, val);
        netif_stop_queue(dev);
@@ -351,7 +338,7 @@ static struct net_device_stats *adm5120_sw_stats(struct net_device *dev)
        int portmask;
        unsigned long adm5120_cpup_conf_reg;
 
-       portmask = vlan_matrix[priv->port] & 0x3f;
+       portmask = adm5120_eth_vlans[priv->port] & 0x3f;
 
        adm5120_cpup_conf_reg = adm5120_get_reg(ADM5120_CPUP_CONF);
 
@@ -398,7 +385,7 @@ static void adm5120_set_multicast_list(struct net_device *dev)
        struct adm5120_sw *priv = netdev_priv(dev);
        int portmask;
 
-       portmask = vlan_matrix[priv->port] & 0x3f;
+       portmask = adm5120_eth_vlans[priv->port] & 0x3f;
 
        if (dev->flags & IFF_PROMISC)
                adm5120_set_reg(ADM5120_CPUP_CONF,
@@ -460,15 +447,15 @@ static int adm5120_do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
                case SIOCSMATRIX:
                        if (!capable(CAP_NET_ADMIN))
                                return -EPERM;
-                       err = copy_from_user(vlan_matrix, rq->ifr_data,
-                           sizeof(vlan_matrix));
+                       err = copy_from_user(adm5120_eth_vlans, rq->ifr_data,
+                           sizeof(adm5120_eth_vlans));
                        if (err)
                                return -EFAULT;
-                       adm5120_set_vlan(vlan_matrix);
+                       adm5120_set_vlan(adm5120_eth_vlans);
                        break;
                case SIOCGMATRIX:
-                       err = copy_to_user(rq->ifr_data, vlan_matrix,
-                           sizeof(vlan_matrix));
+                       err = copy_to_user(rq->ifr_data, adm5120_eth_vlans,
+                           sizeof(adm5120_eth_vlans));
                        if (err)
                                return -EFAULT;
                        break;
@@ -592,7 +579,7 @@ static int __init adm5120_sw_init(void)
                printk(KERN_INFO "%s: ADM5120 switch port%d\n", dev->name, i);
        }
        /* setup vlan/port mapping after devs are filled up */
-       adm5120_set_vlan(vlan_matrix);
+       adm5120_set_vlan(adm5120_eth_vlans);
 
        adm5120_set_reg(ADM5120_CPUP_CONF,
            ADM5120_CRC_PADDING | ADM5120_DISUNALL | ADM5120_DISMCALL);
index 80ace78654eb07aa1f66d3049ea165780ece7c01..7e95ecad4af76e66e6379777b50fb1220cccd476 100644 (file)
@@ -37,7 +37,8 @@ struct adm5120_board {
        void                    (*board_setup)(void);
        void                    (*board_reset)(void);
 
-       unsigned int            num_eth_ports;
+       unsigned int            eth_num_ports;
+       unsigned char           *eth_vlans;
        unsigned int            num_devices;
        struct platform_device  **devices;
 
index bf00e8bd2b8615f45f1fad36a0f647929b77f2c9..9f939876d523ae1876ae271ab318ea67b9fc5478 100644 (file)
@@ -56,6 +56,7 @@ extern unsigned long adm5120_memsize;
  */
 extern unsigned int adm5120_eth_num_ports;
 extern unsigned char adm5120_eth_macs[6][6];
+extern unsigned char adm5120_eth_vlans[6];
 
 extern void adm5120_soc_init(void) __init;
 extern void adm5120_mem_init(void) __init;