X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/72f8c837fe5c73aabba91d7be62279cf9f094808..a5e3f9b1977f4bfe24df52c2522549f911642d27:/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c diff --git a/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c b/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c index 83a311fb9..80c81abf7 100644 --- a/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c +++ b/target/linux/adm5120-2.6/files/drivers/net/adm5120sw.c @@ -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 @@ -262,7 +249,7 @@ static int adm5120_sw_open(struct net_device *dev) { unsigned long val; int i; - + netif_start_queue(dev); if (!adm5120_if_open++) { /* enable interrupts on first open */ @@ -274,7 +261,7 @@ static int adm5120_sw_open(struct net_device *dev) val = adm5120_get_reg(ADM5120_PORT_CONF0); for (i=0; istatus = ((skb->lenlen) << ADM5120_DMA_LENSHIFT) | (0x1 << priv->port); - + dma->len = skb->len < ETH_ZLEN ? ETH_ZLEN : skb->len; priv->stats.tx_packets++; priv->stats.tx_bytes += skb->len; @@ -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; @@ -537,6 +524,9 @@ static int __init adm5120_sw_init(void) adm5120_set_reg(ADM5120_PHY_CNTL3, adm5120_get_reg(ADM5120_PHY_CNTL3) | ADM5120_PHY_NTH); + /* Force all the packets from all ports are low priority */ + adm5120_set_reg(ADM5120_PRI_CNTL, 0); + adm5120_set_reg(ADM5120_INT_MASK, ADM5120_INTMASKALL); adm5120_set_reg(ADM5120_INT_ST, ADM5120_INTMASKALL); @@ -554,7 +544,7 @@ static int __init adm5120_sw_init(void) adm5120_set_reg(ADM5120_RECEIVE_HBADDR, KSEG1ADDR(adm5120_dma_rxh)); adm5120_set_reg(ADM5120_RECEIVE_LBADDR, KSEG1ADDR(adm5120_dma_rxl)); - for (i=0; iname, 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); @@ -612,9 +602,9 @@ static void __exit adm5120_sw_exit(void) { int i; - for (i = 0; i < adm5120_nrdevs; i++) { + for (i = 0; i < SW_DEVS; i++) { unregister_netdev(adm5120_devs[i]); - free_netdev(adm5120_devs[i-1]); + free_netdev(adm5120_devs[i]); } free_irq(ADM5120_IRQ_SWITCH, NULL);