2020#include <linux/init.h>
2121#include <linux/spinlock.h>
2222#include <linux/crc32.h>
23- #include <linux/crc32poly.h>
2423#include <linux/bitrev.h>
2524#include <linux/ethtool.h>
2625#include <linux/slab.h>
@@ -796,59 +795,6 @@ static irqreturn_t bmac_txdma_intr(int irq, void *dev_id)
796795}
797796
798797#ifndef SUNHME_MULTICAST
799- /* Real fast bit-reversal algorithm, 6-bit values */
800- static int reverse6 [64 ] = {
801- 0x0 ,0x20 ,0x10 ,0x30 ,0x8 ,0x28 ,0x18 ,0x38 ,
802- 0x4 ,0x24 ,0x14 ,0x34 ,0xc ,0x2c ,0x1c ,0x3c ,
803- 0x2 ,0x22 ,0x12 ,0x32 ,0xa ,0x2a ,0x1a ,0x3a ,
804- 0x6 ,0x26 ,0x16 ,0x36 ,0xe ,0x2e ,0x1e ,0x3e ,
805- 0x1 ,0x21 ,0x11 ,0x31 ,0x9 ,0x29 ,0x19 ,0x39 ,
806- 0x5 ,0x25 ,0x15 ,0x35 ,0xd ,0x2d ,0x1d ,0x3d ,
807- 0x3 ,0x23 ,0x13 ,0x33 ,0xb ,0x2b ,0x1b ,0x3b ,
808- 0x7 ,0x27 ,0x17 ,0x37 ,0xf ,0x2f ,0x1f ,0x3f
809- };
810-
811- static unsigned int
812- crc416 (unsigned int curval , unsigned short nxtval )
813- {
814- unsigned int counter , cur = curval , next = nxtval ;
815- int high_crc_set , low_data_set ;
816-
817- /* Swap bytes */
818- next = ((next & 0x00FF ) << 8 ) | (next >> 8 );
819-
820- /* Compute bit-by-bit */
821- for (counter = 0 ; counter < 16 ; ++ counter ) {
822- /* is high CRC bit set? */
823- if ((cur & 0x80000000 ) == 0 ) high_crc_set = 0 ;
824- else high_crc_set = 1 ;
825-
826- cur = cur << 1 ;
827-
828- if ((next & 0x0001 ) == 0 ) low_data_set = 0 ;
829- else low_data_set = 1 ;
830-
831- next = next >> 1 ;
832-
833- /* do the XOR */
834- if (high_crc_set ^ low_data_set ) cur = cur ^ CRC32_POLY_BE ;
835- }
836- return cur ;
837- }
838-
839- static unsigned int
840- bmac_crc (unsigned short * address )
841- {
842- unsigned int newcrc ;
843-
844- XXDEBUG (("bmac_crc: addr=%#04x, %#04x, %#04x\n" , * address , address [1 ], address [2 ]));
845- newcrc = crc416 (0xffffffff , * address ); /* address bits 47 - 32 */
846- newcrc = crc416 (newcrc , address [1 ]); /* address bits 31 - 16 */
847- newcrc = crc416 (newcrc , address [2 ]); /* address bits 15 - 0 */
848-
849- return (newcrc );
850- }
851-
852798/*
853799 * Add requested mcast addr to BMac's hash table filter.
854800 *
@@ -861,8 +807,7 @@ bmac_addhash(struct bmac_data *bp, unsigned char *addr)
861807 unsigned short mask ;
862808
863809 if (!(* addr )) return ;
864- crc = bmac_crc ((unsigned short * )addr ) & 0x3f ; /* Big-endian alert! */
865- crc = reverse6 [crc ]; /* Hyperfast bit-reversing algorithm */
810+ crc = crc32 (~0 , addr , ETH_ALEN ) >> 26 ;
866811 if (bp -> hash_use_count [crc ]++ ) return ; /* This bit is already set */
867812 mask = crc % 16 ;
868813 mask = (unsigned char )1 << mask ;
@@ -876,8 +821,7 @@ bmac_removehash(struct bmac_data *bp, unsigned char *addr)
876821 unsigned char mask ;
877822
878823 /* Now, delete the address from the filter copy, as indicated */
879- crc = bmac_crc ((unsigned short * )addr ) & 0x3f ; /* Big-endian alert! */
880- crc = reverse6 [crc ]; /* Hyperfast bit-reversing algorithm */
824+ crc = crc32 (~0 , addr , ETH_ALEN ) >> 26 ;
881825 if (bp -> hash_use_count [crc ] == 0 ) return ; /* That bit wasn't in use! */
882826 if (-- bp -> hash_use_count [crc ]) return ; /* That bit is still in use */
883827 mask = crc % 16 ;
0 commit comments