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 __le16
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 __le16
s_uGetDataDuration(struct vnt_private
*pDevice
,
133 u8 byPktType
, int bNeedAck
);
135 static __le16
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 __le16
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 __le16
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 __le16
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
;
405 return cpu_to_le16((u16
)rrv_time
);
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 __le16
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 __le16
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
->duration_a
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
485 buf
->duration_b
= s_uGetDataDuration(priv
, PK_TYPE_11B
, need_ack
);
487 buf
->time_stamp_off_a
= vnt_time_stamp_off(priv
, rate
);
488 buf
->time_stamp_off_b
= vnt_time_stamp_off(priv
,
489 priv
->byTopCCKBasicRate
);
491 return le16_to_cpu(buf
->duration_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
->duration_a
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
506 buf
->duration_b
= s_uGetDataDuration(priv
, PK_TYPE_11B
, need_ack
);
508 buf
->duration_a_f0
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
509 buf
->duration_a_f1
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
511 buf
->time_stamp_off_a
= vnt_time_stamp_off(priv
, rate
);
512 buf
->time_stamp_off_b
= vnt_time_stamp_off(priv
,
513 priv
->byTopCCKBasicRate
);
515 return le16_to_cpu(buf
->duration_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
->duration
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
527 buf
->duration_f0
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
528 buf
->duration_f1
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
530 buf
->time_stamp_off
= vnt_time_stamp_off(priv
, rate
);
532 return le16_to_cpu(buf
->duration
);
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
->duration
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
544 buf
->time_stamp_off
= vnt_time_stamp_off(priv
, rate
);
546 return le16_to_cpu(buf
->duration
);
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
->op_mode
== NL80211_IFTYPE_ADHOC
||
557 priv
->op_mode
== NL80211_IFTYPE_AP
)
558 memcpy(rts
->ra
, eth_hdr
->h_dest
, ETH_ALEN
);
560 memcpy(rts
->ra
, priv
->abyBSSID
, ETH_ALEN
);
562 if (priv
->op_mode
== NL80211_IFTYPE_AP
)
563 memcpy(rts
->ta
, priv
->abyBSSID
, ETH_ALEN
);
565 memcpy(rts
->ta
, eth_hdr
->h_source
, ETH_ALEN
);
570 static u16
vnt_rxtx_rts_g_head(struct vnt_private
*priv
,
571 struct vnt_rts_g
*buf
, struct ethhdr
*eth_hdr
,
572 u8 pkt_type
, u32 frame_len
, int need_ack
,
573 u16 current_rate
, u8 fb_option
)
575 u16 rts_frame_len
= 20;
577 BBvCalculateParameter(priv
, rts_frame_len
, priv
->byTopCCKBasicRate
,
578 PK_TYPE_11B
, &buf
->b
);
579 BBvCalculateParameter(priv
, rts_frame_len
,
580 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
582 buf
->duration_bb
= s_uGetRTSCTSDuration(priv
, RTSDUR_BB
, frame_len
,
583 PK_TYPE_11B
, priv
->byTopCCKBasicRate
, need_ack
, fb_option
);
584 buf
->duration_aa
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
585 pkt_type
, current_rate
, need_ack
, fb_option
);
586 buf
->duration_ba
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA
, frame_len
,
587 pkt_type
, current_rate
, need_ack
, fb_option
);
589 vnt_fill_ieee80211_rts(priv
, &buf
->data
, eth_hdr
, buf
->duration_aa
);
591 return vnt_rxtx_datahead_g(priv
, pkt_type
, current_rate
,
592 &buf
->data_head
, frame_len
, need_ack
);
595 static u16
vnt_rxtx_rts_g_fb_head(struct vnt_private
*priv
,
596 struct vnt_rts_g_fb
*buf
, struct ethhdr
*eth_hdr
,
597 u8 pkt_type
, u32 frame_len
, int need_ack
,
598 u16 current_rate
, u8 fb_option
)
600 u16 rts_frame_len
= 20;
602 BBvCalculateParameter(priv
, rts_frame_len
, priv
->byTopCCKBasicRate
,
603 PK_TYPE_11B
, &buf
->b
);
604 BBvCalculateParameter(priv
, rts_frame_len
,
605 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
608 buf
->duration_bb
= s_uGetRTSCTSDuration(priv
, RTSDUR_BB
, frame_len
,
609 PK_TYPE_11B
, priv
->byTopCCKBasicRate
, need_ack
, fb_option
);
610 buf
->duration_aa
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
611 pkt_type
, current_rate
, need_ack
, fb_option
);
612 buf
->duration_ba
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA
, frame_len
,
613 pkt_type
, current_rate
, need_ack
, fb_option
);
616 buf
->rts_duration_ba_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA_F0
,
617 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
, fb_option
);
618 buf
->rts_duration_aa_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F0
,
619 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
, fb_option
);
620 buf
->rts_duration_ba_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA_F1
,
621 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
, fb_option
);
622 buf
->rts_duration_aa_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F1
,
623 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
, fb_option
);
625 vnt_fill_ieee80211_rts(priv
, &buf
->data
, eth_hdr
, buf
->duration_aa
);
627 return vnt_rxtx_datahead_g_fb(priv
, pkt_type
, current_rate
,
628 &buf
->data_head
, frame_len
, need_ack
);
631 static u16
vnt_rxtx_rts_ab_head(struct vnt_private
*priv
,
632 struct vnt_rts_ab
*buf
, struct ethhdr
*eth_hdr
,
633 u8 pkt_type
, u32 frame_len
, int need_ack
,
634 u16 current_rate
, u8 fb_option
)
636 u16 rts_frame_len
= 20;
638 BBvCalculateParameter(priv
, rts_frame_len
,
639 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->ab
);
641 buf
->duration
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
642 pkt_type
, current_rate
, need_ack
, fb_option
);
644 vnt_fill_ieee80211_rts(priv
, &buf
->data
, eth_hdr
, buf
->duration
);
646 return vnt_rxtx_datahead_ab(priv
, pkt_type
, current_rate
,
647 &buf
->data_head
, frame_len
, need_ack
);
650 static u16
vnt_rxtx_rts_a_fb_head(struct vnt_private
*priv
,
651 struct vnt_rts_a_fb
*buf
, struct ethhdr
*eth_hdr
,
652 u8 pkt_type
, u32 frame_len
, int need_ack
,
653 u16 current_rate
, u8 fb_option
)
655 u16 rts_frame_len
= 20;
657 BBvCalculateParameter(priv
, rts_frame_len
,
658 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
660 buf
->duration
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
661 pkt_type
, current_rate
, need_ack
, fb_option
);
663 buf
->rts_duration_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F0
,
664 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
, fb_option
);
666 buf
->rts_duration_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F1
,
667 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
, fb_option
);
669 vnt_fill_ieee80211_rts(priv
, &buf
->data
, eth_hdr
, buf
->duration
);
671 return vnt_rxtx_datahead_a_fb(priv
, pkt_type
, current_rate
,
672 &buf
->data_head
, frame_len
, need_ack
);
675 static u16
s_vFillRTSHead(struct vnt_private
*pDevice
, u8 byPktType
,
676 union vnt_tx_data_head
*head
, u32 cbFrameLength
, int bNeedAck
,
677 struct ethhdr
*psEthHeader
, u16 wCurrentRate
, u8 byFBOption
)
683 /* Note: So far RTSHead doesn't appear in ATIM
684 * & Beacom DMA, so we don't need to take them
686 * Otherwise, we need to modified codes for them.
691 if (byFBOption
== AUTO_FB_NONE
)
692 return vnt_rxtx_rts_g_head(pDevice
, &head
->rts_g
,
693 psEthHeader
, byPktType
, cbFrameLength
,
694 bNeedAck
, wCurrentRate
, byFBOption
);
696 return vnt_rxtx_rts_g_fb_head(pDevice
, &head
->rts_g_fb
,
697 psEthHeader
, byPktType
, cbFrameLength
,
698 bNeedAck
, wCurrentRate
, byFBOption
);
702 return vnt_rxtx_rts_a_fb_head(pDevice
, &head
->rts_a_fb
,
703 psEthHeader
, byPktType
, cbFrameLength
,
704 bNeedAck
, wCurrentRate
, byFBOption
);
708 return vnt_rxtx_rts_ab_head(pDevice
, &head
->rts_ab
,
709 psEthHeader
, byPktType
, cbFrameLength
,
710 bNeedAck
, wCurrentRate
, byFBOption
);
716 static u16
s_vFillCTSHead(struct vnt_private
*pDevice
, u32 uDMAIdx
,
717 u8 byPktType
, union vnt_tx_data_head
*head
, u32 cbFrameLength
,
718 int bNeedAck
, u16 wCurrentRate
, u8 byFBOption
)
720 u32 uCTSFrameLen
= 14;
725 if (byFBOption
!= AUTO_FB_NONE
) {
727 struct vnt_cts_fb
*pBuf
= &head
->cts_g_fb
;
728 /* Get SignalField,ServiceField,Length */
729 BBvCalculateParameter(pDevice
, uCTSFrameLen
,
730 pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
, &pBuf
->b
);
731 pBuf
->duration_ba
= s_uGetRTSCTSDuration(pDevice
, CTSDUR_BA
,
732 cbFrameLength
, byPktType
,
733 wCurrentRate
, bNeedAck
, byFBOption
);
734 /* Get CTSDuration_ba_f0 */
735 pBuf
->cts_duration_ba_f0
= s_uGetRTSCTSDuration(pDevice
,
736 CTSDUR_BA_F0
, cbFrameLength
, byPktType
,
737 pDevice
->tx_rate_fb0
, bNeedAck
, byFBOption
);
738 /* Get CTSDuration_ba_f1 */
739 pBuf
->cts_duration_ba_f1
= s_uGetRTSCTSDuration(pDevice
,
740 CTSDUR_BA_F1
, cbFrameLength
, byPktType
,
741 pDevice
->tx_rate_fb1
, bNeedAck
, byFBOption
);
742 /* Get CTS Frame body */
743 pBuf
->data
.duration
= pBuf
->duration_ba
;
744 pBuf
->data
.frame_control
= TYPE_CTL_CTS
;
745 memcpy(pBuf
->data
.ra
, pDevice
->abyCurrentNetAddr
, ETH_ALEN
);
747 return vnt_rxtx_datahead_g_fb(pDevice
, byPktType
, wCurrentRate
,
748 &pBuf
->data_head
, cbFrameLength
, bNeedAck
);
750 struct vnt_cts
*pBuf
= &head
->cts_g
;
751 /* Get SignalField,ServiceField,Length */
752 BBvCalculateParameter(pDevice
, uCTSFrameLen
,
753 pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
, &pBuf
->b
);
754 /* Get CTSDuration_ba */
755 pBuf
->duration_ba
= s_uGetRTSCTSDuration(pDevice
,
756 CTSDUR_BA
, cbFrameLength
, byPktType
,
757 wCurrentRate
, bNeedAck
, byFBOption
);
758 /*Get CTS Frame body*/
759 pBuf
->data
.duration
= pBuf
->duration_ba
;
760 pBuf
->data
.frame_control
= TYPE_CTL_CTS
;
761 memcpy(pBuf
->data
.ra
, pDevice
->abyCurrentNetAddr
, ETH_ALEN
);
763 return vnt_rxtx_datahead_g(pDevice
, byPktType
, wCurrentRate
,
764 &pBuf
->data_head
, cbFrameLength
, bNeedAck
);
773 * Generate FIFO control for MAC & Baseband controller
777 * pDevice - Pointer to adpater
778 * pTxDataHead - Transmit Data Buffer
779 * pTxBufHead - pTxBufHead
780 * pvRrvTime - pvRrvTime
783 * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS)
784 * bNeedACK - If need ACK
785 * uDMAIdx - DMA Index
793 static u16
s_vGenerateTxParameter(struct vnt_private
*pDevice
,
794 u8 byPktType
, u16 wCurrentRate
, struct vnt_tx_buffer
*tx_buffer
,
795 struct vnt_mic_hdr
**mic_hdr
, u32 need_mic
, u32 cbFrameSize
,
796 int bNeedACK
, u32 uDMAIdx
, struct ethhdr
*psEthHeader
, bool need_rts
)
798 struct vnt_tx_fifo_head
*pFifoHead
= &tx_buffer
->fifo_head
;
799 union vnt_tx_data_head
*head
= NULL
;
801 u8 byFBOption
= AUTO_FB_NONE
;
803 pFifoHead
->wReserved
= wCurrentRate
;
804 wFifoCtl
= pFifoHead
->wFIFOCtl
;
806 if (wFifoCtl
& FIFOCTL_AUTO_FB_0
)
807 byFBOption
= AUTO_FB_0
;
808 else if (wFifoCtl
& FIFOCTL_AUTO_FB_1
)
809 byFBOption
= AUTO_FB_1
;
814 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
816 struct vnt_rrv_time_rts
*pBuf
=
817 &tx_buffer
->tx_head
.tx_rts
.rts
;
819 pBuf
->rts_rrv_time_aa
= s_uGetRTSCTSRsvTime(pDevice
, 2,
820 byPktType
, cbFrameSize
, wCurrentRate
);
821 pBuf
->rts_rrv_time_ba
= s_uGetRTSCTSRsvTime(pDevice
, 1,
822 byPktType
, cbFrameSize
, wCurrentRate
);
823 pBuf
->rts_rrv_time_bb
= s_uGetRTSCTSRsvTime(pDevice
, 0,
824 byPktType
, cbFrameSize
, wCurrentRate
);
826 pBuf
->rrv_time_a
= vnt_rxtx_rsvtime_le16(pDevice
,
827 byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
);
828 pBuf
->rrv_time_b
= vnt_rxtx_rsvtime_le16(pDevice
,
829 PK_TYPE_11B
, cbFrameSize
,
830 pDevice
->byTopCCKBasicRate
, bNeedACK
);
833 *mic_hdr
= &tx_buffer
->
834 tx_head
.tx_rts
.tx
.mic
.hdr
;
835 head
= &tx_buffer
->tx_head
.tx_rts
.tx
.mic
.head
;
837 head
= &tx_buffer
->tx_head
.tx_rts
.tx
.head
;
841 return s_vFillRTSHead(pDevice
, byPktType
, head
,
842 cbFrameSize
, bNeedACK
, psEthHeader
,
843 wCurrentRate
, byFBOption
);
846 struct vnt_rrv_time_cts
*pBuf
= &tx_buffer
->
849 pBuf
->rrv_time_a
= vnt_rxtx_rsvtime_le16(pDevice
,
850 byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
);
851 pBuf
->rrv_time_b
= vnt_rxtx_rsvtime_le16(pDevice
,
852 PK_TYPE_11B
, cbFrameSize
,
853 pDevice
->byTopCCKBasicRate
, bNeedACK
);
855 pBuf
->cts_rrv_time_ba
= s_uGetRTSCTSRsvTime(pDevice
, 3,
856 byPktType
, cbFrameSize
, wCurrentRate
);
859 *mic_hdr
= &tx_buffer
->
860 tx_head
.tx_cts
.tx
.mic
.hdr
;
861 head
= &tx_buffer
->tx_head
.tx_cts
.tx
.mic
.head
;
863 head
= &tx_buffer
->tx_head
.tx_cts
.tx
.head
;
867 return s_vFillCTSHead(pDevice
, uDMAIdx
, byPktType
,
868 head
, cbFrameSize
, bNeedACK
, wCurrentRate
,
871 } else if (byPktType
== PK_TYPE_11A
) {
873 *mic_hdr
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.hdr
;
874 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.head
;
876 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.head
;
880 struct vnt_rrv_time_ab
*pBuf
= &tx_buffer
->
883 pBuf
->rts_rrv_time
= s_uGetRTSCTSRsvTime(pDevice
, 2,
884 byPktType
, cbFrameSize
, wCurrentRate
);
886 pBuf
->rrv_time
= vnt_rxtx_rsvtime_le16(pDevice
,
887 byPktType
, cbFrameSize
, wCurrentRate
, bNeedACK
);
890 return s_vFillRTSHead(pDevice
, byPktType
, head
,
891 cbFrameSize
, bNeedACK
, psEthHeader
,
892 wCurrentRate
, byFBOption
);
894 struct vnt_rrv_time_ab
*pBuf
= &tx_buffer
->
897 pBuf
->rrv_time
= vnt_rxtx_rsvtime_le16(pDevice
,
898 PK_TYPE_11A
, cbFrameSize
,
899 wCurrentRate
, bNeedACK
);
901 return vnt_rxtx_datahead_a_fb(pDevice
, byPktType
,
902 wCurrentRate
, &head
->data_head_a_fb
,
903 cbFrameSize
, bNeedACK
);
905 } else if (byPktType
== PK_TYPE_11B
) {
907 *mic_hdr
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.hdr
;
908 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.head
;
910 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.head
;
914 struct vnt_rrv_time_ab
*pBuf
= &tx_buffer
->
917 pBuf
->rts_rrv_time
= s_uGetRTSCTSRsvTime(pDevice
, 0,
918 byPktType
, cbFrameSize
, wCurrentRate
);
920 pBuf
->rrv_time
= vnt_rxtx_rsvtime_le16(pDevice
,
921 PK_TYPE_11B
, cbFrameSize
, wCurrentRate
,
925 return s_vFillRTSHead(pDevice
, byPktType
, head
,
927 bNeedACK
, psEthHeader
, wCurrentRate
, byFBOption
);
929 struct vnt_rrv_time_ab
*pBuf
= &tx_buffer
->
932 pBuf
->rrv_time
= vnt_rxtx_rsvtime_le16(pDevice
,
933 PK_TYPE_11B
, cbFrameSize
,
934 wCurrentRate
, bNeedACK
);
936 return vnt_rxtx_datahead_ab(pDevice
, byPktType
,
937 wCurrentRate
, &head
->data_head_ab
,
938 cbFrameSize
, bNeedACK
);
945 u8 * pbyBuffer,//point to pTxBufHead
946 u16 wFragType,//00:Non-Frag, 01:Start, 02:Mid, 03:Last
947 unsigned int cbFragmentSize,//Hdr+payoad+FCS
950 static int s_bPacketToWirelessUsb(struct vnt_private
*pDevice
, u8 byPktType
,
951 struct vnt_tx_buffer
*tx_buffer
, int bNeedEncryption
,
952 u32 uSkbPacketLen
, u32 uDMAIdx
, struct ethhdr
*psEthHeader
,
953 u8
*pPacket
, PSKeyItem pTransmitKey
, u32 uNodeIndex
, u16 wCurrentRate
,
954 u32
*pcbHeaderLen
, u32
*pcbTotalLen
)
956 struct vnt_tx_fifo_head
*pTxBufHead
= &tx_buffer
->fifo_head
;
957 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
958 u32 cbFrameSize
, cbFrameBodySize
;
960 u32 cbIVlen
= 0, cbICVlen
= 0, cbMIClen
= 0, cbMACHdLen
= 0;
961 u32 cbFCSlen
= 4, cbMICHDR
= 0;
964 u8
*pbyType
, *pbyMacHdr
, *pbyIVHead
, *pbyPayloadHead
, *pbyTxBufferAddr
;
965 u8 abySNAP_RFC1042
[ETH_ALEN
] = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0x00};
966 u8 abySNAP_Bridgetunnel
[ETH_ALEN
]
967 = {0xAA, 0xAA, 0x03, 0x00, 0x00, 0xF8};
969 u32 cbHeaderLength
= 0, uPadding
= 0;
970 struct vnt_mic_hdr
*pMICHDR
;
971 u8 byFBOption
= AUTO_FB_NONE
, byFragType
;
973 u32 dwMICKey0
, dwMICKey1
, dwMIC_Priority
;
974 u32
*pdwMIC_L
, *pdwMIC_R
;
975 int bSoftWEP
= false;
979 if (bNeedEncryption
&& pTransmitKey
->pvKeyTable
) {
980 if (((PSKeyTable
)pTransmitKey
->pvKeyTable
)->bSoftWEP
== true)
981 bSoftWEP
= true; /* WEP 256 */
985 if (ntohs(psEthHeader
->h_proto
) > ETH_DATA_LEN
)
990 cbFrameBodySize
= uSkbPacketLen
- ETH_HLEN
+ cb802_1_H_len
;
993 pTxBufHead
->wFIFOCtl
|= (u16
)(byPktType
<<8);
995 if (pDevice
->op_mode
== NL80211_IFTYPE_ADHOC
||
996 pDevice
->op_mode
== NL80211_IFTYPE_AP
) {
997 if (is_multicast_ether_addr(psEthHeader
->h_dest
)) {
999 pTxBufHead
->wFIFOCtl
=
1000 pTxBufHead
->wFIFOCtl
& (~FIFOCTL_NEEDACK
);
1003 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
1006 /* MSDUs in Infra mode always need ACK */
1008 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
1011 pTxBufHead
->wTimeStamp
= DEFAULT_MSDU_LIFETIME_RES_64us
;
1013 //Set FRAGCTL_MACHDCNT
1014 cbMACHdLen
= WLAN_HDR_ADDR3_LEN
;
1016 pTxBufHead
->wFragCtl
|= (u16
)(cbMACHdLen
<< 10);
1018 //Set FIFOCTL_GrpAckPolicy
1019 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
1020 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
1023 /* Set Auto Fallback Ctl */
1024 if (wCurrentRate
>= RATE_18M
) {
1025 if (pDevice
->byAutoFBCtrl
== AUTO_FB_0
) {
1026 pTxBufHead
->wFIFOCtl
|= FIFOCTL_AUTO_FB_0
;
1028 pDevice
->tx_rate_fb0
=
1029 wFB_Opt0
[FB_RATE0
][wCurrentRate
- RATE_18M
];
1030 pDevice
->tx_rate_fb1
=
1031 wFB_Opt0
[FB_RATE1
][wCurrentRate
- RATE_18M
];
1033 byFBOption
= AUTO_FB_0
;
1034 } else if (pDevice
->byAutoFBCtrl
== AUTO_FB_1
) {
1035 pTxBufHead
->wFIFOCtl
|= FIFOCTL_AUTO_FB_1
;
1036 pDevice
->tx_rate_fb0
=
1037 wFB_Opt1
[FB_RATE0
][wCurrentRate
- RATE_18M
];
1038 pDevice
->tx_rate_fb1
=
1039 wFB_Opt1
[FB_RATE1
][wCurrentRate
- RATE_18M
];
1041 byFBOption
= AUTO_FB_1
;
1045 if (bSoftWEP
!= true) {
1046 if ((bNeedEncryption
) && (pTransmitKey
!= NULL
)) { //WEP enabled
1047 if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) { //WEP40 or WEP104
1048 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
1050 if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
1051 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Tx Set wFragCtl == FRAGCTL_TKIP\n");
1052 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
1054 else if (pTransmitKey
->byCipherSuite
== KEY_CTL_CCMP
) { //CCMP
1055 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
1060 if ((bNeedEncryption
) && (pTransmitKey
!= NULL
)) {
1061 if (pTransmitKey
->byCipherSuite
== KEY_CTL_WEP
) {
1065 else if (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
) {
1066 cbIVlen
= 8;//IV+ExtIV
1070 if (pTransmitKey
->byCipherSuite
== KEY_CTL_CCMP
) {
1071 cbIVlen
= 8;//RSN Header
1073 cbMICHDR
= sizeof(struct vnt_mic_hdr
);
1075 if (bSoftWEP
== false) {
1076 //MAC Header should be padding 0 to DW alignment.
1077 uPadding
= 4 - (cbMACHdLen
%4);
1082 cbFrameSize
= cbMACHdLen
+ cbIVlen
+ (cbFrameBodySize
+ cbMIClen
) + cbICVlen
+ cbFCSlen
;
1084 if ( (bNeedACK
== false) ||(cbFrameSize
< pDevice
->wRTSThreshold
) ) {
1088 pTxBufHead
->wFIFOCtl
|= (FIFOCTL_RTS
| FIFOCTL_LRETRY
);
1091 pbyTxBufferAddr
= (u8
*) &(pTxBufHead
->adwTxKey
[0]);
1092 wTxBufSize
= sizeof(struct vnt_tx_fifo_head
);
1094 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
1095 if (byFBOption
== AUTO_FB_NONE
) {
1096 if (bRTS
== true) {//RTS_need
1097 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_rts
) +
1098 cbMICHDR
+ sizeof(struct vnt_rts_g
);
1100 else { //RTS_needless
1101 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_cts
) +
1102 cbMICHDR
+ sizeof(struct vnt_cts
);
1106 if (bRTS
== true) {//RTS_need
1107 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_rts
) +
1108 cbMICHDR
+ sizeof(struct vnt_rts_g_fb
);
1110 else if (bRTS
== false) { //RTS_needless
1111 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_cts
) +
1112 cbMICHDR
+ sizeof(struct vnt_cts_fb
);
1116 else {//802.11a/b packet
1117 if (byFBOption
== AUTO_FB_NONE
) {
1118 if (bRTS
== true) {//RTS_need
1119 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1120 cbMICHDR
+ sizeof(struct vnt_rts_ab
);
1122 else if (bRTS
== false) { //RTS_needless, no MICHDR
1123 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1124 cbMICHDR
+ sizeof(struct vnt_tx_datahead_ab
);
1128 if (bRTS
== true) {//RTS_need
1129 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1130 cbMICHDR
+ sizeof(struct vnt_rts_a_fb
);
1132 else if (bRTS
== false) { //RTS_needless
1133 cbHeaderLength
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1134 cbMICHDR
+ sizeof(struct vnt_tx_datahead_a_fb
);
1139 pbyMacHdr
= (u8
*)(pbyTxBufferAddr
+ cbHeaderLength
);
1140 pbyIVHead
= (u8
*)(pbyMacHdr
+ cbMACHdLen
+ uPadding
);
1141 pbyPayloadHead
= (u8
*)(pbyMacHdr
+ cbMACHdLen
+ uPadding
+ cbIVlen
);
1143 //=========================
1145 //=========================
1146 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"No Fragmentation...\n");
1147 byFragType
= FRAGCTL_NONFRAG
;
1148 //uDMAIdx = TYPE_AC0DMA;
1149 //pTxBufHead = (PSTxBufHead) &(pTxBufHead->adwTxKey[0]);
1151 /* Fill FIFO, RrvTime, RTS and CTS */
1152 uDuration
= s_vGenerateTxParameter(pDevice
, byPktType
, wCurrentRate
,
1153 tx_buffer
, &pMICHDR
, cbMICHDR
,
1154 cbFrameSize
, bNeedACK
, uDMAIdx
, psEthHeader
, bRTS
);
1156 // Generate TX MAC Header
1157 s_vGenerateMACHeader(pDevice
, pbyMacHdr
, (u16
)uDuration
, psEthHeader
, bNeedEncryption
,
1158 byFragType
, uDMAIdx
, 0);
1160 if (bNeedEncryption
== true) {
1162 s_vFillTxKey(pDevice
, pTxBufHead
, pbyIVHead
, pTransmitKey
,
1163 pbyMacHdr
, (u16
)cbFrameBodySize
, pMICHDR
);
1165 if (pDevice
->bEnableHostWEP
) {
1166 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
1167 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
1172 if (ntohs(psEthHeader
->h_proto
) > ETH_DATA_LEN
) {
1173 if ((psEthHeader
->h_proto
== cpu_to_be16(ETH_P_IPX
)) ||
1174 (psEthHeader
->h_proto
== cpu_to_le16(0xF380)))
1175 memcpy((u8
*) (pbyPayloadHead
),
1176 abySNAP_Bridgetunnel
, 6);
1178 memcpy((u8
*) (pbyPayloadHead
), &abySNAP_RFC1042
[0], 6);
1180 pbyType
= (u8
*) (pbyPayloadHead
+ 6);
1182 memcpy(pbyType
, &(psEthHeader
->h_proto
), sizeof(u16
));
1185 if (pPacket
!= NULL
) {
1186 // Copy the Packet into a tx Buffer
1187 memcpy((pbyPayloadHead
+ cb802_1_H_len
),
1188 (pPacket
+ ETH_HLEN
),
1189 uSkbPacketLen
- ETH_HLEN
1193 // while bRelayPacketSend psEthHeader is point to header+payload
1194 memcpy((pbyPayloadHead
+ cb802_1_H_len
), ((u8
*)psEthHeader
) + ETH_HLEN
, uSkbPacketLen
- ETH_HLEN
);
1197 if ((bNeedEncryption
== true) && (pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
1199 ///////////////////////////////////////////////////////////////////
1201 if (pDevice
->vnt_mgmt
.eAuthenMode
== WMAC_AUTH_WPANONE
) {
1202 dwMICKey0
= *(u32
*)(&pTransmitKey
->abyKey
[16]);
1203 dwMICKey1
= *(u32
*)(&pTransmitKey
->abyKey
[20]);
1205 else if ((pTransmitKey
->dwKeyIndex
& AUTHENTICATOR_KEY
) != 0) {
1206 dwMICKey0
= *(u32
*)(&pTransmitKey
->abyKey
[16]);
1207 dwMICKey1
= *(u32
*)(&pTransmitKey
->abyKey
[20]);
1210 dwMICKey0
= *(u32
*)(&pTransmitKey
->abyKey
[24]);
1211 dwMICKey1
= *(u32
*)(&pTransmitKey
->abyKey
[28]);
1213 // DO Software Michael
1214 MIC_vInit(dwMICKey0
, dwMICKey1
);
1215 MIC_vAppend((u8
*)&(psEthHeader
->h_dest
[0]), 12);
1217 MIC_vAppend((u8
*)&dwMIC_Priority
, 4);
1218 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MIC KEY: %X, %X\n",
1219 dwMICKey0
, dwMICKey1
);
1221 ///////////////////////////////////////////////////////////////////
1223 //DBG_PRN_GRP12(("Length:%d, %d\n", cbFrameBodySize, uFromHDtoPLDLength));
1224 //for (ii = 0; ii < cbFrameBodySize; ii++) {
1225 // DBG_PRN_GRP12(("%02x ", *((u8 *)((pbyPayloadHead + cb802_1_H_len) + ii))));
1227 //DBG_PRN_GRP12(("\n\n\n"));
1229 MIC_vAppend(pbyPayloadHead
, cbFrameBodySize
);
1231 pdwMIC_L
= (u32
*)(pbyPayloadHead
+ cbFrameBodySize
);
1232 pdwMIC_R
= (u32
*)(pbyPayloadHead
+ cbFrameBodySize
+ 4);
1234 MIC_vGetMIC(pdwMIC_L
, pdwMIC_R
);
1237 if (pDevice
->bTxMICFail
== true) {
1240 pDevice
->bTxMICFail
= false;
1242 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"uLength: %d, %d\n", uLength, cbFrameBodySize);
1243 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"cbReqCount:%d, %d, %d, %d\n", cbReqCount, cbHeaderLength, uPadding, cbIVlen);
1244 //DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"MIC:%lX, %lX\n", *pdwMIC_L, *pdwMIC_R);
1247 if (bSoftWEP
== true) {
1249 s_vSWencryption(pDevice
, pTransmitKey
, (pbyPayloadHead
), (u16
)(cbFrameBodySize
+ cbMIClen
));
1251 } else if ( ((pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) && (bNeedEncryption
== true)) ||
1252 ((pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) && (bNeedEncryption
== true)) ||
1253 ((pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) && (bNeedEncryption
== true)) ) {
1254 cbFrameSize
-= cbICVlen
;
1257 cbFrameSize
-= cbFCSlen
;
1259 *pcbHeaderLen
= cbHeaderLength
;
1260 *pcbTotalLen
= cbHeaderLength
+ cbFrameSize
;
1262 //Set FragCtl in TxBufferHead
1263 pTxBufHead
->wFragCtl
|= (u16
)byFragType
;
1272 * Translate 802.3 to 802.11 header
1276 * pDevice - Pointer to adapter
1277 * dwTxBufferAddr - Transmit Buffer
1278 * pPacket - Packet from upper layer
1279 * cbPacketSize - Transmit Data Length
1281 * pcbHeadSize - Header size of MAC&Baseband control and 802.11 Header
1282 * pcbAppendPayload - size of append payload for 802.1H translation
1284 * Return Value: none
1288 static void s_vGenerateMACHeader(struct vnt_private
*pDevice
,
1289 u8
*pbyBufferAddr
, u16 wDuration
, struct ethhdr
*psEthHeader
,
1290 int bNeedEncrypt
, u16 wFragType
, u32 uDMAIdx
, u32 uFragIdx
)
1292 struct ieee80211_hdr
*pMACHeader
= (struct ieee80211_hdr
*)pbyBufferAddr
;
1294 pMACHeader
->frame_control
= TYPE_802_11_DATA
;
1296 if (pDevice
->op_mode
== NL80211_IFTYPE_AP
) {
1297 memcpy(&(pMACHeader
->addr1
[0]),
1298 &(psEthHeader
->h_dest
[0]),
1300 memcpy(&(pMACHeader
->addr2
[0]), &(pDevice
->abyBSSID
[0]), ETH_ALEN
);
1301 memcpy(&(pMACHeader
->addr3
[0]),
1302 &(psEthHeader
->h_source
[0]),
1304 pMACHeader
->frame_control
|= FC_FROMDS
;
1306 if (pDevice
->op_mode
== NL80211_IFTYPE_ADHOC
) {
1307 memcpy(&(pMACHeader
->addr1
[0]),
1308 &(psEthHeader
->h_dest
[0]),
1310 memcpy(&(pMACHeader
->addr2
[0]),
1311 &(psEthHeader
->h_source
[0]),
1313 memcpy(&(pMACHeader
->addr3
[0]),
1314 &(pDevice
->abyBSSID
[0]),
1317 memcpy(&(pMACHeader
->addr3
[0]),
1318 &(psEthHeader
->h_dest
[0]),
1320 memcpy(&(pMACHeader
->addr2
[0]),
1321 &(psEthHeader
->h_source
[0]),
1323 memcpy(&(pMACHeader
->addr1
[0]),
1324 &(pDevice
->abyBSSID
[0]),
1326 pMACHeader
->frame_control
|= FC_TODS
;
1331 pMACHeader
->frame_control
|= cpu_to_le16((u16
)WLAN_SET_FC_ISWEP(1));
1333 pMACHeader
->duration_id
= cpu_to_le16(wDuration
);
1335 pMACHeader
->seq_ctrl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
1337 //Set FragNumber in Sequence Control
1338 pMACHeader
->seq_ctrl
|= cpu_to_le16((u16
)uFragIdx
);
1340 if ((wFragType
== FRAGCTL_ENDFRAG
) || (wFragType
== FRAGCTL_NONFRAG
)) {
1341 pDevice
->wSeqCounter
++;
1342 if (pDevice
->wSeqCounter
> 0x0fff)
1343 pDevice
->wSeqCounter
= 0;
1346 if ((wFragType
== FRAGCTL_STAFRAG
) || (wFragType
== FRAGCTL_MIDFRAG
)) { //StartFrag or MidFrag
1347 pMACHeader
->frame_control
|= FC_MOREFRAG
;
1354 * Request instructs a MAC to transmit a 802.11 management packet through
1355 * the adapter onto the medium.
1359 * hDeviceContext - Pointer to the adapter
1360 * pPacket - A pointer to a descriptor for the packet to transmit
1364 * Return Value: CMD_STATUS_PENDING if MAC Tx resource available; otherwise false
1368 CMD_STATUS
csMgmt_xmit(struct vnt_private
*pDevice
,
1369 struct vnt_tx_mgmt
*pPacket
)
1371 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1372 struct vnt_tx_buffer
*pTX_Buffer
;
1373 struct vnt_usb_send_context
*pContext
;
1374 struct vnt_tx_fifo_head
*pTxBufHead
;
1375 struct ieee80211_hdr
*pMACHeader
;
1376 struct ethhdr sEthHeader
;
1377 u8 byPktType
, *pbyTxBufferAddr
;
1378 struct vnt_mic_hdr
*pMICHDR
= NULL
;
1379 u32 uDuration
, cbReqCount
, cbHeaderSize
, cbFrameBodySize
, cbFrameSize
;
1380 int bNeedACK
, bIsPSPOLL
= false;
1381 u32 cbIVlen
= 0, cbICVlen
= 0, cbMIClen
= 0, cbFCSlen
= 4;
1385 u16 wCurrentRate
= RATE_1M
;
1387 pContext
= s_vGetFreeContext(pDevice
);
1389 if (NULL
== pContext
) {
1390 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"ManagementSend TX...NO CONTEXT!\n");
1391 return CMD_STATUS_RESOURCES
;
1394 pTX_Buffer
= (struct vnt_tx_buffer
*)&pContext
->Data
[0];
1395 cbFrameBodySize
= pPacket
->cbPayloadLen
;
1396 pTxBufHead
= &pTX_Buffer
->fifo_head
;
1397 pbyTxBufferAddr
= (u8
*)&pTxBufHead
->adwTxKey
[0];
1398 wTxBufSize
= sizeof(struct vnt_tx_fifo_head
);
1400 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1401 wCurrentRate
= RATE_6M
;
1402 byPktType
= PK_TYPE_11A
;
1404 wCurrentRate
= RATE_1M
;
1405 byPktType
= PK_TYPE_11B
;
1408 // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
1409 // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
1410 // And cmd timer will wait data pkt TX finish before scanning so it's OK
1411 // to set power here.
1412 if (pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
1413 RFbSetPower(pDevice
, wCurrentRate
, pDevice
->byCurrentCh
);
1415 RFbSetPower(pDevice
, wCurrentRate
, pMgmt
->uCurrChannel
);
1417 pDevice
->wCurrentRate
= wCurrentRate
;
1420 if (byPktType
== PK_TYPE_11A
) {//0000 0000 0000 0000
1421 pTxBufHead
->wFIFOCtl
= 0;
1423 else if (byPktType
== PK_TYPE_11B
) {//0000 0001 0000 0000
1424 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11B
;
1426 else if (byPktType
== PK_TYPE_11GB
) {//0000 0010 0000 0000
1427 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GB
;
1429 else if (byPktType
== PK_TYPE_11GA
) {//0000 0011 0000 0000
1430 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GA
;
1433 pTxBufHead
->wFIFOCtl
|= FIFOCTL_TMOEN
;
1434 pTxBufHead
->wTimeStamp
= cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us
);
1436 if (is_multicast_ether_addr(pPacket
->p80211Header
->sA3
.abyAddr1
)) {
1441 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
1444 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
1445 (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) ) {
1447 pTxBufHead
->wFIFOCtl
|= FIFOCTL_LRETRY
;
1448 //Set Preamble type always long
1449 //pDevice->byPreambleType = PREAMBLE_LONG;
1450 // probe-response don't retry
1451 //if ((pPacket->p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
1452 // bNeedACK = false;
1453 // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
1457 pTxBufHead
->wFIFOCtl
|= (FIFOCTL_GENINT
| FIFOCTL_ISDMA0
);
1459 if ((pPacket
->p80211Header
->sA4
.wFrameCtl
& TYPE_SUBTYPE_MASK
) == TYPE_CTL_PSPOLL
) {
1461 cbMacHdLen
= WLAN_HDR_ADDR2_LEN
;
1463 cbMacHdLen
= WLAN_HDR_ADDR3_LEN
;
1466 //Set FRAGCTL_MACHDCNT
1467 pTxBufHead
->wFragCtl
|= cpu_to_le16((u16
)(cbMacHdLen
<< 10));
1470 // Although spec says MMPDU can be fragmented; In most case,
1471 // no one will send a MMPDU under fragmentation. With RTS may occur.
1473 if (WLAN_GET_FC_ISWEP(pPacket
->p80211Header
->sA4
.wFrameCtl
) != 0) {
1474 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) {
1477 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
1479 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
1480 cbIVlen
= 8;//IV+ExtIV
1483 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
1484 //We need to get seed here for filling TxKey entry.
1485 //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
1486 // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
1488 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
1489 cbIVlen
= 8;//RSN Header
1491 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
1493 //MAC Header should be padding 0 to DW alignment.
1494 uPadding
= 4 - (cbMacHdLen
%4);
1498 cbFrameSize
= cbMacHdLen
+ cbFrameBodySize
+ cbIVlen
+ cbMIClen
+ cbICVlen
+ cbFCSlen
;
1500 //Set FIFOCTL_GrpAckPolicy
1501 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
1502 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
1504 //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
1506 //Set RrvTime/RTS/CTS Buffer
1507 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
1508 cbHeaderSize
= wTxBufSize
+ sizeof(struct vnt_rrv_time_cts
) +
1509 sizeof(struct vnt_cts
);
1511 else { // 802.11a/b packet
1512 cbHeaderSize
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) +
1513 sizeof(struct vnt_tx_datahead_ab
);
1516 memcpy(&(sEthHeader
.h_dest
[0]),
1517 &(pPacket
->p80211Header
->sA3
.abyAddr1
[0]),
1519 memcpy(&(sEthHeader
.h_source
[0]),
1520 &(pPacket
->p80211Header
->sA3
.abyAddr2
[0]),
1522 //=========================
1524 //=========================
1525 pTxBufHead
->wFragCtl
|= (u16
)FRAGCTL_NONFRAG
;
1527 /* Fill FIFO,RrvTime,RTS,and CTS */
1528 uDuration
= s_vGenerateTxParameter(pDevice
, byPktType
, wCurrentRate
,
1529 pTX_Buffer
, &pMICHDR
, 0,
1530 cbFrameSize
, bNeedACK
, TYPE_TXDMA0
, &sEthHeader
, false);
1532 pMACHeader
= (struct ieee80211_hdr
*) (pbyTxBufferAddr
+ cbHeaderSize
);
1534 cbReqCount
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
+ cbFrameBodySize
;
1536 if (WLAN_GET_FC_ISWEP(pPacket
->p80211Header
->sA4
.wFrameCtl
) != 0) {
1538 u8
* pbyPayloadHead
;
1540 PSKeyItem pTransmitKey
= NULL
;
1542 pbyIVHead
= (u8
*)(pbyTxBufferAddr
+ cbHeaderSize
+ cbMacHdLen
+ uPadding
);
1543 pbyPayloadHead
= (u8
*)(pbyTxBufferAddr
+ cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
);
1545 if (pDevice
->op_mode
== NL80211_IFTYPE_STATION
&&
1546 pDevice
->bLinkPass
== true) {
1547 pbyBSSID
= pDevice
->abyBSSID
;
1549 if (KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == false) {
1551 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == true) {
1552 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get GTK.\n");
1556 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get PTK.\n");
1561 pbyBSSID
= pDevice
->abyBroadcastAddr
;
1562 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == false) {
1563 pTransmitKey
= NULL
;
1564 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"KEY is NULL. OP Mode[%d]\n", pDevice
->op_mode
);
1566 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Get GTK.\n");
1570 s_vFillTxKey(pDevice
, pTxBufHead
, pbyIVHead
, pTransmitKey
,
1571 (u8
*)pMACHeader
, (u16
)cbFrameBodySize
, NULL
);
1573 memcpy(pMACHeader
, pPacket
->p80211Header
, cbMacHdLen
);
1574 memcpy(pbyPayloadHead
, ((u8
*)(pPacket
->p80211Header
) + cbMacHdLen
),
1578 // Copy the Packet into a tx Buffer
1579 memcpy(pMACHeader
, pPacket
->p80211Header
, pPacket
->cbMPDULen
);
1582 pMACHeader
->seq_ctrl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
1583 pDevice
->wSeqCounter
++ ;
1584 if (pDevice
->wSeqCounter
> 0x0fff)
1585 pDevice
->wSeqCounter
= 0;
1588 // The MAC will automatically replace the Duration-field of MAC header by Duration-field
1589 // of FIFO control header.
1590 // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
1591 // in the same place of other packet's Duration-field).
1592 // And it will cause Cisco-AP to issue Disassociation-packet
1593 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
1594 struct vnt_tx_datahead_g
*data_head
= &pTX_Buffer
->tx_head
.
1595 tx_cts
.tx
.head
.cts_g
.data_head
;
1596 data_head
->duration_a
=
1597 cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
1598 data_head
->duration_b
=
1599 cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
1601 struct vnt_tx_datahead_ab
*data_head
= &pTX_Buffer
->tx_head
.
1602 tx_ab
.tx
.head
.data_head_ab
;
1603 data_head
->duration
=
1604 cpu_to_le16(pPacket
->p80211Header
->sA2
.wDurationID
);
1608 pTX_Buffer
->wTxByteCount
= cpu_to_le16((u16
)(cbReqCount
));
1609 pTX_Buffer
->byPKTNO
= (u8
) (((wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
1610 pTX_Buffer
->byType
= 0x00;
1612 pContext
->pPacket
= NULL
;
1613 pContext
->type
= CONTEXT_MGMT_PACKET
;
1614 pContext
->uBufLen
= (u16
)cbReqCount
+ 4; //USB header
1616 if (WLAN_GET_FC_TODS(pMACHeader
->frame_control
) == 0) {
1617 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
1618 &pMACHeader
->addr1
[0], (u16
)cbFrameSize
,
1619 pTxBufHead
->wFIFOCtl
);
1622 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
1623 &pMACHeader
->addr3
[0], (u16
)cbFrameSize
,
1624 pTxBufHead
->wFIFOCtl
);
1627 PIPEnsSendBulkOut(pDevice
,pContext
);
1628 return CMD_STATUS_PENDING
;
1631 CMD_STATUS
csBeacon_xmit(struct vnt_private
*pDevice
,
1632 struct vnt_tx_mgmt
*pPacket
)
1634 struct vnt_beacon_buffer
*pTX_Buffer
;
1635 struct vnt_tx_short_buf_head
*short_head
;
1636 u32 cbFrameSize
= pPacket
->cbMPDULen
+ WLAN_FCS_LEN
;
1637 u32 cbHeaderSize
= 0;
1638 struct ieee80211_hdr
*pMACHeader
;
1640 u32 cbFrameBodySize
;
1642 struct vnt_usb_send_context
*pContext
;
1645 pContext
= s_vGetFreeContext(pDevice
);
1646 if (NULL
== pContext
) {
1647 status
= CMD_STATUS_RESOURCES
;
1648 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"ManagementSend TX...NO CONTEXT!\n");
1652 pTX_Buffer
= (struct vnt_beacon_buffer
*)&pContext
->Data
[0];
1653 short_head
= &pTX_Buffer
->short_head
;
1655 cbFrameBodySize
= pPacket
->cbPayloadLen
;
1657 cbHeaderSize
= sizeof(struct vnt_tx_short_buf_head
);
1659 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1660 wCurrentRate
= RATE_6M
;
1662 /* Get SignalField,ServiceField,Length */
1663 BBvCalculateParameter(pDevice
, cbFrameSize
, wCurrentRate
,
1664 PK_TYPE_11A
, &short_head
->ab
);
1666 /* Get Duration and TimeStampOff */
1667 short_head
->duration
= s_uGetDataDuration(pDevice
,
1668 PK_TYPE_11A
, false);
1669 short_head
->time_stamp_off
=
1670 vnt_time_stamp_off(pDevice
, wCurrentRate
);
1672 wCurrentRate
= RATE_1M
;
1673 short_head
->fifo_ctl
|= FIFOCTL_11B
;
1675 /* Get SignalField,ServiceField,Length */
1676 BBvCalculateParameter(pDevice
, cbFrameSize
, wCurrentRate
,
1677 PK_TYPE_11B
, &short_head
->ab
);
1679 /* Get Duration and TimeStampOff */
1680 short_head
->duration
= s_uGetDataDuration(pDevice
,
1681 PK_TYPE_11B
, false);
1682 short_head
->time_stamp_off
=
1683 vnt_time_stamp_off(pDevice
, wCurrentRate
);
1687 /* Generate Beacon Header */
1688 pMACHeader
= &pTX_Buffer
->hdr
;
1690 memcpy(pMACHeader
, pPacket
->p80211Header
, pPacket
->cbMPDULen
);
1692 pMACHeader
->duration_id
= 0;
1693 pMACHeader
->seq_ctrl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
1694 pDevice
->wSeqCounter
++;
1695 if (pDevice
->wSeqCounter
> 0x0fff)
1696 pDevice
->wSeqCounter
= 0;
1698 cbReqCount
= cbHeaderSize
+ WLAN_HDR_ADDR3_LEN
+ cbFrameBodySize
;
1700 pTX_Buffer
->wTxByteCount
= (u16
)cbReqCount
;
1701 pTX_Buffer
->byPKTNO
= (u8
) (((wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
1702 pTX_Buffer
->byType
= 0x01;
1704 pContext
->pPacket
= NULL
;
1705 pContext
->type
= CONTEXT_MGMT_PACKET
;
1706 pContext
->uBufLen
= (u16
)cbReqCount
+ 4; //USB header
1708 PIPEnsSendBulkOut(pDevice
,pContext
);
1709 return CMD_STATUS_PENDING
;
1713 void vDMA0_tx_80211(struct vnt_private
*pDevice
, struct sk_buff
*skb
)
1715 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
1716 struct vnt_tx_buffer
*pTX_Buffer
;
1717 struct vnt_tx_fifo_head
*pTxBufHead
;
1719 u8
*pbyTxBufferAddr
;
1720 u32 uDuration
, cbReqCount
;
1721 struct ieee80211_hdr
*pMACHeader
;
1722 u32 cbHeaderSize
, cbFrameBodySize
;
1723 int bNeedACK
, bIsPSPOLL
= false;
1725 u32 cbIVlen
= 0, cbICVlen
= 0, cbMIClen
= 0, cbFCSlen
= 4;
1727 u32 cbMICHDR
= 0, uLength
= 0;
1728 u32 dwMICKey0
, dwMICKey1
;
1730 u32
*pdwMIC_L
, *pdwMIC_R
;
1733 struct ethhdr sEthHeader
;
1734 struct vnt_mic_hdr
*pMICHDR
;
1735 u32 wCurrentRate
= RATE_1M
;
1736 PUWLAN_80211HDR p80211Header
;
1738 int bNodeExist
= false;
1740 PSKeyItem pTransmitKey
= NULL
;
1741 u8
*pbyIVHead
, *pbyPayloadHead
, *pbyMacHdr
;
1742 u32 cbExtSuppRate
= 0;
1743 struct vnt_usb_send_context
*pContext
;
1747 if(skb
->len
<= WLAN_HDR_ADDR3_LEN
) {
1748 cbFrameBodySize
= 0;
1751 cbFrameBodySize
= skb
->len
- WLAN_HDR_ADDR3_LEN
;
1753 p80211Header
= (PUWLAN_80211HDR
)skb
->data
;
1755 pContext
= s_vGetFreeContext(pDevice
);
1757 if (NULL
== pContext
) {
1758 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"DMA0 TX...NO CONTEXT!\n");
1759 dev_kfree_skb_irq(skb
);
1763 pTX_Buffer
= (struct vnt_tx_buffer
*)&pContext
->Data
[0];
1764 pTxBufHead
= &pTX_Buffer
->fifo_head
;
1765 pbyTxBufferAddr
= (u8
*)&pTxBufHead
->adwTxKey
[0];
1766 wTxBufSize
= sizeof(struct vnt_tx_fifo_head
);
1768 if (pDevice
->byBBType
== BB_TYPE_11A
) {
1769 wCurrentRate
= RATE_6M
;
1770 byPktType
= PK_TYPE_11A
;
1772 wCurrentRate
= RATE_1M
;
1773 byPktType
= PK_TYPE_11B
;
1776 // SetPower will cause error power TX state for OFDM Date packet in TX buffer.
1777 // 2004.11.11 Kyle -- Using OFDM power to tx MngPkt will decrease the connection capability.
1778 // And cmd timer will wait data pkt TX finish before scanning so it's OK
1779 // to set power here.
1780 if (pMgmt
->eScanState
!= WMAC_NO_SCANNING
) {
1781 RFbSetPower(pDevice
, wCurrentRate
, pDevice
->byCurrentCh
);
1783 RFbSetPower(pDevice
, wCurrentRate
, pMgmt
->uCurrChannel
);
1786 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"vDMA0_tx_80211: p80211Header->sA3.wFrameCtl = %x \n", p80211Header
->sA3
.wFrameCtl
);
1789 if (byPktType
== PK_TYPE_11A
) {//0000 0000 0000 0000
1790 pTxBufHead
->wFIFOCtl
= 0;
1792 else if (byPktType
== PK_TYPE_11B
) {//0000 0001 0000 0000
1793 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11B
;
1795 else if (byPktType
== PK_TYPE_11GB
) {//0000 0010 0000 0000
1796 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GB
;
1798 else if (byPktType
== PK_TYPE_11GA
) {//0000 0011 0000 0000
1799 pTxBufHead
->wFIFOCtl
|= FIFOCTL_11GA
;
1802 pTxBufHead
->wFIFOCtl
|= FIFOCTL_TMOEN
;
1803 pTxBufHead
->wTimeStamp
= cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us
);
1805 if (is_multicast_ether_addr(p80211Header
->sA3
.abyAddr1
)) {
1807 if (pDevice
->bEnableHostWEP
) {
1813 if (pDevice
->bEnableHostWEP
) {
1814 if (BSSbIsSTAInNodeDB(pDevice
, (u8
*)(p80211Header
->sA3
.abyAddr1
), &uNodeIndex
))
1818 pTxBufHead
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
1821 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) ||
1822 (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) ) {
1824 pTxBufHead
->wFIFOCtl
|= FIFOCTL_LRETRY
;
1825 //Set Preamble type always long
1826 //pDevice->byPreambleType = PREAMBLE_LONG;
1828 // probe-response don't retry
1829 //if ((p80211Header->sA4.wFrameCtl & TYPE_SUBTYPE_MASK) == TYPE_MGMT_PROBE_RSP) {
1830 // bNeedACK = false;
1831 // pTxBufHead->wFIFOCtl &= (~FIFOCTL_NEEDACK);
1835 pTxBufHead
->wFIFOCtl
|= (FIFOCTL_GENINT
| FIFOCTL_ISDMA0
);
1837 if ((p80211Header
->sA4
.wFrameCtl
& TYPE_SUBTYPE_MASK
) == TYPE_CTL_PSPOLL
) {
1839 cbMacHdLen
= WLAN_HDR_ADDR2_LEN
;
1841 cbMacHdLen
= WLAN_HDR_ADDR3_LEN
;
1844 // hostapd daemon ext support rate patch
1845 if (WLAN_GET_FC_FSTYPE(p80211Header
->sA4
.wFrameCtl
) == WLAN_FSTYPE_ASSOCRESP
) {
1847 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
!= 0) {
1848 cbExtSuppRate
+= ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
;
1851 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
!= 0) {
1852 cbExtSuppRate
+= ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
;
1855 if (cbExtSuppRate
>0) {
1856 cbFrameBodySize
= WLAN_ASSOCRESP_OFF_SUPP_RATES
;
1860 //Set FRAGCTL_MACHDCNT
1861 pTxBufHead
->wFragCtl
|= cpu_to_le16((u16
)cbMacHdLen
<< 10);
1864 // Although spec says MMPDU can be fragmented; In most case,
1865 // no one will send a MMPDU under fragmentation. With RTS may occur.
1867 if (WLAN_GET_FC_ISWEP(p80211Header
->sA4
.wFrameCtl
) != 0) {
1868 if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption1Enabled
) {
1871 pTxBufHead
->wFragCtl
|= FRAGCTL_LEGACY
;
1873 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption2Enabled
) {
1874 cbIVlen
= 8;//IV+ExtIV
1877 pTxBufHead
->wFragCtl
|= FRAGCTL_TKIP
;
1878 //We need to get seed here for filling TxKey entry.
1879 //TKIPvMixKey(pTransmitKey->abyKey, pDevice->abyCurrentNetAddr,
1880 // pTransmitKey->wTSC15_0, pTransmitKey->dwTSC47_16, pDevice->abyPRNG);
1882 else if (pDevice
->eEncryptionStatus
== Ndis802_11Encryption3Enabled
) {
1883 cbIVlen
= 8;//RSN Header
1885 cbMICHDR
= sizeof(struct vnt_mic_hdr
);
1886 pTxBufHead
->wFragCtl
|= FRAGCTL_AES
;
1888 //MAC Header should be padding 0 to DW alignment.
1889 uPadding
= 4 - (cbMacHdLen
%4);
1893 cbFrameSize
= cbMacHdLen
+ cbFrameBodySize
+ cbIVlen
+ cbMIClen
+ cbICVlen
+ cbFCSlen
+ cbExtSuppRate
;
1895 //Set FIFOCTL_GrpAckPolicy
1896 if (pDevice
->bGrpAckPolicy
== true) {//0000 0100 0000 0000
1897 pTxBufHead
->wFIFOCtl
|= FIFOCTL_GRPACK
;
1899 //the rest of pTxBufHead->wFragCtl:FragTyp will be set later in s_vFillFragParameter()
1901 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {//802.11g packet
1902 cbHeaderSize
= wTxBufSize
+ sizeof(struct vnt_rrv_time_cts
) + cbMICHDR
+
1903 sizeof(struct vnt_cts
);
1906 else {//802.11a/b packet
1907 cbHeaderSize
= wTxBufSize
+ sizeof(struct vnt_rrv_time_ab
) + cbMICHDR
+
1908 sizeof(struct vnt_tx_datahead_ab
);
1910 memcpy(&(sEthHeader
.h_dest
[0]),
1911 &(p80211Header
->sA3
.abyAddr1
[0]),
1913 memcpy(&(sEthHeader
.h_source
[0]),
1914 &(p80211Header
->sA3
.abyAddr2
[0]),
1916 //=========================
1918 //=========================
1919 pTxBufHead
->wFragCtl
|= (u16
)FRAGCTL_NONFRAG
;
1921 /* Fill FIFO,RrvTime,RTS,and CTS */
1922 uDuration
= s_vGenerateTxParameter(pDevice
, byPktType
, wCurrentRate
,
1923 pTX_Buffer
, &pMICHDR
, cbMICHDR
,
1924 cbFrameSize
, bNeedACK
, TYPE_TXDMA0
, &sEthHeader
, false);
1926 pMACHeader
= (struct ieee80211_hdr
*) (pbyTxBufferAddr
+ cbHeaderSize
);
1928 cbReqCount
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
+ (cbFrameBodySize
+ cbMIClen
) + cbExtSuppRate
;
1930 pbyMacHdr
= (u8
*)(pbyTxBufferAddr
+ cbHeaderSize
);
1931 pbyPayloadHead
= (u8
*)(pbyMacHdr
+ cbMacHdLen
+ uPadding
+ cbIVlen
);
1932 pbyIVHead
= (u8
*)(pbyMacHdr
+ cbMacHdLen
+ uPadding
);
1934 // Copy the Packet into a tx Buffer
1935 memcpy(pbyMacHdr
, skb
->data
, cbMacHdLen
);
1937 // version set to 0, patch for hostapd deamon
1938 pMACHeader
->frame_control
&= cpu_to_le16(0xfffc);
1939 memcpy(pbyPayloadHead
, (skb
->data
+ cbMacHdLen
), cbFrameBodySize
);
1941 // replace support rate, patch for hostapd daemon( only support 11M)
1942 if (WLAN_GET_FC_FSTYPE(p80211Header
->sA4
.wFrameCtl
) == WLAN_FSTYPE_ASSOCRESP
) {
1943 if (cbExtSuppRate
!= 0) {
1944 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
!= 0)
1945 memcpy((pbyPayloadHead
+ cbFrameBodySize
),
1946 pMgmt
->abyCurrSuppRates
,
1947 ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
1949 if (((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
!= 0)
1950 memcpy((pbyPayloadHead
+ cbFrameBodySize
) + ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrSuppRates
)->len
+ WLAN_IEHDR_LEN
,
1951 pMgmt
->abyCurrExtSuppRates
,
1952 ((PWLAN_IE_SUPP_RATES
)pMgmt
->abyCurrExtSuppRates
)->len
+ WLAN_IEHDR_LEN
1958 if (WLAN_GET_FC_ISWEP(p80211Header
->sA4
.wFrameCtl
) != 0) {
1960 if (pDevice
->bEnableHostWEP
) {
1961 pTransmitKey
= &STempKey
;
1962 pTransmitKey
->byCipherSuite
= pMgmt
->sNodeDBTable
[uNodeIndex
].byCipherSuite
;
1963 pTransmitKey
->dwKeyIndex
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
;
1964 pTransmitKey
->uKeyLength
= pMgmt
->sNodeDBTable
[uNodeIndex
].uWepKeyLength
;
1965 pTransmitKey
->dwTSC47_16
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
;
1966 pTransmitKey
->wTSC15_0
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
;
1967 memcpy(pTransmitKey
->abyKey
,
1968 &pMgmt
->sNodeDBTable
[uNodeIndex
].abyWepKey
[0],
1969 pTransmitKey
->uKeyLength
1973 if ((pTransmitKey
!= NULL
) && (pTransmitKey
->byCipherSuite
== KEY_CTL_TKIP
)) {
1975 dwMICKey0
= *(u32
*)(&pTransmitKey
->abyKey
[16]);
1976 dwMICKey1
= *(u32
*)(&pTransmitKey
->abyKey
[20]);
1978 // DO Software Michael
1979 MIC_vInit(dwMICKey0
, dwMICKey1
);
1980 MIC_vAppend((u8
*)&(sEthHeader
.h_dest
[0]), 12);
1982 MIC_vAppend((u8
*)&dwMIC_Priority
, 4);
1983 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"DMA0_tx_8021:MIC KEY:"\
1984 " %X, %X\n", dwMICKey0
, dwMICKey1
);
1986 uLength
= cbHeaderSize
+ cbMacHdLen
+ uPadding
+ cbIVlen
;
1988 MIC_vAppend((pbyTxBufferAddr
+ uLength
), cbFrameBodySize
);
1990 pdwMIC_L
= (u32
*)(pbyTxBufferAddr
+ uLength
+ cbFrameBodySize
);
1991 pdwMIC_R
= (u32
*)(pbyTxBufferAddr
+ uLength
+ cbFrameBodySize
+ 4);
1993 MIC_vGetMIC(pdwMIC_L
, pdwMIC_R
);
1996 if (pDevice
->bTxMICFail
== true) {
1999 pDevice
->bTxMICFail
= false;
2002 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"uLength: %d, %d\n", uLength
, cbFrameBodySize
);
2003 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"cbReqCount:%d, %d, %d, %d\n", cbReqCount
, cbHeaderSize
, uPadding
, cbIVlen
);
2004 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"MIC:%x, %x\n",
2005 *pdwMIC_L
, *pdwMIC_R
);
2009 s_vFillTxKey(pDevice
, pTxBufHead
, pbyIVHead
, pTransmitKey
,
2010 pbyMacHdr
, (u16
)cbFrameBodySize
, pMICHDR
);
2012 if (pDevice
->bEnableHostWEP
) {
2013 pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
= pTransmitKey
->dwTSC47_16
;
2014 pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
= pTransmitKey
->wTSC15_0
;
2017 if ((pDevice
->byLocalID
<= REV_ID_VT3253_A1
)) {
2018 s_vSWencryption(pDevice
, pTransmitKey
, pbyPayloadHead
, (u16
)(cbFrameBodySize
+ cbMIClen
));
2022 pMACHeader
->seq_ctrl
= cpu_to_le16(pDevice
->wSeqCounter
<< 4);
2023 pDevice
->wSeqCounter
++ ;
2024 if (pDevice
->wSeqCounter
> 0x0fff)
2025 pDevice
->wSeqCounter
= 0;
2028 // The MAC will automatically replace the Duration-field of MAC header by Duration-field
2029 // of FIFO control header.
2030 // This will cause AID-field of PS-POLL packet be incorrect (Because PS-POLL's AID field is
2031 // in the same place of other packet's Duration-field).
2032 // And it will cause Cisco-AP to issue Disassociation-packet
2033 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
2034 struct vnt_tx_datahead_g
*data_head
= &pTX_Buffer
->tx_head
.
2035 tx_cts
.tx
.head
.cts_g
.data_head
;
2036 data_head
->duration_a
=
2037 cpu_to_le16(p80211Header
->sA2
.wDurationID
);
2038 data_head
->duration_b
=
2039 cpu_to_le16(p80211Header
->sA2
.wDurationID
);
2041 struct vnt_tx_datahead_ab
*data_head
= &pTX_Buffer
->tx_head
.
2042 tx_ab
.tx
.head
.data_head_ab
;
2043 data_head
->duration
=
2044 cpu_to_le16(p80211Header
->sA2
.wDurationID
);
2048 pTX_Buffer
->wTxByteCount
= cpu_to_le16((u16
)(cbReqCount
));
2049 pTX_Buffer
->byPKTNO
= (u8
) (((wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
2050 pTX_Buffer
->byType
= 0x00;
2052 pContext
->pPacket
= skb
;
2053 pContext
->type
= CONTEXT_MGMT_PACKET
;
2054 pContext
->uBufLen
= (u16
)cbReqCount
+ 4; //USB header
2056 if (WLAN_GET_FC_TODS(pMACHeader
->frame_control
) == 0) {
2057 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
2058 &pMACHeader
->addr1
[0], (u16
)cbFrameSize
,
2059 pTxBufHead
->wFIFOCtl
);
2062 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
2063 &pMACHeader
->addr3
[0], (u16
)cbFrameSize
,
2064 pTxBufHead
->wFIFOCtl
);
2066 PIPEnsSendBulkOut(pDevice
,pContext
);
2071 //TYPE_AC0DMA data tx
2074 * Tx packet via AC0DMA(DMA1)
2078 * pDevice - Pointer to the adapter
2079 * skb - Pointer to tx skb packet
2083 * Return Value: NULL
2086 int nsDMA_tx_packet(struct vnt_private
*pDevice
,
2087 u32 uDMAIdx
, struct sk_buff
*skb
)
2089 struct net_device_stats
*pStats
= &pDevice
->stats
;
2090 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2091 struct vnt_tx_buffer
*pTX_Buffer
;
2092 u32 BytesToWrite
= 0, uHeaderLen
= 0;
2094 u8 byMask
[8] = {1, 2, 4, 8, 0x10, 0x20, 0x40, 0x80};
2097 int bNeedEncryption
= false;
2098 PSKeyItem pTransmitKey
= NULL
;
2101 int bTKIP_UseGTK
= false;
2102 int bNeedDeAuth
= false;
2104 int bNodeExist
= false;
2105 struct vnt_usb_send_context
*pContext
;
2106 bool fConvertedPacket
;
2108 u16 wKeepRate
= pDevice
->wCurrentRate
;
2109 int bTxeapol_key
= false;
2111 if (pMgmt
->eCurrMode
== WMAC_MODE_ESS_AP
) {
2113 if (pDevice
->uAssocCount
== 0) {
2114 dev_kfree_skb_irq(skb
);
2118 if (is_multicast_ether_addr((u8
*)(skb
->data
))) {
2121 if (pMgmt
->sNodeDBTable
[0].bPSEnable
) {
2123 skb_queue_tail(&(pMgmt
->sNodeDBTable
[0].sTxPSQueue
), skb
);
2124 pMgmt
->sNodeDBTable
[0].wEnQueueCnt
++;
2126 pMgmt
->abyPSTxMap
[0] |= byMask
[0];
2129 // multicast/broadcast data rate
2131 if (pDevice
->byBBType
!= BB_TYPE_11A
)
2132 pDevice
->wCurrentRate
= RATE_2M
;
2134 pDevice
->wCurrentRate
= RATE_24M
;
2135 // long preamble type
2136 pDevice
->byPreambleType
= PREAMBLE_SHORT
;
2140 if (BSSbIsSTAInNodeDB(pDevice
, (u8
*)(skb
->data
), &uNodeIndex
)) {
2142 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bPSEnable
) {
2144 skb_queue_tail(&pMgmt
->sNodeDBTable
[uNodeIndex
].sTxPSQueue
, skb
);
2146 pMgmt
->sNodeDBTable
[uNodeIndex
].wEnQueueCnt
++;
2148 wAID
= pMgmt
->sNodeDBTable
[uNodeIndex
].wAID
;
2149 pMgmt
->abyPSTxMap
[wAID
>> 3] |= byMask
[wAID
& 7];
2150 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Set:pMgmt->abyPSTxMap[%d]= %d\n",
2151 (wAID
>> 3), pMgmt
->abyPSTxMap
[wAID
>> 3]);
2155 // AP rate decided from node
2156 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
;
2157 // tx preamble decided from node
2159 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
) {
2160 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2163 pDevice
->byPreambleType
= PREAMBLE_LONG
;
2169 if (bNodeExist
== false) {
2170 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Unknown STA not found in node DB \n");
2171 dev_kfree_skb_irq(skb
);
2176 pContext
= s_vGetFreeContext(pDevice
);
2178 if (pContext
== NULL
) {
2179 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
" pContext == NULL\n");
2180 dev_kfree_skb_irq(skb
);
2181 return STATUS_RESOURCES
;
2184 memcpy(pDevice
->sTxEthHeader
.h_dest
, (u8
*)(skb
->data
), ETH_HLEN
);
2186 //mike add:station mode check eapol-key challenge--->
2188 u8 Protocol_Version
; //802.1x Authentication
2189 u8 Packet_Type
; //802.1x Authentication
2193 Protocol_Version
= skb
->data
[ETH_HLEN
];
2194 Packet_Type
= skb
->data
[ETH_HLEN
+1];
2195 Descriptor_type
= skb
->data
[ETH_HLEN
+1+1+2];
2196 Key_info
= (skb
->data
[ETH_HLEN
+1+1+2+1] << 8)|(skb
->data
[ETH_HLEN
+1+1+2+2]);
2197 if (pDevice
->sTxEthHeader
.h_proto
== cpu_to_be16(ETH_P_PAE
)) {
2198 /* 802.1x OR eapol-key challenge frame transfer */
2199 if (((Protocol_Version
== 1) || (Protocol_Version
== 2)) &&
2200 (Packet_Type
== 3)) {
2201 bTxeapol_key
= true;
2202 if(!(Key_info
& BIT3
) && //WPA or RSN group-key challenge
2203 (Key_info
& BIT8
) && (Key_info
& BIT9
)) { //send 2/2 key
2204 if(Descriptor_type
==254) {
2205 pDevice
->fWPA_Authened
= true;
2209 pDevice
->fWPA_Authened
= true;
2210 PRINT_K("WPA2(re-keying) ");
2212 PRINT_K("Authentication completed!!\n");
2214 else if((Key_info
& BIT3
) && (Descriptor_type
==2) && //RSN pairwise-key challenge
2215 (Key_info
& BIT8
) && (Key_info
& BIT9
)) {
2216 pDevice
->fWPA_Authened
= true;
2217 PRINT_K("WPA2 Authentication completed!!\n");
2222 //mike add:station mode check eapol-key challenge<---
2224 if (pDevice
->bEncryptionEnable
== true) {
2225 bNeedEncryption
= true;
2228 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) &&
2229 (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
2230 pbyBSSID
= pDevice
->abyBSSID
;
2232 if (KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == false) {
2234 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == true) {
2235 bTKIP_UseGTK
= true;
2236 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get GTK.\n");
2240 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get PTK.\n");
2243 }else if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2244 /* TO_DS = 0 and FROM_DS = 0 --> 802.11 MAC Address1 */
2245 pbyBSSID
= pDevice
->sTxEthHeader
.h_dest
;
2246 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"IBSS Serach Key: \n");
2247 for (ii
= 0; ii
< 6; ii
++)
2248 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"%x \n", *(pbyBSSID
+ii
));
2249 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"\n");
2252 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, PAIRWISE_KEY
, &pTransmitKey
) == true)
2256 pbyBSSID
= pDevice
->abyBroadcastAddr
;
2257 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == false) {
2258 pTransmitKey
= NULL
;
2259 if (pMgmt
->eCurrMode
== WMAC_MODE_IBSS_STA
) {
2260 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"IBSS and KEY is NULL. [%d]\n", pMgmt
->eCurrMode
);
2263 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"NOT IBSS and KEY is NULL. [%d]\n", pMgmt
->eCurrMode
);
2265 bTKIP_UseGTK
= true;
2266 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get GTK.\n");
2271 if (pDevice
->bEnableHostWEP
) {
2272 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"acdma0: STA index %d\n", uNodeIndex
);
2273 if (pDevice
->bEncryptionEnable
== true) {
2274 pTransmitKey
= &STempKey
;
2275 pTransmitKey
->byCipherSuite
= pMgmt
->sNodeDBTable
[uNodeIndex
].byCipherSuite
;
2276 pTransmitKey
->dwKeyIndex
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
;
2277 pTransmitKey
->uKeyLength
= pMgmt
->sNodeDBTable
[uNodeIndex
].uWepKeyLength
;
2278 pTransmitKey
->dwTSC47_16
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
;
2279 pTransmitKey
->wTSC15_0
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
;
2280 memcpy(pTransmitKey
->abyKey
,
2281 &pMgmt
->sNodeDBTable
[uNodeIndex
].abyWepKey
[0],
2282 pTransmitKey
->uKeyLength
2287 byPktType
= (u8
)pDevice
->byPacketType
;
2289 if (pDevice
->bFixRate
) {
2290 if (pDevice
->byBBType
== BB_TYPE_11B
) {
2291 if (pDevice
->uConnectionRate
>= RATE_11M
) {
2292 pDevice
->wCurrentRate
= RATE_11M
;
2294 pDevice
->wCurrentRate
= (u16
)pDevice
->uConnectionRate
;
2297 if ((pDevice
->byBBType
== BB_TYPE_11A
) &&
2298 (pDevice
->uConnectionRate
<= RATE_6M
)) {
2299 pDevice
->wCurrentRate
= RATE_6M
;
2301 if (pDevice
->uConnectionRate
>= RATE_54M
)
2302 pDevice
->wCurrentRate
= RATE_54M
;
2304 pDevice
->wCurrentRate
= (u16
)pDevice
->uConnectionRate
;
2309 if (pDevice
->op_mode
== NL80211_IFTYPE_ADHOC
) {
2310 // Adhoc Tx rate decided from node DB
2311 if (is_multicast_ether_addr(pDevice
->sTxEthHeader
.h_dest
)) {
2312 // Multicast use highest data rate
2313 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[0].wTxDataRate
;
2315 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2318 if (BSSbIsSTAInNodeDB(pDevice
, &(pDevice
->sTxEthHeader
.h_dest
[0]), &uNodeIndex
)) {
2319 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
;
2320 if (pMgmt
->sNodeDBTable
[uNodeIndex
].bShortPreamble
) {
2321 pDevice
->byPreambleType
= pDevice
->byShortPreamble
;
2325 pDevice
->byPreambleType
= PREAMBLE_LONG
;
2327 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Found Node Index is [%d] Tx Data Rate:[%d]\n",uNodeIndex
, pDevice
->wCurrentRate
);
2330 if (pDevice
->byBBType
!= BB_TYPE_11A
)
2331 pDevice
->wCurrentRate
= RATE_2M
;
2333 pDevice
->wCurrentRate
= RATE_24M
; // refer to vMgrCreateOwnIBSS()'s
2334 // abyCurrExtSuppRates[]
2335 pDevice
->byPreambleType
= PREAMBLE_SHORT
;
2336 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Not Found Node use highest basic Rate.....\n");
2340 if (pDevice
->op_mode
== NL80211_IFTYPE_STATION
) {
2341 // Infra STA rate decided from AP Node, index = 0
2342 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[0].wTxDataRate
;
2346 if (pDevice
->sTxEthHeader
.h_proto
== cpu_to_be16(ETH_P_PAE
)) {
2347 if (pDevice
->byBBType
!= BB_TYPE_11A
) {
2348 pDevice
->wCurrentRate
= RATE_1M
;
2349 pDevice
->byACKRate
= RATE_1M
;
2350 pDevice
->byTopCCKBasicRate
= RATE_1M
;
2351 pDevice
->byTopOFDMBasicRate
= RATE_6M
;
2353 pDevice
->wCurrentRate
= RATE_6M
;
2354 pDevice
->byACKRate
= RATE_6M
;
2355 pDevice
->byTopCCKBasicRate
= RATE_1M
;
2356 pDevice
->byTopOFDMBasicRate
= RATE_6M
;
2360 DBG_PRT(MSG_LEVEL_DEBUG
,
2361 KERN_INFO
"dma_tx: pDevice->wCurrentRate = %d\n",
2362 pDevice
->wCurrentRate
);
2364 if (wKeepRate
!= pDevice
->wCurrentRate
) {
2365 bScheduleCommand((void *) pDevice
, WLAN_CMD_SETPOWER
, NULL
);
2368 if (pDevice
->wCurrentRate
<= RATE_11M
) {
2369 byPktType
= PK_TYPE_11B
;
2372 if (bNeedEncryption
== true) {
2373 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"ntohs Pkt Type=%04x\n", ntohs(pDevice
->sTxEthHeader
.h_proto
));
2374 if ((pDevice
->sTxEthHeader
.h_proto
) == cpu_to_be16(ETH_P_PAE
)) {
2375 bNeedEncryption
= false;
2376 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Pkt Type=%04x\n", (pDevice
->sTxEthHeader
.h_proto
));
2377 if ((pMgmt
->eCurrMode
== WMAC_MODE_ESS_STA
) && (pMgmt
->eCurrState
== WMAC_STATE_ASSOC
)) {
2378 if (pTransmitKey
== NULL
) {
2379 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Don't Find TX KEY\n");
2382 if (bTKIP_UseGTK
== true) {
2383 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"error: KEY is GTK!!~~\n");
2386 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Find PTK [%X]\n",
2387 pTransmitKey
->dwKeyIndex
);
2388 bNeedEncryption
= true;
2393 if (pDevice
->bEnableHostWEP
) {
2394 if ((uNodeIndex
!= 0) &&
2395 (pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
& PAIRWISE_KEY
)) {
2396 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"Find PTK [%X]\n",
2397 pTransmitKey
->dwKeyIndex
);
2398 bNeedEncryption
= true;
2404 if (pTransmitKey
== NULL
) {
2405 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"return no tx key\n");
2406 pContext
->bBoolInUse
= false;
2407 dev_kfree_skb_irq(skb
);
2408 pStats
->tx_dropped
++;
2409 return STATUS_FAILURE
;
2414 pTX_Buffer
= (struct vnt_tx_buffer
*)&pContext
->Data
[0];
2416 fConvertedPacket
= s_bPacketToWirelessUsb(pDevice
, byPktType
,
2417 pTX_Buffer
, bNeedEncryption
,
2418 skb
->len
, uDMAIdx
, &pDevice
->sTxEthHeader
,
2419 (u8
*)skb
->data
, pTransmitKey
, uNodeIndex
,
2420 pDevice
->wCurrentRate
,
2421 &uHeaderLen
, &BytesToWrite
2424 if (fConvertedPacket
== false) {
2425 pContext
->bBoolInUse
= false;
2426 dev_kfree_skb_irq(skb
);
2427 return STATUS_FAILURE
;
2430 if ( pDevice
->bEnablePSMode
== true ) {
2431 if ( !pDevice
->bPSModeTxBurst
) {
2432 bScheduleCommand((void *) pDevice
,
2433 WLAN_CMD_MAC_DISPOWERSAVING
,
2435 pDevice
->bPSModeTxBurst
= true;
2439 pTX_Buffer
->byPKTNO
= (u8
) (((pDevice
->wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
2440 pTX_Buffer
->wTxByteCount
= (u16
)BytesToWrite
;
2442 pContext
->pPacket
= skb
;
2443 pContext
->type
= CONTEXT_DATA_PACKET
;
2444 pContext
->uBufLen
= (u16
)BytesToWrite
+ 4 ; //USB header
2446 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
2447 &pDevice
->sTxEthHeader
.h_dest
[0],
2448 (u16
)(BytesToWrite
-uHeaderLen
),
2449 pTX_Buffer
->fifo_head
.wFIFOCtl
);
2451 status
= PIPEnsSendBulkOut(pDevice
,pContext
);
2453 if (bNeedDeAuth
== true) {
2454 u16 wReason
= WLAN_MGMT_REASON_MIC_FAILURE
;
2456 bScheduleCommand((void *) pDevice
, WLAN_CMD_DEAUTH
, (u8
*) &wReason
);
2459 if(status
!=STATUS_PENDING
) {
2460 pContext
->bBoolInUse
= false;
2461 dev_kfree_skb_irq(skb
);
2462 return STATUS_FAILURE
;
2471 * Relay packet send (AC1DMA) from rx dpc.
2475 * pDevice - Pointer to the adapter
2476 * pPacket - Pointer to rx packet
2477 * cbPacketSize - rx ethernet frame size
2481 * Return Value: Return true if packet is copy to dma1; otherwise false
2484 int bRelayPacketSend(struct vnt_private
*pDevice
, u8
*pbySkbData
, u32 uDataLen
,
2487 struct vnt_manager
*pMgmt
= &pDevice
->vnt_mgmt
;
2488 struct vnt_tx_buffer
*pTX_Buffer
;
2489 u32 BytesToWrite
= 0, uHeaderLen
= 0;
2490 u8 byPktType
= PK_TYPE_11B
;
2491 int bNeedEncryption
= false;
2493 PSKeyItem pTransmitKey
= NULL
;
2495 struct vnt_usb_send_context
*pContext
;
2497 int fConvertedPacket
;
2499 u16 wKeepRate
= pDevice
->wCurrentRate
;
2501 pContext
= s_vGetFreeContext(pDevice
);
2503 if (NULL
== pContext
) {
2507 memcpy(pDevice
->sTxEthHeader
.h_dest
, (u8
*)pbySkbData
, ETH_HLEN
);
2509 if (pDevice
->bEncryptionEnable
== true) {
2510 bNeedEncryption
= true;
2512 pbyBSSID
= pDevice
->abyBroadcastAddr
;
2513 if(KeybGetTransmitKey(&(pDevice
->sKey
), pbyBSSID
, GROUP_KEY
, &pTransmitKey
) == false) {
2514 pTransmitKey
= NULL
;
2515 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"KEY is NULL. [%d]\n", pMgmt
->eCurrMode
);
2517 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_DEBUG
"Get GTK.\n");
2521 if (pDevice
->bEnableHostWEP
) {
2522 if (uNodeIndex
< MAX_NODE_NUM
+ 1) {
2523 pTransmitKey
= &STempKey
;
2524 pTransmitKey
->byCipherSuite
= pMgmt
->sNodeDBTable
[uNodeIndex
].byCipherSuite
;
2525 pTransmitKey
->dwKeyIndex
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwKeyIndex
;
2526 pTransmitKey
->uKeyLength
= pMgmt
->sNodeDBTable
[uNodeIndex
].uWepKeyLength
;
2527 pTransmitKey
->dwTSC47_16
= pMgmt
->sNodeDBTable
[uNodeIndex
].dwTSC47_16
;
2528 pTransmitKey
->wTSC15_0
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTSC15_0
;
2529 memcpy(pTransmitKey
->abyKey
,
2530 &pMgmt
->sNodeDBTable
[uNodeIndex
].abyWepKey
[0],
2531 pTransmitKey
->uKeyLength
2536 if ( bNeedEncryption
&& (pTransmitKey
== NULL
) ) {
2537 pContext
->bBoolInUse
= false;
2541 byPktTyp
= (u8
)pDevice
->byPacketType
;
2543 if (pDevice
->bFixRate
) {
2544 if (pDevice
->byBBType
== BB_TYPE_11B
) {
2545 if (pDevice
->uConnectionRate
>= RATE_11M
) {
2546 pDevice
->wCurrentRate
= RATE_11M
;
2548 pDevice
->wCurrentRate
= (u16
)pDevice
->uConnectionRate
;
2551 if ((pDevice
->byBBType
== BB_TYPE_11A
) &&
2552 (pDevice
->uConnectionRate
<= RATE_6M
)) {
2553 pDevice
->wCurrentRate
= RATE_6M
;
2555 if (pDevice
->uConnectionRate
>= RATE_54M
)
2556 pDevice
->wCurrentRate
= RATE_54M
;
2558 pDevice
->wCurrentRate
= (u16
)pDevice
->uConnectionRate
;
2563 pDevice
->wCurrentRate
= pMgmt
->sNodeDBTable
[uNodeIndex
].wTxDataRate
;
2566 if (wKeepRate
!= pDevice
->wCurrentRate
) {
2567 bScheduleCommand((void *) pDevice
, WLAN_CMD_SETPOWER
, NULL
);
2570 if (pDevice
->wCurrentRate
<= RATE_11M
)
2571 byPktType
= PK_TYPE_11B
;
2573 BytesToWrite
= uDataLen
+ ETH_FCS_LEN
;
2575 // Convert the packet to an usb frame and copy into our buffer
2576 // and send the irp.
2578 pTX_Buffer
= (struct vnt_tx_buffer
*)&pContext
->Data
[0];
2580 fConvertedPacket
= s_bPacketToWirelessUsb(pDevice
, byPktType
,
2581 pTX_Buffer
, bNeedEncryption
,
2582 uDataLen
, TYPE_AC0DMA
, &pDevice
->sTxEthHeader
,
2583 pbySkbData
, pTransmitKey
, uNodeIndex
,
2584 pDevice
->wCurrentRate
,
2585 &uHeaderLen
, &BytesToWrite
2588 if (fConvertedPacket
== false) {
2589 pContext
->bBoolInUse
= false;
2593 pTX_Buffer
->byPKTNO
= (u8
) (((pDevice
->wCurrentRate
<<4) &0x00F0) | ((pDevice
->wSeqCounter
- 1) & 0x000F));
2594 pTX_Buffer
->wTxByteCount
= (u16
)BytesToWrite
;
2596 pContext
->pPacket
= NULL
;
2597 pContext
->type
= CONTEXT_DATA_PACKET
;
2598 pContext
->uBufLen
= (u16
)BytesToWrite
+ 4 ; //USB header
2600 s_vSaveTxPktInfo(pDevice
, (u8
)(pTX_Buffer
->byPKTNO
& 0x0F),
2601 &pDevice
->sTxEthHeader
.h_dest
[0],
2602 (u16
)(BytesToWrite
- uHeaderLen
),
2603 pTX_Buffer
->fifo_head
.wFIFOCtl
);
2605 status
= PIPEnsSendBulkOut(pDevice
,pContext
);