2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 * Purpose: handle WMAC frame relay & filterring
28 * ROUTEbRelay - Relay packet
35 #if !defined(__MAC_H__)
38 #if !defined(__TCRC_H__)
41 #if !defined(__RXTX_H__)
44 #if !defined(__WROUTE_H__)
47 #if !defined(__CARD_H__)
50 #if !defined(__BASEBAND_H__)
53 /*--------------------- Static Definitions -------------------------*/
55 /*--------------------- Static Classes ----------------------------*/
57 /*--------------------- Static Variables --------------------------*/
58 static int msglevel =MSG_LEVEL_INFO;
59 //static int msglevel =MSG_LEVEL_DEBUG;
60 /*--------------------- Static Functions --------------------------*/
62 /*--------------------- Export Variables --------------------------*/
68 * Relay packet. Return TRUE if packet is copy to DMA1
73 * pbySkbData - rx packet skb data
77 * Return Value: TRUE if packet duplicate; otherwise FALSE
80 BOOL ROUTEbRelay (PSDevice pDevice, PBYTE pbySkbData, UINT uDataLen, UINT uNodeIndex)
82 PSMgmtObject pMgmt = pDevice->pMgmt;
83 PSTxDesc pHeadTD, pLastTD;
87 BOOL bNeedEncryption = FALSE;
89 PSKeyItem pTransmitKey = NULL;
97 if (AVAIL_TD(pDevice, TYPE_AC0DMA)<=0) {
98 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_INFO "Relay can't allocate TD1..\n");
102 pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA];
104 pHeadTD->m_td1TD1.byTCR = (TCR_EDP|TCR_STP);
106 memcpy(pDevice->sTxEthHeader.abyDstAddr, (PBYTE)pbySkbData, U_HEADER_LEN);
108 cbFrameBodySize = uDataLen - U_HEADER_LEN;
110 if (ntohs(pDevice->sTxEthHeader.wType) > MAX_DATA_LEN) {
111 cbFrameBodySize += 8;
114 if (pDevice->bEncryptionEnable == TRUE) {
115 bNeedEncryption = TRUE;
118 pbyBSSID = pDevice->abyBroadcastAddr;
119 if(KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, GROUP_KEY, &pTransmitKey) == FALSE) {
121 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"KEY is NULL. [%d]\n", pDevice->pMgmt->eCurrMode);
123 DEVICE_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG"Get GTK.\n");
127 if (pDevice->bEnableHostWEP) {
128 if (uNodeIndex >= 0) {
129 pTransmitKey = &STempKey;
130 pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
131 pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
132 pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
133 pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
134 pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
135 memcpy(pTransmitKey->abyKey,
136 &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
137 pTransmitKey->uKeyLength
142 uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, cbFrameBodySize, &pDevice->sTxEthHeader);
144 if (uMACfragNum > AVAIL_TD(pDevice,TYPE_AC0DMA)) {
147 byPktTyp = (BYTE)pDevice->byPacketType;
149 if (pDevice->bFixRate) {
150 if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
151 if (pDevice->uConnectionRate >= RATE_11M) {
152 pDevice->wCurrentRate = RATE_11M;
154 pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
157 if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) &&
158 (pDevice->uConnectionRate <= RATE_6M)) {
159 pDevice->wCurrentRate = RATE_6M;
161 if (pDevice->uConnectionRate >= RATE_54M)
162 pDevice->wCurrentRate = RATE_54M;
164 pDevice->wCurrentRate = (WORD)pDevice->uConnectionRate;
169 pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
172 if (pDevice->wCurrentRate <= RATE_11M)
173 byPktTyp = PK_TYPE_11B;
175 vGenerateFIFOHeader(pDevice, byPktTyp, pDevice->pbyTmpBuff, bNeedEncryption,
176 cbFrameBodySize, TYPE_AC0DMA, pHeadTD,
177 &pDevice->sTxEthHeader, pbySkbData, pTransmitKey, uNodeIndex,
182 if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
184 MACbPSWakeup(pDevice->PortOffset);
187 pDevice->bPWBitOn = FALSE;
190 for (ii = 0; ii < uMACfragNum; ii++) {
191 // Poll Transmit the adapter
193 pHeadTD->m_td0TD0.f1Owner=OWNED_BY_NIC;
195 if (ii == (uMACfragNum - 1))
197 pHeadTD = pHeadTD->next;
200 pLastTD->pTDInfo->skb = 0;
201 pLastTD->pTDInfo->byFlags = 0;
203 pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD;
205 MACvTransmitAC0(pDevice->PortOffset);