Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1 | /* |
| 2 | ************************************************************************* |
| 3 | * Ralink Tech Inc. |
| 4 | * 5F., No.36, Taiyuan St., Jhubei City, |
| 5 | * Hsinchu County 302, |
| 6 | * Taiwan, R.O.C. |
| 7 | * |
| 8 | * (c) Copyright 2002-2007, Ralink Technology, Inc. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify * |
| 11 | * it under the terms of the GNU General Public License as published by * |
| 12 | * the Free Software Foundation; either version 2 of the License, or * |
| 13 | * (at your option) any later version. * |
| 14 | * * |
| 15 | * This program is distributed in the hope that it will be useful, * |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * |
| 18 | * GNU General Public License for more details. * |
| 19 | * * |
| 20 | * You should have received a copy of the GNU General Public License * |
| 21 | * along with this program; if not, write to the * |
| 22 | * Free Software Foundation, Inc., * |
| 23 | * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * |
| 24 | * * |
| 25 | ************************************************************************* |
| 26 | */ |
| 27 | |
| 28 | /* |
| 29 | All functions in this file must be PCI-depended, or you should out your function |
| 30 | in other files. |
| 31 | |
| 32 | */ |
| 33 | #include "../rt_config.h" |
| 34 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 35 | u16 RtmpPCI_WriteTxResource(struct rt_rtmp_adapter *pAd, |
| 36 | struct rt_tx_blk *pTxBlk, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 37 | IN BOOLEAN bIsLast, u16 * FreeNumber) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 38 | { |
| 39 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 40 | u8 *pDMAHeaderBufVA; |
| 41 | u16 TxIdx, RetTxIdx; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 42 | struct rt_txd * pTxD; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 43 | u32 BufBasePaLow; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 44 | struct rt_rtmp_tx_ring *pTxRing; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 45 | u16 hwHeaderLen; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 46 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 47 | /* */ |
| 48 | /* get Tx Ring Resource */ |
| 49 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 50 | pTxRing = &pAd->TxRing[pTxBlk->QueIdx]; |
| 51 | TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 52 | pDMAHeaderBufVA = (u8 *)pTxRing->Cell[TxIdx].DmaBuf.AllocVa; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 53 | BufBasePaLow = |
| 54 | RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 55 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 56 | /* copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 57 | if (pTxBlk->TxFrameType == TX_AMSDU_FRAME) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 58 | /*hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD, 4)+LENGTH_AMSDU_SUBFRAMEHEAD; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 59 | hwHeaderLen = |
| 60 | pTxBlk->MpduHeaderLen - LENGTH_AMSDU_SUBFRAMEHEAD + |
| 61 | pTxBlk->HdrPadLen + LENGTH_AMSDU_SUBFRAMEHEAD; |
| 62 | } else { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 63 | /*hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 64 | hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen; |
| 65 | } |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 66 | NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, |
| 67 | TXINFO_SIZE + TXWI_SIZE + hwHeaderLen); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 68 | |
| 69 | pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket; |
| 70 | pTxRing->Cell[TxIdx].pNextNdisPacket = NULL; |
| 71 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 72 | /* */ |
| 73 | /* build Tx Descriptor */ |
| 74 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 75 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 76 | pTxD = (struct rt_txd *) pTxRing->Cell[TxIdx].AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 77 | NdisZeroMemory(pTxD, TXD_SIZE); |
| 78 | |
| 79 | pTxD->SDPtr0 = BufBasePaLow; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 80 | pTxD->SDLen0 = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen; /* include padding */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 81 | pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE); |
| 82 | pTxD->SDLen1 = pTxBlk->SrcBufLen; |
| 83 | pTxD->LastSec0 = 0; |
| 84 | pTxD->LastSec1 = (bIsLast) ? 1 : 0; |
| 85 | |
| 86 | RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA); |
| 87 | |
| 88 | RetTxIdx = TxIdx; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 89 | /* */ |
| 90 | /* Update Tx index */ |
| 91 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 92 | INC_RING_INDEX(TxIdx, TX_RING_SIZE); |
| 93 | pTxRing->TxCpuIdx = TxIdx; |
| 94 | |
| 95 | *FreeNumber -= 1; |
| 96 | |
| 97 | return RetTxIdx; |
| 98 | } |
| 99 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 100 | u16 RtmpPCI_WriteSingleTxResource(struct rt_rtmp_adapter *pAd, |
| 101 | struct rt_tx_blk *pTxBlk, |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 102 | IN BOOLEAN bIsLast, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 103 | u16 * FreeNumber) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 104 | { |
| 105 | |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 106 | u8 *pDMAHeaderBufVA; |
| 107 | u16 TxIdx, RetTxIdx; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 108 | struct rt_txd * pTxD; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 109 | u32 BufBasePaLow; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 110 | struct rt_rtmp_tx_ring *pTxRing; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 111 | u16 hwHeaderLen; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 112 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 113 | /* */ |
| 114 | /* get Tx Ring Resource */ |
| 115 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 116 | pTxRing = &pAd->TxRing[pTxBlk->QueIdx]; |
| 117 | TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 118 | pDMAHeaderBufVA = (u8 *)pTxRing->Cell[TxIdx].DmaBuf.AllocVa; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 119 | BufBasePaLow = |
| 120 | RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 121 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 122 | /* copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */ |
| 123 | /*hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 124 | hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen; |
| 125 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 126 | NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, |
| 127 | TXINFO_SIZE + TXWI_SIZE + hwHeaderLen); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 128 | |
| 129 | pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket; |
| 130 | pTxRing->Cell[TxIdx].pNextNdisPacket = NULL; |
| 131 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 132 | /* */ |
| 133 | /* build Tx Descriptor */ |
| 134 | /* */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 135 | pTxD = (struct rt_txd *) pTxRing->Cell[TxIdx].AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 136 | NdisZeroMemory(pTxD, TXD_SIZE); |
| 137 | |
| 138 | pTxD->SDPtr0 = BufBasePaLow; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 139 | pTxD->SDLen0 = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen; /* include padding */ |
Joe Perches | 859171c | 2010-11-14 19:04:48 -0800 | [diff] [blame] | 140 | pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 141 | pTxD->SDLen1 = pTxBlk->SrcBufLen; |
| 142 | pTxD->LastSec0 = 0; |
| 143 | pTxD->LastSec1 = (bIsLast) ? 1 : 0; |
| 144 | |
| 145 | RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA); |
| 146 | |
| 147 | RetTxIdx = TxIdx; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 148 | /* */ |
| 149 | /* Update Tx index */ |
| 150 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 151 | INC_RING_INDEX(TxIdx, TX_RING_SIZE); |
| 152 | pTxRing->TxCpuIdx = TxIdx; |
| 153 | |
| 154 | *FreeNumber -= 1; |
| 155 | |
| 156 | return RetTxIdx; |
| 157 | } |
| 158 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 159 | u16 RtmpPCI_WriteMultiTxResource(struct rt_rtmp_adapter *pAd, |
| 160 | struct rt_tx_blk *pTxBlk, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 161 | u8 frameNum, u16 * FreeNumber) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 162 | { |
| 163 | BOOLEAN bIsLast; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 164 | u8 *pDMAHeaderBufVA; |
| 165 | u16 TxIdx, RetTxIdx; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 166 | struct rt_txd * pTxD; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 167 | u32 BufBasePaLow; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 168 | struct rt_rtmp_tx_ring *pTxRing; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 169 | u16 hwHdrLen; |
| 170 | u32 firstDMALen; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 171 | |
| 172 | bIsLast = ((frameNum == (pTxBlk->TotalFrameNum - 1)) ? 1 : 0); |
| 173 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 174 | /* */ |
| 175 | /* get Tx Ring Resource */ |
| 176 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 177 | pTxRing = &pAd->TxRing[pTxBlk->QueIdx]; |
| 178 | TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 179 | pDMAHeaderBufVA = (u8 *)pTxRing->Cell[TxIdx].DmaBuf.AllocVa; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 180 | BufBasePaLow = |
| 181 | RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 182 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 183 | if (frameNum == 0) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 184 | /* copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 185 | if (pTxBlk->TxFrameType == TX_AMSDU_FRAME) |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 186 | /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_AMSDU_SUBFRAMEHEAD, 4)+LENGTH_AMSDU_SUBFRAMEHEAD; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 187 | hwHdrLen = |
| 188 | pTxBlk->MpduHeaderLen - LENGTH_AMSDU_SUBFRAMEHEAD + |
| 189 | pTxBlk->HdrPadLen + LENGTH_AMSDU_SUBFRAMEHEAD; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 190 | else if (pTxBlk->TxFrameType == TX_RALINK_FRAME) |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 191 | /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen-LENGTH_ARALINK_HEADER_FIELD, 4)+LENGTH_ARALINK_HEADER_FIELD; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 192 | hwHdrLen = |
| 193 | pTxBlk->MpduHeaderLen - |
| 194 | LENGTH_ARALINK_HEADER_FIELD + pTxBlk->HdrPadLen + |
| 195 | LENGTH_ARALINK_HEADER_FIELD; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 196 | else |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 197 | /*hwHdrLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 198 | hwHdrLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen; |
| 199 | |
| 200 | firstDMALen = TXINFO_SIZE + TXWI_SIZE + hwHdrLen; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 201 | } else { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 202 | firstDMALen = pTxBlk->MpduHeaderLen; |
| 203 | } |
| 204 | |
| 205 | NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen); |
| 206 | |
| 207 | pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket; |
| 208 | pTxRing->Cell[TxIdx].pNextNdisPacket = NULL; |
| 209 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 210 | /* */ |
| 211 | /* build Tx Descriptor */ |
| 212 | /* */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 213 | pTxD = (struct rt_txd *) pTxRing->Cell[TxIdx].AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 214 | NdisZeroMemory(pTxD, TXD_SIZE); |
| 215 | |
| 216 | pTxD->SDPtr0 = BufBasePaLow; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 217 | pTxD->SDLen0 = firstDMALen; /* include padding */ |
Joe Perches | 859171c | 2010-11-14 19:04:48 -0800 | [diff] [blame] | 218 | pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 219 | pTxD->SDLen1 = pTxBlk->SrcBufLen; |
| 220 | pTxD->LastSec0 = 0; |
| 221 | pTxD->LastSec1 = (bIsLast) ? 1 : 0; |
| 222 | |
| 223 | RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA); |
| 224 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 225 | RetTxIdx = TxIdx; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 226 | /* */ |
| 227 | /* Update Tx index */ |
| 228 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 229 | INC_RING_INDEX(TxIdx, TX_RING_SIZE); |
| 230 | pTxRing->TxCpuIdx = TxIdx; |
| 231 | |
| 232 | *FreeNumber -= 1; |
| 233 | |
| 234 | return RetTxIdx; |
| 235 | |
| 236 | } |
| 237 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 238 | void RtmpPCI_FinalWriteTxResource(struct rt_rtmp_adapter *pAd, |
| 239 | struct rt_tx_blk *pTxBlk, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 240 | u16 totalMPDUSize, u16 FirstTxIdx) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 241 | { |
| 242 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 243 | struct rt_txwi * pTxWI; |
| 244 | struct rt_rtmp_tx_ring *pTxRing; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 245 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 246 | /* */ |
| 247 | /* get Tx Ring Resource */ |
| 248 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 249 | pTxRing = &pAd->TxRing[pTxBlk->QueIdx]; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 250 | pTxWI = (struct rt_txwi *) pTxRing->Cell[FirstTxIdx].DmaBuf.AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 251 | pTxWI->MPDUtotalByteCount = totalMPDUSize; |
| 252 | |
| 253 | } |
| 254 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 255 | void RtmpPCIDataLastTxIdx(struct rt_rtmp_adapter *pAd, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 256 | u8 QueIdx, u16 LastTxIdx) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 257 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 258 | struct rt_txd * pTxD; |
| 259 | struct rt_rtmp_tx_ring *pTxRing; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 260 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 261 | /* */ |
| 262 | /* get Tx Ring Resource */ |
| 263 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 264 | pTxRing = &pAd->TxRing[QueIdx]; |
| 265 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 266 | /* */ |
| 267 | /* build Tx Descriptor */ |
| 268 | /* */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 269 | pTxD = (struct rt_txd *) pTxRing->Cell[LastTxIdx].AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 270 | |
| 271 | pTxD->LastSec1 = 1; |
| 272 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 273 | } |
| 274 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 275 | u16 RtmpPCI_WriteFragTxResource(struct rt_rtmp_adapter *pAd, |
| 276 | struct rt_tx_blk *pTxBlk, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 277 | u8 fragNum, u16 * FreeNumber) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 278 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 279 | u8 *pDMAHeaderBufVA; |
| 280 | u16 TxIdx, RetTxIdx; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 281 | struct rt_txd * pTxD; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 282 | u32 BufBasePaLow; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 283 | struct rt_rtmp_tx_ring *pTxRing; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 284 | u16 hwHeaderLen; |
| 285 | u32 firstDMALen; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 286 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 287 | /* */ |
| 288 | /* Get Tx Ring Resource */ |
| 289 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 290 | pTxRing = &pAd->TxRing[pTxBlk->QueIdx]; |
| 291 | TxIdx = pAd->TxRing[pTxBlk->QueIdx].TxCpuIdx; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 292 | pDMAHeaderBufVA = (u8 *)pTxRing->Cell[TxIdx].DmaBuf.AllocVa; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 293 | BufBasePaLow = |
| 294 | RTMP_GetPhysicalAddressLow(pTxRing->Cell[TxIdx].DmaBuf.AllocPa); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 295 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 296 | /* */ |
| 297 | /* Copy TXINFO + TXWI + WLAN Header + LLC into DMA Header Buffer */ |
| 298 | /* */ |
| 299 | /*hwHeaderLen = ROUND_UP(pTxBlk->MpduHeaderLen, 4); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 300 | hwHeaderLen = pTxBlk->MpduHeaderLen + pTxBlk->HdrPadLen; |
| 301 | |
| 302 | firstDMALen = TXINFO_SIZE + TXWI_SIZE + hwHeaderLen; |
| 303 | NdisMoveMemory(pDMAHeaderBufVA, pTxBlk->HeaderBuf, firstDMALen); |
| 304 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 305 | /* */ |
| 306 | /* Build Tx Descriptor */ |
| 307 | /* */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 308 | pTxD = (struct rt_txd *) pTxRing->Cell[TxIdx].AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 309 | NdisZeroMemory(pTxD, TXD_SIZE); |
| 310 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 311 | if (fragNum == pTxBlk->TotalFragNum) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 312 | pTxRing->Cell[TxIdx].pNdisPacket = pTxBlk->pPacket; |
| 313 | pTxRing->Cell[TxIdx].pNextNdisPacket = NULL; |
| 314 | } |
| 315 | |
| 316 | pTxD->SDPtr0 = BufBasePaLow; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 317 | pTxD->SDLen0 = firstDMALen; /* include padding */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 318 | pTxD->SDPtr1 = PCI_MAP_SINGLE(pAd, pTxBlk, 0, 1, PCI_DMA_TODEVICE); |
| 319 | pTxD->SDLen1 = pTxBlk->SrcBufLen; |
| 320 | pTxD->LastSec0 = 0; |
| 321 | pTxD->LastSec1 = 1; |
| 322 | |
| 323 | RTMPWriteTxDescriptor(pAd, pTxD, FALSE, FIFO_EDCA); |
| 324 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 325 | RetTxIdx = TxIdx; |
| 326 | pTxBlk->Priv += pTxBlk->SrcBufLen; |
| 327 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 328 | /* */ |
| 329 | /* Update Tx index */ |
| 330 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 331 | INC_RING_INDEX(TxIdx, TX_RING_SIZE); |
| 332 | pTxRing->TxCpuIdx = TxIdx; |
| 333 | |
| 334 | *FreeNumber -= 1; |
| 335 | |
| 336 | return RetTxIdx; |
| 337 | |
| 338 | } |
| 339 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 340 | /* |
| 341 | Must be run in Interrupt context |
| 342 | This function handle PCI specific TxDesc and cpu index update and kick the packet out. |
| 343 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 344 | int RtmpPCIMgmtKickOut(struct rt_rtmp_adapter *pAd, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 345 | u8 QueIdx, |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 346 | void *pPacket, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 347 | u8 *pSrcBufVA, u32 SrcBufLen) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 348 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 349 | struct rt_txd * pTxD; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 350 | unsigned long SwIdx = pAd->MgmtRing.TxCpuIdx; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 351 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 352 | pTxD = (struct rt_txd *) pAd->MgmtRing.Cell[SwIdx].AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 353 | |
| 354 | pAd->MgmtRing.Cell[SwIdx].pNdisPacket = pPacket; |
| 355 | pAd->MgmtRing.Cell[SwIdx].pNextNdisPacket = NULL; |
| 356 | |
| 357 | RTMPWriteTxDescriptor(pAd, pTxD, TRUE, FIFO_MGMT); |
| 358 | pTxD->LastSec0 = 1; |
| 359 | pTxD->LastSec1 = 1; |
| 360 | pTxD->DMADONE = 0; |
| 361 | pTxD->SDLen1 = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 362 | pTxD->SDPtr0 = |
| 363 | PCI_MAP_SINGLE(pAd, pSrcBufVA, SrcBufLen, 0, PCI_DMA_TODEVICE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 364 | pTxD->SDLen0 = SrcBufLen; |
| 365 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 366 | /*================================================================== */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 367 | /* DBGPRINT_RAW(RT_DEBUG_TRACE, ("MLMEHardTransmit\n")); |
| 368 | for (i = 0; i < (TXWI_SIZE+24); i++) |
| 369 | { |
| 370 | |
| 371 | DBGPRINT_RAW(RT_DEBUG_TRACE, ("%x:", *(pSrcBufVA+i))); |
| 372 | if ( i%4 == 3) |
| 373 | DBGPRINT_RAW(RT_DEBUG_TRACE, (" :: ")); |
| 374 | if ( i%16 == 15) |
| 375 | DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n ")); |
| 376 | } |
| 377 | DBGPRINT_RAW(RT_DEBUG_TRACE, ("\n "));*/ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 378 | /*======================================================================= */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 379 | |
| 380 | pAd->RalinkCounters.KickTxCount++; |
| 381 | pAd->RalinkCounters.OneSecTxDoneCount++; |
| 382 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 383 | /* Increase TX_CTX_IDX, but write to register later. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 384 | INC_RING_INDEX(pAd->MgmtRing.TxCpuIdx, MGMT_RING_SIZE); |
| 385 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 386 | RTMP_IO_WRITE32(pAd, TX_MGMTCTX_IDX, pAd->MgmtRing.TxCpuIdx); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 387 | |
| 388 | return 0; |
| 389 | } |
| 390 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 391 | /* |
| 392 | ======================================================================== |
| 393 | |
| 394 | Routine Description: |
| 395 | Check Rx descriptor, return NDIS_STATUS_FAILURE if any error dound |
| 396 | |
| 397 | Arguments: |
| 398 | pRxD Pointer to the Rx descriptor |
| 399 | |
| 400 | Return Value: |
| 401 | NDIS_STATUS_SUCCESS No err |
| 402 | NDIS_STATUS_FAILURE Error |
| 403 | |
| 404 | Note: |
| 405 | |
| 406 | ======================================================================== |
| 407 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 408 | int RTMPCheckRxError(struct rt_rtmp_adapter *pAd, |
| 409 | struct rt_header_802_11 * pHeader, |
| 410 | struct rt_rxwi * pRxWI, IN PRT28XX_RXD_STRUC pRxD) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 411 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 412 | struct rt_cipher_key *pWpaKey; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 413 | int dBm; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 414 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 415 | /* Phy errors & CRC errors */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 416 | if ( /*(pRxD->PhyErr) || */ (pRxD->Crc)) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 417 | /* Check RSSI for Noise Hist statistic collection. */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 418 | dBm = (int)(pRxWI->RSSI0) - pAd->BbpRssiToDbmDelta; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 419 | if (dBm <= -87) |
| 420 | pAd->StaCfg.RPIDensity[0] += 1; |
| 421 | else if (dBm <= -82) |
| 422 | pAd->StaCfg.RPIDensity[1] += 1; |
| 423 | else if (dBm <= -77) |
| 424 | pAd->StaCfg.RPIDensity[2] += 1; |
| 425 | else if (dBm <= -72) |
| 426 | pAd->StaCfg.RPIDensity[3] += 1; |
| 427 | else if (dBm <= -67) |
| 428 | pAd->StaCfg.RPIDensity[4] += 1; |
| 429 | else if (dBm <= -62) |
| 430 | pAd->StaCfg.RPIDensity[5] += 1; |
| 431 | else if (dBm <= -57) |
| 432 | pAd->StaCfg.RPIDensity[6] += 1; |
| 433 | else if (dBm > -57) |
| 434 | pAd->StaCfg.RPIDensity[7] += 1; |
| 435 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 436 | return (NDIS_STATUS_FAILURE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 437 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 438 | /* Add Rx size to channel load counter, we should ignore error counts */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 439 | pAd->StaCfg.CLBusyBytes += (pRxD->SDL0 + 14); |
| 440 | |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 441 | /* Drop ToDs promiscuous frame, it is opened due to CCX 2 channel load statistics */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 442 | if (pHeader != NULL) { |
| 443 | if (pHeader->FC.ToDs) { |
| 444 | return (NDIS_STATUS_FAILURE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 445 | } |
| 446 | } |
Lucas De Marchi | e9c5499 | 2011-04-26 23:28:26 -0700 | [diff] [blame^] | 447 | /* Drop not U2M frames, can't drop here because we will drop beacon in this case */ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 448 | /* I am kind of doubting the U2M bit operation */ |
| 449 | /* if (pRxD->U2M == 0) */ |
| 450 | /* return(NDIS_STATUS_FAILURE); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 451 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 452 | /* drop decyption fail frame */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 453 | if (pRxD->CipherErr) { |
| 454 | if (pRxD->CipherErr == 2) { |
| 455 | DBGPRINT_RAW(RT_DEBUG_TRACE, |
| 456 | ("pRxD ERROR: ICV ok but MICErr ")); |
| 457 | } else if (pRxD->CipherErr == 1) { |
| 458 | DBGPRINT_RAW(RT_DEBUG_TRACE, ("pRxD ERROR: ICV Err ")); |
| 459 | } else if (pRxD->CipherErr == 3) |
| 460 | DBGPRINT_RAW(RT_DEBUG_TRACE, |
| 461 | ("pRxD ERROR: Key not valid ")); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 462 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 463 | if (((pRxD->CipherErr & 1) == 1) |
| 464 | && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd)) |
| 465 | RTMPSendWirelessEvent(pAd, IW_ICV_ERROR_EVENT_FLAG, |
| 466 | pAd->MacTab.Content[BSSID_WCID]. |
| 467 | Addr, BSS0, 0); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 468 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 469 | DBGPRINT_RAW(RT_DEBUG_TRACE, |
| 470 | (" %d (len=%d, Mcast=%d, MyBss=%d, Wcid=%d, KeyId=%d)\n", |
| 471 | pRxD->CipherErr, pRxD->SDL0, |
| 472 | pRxD->Mcast | pRxD->Bcast, pRxD->MyBss, |
| 473 | pRxWI->WirelessCliID, |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 474 | /* CipherName[pRxD->CipherAlg], */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 475 | pRxWI->KeyIndex)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 476 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 477 | /* */ |
| 478 | /* MIC Error */ |
| 479 | /* */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 480 | if (pRxD->CipherErr == 2) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 481 | pWpaKey = &pAd->SharedKey[BSS0][pRxWI->KeyIndex]; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 482 | if (pAd->StaCfg.WpaSupplicantUP) |
| 483 | WpaSendMicFailureToWpaSupplicant(pAd, |
| 484 | (pWpaKey-> |
| 485 | Type == |
| 486 | PAIRWISEKEY) ? |
| 487 | TRUE : FALSE); |
| 488 | else |
| 489 | RTMPReportMicError(pAd, pWpaKey); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 490 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 491 | if (((pRxD->CipherErr & 2) == 2) |
| 492 | && pAd->CommonCfg.bWirelessEvent && INFRA_ON(pAd)) |
| 493 | RTMPSendWirelessEvent(pAd, |
| 494 | IW_MIC_ERROR_EVENT_FLAG, |
| 495 | pAd->MacTab. |
| 496 | Content[BSSID_WCID].Addr, |
| 497 | BSS0, 0); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 498 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 499 | DBGPRINT_RAW(RT_DEBUG_ERROR, ("Rx MIC Value error\n")); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 500 | } |
| 501 | |
| 502 | if (pHeader == NULL) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 503 | return (NDIS_STATUS_SUCCESS); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 504 | /*if ((pRxD->CipherAlg == CIPHER_AES) && |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 505 | (pHeader->Sequence == pAd->FragFrame.Sequence)) |
| 506 | { |
| 507 | // |
| 508 | // Acceptable since the First FragFrame no CipherErr problem. |
| 509 | // |
| 510 | return(NDIS_STATUS_SUCCESS); |
| 511 | } */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 512 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 513 | return (NDIS_STATUS_FAILURE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 514 | } |
| 515 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 516 | return (NDIS_STATUS_SUCCESS); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 517 | } |
| 518 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 519 | BOOLEAN RTMPFreeTXDUponTxDmaDone(struct rt_rtmp_adapter *pAd, u8 QueIdx) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 520 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 521 | struct rt_rtmp_tx_ring *pTxRing; |
| 522 | struct rt_txd * pTxD; |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 523 | void *pPacket; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 524 | u8 FREE = 0; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 525 | struct rt_txd TxD, *pOriTxD; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 526 | /*unsigned long IrqFlags; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 527 | BOOLEAN bReschedule = FALSE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 528 | |
| 529 | ASSERT(QueIdx < NUM_OF_TX_RING); |
| 530 | pTxRing = &pAd->TxRing[QueIdx]; |
| 531 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 532 | RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF, |
| 533 | &pTxRing->TxDmaIdx); |
| 534 | while (pTxRing->TxSwFreeIdx != pTxRing->TxDmaIdx) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 535 | /* RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 536 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 537 | /* static rate also need NICUpdateFifoStaCounters() function. */ |
| 538 | /*if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_TX_RATE_SWITCH_ENABLED)) */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 539 | NICUpdateFifoStaCounters(pAd); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 540 | |
| 541 | /* Note : If (pAd->ate.bQATxStart == TRUE), we will never reach here. */ |
| 542 | FREE++; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 543 | pTxD = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 544 | (struct rt_txd *) (pTxRing->Cell[pTxRing->TxSwFreeIdx].AllocVa); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 545 | pOriTxD = pTxD; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 546 | NdisMoveMemory(&TxD, pTxD, sizeof(struct rt_txd)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 547 | pTxD = &TxD; |
| 548 | |
| 549 | pTxD->DMADONE = 0; |
| 550 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 551 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 552 | pPacket = |
| 553 | pTxRing->Cell[pTxRing->TxSwFreeIdx].pNdisPacket; |
| 554 | if (pPacket) { |
| 555 | PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, |
| 556 | pTxD->SDLen1, |
| 557 | PCI_DMA_TODEVICE); |
| 558 | RELEASE_NDIS_PACKET(pAd, pPacket, |
| 559 | NDIS_STATUS_SUCCESS); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 560 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 561 | /*Always assign pNdisPacket as NULL after clear */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 562 | pTxRing->Cell[pTxRing->TxSwFreeIdx].pNdisPacket = NULL; |
| 563 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 564 | pPacket = |
| 565 | pTxRing->Cell[pTxRing->TxSwFreeIdx].pNextNdisPacket; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 566 | |
| 567 | ASSERT(pPacket == NULL); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 568 | if (pPacket) { |
| 569 | PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, |
| 570 | pTxD->SDLen1, |
| 571 | PCI_DMA_TODEVICE); |
| 572 | RELEASE_NDIS_PACKET(pAd, pPacket, |
| 573 | NDIS_STATUS_SUCCESS); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 574 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 575 | /*Always assign pNextNdisPacket as NULL after clear */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 576 | pTxRing->Cell[pTxRing->TxSwFreeIdx].pNextNdisPacket = |
| 577 | NULL; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 578 | } |
| 579 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 580 | pAd->RalinkCounters.TransmittedByteCount += |
| 581 | (pTxD->SDLen1 + pTxD->SDLen0); |
| 582 | pAd->RalinkCounters.OneSecDmaDoneCount[QueIdx]++; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 583 | INC_RING_INDEX(pTxRing->TxSwFreeIdx, TX_RING_SIZE); |
| 584 | /* get tx_tdx_idx again */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 585 | RTMP_IO_READ32(pAd, TX_DTX_IDX0 + QueIdx * RINGREG_DIFF, |
| 586 | &pTxRing->TxDmaIdx); |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 587 | NdisMoveMemory(pOriTxD, pTxD, sizeof(struct rt_txd)); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 588 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 589 | /* RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 590 | } |
| 591 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 592 | return bReschedule; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 593 | |
| 594 | } |
| 595 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 596 | /* |
| 597 | ======================================================================== |
| 598 | |
| 599 | Routine Description: |
| 600 | Process TX Rings DMA Done interrupt, running in DPC level |
| 601 | |
| 602 | Arguments: |
| 603 | Adapter Pointer to our adapter |
| 604 | |
| 605 | Return Value: |
| 606 | None |
| 607 | |
| 608 | IRQL = DISPATCH_LEVEL |
| 609 | |
| 610 | ======================================================================== |
| 611 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 612 | BOOLEAN RTMPHandleTxRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 613 | INT_SOURCE_CSR_STRUC TxRingBitmap) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 614 | { |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 615 | /* u8 Count = 0; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 616 | unsigned long IrqFlags; |
| 617 | BOOLEAN bReschedule = FALSE; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 618 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 619 | /* Make sure Tx ring resource won't be used by other threads */ |
| 620 | /*NdisAcquireSpinLock(&pAd->TxRingLock); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 621 | |
| 622 | RTMP_IRQ_LOCK(&pAd->irq_lock, IrqFlags); |
| 623 | |
| 624 | if (TxRingBitmap.field.Ac0DmaDone) |
| 625 | bReschedule = RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_BE); |
| 626 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 627 | if (TxRingBitmap.field.Ac3DmaDone) |
| 628 | bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_VO); |
| 629 | |
| 630 | if (TxRingBitmap.field.Ac2DmaDone) |
| 631 | bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_VI); |
| 632 | |
| 633 | if (TxRingBitmap.field.Ac1DmaDone) |
| 634 | bReschedule |= RTMPFreeTXDUponTxDmaDone(pAd, QID_AC_BK); |
| 635 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 636 | /* Make sure to release Tx ring resource */ |
| 637 | /*NdisReleaseSpinLock(&pAd->TxRingLock); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 638 | RTMP_IRQ_UNLOCK(&pAd->irq_lock, IrqFlags); |
| 639 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 640 | /* Dequeue outgoing frames from TxSwQueue[] and process it */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 641 | RTMPDeQueuePacket(pAd, FALSE, NUM_OF_TX_RING, MAX_TX_PROCESS); |
| 642 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 643 | return bReschedule; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 644 | } |
| 645 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 646 | /* |
| 647 | ======================================================================== |
| 648 | |
| 649 | Routine Description: |
| 650 | Process MGMT ring DMA done interrupt, running in DPC level |
| 651 | |
| 652 | Arguments: |
| 653 | pAd Pointer to our adapter |
| 654 | |
| 655 | Return Value: |
| 656 | None |
| 657 | |
| 658 | IRQL = DISPATCH_LEVEL |
| 659 | |
| 660 | Note: |
| 661 | |
| 662 | ======================================================================== |
| 663 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 664 | void RTMPHandleMgmtRingDmaDoneInterrupt(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 665 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 666 | struct rt_txd * pTxD; |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 667 | void *pPacket; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 668 | /* int i; */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 669 | u8 FREE = 0; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 670 | struct rt_rtmp_mgmt_ring *pMgmtRing = &pAd->MgmtRing; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 671 | |
| 672 | NdisAcquireSpinLock(&pAd->MgmtRingLock); |
| 673 | |
| 674 | RTMP_IO_READ32(pAd, TX_MGMTDTX_IDX, &pMgmtRing->TxDmaIdx); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 675 | while (pMgmtRing->TxSwFreeIdx != pMgmtRing->TxDmaIdx) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 676 | FREE++; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 677 | pTxD = |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 678 | (struct rt_txd *) (pMgmtRing->Cell[pAd->MgmtRing.TxSwFreeIdx]. |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 679 | AllocVa); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 680 | pTxD->DMADONE = 0; |
| 681 | pPacket = pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNdisPacket; |
| 682 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 683 | if (pPacket) { |
| 684 | PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr0, pTxD->SDLen0, |
| 685 | PCI_DMA_TODEVICE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 686 | RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS); |
| 687 | } |
| 688 | pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNdisPacket = NULL; |
| 689 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 690 | pPacket = |
| 691 | pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNextNdisPacket; |
| 692 | if (pPacket) { |
| 693 | PCI_UNMAP_SINGLE(pAd, pTxD->SDPtr1, pTxD->SDLen1, |
| 694 | PCI_DMA_TODEVICE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 695 | RELEASE_NDIS_PACKET(pAd, pPacket, NDIS_STATUS_SUCCESS); |
| 696 | } |
| 697 | pMgmtRing->Cell[pMgmtRing->TxSwFreeIdx].pNextNdisPacket = NULL; |
| 698 | INC_RING_INDEX(pMgmtRing->TxSwFreeIdx, MGMT_RING_SIZE); |
| 699 | |
| 700 | } |
| 701 | NdisReleaseSpinLock(&pAd->MgmtRingLock); |
| 702 | |
| 703 | } |
| 704 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 705 | /* |
| 706 | ======================================================================== |
| 707 | |
| 708 | Routine Description: |
| 709 | Arguments: |
| 710 | Adapter Pointer to our adapter. Dequeue all power safe delayed braodcast frames after beacon. |
| 711 | |
| 712 | IRQL = DISPATCH_LEVEL |
| 713 | |
| 714 | ======================================================================== |
| 715 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 716 | void RTMPHandleTBTTInterrupt(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 717 | { |
| 718 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 719 | if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 720 | } |
| 721 | } |
| 722 | } |
| 723 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 724 | /* |
| 725 | ======================================================================== |
| 726 | |
| 727 | Routine Description: |
| 728 | Arguments: |
| 729 | pAd Pointer to our adapter. Rewrite beacon content before next send-out. |
| 730 | |
| 731 | IRQL = DISPATCH_LEVEL |
| 732 | |
| 733 | ======================================================================== |
| 734 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 735 | void RTMPHandlePreTBTTInterrupt(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 736 | { |
| 737 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 738 | if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) { |
| 739 | DBGPRINT(RT_DEBUG_TRACE, |
| 740 | ("RTMPHandlePreTBTTInterrupt...\n")); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 741 | } |
| 742 | } |
| 743 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 744 | } |
| 745 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 746 | void RTMPHandleRxCoherentInterrupt(struct rt_rtmp_adapter *pAd) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 747 | { |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 748 | WPDMA_GLO_CFG_STRUC GloCfg; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 749 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 750 | if (pAd == NULL) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 751 | DBGPRINT(RT_DEBUG_TRACE, ("====> pAd is NULL, return.\n")); |
| 752 | return; |
| 753 | } |
| 754 | |
| 755 | DBGPRINT(RT_DEBUG_TRACE, ("==> RTMPHandleRxCoherentInterrupt \n")); |
| 756 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 757 | RTMP_IO_READ32(pAd, WPDMA_GLO_CFG, &GloCfg.word); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 758 | |
| 759 | GloCfg.field.EnTXWriteBackDDONE = 0; |
| 760 | GloCfg.field.EnableRxDMA = 0; |
| 761 | GloCfg.field.EnableTxDMA = 0; |
| 762 | RTMP_IO_WRITE32(pAd, WPDMA_GLO_CFG, GloCfg.word); |
| 763 | |
| 764 | RTMPRingCleanUp(pAd, QID_AC_BE); |
| 765 | RTMPRingCleanUp(pAd, QID_AC_BK); |
| 766 | RTMPRingCleanUp(pAd, QID_AC_VI); |
| 767 | RTMPRingCleanUp(pAd, QID_AC_VO); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 768 | RTMPRingCleanUp(pAd, QID_MGMT); |
| 769 | RTMPRingCleanUp(pAd, QID_RX); |
| 770 | |
| 771 | RTMPEnableRxTx(pAd); |
| 772 | |
| 773 | DBGPRINT(RT_DEBUG_TRACE, ("<== RTMPHandleRxCoherentInterrupt \n")); |
| 774 | } |
| 775 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 776 | void *GetPacketFromRxRing(struct rt_rtmp_adapter *pAd, |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 777 | OUT PRT28XX_RXD_STRUC pSaveRxD, |
| 778 | OUT BOOLEAN * pbReschedule, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 779 | IN u32 * pRxPending) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 780 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 781 | struct rt_rxd * pRxD; |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 782 | void *pRxPacket = NULL; |
| 783 | void *pNewPacket; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 784 | void *AllocVa; |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 785 | dma_addr_t AllocPa; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 786 | BOOLEAN bReschedule = FALSE; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 787 | struct rt_rtmp_dmacb *pRxCell; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 788 | |
| 789 | RTMP_SEM_LOCK(&pAd->RxRingLock); |
| 790 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 791 | if (*pRxPending == 0) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 792 | /* Get how may packets had been received */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 793 | RTMP_IO_READ32(pAd, RX_DRX_IDX, &pAd->RxRing.RxDmaIdx); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 794 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 795 | if (pAd->RxRing.RxSwReadIdx == pAd->RxRing.RxDmaIdx) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 796 | /* no more rx packets */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 797 | bReschedule = FALSE; |
| 798 | goto done; |
| 799 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 800 | /* get rx pending count */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 801 | if (pAd->RxRing.RxDmaIdx > pAd->RxRing.RxSwReadIdx) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 802 | *pRxPending = |
| 803 | pAd->RxRing.RxDmaIdx - pAd->RxRing.RxSwReadIdx; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 804 | else |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 805 | *pRxPending = |
| 806 | pAd->RxRing.RxDmaIdx + RX_RING_SIZE - |
| 807 | pAd->RxRing.RxSwReadIdx; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 808 | |
| 809 | } |
| 810 | |
| 811 | pRxCell = &pAd->RxRing.Cell[pAd->RxRing.RxSwReadIdx]; |
| 812 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 813 | /* Point to Rx indexed rx ring descriptor */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 814 | pRxD = (struct rt_rxd *) pRxCell->AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 815 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 816 | if (pRxD->DDONE == 0) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 817 | *pRxPending = 0; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 818 | /* DMAIndx had done but DDONE bit not ready */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 819 | bReschedule = TRUE; |
| 820 | goto done; |
| 821 | } |
| 822 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 823 | /* return rx descriptor */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 824 | NdisMoveMemory(pSaveRxD, pRxD, RXD_SIZE); |
| 825 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 826 | pNewPacket = |
| 827 | RTMP_AllocateRxPacketBuffer(pAd, RX_BUFFER_AGGRESIZE, FALSE, |
| 828 | &AllocVa, &AllocPa); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 829 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 830 | if (pNewPacket) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 831 | /* unmap the rx buffer */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 832 | PCI_UNMAP_SINGLE(pAd, pRxCell->DmaBuf.AllocPa, |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 833 | pRxCell->DmaBuf.AllocSize, PCI_DMA_FROMDEVICE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 834 | pRxPacket = pRxCell->pNdisPacket; |
| 835 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 836 | pRxCell->DmaBuf.AllocSize = RX_BUFFER_AGGRESIZE; |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 837 | pRxCell->pNdisPacket = (void *)pNewPacket; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 838 | pRxCell->DmaBuf.AllocVa = AllocVa; |
| 839 | pRxCell->DmaBuf.AllocPa = AllocPa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 840 | /* update SDP0 to new buffer of rx packet */ |
| 841 | pRxD->SDP0 = AllocPa; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 842 | } else { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 843 | /*DBGPRINT(RT_DEBUG_TRACE,("No Rx Buffer\n")); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 844 | pRxPacket = NULL; |
| 845 | bReschedule = TRUE; |
| 846 | } |
| 847 | |
| 848 | pRxD->DDONE = 0; |
| 849 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 850 | /* had handled one rx packet */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 851 | *pRxPending = *pRxPending - 1; |
| 852 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 853 | /* update rx descriptor and kick rx */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 854 | INC_RING_INDEX(pAd->RxRing.RxSwReadIdx, RX_RING_SIZE); |
| 855 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 856 | pAd->RxRing.RxCpuIdx = |
| 857 | (pAd->RxRing.RxSwReadIdx == |
| 858 | 0) ? (RX_RING_SIZE - 1) : (pAd->RxRing.RxSwReadIdx - 1); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 859 | RTMP_IO_WRITE32(pAd, RX_CRX_IDX, pAd->RxRing.RxCpuIdx); |
| 860 | |
| 861 | done: |
| 862 | RTMP_SEM_UNLOCK(&pAd->RxRingLock); |
| 863 | *pbReschedule = bReschedule; |
| 864 | return pRxPacket; |
| 865 | } |
| 866 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 867 | int MlmeHardTransmitTxRing(struct rt_rtmp_adapter *pAd, |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 868 | u8 QueIdx, void *pPacket) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 869 | { |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 870 | struct rt_packet_info PacketInfo; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 871 | u8 *pSrcBufVA; |
| 872 | u32 SrcBufLen; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 873 | struct rt_txd * pTxD; |
| 874 | struct rt_header_802_11 * pHeader_802_11; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 875 | BOOLEAN bAckRequired, bInsertTimestamp; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 876 | unsigned long SrcBufPA; |
| 877 | /*u8 TxBufIdx; */ |
| 878 | u8 MlmeRate; |
| 879 | unsigned long SwIdx = pAd->TxRing[QueIdx].TxCpuIdx; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 880 | struct rt_txwi * pFirstTxWI; |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 881 | /*unsigned long i; */ |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 882 | /*HTTRANSMIT_SETTING MlmeTransmit; //Rate for this MGMT frame. */ |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 883 | unsigned long FreeNum; |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 884 | struct rt_mac_table_entry *pMacEntry = NULL; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 885 | |
| 886 | RTMP_QueryPacketInfo(pPacket, &PacketInfo, &pSrcBufVA, &SrcBufLen); |
| 887 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 888 | if (pSrcBufVA == NULL) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 889 | /* The buffer shouldn't be NULL */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 890 | return NDIS_STATUS_FAILURE; |
| 891 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 892 | /* Make sure MGMT ring resource won't be used by other threads */ |
| 893 | /*NdisAcquireSpinLock(&pAd->TxRingLock); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 894 | |
| 895 | FreeNum = GET_TXRING_FREENO(pAd, QueIdx); |
| 896 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 897 | if (FreeNum == 0) { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 898 | /*NdisReleaseSpinLock(&pAd->TxRingLock); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 899 | return NDIS_STATUS_FAILURE; |
| 900 | } |
| 901 | |
| 902 | SwIdx = pAd->TxRing[QueIdx].TxCpuIdx; |
| 903 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 904 | pTxD = (struct rt_txd *) pAd->TxRing[QueIdx].Cell[SwIdx].AllocVa; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 905 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 906 | if (pAd->TxRing[QueIdx].Cell[SwIdx].pNdisPacket) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 907 | DBGPRINT(RT_DEBUG_OFF, ("MlmeHardTransmit Error\n")); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 908 | /*NdisReleaseSpinLock(&pAd->TxRingLock); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 909 | return NDIS_STATUS_FAILURE; |
| 910 | } |
| 911 | |
| 912 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 913 | /* outgoing frame always wakeup PHY to prevent frame lost */ |
| 914 | /* if (pAd->StaCfg.Psm == PWR_SAVE) */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 915 | if (OPSTATUS_TEST_FLAG(pAd, fOP_STATUS_DOZE)) |
| 916 | AsicForceWakeup(pAd, TRUE); |
| 917 | } |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 918 | pFirstTxWI = (struct rt_txwi *) pSrcBufVA; |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 919 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 920 | pHeader_802_11 = (struct rt_header_802_11 *) (pSrcBufVA + TXWI_SIZE); |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 921 | if (pHeader_802_11->Addr1[0] & 0x01) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 922 | MlmeRate = pAd->CommonCfg.BasicMlmeRate; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 923 | } else { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 924 | MlmeRate = pAd->CommonCfg.MlmeRate; |
| 925 | } |
| 926 | |
| 927 | if ((pHeader_802_11->FC.Type == BTYPE_DATA) && |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 928 | (pHeader_802_11->FC.SubType == SUBTYPE_QOS_NULL)) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 929 | pMacEntry = MacTableLookup(pAd, pHeader_802_11->Addr1); |
| 930 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 931 | /* Verify Mlme rate for a / g bands. */ |
| 932 | if ((pAd->LatchRfRegs.Channel > 14) && (MlmeRate < RATE_6)) /* 11A band */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 933 | MlmeRate = RATE_6; |
| 934 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 935 | /* */ |
| 936 | /* Should not be hard code to set PwrMgmt to 0 (PWR_ACTIVE) */ |
| 937 | /* Snice it's been set to 0 while on MgtMacHeaderInit */ |
| 938 | /* By the way this will cause frame to be send on PWR_SAVE failed. */ |
| 939 | /* */ |
| 940 | /* */ |
| 941 | /* In WMM-UAPSD, mlme frame should be set psm as power saving but probe request frame */ |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 942 | /* Data-Null packets also pass through MMRequest in RT2860, however, we hope control the psm bit to pass APSD */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 943 | if (pHeader_802_11->FC.Type != BTYPE_DATA) { |
| 944 | if ((pHeader_802_11->FC.SubType == SUBTYPE_PROBE_REQ) |
| 945 | || !(pAd->CommonCfg.bAPSDCapable |
| 946 | && pAd->CommonCfg.APEdcaParm.bAPSDCapable)) { |
| 947 | pHeader_802_11->FC.PwrMgmt = PWR_ACTIVE; |
| 948 | } else { |
| 949 | pHeader_802_11->FC.PwrMgmt = |
| 950 | pAd->CommonCfg.bAPSDForcePowerSave; |
| 951 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 952 | } |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 953 | |
| 954 | bInsertTimestamp = FALSE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 955 | if (pHeader_802_11->FC.Type == BTYPE_CNTL) /* must be PS-POLL */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 956 | { |
| 957 | bAckRequired = FALSE; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 958 | } else /* BTYPE_MGMT or BTYPE_DATA(must be NULL frame) */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 959 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 960 | if (pHeader_802_11->Addr1[0] & 0x01) /* MULTICAST, BROADCAST */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 961 | { |
| 962 | bAckRequired = FALSE; |
| 963 | pHeader_802_11->Duration = 0; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 964 | } else { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 965 | bAckRequired = TRUE; |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 966 | pHeader_802_11->Duration = |
| 967 | RTMPCalcDuration(pAd, MlmeRate, 14); |
| 968 | if (pHeader_802_11->FC.SubType == SUBTYPE_PROBE_RSP) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 969 | bInsertTimestamp = TRUE; |
| 970 | } |
| 971 | } |
| 972 | } |
| 973 | pHeader_802_11->Sequence = pAd->Sequence++; |
| 974 | if (pAd->Sequence > 0xfff) |
| 975 | pAd->Sequence = 0; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 976 | /* Before radar detection done, mgmt frame can not be sent but probe req */ |
| 977 | /* Because we need to use probe req to trigger driver to send probe req in passive scan */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 978 | if ((pHeader_802_11->FC.SubType != SUBTYPE_PROBE_REQ) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 979 | && (pAd->CommonCfg.bIEEE80211H == 1) |
| 980 | && (pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE)) { |
| 981 | DBGPRINT(RT_DEBUG_ERROR, |
Sebastian Dalfuß | 06aea99 | 2009-11-07 17:31:12 +0100 | [diff] [blame] | 982 | ("MlmeHardTransmit --> radar detect not in normal mode!\n")); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 983 | /*NdisReleaseSpinLock(&pAd->TxRingLock); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 984 | return (NDIS_STATUS_FAILURE); |
| 985 | } |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 986 | /* */ |
| 987 | /* fill scatter-and-gather buffer list into TXD. Internally created NDIS PACKET */ |
| 988 | /* should always has only one ohysical buffer, and the whole frame size equals */ |
| 989 | /* to the first scatter buffer size */ |
| 990 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 991 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 992 | /* Initialize TX Descriptor */ |
| 993 | /* For inter-frame gap, the number is for this frame and next frame */ |
| 994 | /* For MLME rate, we will fix as 2Mb to match other vendor's implement */ |
| 995 | /* pAd->CommonCfg.MlmeTransmit.field.MODE = 1; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 996 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 997 | /* management frame doesn't need encryption. so use RESERVED_WCID no matter u are sending to specific wcid or not. */ |
| 998 | /* Only beacon use Nseq=TRUE. So here we use Nseq=FALSE. */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 999 | if (pMacEntry == NULL) { |
| 1000 | RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, bInsertTimestamp, |
| 1001 | FALSE, bAckRequired, FALSE, 0, RESERVED_WCID, |
| 1002 | (SrcBufLen - TXWI_SIZE), PID_MGMT, 0, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1003 | (u8)pAd->CommonCfg.MlmeTransmit.field.MCS, |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1004 | IFS_BACKOFF, FALSE, &pAd->CommonCfg.MlmeTransmit); |
| 1005 | } else { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1006 | RTMPWriteTxWI(pAd, pFirstTxWI, FALSE, FALSE, |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1007 | bInsertTimestamp, FALSE, bAckRequired, FALSE, |
| 1008 | 0, pMacEntry->Aid, (SrcBufLen - TXWI_SIZE), |
| 1009 | pMacEntry->MaxHTPhyMode.field.MCS, 0, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1010 | (u8)pMacEntry->MaxHTPhyMode.field.MCS, |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1011 | IFS_BACKOFF, FALSE, &pMacEntry->MaxHTPhyMode); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1012 | } |
| 1013 | |
| 1014 | pAd->TxRing[QueIdx].Cell[SwIdx].pNdisPacket = pPacket; |
| 1015 | pAd->TxRing[QueIdx].Cell[SwIdx].pNextNdisPacket = NULL; |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1016 | /* pFirstTxWI->MPDUtotalByteCount = SrcBufLen - TXWI_SIZE; */ |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1017 | SrcBufPA = |
| 1018 | PCI_MAP_SINGLE(pAd, pSrcBufVA, SrcBufLen, 0, PCI_DMA_TODEVICE); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1019 | |
| 1020 | RTMPWriteTxDescriptor(pAd, pTxD, TRUE, FIFO_EDCA); |
| 1021 | pTxD->LastSec0 = 1; |
| 1022 | pTxD->LastSec1 = 1; |
| 1023 | pTxD->SDLen0 = SrcBufLen; |
| 1024 | pTxD->SDLen1 = 0; |
| 1025 | pTxD->SDPtr0 = SrcBufPA; |
| 1026 | pTxD->DMADONE = 0; |
| 1027 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1028 | pAd->RalinkCounters.KickTxCount++; |
| 1029 | pAd->RalinkCounters.OneSecTxDoneCount++; |
| 1030 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1031 | /* Increase TX_CTX_IDX, but write to register later. */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1032 | INC_RING_INDEX(pAd->TxRing[QueIdx].TxCpuIdx, TX_RING_SIZE); |
| 1033 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1034 | RTMP_IO_WRITE32(pAd, TX_CTX_IDX0 + QueIdx * 0x10, |
| 1035 | pAd->TxRing[QueIdx].TxCpuIdx); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1036 | |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1037 | /* Make sure to release MGMT ring resource */ |
| 1038 | /* NdisReleaseSpinLock(&pAd->TxRingLock); */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1039 | |
| 1040 | return NDIS_STATUS_SUCCESS; |
| 1041 | } |
| 1042 | |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1043 | int MlmeDataHardTransmit(struct rt_rtmp_adapter *pAd, |
Bartlomiej Zolnierkiewicz | 8a10a54 | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1044 | u8 QueIdx, void *pPacket) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1045 | { |
| 1046 | if ((pAd->CommonCfg.RadarDetect.RDMode != RD_NORMAL_MODE) |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1047 | ) { |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1048 | return NDIS_STATUS_FAILURE; |
| 1049 | } |
| 1050 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1051 | return MlmeHardTransmitTxRing(pAd, QueIdx, pPacket); |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1052 | } |
| 1053 | |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1054 | /* |
| 1055 | ======================================================================== |
| 1056 | |
| 1057 | Routine Description: |
| 1058 | Calculates the duration which is required to transmit out frames |
| 1059 | with given size and specified rate. |
| 1060 | |
| 1061 | Arguments: |
| 1062 | pTxD Pointer to transmit descriptor |
| 1063 | Ack Setting for Ack requirement bit |
| 1064 | Fragment Setting for Fragment bit |
| 1065 | RetryMode Setting for retry mode |
| 1066 | Ifs Setting for IFS gap |
| 1067 | Rate Setting for transmit rate |
| 1068 | Service Setting for service |
| 1069 | Length Frame length |
| 1070 | TxPreamble Short or Long preamble when using CCK rates |
| 1071 | QueIdx - 0-3, according to 802.11e/d4.4 June/2003 |
| 1072 | |
| 1073 | Return Value: |
| 1074 | None |
| 1075 | |
| 1076 | IRQL = PASSIVE_LEVEL |
| 1077 | IRQL = DISPATCH_LEVEL |
| 1078 | |
| 1079 | ======================================================================== |
| 1080 | */ |
Bartlomiej Zolnierkiewicz | 62eb734 | 2009-12-11 12:23:16 -0800 | [diff] [blame] | 1081 | void RTMPWriteTxDescriptor(struct rt_rtmp_adapter *pAd, |
| 1082 | struct rt_txd * pTxD, |
Bartlomiej Zolnierkiewicz | 51126de | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1083 | IN BOOLEAN bWIV, u8 QueueSEL) |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1084 | { |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1085 | /* */ |
| 1086 | /* Always use Long preamble before verifiation short preamble functionality works well. */ |
| 1087 | /* Todo: remove the following line if short preamble functionality works */ |
| 1088 | /* */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1089 | OPSTATUS_CLEAR_FLAG(pAd, fOP_STATUS_SHORT_PREAMBLE_INUSED); |
| 1090 | |
Bartlomiej Zolnierkiewicz | 96b3c83d | 2009-12-11 12:23:13 -0800 | [diff] [blame] | 1091 | pTxD->WIV = (bWIV) ? 1 : 0; |
| 1092 | pTxD->QSEL = (QueueSEL); |
Bartlomiej Zolnierkiewicz | ec278fa | 2009-12-11 12:23:15 -0800 | [diff] [blame] | 1093 | /*RT2860c?? fixed using EDCA queue for test... We doubt Queue1 has problem. 2006-09-26 Jan */ |
| 1094 | /*pTxD->QSEL= FIFO_EDCA; */ |
Bartlomiej Zolnierkiewicz | ca97b83 | 2009-09-22 20:44:07 +0200 | [diff] [blame] | 1095 | pTxD->DMADONE = 0; |
| 1096 | } |