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 & filtering
28 * ROUTEbRelay - Relay packet
41 /*--------------------- Static Definitions -------------------------*/
43 /*--------------------- Static Classes ----------------------------*/
45 /*--------------------- Static Functions --------------------------*/
47 /*--------------------- Export Variables --------------------------*/
51 * Relay packet. Return true if packet is copy to DMA1
56 * pbySkbData - rx packet skb data
60 * Return Value: true if packet duplicate; otherwise false
63 bool ROUTEbRelay(struct vnt_private *pDevice, unsigned char *pbySkbData,
64 unsigned int uDataLen, unsigned int uNodeIndex)
66 PSMgmtObject pMgmt = pDevice->pMgmt;
67 PSTxDesc pHeadTD, pLastTD;
68 unsigned int cbFrameBodySize;
69 unsigned int uMACfragNum;
70 unsigned char byPktType;
71 bool bNeedEncryption = false;
73 PSKeyItem pTransmitKey = NULL;
74 unsigned int cbHeaderSize;
76 unsigned char *pbyBSSID;
78 if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 0) {
79 pr_debug("Relay can't allocate TD1..\n");
83 pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA];
85 pHeadTD->m_td1TD1.byTCR = (TCR_EDP | TCR_STP);
87 memcpy(pDevice->sTxEthHeader.abyDstAddr, pbySkbData, ETH_HLEN);
89 cbFrameBodySize = uDataLen - ETH_HLEN;
91 if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN)
94 if (pDevice->bEncryptionEnable == true) {
95 bNeedEncryption = true;
98 pbyBSSID = pDevice->abyBroadcastAddr;
99 if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID,
100 GROUP_KEY, &pTransmitKey) == false) {
102 pr_debug("KEY is NULL. [%d]\n",
103 pDevice->pMgmt->eCurrMode);
105 pr_debug("Get GTK\n");
109 if (pDevice->bEnableHostWEP) {
110 if (uNodeIndex < MAX_NODE_NUM + 1) {
111 pTransmitKey = &STempKey;
112 pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite;
113 pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex;
114 pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength;
115 pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16;
116 pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0;
117 memcpy(pTransmitKey->abyKey,
118 &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0],
119 pTransmitKey->uKeyLength);
123 uMACfragNum = cbGetFragCount(pDevice, pTransmitKey,
124 cbFrameBodySize, &pDevice->sTxEthHeader);
126 if (uMACfragNum > AVAIL_TD(pDevice, TYPE_AC0DMA))
129 byPktType = pDevice->byPacketType;
131 if (pDevice->bFixRate) {
132 if (pDevice->eCurrentPHYType == PHY_TYPE_11B) {
133 if (pDevice->uConnectionRate >= RATE_11M)
134 pDevice->wCurrentRate = RATE_11M;
136 pDevice->wCurrentRate = pDevice->uConnectionRate;
138 if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) &&
139 (pDevice->uConnectionRate <= RATE_6M)) {
140 pDevice->wCurrentRate = RATE_6M;
142 if (pDevice->uConnectionRate >= RATE_54M)
143 pDevice->wCurrentRate = RATE_54M;
145 pDevice->wCurrentRate = pDevice->uConnectionRate;
149 pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate;
152 if (pDevice->wCurrentRate <= RATE_11M)
153 byPktType = PK_TYPE_11B;
155 vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff,
156 bNeedEncryption, cbFrameBodySize, TYPE_AC0DMA,
157 pHeadTD, &pDevice->sTxEthHeader, pbySkbData,
158 pTransmitKey, uNodeIndex, &uMACfragNum,
161 if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) {
163 MACbPSWakeup(pDevice->PortOffset);
166 pDevice->bPWBitOn = false;
169 for (ii = 0; ii < uMACfragNum; ii++) {
170 // Poll Transmit the adapter
172 pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC;
174 if (ii == (uMACfragNum - 1))
176 pHeadTD = pHeadTD->next;
179 pLastTD->pTDInfo->skb = NULL;
180 pLastTD->pTDInfo->byFlags = 0;
182 pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD;
184 MACvTransmitAC0(pDevice->PortOffset);