Staging: vt665x: Clean up include files, Part 2
[linux-2.6/linux-2.6-openrd.git] / drivers / staging / vt6655 / tether.c
blob7268735d01ce0474633793880362bb3312b8a993
1 /*
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.
19 * File: tether.c
21 * Purpose:
23 * Author: Tevin Chen
25 * Date: May 21, 1996
27 * Functions:
28 * ETHbyGetHashIndexByCrc32 - Caculate multicast hash value by CRC32
29 * ETHbIsBufferCrc32Ok - Check CRC value of the buffer if Ok or not
31 * Revision History:
35 #include "device.h"
36 #include "tmacro.h"
37 #include "tbit.h"
38 #include "tcrc.h"
39 #include "tether.h"
41 /*--------------------- Static Definitions -------------------------*/
43 /*--------------------- Static Classes ----------------------------*/
45 /*--------------------- Static Variables --------------------------*/
47 /*--------------------- Static Functions --------------------------*/
49 /*--------------------- Export Variables --------------------------*/
54 * Description: Caculate multicast hash value by CRC32
56 * Parameters:
57 * In:
58 * pbyMultiAddr - Multicast Address
59 * Out:
60 * none
62 * Return Value: Hash value
65 BYTE ETHbyGetHashIndexByCrc32 (PBYTE pbyMultiAddr)
67 int ii;
68 BYTE byTmpHash;
69 BYTE byHash = 0;
71 // get the least 6-bits from CRC generator
72 byTmpHash = (BYTE)(CRCdwCrc32(pbyMultiAddr, U_ETHER_ADDR_LEN,
73 0xFFFFFFFFL) & 0x3F);
74 // reverse most bit to least bit
75 for (ii = 0; ii < (sizeof(byTmpHash) * 8); ii++) {
76 byHash <<= 1;
77 if (BITbIsBitOn(byTmpHash, 0x01))
78 byHash |= 1;
79 byTmpHash >>= 1;
82 // adjust 6-bits to the right most
83 return (byHash >> 2);
88 * Description: Check CRC value of the buffer if Ok or not
90 * Parameters:
91 * In:
92 * pbyBuffer - pointer of buffer (normally is rx buffer)
93 * cbFrameLength - length of buffer, including CRC portion
94 * Out:
95 * none
97 * Return Value: TRUE if ok; FALSE if error.
100 BOOL ETHbIsBufferCrc32Ok (PBYTE pbyBuffer, UINT cbFrameLength)
102 DWORD dwCRC;
104 dwCRC = CRCdwGetCrc32(pbyBuffer, cbFrameLength - 4);
105 if (cpu_to_le32(*((PDWORD)(pbyBuffer + cbFrameLength - 4))) != dwCRC) {
106 return FALSE;
108 return TRUE;