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/802.3/802.11 rx & tx functions
28 * s_vGenerateTxParameter - Generate tx dma required parameter.
29 * s_vGenerateMACHeader - Translate 802.3 to 802.11 header
30 * csBeacon_xmit - beacon tx function
31 * csMgmt_xmit - management tx function
32 * s_uGetDataDuration - get tx data required duration
33 * s_uFillDataHead- fulfill tx data duration header
34 * s_uGetRTSCTSDuration- get rtx/cts required duration
35 * s_uGetRTSCTSRsvTime- get rts/cts reserved time
36 * s_uGetTxRsvTime- get frame reserved time
37 * s_vFillCTSHead- fulfill CTS ctl header
38 * s_vFillFragParameter- Set fragment ctl parameter.
39 * s_vFillRTSHead- fulfill RTS ctl header
40 * s_vFillTxKey- fulfill tx encrypt key
41 * s_vSWencryption- Software encrypt header
42 * vDMA0_tx_80211- tx 802.11 frame via dma0
43 * vGenerateFIFOHeader- Generate tx FIFO ctl header
65 static int msglevel
= MSG_LEVEL_INFO
;
67 static const u16 wTimeStampOff
[2][MAX_RATE
] = {
68 {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble
69 {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, // Short Preamble
72 static const u16 wFB_Opt0
[2][5] = {
73 {RATE_12M
, RATE_18M
, RATE_24M
, RATE_36M
, RATE_48M
}, // fallback_rate0
74 {RATE_12M
, RATE_12M
, RATE_18M
, RATE_24M
, RATE_36M
}, // fallback_rate1
76 static const u16 wFB_Opt1
[2][5] = {
77 {RATE_12M
, RATE_18M
, RATE_24M
, RATE_24M
, RATE_36M
}, // fallback_rate0
78 {RATE_6M
, RATE_6M
, RATE_12M
, RATE_12M
, RATE_18M
}, // fallback_rate1
85 #define RTSDUR_BA_F0 4
86 #define RTSDUR_AA_F0 5
87 #define RTSDUR_BA_F1 6
88 #define RTSDUR_AA_F1 7
89 #define CTSDUR_BA_F0 8
90 #define CTSDUR_BA_F1 9
93 #define DATADUR_A_F0 12
94 #define DATADUR_A_F1 13
96 static void s_vSaveTxPktInfo(struct vnt_private
*pDevice
, u8 byPktNum
,
97 u8
*pbyDestAddr
, u16 wPktLength
, u16 wFIFOCtl
);
99 static struct vnt_usb_send_context
*s_vGetFreeContext(struct vnt_private
*);
101 static u16
s_vGenerateTxParameter(struct vnt_private
*pDevice
,
102 u8 byPktType
, u16 wCurrentRate
, struct vnt_tx_buffer
*tx_buffer
,
103 struct vnt_mic_hdr
**mic_hdr
, u32 need_mic
, u32 cbFrameSize
,
104 int bNeedACK
, u32 uDMAIdx
, struct ethhdr
*psEthHeader
, bool need_rts
);
106 static void s_vGenerateMACHeader(struct vnt_private
*pDevice
,
107 u8
*pbyBufferAddr
, u16 wDuration
, struct ethhdr
*psEthHeader
,
108 int bNeedEncrypt
, u16 wFragType
, u32 uDMAIdx
, u32 uFragIdx
);
110 static void s_vFillTxKey(struct vnt_private
*pDevice
,
111 struct vnt_tx_fifo_head
*fifo_head
, u8
*pbyIVHead
,
112 PSKeyItem pTransmitKey
, u8
*pbyHdrBuf
, u16 wPayloadLen
,
113 struct vnt_mic_hdr
*mic_hdr
);
115 static void s_vSWencryption(struct vnt_private
*pDevice
,
116 PSKeyItem pTransmitKey
, u8
*pbyPayloadHead
, u16 wPayloadSize
);
118 static unsigned int s_uGetTxRsvTime(struct vnt_private
*pDevice
, u8 byPktType
,
119 u32 cbFrameLength
, u16 wRate
, int bNeedAck
);
121 static u16
s_uGetRTSCTSRsvTime(struct vnt_private
*priv
,
122 u8 rsv_type
, u8 pkt_type
, u32 frame_lenght
, u16 current_rate
);
124 static u16
s_vFillCTSHead(struct vnt_private
*pDevice
, u32 uDMAIdx
,
125 u8 byPktType
, union vnt_tx_data_head
*head
, u32 cbFrameLength
,
126 int bNeedAck
, u16 wCurrentRate
, u8 byFBOption
);
128 static u16
s_vFillRTSHead(struct vnt_private
*pDevice
, u8 byPktType
,
129 union vnt_tx_data_head
*head
, u32 cbFrameLength
, int bNeedAck
,
130 struct ethhdr
*psEthHeader
, u16 wCurrentRate
, u8 byFBOption
);
132 static u16
s_uGetDataDuration(struct vnt_private
*pDevice
,
133 u8 byPktType
, int bNeedAck
);
135 static u16
s_uGetRTSCTSDuration(struct vnt_private
*pDevice
,
136 u8 byDurType
, u32 cbFrameLength
, u8 byPktType
, u16 wRate
,
137 int bNeedAck
, u8 byFBOption
);
139 static struct vnt_usb_send_context
140 *s_vGetFreeContext(struct vnt_private
*priv
)
142 struct vnt_usb_send_context
*context
= NULL
;
145 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"GetFreeContext()\n");
147 for (ii
= 0; ii
< priv
->cbTD
; ii
++) {
151 context
= priv
->apTD
[ii
];
152 if (context
->bBoolInUse
== false) {
153 context
->bBoolInUse
= true;
154 memset(context
->Data
, 0,
155 MAX_TOTAL_SIZE_WITH_ALL_HEADERS
);
160 if (ii
== priv
->cbTD
)
161 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"No Free Tx Context\n");
166 static void s_vSaveTxPktInfo(struct vnt_private
*pDevice
, u8 byPktNum
,
167 u8
*pbyDestAddr
, u16 wPktLength
, u16 wFIFOCtl
)
169 struct net_device_stats
*stats
= &pDevice
->stats
;
170 struct vnt_tx_pkt_info
*pkt_info
= pDevice
->pkt_info
;
172 pkt_info
[byPktNum
].fifo_ctl
= wFIFOCtl
;
173 memcpy(pkt_info
[byPktNum
].dest_addr
, pbyDestAddr
, ETH_ALEN
);
175 stats
->tx_bytes
+= wPktLength
;
178 static void s_vFillTxKey(struct vnt_private
*pDevice
,
179 struct vnt_tx_fifo_head
*fifo_head
, u8
*pbyIVHead
,
180 PSKeyItem pTransmitKey
, u8
*pbyHdrBuf
, u16 wPayloadLen
,
181 struct vnt_mic_hdr
*mic_hdr
)
183 u8
*pbyBuf
= (u8
*)&fifo_head
->adwTxKey
[0];
184 u32
*pdwIV
= (u32
*)pbyIVHead
;
185 u32
*pdwExtIV
= (u32
*)((u8
*)pbyIVHead
+ 4);
186 struct ieee80211_hdr
*pMACHeader
= (struct ieee80211_hdr
*)pbyHdrBuf
;
190 if (pTransmitKey
== NULL
)
193 dwRevIVCounter
= cpu_to_le32(pDevice
->dwIVCounter
);
194 *pdwIV
= pDevice
->dwIVCounter
;
195 pDevice
->byKeyIndex
= pTransmitKey
->dwKeyIndex
& 0xf;
197 switch (pTransmitKey
->byCipherSuite
) {
199 if (pTransmitKey
->uKeyLength
== WLAN_WEP232_KEYLEN
) {
200 memcpy(pDevice
->abyPRNG
, (u8
*)&dwRevIVCounter
, 3);
201 memcpy(pDevice
->abyPRNG
+ 3, pTransmitKey
->abyKey
,
202 pTransmitKey
->uKeyLength
);
204 memcpy(pbyBuf
, (u8
*)&dwRevIVCounter
, 3);
205 memcpy(pbyBuf
+ 3, pTransmitKey
->abyKey
,
206 pTransmitKey
->uKeyLength
);
207 if (pTransmitKey
->uKeyLength
== WLAN_WEP40_KEYLEN
) {
208 memcpy(pbyBuf
+8, (u8
*)&dwRevIVCounter
, 3);
209 memcpy(pbyBuf
+11, pTransmitKey
->abyKey
,
210 pTransmitKey
->uKeyLength
);
213 memcpy(pDevice
->abyPRNG
, pbyBuf
, 16);
215 /* Append IV after Mac Header */
216 *pdwIV
&= WEP_IV_MASK
;
217 *pdwIV
|= (u32
)pDevice
->byKeyIndex
<< 30;
218 *pdwIV
= cpu_to_le32(*pdwIV
);
220 pDevice
->dwIVCounter
++;
221 if (pDevice
->dwIVCounter
> WEP_IV_MASK
)
222 pDevice
->dwIVCounter
= 0;
226 pTransmitKey
->wTSC15_0
++;
227 if (pTransmitKey
->wTSC15_0
== 0)
228 pTransmitKey
->dwTSC47_16
++;
230 TKIPvMixKey(pTransmitKey
->abyKey
, pDevice
->abyCurrentNetAddr
,
231 pTransmitKey
->wTSC15_0
, pTransmitKey
->dwTSC47_16
,
233 memcpy(pbyBuf
, pDevice
->abyPRNG
, 16);
236 memcpy(pdwIV
, pDevice
->abyPRNG
, 3);
238 *(pbyIVHead
+3) = (u8
)(((pDevice
->byKeyIndex
<< 6) &
240 /* Append IV&ExtIV after Mac Header */
241 *pdwExtIV
= cpu_to_le32(pTransmitKey
->dwTSC47_16
);
243 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
244 "vFillTxKey()---- pdwExtIV: %x\n", *pdwExtIV
);
248 pTransmitKey
->wTSC15_0
++;
249 if (pTransmitKey
->wTSC15_0
== 0)
250 pTransmitKey
->dwTSC47_16
++;
252 memcpy(pbyBuf
, pTransmitKey
->abyKey
, 16);
256 *(pbyIVHead
+3) = (u8
)(((pDevice
->byKeyIndex
<< 6) &
259 *pdwIV
|= cpu_to_le16((u16
)(pTransmitKey
->wTSC15_0
));
261 /* Append IV&ExtIV after Mac Header */
262 *pdwExtIV
= cpu_to_le32(pTransmitKey
->dwTSC47_16
);
269 mic_hdr
->payload_len
= cpu_to_be16(wPayloadLen
);
270 memcpy(mic_hdr
->mic_addr2
, pMACHeader
->addr2
, ETH_ALEN
);
272 mic_hdr
->tsc_47_16
= cpu_to_be32(pTransmitKey
->dwTSC47_16
);
273 mic_hdr
->tsc_15_0
= cpu_to_be16(pTransmitKey
->wTSC15_0
);
276 if (ieee80211_has_a4(pMACHeader
->frame_control
))
277 mic_hdr
->hlen
= cpu_to_be16(28);
279 mic_hdr
->hlen
= cpu_to_be16(22);
281 memcpy(mic_hdr
->addr1
, pMACHeader
->addr1
, ETH_ALEN
);
282 memcpy(mic_hdr
->addr2
, pMACHeader
->addr2
, ETH_ALEN
);
285 memcpy(mic_hdr
->addr3
, pMACHeader
->addr3
, ETH_ALEN
);
286 mic_hdr
->frame_control
= cpu_to_le16(pMACHeader
->frame_control
288 mic_hdr
->seq_ctrl
= cpu_to_le16(pMACHeader
->seq_ctrl
& 0xf);
290 if (ieee80211_has_a4(pMACHeader
->frame_control
))
291 memcpy(mic_hdr
->addr4
, pMACHeader
->addr4
, ETH_ALEN
);
295 static void s_vSWencryption(struct vnt_private
*pDevice
,
296 PSKeyItem pTransmitKey
, u8
*pbyPayloadHead
, u16 wPayloadSize
)
299 u32 dwICV
= 0xffffffff;
302 if (pTransmitKey
== NULL
)
305 if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) {
306 //=======================================================================
307 // Append ICV after payload
308 dwICV
= CRCdwGetCrc32Ex(pbyPayloadHead
, wPayloadSize
, dwICV
);//ICV(Payload)
309 pdwICV
= (u32
*)(pbyPayloadHead
+ wPayloadSize
);
310 // finally, we must invert dwCRC to get the correct answer
311 *pdwICV
= cpu_to_le32(~dwICV
);
313 rc4_init(&pDevice
->SBox
, pDevice
->abyPRNG
, pTransmitKey
->uKeyLength
+ 3);
314 rc4_encrypt(&pDevice
->SBox
, pbyPayloadHead
, pbyPayloadHead
, wPayloadSize
+cbICVlen
);
315 //=======================================================================
316 } else if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
317 //=======================================================================
318 //Append ICV after payload
319 dwICV
= CRCdwGetCrc32Ex(pbyPayloadHead
, wPayloadSize
, dwICV
);//ICV(Payload)
320 pdwICV
= (u32
*)(pbyPayloadHead
+ wPayloadSize
);
321 // finally, we must invert dwCRC to get the correct answer
322 *pdwICV
= cpu_to_le32(~dwICV
);
324 rc4_init(&pDevice
->SBox
, pDevice
->abyPRNG
, TKIP_KEY_LEN
);
325 rc4_encrypt(&pDevice
->SBox
, pbyPayloadHead
, pbyPayloadHead
, wPayloadSize
+cbICVlen
);
326 //=======================================================================
330 static u16
vnt_time_stamp_off(struct vnt_private
*priv
, u16 rate
)
332 return cpu_to_le16(wTimeStampOff
[priv
->byPreambleType
% 2]
336 /*byPktType : PK_TYPE_11A 0
341 static u32
s_uGetTxRsvTime(struct vnt_private
*priv
, u8 pkt_type
,
342 u32 frame_length
, u16 rate
, int need_ack
)
344 u32 data_time
, ack_time
;
346 data_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
,
349 if (pkt_type
== PK_TYPE_11B
)
350 ack_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
, 14,
351 (u16
)priv
->byTopCCKBasicRate
);
353 ack_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
, 14,
354 (u16
)priv
->byTopOFDMBasicRate
);
357 return data_time
+ priv
->uSIFS
+ ack_time
;
362 static u16
vnt_rxtx_rsvtime_le16(struct vnt_private
*priv
, u8 pkt_type
,
363 u32 frame_length
, u16 rate
, int need_ack
)
365 return cpu_to_le16((u16
)s_uGetTxRsvTime(priv
, pkt_type
,
366 frame_length
, rate
, need_ack
));
369 //byFreqType: 0=>5GHZ 1=>2.4GHZ
370 static u16
s_uGetRTSCTSRsvTime(struct vnt_private
*priv
,
371 u8 rsv_type
, u8 pkt_type
, u32 frame_lenght
, u16 current_rate
)
373 u32 rrv_time
, rts_time
, cts_time
, ack_time
, data_time
;
375 rrv_time
= rts_time
= cts_time
= ack_time
= data_time
= 0;
377 data_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
,
378 frame_lenght
, current_rate
);
381 rts_time
= BBuGetFrameTime(priv
->byPreambleType
,
382 pkt_type
, 20, priv
->byTopCCKBasicRate
);
383 cts_time
= ack_time
= BBuGetFrameTime(priv
->byPreambleType
,
384 pkt_type
, 14, priv
->byTopCCKBasicRate
);
385 } else if (rsv_type
== 1) {
386 rts_time
= BBuGetFrameTime(priv
->byPreambleType
,
387 pkt_type
, 20, priv
->byTopCCKBasicRate
);
388 cts_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
,
389 14, priv
->byTopCCKBasicRate
);
390 ack_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
,
391 14, priv
->byTopOFDMBasicRate
);
392 } else if (rsv_type
== 2) {
393 rts_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
,
394 20, priv
->byTopOFDMBasicRate
);
395 cts_time
= ack_time
= BBuGetFrameTime(priv
->byPreambleType
,
396 pkt_type
, 14, priv
->byTopOFDMBasicRate
);
397 } else if (rsv_type
== 3) {
398 cts_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
,
399 14, priv
->byTopCCKBasicRate
);
400 ack_time
= BBuGetFrameTime(priv
->byPreambleType
, pkt_type
,
401 14, priv
->byTopOFDMBasicRate
);
403 rrv_time
= cts_time
+ ack_time
+ data_time
+ 2 * priv
->uSIFS
;
408 rrv_time
= rts_time
+ cts_time
+ ack_time
+ data_time
+ 3 * priv
->uSIFS
;
410 return cpu_to_le16((u16
)rrv_time
);
413 //byFreqType 0: 5GHz, 1:2.4Ghz
414 static u16
s_uGetDataDuration(struct vnt_private
*pDevice
,
415 u8 byPktType
, int bNeedAck
)
420 if (byPktType
== PK_TYPE_11B
)
421 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
,
422 byPktType
, 14, pDevice
->byTopCCKBasicRate
);
424 uAckTime
= BBuGetFrameTime(pDevice
->byPreambleType
,
425 byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
426 return cpu_to_le16((u16
)(pDevice
->uSIFS
+ uAckTime
));
432 //byFreqType: 0=>5GHZ 1=>2.4GHZ
433 static u16
s_uGetRTSCTSDuration(struct vnt_private
*pDevice
, u8 byDurType
,
434 u32 cbFrameLength
, u8 byPktType
, u16 wRate
, int bNeedAck
,
437 u32 uCTSTime
= 0, uDurTime
= 0;
444 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
,
445 14, pDevice
->byTopCCKBasicRate
);
446 uDurTime
= uCTSTime
+ 2 * pDevice
->uSIFS
+
447 s_uGetTxRsvTime(pDevice
, byPktType
,
448 cbFrameLength
, wRate
, bNeedAck
);
454 uCTSTime
= BBuGetFrameTime(pDevice
->byPreambleType
, byPktType
,
455 14, pDevice
->byTopOFDMBasicRate
);
456 uDurTime
= uCTSTime
+ 2 * pDevice
->uSIFS
+
457 s_uGetTxRsvTime(pDevice
, byPktType
,
458 cbFrameLength
, wRate
, bNeedAck
);
464 uDurTime
= pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
,
465 byPktType
, cbFrameLength
, wRate
, bNeedAck
);
472 return cpu_to_le16((u16
)uDurTime
);
475 static u16
vnt_rxtx_datahead_g(struct vnt_private
*priv
, u8 pkt_type
, u16 rate
,
476 struct vnt_tx_datahead_g
*buf
, u32 frame_len
, int need_ack
)
478 /* Get SignalField,ServiceField,Length */
479 BBvCalculateParameter(priv
, frame_len
, rate
, pkt_type
, &buf
->a
);
480 BBvCalculateParameter(priv
, frame_len
, priv
->byTopCCKBasicRate
,
481 PK_TYPE_11B
, &buf
->b
);
483 /* Get Duration and TimeStamp */
484 buf
->wDuration_a
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
485 buf
->wDuration_b
= s_uGetDataDuration(priv
, PK_TYPE_11B
, need_ack
);
487 buf
->wTimeStampOff_a
= vnt_time_stamp_off(priv
, rate
);
488 buf
->wTimeStampOff_b
= vnt_time_stamp_off(priv
,
489 priv
->byTopCCKBasicRate
);
491 return buf
->wDuration_a
;
494 static u16
vnt_rxtx_datahead_g_fb(struct vnt_private
*priv
, u8 pkt_type
,
495 u16 rate
, struct vnt_tx_datahead_g_fb
*buf
,
496 u32 frame_len
, int need_ack
)
498 /* Get SignalField,ServiceField,Length */
499 BBvCalculateParameter(priv
, frame_len
, rate
, pkt_type
, &buf
->a
);
501 BBvCalculateParameter(priv
, frame_len
, priv
->byTopCCKBasicRate
,
502 PK_TYPE_11B
, &buf
->b
);
504 /* Get Duration and TimeStamp */
505 buf
->wDuration_a
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
506 buf
->wDuration_b
= s_uGetDataDuration(priv
, PK_TYPE_11B
, need_ack
);
508 buf
->wDuration_a_f0
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
509 buf
->wDuration_a_f1
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
511 buf
->wTimeStampOff_a
= vnt_time_stamp_off(priv
, rate
);
512 buf
->wTimeStampOff_b
= vnt_time_stamp_off(priv
,
513 priv
->byTopCCKBasicRate
);
515 return buf
->wDuration_a
;
518 static u16
vnt_rxtx_datahead_a_fb(struct vnt_private
*priv
, u8 pkt_type
,
519 u16 rate
, struct vnt_tx_datahead_a_fb
*buf
,
520 u32 frame_len
, int need_ack
)
522 /* Get SignalField,ServiceField,Length */
523 BBvCalculateParameter(priv
, frame_len
, rate
, pkt_type
, &buf
->a
);
524 /* Get Duration and TimeStampOff */
525 buf
->wDuration
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
527 buf
->wDuration_f0
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
528 buf
->wDuration_f1
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
530 buf
->wTimeStampOff
= vnt_time_stamp_off(priv
, rate
);
532 return buf
->wDuration
;
535 static u16
vnt_rxtx_datahead_ab(struct vnt_private
*priv
, u8 pkt_type
,
536 u16 rate
, struct vnt_tx_datahead_ab
*buf
,
537 u32 frame_len
, int need_ack
)
539 /* Get SignalField,ServiceField,Length */
540 BBvCalculateParameter(priv
, frame_len
, rate
, pkt_type
, &buf
->ab
);
541 /* Get Duration and TimeStampOff */
542 buf
->wDuration
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
544 buf
->wTimeStampOff
= vnt_time_stamp_off(priv
, rate
);
546 return buf
->wDuration
;
549 static int vnt_fill_ieee80211_rts(struct vnt_private
*priv
,
550 struct ieee80211_rts
*rts
, struct ethhdr
*eth_hdr
,
553 rts
->duration
= duration
;
554 rts
->frame_control
= TYPE_CTL_RTS
;
556 if (priv
->eOPMode
== OP_MODE_ADHOC
|| priv
->eOPMode
== OP_MODE_AP
)
557 memcpy(rts
->ra
, eth_hdr
->h_dest
, ETH_ALEN
);
559 memcpy(rts
->ra
, priv
->abyBSSID
, ETH_ALEN
);
561 if (priv
->eOPMode
== OP_MODE_AP
)
562 memcpy(rts
->ta
, priv
->abyBSSID
, ETH_ALEN
);
564 memcpy(rts
->ta
, eth_hdr
->h_source
, ETH_ALEN
);
569 static u16
vnt_rxtx_rts_g_head(struct vnt_private
*priv
,
570 struct vnt_rts_g
*buf
, struct ethhdr
*eth_hdr
,
571 u8 pkt_type
, u32 frame_len
, int need_ack
,
572 u16 current_rate
, u8 fb_option
)
574 u16 rts_frame_len
= 20;
576 BBvCalculateParameter(priv
, rts_frame_len
, priv
->byTopCCKBasicRate
,
577 PK_TYPE_11B
, &buf
->b
);
578 BBvCalculateParameter(priv
, rts_frame_len
,
579 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
581 buf
->wDuration_bb
= s_uGetRTSCTSDuration(priv
, RTSDUR_BB
, frame_len
,
582 PK_TYPE_11B
, priv
->byTopCCKBasicRate
, need_ack
, fb_option
);
583 buf
->wDuration_aa
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
584 pkt_type
, current_rate
, need_ack
, fb_option
);
585 buf
->wDuration_ba
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA
, frame_len
,
586 pkt_type
, current_rate
, need_ack
, fb_option
);
588 vnt_fill_ieee80211_rts(priv
, &buf
->data
, eth_hdr
, buf
->wDuration_aa
);
590 return vnt_rxtx_datahead_g(priv
, pkt_type
, current_rate
,
591 &buf
->data_head
, frame_len
, need_ack
);
594 static u16
vnt_rxtx_rts_g_fb_head(struct vnt_private
*priv
,
595 struct vnt_rts_g_fb
*buf
, struct ethhdr
*eth_hdr
,
596 u8 pkt_type
, u32 frame_len
, int need_ack
,
597 u16 current_rate
, u8 fb_option
)
599 u16 rts_frame_len
= 20;
601 BBvCalculateParameter(priv
, rts_frame_len
, priv
->byTopCCKBasicRate
,
602 PK_TYPE_11B
, &buf
->b
);
603 BBvCalculateParameter(priv
, rts_frame_len
,
604 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
607 buf
->wDuration_bb
= s_uGetRTSCTSDuration(priv
, RTSDUR_BB
, frame_len
,
608 PK_TYPE_11B
, priv
->byTopCCKBasicRate
, need_ack
, fb_option
);
609 buf
->wDuration_aa
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
610 pkt_type
, current_rate
, need_ack
, fb_option
);
611 buf
->wDuration_ba
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA
, frame_len
,
612 pkt_type
, current_rate
, need_ack
, fb_option
);
615 buf
->wRTSDuration_ba_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA_F0
,
616 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
, fb_option
);
617 buf
->wRTSDuration_aa_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F0
,
618 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
, fb_option
);
619 buf
->wRTSDuration_ba_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA_F1
,
620 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
, fb_option
);
621 buf
->wRTSDuration_aa_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F1
,
622 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
, fb_option
);
624 vnt_fill_ieee80211_rts(priv
, &buf
->data
, eth_hdr
, buf
->wDuration_aa
);
626 return vnt_rxtx_datahead_g_fb(priv
, pkt_type
, current_rate
,
627 &buf
->data_head
, frame_len
, need_ack
);
630 static u16
vnt_rxtx_rts_ab_head(struct vnt_private
*priv
,
631 struct vnt_rts_ab
*buf
, struct ethhdr
*eth_hdr
,
632 u8 pkt_type
, u32 frame_len
, int need_ack
,
633 u16 current_rate
, u8 fb_option
)
635 u16 rts_frame_len
= 20;
637 BBvCalculateParameter(priv
, rts_frame_len
,
638 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->ab
);
640 buf
->wDuration
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
641 pkt_type
, current_rate
, need_ack
, fb_option
);
643 vnt_fill_ieee80211_rts(priv
, &buf
->data
, eth_hdr
, buf
->wDuration
);
645 return vnt_rxtx_datahead_ab(priv
, pkt_type
, current_rate
,
646 &buf
->data_head
, frame_len
, need_ack
);
649 static u16
vnt_rxtx_rts_a_fb_head(struct vnt_private
*priv
,
650 struct vnt_rts_a_fb
*buf
, struct ethhdr
*eth_hdr
,
651 u8 pkt_type
, u32 frame_len
, int need_ack
,
652 u16 current_rate
, u8 fb_option
)
654 u16 rts_frame_len
= 20;
656 BBvCalculateParameter(priv
, rts_frame_len
,
657 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
659 buf
->wDuration
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
660 pkt_type
, current_rate
, need_ack
, fb_option
);
662 buf
->wRTSDuration_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F0
,
663 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
, fb_option
);
665 buf
->wRTSDuration_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F1
,
666 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
, fb_option
);
668 vnt_fill_ieee80211_rts(priv
, &buf
->data
, eth_hdr
, buf
->wDuration
);
670 return vnt_rxtx_datahead_a_fb(priv
, pkt_type
, current_rate
,
671 &buf
->data_head
, frame_len
, need_ack
);
674 static u16
s_vFillRTSHead(struct vnt_private
*pDevice
, u8 byPktType
,
675 union vnt_tx_data_head
*head
, u32 cbFrameLength
, int bNeedAck
,
676 struct ethhdr
*psEthHeader
, u16 wCurrentRate
, u8 byFBOption
)
682 /* Note: So far RTSHead doesn't appear in ATIM
683 * & Beacom DMA, so we don't need to take them
685 * Otherwise, we need to modified codes for them.
690 if (byFBOption
== AUTO_FB_NONE
)
691 return vnt_rxtx_rts_g_head(pDevice
, &head
->rts_g
,
692 psEthHeader
, byPktType
, cbFrameLength
,
693 bNeedAck
, wCurrentRate
, byFBOption
);
695 return vnt_rxtx_rts_g_fb_head(pDevice
, &head
->rts_g_fb
,
696 psEthHeader
, byPktType
, cbFrameLength
,
697 bNeedAck
, wCurrentRate
, byFBOption
);
701 return vnt_rxtx_rts_a_fb_head(pDevice
, &head
->rts_a_fb
,
702 psEthHeader
, byPktType
, cbFrameLength
,
703 bNeedAck
, wCurrentRate
, byFBOption
);
707 return vnt_rxtx_rts_ab_head(pDevice
, &head
->rts_ab
,
708 psEthHeader
, byPktType
, cbFrameLength
,
709 bNeedAck
, wCurrentRate
, byFBOption
);
715 static u16
s_vFillCTSHead(struct vnt_private
*pDevice
, u32 uDMAIdx
,
716 u8 byPktType
, union vnt_tx_data_head
*head
, u32 cbFrameLength
,
717 int bNeedAck
, u16 wCurrentRate
, u8 byFBOption
)
719 u32 uCTSFrameLen
= 14;
724 if (byFBOption
!= AUTO_FB_NONE
) {
726 struct vnt_cts_fb
*pBuf
= &head
->cts_g_fb
;
727 /* Get SignalField,ServiceField,Length */
728 BBvCalculateParameter(pDevice
, uCTSFrameLen
,
729 pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
, &pBuf
->b
);
730 pBuf
->wDuration_ba
= s_uGetRTSCTSDuration(pDevice
, CTSDUR_BA
,
731 cbFrameLength
, byPktType
,
732 wCurrentRate
, bNeedAck
, byFBOption
);
733 /* Get CTSDuration_ba_f0 */
734 pBuf
->wCTSDuration_ba_f0
= s_uGetRTSCTSDuration(pDevice
,
735 CTSDUR_BA_F0
, cbFrameLength
, byPktType
,
736 pDevice
->tx_rate_fb0
, bNeedAck
, byFBOption
);
737 /* Get CTSDuration_ba_f1 */
738 pBuf
->wCTSDuration_ba_f1
= s_uGetRTSCTSDuration(pDevice
,
739 CTSDUR_BA_F1
, cbFrameLength
, byPktType
,
740 pDevice
->tx_rate_fb1
, bNeedAck
, byFBOption
);
741 /* Get CTS Frame body */
742 pBuf
->data
.duration
= pBuf
->wDuration_ba
;
743 pBuf
->data
.frame_control
= TYPE_CTL_CTS
;
744 memcpy(pBuf
->data
.ra
, pDevice
->abyCurrentNetAddr
, ETH_ALEN
);
746 return vnt_rxtx_datahead_g_fb(pDevice
, byPktType
, wCurrentRate
,
747 &pBuf
->data_head
, cbFrameLength
, bNeedAck
);
749 struct vnt_cts
*pBuf
= &head
->cts_g
;
750 /* Get SignalField,ServiceField,Length */
751 BBvCalculateParameter(pDevice
, uCTSFrameLen
,
752 pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
, &pBuf
->b
);
753 /* Get CTSDuration_ba */
754 pBuf
->wDuration_ba
= s_uGetRTSCTSDuration(pDevice
,
755 CTSDUR_BA
, cbFrameLength
, byPktType
,
756 wCurrentRate
, bNeedAck
, byFBOption
);
757 /*Get CTS Frame body*/
758 pBuf
->data
.duration
= pBuf
->wDuration_ba
;
759 pBuf
->data
.frame_control
= TYPE_CTL_CTS
;
760 memcpy(pBuf
->data
.ra
, pDevice
->abyCurrentNetAddr
, ETH_ALEN
);
762 return vnt_rxtx_datahead_g(pDevice
, byPktType
, wCurrentRate
,
763 &pBuf
->data_head
, cbFrameLength
, bNeedAck
);
772 * Generate FIFO control for MAC & Baseband controller
776 * pDevice - Pointer to adpater
777 * pTxDataHead - Transmit Data Buffer
778 * pTxBufHead - pTxBufHead
779 * pvRrvTime - pvRrvTime
782 * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS)
783 * bNeedACK - If need ACK
784 * uDMAIdx - DMA Index
792 static u16
s_vGenerateTxParameter(struct vnt_private
*pDevice
,
793 u8 byPktType
, u16 wCurrentRate
, struct vnt_tx_buffer
*tx_buffer
,
794 struct vnt_mic_hdr
**mic_hdr
, u32 need_mic
, u32 cbFrameSize
,
795 int bNeedACK
, u32 uDMAIdx
, struct ethhdr
*psEthHeader
, bool need_rts
)
797 struct vnt_tx_fifo_head
*pFifoHead
= &tx_buffer
->fifo_head
;
798 union vnt_tx_data_head
*head
= NULL
;
800 u8 byFBOption
= AUTO_FB_NONE
;
802 pFifoHead
->wReserved
= wCurrentRate
;
803 wFifoCtl
= pFifoHead
->wFIFOCtl
;
805 if (wFifoCtl
& FIFOCTL_AUTO_FB_0
)
806 byFBOption
= AUTO_FB_0
;
807 else if (wFifoCtl
& FIFOCTL_AUTO_FB_1
)
808 byFBOption
= AUTO_FB_1
;
813 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
815 struct vnt_rrv_time_rts
*pBuf
=
816 &tx_buffer
->tx_head
.tx_rts
.rts
;
818 pBuf
->wRTSTxRrvTime_aa
= s_uGetRTSCTSRsvTime(pDevice
, 2,
819 byPktType
, cbFrameSize
, wCurrentRate
);
820 pBuf
->wRTSTxRrvTime_ba
= s_uGetRTSCTSRsvTime(pDevice
, 1,
821 byPktType
, cbFrameSize
, wCurrentRate
);
822 pBuf
->wRTSTxRrvTime_bb
= s_uGetRTSCTSRsvTime(pDevice
, 0,
823 byPktType
, cbFrameSize
, wCurrentRate
);
825 pBuf
->wTxRrvTime_a
= vnt_rxtx_rsvtime_le16(pDevice
,
826 byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
);
827 pBuf
->wTxRrvTime_b
= vnt_rxtx_rsvtime_le16(pDevice
,
828 PK_TYPE_11B
, cbFrameSize
,
829 pDevice
->byTopCCKBasicRate
, bNeedACK
);
832 *mic_hdr
= &tx_buffer
->
833 tx_head
.tx_rts
.tx
.mic
.hdr
;
834 head
= &tx_buffer
->tx_head
.tx_rts
.tx
.mic
.head
;
836 head
= &tx_buffer
->tx_head
.tx_rts
.tx
.head
;
840 return s_vFillRTSHead(pDevice
, byPktType
, head
,
841 cbFrameSize
, bNeedACK
, psEthHeader
,
842 wCurrentRate
, byFBOption
);
845 struct vnt_rrv_time_cts
*pBuf
= &tx_buffer
->
848 pBuf
->wTxRrvTime_a
= vnt_rxtx_rsvtime_le16(pDevice
,
849 byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
);
850 pBuf
->wTxRrvTime_b
= vnt_rxtx_rsvtime_le16(pDevice
,
851 PK_TYPE_11B
, cbFrameSize
,
852 pDevice
->byTopCCKBasicRate
, bNeedACK
);
854 pBuf
->wCTSTxRrvTime_ba
= s_uGetRTSCTSRsvTime(pDevice
, 3,
855 byPktType
, cbFrameSize
, wCurrentRate
);
858 *mic_hdr
= &tx_buffer
->
859 tx_head
.tx_cts
.tx
.mic
.hdr
;
860 head
= &tx_buffer
->tx_head
.tx_cts
.tx
.mic
.head
;
862 head
= &tx_buffer
->tx_head
.tx_cts
.tx
.head
;
866 return s_vFillCTSHead(pDevice
, uDMAIdx
, byPktType
,
867 head
, cbFrameSize
, bNeedACK
, wCurrentRate
,
870 } else if (byPktType
== PK_TYPE_11A
) {
872 *mic_hdr
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.hdr
;
873 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.head
;
875 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.head
;
879 struct vnt_rrv_time_ab
*pBuf
= &tx_buffer
->
882 pBuf
->wRTSTxRrvTime
= s_uGetRTSCTSRsvTime(pDevice
, 2,
883 byPktType
, cbFrameSize
, wCurrentRate
);
885 pBuf
->wTxRrvTime
= vnt_rxtx_rsvtime_le16(pDevice
,
886 byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
);
889 return s_vFillRTSHead(pDevice
, byPktType
, head
,
890 cbFrameSize
, bNeedACK
, psEthHeader
,
891 wCurrentRate
, byFBOption
);
893 struct vnt_rrv_time_ab
*pBuf
= &tx_buffer
->
896 pBuf
->wTxRrvTime
= vnt_rxtx_rsvtime_le16(pDevice
,
897 PK_TYPE_11A
, cbFrameSize
,
898 wCurrentRate
, bNeedACK
);
900 return vnt_rxtx_datahead_a_fb(pDevice
, byPktType
,
901 wCurrentRate
, &head
->data_head_a_fb
,
902 cbFrameSize
, bNeedACK
);
904 } else if (byPktType
== PK_TYPE_11B
) {
906 *mic_hdr
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.hdr
;
907 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.head
;
909 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.head
;
913 struct vnt_rrv_time_ab
*pBuf
= &tx_buffer
->
916 pBuf
->wRTSTxRrvTime
= s_uGetRTSCTSRsvTime(pDevice
, 0,
917 byPktType
, cbFrameSize
, wCurrentRate
);
919 pBuf
->wTxRrvTime
= vnt_rxtx_rsvtime_le16(pDevice
,
920 PK_TYPE_11B
, cbFrameSize
, wCurrentRate
,
924 return s_vFillRTSHead(pDevice
, byPktType
, head
,
926 bNeedACK
, psEthHeader
, wCurrentRate
, byFBOption
);
928 struct vnt_rrv_time_ab
*pBuf
= &tx_buffer
->
931 pBuf
->wTxRrvTime
= vnt_rxtx_rsvtime_le16(pDevice
,
932 PK_TYPE_11B
, cbFrameSize
,
933 wCurrentRate
, bNeedACK
);
935 return vnt_rxtx_datahead_ab(pDevice
, byPktType
,
936 wCurrentRate
, &head
->data_head_ab
,
937 cbFrameSize
, bNeedACK
);
944 u8 * pbyBuffer,//point to pTxBufHead
945 u16 wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last
946 unsigned int cbFragmentSize,//Hdr+payoad+FCS
949 static int s_bPacketToWirelessUsb(struct vnt_private
*pDevice
, u8 byPktType
,
950 struct vnt_tx_buffer
*tx_buffer
, int bNeedEncryption
,
951 u32 uSkbPacketLen
, u32 uDMAIdx
, struct ethhdr
*psEthHeader
,
952 u8
*pPacket
, PSKeyItem pTransmitKey
, u32 uNodeIndex
, u16 wCurrentRate
,
953 u32
*pcbHeaderLen
, u32
*pcbTotalLen
)
955 struct vnt_tx_fifo_head
*pTxBufHead
= &tx_buffer
->fifo_head
;
956 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
957 u32 cbFrameSize
, cbFrameBodySize
;
959 u32 cbIVlen
= 0, cbICVlen
= 0, cbMIClen
= 0, cbMACHdLen
= 0;
960 u32 cbFCSlen
= 4, cbMICHDR
= 0;
963 u8
*pbyType
, *pbyMacHdr
, *pbyIVHead
, *pbyPayloadHead
, *pbyTxBufferAddr
;
964 u8 abySNAP_RFC1042
[ETH_ALEN
] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
965 u8 abySNAP_Bridgetunnel
[ETH_ALEN
]
966 = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
968 u32 cbHeaderLength
= 0, uPadding
= 0;
969 struct vnt_mic_hdr
*pMICHDR
;
970 u8 byFBOption
= AUTO_FB_NONE
, byFragType
;
972 u32 dwMICKey0
, dwMICKey1
, dwMIC_Priority
;
973 u32
*pdwMIC_L
, *pdwMIC_R
;
974 int bSoftWEP
= false;
978 if (bNeedEncryption
&& pTransmitKey
->pvKeyTable
) {
979 if (((PSKeyTable
)pTransmitKey
->pvKeyTable
)->bSoftWEP
== true)
980 bSoftWEP
= true; /* WEP 256 */
984 if (ntohs(psEthHeader
->h_proto
) > ETH_DATA_LEN
)
989 cbFrameBodySize
= uSkbPacketLen
- ETH_HLEN
+ cb802_1_H_len
;
992 pTxBufHead
->wFIFOCtl
|= (u16
)(byPktType
<<8);
994 if ((pDevice
->eOPMode
== OP_MODE_ADHOC
) ||
995 (pDevice
->eOPMode
== OP_MODE_AP
)) {
996 if (is_multicast_ether_addr(psEthHeader
->h_dest
)) {
998 pTxBufHead
->wFIFOCtl
=
999 pTxBufHead
->wFIFOCtl
& (~FIFOCTL_NEEDACK
);
1002 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
1005 /* MSDUs in Infra mode always need ACK */
1007 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
1010 pTxBufHead
->wTimeStamp
= DEFAULT_MSDU_LIFETIME_RES_64us
;
1012 //Set FRAGCTL_MACHDCNT
1013 cbMACHdLen
= WLAN_HDR_ADDR3_LEN
;
1015 pTxBufHead
->wFragCtl
|= (u16
)(cbMACHdLen
<< 10);
1017 //Set FIFOCTL_GrpAckPolicy
1018 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
1019 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
1022 /* Set Auto Fallback Ctl */
1023 if (wCurrentRate
>= RATE_18M
) {
1024 if (pDevice
->byAutoFBCtrl
== AUTO_FB_0
) {
1025 pTxBufHead
->wFIFOCtl
|= FIFOCTL_AUTO_FB_0
;
1027 pDevice
->tx_rate_fb0
=
1028 wFB_Opt0
[FB_RATE0
][wCurrentRate
- RATE_18M
];
1029 pDevice
->tx_rate_fb1
=
1030 wFB_Opt0
[FB_RATE1
][wCurrentRate
- RATE_18M
];
1032 byFBOption
= AUTO_FB_0
;
1033 } else if (pDevice
->byAutoFBCtrl
== AUTO_FB_1
) {
1034 pTxBufHead
->wFIFOCtl
|= FIFOCTL_AUTO_FB_1
;
1035 pDevice
->tx_rate_fb0
=
1036 wFB_Opt1
[FB_RATE0
][wCurrentRate
- RATE_18M
];
1037 pDevice
->tx_rate_fb1
=
1038 wFB_Opt1
[FB_RATE1
][wCurrentRate
- RATE_18M
];
1040 byFBOption
= AUTO_FB_1
;
1044 if (bSoftWEP
!= true) {
1045 if ((bNeedEncryption
) && (pTransmitKey
!= NULL
)) { //WEP enabled
1046 if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) { //WEP40 or WEP104
1047 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
1049 if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
1050 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Tx Set wFragCtl == FRAGCTL_TKIP\n");
1051 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
1053 else if (pTransmitKey
->byCipherSuite
== KEY_CTL_CCMP
) { //CCMP
1054 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
1059 if ((bNeedEncryption
) && (pTransmitKey
!= NULL
)) {
1060 if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) {
1064 else if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
1065 cbIVlen
= 8;//IV+ExtIV
1069 if (pTransmitKey
->byCipherSuite
== KEY_CTL_CCMP
) {
1070 cbIVlen
= 8;//RSN Header
1072 cbMICHDR
= sizeof(struct vnt_mic_hdr
);
1074 if (bSoftWEP
== false) {
1075 //MAC Header should be padding 0 to DW alignment.
1076 uPadding
= 4 - (cbMACHdLen
%4);
1081 cbFrameSize
= cbMACHdLen
+ cbIVlen
+ (cbFrameBodySize
+ cbMIClen
) + cbICVlen
+ cbFCSlen
;
1083 if ( (bNeedACK
== false) ||(cbFrameSize
< pDevice
->wRTSThreshold
) ) {
1087 pTxBufHead
->wFIFOCtl
|= (FIFOCTL_RTS
| FIFOCTL_LRETRY
);
1090 pbyTxBufferAddr
= (u8
*) &(pTxBufHead
->adwTxKey
[0]);
1091 wTxBufSize
= sizeof(struct vnt_tx_fifo_head
);
1093 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
1094 if (byFBOption
== AUTO_FB_NONE
) {
1095 if (bRTS
== true) {//RTS_need
1096 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_rts
) +
1097 cbMICHDR
+ sizeof(struct vnt_rts_g
);
1099 else { //RTS_needless
1100 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_cts
) +
1101 cbMICHDR
+ sizeof(struct vnt_cts
);
1105 if (bRTS
== true) {//RTS_need
1106 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_rts
) +
1107 cbMICHDR
+ sizeof(struct vnt_rts_g_fb
);
1109 else if (bRTS
== false) { //RTS_needless
1110 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_cts
) +
1111 cbMICHDR
+ sizeof(struct vnt_cts_fb
);
1115 else {//802.11a/b packet
1116 if (byFBOption
== AUTO_FB_NONE
) {
1117 if (bRTS
== true) {//RTS_need
1118 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1119 cbMICHDR
+ sizeof(struct vnt_rts_ab
);
1121 else if (bRTS
== false) { //RTS_needless, no MICHDR
1122 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1123 cbMICHDR
+ sizeof(struct vnt_tx_datahead_ab
);
1127 if (bRTS
== true) {//RTS_need
1128 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1129 cbMICHDR
+ sizeof(struct vnt_rts_a_fb
);
1131 else if (bRTS
== false) { //RTS_needless
1132 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1133 cbMICHDR
+ sizeof(struct vnt_tx_datahead_a_fb
);
1138 pbyMacHdr
= (u8
*)(pbyTxBufferAddr
+ cbHeaderLength
);
1139 pbyIVHead
= (u8
*)(pbyMacHdr
+ cbMACHdLen
+ uPadding
);
1140 pbyPayloadHead
= (u8
*)(pbyMacHdr
+ cbMACHdLen
+ uPadding
+ cbIVlen
);
1142 //=========================
1144 //=========================
1145 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"No Fragmentation...\n");
1146 byFragType
= FRAGCTL_NONFRAG
;
1147 //uDMAIdx = TYPE_AC0DMA;
1148 //pTxBufHead = (PSTxBufHead) &(pTxBufHead->adwTxKey[0]);
1150 /* Fill FIFO, RrvTime, RTS and CTS */
1151 uDuration
= s_vGenerateTxParameter(pDevice
, byPktType
, wCurrentRate
,
1152 tx_buffer
, &pMICHDR
, cbMICHDR
,
1153 cbFrameSize
, bNeedACK
, uDMAIdx
, psEthHeader
, bRTS
);
1155 // Generate TX MAC Header
1156 s_vGenerateMACHeader(pDevice
, pbyMacHdr
, (u16
)uDuration
, psEthHeader
, bNeedEncryption
,
1157 byFragType
, uDMAIdx
, 0);
1159 if (bNeedEncryption
== true) {
1161 s_vFillTxKey(pDevice
, pTxBufHead
, pbyIVHead
, pTransmitKey
,
1162 pbyMacHdr
, (u16
)cbFrameBodySize
, pMICHDR
);
1164 if (pDevice
->bEnableHostWEP
) {
1165 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
1166 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
1171 if (ntohs(psEthHeader
->h_proto
) > ETH_DATA_LEN
) {
1172 if ((psEthHeader
->h_proto
== cpu_to_be16(ETH_P_IPX
)) ||
1173 (psEthHeader
->h_proto
== cpu_to_le16(0xF380)))
1174 memcpy((u8
*) (pbyPayloadHead
),
1175 abySNAP_Bridgetunnel
, 6);
1177 memcpy((u8
*) (pbyPayloadHead
), &abySNAP_RFC1042
[0], 6);
1179 pbyType
= (u8
*) (pbyPayloadHead
+ 6);
1181 memcpy(pbyType
, &(psEthHeader
->h_proto
), sizeof(u16
));
1184 if (pPacket
!= NULL
) {
1185 // Copy the Packet into a tx Buffer
1186 memcpy((pbyPayloadHead
+ cb802_1_H_len
),
1187 (pPacket
+ ETH_HLEN
),
1188 uSkbPacketLen
- ETH_HLEN
1192 // while bRelayPacketSend psEthHeader is point to header+payload
1193 memcpy((pbyPayloadHead
+ cb802_1_H_len
), ((u8
*)psEthHeader
) + ETH_HLEN
, uSkbPacketLen
- ETH_HLEN
);
1196 if ((bNeedEncryption
== true) && (pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
1198 ///////////////////////////////////////////////////////////////////
1200 if (pDevice
->vnt_mgmt
.eAuthenMode
== WMAC_AUTH_WPANONE
) {
1201 dwMICKey0
= *(u32
*)(&pTransmitKey
->abyKey
[16]);
1202 dwMICKey1
= *(u32
*)(&pTransmitKey
->abyKey
[20]);
1204 else if ((pTransmitKey
->dwKeyIndex
& AUTHENTICATOR_KEY
) != 0) {
1205 dwMICKey0
= *(u32
*)(&pTransmitKey
->abyKey
[16]);
1206 dwMICKey1
= *(u32
*)(&pTransmitKey
->abyKey
[20]);
1209 dwMICKey0
= *(u32
*)(&pTransmitKey
->abyKey
[24]);
1210 dwMICKey1
= *(u32
*)(&pTransmitKey
->abyKey
[28]);
1212 // DO Software Michael
1213 MIC_vInit(dwMICKey0
, dwMICKey1
);
1214 MIC_vAppend((u8
*)&(psEthHeader
->h_dest
[0]), 12);
1216 MIC_vAppend((u8
*)&dwMIC_Priority
, 4);
1217 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MIC KEY: %X, %X\n",
1218 dwMICKey0
, dwMICKey1
);
1220 ///////////////////////////////////////////////////////////////////
1222 //DBG_PRN_GRP12(("Length:%d, %d\n", cbFrameBodySize, uFromHDtoPLDLength));
1223 //for (ii = 0; ii < cbFrameBodySize; ii++) {
1224 // DBG_PRN_GRP12(("%02x ", *((u8 *)((pbyPayloadHead + cb802_1_H_len) + ii))));
1226 //DBG_PRN_GRP12(("\n\n\n"));
1228 MIC_vAppend(pbyPayloadHead
, cbFrameBodySize
);
1230 pdwMIC_L
= (u32
*)(pbyPayloadHead
+ cbFrameBodySize
);
1231 pdwMIC_R
= (u32
*)(pbyPayloadHead
+ cbFrameBodySize
+ 4);
1233 MIC_vGetMIC(pdwMIC_L
, pdwMIC_R
);
1236 if (pDevice
->bTxMICFail
== true) {
1239 pDevice
->bTxMICFail
= false;
1241 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize);
1242 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderLength, uPadding, cbIVlen);
1243 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R);
1246 if (bSoftWEP
== true) {
1248 s_vSWencryption(pDevice
, pTransmitKey
, (pbyPayloadHead
), (u16
)(cbFrameBodySize
+ cbMIClen
));
1250 } else if ( ((pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) && (bNeedEncryption
== true)) ||
1251 ((pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) && (bNeedEncryption
== true)) ||
1252 ((pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) && (bNeedEncryption
== true)) ) {
1253 cbFrameSize
-= cbICVlen
;
1256 cbFrameSize
-= cbFCSlen
;
1258 *pcbHeaderLen
= cbHeaderLength
;
1259 *pcbTotalLen
= cbHeaderLength
+ cbFrameSize
;
1261 //Set FragCtl in TxBufferHead
1262 pTxBufHead
->wFragCtl
|= (u16
)byFragType
;
1271 * Translate 802.3 to 802.11 header
1275 * pDevice - Pointer to adapter
1276 * dwTxBufferAddr - Transmit Buffer
1277 * pPacket - Packet from upper layer
1278 * cbPacketSize - Transmit Data Length
1280 * pcbHeadSize - Header size of MAC&Baseband control and 802.11 Header
1281 * pcbAppendPayload - size of append payload for 802.1H translation
1283 * Return Value: none
1287 static void s_vGenerateMACHeader(struct vnt_private
*pDevice
,
1288 u8
*pbyBufferAddr
, u16 wDuration
, struct ethhdr
*psEthHeader
,
1289 int bNeedEncrypt
, u16 wFragType
, u32 uDMAIdx
, u32 uFragIdx
)
1291 struct ieee80211_hdr
*pMACHeader
= (struct ieee80211_hdr
*)pbyBufferAddr
;
1293 pMACHeader
->frame_control
= TYPE_802_11_DATA
;
1295 if (pDevice
->eOPMode
== OP_MODE_AP
) {
1296 memcpy(&(pMACHeader
->addr1
[0]),
1297 &(psEthHeader
->h_dest
[0]),
1299 memcpy(&(pMACHeader
->addr2
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
1300 memcpy(&(pMACHeader
->addr3
[0]),
1301 &(psEthHeader
->h_source
[0]),
1303 pMACHeader
->frame_control
|= FC_FROMDS
;
1305 if (pDevice
->eOPMode
== OP_MODE_ADHOC
) {
1306 memcpy(&(pMACHeader
->addr1
[0]),
1307 &(psEthHeader
->h_dest
[0]),
1309 memcpy(&(pMACHeader
->addr2
[0]),
1310 &(psEthHeader
->h_source
[0]),
1312 memcpy(&(pMACHeader
->addr3
[0]),
1313 &(pDevice
->abyBSSID
[0]),
1316 memcpy(&(pMACHeader
->addr3
[0]),
1317 &(psEthHeader
->h_dest
[0]),
1319 memcpy(&(pMACHeader
->addr2
[0]),
1320 &(psEthHeader
->h_source
[0]),
1322 memcpy(&(pMACHeader
->addr1
[0]),
1323 &(pDevice
->abyBSSID
[0]),
1325 pMACHeader
->frame_control
|= FC_TODS
;
1330 pMACHeader
->frame_control
|= cpu_to_le16((u16
)WLAN_SET_FC_ISWEP(1));
1332 pMACHeader
->duration_id
= cpu_to_le16(wDuration
);
1334 pMACHeader
->seq_ctrl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
1336 //Set FragNumber in Sequence Control
1337 pMACHeader
->seq_ctrl
|= cpu_to_le16((u16
)uFragIdx
);
1339 if ((wFragType
== FRAGCTL_ENDFRAG
) || (wFragType
== FRAGCTL_NONFRAG
)) {
1340 pDevice
->wSeqCounter
++;
1341 if (pDevice
->wSeqCounter
> 0x0fff)
1342 pDevice
->wSeqCounter
= 0;
1345 if ((wFragType
== FRAGCTL_STAFRAG
) || (wFragType
== FRAGCTL_MIDFRAG
)) { //StartFrag or MidFrag
1346 pMACHeader
->frame_control
|= FC_MOREFRAG
;
1353 * Request instructs a MAC to transmit a 802.11 management packet through
1354 * the adapter onto the medium.
1358 * hDeviceContext - Pointer to the adapter
1359 * pPacket - A pointer to a descriptor for the packet to transmit
1363 * Return Value: CMD_STATUS_PENDING if MAC Tx resource available; otherwise false
1367 CMD_STATUS
csMgmt_xmit(struct vnt_private
*pDevice
,
1368 struct vnt_tx_mgmt
*pPacket
)
1370 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1371 struct vnt_tx_buffer
*pTX_Buffer
;
1372 struct vnt_usb_send_context
*pContext
;
1373 struct vnt_tx_fifo_head
*pTxBufHead
;
1374 struct ieee80211_hdr
*pMACHeader
;
1375 struct ethhdr sEthHeader
;
1376 u8 byPktType
, *pbyTxBufferAddr
;
1377 struct vnt_mic_hdr
*pMICHDR
= NULL
;
1378 u32 uDuration
, cbReqCount
, cbHeaderSize
, cbFrameBodySize
, cbFrameSize
;
1379 int bNeedACK
, bIsPSPOLL
= false;
1380 u32 cbIVlen
= 0, cbICVlen
= 0, cbMIClen
= 0, cbFCSlen
= 4;
1384 u16 wCurrentRate
= RATE_1M
;
1386 pContext
= s_vGetFreeContext(pDevice
);
1388 if (NULL
== pContext
) {
1389 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"ManagementSend TX...NO CONTEXT!\n");
1390 return CMD_STATUS_RESOURCES
;
1393 pTX_Buffer
= (struct vnt_tx_buffer
*)&pContext
->Data
[0];
1394 cbFrameBodySize
= pPacket
->cbPayloadLen
;
1395 pTxBufHead
= &pTX_Buffer
->fifo_head
;
1396 pbyTxBufferAddr
= (u8
*)&pTxBufHead
->adwTxKey
[0];
1397 wTxBufSize
= sizeof(struct vnt_tx_fifo_head
);
1399 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1400 wCurrentRate
= RATE_6M
;
1401 byPktType
= PK_TYPE_11A
;
1403 wCurrentRate
= RATE_1M
;
1404 byPktType
= PK_TYPE_11B
;
1407 // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
1408 // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
1409 // And cmd timer will wait data pkt TX finish before scanning so it's OK
1410 // to set power here.
1411 if (pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
1412 RFbSetPower(pDevice
, wCurrentRate
, pDevice
->byCurrentCh
);
1414 RFbSetPower(pDevice
, wCurrentRate
, pMgmt
->uCurrChannel
);
1416 pDevice
->wCurrentRate
= wCurrentRate
;
1419 if (byPktType
== PK_TYPE_11A
) {//0000 0000 0000 0000
1420 pTxBufHead
->wFIFOCtl
= 0;
1422 else if (byPktType
== PK_TYPE_11B
) {//0000 0001 0000 0000
1423 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11B
;
1425 else if (byPktType
== PK_TYPE_11GB
) {//0000 0010 0000 0000
1426 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GB
;
1428 else if (byPktType
== PK_TYPE_11GA
) {//0000 0011 0000 0000
1429 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GA
;
1432 pTxBufHead
->wFIFOCtl
|= FIFOCTL_TMOEN
;
1433 pTxBufHead
->wTimeStamp
= cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us
);
1435 if (is_multicast_ether_addr(pPacket
->p80211Header
->sA3
.abyAddr1
)) {
1440 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
1443 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
1444 (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) ) {
1446 pTxBufHead
->wFIFOCtl
|= FIFOCTL_LRETRY
;
1447 //Set Preamble type always long
1448 //pDevice->byPreambleType = PREAMBLE_LONG;
1449 // probe-response don't retry
1450 //if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
1451 // bNeedACK = false;
1452 // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
1456 pTxBufHead
->wFIFOCtl
|= (FIFOCTL_GENINT
| FIFOCTL_ISDMA0
);
1458 if ((pPacket
->p80211Header
->sA4
.wFrameCtl
& TYPE_SUBTYPE_MASK
) == TYPE_CTL_PSPOLL
) {
1460 cbMacHdLen
= WLAN_HDR_ADDR2_LEN
;
1462 cbMacHdLen
= WLAN_HDR_ADDR3_LEN
;
1465 //Set FRAGCTL_MACHDCNT
1466 pTxBufHead
->wFragCtl
|= cpu_to_le16((u16
)(cbMacHdLen
<< 10));
1469 // Although spec says MMPDU can be fragmented; In most case,
1470 // no one will send a MMPDU under fragmentation. With RTS may occur.
1472 if (WLAN_GET_FC_ISWEP(pPacket
->p80211Header
->sA4
.wFrameCtl
) != 0) {
1473 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) {
1476 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
1478 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
1479 cbIVlen
= 8;//IV+ExtIV
1482 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
1483 //We need to get seed here for filling TxKey entry.
1484 //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
1485 // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
1487 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
1488 cbIVlen
= 8;//RSN Header
1490 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
1492 //MAC Header should be padding 0 to DW alignment.
1493 uPadding
= 4 - (cbMacHdLen
%4);
1497 cbFrameSize
= cbMacHdLen
+ cbFrameBodySize
+ cbIVlen
+ cbMIClen
+ cbICVlen
+ cbFCSlen
;
1499 //Set FIFOCTL_GrpAckPolicy
1500 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
1501 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
1503 //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
1505 //Set RrvTime/RTS/CTS Buffer
1506 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
1507 cbHeaderSize
= wTxBufSize
+ sizeof(struct vnt_rrv_time_cts
) +
1508 sizeof(struct vnt_cts
);
1510 else { // 802.11a/b packet
1511 cbHeaderSize
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1512 sizeof(struct vnt_tx_datahead_ab
);
1515 memcpy(&(sEthHeader
.h_dest
[0]),
1516 &(pPacket
->p80211Header
->sA3
.abyAddr1
[0]),
1518 memcpy(&(sEthHeader
.h_source
[0]),
1519 &(pPacket
->p80211Header
->sA3
.abyAddr2
[0]),
1521 //=========================
1523 //=========================
1524 pTxBufHead
->wFragCtl
|= (u16
)FRAGCTL_NONFRAG
;
1526 /* Fill FIFO,RrvTime,RTS,and CTS */
1527 uDuration
= s_vGenerateTxParameter(pDevice
, byPktType
, wCurrentRate
,
1528 pTX_Buffer
, &pMICHDR
, 0,
1529 cbFrameSize
, bNeedACK
, TYPE_TXDMA0
, &sEthHeader
, false);
1531 pMACHeader
= (struct ieee80211_hdr
*) (pbyTxBufferAddr
+ cbHeaderSize
);
1533 cbReqCount
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
+ cbFrameBodySize
;
1535 if (WLAN_GET_FC_ISWEP(pPacket
->p80211Header
->sA4
.wFrameCtl
) != 0) {
1537 u8
* pbyPayloadHead
;
1539 PSKeyItem pTransmitKey
= NULL
;
1541 pbyIVHead
= (u8
*)(pbyTxBufferAddr
+ cbHeaderSize
+ cbMacHdLen
+ uPadding
);
1542 pbyPayloadHead
= (u8
*)(pbyTxBufferAddr
+ cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
);
1544 if ((pDevice
->eOPMode
== OP_MODE_INFRASTRUCTURE
) &&
1545 (pDevice
->bLinkPass
== true)) {
1546 pbyBSSID
= pDevice
->abyBSSID
;
1548 if (KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == false) {
1550 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == true) {
1551 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get GTK.\n");
1555 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get PTK.\n");
1560 pbyBSSID
= pDevice
->abyBroadcastAddr
;
1561 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == false) {
1562 pTransmitKey
= NULL
;
1563 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"KEY is NULL. OP Mode[%d]\n", pDevice
->eOPMode
);
1565 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get GTK.\n");
1569 s_vFillTxKey(pDevice
, pTxBufHead
, pbyIVHead
, pTransmitKey
,
1570 (u8
*)pMACHeader
, (u16
)cbFrameBodySize
, NULL
);
1572 memcpy(pMACHeader
, pPacket
->p80211Header
, cbMacHdLen
);
1573 memcpy(pbyPayloadHead
, ((u8
*)(pPacket
->p80211Header
) + cbMacHdLen
),
1577 // Copy the Packet into a tx Buffer
1578 memcpy(pMACHeader
, pPacket
->p80211Header
, pPacket
->cbMPDULen
);
1581 pMACHeader
->seq_ctrl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
1582 pDevice
->wSeqCounter
++ ;
1583 if (pDevice
->wSeqCounter
> 0x0fff)
1584 pDevice
->wSeqCounter
= 0;
1587 // The MAC will automatically replace the Duration-field of MAC header by Duration-field
1588 // of FIFO control header.
1589 // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
1590 // in the same place of other packet's Duration-field).
1591 // And it will cause Cisco-AP to issue Disassociation-packet
1592 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
1593 struct vnt_tx_datahead_g
*data_head
= &pTX_Buffer
->tx_head
.
1594 tx_cts
.tx
.head
.cts_g
.data_head
;
1595 data_head
->wDuration_a
=
1596 cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
1597 data_head
->wDuration_b
=
1598 cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
1600 struct vnt_tx_datahead_ab
*data_head
= &pTX_Buffer
->tx_head
.
1601 tx_ab
.tx
.head
.data_head_ab
;
1602 data_head
->wDuration
=
1603 cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
1607 pTX_Buffer
->wTxByteCount
= cpu_to_le16((u16
)(cbReqCount
));
1608 pTX_Buffer
->byPKTNO
= (u8
) (((wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
1609 pTX_Buffer
->byType
= 0x00;
1611 pContext
->pPacket
= NULL
;
1612 pContext
->Type
= CONTEXT_MGMT_PACKET
;
1613 pContext
->uBufLen
= (u16
)cbReqCount
+ 4; //USB header
1615 if (WLAN_GET_FC_TODS(pMACHeader
->frame_control
) == 0) {
1616 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
1617 &pMACHeader
->addr1
[0], (u16
)cbFrameSize
,
1618 pTxBufHead
->wFIFOCtl
);
1621 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
1622 &pMACHeader
->addr3
[0], (u16
)cbFrameSize
,
1623 pTxBufHead
->wFIFOCtl
);
1626 PIPEnsSendBulkOut(pDevice
,pContext
);
1627 return CMD_STATUS_PENDING
;
1630 CMD_STATUS
csBeacon_xmit(struct vnt_private
*pDevice
,
1631 struct vnt_tx_mgmt
*pPacket
)
1633 struct vnt_beacon_buffer
*pTX_Buffer
;
1634 struct vnt_tx_short_buf_head
*short_head
;
1635 u32 cbFrameSize
= pPacket
->cbMPDULen
+ WLAN_FCS_LEN
;
1636 u32 cbHeaderSize
= 0;
1637 struct ieee80211_hdr
*pMACHeader
;
1639 u32 cbFrameBodySize
;
1641 struct vnt_usb_send_context
*pContext
;
1644 pContext
= s_vGetFreeContext(pDevice
);
1645 if (NULL
== pContext
) {
1646 status
= CMD_STATUS_RESOURCES
;
1647 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"ManagementSend TX...NO CONTEXT!\n");
1651 pTX_Buffer
= (struct vnt_beacon_buffer
*)&pContext
->Data
[0];
1652 short_head
= &pTX_Buffer
->short_head
;
1654 cbFrameBodySize
= pPacket
->cbPayloadLen
;
1656 cbHeaderSize
= sizeof(struct vnt_tx_short_buf_head
);
1658 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1659 wCurrentRate
= RATE_6M
;
1661 /* Get SignalField,ServiceField,Length */
1662 BBvCalculateParameter(pDevice
, cbFrameSize
, wCurrentRate
,
1663 PK_TYPE_11A
, &short_head
->ab
);
1665 /* Get Duration and TimeStampOff */
1666 short_head
->duration
= s_uGetDataDuration(pDevice
,
1667 PK_TYPE_11A
, false);
1668 short_head
->time_stamp_off
=
1669 vnt_time_stamp_off(pDevice
, wCurrentRate
);
1671 wCurrentRate
= RATE_1M
;
1672 short_head
->fifo_ctl
|= FIFOCTL_11B
;
1674 /* Get SignalField,ServiceField,Length */
1675 BBvCalculateParameter(pDevice
, cbFrameSize
, wCurrentRate
,
1676 PK_TYPE_11B
, &short_head
->ab
);
1678 /* Get Duration and TimeStampOff */
1679 short_head
->duration
= s_uGetDataDuration(pDevice
,
1680 PK_TYPE_11B
, false);
1681 short_head
->time_stamp_off
=
1682 vnt_time_stamp_off(pDevice
, wCurrentRate
);
1686 /* Generate Beacon Header */
1687 pMACHeader
= &pTX_Buffer
->hdr
;
1689 memcpy(pMACHeader
, pPacket
->p80211Header
, pPacket
->cbMPDULen
);
1691 pMACHeader
->duration_id
= 0;
1692 pMACHeader
->seq_ctrl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
1693 pDevice
->wSeqCounter
++;
1694 if (pDevice
->wSeqCounter
> 0x0fff)
1695 pDevice
->wSeqCounter
= 0;
1697 cbReqCount
= cbHeaderSize
+ WLAN_HDR_ADDR3_LEN
+ cbFrameBodySize
;
1699 pTX_Buffer
->wTxByteCount
= (u16
)cbReqCount
;
1700 pTX_Buffer
->byPKTNO
= (u8
) (((wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
1701 pTX_Buffer
->byType
= 0x01;
1703 pContext
->pPacket
= NULL
;
1704 pContext
->Type
= CONTEXT_MGMT_PACKET
;
1705 pContext
->uBufLen
= (u16
)cbReqCount
+ 4; //USB header
1707 PIPEnsSendBulkOut(pDevice
,pContext
);
1708 return CMD_STATUS_PENDING
;
1712 void vDMA0_tx_80211(struct vnt_private
*pDevice
, struct sk_buff
*skb
)
1714 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1715 struct vnt_tx_buffer
*pTX_Buffer
;
1716 struct vnt_tx_fifo_head
*pTxBufHead
;
1718 u8
*pbyTxBufferAddr
;
1719 u32 uDuration
, cbReqCount
;
1720 struct ieee80211_hdr
*pMACHeader
;
1721 u32 cbHeaderSize
, cbFrameBodySize
;
1722 int bNeedACK
, bIsPSPOLL
= false;
1724 u32 cbIVlen
= 0, cbICVlen
= 0, cbMIClen
= 0, cbFCSlen
= 4;
1726 u32 cbMICHDR
= 0, uLength
= 0;
1727 u32 dwMICKey0
, dwMICKey1
;
1729 u32
*pdwMIC_L
, *pdwMIC_R
;
1732 struct ethhdr sEthHeader
;
1733 struct vnt_mic_hdr
*pMICHDR
;
1734 u32 wCurrentRate
= RATE_1M
;
1735 PUWLAN_80211HDR p80211Header
;
1737 int bNodeExist
= false;
1739 PSKeyItem pTransmitKey
= NULL
;
1740 u8
*pbyIVHead
, *pbyPayloadHead
, *pbyMacHdr
;
1741 u32 cbExtSuppRate
= 0;
1742 struct vnt_usb_send_context
*pContext
;
1746 if(skb
->len
<= WLAN_HDR_ADDR3_LEN
) {
1747 cbFrameBodySize
= 0;
1750 cbFrameBodySize
= skb
->len
- WLAN_HDR_ADDR3_LEN
;
1752 p80211Header
= (PUWLAN_80211HDR
)skb
->data
;
1754 pContext
= s_vGetFreeContext(pDevice
);
1756 if (NULL
== pContext
) {
1757 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"DMA0 TX...NO CONTEXT!\n");
1758 dev_kfree_skb_irq(skb
);
1762 pTX_Buffer
= (struct vnt_tx_buffer
*)&pContext
->Data
[0];
1763 pTxBufHead
= &pTX_Buffer
->fifo_head
;
1764 pbyTxBufferAddr
= (u8
*)&pTxBufHead
->adwTxKey
[0];
1765 wTxBufSize
= sizeof(struct vnt_tx_fifo_head
);
1767 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1768 wCurrentRate
= RATE_6M
;
1769 byPktType
= PK_TYPE_11A
;
1771 wCurrentRate
= RATE_1M
;
1772 byPktType
= PK_TYPE_11B
;
1775 // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
1776 // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
1777 // And cmd timer will wait data pkt TX finish before scanning so it's OK
1778 // to set power here.
1779 if (pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
1780 RFbSetPower(pDevice
, wCurrentRate
, pDevice
->byCurrentCh
);
1782 RFbSetPower(pDevice
, wCurrentRate
, pMgmt
->uCurrChannel
);
1785 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header
->sA3
.wFrameCtl
);
1788 if (byPktType
== PK_TYPE_11A
) {//0000 0000 0000 0000
1789 pTxBufHead
->wFIFOCtl
= 0;
1791 else if (byPktType
== PK_TYPE_11B
) {//0000 0001 0000 0000
1792 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11B
;
1794 else if (byPktType
== PK_TYPE_11GB
) {//0000 0010 0000 0000
1795 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GB
;
1797 else if (byPktType
== PK_TYPE_11GA
) {//0000 0011 0000 0000
1798 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GA
;
1801 pTxBufHead
->wFIFOCtl
|= FIFOCTL_TMOEN
;
1802 pTxBufHead
->wTimeStamp
= cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us
);
1804 if (is_multicast_ether_addr(p80211Header
->sA3
.abyAddr1
)) {
1806 if (pDevice
->bEnableHostWEP
) {
1812 if (pDevice
->bEnableHostWEP
) {
1813 if (BSSbIsSTAInNodeDB(pDevice
, (u8
*)(p80211Header
->sA3
.abyAddr1
), &uNodeIndex
))
1817 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
1820 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
1821 (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) ) {
1823 pTxBufHead
->wFIFOCtl
|= FIFOCTL_LRETRY
;
1824 //Set Preamble type always long
1825 //pDevice->byPreambleType = PREAMBLE_LONG;
1827 // probe-response don't retry
1828 //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
1829 // bNeedACK = false;
1830 // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
1834 pTxBufHead
->wFIFOCtl
|= (FIFOCTL_GENINT
| FIFOCTL_ISDMA0
);
1836 if ((p80211Header
->sA4
.wFrameCtl
& TYPE_SUBTYPE_MASK
) == TYPE_CTL_PSPOLL
) {
1838 cbMacHdLen
= WLAN_HDR_ADDR2_LEN
;
1840 cbMacHdLen
= WLAN_HDR_ADDR3_LEN
;
1843 // hostapd daemon ext support rate patch
1844 if (WLAN_GET_FC_FSTYPE(p80211Header
->sA4
.wFrameCtl
) == WLAN_FSTYPE_ASSOCRESP
) {
1846 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
!= 0) {
1847 cbExtSuppRate
+= ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
1850 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
!= 0) {
1851 cbExtSuppRate
+= ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
1854 if (cbExtSuppRate
>0) {
1855 cbFrameBodySize
= WLAN_ASSOCRESP_OFF_SUPP_RATES
;
1859 //Set FRAGCTL_MACHDCNT
1860 pTxBufHead
->wFragCtl
|= cpu_to_le16((u16
)cbMacHdLen
<< 10);
1863 // Although spec says MMPDU can be fragmented; In most case,
1864 // no one will send a MMPDU under fragmentation. With RTS may occur.
1866 if (WLAN_GET_FC_ISWEP(p80211Header
->sA4
.wFrameCtl
) != 0) {
1867 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) {
1870 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
1872 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
1873 cbIVlen
= 8;//IV+ExtIV
1876 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
1877 //We need to get seed here for filling TxKey entry.
1878 //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
1879 // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
1881 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
1882 cbIVlen
= 8;//RSN Header
1884 cbMICHDR
= sizeof(struct vnt_mic_hdr
);
1885 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
1887 //MAC Header should be padding 0 to DW alignment.
1888 uPadding
= 4 - (cbMacHdLen
%4);
1892 cbFrameSize
= cbMacHdLen
+ cbFrameBodySize
+ cbIVlen
+ cbMIClen
+ cbICVlen
+ cbFCSlen
+ cbExtSuppRate
;
1894 //Set FIFOCTL_GrpAckPolicy
1895 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
1896 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
1898 //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
1900 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
1901 cbHeaderSize
= wTxBufSize
+ sizeof(struct vnt_rrv_time_cts
) + cbMICHDR
+
1902 sizeof(struct vnt_cts
);
1905 else {//802.11a/b packet
1906 cbHeaderSize
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) + cbMICHDR
+
1907 sizeof(struct vnt_tx_datahead_ab
);
1909 memcpy(&(sEthHeader
.h_dest
[0]),
1910 &(p80211Header
->sA3
.abyAddr1
[0]),
1912 memcpy(&(sEthHeader
.h_source
[0]),
1913 &(p80211Header
->sA3
.abyAddr2
[0]),
1915 //=========================
1917 //=========================
1918 pTxBufHead
->wFragCtl
|= (u16
)FRAGCTL_NONFRAG
;
1920 /* Fill FIFO,RrvTime,RTS,and CTS */
1921 uDuration
= s_vGenerateTxParameter(pDevice
, byPktType
, wCurrentRate
,
1922 pTX_Buffer
, &pMICHDR
, cbMICHDR
,
1923 cbFrameSize
, bNeedACK
, TYPE_TXDMA0
, &sEthHeader
, false);
1925 pMACHeader
= (struct ieee80211_hdr
*) (pbyTxBufferAddr
+ cbHeaderSize
);
1927 cbReqCount
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
+ (cbFrameBodySize
+ cbMIClen
) + cbExtSuppRate
;
1929 pbyMacHdr
= (u8
*)(pbyTxBufferAddr
+ cbHeaderSize
);
1930 pbyPayloadHead
= (u8
*)(pbyMacHdr
+ cbMacHdLen
+ uPadding
+ cbIVlen
);
1931 pbyIVHead
= (u8
*)(pbyMacHdr
+ cbMacHdLen
+ uPadding
);
1933 // Copy the Packet into a tx Buffer
1934 memcpy(pbyMacHdr
, skb
->data
, cbMacHdLen
);
1936 // version set to 0, patch for hostapd deamon
1937 pMACHeader
->frame_control
&= cpu_to_le16(0xfffc);
1938 memcpy(pbyPayloadHead
, (skb
->data
+ cbMacHdLen
), cbFrameBodySize
);
1940 // replace support rate, patch for hostapd daemon( only support 11M)
1941 if (WLAN_GET_FC_FSTYPE(p80211Header
->sA4
.wFrameCtl
) == WLAN_FSTYPE_ASSOCRESP
) {
1942 if (cbExtSuppRate
!= 0) {
1943 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
!= 0)
1944 memcpy((pbyPayloadHead
+ cbFrameBodySize
),
1945 pMgmt
->abyCurrSuppRates
,
1946 ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
1948 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
!= 0)
1949 memcpy((pbyPayloadHead
+ cbFrameBodySize
) + ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
,
1950 pMgmt
->abyCurrExtSuppRates
,
1951 ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
1957 if (WLAN_GET_FC_ISWEP(p80211Header
->sA4
.wFrameCtl
) != 0) {
1959 if (pDevice
->bEnableHostWEP
) {
1960 pTransmitKey
= &STempKey
;
1961 pTransmitKey
->byCipherSuite
= pMgmt
->sNodeDBTable
[uNodeIndex
].byCipherSuite
;
1962 pTransmitKey
->dwKeyIndex
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
;
1963 pTransmitKey
->uKeyLength
= pMgmt
->sNodeDBTable
[uNodeIndex
].uWepKeyLength
;
1964 pTransmitKey
->dwTSC47_16
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
;
1965 pTransmitKey
->wTSC15_0
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
;
1966 memcpy(pTransmitKey
->abyKey
,
1967 &pMgmt
->sNodeDBTable
[uNodeIndex
].abyWepKey
[0],
1968 pTransmitKey
->uKeyLength
1972 if ((pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
1974 dwMICKey0
= *(u32
*)(&pTransmitKey
->abyKey
[16]);
1975 dwMICKey1
= *(u32
*)(&pTransmitKey
->abyKey
[20]);
1977 // DO Software Michael
1978 MIC_vInit(dwMICKey0
, dwMICKey1
);
1979 MIC_vAppend((u8
*)&(sEthHeader
.h_dest
[0]), 12);
1981 MIC_vAppend((u8
*)&dwMIC_Priority
, 4);
1982 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"DMA0_tx_8021:MIC KEY:"\
1983 " %X, %X\n", dwMICKey0
, dwMICKey1
);
1985 uLength
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
;
1987 MIC_vAppend((pbyTxBufferAddr
+ uLength
), cbFrameBodySize
);
1989 pdwMIC_L
= (u32
*)(pbyTxBufferAddr
+ uLength
+ cbFrameBodySize
);
1990 pdwMIC_R
= (u32
*)(pbyTxBufferAddr
+ uLength
+ cbFrameBodySize
+ 4);
1992 MIC_vGetMIC(pdwMIC_L
, pdwMIC_R
);
1995 if (pDevice
->bTxMICFail
== true) {
1998 pDevice
->bTxMICFail
= false;
2001 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"uLength: %d, %d\n", uLength
, cbFrameBodySize
);
2002 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"cbReqCount:%d, %d, %d, %d\n", cbReqCount
, cbHeaderSize
, uPadding
, cbIVlen
);
2003 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MIC:%x, %x\n",
2004 *pdwMIC_L
, *pdwMIC_R
);
2008 s_vFillTxKey(pDevice
, pTxBufHead
, pbyIVHead
, pTransmitKey
,
2009 pbyMacHdr
, (u16
)cbFrameBodySize
, pMICHDR
);
2011 if (pDevice
->bEnableHostWEP
) {
2012 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
2013 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
2016 if ((pDevice
->byLocalID
<= REV_ID_VT3253_A1
)) {
2017 s_vSWencryption(pDevice
, pTransmitKey
, pbyPayloadHead
, (u16
)(cbFrameBodySize
+ cbMIClen
));
2021 pMACHeader
->seq_ctrl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
2022 pDevice
->wSeqCounter
++ ;
2023 if (pDevice
->wSeqCounter
> 0x0fff)
2024 pDevice
->wSeqCounter
= 0;
2027 // The MAC will automatically replace the Duration-field of MAC header by Duration-field
2028 // of FIFO control header.
2029 // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
2030 // in the same place of other packet's Duration-field).
2031 // And it will cause Cisco-AP to issue Disassociation-packet
2032 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
2033 struct vnt_tx_datahead_g
*data_head
= &pTX_Buffer
->tx_head
.
2034 tx_cts
.tx
.head
.cts_g
.data_head
;
2035 data_head
->wDuration_a
=
2036 cpu_to_le16(p80211Header
->sA2
.wDurationID
);
2037 data_head
->wDuration_b
=
2038 cpu_to_le16(p80211Header
->sA2
.wDurationID
);
2040 struct vnt_tx_datahead_ab
*data_head
= &pTX_Buffer
->tx_head
.
2041 tx_ab
.tx
.head
.data_head_ab
;
2042 data_head
->wDuration
=
2043 cpu_to_le16(p80211Header
->sA2
.wDurationID
);
2047 pTX_Buffer
->wTxByteCount
= cpu_to_le16((u16
)(cbReqCount
));
2048 pTX_Buffer
->byPKTNO
= (u8
) (((wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
2049 pTX_Buffer
->byType
= 0x00;
2051 pContext
->pPacket
= skb
;
2052 pContext
->Type
= CONTEXT_MGMT_PACKET
;
2053 pContext
->uBufLen
= (u16
)cbReqCount
+ 4; //USB header
2055 if (WLAN_GET_FC_TODS(pMACHeader
->frame_control
) == 0) {
2056 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
2057 &pMACHeader
->addr1
[0], (u16
)cbFrameSize
,
2058 pTxBufHead
->wFIFOCtl
);
2061 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
2062 &pMACHeader
->addr3
[0], (u16
)cbFrameSize
,
2063 pTxBufHead
->wFIFOCtl
);
2065 PIPEnsSendBulkOut(pDevice
,pContext
);
2070 //TYPE_AC0DMA data tx
2073 * Tx packet via AC0DMA(DMA1)
2077 * pDevice - Pointer to the adapter
2078 * skb - Pointer to tx skb packet
2082 * Return Value: NULL
2085 int nsDMA_tx_packet(struct vnt_private
*pDevice
,
2086 u32 uDMAIdx
, struct sk_buff
*skb
)
2088 struct net_device_stats
*pStats
= &pDevice
->stats
;
2089 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2090 struct vnt_tx_buffer
*pTX_Buffer
;
2091 u32 BytesToWrite
= 0, uHeaderLen
= 0;
2093 u8 byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
2096 int bNeedEncryption
= false;
2097 PSKeyItem pTransmitKey
= NULL
;
2100 int bTKIP_UseGTK
= false;
2101 int bNeedDeAuth
= false;
2103 int bNodeExist
= false;
2104 struct vnt_usb_send_context
*pContext
;
2105 bool fConvertedPacket
;
2107 u16 wKeepRate
= pDevice
->wCurrentRate
;
2108 int bTxeapol_key
= false;
2110 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2112 if (pDevice
->uAssocCount
== 0) {
2113 dev_kfree_skb_irq(skb
);
2117 if (is_multicast_ether_addr((u8
*)(skb
->data
))) {
2120 if (pMgmt
->sNodeDBTable
[0].bPSEnable
) {
2122 skb_queue_tail(&(pMgmt
->sNodeDBTable
[0].sTxPSQueue
), skb
);
2123 pMgmt
->sNodeDBTable
[0].wEnQueueCnt
++;
2125 pMgmt
->abyPSTxMap
[0] |= byMask
[0];
2128 // multicast/broadcast data rate
2130 if (pDevice
->byBBType
!= BB_TYPE_11A
)
2131 pDevice
->wCurrentRate
= RATE_2M
;
2133 pDevice
->wCurrentRate
= RATE_24M
;
2134 // long preamble type
2135 pDevice
->byPreambleType
= PREAMBLE_SHORT
;
2139 if (BSSbIsSTAInNodeDB(pDevice
, (u8
*)(skb
->data
), &uNodeIndex
)) {
2141 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
) {
2143 skb_queue_tail(&pMgmt
->sNodeDBTable
[uNodeIndex
].sTxPSQueue
, skb
);
2145 pMgmt
->sNodeDBTable
[uNodeIndex
].wEnQueueCnt
++;
2147 wAID
= pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
;
2148 pMgmt
->abyPSTxMap
[wAID
>> 3] |= byMask
[wAID
& 7];
2149 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set:pMgmt->abyPSTxMap[%d]= %d\n",
2150 (wAID
>> 3), pMgmt
->abyPSTxMap
[wAID
>> 3]);
2154 // AP rate decided from node
2155 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
;
2156 // tx preamble decided from node
2158 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
) {
2159 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2162 pDevice
->byPreambleType
= PREAMBLE_LONG
;
2168 if (bNodeExist
== false) {
2169 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Unknown STA not found in node DB \n");
2170 dev_kfree_skb_irq(skb
);
2175 pContext
= s_vGetFreeContext(pDevice
);
2177 if (pContext
== NULL
) {
2178 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
" pContext == NULL\n");
2179 dev_kfree_skb_irq(skb
);
2180 return STATUS_RESOURCES
;
2183 memcpy(pDevice
->sTxEthHeader
.h_dest
, (u8
*)(skb
->data
), ETH_HLEN
);
2185 //mike add:station mode check eapol-key challenge--->
2187 u8 Protocol_Version
; //802.1x Authentication
2188 u8 Packet_Type
; //802.1x Authentication
2192 Protocol_Version
= skb
->data
[ETH_HLEN
];
2193 Packet_Type
= skb
->data
[ETH_HLEN
+1];
2194 Descriptor_type
= skb
->data
[ETH_HLEN
+1+1+2];
2195 Key_info
= (skb
->data
[ETH_HLEN
+1+1+2+1] << 8)|(skb
->data
[ETH_HLEN
+1+1+2+2]);
2196 if (pDevice
->sTxEthHeader
.h_proto
== cpu_to_be16(ETH_P_PAE
)) {
2197 /* 802.1x OR eapol-key challenge frame transfer */
2198 if (((Protocol_Version
== 1) || (Protocol_Version
== 2)) &&
2199 (Packet_Type
== 3)) {
2200 bTxeapol_key
= true;
2201 if(!(Key_info
& BIT3
) && //WPA or RSN group-key challenge
2202 (Key_info
& BIT8
) && (Key_info
& BIT9
)) { //send 2/2 key
2203 if(Descriptor_type
==254) {
2204 pDevice
->fWPA_Authened
= true;
2208 pDevice
->fWPA_Authened
= true;
2209 PRINT_K("WPA2(re-keying) ");
2211 PRINT_K("Authentication completed!!\n");
2213 else if((Key_info
& BIT3
) && (Descriptor_type
==2) && //RSN pairwise-key challenge
2214 (Key_info
& BIT8
) && (Key_info
& BIT9
)) {
2215 pDevice
->fWPA_Authened
= true;
2216 PRINT_K("WPA2 Authentication completed!!\n");
2221 //mike add:station mode check eapol-key challenge<---
2223 if (pDevice
->bEncryptionEnable
== true) {
2224 bNeedEncryption
= true;
2227 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
2228 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
2229 pbyBSSID
= pDevice
->abyBSSID
;
2231 if (KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == false) {
2233 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == true) {
2234 bTKIP_UseGTK
= true;
2235 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get GTK.\n");
2239 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get PTK.\n");
2242 }else if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2243 /* TO_DS = 0 and FROM_DS = 0 --> 802.11 MAC Address1 */
2244 pbyBSSID
= pDevice
->sTxEthHeader
.h_dest
;
2245 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"IBSS Serach Key: \n");
2246 for (ii
= 0; ii
< 6; ii
++)
2247 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"%x \n", *(pbyBSSID
+ii
));
2248 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"\n");
2251 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == true)
2255 pbyBSSID
= pDevice
->abyBroadcastAddr
;
2256 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == false) {
2257 pTransmitKey
= NULL
;
2258 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2259 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"IBSS and KEY is NULL. [%d]\n", pMgmt
->eCurrMode
);
2262 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"NOT IBSS and KEY is NULL. [%d]\n", pMgmt
->eCurrMode
);
2264 bTKIP_UseGTK
= true;
2265 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get GTK.\n");
2270 if (pDevice
->bEnableHostWEP
) {
2271 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"acdma0: STA index %d\n", uNodeIndex
);
2272 if (pDevice
->bEncryptionEnable
== true) {
2273 pTransmitKey
= &STempKey
;
2274 pTransmitKey
->byCipherSuite
= pMgmt
->sNodeDBTable
[uNodeIndex
].byCipherSuite
;
2275 pTransmitKey
->dwKeyIndex
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
;
2276 pTransmitKey
->uKeyLength
= pMgmt
->sNodeDBTable
[uNodeIndex
].uWepKeyLength
;
2277 pTransmitKey
->dwTSC47_16
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
;
2278 pTransmitKey
->wTSC15_0
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
;
2279 memcpy(pTransmitKey
->abyKey
,
2280 &pMgmt
->sNodeDBTable
[uNodeIndex
].abyWepKey
[0],
2281 pTransmitKey
->uKeyLength
2286 byPktType
= (u8
)pDevice
->byPacketType
;
2288 if (pDevice
->bFixRate
) {
2289 if (pDevice
->byBBType
== BB_TYPE_11B
) {
2290 if (pDevice
->uConnectionRate
>= RATE_11M
) {
2291 pDevice
->wCurrentRate
= RATE_11M
;
2293 pDevice
->wCurrentRate
= (u16
)pDevice
->uConnectionRate
;
2296 if ((pDevice
->byBBType
== BB_TYPE_11A
) &&
2297 (pDevice
->uConnectionRate
<= RATE_6M
)) {
2298 pDevice
->wCurrentRate
= RATE_6M
;
2300 if (pDevice
->uConnectionRate
>= RATE_54M
)
2301 pDevice
->wCurrentRate
= RATE_54M
;
2303 pDevice
->wCurrentRate
= (u16
)pDevice
->uConnectionRate
;
2308 if (pDevice
->eOPMode
== OP_MODE_ADHOC
) {
2309 // Adhoc Tx rate decided from node DB
2310 if (is_multicast_ether_addr(pDevice
->sTxEthHeader
.h_dest
)) {
2311 // Multicast use highest data rate
2312 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[0].wTxDataRate
;
2314 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2317 if (BSSbIsSTAInNodeDB(pDevice
, &(pDevice
->sTxEthHeader
.h_dest
[0]), &uNodeIndex
)) {
2318 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
;
2319 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
) {
2320 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2324 pDevice
->byPreambleType
= PREAMBLE_LONG
;
2326 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Found Node Index is [%d] Tx Data Rate:[%d]\n",uNodeIndex
, pDevice
->wCurrentRate
);
2329 if (pDevice
->byBBType
!= BB_TYPE_11A
)
2330 pDevice
->wCurrentRate
= RATE_2M
;
2332 pDevice
->wCurrentRate
= RATE_24M
; // refer to vMgrCreateOwnIBSS()'s
2333 // abyCurrExtSuppRates[]
2334 pDevice
->byPreambleType
= PREAMBLE_SHORT
;
2335 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Not Found Node use highest basic Rate.....\n");
2339 if (pDevice
->eOPMode
== OP_MODE_INFRASTRUCTURE
) {
2340 // Infra STA rate decided from AP Node, index = 0
2341 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[0].wTxDataRate
;
2345 if (pDevice
->sTxEthHeader
.h_proto
== cpu_to_be16(ETH_P_PAE
)) {
2346 if (pDevice
->byBBType
!= BB_TYPE_11A
) {
2347 pDevice
->wCurrentRate
= RATE_1M
;
2348 pDevice
->byACKRate
= RATE_1M
;
2349 pDevice
->byTopCCKBasicRate
= RATE_1M
;
2350 pDevice
->byTopOFDMBasicRate
= RATE_6M
;
2352 pDevice
->wCurrentRate
= RATE_6M
;
2353 pDevice
->byACKRate
= RATE_6M
;
2354 pDevice
->byTopCCKBasicRate
= RATE_1M
;
2355 pDevice
->byTopOFDMBasicRate
= RATE_6M
;
2359 DBG_PRT(MSG_LEVEL_DEBUG
,
2360 KERN_INFO
"dma_tx: pDevice->wCurrentRate = %d\n",
2361 pDevice
->wCurrentRate
);
2363 if (wKeepRate
!= pDevice
->wCurrentRate
) {
2364 bScheduleCommand((void *) pDevice
, WLAN_CMD_SETPOWER
, NULL
);
2367 if (pDevice
->wCurrentRate
<= RATE_11M
) {
2368 byPktType
= PK_TYPE_11B
;
2371 if (bNeedEncryption
== true) {
2372 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"ntohs Pkt Type=%04x\n", ntohs(pDevice
->sTxEthHeader
.h_proto
));
2373 if ((pDevice
->sTxEthHeader
.h_proto
) == cpu_to_be16(ETH_P_PAE
)) {
2374 bNeedEncryption
= false;
2375 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pkt Type=%04x\n", (pDevice
->sTxEthHeader
.h_proto
));
2376 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
2377 if (pTransmitKey
== NULL
) {
2378 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Don't Find TX KEY\n");
2381 if (bTKIP_UseGTK
== true) {
2382 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"error: KEY is GTK!!~~\n");
2385 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Find PTK [%X]\n",
2386 pTransmitKey
->dwKeyIndex
);
2387 bNeedEncryption
= true;
2392 if (pDevice
->bEnableHostWEP
) {
2393 if ((uNodeIndex
!= 0) &&
2394 (pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
& PAIRWISE_KEY
)) {
2395 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Find PTK [%X]\n",
2396 pTransmitKey
->dwKeyIndex
);
2397 bNeedEncryption
= true;
2403 if (pTransmitKey
== NULL
) {
2404 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return no tx key\n");
2405 pContext
->bBoolInUse
= false;
2406 dev_kfree_skb_irq(skb
);
2407 pStats
->tx_dropped
++;
2408 return STATUS_FAILURE
;
2413 pTX_Buffer
= (struct vnt_tx_buffer
*)&pContext
->Data
[0];
2415 fConvertedPacket
= s_bPacketToWirelessUsb(pDevice
, byPktType
,
2416 pTX_Buffer
, bNeedEncryption
,
2417 skb
->len
, uDMAIdx
, &pDevice
->sTxEthHeader
,
2418 (u8
*)skb
->data
, pTransmitKey
, uNodeIndex
,
2419 pDevice
->wCurrentRate
,
2420 &uHeaderLen
, &BytesToWrite
2423 if (fConvertedPacket
== false) {
2424 pContext
->bBoolInUse
= false;
2425 dev_kfree_skb_irq(skb
);
2426 return STATUS_FAILURE
;
2429 if ( pDevice
->bEnablePSMode
== true ) {
2430 if ( !pDevice
->bPSModeTxBurst
) {
2431 bScheduleCommand((void *) pDevice
,
2432 WLAN_CMD_MAC_DISPOWERSAVING
,
2434 pDevice
->bPSModeTxBurst
= true;
2438 pTX_Buffer
->byPKTNO
= (u8
) (((pDevice
->wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
2439 pTX_Buffer
->wTxByteCount
= (u16
)BytesToWrite
;
2441 pContext
->pPacket
= skb
;
2442 pContext
->Type
= CONTEXT_DATA_PACKET
;
2443 pContext
->uBufLen
= (u16
)BytesToWrite
+ 4 ; //USB header
2445 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
2446 &pContext
->sEthHeader
.h_dest
[0],
2447 (u16
)(BytesToWrite
-uHeaderLen
),
2448 pTX_Buffer
->fifo_head
.wFIFOCtl
);
2450 status
= PIPEnsSendBulkOut(pDevice
,pContext
);
2452 if (bNeedDeAuth
== true) {
2453 u16 wReason
= WLAN_MGMT_REASON_MIC_FAILURE
;
2455 bScheduleCommand((void *) pDevice
, WLAN_CMD_DEAUTH
, (u8
*) &wReason
);
2458 if(status
!=STATUS_PENDING
) {
2459 pContext
->bBoolInUse
= false;
2460 dev_kfree_skb_irq(skb
);
2461 return STATUS_FAILURE
;
2470 * Relay packet send (AC1DMA) from rx dpc.
2474 * pDevice - Pointer to the adapter
2475 * pPacket - Pointer to rx packet
2476 * cbPacketSize - rx ethernet frame size
2480 * Return Value: Return true if packet is copy to dma1; otherwise false
2483 int bRelayPacketSend(struct vnt_private
*pDevice
, u8
*pbySkbData
, u32 uDataLen
,
2486 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2487 struct vnt_tx_buffer
*pTX_Buffer
;
2488 u32 BytesToWrite
= 0, uHeaderLen
= 0;
2489 u8 byPktType
= PK_TYPE_11B
;
2490 int bNeedEncryption
= false;
2492 PSKeyItem pTransmitKey
= NULL
;
2494 struct vnt_usb_send_context
*pContext
;
2496 int fConvertedPacket
;
2498 u16 wKeepRate
= pDevice
->wCurrentRate
;
2500 pContext
= s_vGetFreeContext(pDevice
);
2502 if (NULL
== pContext
) {
2506 memcpy(pDevice
->sTxEthHeader
.h_dest
, (u8
*)pbySkbData
, ETH_HLEN
);
2508 if (pDevice
->bEncryptionEnable
== true) {
2509 bNeedEncryption
= true;
2511 pbyBSSID
= pDevice
->abyBroadcastAddr
;
2512 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == false) {
2513 pTransmitKey
= NULL
;
2514 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"KEY is NULL. [%d]\n", pMgmt
->eCurrMode
);
2516 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get GTK.\n");
2520 if (pDevice
->bEnableHostWEP
) {
2521 if (uNodeIndex
< MAX_NODE_NUM
+ 1) {
2522 pTransmitKey
= &STempKey
;
2523 pTransmitKey
->byCipherSuite
= pMgmt
->sNodeDBTable
[uNodeIndex
].byCipherSuite
;
2524 pTransmitKey
->dwKeyIndex
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
;
2525 pTransmitKey
->uKeyLength
= pMgmt
->sNodeDBTable
[uNodeIndex
].uWepKeyLength
;
2526 pTransmitKey
->dwTSC47_16
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
;
2527 pTransmitKey
->wTSC15_0
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
;
2528 memcpy(pTransmitKey
->abyKey
,
2529 &pMgmt
->sNodeDBTable
[uNodeIndex
].abyWepKey
[0],
2530 pTransmitKey
->uKeyLength
2535 if ( bNeedEncryption
&& (pTransmitKey
== NULL
) ) {
2536 pContext
->bBoolInUse
= false;
2540 byPktTyp
= (u8
)pDevice
->byPacketType
;
2542 if (pDevice
->bFixRate
) {
2543 if (pDevice
->byBBType
== BB_TYPE_11B
) {
2544 if (pDevice
->uConnectionRate
>= RATE_11M
) {
2545 pDevice
->wCurrentRate
= RATE_11M
;
2547 pDevice
->wCurrentRate
= (u16
)pDevice
->uConnectionRate
;
2550 if ((pDevice
->byBBType
== BB_TYPE_11A
) &&
2551 (pDevice
->uConnectionRate
<= RATE_6M
)) {
2552 pDevice
->wCurrentRate
= RATE_6M
;
2554 if (pDevice
->uConnectionRate
>= RATE_54M
)
2555 pDevice
->wCurrentRate
= RATE_54M
;
2557 pDevice
->wCurrentRate
= (u16
)pDevice
->uConnectionRate
;
2562 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
;
2565 if (wKeepRate
!= pDevice
->wCurrentRate
) {
2566 bScheduleCommand((void *) pDevice
, WLAN_CMD_SETPOWER
, NULL
);
2569 if (pDevice
->wCurrentRate
<= RATE_11M
)
2570 byPktType
= PK_TYPE_11B
;
2572 BytesToWrite
= uDataLen
+ ETH_FCS_LEN
;
2574 // Convert the packet to an usb frame and copy into our buffer
2575 // and send the irp.
2577 pTX_Buffer
= (struct vnt_tx_buffer
*)&pContext
->Data
[0];
2579 fConvertedPacket
= s_bPacketToWirelessUsb(pDevice
, byPktType
,
2580 pTX_Buffer
, bNeedEncryption
,
2581 uDataLen
, TYPE_AC0DMA
, &pDevice
->sTxEthHeader
,
2582 pbySkbData
, pTransmitKey
, uNodeIndex
,
2583 pDevice
->wCurrentRate
,
2584 &uHeaderLen
, &BytesToWrite
2587 if (fConvertedPacket
== false) {
2588 pContext
->bBoolInUse
= false;
2592 pTX_Buffer
->byPKTNO
= (u8
) (((pDevice
->wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
2593 pTX_Buffer
->wTxByteCount
= (u16
)BytesToWrite
;
2595 pContext
->pPacket
= NULL
;
2596 pContext
->Type
= CONTEXT_DATA_PACKET
;
2597 pContext
->uBufLen
= (u16
)BytesToWrite
+ 4 ; //USB header
2599 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
2600 &pContext
->sEthHeader
.h_dest
[0],
2601 (u16
)(BytesToWrite
- uHeaderLen
),
2602 pTX_Buffer
->fifo_head
.wFIFOCtl
);
2604 status
= PIPEnsSendBulkOut(pDevice
,pContext
);