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
41 /*--------------------- Static Definitions -------------------------*/
43 /*--------------------- Static Classes ----------------------------*/
45 /*--------------------- Static Variables --------------------------*/
46 static int msglevel
=MSG_LEVEL_INFO
;
47 //static int msglevel =MSG_LEVEL_DEBUG;
48 /*--------------------- Static Functions --------------------------*/
50 /*--------------------- Export Variables --------------------------*/
56 * Relay packet. Return TRUE if packet is copy to DMA1
61 * pbySkbData - rx packet skb data
65 * Return Value: TRUE if packet duplicate; otherwise FALSE
68 BOOL
ROUTEbRelay (PSDevice pDevice
, PBYTE pbySkbData
, UINT uDataLen
, UINT uNodeIndex
)
70 PSMgmtObject pMgmt
= pDevice
->pMgmt
;
71 PSTxDesc pHeadTD
, pLastTD
;
75 BOOL bNeedEncryption
= FALSE
;
77 PSKeyItem pTransmitKey
= NULL
;
85 if (AVAIL_TD(pDevice
, TYPE_AC0DMA
)<=0) {
86 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Relay can't allocate TD1..\n");
90 pHeadTD
= pDevice
->apCurrTD
[TYPE_AC0DMA
];
92 pHeadTD
->m_td1TD1
.byTCR
= (TCR_EDP
|TCR_STP
);
94 memcpy(pDevice
->sTxEthHeader
.abyDstAddr
, (PBYTE
)pbySkbData
, U_HEADER_LEN
);
96 cbFrameBodySize
= uDataLen
- U_HEADER_LEN
;
98 if (ntohs(pDevice
->sTxEthHeader
.wType
) > MAX_DATA_LEN
) {
102 if (pDevice
->bEncryptionEnable
== TRUE
) {
103 bNeedEncryption
= TRUE
;
106 pbyBSSID
= pDevice
->abyBroadcastAddr
;
107 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == FALSE
) {
109 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"KEY is NULL. [%d]\n", pDevice
->pMgmt
->eCurrMode
);
111 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get GTK.\n");
115 if (pDevice
->bEnableHostWEP
) {
116 if (uNodeIndex
>= 0) {
117 pTransmitKey
= &STempKey
;
118 pTransmitKey
->byCipherSuite
= pMgmt
->sNodeDBTable
[uNodeIndex
].byCipherSuite
;
119 pTransmitKey
->dwKeyIndex
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
;
120 pTransmitKey
->uKeyLength
= pMgmt
->sNodeDBTable
[uNodeIndex
].uWepKeyLength
;
121 pTransmitKey
->dwTSC47_16
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
;
122 pTransmitKey
->wTSC15_0
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
;
123 memcpy(pTransmitKey
->abyKey
,
124 &pMgmt
->sNodeDBTable
[uNodeIndex
].abyWepKey
[0],
125 pTransmitKey
->uKeyLength
130 uMACfragNum
= cbGetFragCount(pDevice
, pTransmitKey
, cbFrameBodySize
, &pDevice
->sTxEthHeader
);
132 if (uMACfragNum
> AVAIL_TD(pDevice
,TYPE_AC0DMA
)) {
135 byPktType
= (BYTE
)pDevice
->byPacketType
;
137 if (pDevice
->bFixRate
) {
138 if (pDevice
->eCurrentPHYType
== PHY_TYPE_11B
) {
139 if (pDevice
->uConnectionRate
>= RATE_11M
) {
140 pDevice
->wCurrentRate
= RATE_11M
;
142 pDevice
->wCurrentRate
= (WORD
)pDevice
->uConnectionRate
;
145 if ((pDevice
->eCurrentPHYType
== PHY_TYPE_11A
) &&
146 (pDevice
->uConnectionRate
<= RATE_6M
)) {
147 pDevice
->wCurrentRate
= RATE_6M
;
149 if (pDevice
->uConnectionRate
>= RATE_54M
)
150 pDevice
->wCurrentRate
= RATE_54M
;
152 pDevice
->wCurrentRate
= (WORD
)pDevice
->uConnectionRate
;
157 pDevice
->wCurrentRate
= pDevice
->pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
;
160 if (pDevice
->wCurrentRate
<= RATE_11M
)
161 byPktType
= PK_TYPE_11B
;
163 vGenerateFIFOHeader(pDevice
, byPktType
, pDevice
->pbyTmpBuff
, bNeedEncryption
,
164 cbFrameBodySize
, TYPE_AC0DMA
, pHeadTD
,
165 &pDevice
->sTxEthHeader
, pbySkbData
, pTransmitKey
, uNodeIndex
,
170 if (MACbIsRegBitsOn(pDevice
->PortOffset
, MAC_REG_PSCTL
, PSCTL_PS
)) {
172 MACbPSWakeup(pDevice
->PortOffset
);
175 pDevice
->bPWBitOn
= FALSE
;
178 for (ii
= 0; ii
< uMACfragNum
; ii
++) {
179 // Poll Transmit the adapter
181 pHeadTD
->m_td0TD0
.f1Owner
=OWNED_BY_NIC
;
183 if (ii
== (uMACfragNum
- 1))
185 pHeadTD
= pHeadTD
->next
;
188 pLastTD
->pTDInfo
->skb
= 0;
189 pLastTD
->pTDInfo
->byFlags
= 0;
191 pDevice
->apCurrTD
[TYPE_AC0DMA
] = pHeadTD
;
193 MACvTransmitAC0(pDevice
->PortOffset
);