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 * csBeacon_xmit - beacon tx function
30 * csMgmt_xmit - management tx function
31 * s_uGetDataDuration - get tx data required duration
32 * s_uFillDataHead- fulfill tx data duration header
33 * s_uGetRTSCTSDuration- get rtx/cts required duration
34 * s_uGetRTSCTSRsvTime- get rts/cts reserved time
35 * s_uGetTxRsvTime- get frame reserved time
36 * s_vFillCTSHead- fulfill CTS ctl header
37 * s_vFillFragParameter- Set fragment ctl parameter.
38 * s_vFillRTSHead- fulfill RTS ctl header
39 * vDMA0_tx_80211- tx 802.11 frame via dma0
40 * vGenerateFIFOHeader- Generate tx FIFO ctl header
53 static int msglevel
= MSG_LEVEL_INFO
;
55 static const u16 wTimeStampOff
[2][MAX_RATE
] = {
56 {384, 288, 226, 209, 54, 43, 37, 31, 28, 25, 24, 23}, // Long Preamble
57 {384, 192, 130, 113, 54, 43, 37, 31, 28, 25, 24, 23}, // Short Preamble
60 static const u16 wFB_Opt0
[2][5] = {
61 {RATE_12M
, RATE_18M
, RATE_24M
, RATE_36M
, RATE_48M
}, // fallback_rate0
62 {RATE_12M
, RATE_12M
, RATE_18M
, RATE_24M
, RATE_36M
}, // fallback_rate1
64 static const u16 wFB_Opt1
[2][5] = {
65 {RATE_12M
, RATE_18M
, RATE_24M
, RATE_24M
, RATE_36M
}, // fallback_rate0
66 {RATE_6M
, RATE_6M
, RATE_12M
, RATE_12M
, RATE_18M
}, // fallback_rate1
73 #define RTSDUR_BA_F0 4
74 #define RTSDUR_AA_F0 5
75 #define RTSDUR_BA_F1 6
76 #define RTSDUR_AA_F1 7
77 #define CTSDUR_BA_F0 8
78 #define CTSDUR_BA_F1 9
81 #define DATADUR_A_F0 12
82 #define DATADUR_A_F1 13
84 static struct vnt_usb_send_context
*s_vGetFreeContext(struct vnt_private
*);
86 static u16
s_vGenerateTxParameter(struct vnt_usb_send_context
*tx_context
,
87 u8 byPktType
, u16 wCurrentRate
, struct vnt_tx_buffer
*tx_buffer
,
88 struct vnt_mic_hdr
**mic_hdr
, u32 need_mic
, u32 cbFrameSize
,
89 int bNeedACK
, bool need_rts
);
91 static unsigned int s_uGetTxRsvTime(struct vnt_private
*pDevice
, u8 byPktType
,
92 u32 cbFrameLength
, u16 wRate
, int bNeedAck
);
94 static __le16
s_uGetRTSCTSRsvTime(struct vnt_private
*priv
,
95 u8 rsv_type
, u8 pkt_type
, u32 frame_length
, u16 current_rate
);
97 static u16
s_vFillCTSHead(struct vnt_usb_send_context
*tx_context
,
98 u8 byPktType
, union vnt_tx_data_head
*head
, u32 cbFrameLength
,
99 int bNeedAck
, u16 wCurrentRate
);
101 static u16
s_vFillRTSHead(struct vnt_usb_send_context
*tx_context
, u8 byPktType
,
102 union vnt_tx_data_head
*head
, u32 cbFrameLength
, int bNeedAck
,
105 static __le16
s_uGetDataDuration(struct vnt_private
*pDevice
,
106 u8 byPktType
, int bNeedAck
);
108 static __le16
s_uGetRTSCTSDuration(struct vnt_private
*pDevice
,
109 u8 byDurType
, u32 cbFrameLength
, u8 byPktType
, u16 wRate
,
112 static struct vnt_usb_send_context
113 *s_vGetFreeContext(struct vnt_private
*priv
)
115 struct vnt_usb_send_context
*context
= NULL
;
118 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"GetFreeContext()\n");
120 for (ii
= 0; ii
< priv
->cbTD
; ii
++) {
124 context
= priv
->apTD
[ii
];
125 if (context
->in_use
== false) {
126 context
->in_use
= true;
127 memset(context
->data
, 0,
128 MAX_TOTAL_SIZE_WITH_ALL_HEADERS
);
136 if (ii
== priv
->cbTD
)
137 DBG_PRT(MSG_LEVEL_DEBUG
, KERN_INFO
"No Free Tx Context\n");
142 static __le16
vnt_time_stamp_off(struct vnt_private
*priv
, u16 rate
)
144 return cpu_to_le16(wTimeStampOff
[priv
->byPreambleType
% 2]
148 /*byPktType : PK_TYPE_11A 0
153 static u32
s_uGetTxRsvTime(struct vnt_private
*priv
, u8 pkt_type
,
154 u32 frame_length
, u16 rate
, int need_ack
)
156 u32 data_time
, ack_time
;
158 data_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
161 if (pkt_type
== PK_TYPE_11B
)
162 ack_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
163 14, (u16
)priv
->byTopCCKBasicRate
);
165 ack_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
166 14, (u16
)priv
->byTopOFDMBasicRate
);
169 return data_time
+ priv
->uSIFS
+ ack_time
;
174 static __le16
vnt_rxtx_rsvtime_le16(struct vnt_private
*priv
, u8 pkt_type
,
175 u32 frame_length
, u16 rate
, int need_ack
)
177 return cpu_to_le16((u16
)s_uGetTxRsvTime(priv
, pkt_type
,
178 frame_length
, rate
, need_ack
));
181 //byFreqType: 0=>5GHZ 1=>2.4GHZ
182 static __le16
s_uGetRTSCTSRsvTime(struct vnt_private
*priv
,
183 u8 rsv_type
, u8 pkt_type
, u32 frame_length
, u16 current_rate
)
185 u32 rrv_time
, rts_time
, cts_time
, ack_time
, data_time
;
187 rrv_time
= rts_time
= cts_time
= ack_time
= data_time
= 0;
189 data_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
190 frame_length
, current_rate
);
193 rts_time
= vnt_get_frame_time(priv
->byPreambleType
,
194 pkt_type
, 20, priv
->byTopCCKBasicRate
);
195 cts_time
= ack_time
= vnt_get_frame_time(priv
->byPreambleType
,
196 pkt_type
, 14, priv
->byTopCCKBasicRate
);
197 } else if (rsv_type
== 1) {
198 rts_time
= vnt_get_frame_time(priv
->byPreambleType
,
199 pkt_type
, 20, priv
->byTopCCKBasicRate
);
200 cts_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
201 14, priv
->byTopCCKBasicRate
);
202 ack_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
203 14, priv
->byTopOFDMBasicRate
);
204 } else if (rsv_type
== 2) {
205 rts_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
206 20, priv
->byTopOFDMBasicRate
);
207 cts_time
= ack_time
= vnt_get_frame_time(priv
->byPreambleType
,
208 pkt_type
, 14, priv
->byTopOFDMBasicRate
);
209 } else if (rsv_type
== 3) {
210 cts_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
211 14, priv
->byTopCCKBasicRate
);
212 ack_time
= vnt_get_frame_time(priv
->byPreambleType
, pkt_type
,
213 14, priv
->byTopOFDMBasicRate
);
215 rrv_time
= cts_time
+ ack_time
+ data_time
+ 2 * priv
->uSIFS
;
217 return cpu_to_le16((u16
)rrv_time
);
220 rrv_time
= rts_time
+ cts_time
+ ack_time
+ data_time
+ 3 * priv
->uSIFS
;
222 return cpu_to_le16((u16
)rrv_time
);
225 //byFreqType 0: 5GHz, 1:2.4Ghz
226 static __le16
s_uGetDataDuration(struct vnt_private
*pDevice
,
227 u8 byPktType
, int bNeedAck
)
232 if (byPktType
== PK_TYPE_11B
)
233 uAckTime
= vnt_get_frame_time(pDevice
->byPreambleType
,
234 byPktType
, 14, pDevice
->byTopCCKBasicRate
);
236 uAckTime
= vnt_get_frame_time(pDevice
->byPreambleType
,
237 byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
238 return cpu_to_le16((u16
)(pDevice
->uSIFS
+ uAckTime
));
244 //byFreqType: 0=>5GHZ 1=>2.4GHZ
245 static __le16
s_uGetRTSCTSDuration(struct vnt_private
*pDevice
, u8 byDurType
,
246 u32 cbFrameLength
, u8 byPktType
, u16 wRate
, int bNeedAck
)
248 u32 uCTSTime
= 0, uDurTime
= 0;
255 uCTSTime
= vnt_get_frame_time(pDevice
->byPreambleType
,
256 byPktType
, 14, pDevice
->byTopCCKBasicRate
);
257 uDurTime
= uCTSTime
+ 2 * pDevice
->uSIFS
+
258 s_uGetTxRsvTime(pDevice
, byPktType
,
259 cbFrameLength
, wRate
, bNeedAck
);
265 uCTSTime
= vnt_get_frame_time(pDevice
->byPreambleType
,
266 byPktType
, 14, pDevice
->byTopOFDMBasicRate
);
267 uDurTime
= uCTSTime
+ 2 * pDevice
->uSIFS
+
268 s_uGetTxRsvTime(pDevice
, byPktType
,
269 cbFrameLength
, wRate
, bNeedAck
);
275 uDurTime
= pDevice
->uSIFS
+ s_uGetTxRsvTime(pDevice
,
276 byPktType
, cbFrameLength
, wRate
, bNeedAck
);
283 return cpu_to_le16((u16
)uDurTime
);
286 static u16
vnt_mac_hdr_pos(struct vnt_usb_send_context
*tx_context
,
287 struct ieee80211_hdr
*hdr
)
289 u8
*head
= tx_context
->data
+ offsetof(struct vnt_tx_buffer
, fifo_head
);
290 u8
*hdr_pos
= (u8
*)hdr
;
292 tx_context
->hdr
= hdr
;
293 if (!tx_context
->hdr
)
296 return (u16
)(hdr_pos
- head
);
299 static u16
vnt_rxtx_datahead_g(struct vnt_usb_send_context
*tx_context
,
300 u8 pkt_type
, u16 rate
, struct vnt_tx_datahead_g
*buf
,
301 u32 frame_len
, int need_ack
)
304 struct vnt_private
*priv
= tx_context
->priv
;
305 struct ieee80211_hdr
*hdr
=
306 (struct ieee80211_hdr
*)tx_context
->skb
->data
;
308 /* Get SignalField,ServiceField,Length */
309 vnt_get_phy_field(priv
, frame_len
, rate
, pkt_type
, &buf
->a
);
310 vnt_get_phy_field(priv
, frame_len
, priv
->byTopCCKBasicRate
,
311 PK_TYPE_11B
, &buf
->b
);
313 /* Get Duration and TimeStamp */
314 if (ieee80211_is_pspoll(hdr
->frame_control
)) {
315 __le16 dur
= cpu_to_le16(priv
->current_aid
| BIT(14) | BIT(15));
317 buf
->duration_a
= dur
;
318 buf
->duration_b
= dur
;
320 buf
->duration_a
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
321 buf
->duration_b
= s_uGetDataDuration(priv
,
322 PK_TYPE_11B
, need_ack
);
325 buf
->time_stamp_off_a
= vnt_time_stamp_off(priv
, rate
);
326 buf
->time_stamp_off_b
= vnt_time_stamp_off(priv
,
327 priv
->byTopCCKBasicRate
);
329 tx_context
->tx_hdr_size
= vnt_mac_hdr_pos(tx_context
, &buf
->hdr
);
331 return le16_to_cpu(buf
->duration_a
);
334 static u16
vnt_rxtx_datahead_g_fb(struct vnt_usb_send_context
*tx_context
,
335 u8 pkt_type
, u16 rate
, struct vnt_tx_datahead_g_fb
*buf
,
336 u32 frame_len
, int need_ack
)
338 struct vnt_private
*priv
= tx_context
->priv
;
340 /* Get SignalField,ServiceField,Length */
341 vnt_get_phy_field(priv
, frame_len
, rate
, pkt_type
, &buf
->a
);
343 vnt_get_phy_field(priv
, frame_len
, priv
->byTopCCKBasicRate
,
344 PK_TYPE_11B
, &buf
->b
);
346 /* Get Duration and TimeStamp */
347 buf
->duration_a
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
348 buf
->duration_b
= s_uGetDataDuration(priv
, PK_TYPE_11B
, need_ack
);
350 buf
->duration_a_f0
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
351 buf
->duration_a_f1
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
353 buf
->time_stamp_off_a
= vnt_time_stamp_off(priv
, rate
);
354 buf
->time_stamp_off_b
= vnt_time_stamp_off(priv
,
355 priv
->byTopCCKBasicRate
);
357 tx_context
->tx_hdr_size
= vnt_mac_hdr_pos(tx_context
, &buf
->hdr
);
359 return le16_to_cpu(buf
->duration_a
);
362 static u16
vnt_rxtx_datahead_a_fb(struct vnt_usb_send_context
*tx_context
,
363 u8 pkt_type
, u16 rate
, struct vnt_tx_datahead_a_fb
*buf
,
364 u32 frame_len
, int need_ack
)
366 struct vnt_private
*priv
= tx_context
->priv
;
368 /* Get SignalField,ServiceField,Length */
369 vnt_get_phy_field(priv
, frame_len
, rate
, pkt_type
, &buf
->a
);
370 /* Get Duration and TimeStampOff */
371 buf
->duration
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
373 buf
->duration_f0
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
374 buf
->duration_f1
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
376 buf
->time_stamp_off
= vnt_time_stamp_off(priv
, rate
);
378 tx_context
->tx_hdr_size
= vnt_mac_hdr_pos(tx_context
, &buf
->hdr
);
380 return le16_to_cpu(buf
->duration
);
383 static u16
vnt_rxtx_datahead_ab(struct vnt_usb_send_context
*tx_context
,
384 u8 pkt_type
, u16 rate
, struct vnt_tx_datahead_ab
*buf
,
385 u32 frame_len
, int need_ack
)
387 struct vnt_private
*priv
= tx_context
->priv
;
388 struct ieee80211_hdr
*hdr
=
389 (struct ieee80211_hdr
*)tx_context
->skb
->data
;
391 /* Get SignalField,ServiceField,Length */
392 vnt_get_phy_field(priv
, frame_len
, rate
, pkt_type
, &buf
->ab
);
394 /* Get Duration and TimeStampOff */
395 if (ieee80211_is_pspoll(hdr
->frame_control
)) {
396 __le16 dur
= cpu_to_le16(priv
->current_aid
| BIT(14) | BIT(15));
400 buf
->duration
= s_uGetDataDuration(priv
, pkt_type
, need_ack
);
403 buf
->time_stamp_off
= vnt_time_stamp_off(priv
, rate
);
405 tx_context
->tx_hdr_size
= vnt_mac_hdr_pos(tx_context
, &buf
->hdr
);
407 return le16_to_cpu(buf
->duration
);
410 static int vnt_fill_ieee80211_rts(struct vnt_usb_send_context
*tx_context
,
411 struct ieee80211_rts
*rts
, __le16 duration
)
413 struct ieee80211_hdr
*hdr
=
414 (struct ieee80211_hdr
*)tx_context
->skb
->data
;
416 rts
->duration
= duration
;
418 cpu_to_le16(IEEE80211_FTYPE_CTL
| IEEE80211_STYPE_RTS
);
420 memcpy(rts
->ra
, hdr
->addr1
, ETH_ALEN
);
421 memcpy(rts
->ta
, hdr
->addr2
, ETH_ALEN
);
426 static u16
vnt_rxtx_rts_g_head(struct vnt_usb_send_context
*tx_context
,
427 struct vnt_rts_g
*buf
, u8 pkt_type
, u32 frame_len
, int need_ack
,
430 struct vnt_private
*priv
= tx_context
->priv
;
431 u16 rts_frame_len
= 20;
433 vnt_get_phy_field(priv
, rts_frame_len
, priv
->byTopCCKBasicRate
,
434 PK_TYPE_11B
, &buf
->b
);
435 vnt_get_phy_field(priv
, rts_frame_len
,
436 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
438 buf
->duration_bb
= s_uGetRTSCTSDuration(priv
, RTSDUR_BB
, frame_len
,
439 PK_TYPE_11B
, priv
->byTopCCKBasicRate
, need_ack
);
440 buf
->duration_aa
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
441 pkt_type
, current_rate
, need_ack
);
442 buf
->duration_ba
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA
, frame_len
,
443 pkt_type
, current_rate
, need_ack
);
445 vnt_fill_ieee80211_rts(tx_context
, &buf
->data
, buf
->duration_aa
);
447 return vnt_rxtx_datahead_g(tx_context
, pkt_type
, current_rate
,
448 &buf
->data_head
, frame_len
, need_ack
);
451 static u16
vnt_rxtx_rts_g_fb_head(struct vnt_usb_send_context
*tx_context
,
452 struct vnt_rts_g_fb
*buf
, u8 pkt_type
, u32 frame_len
, int need_ack
,
455 struct vnt_private
*priv
= tx_context
->priv
;
456 u16 rts_frame_len
= 20;
458 vnt_get_phy_field(priv
, rts_frame_len
, priv
->byTopCCKBasicRate
,
459 PK_TYPE_11B
, &buf
->b
);
460 vnt_get_phy_field(priv
, rts_frame_len
,
461 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
464 buf
->duration_bb
= s_uGetRTSCTSDuration(priv
, RTSDUR_BB
, frame_len
,
465 PK_TYPE_11B
, priv
->byTopCCKBasicRate
, need_ack
);
466 buf
->duration_aa
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
467 pkt_type
, current_rate
, need_ack
);
468 buf
->duration_ba
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA
, frame_len
,
469 pkt_type
, current_rate
, need_ack
);
472 buf
->rts_duration_ba_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA_F0
,
473 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
);
474 buf
->rts_duration_aa_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F0
,
475 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
);
476 buf
->rts_duration_ba_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_BA_F1
,
477 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
);
478 buf
->rts_duration_aa_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F1
,
479 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
);
481 vnt_fill_ieee80211_rts(tx_context
, &buf
->data
, buf
->duration_aa
);
483 return vnt_rxtx_datahead_g_fb(tx_context
, pkt_type
, current_rate
,
484 &buf
->data_head
, frame_len
, need_ack
);
487 static u16
vnt_rxtx_rts_ab_head(struct vnt_usb_send_context
*tx_context
,
488 struct vnt_rts_ab
*buf
, u8 pkt_type
, u32 frame_len
, int need_ack
,
491 struct vnt_private
*priv
= tx_context
->priv
;
492 u16 rts_frame_len
= 20;
494 vnt_get_phy_field(priv
, rts_frame_len
,
495 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->ab
);
497 buf
->duration
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
498 pkt_type
, current_rate
, need_ack
);
500 vnt_fill_ieee80211_rts(tx_context
, &buf
->data
, buf
->duration
);
502 return vnt_rxtx_datahead_ab(tx_context
, pkt_type
, current_rate
,
503 &buf
->data_head
, frame_len
, need_ack
);
506 static u16
vnt_rxtx_rts_a_fb_head(struct vnt_usb_send_context
*tx_context
,
507 struct vnt_rts_a_fb
*buf
, u8 pkt_type
, u32 frame_len
, int need_ack
,
510 struct vnt_private
*priv
= tx_context
->priv
;
511 u16 rts_frame_len
= 20;
513 vnt_get_phy_field(priv
, rts_frame_len
,
514 priv
->byTopOFDMBasicRate
, pkt_type
, &buf
->a
);
516 buf
->duration
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA
, frame_len
,
517 pkt_type
, current_rate
, need_ack
);
519 buf
->rts_duration_f0
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F0
,
520 frame_len
, pkt_type
, priv
->tx_rate_fb0
, need_ack
);
522 buf
->rts_duration_f1
= s_uGetRTSCTSDuration(priv
, RTSDUR_AA_F1
,
523 frame_len
, pkt_type
, priv
->tx_rate_fb1
, need_ack
);
525 vnt_fill_ieee80211_rts(tx_context
, &buf
->data
, buf
->duration
);
527 return vnt_rxtx_datahead_a_fb(tx_context
, pkt_type
, current_rate
,
528 &buf
->data_head
, frame_len
, need_ack
);
531 static u16
s_vFillRTSHead(struct vnt_usb_send_context
*tx_context
, u8 byPktType
,
532 union vnt_tx_data_head
*head
, u32 cbFrameLength
, int bNeedAck
,
539 /* Note: So far RTSHead doesn't appear in ATIM
540 * & Beacom DMA, so we don't need to take them
542 * Otherwise, we need to modified codes for them.
547 if (!tx_context
->fb_option
)
548 return vnt_rxtx_rts_g_head(tx_context
, &head
->rts_g
,
549 byPktType
, cbFrameLength
,
550 bNeedAck
, wCurrentRate
);
552 return vnt_rxtx_rts_g_fb_head(tx_context
,
553 &head
->rts_g_fb
, byPktType
,
554 cbFrameLength
, bNeedAck
, wCurrentRate
);
557 if (tx_context
->fb_option
) {
558 return vnt_rxtx_rts_a_fb_head(tx_context
,
559 &head
->rts_a_fb
, byPktType
,
560 cbFrameLength
, bNeedAck
, wCurrentRate
);
564 return vnt_rxtx_rts_ab_head(tx_context
, &head
->rts_ab
,
565 byPktType
, cbFrameLength
, bNeedAck
,
572 static u16
s_vFillCTSHead(struct vnt_usb_send_context
*tx_context
,
573 u8 byPktType
, union vnt_tx_data_head
*head
, u32 cbFrameLength
,
574 int bNeedAck
, u16 wCurrentRate
)
576 struct vnt_private
*pDevice
= tx_context
->priv
;
577 u32 uCTSFrameLen
= 14;
582 if (tx_context
->fb_option
) {
584 struct vnt_cts_fb
*pBuf
= &head
->cts_g_fb
;
585 /* Get SignalField,ServiceField,Length */
586 vnt_get_phy_field(pDevice
, uCTSFrameLen
,
587 pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
, &pBuf
->b
);
588 pBuf
->duration_ba
= s_uGetRTSCTSDuration(pDevice
, CTSDUR_BA
,
589 cbFrameLength
, byPktType
,
590 wCurrentRate
, bNeedAck
);
591 /* Get CTSDuration_ba_f0 */
592 pBuf
->cts_duration_ba_f0
= s_uGetRTSCTSDuration(pDevice
,
593 CTSDUR_BA_F0
, cbFrameLength
, byPktType
,
594 pDevice
->tx_rate_fb0
, bNeedAck
);
595 /* Get CTSDuration_ba_f1 */
596 pBuf
->cts_duration_ba_f1
= s_uGetRTSCTSDuration(pDevice
,
597 CTSDUR_BA_F1
, cbFrameLength
, byPktType
,
598 pDevice
->tx_rate_fb1
, bNeedAck
);
599 /* Get CTS Frame body */
600 pBuf
->data
.duration
= pBuf
->duration_ba
;
601 pBuf
->data
.frame_control
=
602 cpu_to_le16(IEEE80211_FTYPE_CTL
| IEEE80211_STYPE_CTS
);
604 memcpy(pBuf
->data
.ra
, pDevice
->abyCurrentNetAddr
, ETH_ALEN
);
606 return vnt_rxtx_datahead_g_fb(tx_context
, byPktType
,
607 wCurrentRate
, &pBuf
->data_head
, cbFrameLength
,
610 struct vnt_cts
*pBuf
= &head
->cts_g
;
611 /* Get SignalField,ServiceField,Length */
612 vnt_get_phy_field(pDevice
, uCTSFrameLen
,
613 pDevice
->byTopCCKBasicRate
, PK_TYPE_11B
, &pBuf
->b
);
614 /* Get CTSDuration_ba */
615 pBuf
->duration_ba
= s_uGetRTSCTSDuration(pDevice
,
616 CTSDUR_BA
, cbFrameLength
, byPktType
,
617 wCurrentRate
, bNeedAck
);
618 /*Get CTS Frame body*/
619 pBuf
->data
.duration
= pBuf
->duration_ba
;
620 pBuf
->data
.frame_control
=
621 cpu_to_le16(IEEE80211_FTYPE_CTL
| IEEE80211_STYPE_CTS
);
623 memcpy(pBuf
->data
.ra
, pDevice
->abyCurrentNetAddr
, ETH_ALEN
);
625 return vnt_rxtx_datahead_g(tx_context
, byPktType
, wCurrentRate
,
626 &pBuf
->data_head
, cbFrameLength
, bNeedAck
);
632 static u16
vnt_rxtx_rts(struct vnt_usb_send_context
*tx_context
,
633 union vnt_tx_head
*tx_head
, u8 pkt_type
, u32 frame_size
,
634 int need_ack
, u16 current_rate
)
636 struct vnt_private
*priv
= tx_context
->priv
;
637 struct vnt_rrv_time_rts
*buf
= &tx_head
->tx_rts
.rts
;
639 buf
->rts_rrv_time_aa
= s_uGetRTSCTSRsvTime(priv
, 2,
640 pkt_type
, frame_size
, current_rate
);
641 buf
->rts_rrv_time_ba
= s_uGetRTSCTSRsvTime(priv
, 1,
642 pkt_type
, frame_size
, current_rate
);
643 buf
->rts_rrv_time_bb
= s_uGetRTSCTSRsvTime(priv
, 0,
644 pkt_type
, frame_size
, current_rate
);
646 buf
->rrv_time_a
= vnt_rxtx_rsvtime_le16(priv
, pkt_type
, frame_size
,
647 current_rate
, need_ack
);
648 buf
->rrv_time_b
= vnt_rxtx_rsvtime_le16(priv
, PK_TYPE_11B
, frame_size
,
649 priv
->byTopCCKBasicRate
, need_ack
);
654 static u16
vnt_rxtx_cts(struct vnt_usb_send_context
*tx_context
,
655 union vnt_tx_head
*tx_head
, u8 pkt_type
, u32 frame_size
,
656 int need_ack
, u16 current_rate
)
658 struct vnt_private
*priv
= tx_context
->priv
;
659 struct vnt_rrv_time_cts
*buf
= &tx_head
->tx_cts
.cts
;
661 buf
->rrv_time_a
= vnt_rxtx_rsvtime_le16(priv
, pkt_type
,
662 frame_size
, current_rate
, need_ack
);
663 buf
->rrv_time_b
= vnt_rxtx_rsvtime_le16(priv
, PK_TYPE_11B
,
664 frame_size
, priv
->byTopCCKBasicRate
, need_ack
);
666 buf
->cts_rrv_time_ba
= s_uGetRTSCTSRsvTime(priv
, 3,
667 pkt_type
, frame_size
, current_rate
);
672 static u16
vnt_rxtx_ab(struct vnt_usb_send_context
*tx_context
,
673 union vnt_tx_head
*tx_head
, u8 pkt_type
, u32 frame_size
,
674 int need_ack
, u16 current_rate
, bool need_rts
)
676 struct vnt_private
*priv
= tx_context
->priv
;
677 struct vnt_rrv_time_ab
*buf
= &tx_head
->tx_ab
.ab
;
679 buf
->rrv_time
= vnt_rxtx_rsvtime_le16(priv
, pkt_type
,
680 frame_size
, current_rate
, need_ack
);
683 if (pkt_type
== PK_TYPE_11B
)
684 buf
->rts_rrv_time
= s_uGetRTSCTSRsvTime(priv
, 0,
685 pkt_type
, frame_size
, current_rate
);
686 else /* PK_TYPE_11A */
687 buf
->rts_rrv_time
= s_uGetRTSCTSRsvTime(priv
, 2,
688 pkt_type
, frame_size
, current_rate
);
697 * Generate FIFO control for MAC & Baseband controller
701 * pDevice - Pointer to adpater
702 * pTxDataHead - Transmit Data Buffer
703 * pTxBufHead - pTxBufHead
704 * pvRrvTime - pvRrvTime
707 * cbFrameSize - Transmit Data Length (Hdr+Payload+FCS)
708 * bNeedACK - If need ACK
716 static u16
s_vGenerateTxParameter(struct vnt_usb_send_context
*tx_context
,
717 u8 byPktType
, u16 wCurrentRate
, struct vnt_tx_buffer
*tx_buffer
,
718 struct vnt_mic_hdr
**mic_hdr
, u32 need_mic
, u32 cbFrameSize
,
719 int bNeedACK
, bool need_rts
)
721 union vnt_tx_data_head
*head
= NULL
;
723 if (byPktType
== PK_TYPE_11GB
|| byPktType
== PK_TYPE_11GA
) {
725 vnt_rxtx_rts(tx_context
, &tx_buffer
->tx_head
,
726 byPktType
, cbFrameSize
, bNeedACK
, wCurrentRate
);
729 *mic_hdr
= &tx_buffer
->
730 tx_head
.tx_rts
.tx
.mic
.hdr
;
731 head
= &tx_buffer
->tx_head
.tx_rts
.tx
.mic
.head
;
733 head
= &tx_buffer
->tx_head
.tx_rts
.tx
.head
;
737 return s_vFillRTSHead(tx_context
, byPktType
, head
,
738 cbFrameSize
, bNeedACK
,
742 vnt_rxtx_cts(tx_context
, &tx_buffer
->tx_head
,
743 byPktType
, cbFrameSize
, bNeedACK
, wCurrentRate
);
746 *mic_hdr
= &tx_buffer
->
747 tx_head
.tx_cts
.tx
.mic
.hdr
;
748 head
= &tx_buffer
->tx_head
.tx_cts
.tx
.mic
.head
;
750 head
= &tx_buffer
->tx_head
.tx_cts
.tx
.head
;
754 return s_vFillCTSHead(tx_context
, byPktType
,
755 head
, cbFrameSize
, bNeedACK
, wCurrentRate
);
757 } else if (byPktType
== PK_TYPE_11A
) {
759 *mic_hdr
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.hdr
;
760 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.head
;
762 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.head
;
766 vnt_rxtx_ab(tx_context
, &tx_buffer
->tx_head
, byPktType
,
767 cbFrameSize
, bNeedACK
, wCurrentRate
, need_rts
);
771 return s_vFillRTSHead(tx_context
, byPktType
, head
,
772 cbFrameSize
, bNeedACK
,
775 vnt_rxtx_ab(tx_context
, &tx_buffer
->tx_head
, byPktType
,
776 cbFrameSize
, bNeedACK
, wCurrentRate
, need_rts
);
778 return vnt_rxtx_datahead_a_fb(tx_context
, byPktType
,
779 wCurrentRate
, &head
->data_head_a_fb
,
780 cbFrameSize
, bNeedACK
);
782 } else if (byPktType
== PK_TYPE_11B
) {
784 *mic_hdr
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.hdr
;
785 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.mic
.head
;
787 head
= &tx_buffer
->tx_head
.tx_ab
.tx
.head
;
791 vnt_rxtx_ab(tx_context
, &tx_buffer
->tx_head
, byPktType
,
792 cbFrameSize
, bNeedACK
, wCurrentRate
, need_rts
);
795 return s_vFillRTSHead(tx_context
, byPktType
, head
,
796 cbFrameSize
, bNeedACK
,
799 vnt_rxtx_ab(tx_context
, &tx_buffer
->tx_head
, byPktType
,
800 cbFrameSize
, bNeedACK
, wCurrentRate
, need_rts
);
802 return vnt_rxtx_datahead_ab(tx_context
, byPktType
,
803 wCurrentRate
, &head
->data_head_ab
,
804 cbFrameSize
, bNeedACK
);
811 static void vnt_fill_txkey(struct vnt_usb_send_context
*tx_context
,
812 u8
*key_buffer
, struct ieee80211_key_conf
*tx_key
, struct sk_buff
*skb
,
813 u16 payload_len
, struct vnt_mic_hdr
*mic_hdr
)
815 struct ieee80211_hdr
*hdr
= tx_context
->hdr
;
816 struct ieee80211_key_seq seq
;
817 u8
*iv
= ((u8
*)hdr
+ ieee80211_get_hdrlen_from_skb(skb
));
819 /* strip header and icv len from payload */
820 payload_len
-= ieee80211_get_hdrlen_from_skb(skb
);
821 payload_len
-= tx_key
->icv_len
;
823 switch (tx_key
->cipher
) {
824 case WLAN_CIPHER_SUITE_WEP40
:
825 case WLAN_CIPHER_SUITE_WEP104
:
826 memcpy(key_buffer
, iv
, 3);
827 memcpy(key_buffer
+ 3, tx_key
->key
, tx_key
->keylen
);
829 if (tx_key
->keylen
== WLAN_KEY_LEN_WEP40
) {
830 memcpy(key_buffer
+ 8, iv
, 3);
831 memcpy(key_buffer
+ 11,
832 tx_key
->key
, WLAN_KEY_LEN_WEP40
);
836 case WLAN_CIPHER_SUITE_TKIP
:
837 ieee80211_get_tkip_p2k(tx_key
, skb
, key_buffer
);
840 case WLAN_CIPHER_SUITE_CCMP
:
846 mic_hdr
->payload_len
= cpu_to_be16(payload_len
);
847 memcpy(mic_hdr
->mic_addr2
, hdr
->addr2
, ETH_ALEN
);
849 ieee80211_get_key_tx_seq(tx_key
, &seq
);
851 memcpy(mic_hdr
->ccmp_pn
, seq
.ccmp
.pn
, IEEE80211_CCMP_PN_LEN
);
853 if (ieee80211_has_a4(hdr
->frame_control
))
854 mic_hdr
->hlen
= cpu_to_be16(28);
856 mic_hdr
->hlen
= cpu_to_be16(22);
858 memcpy(mic_hdr
->addr1
, hdr
->addr1
, ETH_ALEN
);
859 memcpy(mic_hdr
->addr2
, hdr
->addr2
, ETH_ALEN
);
860 memcpy(mic_hdr
->addr3
, hdr
->addr3
, ETH_ALEN
);
862 mic_hdr
->frame_control
= cpu_to_le16(
863 le16_to_cpu(hdr
->frame_control
) & 0xc78f);
864 mic_hdr
->seq_ctrl
= cpu_to_le16(
865 le16_to_cpu(hdr
->seq_ctrl
) & 0xf);
867 if (ieee80211_has_a4(hdr
->frame_control
))
868 memcpy(mic_hdr
->addr4
, hdr
->addr4
, ETH_ALEN
);
871 memcpy(key_buffer
, tx_key
->key
, WLAN_KEY_LEN_CCMP
);
880 int vnt_tx_packet(struct vnt_private
*priv
, struct sk_buff
*skb
)
882 struct ieee80211_tx_info
*info
= IEEE80211_SKB_CB(skb
);
883 struct ieee80211_tx_rate
*tx_rate
= &info
->control
.rates
[0];
884 struct ieee80211_rate
*rate
;
885 struct ieee80211_key_conf
*tx_key
;
886 struct ieee80211_hdr
*hdr
;
887 struct vnt_mic_hdr
*mic_hdr
= NULL
;
888 struct vnt_tx_buffer
*tx_buffer
;
889 struct vnt_tx_fifo_head
*tx_buffer_head
;
890 struct vnt_usb_send_context
*tx_context
;
893 u16 tx_bytes
, tx_header_size
, tx_body_size
, current_rate
, duration_id
;
894 u8 pkt_type
, fb_option
= AUTO_FB_NONE
;
895 bool need_rts
= false, need_ack
= false, is_pspoll
= false;
896 bool need_mic
= false;
898 hdr
= (struct ieee80211_hdr
*)(skb
->data
);
900 rate
= ieee80211_get_tx_rate(priv
->hw
, info
);
902 current_rate
= rate
->hw_value
;
903 if (priv
->wCurrentRate
!= current_rate
&&
904 !(priv
->hw
->conf
.flags
& IEEE80211_CONF_OFFCHANNEL
)) {
905 priv
->wCurrentRate
= current_rate
;
906 bScheduleCommand(priv
, WLAN_CMD_SETPOWER
, NULL
);
909 if (current_rate
> RATE_11M
)
910 pkt_type
= priv
->byPacketType
;
912 pkt_type
= PK_TYPE_11B
;
914 spin_lock_irqsave(&priv
->lock
, flags
);
916 tx_context
= s_vGetFreeContext(priv
);
918 dev_dbg(&priv
->usb
->dev
, "%s No free context\n", __func__
);
919 spin_unlock_irqrestore(&priv
->lock
, flags
);
923 tx_context
->skb
= skb
;
925 spin_unlock_irqrestore(&priv
->lock
, flags
);
927 tx_buffer
= (struct vnt_tx_buffer
*)tx_context
->data
;
928 tx_buffer_head
= &tx_buffer
->fifo_head
;
929 tx_body_size
= skb
->len
;
931 frame_size
= tx_body_size
+ 4;
933 /*Set fifo controls */
934 if (pkt_type
== PK_TYPE_11A
)
935 tx_buffer_head
->wFIFOCtl
= 0;
936 else if (pkt_type
== PK_TYPE_11B
)
937 tx_buffer_head
->wFIFOCtl
= FIFOCTL_11B
;
938 else if (pkt_type
== PK_TYPE_11GB
)
939 tx_buffer_head
->wFIFOCtl
= FIFOCTL_11GB
;
940 else if (pkt_type
== PK_TYPE_11GA
)
941 tx_buffer_head
->wFIFOCtl
= FIFOCTL_11GA
;
943 if (!ieee80211_is_data(hdr
->frame_control
)) {
944 tx_buffer_head
->wFIFOCtl
|= (FIFOCTL_GENINT
|
946 tx_buffer_head
->wFIFOCtl
|= FIFOCTL_TMOEN
;
948 tx_buffer_head
->time_stamp
=
949 cpu_to_le16(DEFAULT_MGN_LIFETIME_RES_64us
);
951 tx_buffer_head
->time_stamp
=
952 cpu_to_le16(DEFAULT_MSDU_LIFETIME_RES_64us
);
955 if (!(info
->flags
& IEEE80211_TX_CTL_NO_ACK
)) {
956 tx_buffer_head
->wFIFOCtl
|= FIFOCTL_NEEDACK
;
960 if (ieee80211_has_retry(hdr
->frame_control
))
961 tx_buffer_head
->wFIFOCtl
|= FIFOCTL_LRETRY
;
963 if (tx_rate
->flags
& IEEE80211_TX_RC_USE_SHORT_PREAMBLE
)
964 priv
->byPreambleType
= PREAMBLE_SHORT
;
966 priv
->byPreambleType
= PREAMBLE_LONG
;
968 if (tx_rate
->flags
& IEEE80211_TX_RC_USE_RTS_CTS
) {
970 tx_buffer_head
->wFIFOCtl
|= FIFOCTL_RTS
;
973 if (ieee80211_has_a4(hdr
->frame_control
))
974 tx_buffer_head
->wFIFOCtl
|= FIFOCTL_LHEAD
;
976 if (info
->flags
& IEEE80211_TX_CTL_NO_PS_BUFFER
)
979 tx_buffer_head
->frag_ctl
=
980 cpu_to_le16(ieee80211_get_hdrlen_from_skb(skb
) << 10);
982 if (info
->control
.hw_key
) {
983 tx_key
= info
->control
.hw_key
;
984 switch (info
->control
.hw_key
->cipher
) {
985 case WLAN_CIPHER_SUITE_WEP40
:
986 case WLAN_CIPHER_SUITE_WEP104
:
987 tx_buffer_head
->frag_ctl
|= cpu_to_le16(FRAGCTL_LEGACY
);
989 case WLAN_CIPHER_SUITE_TKIP
:
990 tx_buffer_head
->frag_ctl
|= cpu_to_le16(FRAGCTL_TKIP
);
992 case WLAN_CIPHER_SUITE_CCMP
:
993 tx_buffer_head
->frag_ctl
|= cpu_to_le16(FRAGCTL_AES
);
998 frame_size
+= tx_key
->icv_len
;
1001 tx_buffer_head
->current_rate
= cpu_to_le16(current_rate
);
1003 /* legacy rates TODO use ieee80211_tx_rate */
1004 if (current_rate
>= RATE_18M
&& ieee80211_is_data(hdr
->frame_control
)) {
1005 if (priv
->byAutoFBCtrl
== AUTO_FB_0
) {
1006 tx_buffer_head
->wFIFOCtl
|= FIFOCTL_AUTO_FB_0
;
1009 wFB_Opt0
[FB_RATE0
][current_rate
- RATE_18M
];
1011 wFB_Opt0
[FB_RATE1
][current_rate
- RATE_18M
];
1013 fb_option
= AUTO_FB_0
;
1014 } else if (priv
->byAutoFBCtrl
== AUTO_FB_1
) {
1015 tx_buffer_head
->wFIFOCtl
|= FIFOCTL_AUTO_FB_1
;
1018 wFB_Opt1
[FB_RATE0
][current_rate
- RATE_18M
];
1020 wFB_Opt1
[FB_RATE1
][current_rate
- RATE_18M
];
1022 fb_option
= AUTO_FB_1
;
1026 tx_context
->fb_option
= fb_option
;
1028 duration_id
= s_vGenerateTxParameter(tx_context
, pkt_type
, current_rate
,
1029 tx_buffer
, &mic_hdr
, need_mic
, frame_size
,
1030 need_ack
, need_rts
);
1032 tx_header_size
= tx_context
->tx_hdr_size
;
1033 if (!tx_header_size
) {
1034 tx_context
->in_use
= false;
1038 tx_buffer_head
->frag_ctl
|= cpu_to_le16(FRAGCTL_NONFRAG
);
1040 tx_bytes
= tx_header_size
+ tx_body_size
;
1042 memcpy(tx_context
->hdr
, skb
->data
, tx_body_size
);
1044 hdr
->duration_id
= cpu_to_le16(duration_id
);
1046 if (info
->control
.hw_key
) {
1047 tx_key
= info
->control
.hw_key
;
1048 if (tx_key
->keylen
> 0)
1049 vnt_fill_txkey(tx_context
, tx_buffer_head
->tx_key
,
1050 tx_key
, skb
, tx_body_size
, mic_hdr
);
1053 priv
->wSeqCounter
= (le16_to_cpu(hdr
->seq_ctrl
) &
1054 IEEE80211_SCTL_SEQ
) >> 4;
1056 tx_buffer
->tx_byte_count
= cpu_to_le16(tx_bytes
);
1057 tx_buffer
->byPKTNO
= tx_context
->pkt_no
;
1058 tx_buffer
->byType
= 0x00;
1062 tx_context
->type
= CONTEXT_DATA_PACKET
;
1063 tx_context
->buf_len
= tx_bytes
;
1065 spin_lock_irqsave(&priv
->lock
, flags
);
1067 if (PIPEnsSendBulkOut(priv
, tx_context
) != STATUS_PENDING
) {
1068 spin_unlock_irqrestore(&priv
->lock
, flags
);
1072 spin_unlock_irqrestore(&priv
->lock
, flags
);
1077 static int vnt_beacon_xmit(struct vnt_private
*priv
,
1078 struct sk_buff
*skb
)
1080 struct vnt_beacon_buffer
*beacon_buffer
;
1081 struct vnt_tx_short_buf_head
*short_head
;
1082 struct ieee80211_tx_info
*info
;
1083 struct vnt_usb_send_context
*context
;
1084 struct ieee80211_mgmt
*mgmt_hdr
;
1085 unsigned long flags
;
1086 u32 frame_size
= skb
->len
+ 4;
1087 u16 current_rate
, count
;
1089 spin_lock_irqsave(&priv
->lock
, flags
);
1091 context
= s_vGetFreeContext(priv
);
1093 dev_dbg(&priv
->usb
->dev
, "%s No free context!\n", __func__
);
1094 spin_unlock_irqrestore(&priv
->lock
, flags
);
1100 spin_unlock_irqrestore(&priv
->lock
, flags
);
1102 beacon_buffer
= (struct vnt_beacon_buffer
*)&context
->data
[0];
1103 short_head
= &beacon_buffer
->short_head
;
1105 if (priv
->byBBType
== BB_TYPE_11A
) {
1106 current_rate
= RATE_6M
;
1108 /* Get SignalField,ServiceField,Length */
1109 vnt_get_phy_field(priv
, frame_size
, current_rate
,
1110 PK_TYPE_11A
, &short_head
->ab
);
1112 /* Get Duration and TimeStampOff */
1113 short_head
->duration
= s_uGetDataDuration(priv
,
1114 PK_TYPE_11A
, false);
1115 short_head
->time_stamp_off
=
1116 vnt_time_stamp_off(priv
, current_rate
);
1118 current_rate
= RATE_1M
;
1119 short_head
->fifo_ctl
|= FIFOCTL_11B
;
1121 /* Get SignalField,ServiceField,Length */
1122 vnt_get_phy_field(priv
, frame_size
, current_rate
,
1123 PK_TYPE_11B
, &short_head
->ab
);
1125 /* Get Duration and TimeStampOff */
1126 short_head
->duration
= s_uGetDataDuration(priv
,
1127 PK_TYPE_11B
, false);
1128 short_head
->time_stamp_off
=
1129 vnt_time_stamp_off(priv
, current_rate
);
1132 /* Generate Beacon Header */
1133 mgmt_hdr
= &beacon_buffer
->mgmt_hdr
;
1134 memcpy(mgmt_hdr
, skb
->data
, skb
->len
);
1136 /* time stamp always 0 */
1137 mgmt_hdr
->u
.beacon
.timestamp
= 0;
1139 info
= IEEE80211_SKB_CB(skb
);
1140 if (info
->flags
& IEEE80211_TX_CTL_ASSIGN_SEQ
) {
1141 struct ieee80211_hdr
*hdr
= (struct ieee80211_hdr
*)mgmt_hdr
;
1142 hdr
->duration_id
= 0;
1143 hdr
->seq_ctrl
= cpu_to_le16(priv
->wSeqCounter
<< 4);
1146 priv
->wSeqCounter
++;
1147 if (priv
->wSeqCounter
> 0x0fff)
1148 priv
->wSeqCounter
= 0;
1150 count
= sizeof(struct vnt_tx_short_buf_head
) + skb
->len
;
1152 beacon_buffer
->tx_byte_count
= cpu_to_le16(count
);
1153 beacon_buffer
->byPKTNO
= context
->pkt_no
;
1154 beacon_buffer
->byType
= 0x01;
1156 context
->type
= CONTEXT_BEACON_PACKET
;
1157 context
->buf_len
= count
+ 4; /* USB header */
1159 spin_lock_irqsave(&priv
->lock
, flags
);
1161 if (PIPEnsSendBulkOut(priv
, context
) != STATUS_PENDING
)
1162 ieee80211_free_txskb(priv
->hw
, context
->skb
);
1164 spin_unlock_irqrestore(&priv
->lock
, flags
);
1169 int vnt_beacon_make(struct vnt_private
*priv
, struct ieee80211_vif
*vif
)
1171 struct sk_buff
*beacon
;
1173 beacon
= ieee80211_beacon_get(priv
->hw
, vif
);
1177 if (vnt_beacon_xmit(priv
, beacon
)) {
1178 ieee80211_free_txskb(priv
->hw
, beacon
);
1185 int vnt_beacon_enable(struct vnt_private
*priv
, struct ieee80211_vif
*vif
,
1186 struct ieee80211_bss_conf
*conf
)
1190 vnt_mac_reg_bits_off(priv
, MAC_REG_TCR
, TCR_AUTOBCNTX
);
1192 vnt_mac_reg_bits_off(priv
, MAC_REG_TFTCTL
, TFTCTL_TSFCNTREN
);
1194 vnt_mac_set_beacon_interval(priv
, conf
->beacon_int
);
1196 vnt_clear_current_tsf(priv
);
1198 vnt_mac_reg_bits_on(priv
, MAC_REG_TFTCTL
, TFTCTL_TSFCNTREN
);
1200 vnt_reset_next_tbtt(priv
, conf
->beacon_int
);
1202 ret
= vnt_beacon_make(priv
, vif
);