Commit | Line | Data |
---|---|---|
18056f34 GKH |
1 | // SPDX-License-Identifier: GPL-2.0 |
2 | /* | |
eb9eb87d DA |
3 | * Copyright(c) 2003 - 2004 Intel Corporation. All rights reserved. |
4 | * | |
eb9eb87d DA |
5 | * Contact Information: |
6 | * James P. Ketrenos <ipw2100-admin@linux.intel.com> | |
7 | * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 | |
8 | * | |
eb9eb87d DA |
9 | * Few modifications for Realtek's Wi-Fi drivers by |
10 | * Andrea Merello <andrea.merello@gmail.com> | |
11 | * | |
12 | * A special thanks goes to Realtek for their support ! | |
18056f34 | 13 | */ |
ecdfa446 | 14 | #include <linux/compiler.h> |
ecdfa446 GKH |
15 | #include <linux/errno.h> |
16 | #include <linux/if_arp.h> | |
17 | #include <linux/in6.h> | |
18 | #include <linux/in.h> | |
19 | #include <linux/ip.h> | |
20 | #include <linux/kernel.h> | |
21 | #include <linux/module.h> | |
22 | #include <linux/netdevice.h> | |
23 | #include <linux/pci.h> | |
24 | #include <linux/proc_fs.h> | |
25 | #include <linux/skbuff.h> | |
26 | #include <linux/slab.h> | |
27 | #include <linux/tcp.h> | |
28 | #include <linux/types.h> | |
ecdfa446 GKH |
29 | #include <linux/wireless.h> |
30 | #include <linux/etherdevice.h> | |
f38d223b | 31 | #include <linux/uaccess.h> |
ecdfa446 GKH |
32 | #include <linux/if_vlan.h> |
33 | ||
94a79942 | 34 | #include "rtllib.h" |
ecdfa446 | 35 | |
14b40d92 MK |
36 | /* 802.11 Data Frame |
37 | * | |
38 | * | |
39 | * 802.11 frame_control for data frames - 2 bytes | |
35e33b04 MK |
40 | * ,--------------------------------------------------------------------. |
41 | * bits | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | a | b | c | d | e | | |
42 | * |---|---|---|---|---|---|---|---|---|----|----|-----|-----|-----|----| | |
43 | * val | 0 | 0 | 0 | 1 | x | 0 | 0 | 0 | 1 | 0 | x | x | x | x | x | | |
44 | * |---|---|---|---|---|---|---|---|---|----|----|-----|-----|-----|----| | |
45 | * desc | ver | type | ^-subtype-^ |to |from|more|retry| pwr |more |wep | | |
46 | * | | | x=0 data |DS | DS |frag| | mgm |data | | | |
47 | * | | | x=1 data+ack | | | | | | | | | |
48 | * '--------------------------------------------------------------------' | |
49 | * /\ | |
50 | * | | |
51 | * 802.11 Data Frame | | |
52 | * ,--------- 'ctrl' expands to >---' | |
14b40d92 MK |
53 | * | |
54 | * ,--'---,-------------------------------------------------------------. | |
55 | * Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | | |
56 | * |------|------|---------|---------|---------|------|---------|------| | |
57 | * Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | Frame | fcs | | |
58 | * | | tion | (BSSID) | | | ence | data | | | |
59 | * `--------------------------------------------------| |------' | |
60 | * Total: 28 non-data bytes `----.----' | |
61 | * | | |
62 | * .- 'Frame data' expands to <---------------------------' | |
63 | * | | |
64 | * V | |
65 | * ,---------------------------------------------------. | |
66 | * Bytes | 1 | 1 | 1 | 3 | 2 | 0-2304 | | |
67 | * |------|------|---------|----------|------|---------| | |
68 | * Desc. | SNAP | SNAP | Control |Eth Tunnel| Type | IP | | |
69 | * | DSAP | SSAP | | | | Packet | | |
70 | * | 0xAA | 0xAA |0x03 (UI)|0x00-00-F8| | | | |
71 | * `-----------------------------------------| | | |
72 | * Total: 8 non-data bytes `----.----' | |
73 | * | | |
74 | * .- 'IP Packet' expands, if WEP enabled, to <--' | |
75 | * | | |
76 | * V | |
77 | * ,-----------------------. | |
78 | * Bytes | 4 | 0-2296 | 4 | | |
79 | * |-----|-----------|-----| | |
80 | * Desc. | IV | Encrypted | ICV | | |
81 | * | | IP Packet | | | |
82 | * `-----------------------' | |
83 | * Total: 8 non-data bytes | |
84 | * | |
85 | * | |
86 | * 802.3 Ethernet Data Frame | |
87 | * | |
88 | * ,-----------------------------------------. | |
89 | * Bytes | 6 | 6 | 2 | Variable | 4 | | |
90 | * |-------|-------|------|-----------|------| | |
91 | * Desc. | Dest. | Source| Type | IP Packet | fcs | | |
92 | * | MAC | MAC | | | | | |
93 | * `-----------------------------------------' | |
94 | * Total: 18 non-data bytes | |
95 | * | |
35e33b04 MK |
96 | * In the event that fragmentation is required, the incoming payload is split |
97 | * into N parts of size ieee->fts. The first fragment contains the SNAP header | |
98 | * and the remaining packets are just data. | |
14b40d92 | 99 | * |
35e33b04 MK |
100 | * If encryption is enabled, each fragment payload size is reduced by enough |
101 | * space to add the prefix and postfix (IV and ICV totalling 8 bytes in | |
102 | * the case of WEP) So if you have 1500 bytes of payload with ieee->fts set to | |
103 | * 500 without encryption it will take 3 frames. With WEP it will take 4 frames | |
104 | * as the payload of each frame is reduced to 492 bytes. | |
14b40d92 MK |
105 | * |
106 | * SKB visualization | |
107 | * | |
108 | * ,- skb->data | |
109 | * | | |
110 | * | ETHERNET HEADER ,-<-- PAYLOAD | |
111 | * | | 14 bytes from skb->data | |
112 | * | 2 bytes for Type --> ,T. | (sizeof ethhdr) | |
113 | * | | | | | |
114 | * |,-Dest.--. ,--Src.---. | | | | |
115 | * | 6 bytes| | 6 bytes | | | | | |
116 | * v | | | | | | | |
117 | * 0 | v 1 | v | v 2 | |
118 | * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 | |
119 | * ^ | ^ | ^ | | |
120 | * | | | | | | | |
121 | * | | | | `T' <---- 2 bytes for Type | |
122 | * | | | | | |
123 | * | | '---SNAP--' <-------- 6 bytes for SNAP | |
124 | * | | | |
125 | * `-IV--' <-------------------- 4 bytes for IV (WEP) | |
126 | * | |
127 | * SNAP HEADER | |
128 | * | |
129 | */ | |
ecdfa446 GKH |
130 | |
131 | static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; | |
132 | static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; | |
133 | ||
511998ea | 134 | static int rtllib_put_snap(u8 *data, u16 h_proto) |
ecdfa446 | 135 | { |
94a79942 | 136 | struct rtllib_snap_hdr *snap; |
ecdfa446 GKH |
137 | u8 *oui; |
138 | ||
94a79942 | 139 | snap = (struct rtllib_snap_hdr *)data; |
ecdfa446 GKH |
140 | snap->dsap = 0xaa; |
141 | snap->ssap = 0xaa; | |
142 | snap->ctrl = 0x03; | |
143 | ||
144 | if (h_proto == 0x8137 || h_proto == 0x80f3) | |
145 | oui = P802_1H_OUI; | |
146 | else | |
147 | oui = RFC1042_OUI; | |
148 | snap->oui[0] = oui[0]; | |
149 | snap->oui[1] = oui[1]; | |
150 | snap->oui[2] = oui[2]; | |
151 | ||
9326c5ca | 152 | *(__be16 *)(data + SNAP_SIZE) = htons(h_proto); |
ecdfa446 GKH |
153 | |
154 | return SNAP_SIZE + sizeof(u16); | |
155 | } | |
156 | ||
f38d223b LF |
157 | int rtllib_encrypt_fragment(struct rtllib_device *ieee, struct sk_buff *frag, |
158 | int hdr_len) | |
ecdfa446 | 159 | { |
32c44cb5 | 160 | struct lib80211_crypt_data *crypt = NULL; |
ecdfa446 GKH |
161 | int res; |
162 | ||
0ddcf5fd | 163 | crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx]; |
94a79942 | 164 | |
f38d223b | 165 | if (!(crypt && crypt->ops)) { |
d69d2054 MK |
166 | netdev_info(ieee->dev, "=========>%s(), crypt is null\n", |
167 | __func__); | |
ecdfa446 GKH |
168 | return -1; |
169 | } | |
ecdfa446 | 170 | /* To encrypt, frame format is: |
14b40d92 MK |
171 | * IV (4 bytes), clear payload (including SNAP), ICV (4 bytes) |
172 | */ | |
ecdfa446 | 173 | |
ecdfa446 | 174 | /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so |
14b40d92 MK |
175 | * call both MSDU and MPDU encryption functions from here. |
176 | */ | |
ecdfa446 GKH |
177 | atomic_inc(&crypt->refcnt); |
178 | res = 0; | |
179 | if (crypt->ops->encrypt_msdu) | |
180 | res = crypt->ops->encrypt_msdu(frag, hdr_len, crypt->priv); | |
181 | if (res == 0 && crypt->ops->encrypt_mpdu) | |
182 | res = crypt->ops->encrypt_mpdu(frag, hdr_len, crypt->priv); | |
183 | ||
184 | atomic_dec(&crypt->refcnt); | |
185 | if (res < 0) { | |
d69d2054 MK |
186 | netdev_info(ieee->dev, "%s: Encryption failed: len=%d.\n", |
187 | ieee->dev->name, frag->len); | |
ecdfa446 GKH |
188 | return -1; |
189 | } | |
190 | ||
191 | return 0; | |
192 | } | |
193 | ||
194 | ||
f38d223b LF |
195 | void rtllib_txb_free(struct rtllib_txb *txb) |
196 | { | |
ecdfa446 GKH |
197 | if (unlikely(!txb)) |
198 | return; | |
ecdfa446 GKH |
199 | kfree(txb); |
200 | } | |
201 | ||
ec0dc6be LF |
202 | static struct rtllib_txb *rtllib_alloc_txb(int nr_frags, int txb_size, |
203 | gfp_t gfp_mask) | |
ecdfa446 | 204 | { |
94a79942 | 205 | struct rtllib_txb *txb; |
ecdfa446 | 206 | int i; |
3a6b70c3 | 207 | |
f38d223b LF |
208 | txb = kmalloc(sizeof(struct rtllib_txb) + (sizeof(u8 *) * nr_frags), |
209 | gfp_mask); | |
ecdfa446 GKH |
210 | if (!txb) |
211 | return NULL; | |
212 | ||
94a79942 | 213 | memset(txb, 0, sizeof(struct rtllib_txb)); |
ecdfa446 | 214 | txb->nr_frags = nr_frags; |
198e0d17 | 215 | txb->frag_size = cpu_to_le16(txb_size); |
ecdfa446 GKH |
216 | |
217 | for (i = 0; i < nr_frags; i++) { | |
218 | txb->fragments[i] = dev_alloc_skb(txb_size); | |
219 | if (unlikely(!txb->fragments[i])) { | |
220 | i--; | |
221 | break; | |
222 | } | |
223 | memset(txb->fragments[i]->cb, 0, sizeof(txb->fragments[i]->cb)); | |
224 | } | |
225 | if (unlikely(i != nr_frags)) { | |
226 | while (i >= 0) | |
227 | dev_kfree_skb_any(txb->fragments[i--]); | |
228 | kfree(txb); | |
229 | return NULL; | |
230 | } | |
231 | return txb; | |
232 | } | |
233 | ||
ec0dc6be | 234 | static int rtllib_classify(struct sk_buff *skb, u8 bIsAmsdu) |
ecdfa446 GKH |
235 | { |
236 | struct ethhdr *eth; | |
237 | struct iphdr *ip; | |
94a79942 | 238 | |
ecdfa446 GKH |
239 | eth = (struct ethhdr *)skb->data; |
240 | if (eth->h_proto != htons(ETH_P_IP)) | |
241 | return 0; | |
242 | ||
72321415 | 243 | #ifdef VERBOSE_DEBUG |
b99692f4 | 244 | print_hex_dump_bytes("%s: ", __func__, DUMP_PREFIX_NONE, skb->data, |
72321415 MK |
245 | skb->len); |
246 | #endif | |
ecdfa446 | 247 | ip = ip_hdr(skb); |
ecdfa446 | 248 | switch (ip->tos & 0xfc) { |
94a79942 LF |
249 | case 0x20: |
250 | return 2; | |
251 | case 0x40: | |
252 | return 1; | |
253 | case 0x60: | |
254 | return 3; | |
255 | case 0x80: | |
256 | return 4; | |
257 | case 0xa0: | |
258 | return 5; | |
259 | case 0xc0: | |
260 | return 6; | |
261 | case 0xe0: | |
262 | return 7; | |
263 | default: | |
264 | return 0; | |
ecdfa446 GKH |
265 | } |
266 | } | |
267 | ||
ec0dc6be LF |
268 | static void rtllib_tx_query_agg_cap(struct rtllib_device *ieee, |
269 | struct sk_buff *skb, | |
270 | struct cb_desc *tcb_desc) | |
ecdfa446 | 271 | { |
7796d93e | 272 | struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; |
60554f2b | 273 | struct tx_ts_record *pTxTs = NULL; |
4d0c8ee8 | 274 | struct rtllib_hdr_1addr *hdr = (struct rtllib_hdr_1addr *)skb->data; |
94a79942 | 275 | |
f38d223b | 276 | if (rtllib_act_scanning(ieee, false)) |
94a79942 | 277 | return; |
ecdfa446 | 278 | |
f38d223b | 279 | if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) |
ecdfa446 GKH |
280 | return; |
281 | if (!IsQoSDataFrame(skb->data)) | |
282 | return; | |
14fc4235 | 283 | if (is_multicast_ether_addr(hdr->addr1)) |
ecdfa446 | 284 | return; |
65a43784 | 285 | |
f38d223b | 286 | if (tcb_desc->bdhcp || ieee->CntAfterLink < 2) |
94a79942 | 287 | return; |
65a43784 | 288 | |
94a79942 LF |
289 | if (pHTInfo->IOTAction & HT_IOT_ACT_TX_NO_AGGREGATION) |
290 | return; | |
65a43784 | 291 | |
94a79942 | 292 | if (!ieee->GetNmodeSupportBySecCfg(ieee->dev)) |
ecdfa446 | 293 | return; |
f38d223b LF |
294 | if (pHTInfo->bCurrentAMPDUEnable) { |
295 | if (!GetTs(ieee, (struct ts_common_info **)(&pTxTs), hdr->addr1, | |
296 | skb->priority, TX_DIR, true)) { | |
d69d2054 | 297 | netdev_info(ieee->dev, "%s: can't get TS\n", __func__); |
ecdfa446 GKH |
298 | return; |
299 | } | |
f38d223b LF |
300 | if (pTxTs->TxAdmittedBARecord.bValid == false) { |
301 | if (ieee->wpa_ie_len && (ieee->pairwise_key_type == | |
302 | KEY_TYPE_NA)) { | |
94a79942 | 303 | ; |
f38d223b | 304 | } else if (tcb_desc->bdhcp == 1) { |
94a79942 | 305 | ; |
f38d223b | 306 | } else if (!pTxTs->bDisable_AddBa) { |
94a79942 LF |
307 | TsStartAddBaProcess(ieee, pTxTs); |
308 | } | |
ecdfa446 | 309 | goto FORCED_AGG_SETTING; |
94a79942 | 310 | } else if (pTxTs->bUsingBa == false) { |
f38d223b LF |
311 | if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, |
312 | (pTxTs->TxCurSeq+1)%4096)) | |
ecdfa446 GKH |
313 | pTxTs->bUsingBa = true; |
314 | else | |
315 | goto FORCED_AGG_SETTING; | |
316 | } | |
94a79942 | 317 | if (ieee->iw_mode == IW_MODE_INFRA) { |
ecdfa446 GKH |
318 | tcb_desc->bAMPDUEnable = true; |
319 | tcb_desc->ampdu_factor = pHTInfo->CurrentAMPDUFactor; | |
320 | tcb_desc->ampdu_density = pHTInfo->CurrentMPDUDensity; | |
321 | } | |
322 | } | |
323 | FORCED_AGG_SETTING: | |
94a79942 | 324 | switch (pHTInfo->ForcedAMPDUMode) { |
f38d223b LF |
325 | case HT_AGG_AUTO: |
326 | break; | |
327 | ||
328 | case HT_AGG_FORCE_ENABLE: | |
329 | tcb_desc->bAMPDUEnable = true; | |
330 | tcb_desc->ampdu_density = pHTInfo->ForcedMPDUDensity; | |
331 | tcb_desc->ampdu_factor = pHTInfo->ForcedAMPDUFactor; | |
332 | break; | |
333 | ||
334 | case HT_AGG_FORCE_DISABLE: | |
335 | tcb_desc->bAMPDUEnable = false; | |
336 | tcb_desc->ampdu_density = 0; | |
337 | tcb_desc->ampdu_factor = 0; | |
338 | break; | |
ecdfa446 | 339 | } |
ecdfa446 GKH |
340 | } |
341 | ||
ec0dc6be | 342 | static void rtllib_qurey_ShortPreambleMode(struct rtllib_device *ieee, |
f38d223b | 343 | struct cb_desc *tcb_desc) |
ecdfa446 GKH |
344 | { |
345 | tcb_desc->bUseShortPreamble = false; | |
346 | if (tcb_desc->data_rate == 2) | |
ecdfa446 | 347 | return; |
f38d223b LF |
348 | else if (ieee->current_network.capability & |
349 | WLAN_CAPABILITY_SHORT_PREAMBLE) | |
ecdfa446 | 350 | tcb_desc->bUseShortPreamble = true; |
ecdfa446 | 351 | } |
94a79942 | 352 | |
ec0dc6be | 353 | static void rtllib_query_HTCapShortGI(struct rtllib_device *ieee, |
f38d223b | 354 | struct cb_desc *tcb_desc) |
ecdfa446 | 355 | { |
7796d93e | 356 | struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; |
ecdfa446 | 357 | |
94a79942 | 358 | tcb_desc->bUseShortGI = false; |
ecdfa446 | 359 | |
f38d223b | 360 | if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) |
ecdfa446 GKH |
361 | return; |
362 | ||
f38d223b | 363 | if (pHTInfo->bForcedShortGI) { |
ecdfa446 GKH |
364 | tcb_desc->bUseShortGI = true; |
365 | return; | |
366 | } | |
367 | ||
f38d223b | 368 | if ((pHTInfo->bCurBW40MHz == true) && pHTInfo->bCurShortGI40MHz) |
ecdfa446 | 369 | tcb_desc->bUseShortGI = true; |
f38d223b | 370 | else if ((pHTInfo->bCurBW40MHz == false) && pHTInfo->bCurShortGI20MHz) |
ecdfa446 GKH |
371 | tcb_desc->bUseShortGI = true; |
372 | } | |
373 | ||
ec0dc6be LF |
374 | static void rtllib_query_BandwidthMode(struct rtllib_device *ieee, |
375 | struct cb_desc *tcb_desc) | |
ecdfa446 | 376 | { |
7796d93e | 377 | struct rt_hi_throughput *pHTInfo = ieee->pHTInfo; |
ecdfa446 GKH |
378 | |
379 | tcb_desc->bPacketBW = false; | |
380 | ||
f38d223b | 381 | if (!pHTInfo->bCurrentHTSupport || !pHTInfo->bEnableHT) |
ecdfa446 GKH |
382 | return; |
383 | ||
94a79942 | 384 | if (tcb_desc->bMulticast || tcb_desc->bBroadcast) |
ecdfa446 GKH |
385 | return; |
386 | ||
f38d223b | 387 | if ((tcb_desc->data_rate & 0x80) == 0) |
ecdfa446 | 388 | return; |
f38d223b LF |
389 | if (pHTInfo->bCurBW40MHz && pHTInfo->bCurTxBW40MHz && |
390 | !ieee->bandwidth_auto_switch.bforced_tx20Mhz) | |
ecdfa446 | 391 | tcb_desc->bPacketBW = true; |
ecdfa446 | 392 | } |
94a79942 | 393 | |
ec0dc6be LF |
394 | static void rtllib_query_protectionmode(struct rtllib_device *ieee, |
395 | struct cb_desc *tcb_desc, | |
396 | struct sk_buff *skb) | |
ecdfa446 | 397 | { |
285b7c00 MK |
398 | struct rt_hi_throughput *pHTInfo; |
399 | ||
ecdfa446 | 400 | tcb_desc->bRTSSTBC = false; |
94a79942 LF |
401 | tcb_desc->bRTSUseShortGI = false; |
402 | tcb_desc->bCTSEnable = false; | |
403 | tcb_desc->RTSSC = 0; | |
404 | tcb_desc->bRTSBW = false; | |
ecdfa446 | 405 | |
94a79942 | 406 | if (tcb_desc->bBroadcast || tcb_desc->bMulticast) |
ecdfa446 GKH |
407 | return; |
408 | ||
94a79942 | 409 | if (is_broadcast_ether_addr(skb->data+16)) |
ecdfa446 GKH |
410 | return; |
411 | ||
f38d223b LF |
412 | if (ieee->mode < IEEE_N_24G) { |
413 | if (skb->len > ieee->rts) { | |
ecdfa446 GKH |
414 | tcb_desc->bRTSEnable = true; |
415 | tcb_desc->rts_rate = MGN_24M; | |
f38d223b | 416 | } else if (ieee->current_network.buseprotection) { |
ecdfa446 GKH |
417 | tcb_desc->bRTSEnable = true; |
418 | tcb_desc->bCTSEnable = true; | |
419 | tcb_desc->rts_rate = MGN_24M; | |
420 | } | |
ecdfa446 | 421 | return; |
285b7c00 | 422 | } |
3a6b70c3 | 423 | |
285b7c00 MK |
424 | pHTInfo = ieee->pHTInfo; |
425 | ||
426 | while (true) { | |
427 | if (pHTInfo->IOTAction & HT_IOT_ACT_FORCED_CTS2SELF) { | |
428 | tcb_desc->bCTSEnable = true; | |
429 | tcb_desc->rts_rate = MGN_24M; | |
430 | tcb_desc->bRTSEnable = true; | |
431 | break; | |
432 | } else if (pHTInfo->IOTAction & (HT_IOT_ACT_FORCED_RTS | | |
433 | HT_IOT_ACT_PURE_N_MODE)) { | |
434 | tcb_desc->bRTSEnable = true; | |
435 | tcb_desc->rts_rate = MGN_24M; | |
436 | break; | |
437 | } | |
438 | if (ieee->current_network.buseprotection) { | |
439 | tcb_desc->bRTSEnable = true; | |
440 | tcb_desc->bCTSEnable = true; | |
441 | tcb_desc->rts_rate = MGN_24M; | |
442 | break; | |
443 | } | |
444 | if (pHTInfo->bCurrentHTSupport && pHTInfo->bEnableHT) { | |
445 | u8 HTOpMode = pHTInfo->CurrentOpMode; | |
446 | ||
447 | if ((pHTInfo->bCurBW40MHz && (HTOpMode == 2 || | |
448 | HTOpMode == 3)) || | |
449 | (!pHTInfo->bCurBW40MHz && HTOpMode == 3)) { | |
94a79942 | 450 | tcb_desc->rts_rate = MGN_24M; |
ecdfa446 GKH |
451 | tcb_desc->bRTSEnable = true; |
452 | break; | |
453 | } | |
ecdfa446 | 454 | } |
285b7c00 MK |
455 | if (skb->len > ieee->rts) { |
456 | tcb_desc->rts_rate = MGN_24M; | |
457 | tcb_desc->bRTSEnable = true; | |
458 | break; | |
459 | } | |
460 | if (tcb_desc->bAMPDUEnable) { | |
461 | tcb_desc->rts_rate = MGN_24M; | |
462 | tcb_desc->bRTSEnable = false; | |
463 | break; | |
464 | } | |
465 | goto NO_PROTECTION; | |
ecdfa446 GKH |
466 | } |
467 | if (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_PREAMBLE) | |
468 | tcb_desc->bUseShortPreamble = true; | |
94a79942 | 469 | if (ieee->iw_mode == IW_MODE_MASTER) |
fc00af0c | 470 | goto NO_PROTECTION; |
ecdfa446 GKH |
471 | return; |
472 | NO_PROTECTION: | |
473 | tcb_desc->bRTSEnable = false; | |
474 | tcb_desc->bCTSEnable = false; | |
f38d223b | 475 | tcb_desc->rts_rate = 0; |
ecdfa446 | 476 | tcb_desc->RTSSC = 0; |
f38d223b | 477 | tcb_desc->bRTSBW = false; |
ecdfa446 GKH |
478 | } |
479 | ||
480 | ||
ec0dc6be LF |
481 | static void rtllib_txrate_selectmode(struct rtllib_device *ieee, |
482 | struct cb_desc *tcb_desc) | |
ecdfa446 | 483 | { |
94a79942 | 484 | if (ieee->bTxDisableRateFallBack) |
ecdfa446 GKH |
485 | tcb_desc->bTxDisableRateFallBack = true; |
486 | ||
94a79942 | 487 | if (ieee->bTxUseDriverAssingedRate) |
ecdfa446 | 488 | tcb_desc->bTxUseDriverAssingedRate = true; |
f38d223b LF |
489 | if (!tcb_desc->bTxDisableRateFallBack || |
490 | !tcb_desc->bTxUseDriverAssingedRate) { | |
491 | if (ieee->iw_mode == IW_MODE_INFRA || | |
492 | ieee->iw_mode == IW_MODE_ADHOC) | |
ecdfa446 GKH |
493 | tcb_desc->RATRIndex = 0; |
494 | } | |
495 | } | |
496 | ||
511998ea MK |
497 | static u16 rtllib_query_seqnum(struct rtllib_device *ieee, struct sk_buff *skb, |
498 | u8 *dst) | |
ecdfa446 | 499 | { |
94a79942 LF |
500 | u16 seqnum = 0; |
501 | ||
14fc4235 | 502 | if (is_multicast_ether_addr(dst)) |
94a79942 | 503 | return 0; |
f38d223b | 504 | if (IsQoSDataFrame(skb->data)) { |
60554f2b | 505 | struct tx_ts_record *pTS = NULL; |
3a6b70c3 | 506 | |
f38d223b LF |
507 | if (!GetTs(ieee, (struct ts_common_info **)(&pTS), dst, |
508 | skb->priority, TX_DIR, true)) | |
94a79942 | 509 | return 0; |
94a79942 | 510 | seqnum = pTS->TxCurSeq; |
ecdfa446 | 511 | pTS->TxCurSeq = (pTS->TxCurSeq+1)%4096; |
94a79942 LF |
512 | return seqnum; |
513 | } | |
514 | return 0; | |
515 | } | |
516 | ||
517 | static int wme_downgrade_ac(struct sk_buff *skb) | |
518 | { | |
519 | switch (skb->priority) { | |
f38d223b LF |
520 | case 6: |
521 | case 7: | |
522 | skb->priority = 5; /* VO -> VI */ | |
523 | return 0; | |
524 | case 4: | |
525 | case 5: | |
526 | skb->priority = 3; /* VI -> BE */ | |
527 | return 0; | |
528 | case 0: | |
529 | case 3: | |
530 | skb->priority = 1; /* BE -> BK */ | |
531 | return 0; | |
532 | default: | |
533 | return -1; | |
ecdfa446 GKH |
534 | } |
535 | } | |
536 | ||
a8f4f33a MK |
537 | static u8 rtllib_current_rate(struct rtllib_device *ieee) |
538 | { | |
539 | if (ieee->mode & IEEE_MODE_MASK) | |
540 | return ieee->rate; | |
541 | ||
542 | if (ieee->HTCurrentOperaRate) | |
543 | return ieee->HTCurrentOperaRate; | |
544 | else | |
545 | return ieee->rate & 0x7F; | |
546 | } | |
547 | ||
511998ea | 548 | static int rtllib_xmit_inter(struct sk_buff *skb, struct net_device *dev) |
ecdfa446 | 549 | { |
f38d223b LF |
550 | struct rtllib_device *ieee = (struct rtllib_device *) |
551 | netdev_priv_rsl(dev); | |
94a79942 LF |
552 | struct rtllib_txb *txb = NULL; |
553 | struct rtllib_hdr_3addrqos *frag_hdr; | |
ecdfa446 GKH |
554 | int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; |
555 | unsigned long flags; | |
556 | struct net_device_stats *stats = &ieee->stats; | |
557 | int ether_type = 0, encrypt; | |
558 | int bytes, fc, qos_ctl = 0, hdr_len; | |
559 | struct sk_buff *skb_frag; | |
94a79942 | 560 | struct rtllib_hdr_3addrqos header = { /* Ensure zero initialized */ |
ecdfa446 GKH |
561 | .duration_id = 0, |
562 | .seq_ctl = 0, | |
563 | .qos_ctl = 0 | |
564 | }; | |
67d412e4 | 565 | int qos_activated = ieee->current_network.qos_data.active; |
06c11107 MK |
566 | u8 dest[ETH_ALEN]; |
567 | u8 src[ETH_ALEN]; | |
32c44cb5 | 568 | struct lib80211_crypt_data *crypt = NULL; |
3b83db43 | 569 | struct cb_desc *tcb_desc; |
94a79942 LF |
570 | u8 bIsMulticast = false; |
571 | u8 IsAmsdu = false; | |
f38d223b | 572 | bool bdhcp = false; |
ecdfa446 GKH |
573 | |
574 | spin_lock_irqsave(&ieee->lock, flags); | |
575 | ||
cd017123 | 576 | /* If there is no driver handler to take the TXB, don't bother |
14b40d92 MK |
577 | * creating it... |
578 | */ | |
f38d223b LF |
579 | if ((!ieee->hard_start_xmit && !(ieee->softmac_features & |
580 | IEEE_SOFTMAC_TX_QUEUE)) || | |
581 | ((!ieee->softmac_data_hard_start_xmit && | |
582 | (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE)))) { | |
d69d2054 | 583 | netdev_warn(ieee->dev, "No xmit handler.\n"); |
ecdfa446 GKH |
584 | goto success; |
585 | } | |
586 | ||
587 | ||
f38d223b | 588 | if (likely(ieee->raw_tx == 0)) { |
ecdfa446 | 589 | if (unlikely(skb->len < SNAP_SIZE + sizeof(u16))) { |
d69d2054 MK |
590 | netdev_warn(ieee->dev, "skb too small (%d).\n", |
591 | skb->len); | |
ecdfa446 GKH |
592 | goto success; |
593 | } | |
94a79942 | 594 | /* Save source and destination addresses */ |
b57ceb19 MK |
595 | ether_addr_copy(dest, skb->data); |
596 | ether_addr_copy(src, skb->data + ETH_ALEN); | |
ecdfa446 GKH |
597 | |
598 | memset(skb->cb, 0, sizeof(skb->cb)); | |
599 | ether_type = ntohs(((struct ethhdr *)skb->data)->h_proto); | |
600 | ||
f38d223b | 601 | if (ieee->iw_mode == IW_MODE_MONITOR) { |
94a79942 LF |
602 | txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); |
603 | if (unlikely(!txb)) { | |
d69d2054 MK |
604 | netdev_warn(ieee->dev, |
605 | "Could not allocate TXB\n"); | |
94a79942 LF |
606 | goto failed; |
607 | } | |
ecdfa446 | 608 | |
94a79942 | 609 | txb->encrypted = 0; |
198e0d17 | 610 | txb->payload_size = cpu_to_le16(skb->len); |
59ae1d12 | 611 | skb_put_data(txb->fragments[0], skb->data, skb->len); |
ecdfa446 | 612 | |
ecdfa446 GKH |
613 | goto success; |
614 | } | |
ecdfa446 | 615 | |
55dc4eb3 | 616 | if (skb->len > 282) { |
4c29207a | 617 | if (ether_type == ETH_P_IP) { |
f38d223b LF |
618 | const struct iphdr *ip = (struct iphdr *) |
619 | ((u8 *)skb->data+14); | |
4c29207a | 620 | if (ip->protocol == IPPROTO_UDP) { |
f38d223b LF |
621 | struct udphdr *udp; |
622 | ||
623 | udp = (struct udphdr *)((u8 *)ip + | |
624 | (ip->ihl << 2)); | |
625 | if (((((u8 *)udp)[1] == 68) && | |
626 | (((u8 *)udp)[3] == 67)) || | |
627 | ((((u8 *)udp)[1] == 67) && | |
628 | (((u8 *)udp)[3] == 68))) { | |
65a43784 | 629 | bdhcp = true; |
94a79942 | 630 | ieee->LPSDelayCnt = 200; |
65a43784 | 631 | } |
632 | } | |
4c29207a | 633 | } else if (ether_type == ETH_P_ARP) { |
d69d2054 MK |
634 | netdev_info(ieee->dev, |
635 | "=================>DHCP Protocol start tx ARP pkt!!\n"); | |
94a79942 | 636 | bdhcp = true; |
f38d223b LF |
637 | ieee->LPSDelayCnt = |
638 | ieee->current_network.tim.tim_count; | |
65a43784 | 639 | } |
94a79942 | 640 | } |
65a43784 | 641 | |
94a79942 | 642 | skb->priority = rtllib_classify(skb, IsAmsdu); |
0ddcf5fd | 643 | crypt = ieee->crypt_info.crypt[ieee->crypt_info.tx_keyidx]; |
94a79942 LF |
644 | encrypt = !(ether_type == ETH_P_PAE && ieee->ieee802_1x) && |
645 | ieee->host_encrypt && crypt && crypt->ops; | |
646 | if (!encrypt && ieee->ieee802_1x && | |
f38d223b | 647 | ieee->drop_unencrypted && ether_type != ETH_P_PAE) { |
94a79942 LF |
648 | stats->tx_dropped++; |
649 | goto success; | |
650 | } | |
94a79942 LF |
651 | if (crypt && !encrypt && ether_type == ETH_P_PAE) { |
652 | struct eapol *eap = (struct eapol *)(skb->data + | |
f38d223b LF |
653 | sizeof(struct ethhdr) - SNAP_SIZE - |
654 | sizeof(u16)); | |
e77c752f MK |
655 | netdev_dbg(ieee->dev, |
656 | "TX: IEEE 802.11 EAPOL frame: %s\n", | |
657 | eap_get_type(eap->type)); | |
94a79942 | 658 | } |
ecdfa446 | 659 | |
94a79942 LF |
660 | /* Advance the SKB to the start of the payload */ |
661 | skb_pull(skb, sizeof(struct ethhdr)); | |
ecdfa446 | 662 | |
f38d223b | 663 | /* Determine total amount of storage required for TXB packets */ |
94a79942 | 664 | bytes = skb->len + SNAP_SIZE + sizeof(u16); |
ecdfa446 GKH |
665 | |
666 | if (encrypt) | |
94a79942 | 667 | fc = RTLLIB_FTYPE_DATA | RTLLIB_FCTL_WEP; |
ecdfa446 | 668 | else |
94a79942 | 669 | fc = RTLLIB_FTYPE_DATA; |
ecdfa446 | 670 | |
67d412e4 | 671 | if (qos_activated) |
94a79942 | 672 | fc |= RTLLIB_STYPE_QOS_DATA; |
ecdfa446 | 673 | else |
94a79942 | 674 | fc |= RTLLIB_STYPE_DATA; |
ecdfa446 GKH |
675 | |
676 | if (ieee->iw_mode == IW_MODE_INFRA) { | |
94a79942 | 677 | fc |= RTLLIB_FCTL_TODS; |
ecdfa446 | 678 | /* To DS: Addr1 = BSSID, Addr2 = SA, |
14b40d92 MK |
679 | * Addr3 = DA |
680 | */ | |
b57ceb19 MK |
681 | ether_addr_copy(header.addr1, |
682 | ieee->current_network.bssid); | |
683 | ether_addr_copy(header.addr2, src); | |
94a79942 | 684 | if (IsAmsdu) |
b57ceb19 MK |
685 | ether_addr_copy(header.addr3, |
686 | ieee->current_network.bssid); | |
94a79942 | 687 | else |
b57ceb19 | 688 | ether_addr_copy(header.addr3, dest); |
ecdfa446 GKH |
689 | } else if (ieee->iw_mode == IW_MODE_ADHOC) { |
690 | /* not From/To DS: Addr1 = DA, Addr2 = SA, | |
14b40d92 MK |
691 | * Addr3 = BSSID |
692 | */ | |
b57ceb19 MK |
693 | ether_addr_copy(header.addr1, dest); |
694 | ether_addr_copy(header.addr2, src); | |
695 | ether_addr_copy(header.addr3, | |
696 | ieee->current_network.bssid); | |
ecdfa446 GKH |
697 | } |
698 | ||
14fc4235 | 699 | bIsMulticast = is_multicast_ether_addr(header.addr1); |
94a79942 | 700 | |
f38d223b | 701 | header.frame_ctl = cpu_to_le16(fc); |
ecdfa446 GKH |
702 | |
703 | /* Determine fragmentation size based on destination (multicast | |
14b40d92 MK |
704 | * and broadcast are not fragmented) |
705 | */ | |
94a79942 | 706 | if (bIsMulticast) { |
ecdfa446 GKH |
707 | frag_size = MAX_FRAG_THRESHOLD; |
708 | qos_ctl |= QOS_CTL_NOTCONTAIN_ACK; | |
94a79942 LF |
709 | } else { |
710 | frag_size = ieee->fts; | |
ecdfa446 GKH |
711 | qos_ctl = 0; |
712 | } | |
713 | ||
67d412e4 | 714 | if (qos_activated) { |
94a79942 LF |
715 | hdr_len = RTLLIB_3ADDR_LEN + 2; |
716 | ||
ff2f3e0e DA |
717 | /* in case we are a client verify acm is not set for this ac */ |
718 | while (unlikely(ieee->wmm_acm & (0x01 << skb->priority))) { | |
719 | netdev_info(ieee->dev, "skb->priority = %x\n", | |
720 | skb->priority); | |
721 | if (wme_downgrade_ac(skb)) | |
722 | break; | |
723 | netdev_info(ieee->dev, "converted skb->priority = %x\n", | |
724 | skb->priority); | |
725 | } | |
726 | ||
f38d223b LF |
727 | qos_ctl |= skb->priority; |
728 | header.qos_ctl = cpu_to_le16(qos_ctl & RTLLIB_QOS_TID); | |
ff2f3e0e | 729 | |
ecdfa446 | 730 | } else { |
94a79942 | 731 | hdr_len = RTLLIB_3ADDR_LEN; |
ecdfa446 GKH |
732 | } |
733 | /* Determine amount of payload per fragment. Regardless of if | |
f38d223b LF |
734 | * this stack is providing the full 802.11 header, one will |
735 | * eventually be affixed to this fragment -- so we must account | |
14b40d92 MK |
736 | * for it when determining the amount of payload space. |
737 | */ | |
ecdfa446 GKH |
738 | bytes_per_frag = frag_size - hdr_len; |
739 | if (ieee->config & | |
f38d223b | 740 | (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) |
94a79942 | 741 | bytes_per_frag -= RTLLIB_FCS_LEN; |
ecdfa446 | 742 | |
cd017123 | 743 | /* Each fragment may need to have room for encrypting |
14b40d92 MK |
744 | * pre/postfix |
745 | */ | |
94a79942 | 746 | if (encrypt) { |
32c44cb5 SM |
747 | bytes_per_frag -= crypt->ops->extra_mpdu_prefix_len + |
748 | crypt->ops->extra_mpdu_postfix_len + | |
749 | crypt->ops->extra_msdu_prefix_len + | |
750 | crypt->ops->extra_msdu_postfix_len; | |
94a79942 | 751 | } |
ecdfa446 | 752 | /* Number of fragments is the total bytes_per_frag / |
14b40d92 MK |
753 | * payload_per_fragment |
754 | */ | |
ecdfa446 GKH |
755 | nr_frags = bytes / bytes_per_frag; |
756 | bytes_last_frag = bytes % bytes_per_frag; | |
757 | if (bytes_last_frag) | |
758 | nr_frags++; | |
759 | else | |
760 | bytes_last_frag = bytes_per_frag; | |
761 | ||
f38d223b LF |
762 | /* When we allocate the TXB we allocate enough space for the |
763 | * reserve and full fragment bytes (bytes_per_frag doesn't | |
14b40d92 MK |
764 | * include prefix, postfix, header, FCS, etc.) |
765 | */ | |
f38d223b LF |
766 | txb = rtllib_alloc_txb(nr_frags, frag_size + |
767 | ieee->tx_headroom, GFP_ATOMIC); | |
ecdfa446 | 768 | if (unlikely(!txb)) { |
d69d2054 | 769 | netdev_warn(ieee->dev, "Could not allocate TXB\n"); |
ecdfa446 GKH |
770 | goto failed; |
771 | } | |
772 | txb->encrypted = encrypt; | |
198e0d17 | 773 | txb->payload_size = cpu_to_le16(bytes); |
ecdfa446 | 774 | |
67d412e4 | 775 | if (qos_activated) |
ecdfa446 | 776 | txb->queue_index = UP2AC(skb->priority); |
f38d223b LF |
777 | else |
778 | txb->queue_index = WME_AC_BE; | |
ecdfa446 | 779 | |
ecdfa446 GKH |
780 | for (i = 0; i < nr_frags; i++) { |
781 | skb_frag = txb->fragments[i]; | |
f38d223b LF |
782 | tcb_desc = (struct cb_desc *)(skb_frag->cb + |
783 | MAX_DEV_ADDR_SIZE); | |
67d412e4 | 784 | if (qos_activated) { |
94a79942 | 785 | skb_frag->priority = skb->priority; |
ecdfa446 GKH |
786 | tcb_desc->queue_index = UP2AC(skb->priority); |
787 | } else { | |
94a79942 LF |
788 | skb_frag->priority = WME_AC_BE; |
789 | tcb_desc->queue_index = WME_AC_BE; | |
ecdfa446 GKH |
790 | } |
791 | skb_reserve(skb_frag, ieee->tx_headroom); | |
792 | ||
f38d223b | 793 | if (encrypt) { |
ecdfa446 GKH |
794 | if (ieee->hwsec_active) |
795 | tcb_desc->bHwSec = 1; | |
796 | else | |
797 | tcb_desc->bHwSec = 0; | |
f38d223b | 798 | skb_reserve(skb_frag, |
32c44cb5 SM |
799 | crypt->ops->extra_mpdu_prefix_len + |
800 | crypt->ops->extra_msdu_prefix_len); | |
94a79942 | 801 | } else { |
ecdfa446 GKH |
802 | tcb_desc->bHwSec = 0; |
803 | } | |
59ae1d12 | 804 | frag_hdr = skb_put_data(skb_frag, &header, hdr_len); |
ecdfa446 | 805 | |
f38d223b | 806 | /* If this is not the last fragment, then add the |
14b40d92 MK |
807 | * MOREFRAGS bit to the frame control |
808 | */ | |
ecdfa446 GKH |
809 | if (i != nr_frags - 1) { |
810 | frag_hdr->frame_ctl = cpu_to_le16( | |
94a79942 | 811 | fc | RTLLIB_FCTL_MOREFRAGS); |
ecdfa446 GKH |
812 | bytes = bytes_per_frag; |
813 | ||
814 | } else { | |
f38d223b | 815 | /* The last fragment has the remaining length */ |
ecdfa446 GKH |
816 | bytes = bytes_last_frag; |
817 | } | |
67d412e4 | 818 | if ((qos_activated) && (!bIsMulticast)) { |
f38d223b | 819 | frag_hdr->seq_ctl = |
198e0d17 RK |
820 | cpu_to_le16(rtllib_query_seqnum(ieee, skb_frag, |
821 | header.addr1)); | |
f38d223b | 822 | frag_hdr->seq_ctl = |
86005e16 | 823 | cpu_to_le16(le16_to_cpu(frag_hdr->seq_ctl)<<4 | i); |
ecdfa446 | 824 | } else { |
f38d223b LF |
825 | frag_hdr->seq_ctl = |
826 | cpu_to_le16(ieee->seq_ctrl[0]<<4 | i); | |
ecdfa446 | 827 | } |
ecdfa446 GKH |
828 | /* Put a SNAP header on the first fragment */ |
829 | if (i == 0) { | |
94a79942 | 830 | rtllib_put_snap( |
f38d223b LF |
831 | skb_put(skb_frag, SNAP_SIZE + |
832 | sizeof(u16)), ether_type); | |
ecdfa446 GKH |
833 | bytes -= SNAP_SIZE + sizeof(u16); |
834 | } | |
835 | ||
59ae1d12 | 836 | skb_put_data(skb_frag, skb->data, bytes); |
ecdfa446 GKH |
837 | |
838 | /* Advance the SKB... */ | |
839 | skb_pull(skb, bytes); | |
840 | ||
f38d223b LF |
841 | /* Encryption routine will move the header forward in |
842 | * order to insert the IV between the header and the | |
14b40d92 MK |
843 | * payload |
844 | */ | |
ecdfa446 | 845 | if (encrypt) |
f38d223b LF |
846 | rtllib_encrypt_fragment(ieee, skb_frag, |
847 | hdr_len); | |
ecdfa446 | 848 | if (ieee->config & |
f38d223b | 849 | (CFG_RTLLIB_COMPUTE_FCS | CFG_RTLLIB_RESERVE_FCS)) |
ecdfa446 GKH |
850 | skb_put(skb_frag, 4); |
851 | } | |
852 | ||
67d412e4 | 853 | if ((qos_activated) && (!bIsMulticast)) { |
f38d223b LF |
854 | if (ieee->seq_ctrl[UP2AC(skb->priority) + 1] == 0xFFF) |
855 | ieee->seq_ctrl[UP2AC(skb->priority) + 1] = 0; | |
856 | else | |
857 | ieee->seq_ctrl[UP2AC(skb->priority) + 1]++; | |
ecdfa446 | 858 | } else { |
f38d223b LF |
859 | if (ieee->seq_ctrl[0] == 0xFFF) |
860 | ieee->seq_ctrl[0] = 0; | |
861 | else | |
862 | ieee->seq_ctrl[0]++; | |
ecdfa446 | 863 | } |
f38d223b | 864 | } else { |
94a79942 | 865 | if (unlikely(skb->len < sizeof(struct rtllib_hdr_3addr))) { |
d69d2054 MK |
866 | netdev_warn(ieee->dev, "skb too small (%d).\n", |
867 | skb->len); | |
ecdfa446 GKH |
868 | goto success; |
869 | } | |
870 | ||
94a79942 | 871 | txb = rtllib_alloc_txb(1, skb->len, GFP_ATOMIC); |
f38d223b | 872 | if (!txb) { |
d69d2054 | 873 | netdev_warn(ieee->dev, "Could not allocate TXB\n"); |
ecdfa446 GKH |
874 | goto failed; |
875 | } | |
876 | ||
877 | txb->encrypted = 0; | |
198e0d17 | 878 | txb->payload_size = cpu_to_le16(skb->len); |
59ae1d12 | 879 | skb_put_data(txb->fragments[0], skb->data, skb->len); |
ecdfa446 GKH |
880 | } |
881 | ||
882 | success: | |
f38d223b LF |
883 | if (txb) { |
884 | struct cb_desc *tcb_desc = (struct cb_desc *) | |
885 | (txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); | |
ecdfa446 | 886 | tcb_desc->bTxEnableFwCalcDur = 1; |
94a79942 | 887 | tcb_desc->priority = skb->priority; |
65a43784 | 888 | |
94a79942 | 889 | if (ether_type == ETH_P_PAE) { |
f38d223b LF |
890 | if (ieee->pHTInfo->IOTAction & |
891 | HT_IOT_ACT_WA_IOT_Broadcom) { | |
892 | tcb_desc->data_rate = | |
893 | MgntQuery_TxRateExcludeCCKRates(ieee); | |
94a79942 | 894 | tcb_desc->bTxDisableRateFallBack = false; |
f38d223b | 895 | } else { |
94a79942 | 896 | tcb_desc->data_rate = ieee->basic_rate; |
65a43784 | 897 | tcb_desc->bTxDisableRateFallBack = 1; |
94a79942 LF |
898 | } |
899 | ||
65a43784 | 900 | |
901 | tcb_desc->RATRIndex = 7; | |
902 | tcb_desc->bTxUseDriverAssingedRate = 1; | |
94a79942 LF |
903 | } else { |
904 | if (is_multicast_ether_addr(header.addr1)) | |
905 | tcb_desc->bMulticast = 1; | |
906 | if (is_broadcast_ether_addr(header.addr1)) | |
907 | tcb_desc->bBroadcast = 1; | |
94a79942 | 908 | rtllib_txrate_selectmode(ieee, tcb_desc); |
f38d223b | 909 | if (tcb_desc->bMulticast || tcb_desc->bBroadcast) |
94a79942 LF |
910 | tcb_desc->data_rate = ieee->basic_rate; |
911 | else | |
a8f4f33a | 912 | tcb_desc->data_rate = rtllib_current_rate(ieee); |
f38d223b | 913 | |
4bb01423 | 914 | if (bdhcp) { |
f38d223b LF |
915 | if (ieee->pHTInfo->IOTAction & |
916 | HT_IOT_ACT_WA_IOT_Broadcom) { | |
917 | tcb_desc->data_rate = | |
918 | MgntQuery_TxRateExcludeCCKRates(ieee); | |
94a79942 | 919 | tcb_desc->bTxDisableRateFallBack = false; |
f38d223b | 920 | } else { |
94a79942 LF |
921 | tcb_desc->data_rate = MGN_1M; |
922 | tcb_desc->bTxDisableRateFallBack = 1; | |
923 | } | |
65a43784 | 924 | |
925 | ||
94a79942 LF |
926 | tcb_desc->RATRIndex = 7; |
927 | tcb_desc->bTxUseDriverAssingedRate = 1; | |
928 | tcb_desc->bdhcp = 1; | |
929 | } | |
930 | ||
931 | rtllib_qurey_ShortPreambleMode(ieee, tcb_desc); | |
f38d223b LF |
932 | rtllib_tx_query_agg_cap(ieee, txb->fragments[0], |
933 | tcb_desc); | |
94a79942 LF |
934 | rtllib_query_HTCapShortGI(ieee, tcb_desc); |
935 | rtllib_query_BandwidthMode(ieee, tcb_desc); | |
f38d223b LF |
936 | rtllib_query_protectionmode(ieee, tcb_desc, |
937 | txb->fragments[0]); | |
94a79942 | 938 | } |
ecdfa446 GKH |
939 | } |
940 | spin_unlock_irqrestore(&ieee->lock, flags); | |
941 | dev_kfree_skb_any(skb); | |
942 | if (txb) { | |
f38d223b | 943 | if (ieee->softmac_features & IEEE_SOFTMAC_TX_QUEUE) { |
94a79942 | 944 | dev->stats.tx_packets++; |
83efd529 | 945 | dev->stats.tx_bytes += le16_to_cpu(txb->payload_size); |
94a79942 | 946 | rtllib_softmac_xmit(txb, ieee); |
f38d223b | 947 | } else { |
94a79942 | 948 | if ((*ieee->hard_start_xmit)(txb, dev) == 0) { |
ecdfa446 | 949 | stats->tx_packets++; |
83efd529 | 950 | stats->tx_bytes += le16_to_cpu(txb->payload_size); |
ecdfa446 GKH |
951 | return 0; |
952 | } | |
94a79942 | 953 | rtllib_txb_free(txb); |
ecdfa446 GKH |
954 | } |
955 | } | |
956 | ||
957 | return 0; | |
958 | ||
959 | failed: | |
960 | spin_unlock_irqrestore(&ieee->lock, flags); | |
961 | netif_stop_queue(dev); | |
962 | stats->tx_errors++; | |
963 | return 1; | |
964 | ||
965 | } | |
08e1416f | 966 | |
94a79942 LF |
967 | int rtllib_xmit(struct sk_buff *skb, struct net_device *dev) |
968 | { | |
969 | memset(skb->cb, 0, sizeof(skb->cb)); | |
970 | return rtllib_xmit_inter(skb, dev); | |
971 | } | |
3b28499c | 972 | EXPORT_SYMBOL(rtllib_xmit); |