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