Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v3.14 192 lines 5.5 kB view raw
1/* 2 * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. 3 * All rights reserved. 4 * 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. 9 * 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. 14 * 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. 18 * 19 * File: wroute.c 20 * 21 * Purpose: handle WMAC frame relay & filtering 22 * 23 * Author: Lyndon Chen 24 * 25 * Date: May 20, 2003 26 * 27 * Functions: 28 * ROUTEbRelay - Relay packet 29 * 30 * Revision History: 31 * 32 */ 33 34#include "mac.h" 35#include "tcrc.h" 36#include "rxtx.h" 37#include "wroute.h" 38#include "card.h" 39#include "baseband.h" 40 41/*--------------------- Static Definitions -------------------------*/ 42 43/*--------------------- Static Classes ----------------------------*/ 44 45/*--------------------- Static Variables --------------------------*/ 46static int msglevel = MSG_LEVEL_INFO; 47//static int msglevel =MSG_LEVEL_DEBUG; 48/*--------------------- Static Functions --------------------------*/ 49 50/*--------------------- Export Variables --------------------------*/ 51 52/* 53 * Description: 54 * Relay packet. Return true if packet is copy to DMA1 55 * 56 * Parameters: 57 * In: 58 * pDevice - 59 * pbySkbData - rx packet skb data 60 * Out: 61 * true, false 62 * 63 * Return Value: true if packet duplicate; otherwise false 64 * 65 */ 66bool ROUTEbRelay(PSDevice pDevice, unsigned char *pbySkbData, 67 unsigned int uDataLen, unsigned int uNodeIndex) 68{ 69 PSMgmtObject pMgmt = pDevice->pMgmt; 70 PSTxDesc pHeadTD, pLastTD; 71 unsigned int cbFrameBodySize; 72 unsigned int uMACfragNum; 73 unsigned char byPktType; 74 bool bNeedEncryption = false; 75 SKeyItem STempKey; 76 PSKeyItem pTransmitKey = NULL; 77 unsigned int cbHeaderSize; 78 unsigned int ii; 79 unsigned char *pbyBSSID; 80 81 if (AVAIL_TD(pDevice, TYPE_AC0DMA) <= 0) { 82 DBG_PRT(MSG_LEVEL_DEBUG, 83 KERN_INFO "Relay can't allocate TD1..\n"); 84 return false; 85 } 86 87 pHeadTD = pDevice->apCurrTD[TYPE_AC0DMA]; 88 89 pHeadTD->m_td1TD1.byTCR = (TCR_EDP | TCR_STP); 90 91 memcpy(pDevice->sTxEthHeader.abyDstAddr, pbySkbData, ETH_HLEN); 92 93 cbFrameBodySize = uDataLen - ETH_HLEN; 94 95 if (ntohs(pDevice->sTxEthHeader.wType) > ETH_DATA_LEN) 96 cbFrameBodySize += 8; 97 98 if (pDevice->bEncryptionEnable == true) { 99 bNeedEncryption = true; 100 101 // get group key 102 pbyBSSID = pDevice->abyBroadcastAddr; 103 if (KeybGetTransmitKey(&(pDevice->sKey), pbyBSSID, 104 GROUP_KEY, &pTransmitKey) == false) { 105 pTransmitKey = NULL; 106 DBG_PRT(MSG_LEVEL_DEBUG, 107 KERN_DEBUG "KEY is NULL. [%d]\n", 108 pDevice->pMgmt->eCurrMode); 109 } else { 110 DBG_PRT(MSG_LEVEL_DEBUG, KERN_DEBUG "Get GTK.\n"); 111 } 112 } 113 114 if (pDevice->bEnableHostWEP) { 115 if (uNodeIndex < MAX_NODE_NUM + 1) { 116 pTransmitKey = &STempKey; 117 pTransmitKey->byCipherSuite = pMgmt->sNodeDBTable[uNodeIndex].byCipherSuite; 118 pTransmitKey->dwKeyIndex = pMgmt->sNodeDBTable[uNodeIndex].dwKeyIndex; 119 pTransmitKey->uKeyLength = pMgmt->sNodeDBTable[uNodeIndex].uWepKeyLength; 120 pTransmitKey->dwTSC47_16 = pMgmt->sNodeDBTable[uNodeIndex].dwTSC47_16; 121 pTransmitKey->wTSC15_0 = pMgmt->sNodeDBTable[uNodeIndex].wTSC15_0; 122 memcpy(pTransmitKey->abyKey, 123 &pMgmt->sNodeDBTable[uNodeIndex].abyWepKey[0], 124 pTransmitKey->uKeyLength); 125 } 126 } 127 128 uMACfragNum = cbGetFragCount(pDevice, pTransmitKey, 129 cbFrameBodySize, &pDevice->sTxEthHeader); 130 131 if (uMACfragNum > AVAIL_TD(pDevice, TYPE_AC0DMA)) 132 return false; 133 134 byPktType = pDevice->byPacketType; 135 136 if (pDevice->bFixRate) { 137 if (pDevice->eCurrentPHYType == PHY_TYPE_11B) { 138 if (pDevice->uConnectionRate >= RATE_11M) 139 pDevice->wCurrentRate = RATE_11M; 140 else 141 pDevice->wCurrentRate = pDevice->uConnectionRate; 142 } else { 143 if ((pDevice->eCurrentPHYType == PHY_TYPE_11A) && 144 (pDevice->uConnectionRate <= RATE_6M)) { 145 pDevice->wCurrentRate = RATE_6M; 146 } else { 147 if (pDevice->uConnectionRate >= RATE_54M) 148 pDevice->wCurrentRate = RATE_54M; 149 else 150 pDevice->wCurrentRate = pDevice->uConnectionRate; 151 } 152 } 153 } else { 154 pDevice->wCurrentRate = pDevice->pMgmt->sNodeDBTable[uNodeIndex].wTxDataRate; 155 } 156 157 if (pDevice->wCurrentRate <= RATE_11M) 158 byPktType = PK_TYPE_11B; 159 160 vGenerateFIFOHeader(pDevice, byPktType, pDevice->pbyTmpBuff, 161 bNeedEncryption, cbFrameBodySize, TYPE_AC0DMA, 162 pHeadTD, &pDevice->sTxEthHeader, pbySkbData, 163 pTransmitKey, uNodeIndex, &uMACfragNum, 164 &cbHeaderSize); 165 166 if (MACbIsRegBitsOn(pDevice->PortOffset, MAC_REG_PSCTL, PSCTL_PS)) { 167 // Disable PS 168 MACbPSWakeup(pDevice->PortOffset); 169 } 170 171 pDevice->bPWBitOn = false; 172 173 pLastTD = pHeadTD; 174 for (ii = 0; ii < uMACfragNum; ii++) { 175 // Poll Transmit the adapter 176 wmb(); 177 pHeadTD->m_td0TD0.f1Owner = OWNED_BY_NIC; 178 wmb(); 179 if (ii == (uMACfragNum - 1)) 180 pLastTD = pHeadTD; 181 pHeadTD = pHeadTD->next; 182 } 183 184 pLastTD->pTDInfo->skb = NULL; 185 pLastTD->pTDInfo->byFlags = 0; 186 187 pDevice->apCurrTD[TYPE_AC0DMA] = pHeadTD; 188 189 MACvTransmitAC0(pDevice->PortOffset); 190 191 return true; 192}