Changeset 27876


Ignore:
Timestamp:
2011-08-02T16:13:00+02:00 (7 years ago)
Author:
florian
Message:

[rdc] fix r6040 multicast patch, thanks
nicolas le falher

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/target/linux/rdc/patches-2.6.32/015-r6040_fix_multicast.patch

    r24006 r27876  
    1 The original code does not work well when the number of mulitcast 
    2 address to handle is greater than MCAST_MAX. It only enable promiscous 
    3 mode instead of multicast hash table mode, so the hash table function 
    4 will not be activated and all multicast frames will be recieved in this 
    5 condition. 
    6  
    7 This patch fixes the following issues with the r6040 NIC operating in 
    8 multicast: 
    9  
    10 1) When the IFF_ALLMULTI flag is set, we should write 0xffff to the NIC 
    11 hash table registers to make it process multicast traffic. 
    12  
    13 2) When the number of multicast address to handle is smaller than 
    14 MCAST_MAX, we should use the NIC multicast registers MID1_{L,M,H}. 
    15  
    16 3) The hashing of the address was not correct, due to an invalid 
    17 substraction (15 - (crc & 0x0f)) instead of (crc & 0x0f) and an 
    18 incorrect crc algorithm (ether_crc_le) instead of (ether_crc). 
    19  
    20 4) If necessary, we should set HASH_EN flag in MCR0 to enable multicast 
    21 hash table function. 
    22  
    23  
    24 The version is for net-next-2.6: 
    25  
    26 Reported-by: Marc Leclerc <marc-leclerc@signaturealpha.com> 
    27 Tested-by: Marc Leclerc <marc-leclerc@signaturealpha.com> 
    28 Signed-off-by: Shawn Lin <shawn@dmp.com.tw> 
    29 Signed-off-by: Albert Chen <albert.chen@rdc.com.tw> 
    30 --- 
    311--- a/drivers/net/r6040.c 
    322+++ b/drivers/net/r6040.c 
     
    4010 #define  MAC_RST       0x0001  /* Reset the MAC */ 
    4111 #define MBCR           0x08    /* Bus control */ 
    42 @@ -837,76 +839,88 @@ static void r6040_multicast_list(struct 
     12@@ -837,76 +839,96 @@ 
    4313 { 
    4414        struct r6040_private *lp = netdev_priv(dev); 
     
    4919        struct dev_mc_list *dmi = dev->mc_list; 
    5020        int i; 
     21+       u16 *adrp; 
    5122+       u16 hash_table[4] = { 0 }; 
     23+ 
     24+       spin_lock_irqsave(&lp->lock, flags); 
    5225  
    5326-       /* MAC Address */ 
    54 -       adrp = (u16 *)dev->dev_addr; 
    55 -       iowrite16(adrp[0], ioaddr + MID_0L); 
    56 -       iowrite16(adrp[1], ioaddr + MID_0M); 
    57 -       iowrite16(adrp[2], ioaddr + MID_0H); 
     27+       /* Keep our MAC Address */ 
     28        adrp = (u16 *)dev->dev_addr; 
     29        iowrite16(adrp[0], ioaddr + MID_0L); 
     30        iowrite16(adrp[1], ioaddr + MID_0M); 
     31        iowrite16(adrp[2], ioaddr + MID_0H); 
     32  
     33-       /* Promiscous Mode */ 
     34-       spin_lock_irqsave(&lp->lock, flags); 
    5835- 
    59 -       /* Promiscous Mode */ 
    60         spin_lock_irqsave(&lp->lock, flags); 
    61   
    6236        /* Clear AMCP & PROM bits */ 
    6337-       reg = ioread16(ioaddr) & ~0x0120; 
     
    12498+       else { 
    12599+               u32 crc; 
     100+ 
     101+               lp->mcr0 |= HASH_EN; 
    126102  
    127103-                       if (!(*addrs & 1)) 
    128104-                               continue; 
    129 +               lp->mcr0 |= HASH_EN; 
    130   
    131 -                       crc = ether_crc_le(6, addrs); 
    132 -                       crc >>= 26; 
    133 -                       hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf)); 
    134105+               for (i = 0; i < MCAST_MAX ; i++) { 
    135106+                       iowrite16(0, ioaddr + MID_1L + 8 * i); 
    136107+                       iowrite16(0, ioaddr + MID_1M + 8 * i); 
    137108+                       iowrite16(0, ioaddr + MID_1H + 8 * i); 
    138                 } 
    139 -               /* Fill the MAC hash tables with their values */ 
     109+               } 
    140110+ 
    141111+               /* Build multicast hash table */ 
     
    143113+                       u8 *addrs = dmi->dmi_addr; 
    144114+                       dmi = dmi->next; 
    145 + 
     115  
     116-                       crc = ether_crc_le(6, addrs); 
    146117+                       crc = ether_crc(ETH_ALEN, addrs); 
     118                        crc >>= 26; 
     119-                       hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf)); 
    147120+                       hash_table[crc >> 4] |= 1 << (crc & 0xf); 
    148 +               } 
     121                } 
     122-               /* Fill the MAC hash tables with their values */ 
    149123+       } 
    150124+       iowrite16(lp->mcr0, ioaddr + MCR0); 
Note: See TracChangeset for help on using the changeset viewer.