2 * Copyright (c) 2003 VIA Networking, Inc. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 * ETHbyGetHashIndexByCrc32 - Caculate multicast hash value by CRC32
29 * ETHbIsBufferCrc32Ok - Check CRC value of the buffer if Ok or not
35 #if !defined(__DEVICE_H__)
38 #if !defined(__TMACRO_H__)
41 #if !defined(__TBIT_H__)
44 #if !defined(__TCRC_H__)
47 #if !defined(__TETHER_H__)
54 /*--------------------- Static Definitions -------------------------*/
56 /*--------------------- Static Classes ----------------------------*/
58 /*--------------------- Static Variables --------------------------*/
60 /*--------------------- Static Functions --------------------------*/
62 /*--------------------- Export Variables --------------------------*/
67 * Description: Caculate multicast hash value by CRC32
71 * pbyMultiAddr - Multicast Address
75 * Return Value: Hash value
78 BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr)
84 // get the least 6-bits from CRC generator
85 byTmpHash = (BYTE)(CRCdwCrc32(pbyMultiAddr, U_ETHER_ADDR_LEN,
87 // reverse most bit to least bit
88 for (ii = 0; ii < (sizeof(byTmpHash) * 8); ii++) {
90 if (BITbIsBitOn(byTmpHash, 0x01))
95 // adjust 6-bits to the right most
101 * Description: Check CRC value of the buffer if Ok or not
105 * pbyBuffer - pointer of buffer (normally is rx buffer)
106 * cbFrameLength - length of buffer, including CRC portion
110 * Return Value: TRUE if ok; FALSE if error.
113 BOOL ETHbIsBufferCrc32Ok (PBYTE pbyBuffer, UINT cbFrameLength)
117 dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4);
118 if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) {