Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-next-2.6

+8014 -4149
+8
drivers/net/wireless/Kconfig
··· 228 228 Enable support for PCMCIA cards containing the 229 229 Atmel at76c502 and at76c504 chips. 230 230 231 + config AT76C50X_USB 232 + tristate "Atmel at76c503/at76c505/at76c505a USB cards" 233 + depends on MAC80211 && WLAN_80211 && USB 234 + select FW_LOADER 235 + ---help--- 236 + Enable support for USB Wireless devices using Atmel at76c503, 237 + at76c505 or at76c505a chips. 238 + 231 239 config AIRO_CS 232 240 tristate "Cisco/Aironet 34X/35X/4500/4800 PCMCIA cards" 233 241 depends on PCMCIA && (BROKEN || !M32R) && WLAN_80211
+2
drivers/net/wireless/Makefile
··· 24 24 obj-$(CONFIG_PCI_ATMEL) += atmel_pci.o 25 25 obj-$(CONFIG_PCMCIA_ATMEL) += atmel_cs.o 26 26 27 + obj-$(CONFIG_AT76C50X_USB) += at76c50x-usb.o 28 + 27 29 obj-$(CONFIG_PRISM54) += prism54/ 28 30 29 31 obj-$(CONFIG_HOSTAP) += hostap/
+2 -1
drivers/net/wireless/airo.c
··· 4727 4727 StatsRid stats; 4728 4728 int i, j; 4729 4729 __le32 *vals = stats.vals; 4730 - int len = le16_to_cpu(stats.len); 4730 + int len; 4731 4731 4732 4732 if ((file->private_data = kzalloc(sizeof(struct proc_data ), GFP_KERNEL)) == NULL) 4733 4733 return -ENOMEM; ··· 4738 4738 } 4739 4739 4740 4740 readStatsRid(apriv, &stats, rid, 1); 4741 + len = le16_to_cpu(stats.len); 4741 4742 4742 4743 j = 0; 4743 4744 for(i=0; statsLabels[i]!=(char *)-1 && i*4<len; i++) {
+2501
drivers/net/wireless/at76c50x-usb.c
··· 1 + /* 2 + * at76c503/at76c505 USB driver 3 + * 4 + * Copyright (c) 2002 - 2003 Oliver Kurth 5 + * Copyright (c) 2004 Joerg Albert <joerg.albert@gmx.de> 6 + * Copyright (c) 2004 Nick Jones 7 + * Copyright (c) 2004 Balint Seeber <n0_5p4m_p13453@hotmail.com> 8 + * Copyright (c) 2007 Guido Guenther <agx@sigxcpu.org> 9 + * Copyright (c) 2007 Kalle Valo <kalle.valo@iki.fi> 10 + * 11 + * This program is free software; you can redistribute it and/or 12 + * modify it under the terms of the GNU General Public License as 13 + * published by the Free Software Foundation; either version 2 of 14 + * the License, or (at your option) any later version. 15 + * 16 + * This file is part of the Berlios driver for WLAN USB devices based on the 17 + * Atmel AT76C503A/505/505A. 18 + * 19 + * Some iw_handler code was taken from airo.c, (C) 1999 Benjamin Reed 20 + * 21 + * TODO list is at the wiki: 22 + * 23 + * http://wireless.kernel.org/en/users/Drivers/at76c50x-usb#TODO 24 + * 25 + */ 26 + 27 + #include <linux/init.h> 28 + #include <linux/kernel.h> 29 + #include <linux/sched.h> 30 + #include <linux/errno.h> 31 + #include <linux/slab.h> 32 + #include <linux/module.h> 33 + #include <linux/spinlock.h> 34 + #include <linux/list.h> 35 + #include <linux/usb.h> 36 + #include <linux/netdevice.h> 37 + #include <linux/if_arp.h> 38 + #include <linux/etherdevice.h> 39 + #include <linux/ethtool.h> 40 + #include <linux/wireless.h> 41 + #include <net/iw_handler.h> 42 + #include <net/ieee80211_radiotap.h> 43 + #include <linux/firmware.h> 44 + #include <linux/leds.h> 45 + #include <net/mac80211.h> 46 + 47 + #include "at76c50x-usb.h" 48 + 49 + /* Version information */ 50 + #define DRIVER_NAME "at76c50x-usb" 51 + #define DRIVER_VERSION "0.17" 52 + #define DRIVER_DESC "Atmel at76x USB Wireless LAN Driver" 53 + 54 + /* at76_debug bits */ 55 + #define DBG_PROGRESS 0x00000001 /* authentication/accociation */ 56 + #define DBG_BSS_TABLE 0x00000002 /* show BSS table after scans */ 57 + #define DBG_IOCTL 0x00000004 /* ioctl calls / settings */ 58 + #define DBG_MAC_STATE 0x00000008 /* MAC state transitions */ 59 + #define DBG_TX_DATA 0x00000010 /* tx header */ 60 + #define DBG_TX_DATA_CONTENT 0x00000020 /* tx content */ 61 + #define DBG_TX_MGMT 0x00000040 /* tx management */ 62 + #define DBG_RX_DATA 0x00000080 /* rx data header */ 63 + #define DBG_RX_DATA_CONTENT 0x00000100 /* rx data content */ 64 + #define DBG_RX_MGMT 0x00000200 /* rx mgmt frame headers */ 65 + #define DBG_RX_BEACON 0x00000400 /* rx beacon */ 66 + #define DBG_RX_CTRL 0x00000800 /* rx control */ 67 + #define DBG_RX_MGMT_CONTENT 0x00001000 /* rx mgmt content */ 68 + #define DBG_RX_FRAGS 0x00002000 /* rx data fragment handling */ 69 + #define DBG_DEVSTART 0x00004000 /* fw download, device start */ 70 + #define DBG_URB 0x00008000 /* rx urb status, ... */ 71 + #define DBG_RX_ATMEL_HDR 0x00010000 /* Atmel-specific Rx headers */ 72 + #define DBG_PROC_ENTRY 0x00020000 /* procedure entries/exits */ 73 + #define DBG_PM 0x00040000 /* power management settings */ 74 + #define DBG_BSS_MATCH 0x00080000 /* BSS match failures */ 75 + #define DBG_PARAMS 0x00100000 /* show configured parameters */ 76 + #define DBG_WAIT_COMPLETE 0x00200000 /* command completion */ 77 + #define DBG_RX_FRAGS_SKB 0x00400000 /* skb header of Rx fragments */ 78 + #define DBG_BSS_TABLE_RM 0x00800000 /* purging bss table entries */ 79 + #define DBG_MONITOR_MODE 0x01000000 /* monitor mode */ 80 + #define DBG_MIB 0x02000000 /* dump all MIBs on startup */ 81 + #define DBG_MGMT_TIMER 0x04000000 /* dump mgmt_timer ops */ 82 + #define DBG_WE_EVENTS 0x08000000 /* dump wireless events */ 83 + #define DBG_FW 0x10000000 /* firmware download */ 84 + #define DBG_DFU 0x20000000 /* device firmware upgrade */ 85 + #define DBG_CMD 0x40000000 86 + #define DBG_MAC80211 0x80000000 87 + 88 + #define DBG_DEFAULTS 0 89 + 90 + /* Use our own dbg macro */ 91 + #define at76_dbg(bits, format, arg...) \ 92 + do { \ 93 + if (at76_debug & (bits)) \ 94 + printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , \ 95 + ## arg); \ 96 + } while (0) 97 + 98 + #define at76_dbg_dump(bits, buf, len, format, arg...) \ 99 + do { \ 100 + if (at76_debug & (bits)) { \ 101 + printk(KERN_DEBUG DRIVER_NAME ": " format "\n" , \ 102 + ## arg); \ 103 + print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, \ 104 + buf, len); \ 105 + } \ 106 + } while (0) 107 + 108 + static uint at76_debug = DBG_DEFAULTS; 109 + 110 + /* Protect against concurrent firmware loading and parsing */ 111 + static struct mutex fw_mutex; 112 + 113 + static struct fwentry firmwares[] = { 114 + [0] = { "" }, 115 + [BOARD_503_ISL3861] = { "atmel_at76c503-i3861.bin" }, 116 + [BOARD_503_ISL3863] = { "atmel_at76c503-i3863.bin" }, 117 + [BOARD_503] = { "atmel_at76c503-rfmd.bin" }, 118 + [BOARD_503_ACC] = { "atmel_at76c503-rfmd-acc.bin" }, 119 + [BOARD_505] = { "atmel_at76c505-rfmd.bin" }, 120 + [BOARD_505_2958] = { "atmel_at76c505-rfmd2958.bin" }, 121 + [BOARD_505A] = { "atmel_at76c505a-rfmd2958.bin" }, 122 + [BOARD_505AMX] = { "atmel_at76c505amx-rfmd.bin" }, 123 + }; 124 + 125 + #define USB_DEVICE_DATA(__ops) .driver_info = (kernel_ulong_t)(__ops) 126 + 127 + static struct usb_device_id dev_table[] = { 128 + /* 129 + * at76c503-i3861 130 + */ 131 + /* Generic AT76C503/3861 device */ 132 + { USB_DEVICE(0x03eb, 0x7603), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 133 + /* Linksys WUSB11 v2.1/v2.6 */ 134 + { USB_DEVICE(0x066b, 0x2211), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 135 + /* Netgear MA101 rev. A */ 136 + { USB_DEVICE(0x0864, 0x4100), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 137 + /* Tekram U300C / Allnet ALL0193 */ 138 + { USB_DEVICE(0x0b3b, 0x1612), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 139 + /* HP HN210W J7801A */ 140 + { USB_DEVICE(0x03f0, 0x011c), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 141 + /* Sitecom/Z-Com/Zyxel M4Y-750 */ 142 + { USB_DEVICE(0x0cde, 0x0001), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 143 + /* Dynalink/Askey WLL013 (intersil) */ 144 + { USB_DEVICE(0x069a, 0x0320), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 145 + /* EZ connect 11Mpbs Wireless USB Adapter SMC2662W v1 */ 146 + { USB_DEVICE(0x0d5c, 0xa001), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 147 + /* BenQ AWL300 */ 148 + { USB_DEVICE(0x04a5, 0x9000), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 149 + /* Addtron AWU-120, Compex WLU11 */ 150 + { USB_DEVICE(0x05dd, 0xff31), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 151 + /* Intel AP310 AnyPoint II USB */ 152 + { USB_DEVICE(0x8086, 0x0200), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 153 + /* Dynalink L11U */ 154 + { USB_DEVICE(0x0d8e, 0x7100), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 155 + /* Arescom WL-210, FCC id 07J-GL2411USB */ 156 + { USB_DEVICE(0x0d8e, 0x7110), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 157 + /* I-O DATA WN-B11/USB */ 158 + { USB_DEVICE(0x04bb, 0x0919), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 159 + /* BT Voyager 1010 */ 160 + { USB_DEVICE(0x069a, 0x0821), USB_DEVICE_DATA(BOARD_503_ISL3861) }, 161 + /* 162 + * at76c503-i3863 163 + */ 164 + /* Generic AT76C503/3863 device */ 165 + { USB_DEVICE(0x03eb, 0x7604), USB_DEVICE_DATA(BOARD_503_ISL3863) }, 166 + /* Samsung SWL-2100U */ 167 + { USB_DEVICE(0x055d, 0xa000), USB_DEVICE_DATA(BOARD_503_ISL3863) }, 168 + /* 169 + * at76c503-rfmd 170 + */ 171 + /* Generic AT76C503/RFMD device */ 172 + { USB_DEVICE(0x03eb, 0x7605), USB_DEVICE_DATA(BOARD_503) }, 173 + /* Dynalink/Askey WLL013 (rfmd) */ 174 + { USB_DEVICE(0x069a, 0x0321), USB_DEVICE_DATA(BOARD_503) }, 175 + /* Linksys WUSB11 v2.6 */ 176 + { USB_DEVICE(0x077b, 0x2219), USB_DEVICE_DATA(BOARD_503) }, 177 + /* Network Everywhere NWU11B */ 178 + { USB_DEVICE(0x077b, 0x2227), USB_DEVICE_DATA(BOARD_503) }, 179 + /* Netgear MA101 rev. B */ 180 + { USB_DEVICE(0x0864, 0x4102), USB_DEVICE_DATA(BOARD_503) }, 181 + /* D-Link DWL-120 rev. E */ 182 + { USB_DEVICE(0x2001, 0x3200), USB_DEVICE_DATA(BOARD_503) }, 183 + /* Actiontec 802UAT1, HWU01150-01UK */ 184 + { USB_DEVICE(0x1668, 0x7605), USB_DEVICE_DATA(BOARD_503) }, 185 + /* AirVast W-Buddie WN210 */ 186 + { USB_DEVICE(0x03eb, 0x4102), USB_DEVICE_DATA(BOARD_503) }, 187 + /* Dick Smith Electronics XH1153 802.11b USB adapter */ 188 + { USB_DEVICE(0x1371, 0x5743), USB_DEVICE_DATA(BOARD_503) }, 189 + /* CNet CNUSB611 */ 190 + { USB_DEVICE(0x1371, 0x0001), USB_DEVICE_DATA(BOARD_503) }, 191 + /* FiberLine FL-WL200U */ 192 + { USB_DEVICE(0x1371, 0x0002), USB_DEVICE_DATA(BOARD_503) }, 193 + /* BenQ AWL400 USB stick */ 194 + { USB_DEVICE(0x04a5, 0x9001), USB_DEVICE_DATA(BOARD_503) }, 195 + /* 3Com 3CRSHEW696 */ 196 + { USB_DEVICE(0x0506, 0x0a01), USB_DEVICE_DATA(BOARD_503) }, 197 + /* Siemens Santis ADSL WLAN USB adapter WLL 013 */ 198 + { USB_DEVICE(0x0681, 0x001b), USB_DEVICE_DATA(BOARD_503) }, 199 + /* Belkin F5D6050, version 2 */ 200 + { USB_DEVICE(0x050d, 0x0050), USB_DEVICE_DATA(BOARD_503) }, 201 + /* iBlitzz, BWU613 (not *B or *SB) */ 202 + { USB_DEVICE(0x07b8, 0xb000), USB_DEVICE_DATA(BOARD_503) }, 203 + /* Gigabyte GN-WLBM101 */ 204 + { USB_DEVICE(0x1044, 0x8003), USB_DEVICE_DATA(BOARD_503) }, 205 + /* Planex GW-US11S */ 206 + { USB_DEVICE(0x2019, 0x3220), USB_DEVICE_DATA(BOARD_503) }, 207 + /* Internal WLAN adapter in h5[4,5]xx series iPAQs */ 208 + { USB_DEVICE(0x049f, 0x0032), USB_DEVICE_DATA(BOARD_503) }, 209 + /* Corega Wireless LAN USB-11 mini */ 210 + { USB_DEVICE(0x07aa, 0x0011), USB_DEVICE_DATA(BOARD_503) }, 211 + /* Corega Wireless LAN USB-11 mini2 */ 212 + { USB_DEVICE(0x07aa, 0x0018), USB_DEVICE_DATA(BOARD_503) }, 213 + /* Uniden PCW100 */ 214 + { USB_DEVICE(0x05dd, 0xff35), USB_DEVICE_DATA(BOARD_503) }, 215 + /* 216 + * at76c503-rfmd-acc 217 + */ 218 + /* SMC2664W */ 219 + { USB_DEVICE(0x083a, 0x3501), USB_DEVICE_DATA(BOARD_503_ACC) }, 220 + /* Belkin F5D6050, SMC2662W v2, SMC2662W-AR */ 221 + { USB_DEVICE(0x0d5c, 0xa002), USB_DEVICE_DATA(BOARD_503_ACC) }, 222 + /* 223 + * at76c505-rfmd 224 + */ 225 + /* Generic AT76C505/RFMD */ 226 + { USB_DEVICE(0x03eb, 0x7606), USB_DEVICE_DATA(BOARD_505) }, 227 + /* 228 + * at76c505-rfmd2958 229 + */ 230 + /* Generic AT76C505/RFMD, OvisLink WL-1130USB */ 231 + { USB_DEVICE(0x03eb, 0x7613), USB_DEVICE_DATA(BOARD_505_2958) }, 232 + /* Fiberline FL-WL240U */ 233 + { USB_DEVICE(0x1371, 0x0014), USB_DEVICE_DATA(BOARD_505_2958) }, 234 + /* CNet CNUSB-611G */ 235 + { USB_DEVICE(0x1371, 0x0013), USB_DEVICE_DATA(BOARD_505_2958) }, 236 + /* Linksys WUSB11 v2.8 */ 237 + { USB_DEVICE(0x1915, 0x2233), USB_DEVICE_DATA(BOARD_505_2958) }, 238 + /* Xterasys XN-2122B, IBlitzz BWU613B/BWU613SB */ 239 + { USB_DEVICE(0x12fd, 0x1001), USB_DEVICE_DATA(BOARD_505_2958) }, 240 + /* Corega WLAN USB Stick 11 */ 241 + { USB_DEVICE(0x07aa, 0x7613), USB_DEVICE_DATA(BOARD_505_2958) }, 242 + /* Microstar MSI Box MS6978 */ 243 + { USB_DEVICE(0x0db0, 0x1020), USB_DEVICE_DATA(BOARD_505_2958) }, 244 + /* 245 + * at76c505a-rfmd2958 246 + */ 247 + /* Generic AT76C505A device */ 248 + { USB_DEVICE(0x03eb, 0x7614), USB_DEVICE_DATA(BOARD_505A) }, 249 + /* Generic AT76C505AS device */ 250 + { USB_DEVICE(0x03eb, 0x7617), USB_DEVICE_DATA(BOARD_505A) }, 251 + /* Siemens Gigaset USB WLAN Adapter 11 */ 252 + { USB_DEVICE(0x1690, 0x0701), USB_DEVICE_DATA(BOARD_505A) }, 253 + /* 254 + * at76c505amx-rfmd 255 + */ 256 + /* Generic AT76C505AMX device */ 257 + { USB_DEVICE(0x03eb, 0x7615), USB_DEVICE_DATA(BOARD_505AMX) }, 258 + { } 259 + }; 260 + 261 + MODULE_DEVICE_TABLE(usb, dev_table); 262 + 263 + /* Supported rates of this hardware, bit 7 marks basic rates */ 264 + static const u8 hw_rates[] = { 0x82, 0x84, 0x0b, 0x16 }; 265 + 266 + static const char *const preambles[] = { "long", "short", "auto" }; 267 + 268 + /* Firmware download */ 269 + /* DFU states */ 270 + #define STATE_IDLE 0x00 271 + #define STATE_DETACH 0x01 272 + #define STATE_DFU_IDLE 0x02 273 + #define STATE_DFU_DOWNLOAD_SYNC 0x03 274 + #define STATE_DFU_DOWNLOAD_BUSY 0x04 275 + #define STATE_DFU_DOWNLOAD_IDLE 0x05 276 + #define STATE_DFU_MANIFEST_SYNC 0x06 277 + #define STATE_DFU_MANIFEST 0x07 278 + #define STATE_DFU_MANIFEST_WAIT_RESET 0x08 279 + #define STATE_DFU_UPLOAD_IDLE 0x09 280 + #define STATE_DFU_ERROR 0x0a 281 + 282 + /* DFU commands */ 283 + #define DFU_DETACH 0 284 + #define DFU_DNLOAD 1 285 + #define DFU_UPLOAD 2 286 + #define DFU_GETSTATUS 3 287 + #define DFU_CLRSTATUS 4 288 + #define DFU_GETSTATE 5 289 + #define DFU_ABORT 6 290 + 291 + #define FW_BLOCK_SIZE 1024 292 + 293 + struct dfu_status { 294 + unsigned char status; 295 + unsigned char poll_timeout[3]; 296 + unsigned char state; 297 + unsigned char string; 298 + } __attribute__((packed)); 299 + 300 + static inline int at76_is_intersil(enum board_type board) 301 + { 302 + return (board == BOARD_503_ISL3861 || board == BOARD_503_ISL3863); 303 + } 304 + 305 + static inline int at76_is_503rfmd(enum board_type board) 306 + { 307 + return (board == BOARD_503 || board == BOARD_503_ACC); 308 + } 309 + 310 + static inline int at76_is_505a(enum board_type board) 311 + { 312 + return (board == BOARD_505A || board == BOARD_505AMX); 313 + } 314 + 315 + /* Load a block of the first (internal) part of the firmware */ 316 + static int at76_load_int_fw_block(struct usb_device *udev, int blockno, 317 + void *block, int size) 318 + { 319 + return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), DFU_DNLOAD, 320 + USB_TYPE_CLASS | USB_DIR_OUT | 321 + USB_RECIP_INTERFACE, blockno, 0, block, size, 322 + USB_CTRL_GET_TIMEOUT); 323 + } 324 + 325 + static int at76_dfu_get_status(struct usb_device *udev, 326 + struct dfu_status *status) 327 + { 328 + int ret; 329 + 330 + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), DFU_GETSTATUS, 331 + USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE, 332 + 0, 0, status, sizeof(struct dfu_status), 333 + USB_CTRL_GET_TIMEOUT); 334 + return ret; 335 + } 336 + 337 + static u8 at76_dfu_get_state(struct usb_device *udev, u8 *state) 338 + { 339 + int ret; 340 + 341 + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), DFU_GETSTATE, 342 + USB_TYPE_CLASS | USB_DIR_IN | USB_RECIP_INTERFACE, 343 + 0, 0, state, 1, USB_CTRL_GET_TIMEOUT); 344 + return ret; 345 + } 346 + 347 + /* Convert timeout from the DFU status to jiffies */ 348 + static inline unsigned long at76_get_timeout(struct dfu_status *s) 349 + { 350 + return msecs_to_jiffies((s->poll_timeout[2] << 16) 351 + | (s->poll_timeout[1] << 8) 352 + | (s->poll_timeout[0])); 353 + } 354 + 355 + /* Load internal firmware from the buffer. If manifest_sync_timeout > 0, use 356 + * its value in jiffies in the MANIFEST_SYNC state. */ 357 + static int at76_usbdfu_download(struct usb_device *udev, u8 *buf, u32 size, 358 + int manifest_sync_timeout) 359 + { 360 + u8 *block; 361 + struct dfu_status dfu_stat_buf; 362 + int ret = 0; 363 + int need_dfu_state = 1; 364 + int is_done = 0; 365 + u8 dfu_state = 0; 366 + u32 dfu_timeout = 0; 367 + int bsize = 0; 368 + int blockno = 0; 369 + 370 + at76_dbg(DBG_DFU, "%s( %p, %u, %d)", __func__, buf, size, 371 + manifest_sync_timeout); 372 + 373 + if (!size) { 374 + dev_printk(KERN_ERR, &udev->dev, "FW buffer length invalid!\n"); 375 + return -EINVAL; 376 + } 377 + 378 + block = kmalloc(FW_BLOCK_SIZE, GFP_KERNEL); 379 + if (!block) 380 + return -ENOMEM; 381 + 382 + do { 383 + if (need_dfu_state) { 384 + ret = at76_dfu_get_state(udev, &dfu_state); 385 + if (ret < 0) { 386 + dev_printk(KERN_ERR, &udev->dev, 387 + "cannot get DFU state: %d\n", ret); 388 + goto exit; 389 + } 390 + need_dfu_state = 0; 391 + } 392 + 393 + switch (dfu_state) { 394 + case STATE_DFU_DOWNLOAD_SYNC: 395 + at76_dbg(DBG_DFU, "STATE_DFU_DOWNLOAD_SYNC"); 396 + ret = at76_dfu_get_status(udev, &dfu_stat_buf); 397 + if (ret >= 0) { 398 + dfu_state = dfu_stat_buf.state; 399 + dfu_timeout = at76_get_timeout(&dfu_stat_buf); 400 + need_dfu_state = 0; 401 + } else 402 + dev_printk(KERN_ERR, &udev->dev, 403 + "at76_dfu_get_status returned %d\n", 404 + ret); 405 + break; 406 + 407 + case STATE_DFU_DOWNLOAD_BUSY: 408 + at76_dbg(DBG_DFU, "STATE_DFU_DOWNLOAD_BUSY"); 409 + need_dfu_state = 1; 410 + 411 + at76_dbg(DBG_DFU, "DFU: Resetting device"); 412 + schedule_timeout_interruptible(dfu_timeout); 413 + break; 414 + 415 + case STATE_DFU_DOWNLOAD_IDLE: 416 + at76_dbg(DBG_DFU, "DOWNLOAD..."); 417 + /* fall through */ 418 + case STATE_DFU_IDLE: 419 + at76_dbg(DBG_DFU, "DFU IDLE"); 420 + 421 + bsize = min_t(int, size, FW_BLOCK_SIZE); 422 + memcpy(block, buf, bsize); 423 + at76_dbg(DBG_DFU, "int fw, size left = %5d, " 424 + "bsize = %4d, blockno = %2d", size, bsize, 425 + blockno); 426 + ret = 427 + at76_load_int_fw_block(udev, blockno, block, bsize); 428 + buf += bsize; 429 + size -= bsize; 430 + blockno++; 431 + 432 + if (ret != bsize) 433 + dev_printk(KERN_ERR, &udev->dev, 434 + "at76_load_int_fw_block " 435 + "returned %d\n", ret); 436 + need_dfu_state = 1; 437 + break; 438 + 439 + case STATE_DFU_MANIFEST_SYNC: 440 + at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST_SYNC"); 441 + 442 + ret = at76_dfu_get_status(udev, &dfu_stat_buf); 443 + if (ret < 0) 444 + break; 445 + 446 + dfu_state = dfu_stat_buf.state; 447 + dfu_timeout = at76_get_timeout(&dfu_stat_buf); 448 + need_dfu_state = 0; 449 + 450 + /* override the timeout from the status response, 451 + needed for AT76C505A */ 452 + if (manifest_sync_timeout > 0) 453 + dfu_timeout = manifest_sync_timeout; 454 + 455 + at76_dbg(DBG_DFU, "DFU: Waiting for manifest phase"); 456 + schedule_timeout_interruptible(dfu_timeout); 457 + break; 458 + 459 + case STATE_DFU_MANIFEST: 460 + at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST"); 461 + is_done = 1; 462 + break; 463 + 464 + case STATE_DFU_MANIFEST_WAIT_RESET: 465 + at76_dbg(DBG_DFU, "STATE_DFU_MANIFEST_WAIT_RESET"); 466 + is_done = 1; 467 + break; 468 + 469 + case STATE_DFU_UPLOAD_IDLE: 470 + at76_dbg(DBG_DFU, "STATE_DFU_UPLOAD_IDLE"); 471 + break; 472 + 473 + case STATE_DFU_ERROR: 474 + at76_dbg(DBG_DFU, "STATE_DFU_ERROR"); 475 + ret = -EPIPE; 476 + break; 477 + 478 + default: 479 + at76_dbg(DBG_DFU, "DFU UNKNOWN STATE (%d)", dfu_state); 480 + ret = -EINVAL; 481 + break; 482 + } 483 + } while (!is_done && (ret >= 0)); 484 + 485 + exit: 486 + kfree(block); 487 + if (ret >= 0) 488 + ret = 0; 489 + 490 + return ret; 491 + } 492 + 493 + #define HEX2STR_BUFFERS 4 494 + #define HEX2STR_MAX_LEN 64 495 + #define BIN2HEX(x) ((x) < 10 ? '0' + (x) : (x) + 'A' - 10) 496 + 497 + /* Convert binary data into hex string */ 498 + static char *hex2str(void *buf, int len) 499 + { 500 + static atomic_t a = ATOMIC_INIT(0); 501 + static char bufs[HEX2STR_BUFFERS][3 * HEX2STR_MAX_LEN + 1]; 502 + char *ret = bufs[atomic_inc_return(&a) & (HEX2STR_BUFFERS - 1)]; 503 + char *obuf = ret; 504 + u8 *ibuf = buf; 505 + 506 + if (len > HEX2STR_MAX_LEN) 507 + len = HEX2STR_MAX_LEN; 508 + 509 + if (len <= 0) { 510 + ret[0] = '\0'; 511 + return ret; 512 + } 513 + 514 + while (len--) { 515 + *obuf++ = BIN2HEX(*ibuf >> 4); 516 + *obuf++ = BIN2HEX(*ibuf & 0xf); 517 + *obuf++ = '-'; 518 + ibuf++; 519 + } 520 + *(--obuf) = '\0'; 521 + 522 + return ret; 523 + } 524 + 525 + #define MAC2STR_BUFFERS 4 526 + 527 + static inline char *mac2str(u8 *mac) 528 + { 529 + static atomic_t a = ATOMIC_INIT(0); 530 + static char bufs[MAC2STR_BUFFERS][6 * 3]; 531 + char *str; 532 + 533 + str = bufs[atomic_inc_return(&a) & (MAC2STR_BUFFERS - 1)]; 534 + sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x", 535 + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); 536 + return str; 537 + } 538 + 539 + /* LED trigger */ 540 + static int tx_activity; 541 + static void at76_ledtrig_tx_timerfunc(unsigned long data); 542 + static DEFINE_TIMER(ledtrig_tx_timer, at76_ledtrig_tx_timerfunc, 0, 0); 543 + DEFINE_LED_TRIGGER(ledtrig_tx); 544 + 545 + static void at76_ledtrig_tx_timerfunc(unsigned long data) 546 + { 547 + static int tx_lastactivity; 548 + 549 + if (tx_lastactivity != tx_activity) { 550 + tx_lastactivity = tx_activity; 551 + led_trigger_event(ledtrig_tx, LED_FULL); 552 + mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4); 553 + } else 554 + led_trigger_event(ledtrig_tx, LED_OFF); 555 + } 556 + 557 + static void at76_ledtrig_tx_activity(void) 558 + { 559 + tx_activity++; 560 + if (!timer_pending(&ledtrig_tx_timer)) 561 + mod_timer(&ledtrig_tx_timer, jiffies + HZ / 4); 562 + } 563 + 564 + static int at76_remap(struct usb_device *udev) 565 + { 566 + int ret; 567 + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0a, 568 + USB_TYPE_VENDOR | USB_DIR_OUT | 569 + USB_RECIP_INTERFACE, 0, 0, NULL, 0, 570 + USB_CTRL_GET_TIMEOUT); 571 + if (ret < 0) 572 + return ret; 573 + return 0; 574 + } 575 + 576 + static int at76_get_op_mode(struct usb_device *udev) 577 + { 578 + int ret; 579 + u8 saved; 580 + u8 *op_mode; 581 + 582 + op_mode = kmalloc(1, GFP_NOIO); 583 + if (!op_mode) 584 + return -ENOMEM; 585 + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, 586 + USB_TYPE_VENDOR | USB_DIR_IN | 587 + USB_RECIP_INTERFACE, 0x01, 0, op_mode, 1, 588 + USB_CTRL_GET_TIMEOUT); 589 + saved = *op_mode; 590 + kfree(op_mode); 591 + 592 + if (ret < 0) 593 + return ret; 594 + else if (ret < 1) 595 + return -EIO; 596 + else 597 + return saved; 598 + } 599 + 600 + /* Load a block of the second ("external") part of the firmware */ 601 + static inline int at76_load_ext_fw_block(struct usb_device *udev, int blockno, 602 + void *block, int size) 603 + { 604 + return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e, 605 + USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 606 + 0x0802, blockno, block, size, 607 + USB_CTRL_GET_TIMEOUT); 608 + } 609 + 610 + static inline int at76_get_hw_cfg(struct usb_device *udev, 611 + union at76_hwcfg *buf, int buf_size) 612 + { 613 + return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, 614 + USB_TYPE_VENDOR | USB_DIR_IN | 615 + USB_RECIP_INTERFACE, 0x0a02, 0, 616 + buf, buf_size, USB_CTRL_GET_TIMEOUT); 617 + } 618 + 619 + /* Intersil boards use a different "value" for GetHWConfig requests */ 620 + static inline int at76_get_hw_cfg_intersil(struct usb_device *udev, 621 + union at76_hwcfg *buf, int buf_size) 622 + { 623 + return usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, 624 + USB_TYPE_VENDOR | USB_DIR_IN | 625 + USB_RECIP_INTERFACE, 0x0902, 0, 626 + buf, buf_size, USB_CTRL_GET_TIMEOUT); 627 + } 628 + 629 + /* Get the hardware configuration for the adapter and put it to the appropriate 630 + * fields of 'priv' (the GetHWConfig request and interpretation of the result 631 + * depends on the board type) */ 632 + static int at76_get_hw_config(struct at76_priv *priv) 633 + { 634 + int ret; 635 + union at76_hwcfg *hwcfg = kmalloc(sizeof(*hwcfg), GFP_KERNEL); 636 + 637 + if (!hwcfg) 638 + return -ENOMEM; 639 + 640 + if (at76_is_intersil(priv->board_type)) { 641 + ret = at76_get_hw_cfg_intersil(priv->udev, hwcfg, 642 + sizeof(hwcfg->i)); 643 + if (ret < 0) 644 + goto exit; 645 + memcpy(priv->mac_addr, hwcfg->i.mac_addr, ETH_ALEN); 646 + priv->regulatory_domain = hwcfg->i.regulatory_domain; 647 + } else if (at76_is_503rfmd(priv->board_type)) { 648 + ret = at76_get_hw_cfg(priv->udev, hwcfg, sizeof(hwcfg->r3)); 649 + if (ret < 0) 650 + goto exit; 651 + memcpy(priv->mac_addr, hwcfg->r3.mac_addr, ETH_ALEN); 652 + priv->regulatory_domain = hwcfg->r3.regulatory_domain; 653 + } else { 654 + ret = at76_get_hw_cfg(priv->udev, hwcfg, sizeof(hwcfg->r5)); 655 + if (ret < 0) 656 + goto exit; 657 + memcpy(priv->mac_addr, hwcfg->r5.mac_addr, ETH_ALEN); 658 + priv->regulatory_domain = hwcfg->r5.regulatory_domain; 659 + } 660 + 661 + exit: 662 + kfree(hwcfg); 663 + if (ret < 0) 664 + printk(KERN_ERR "%s: cannot get HW Config (error %d)\n", 665 + wiphy_name(priv->hw->wiphy), ret); 666 + 667 + return ret; 668 + } 669 + 670 + static struct reg_domain const *at76_get_reg_domain(u16 code) 671 + { 672 + int i; 673 + static struct reg_domain const fd_tab[] = { 674 + { 0x10, "FCC (USA)", 0x7ff }, /* ch 1-11 */ 675 + { 0x20, "IC (Canada)", 0x7ff }, /* ch 1-11 */ 676 + { 0x30, "ETSI (most of Europe)", 0x1fff }, /* ch 1-13 */ 677 + { 0x31, "Spain", 0x600 }, /* ch 10-11 */ 678 + { 0x32, "France", 0x1e00 }, /* ch 10-13 */ 679 + { 0x40, "MKK (Japan)", 0x2000 }, /* ch 14 */ 680 + { 0x41, "MKK1 (Japan)", 0x3fff }, /* ch 1-14 */ 681 + { 0x50, "Israel", 0x3fc }, /* ch 3-9 */ 682 + { 0x00, "<unknown>", 0xffffffff } /* ch 1-32 */ 683 + }; 684 + 685 + /* Last entry is fallback for unknown domain code */ 686 + for (i = 0; i < ARRAY_SIZE(fd_tab) - 1; i++) 687 + if (code == fd_tab[i].code) 688 + break; 689 + 690 + return &fd_tab[i]; 691 + } 692 + 693 + static inline int at76_get_mib(struct usb_device *udev, u16 mib, void *buf, 694 + int buf_size) 695 + { 696 + int ret; 697 + 698 + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x33, 699 + USB_TYPE_VENDOR | USB_DIR_IN | 700 + USB_RECIP_INTERFACE, mib << 8, 0, buf, buf_size, 701 + USB_CTRL_GET_TIMEOUT); 702 + if (ret >= 0 && ret != buf_size) 703 + return -EIO; 704 + return ret; 705 + } 706 + 707 + /* Return positive number for status, negative for an error */ 708 + static inline int at76_get_cmd_status(struct usb_device *udev, u8 cmd) 709 + { 710 + u8 *stat_buf; 711 + int ret; 712 + 713 + stat_buf = kmalloc(40, GFP_NOIO); 714 + if (!stat_buf) 715 + return -ENOMEM; 716 + 717 + ret = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), 0x22, 718 + USB_TYPE_VENDOR | USB_DIR_IN | 719 + USB_RECIP_INTERFACE, cmd, 0, stat_buf, 720 + 40, USB_CTRL_GET_TIMEOUT); 721 + if (ret >= 0) 722 + ret = stat_buf[5]; 723 + kfree(stat_buf); 724 + 725 + return ret; 726 + } 727 + 728 + #define MAKE_CMD_CASE(c) case (c): return #c 729 + static const char *at76_get_cmd_string(u8 cmd_status) 730 + { 731 + switch (cmd_status) { 732 + MAKE_CMD_CASE(CMD_SET_MIB); 733 + MAKE_CMD_CASE(CMD_GET_MIB); 734 + MAKE_CMD_CASE(CMD_SCAN); 735 + MAKE_CMD_CASE(CMD_JOIN); 736 + MAKE_CMD_CASE(CMD_START_IBSS); 737 + MAKE_CMD_CASE(CMD_RADIO_ON); 738 + MAKE_CMD_CASE(CMD_RADIO_OFF); 739 + MAKE_CMD_CASE(CMD_STARTUP); 740 + } 741 + 742 + return "UNKNOWN"; 743 + } 744 + 745 + static int at76_set_card_command(struct usb_device *udev, u8 cmd, void *buf, 746 + int buf_size) 747 + { 748 + int ret; 749 + struct at76_command *cmd_buf = kmalloc(sizeof(struct at76_command) + 750 + buf_size, GFP_KERNEL); 751 + 752 + if (!cmd_buf) 753 + return -ENOMEM; 754 + 755 + cmd_buf->cmd = cmd; 756 + cmd_buf->reserved = 0; 757 + cmd_buf->size = cpu_to_le16(buf_size); 758 + memcpy(cmd_buf->data, buf, buf_size); 759 + 760 + at76_dbg_dump(DBG_CMD, cmd_buf, sizeof(struct at76_command) + buf_size, 761 + "issuing command %s (0x%02x)", 762 + at76_get_cmd_string(cmd), cmd); 763 + 764 + ret = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x0e, 765 + USB_TYPE_VENDOR | USB_DIR_OUT | USB_RECIP_DEVICE, 766 + 0, 0, cmd_buf, 767 + sizeof(struct at76_command) + buf_size, 768 + USB_CTRL_GET_TIMEOUT); 769 + kfree(cmd_buf); 770 + return ret; 771 + } 772 + 773 + #define MAKE_CMD_STATUS_CASE(c) case (c): return #c 774 + static const char *at76_get_cmd_status_string(u8 cmd_status) 775 + { 776 + switch (cmd_status) { 777 + MAKE_CMD_STATUS_CASE(CMD_STATUS_IDLE); 778 + MAKE_CMD_STATUS_CASE(CMD_STATUS_COMPLETE); 779 + MAKE_CMD_STATUS_CASE(CMD_STATUS_UNKNOWN); 780 + MAKE_CMD_STATUS_CASE(CMD_STATUS_INVALID_PARAMETER); 781 + MAKE_CMD_STATUS_CASE(CMD_STATUS_FUNCTION_NOT_SUPPORTED); 782 + MAKE_CMD_STATUS_CASE(CMD_STATUS_TIME_OUT); 783 + MAKE_CMD_STATUS_CASE(CMD_STATUS_IN_PROGRESS); 784 + MAKE_CMD_STATUS_CASE(CMD_STATUS_HOST_FAILURE); 785 + MAKE_CMD_STATUS_CASE(CMD_STATUS_SCAN_FAILED); 786 + } 787 + 788 + return "UNKNOWN"; 789 + } 790 + 791 + /* Wait until the command is completed */ 792 + static int at76_wait_completion(struct at76_priv *priv, int cmd) 793 + { 794 + int status = 0; 795 + unsigned long timeout = jiffies + CMD_COMPLETION_TIMEOUT; 796 + 797 + do { 798 + status = at76_get_cmd_status(priv->udev, cmd); 799 + if (status < 0) { 800 + printk(KERN_ERR "%s: at76_get_cmd_status failed: %d\n", 801 + wiphy_name(priv->hw->wiphy), status); 802 + break; 803 + } 804 + 805 + at76_dbg(DBG_WAIT_COMPLETE, 806 + "%s: Waiting on cmd %d, status = %d (%s)", 807 + wiphy_name(priv->hw->wiphy), cmd, status, 808 + at76_get_cmd_status_string(status)); 809 + 810 + if (status != CMD_STATUS_IN_PROGRESS 811 + && status != CMD_STATUS_IDLE) 812 + break; 813 + 814 + schedule_timeout_interruptible(HZ / 10); /* 100 ms */ 815 + if (time_after(jiffies, timeout)) { 816 + printk(KERN_ERR 817 + "%s: completion timeout for command %d\n", 818 + wiphy_name(priv->hw->wiphy), cmd); 819 + status = -ETIMEDOUT; 820 + break; 821 + } 822 + } while (1); 823 + 824 + return status; 825 + } 826 + 827 + static int at76_set_mib(struct at76_priv *priv, struct set_mib_buffer *buf) 828 + { 829 + int ret; 830 + 831 + ret = at76_set_card_command(priv->udev, CMD_SET_MIB, buf, 832 + offsetof(struct set_mib_buffer, 833 + data) + buf->size); 834 + if (ret < 0) 835 + return ret; 836 + 837 + ret = at76_wait_completion(priv, CMD_SET_MIB); 838 + if (ret != CMD_STATUS_COMPLETE) { 839 + printk(KERN_INFO 840 + "%s: set_mib: at76_wait_completion failed " 841 + "with %d\n", wiphy_name(priv->hw->wiphy), ret); 842 + ret = -EIO; 843 + } 844 + 845 + return ret; 846 + } 847 + 848 + /* Return < 0 on error, == 0 if no command sent, == 1 if cmd sent */ 849 + static int at76_set_radio(struct at76_priv *priv, int enable) 850 + { 851 + int ret; 852 + int cmd; 853 + 854 + if (priv->radio_on == enable) 855 + return 0; 856 + 857 + cmd = enable ? CMD_RADIO_ON : CMD_RADIO_OFF; 858 + 859 + ret = at76_set_card_command(priv->udev, cmd, NULL, 0); 860 + if (ret < 0) 861 + printk(KERN_ERR "%s: at76_set_card_command(%d) failed: %d\n", 862 + wiphy_name(priv->hw->wiphy), cmd, ret); 863 + else 864 + ret = 1; 865 + 866 + priv->radio_on = enable; 867 + return ret; 868 + } 869 + 870 + /* Set current power save mode (AT76_PM_OFF/AT76_PM_ON/AT76_PM_SMART) */ 871 + static int at76_set_pm_mode(struct at76_priv *priv) 872 + { 873 + int ret = 0; 874 + 875 + priv->mib_buf.type = MIB_MAC_MGMT; 876 + priv->mib_buf.size = 1; 877 + priv->mib_buf.index = offsetof(struct mib_mac_mgmt, power_mgmt_mode); 878 + priv->mib_buf.data.byte = priv->pm_mode; 879 + 880 + ret = at76_set_mib(priv, &priv->mib_buf); 881 + if (ret < 0) 882 + printk(KERN_ERR "%s: set_mib (pm_mode) failed: %d\n", 883 + wiphy_name(priv->hw->wiphy), ret); 884 + 885 + return ret; 886 + } 887 + 888 + static int at76_set_preamble(struct at76_priv *priv, u8 type) 889 + { 890 + int ret = 0; 891 + 892 + priv->mib_buf.type = MIB_LOCAL; 893 + priv->mib_buf.size = 1; 894 + priv->mib_buf.index = offsetof(struct mib_local, preamble_type); 895 + priv->mib_buf.data.byte = type; 896 + 897 + ret = at76_set_mib(priv, &priv->mib_buf); 898 + if (ret < 0) 899 + printk(KERN_ERR "%s: set_mib (preamble) failed: %d\n", 900 + wiphy_name(priv->hw->wiphy), ret); 901 + 902 + return ret; 903 + } 904 + 905 + static int at76_set_frag(struct at76_priv *priv, u16 size) 906 + { 907 + int ret = 0; 908 + 909 + priv->mib_buf.type = MIB_MAC; 910 + priv->mib_buf.size = 2; 911 + priv->mib_buf.index = offsetof(struct mib_mac, frag_threshold); 912 + priv->mib_buf.data.word = cpu_to_le16(size); 913 + 914 + ret = at76_set_mib(priv, &priv->mib_buf); 915 + if (ret < 0) 916 + printk(KERN_ERR "%s: set_mib (frag threshold) failed: %d\n", 917 + wiphy_name(priv->hw->wiphy), ret); 918 + 919 + return ret; 920 + } 921 + 922 + static int at76_set_rts(struct at76_priv *priv, u16 size) 923 + { 924 + int ret = 0; 925 + 926 + priv->mib_buf.type = MIB_MAC; 927 + priv->mib_buf.size = 2; 928 + priv->mib_buf.index = offsetof(struct mib_mac, rts_threshold); 929 + priv->mib_buf.data.word = cpu_to_le16(size); 930 + 931 + ret = at76_set_mib(priv, &priv->mib_buf); 932 + if (ret < 0) 933 + printk(KERN_ERR "%s: set_mib (rts) failed: %d\n", 934 + wiphy_name(priv->hw->wiphy), ret); 935 + 936 + return ret; 937 + } 938 + 939 + static int at76_set_autorate_fallback(struct at76_priv *priv, int onoff) 940 + { 941 + int ret = 0; 942 + 943 + priv->mib_buf.type = MIB_LOCAL; 944 + priv->mib_buf.size = 1; 945 + priv->mib_buf.index = offsetof(struct mib_local, txautorate_fallback); 946 + priv->mib_buf.data.byte = onoff; 947 + 948 + ret = at76_set_mib(priv, &priv->mib_buf); 949 + if (ret < 0) 950 + printk(KERN_ERR "%s: set_mib (autorate fallback) failed: %d\n", 951 + wiphy_name(priv->hw->wiphy), ret); 952 + 953 + return ret; 954 + } 955 + 956 + static void at76_dump_mib_mac_addr(struct at76_priv *priv) 957 + { 958 + int i; 959 + int ret; 960 + struct mib_mac_addr *m = kmalloc(sizeof(struct mib_mac_addr), 961 + GFP_KERNEL); 962 + 963 + if (!m) 964 + return; 965 + 966 + ret = at76_get_mib(priv->udev, MIB_MAC_ADDR, m, 967 + sizeof(struct mib_mac_addr)); 968 + if (ret < 0) { 969 + printk(KERN_ERR "%s: at76_get_mib (MAC_ADDR) failed: %d\n", 970 + wiphy_name(priv->hw->wiphy), ret); 971 + goto exit; 972 + } 973 + 974 + at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: mac_addr %s res 0x%x 0x%x", 975 + wiphy_name(priv->hw->wiphy), 976 + mac2str(m->mac_addr), m->res[0], m->res[1]); 977 + for (i = 0; i < ARRAY_SIZE(m->group_addr); i++) 978 + at76_dbg(DBG_MIB, "%s: MIB MAC_ADDR: group addr %d: %s, " 979 + "status %d", wiphy_name(priv->hw->wiphy), i, 980 + mac2str(m->group_addr[i]), m->group_addr_status[i]); 981 + exit: 982 + kfree(m); 983 + } 984 + 985 + static void at76_dump_mib_mac_wep(struct at76_priv *priv) 986 + { 987 + int i; 988 + int ret; 989 + int key_len; 990 + struct mib_mac_wep *m = kmalloc(sizeof(struct mib_mac_wep), GFP_KERNEL); 991 + 992 + if (!m) 993 + return; 994 + 995 + ret = at76_get_mib(priv->udev, MIB_MAC_WEP, m, 996 + sizeof(struct mib_mac_wep)); 997 + if (ret < 0) { 998 + printk(KERN_ERR "%s: at76_get_mib (MAC_WEP) failed: %d\n", 999 + wiphy_name(priv->hw->wiphy), ret); 1000 + goto exit; 1001 + } 1002 + 1003 + at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: priv_invoked %u def_key_id %u " 1004 + "key_len %u excl_unencr %u wep_icv_err %u wep_excluded %u " 1005 + "encr_level %u key %d", wiphy_name(priv->hw->wiphy), 1006 + m->privacy_invoked, m->wep_default_key_id, 1007 + m->wep_key_mapping_len, m->exclude_unencrypted, 1008 + le32_to_cpu(m->wep_icv_error_count), 1009 + le32_to_cpu(m->wep_excluded_count), m->encryption_level, 1010 + m->wep_default_key_id); 1011 + 1012 + key_len = (m->encryption_level == 1) ? 1013 + WEP_SMALL_KEY_LEN : WEP_LARGE_KEY_LEN; 1014 + 1015 + for (i = 0; i < WEP_KEYS; i++) 1016 + at76_dbg(DBG_MIB, "%s: MIB MAC_WEP: key %d: %s", 1017 + wiphy_name(priv->hw->wiphy), i, 1018 + hex2str(m->wep_default_keyvalue[i], key_len)); 1019 + exit: 1020 + kfree(m); 1021 + } 1022 + 1023 + static void at76_dump_mib_mac_mgmt(struct at76_priv *priv) 1024 + { 1025 + int ret; 1026 + struct mib_mac_mgmt *m = kmalloc(sizeof(struct mib_mac_mgmt), 1027 + GFP_KERNEL); 1028 + 1029 + if (!m) 1030 + return; 1031 + 1032 + ret = at76_get_mib(priv->udev, MIB_MAC_MGMT, m, 1033 + sizeof(struct mib_mac_mgmt)); 1034 + if (ret < 0) { 1035 + printk(KERN_ERR "%s: at76_get_mib (MAC_MGMT) failed: %d\n", 1036 + wiphy_name(priv->hw->wiphy), ret); 1037 + goto exit; 1038 + } 1039 + 1040 + at76_dbg(DBG_MIB, "%s: MIB MAC_MGMT: beacon_period %d CFP_max_duration " 1041 + "%d medium_occupancy_limit %d station_id 0x%x ATIM_window %d " 1042 + "CFP_mode %d privacy_opt_impl %d DTIM_period %d CFP_period %d " 1043 + "current_bssid %s current_essid %s current_bss_type %d " 1044 + "pm_mode %d ibss_change %d res %d " 1045 + "multi_domain_capability_implemented %d " 1046 + "international_roaming %d country_string %.3s", 1047 + wiphy_name(priv->hw->wiphy), le16_to_cpu(m->beacon_period), 1048 + le16_to_cpu(m->CFP_max_duration), 1049 + le16_to_cpu(m->medium_occupancy_limit), 1050 + le16_to_cpu(m->station_id), le16_to_cpu(m->ATIM_window), 1051 + m->CFP_mode, m->privacy_option_implemented, m->DTIM_period, 1052 + m->CFP_period, mac2str(m->current_bssid), 1053 + hex2str(m->current_essid, IW_ESSID_MAX_SIZE), 1054 + m->current_bss_type, m->power_mgmt_mode, m->ibss_change, 1055 + m->res, m->multi_domain_capability_implemented, 1056 + m->multi_domain_capability_enabled, m->country_string); 1057 + exit: 1058 + kfree(m); 1059 + } 1060 + 1061 + static void at76_dump_mib_mac(struct at76_priv *priv) 1062 + { 1063 + int ret; 1064 + struct mib_mac *m = kmalloc(sizeof(struct mib_mac), GFP_KERNEL); 1065 + 1066 + if (!m) 1067 + return; 1068 + 1069 + ret = at76_get_mib(priv->udev, MIB_MAC, m, sizeof(struct mib_mac)); 1070 + if (ret < 0) { 1071 + printk(KERN_ERR "%s: at76_get_mib (MAC) failed: %d\n", 1072 + wiphy_name(priv->hw->wiphy), ret); 1073 + goto exit; 1074 + } 1075 + 1076 + at76_dbg(DBG_MIB, "%s: MIB MAC: max_tx_msdu_lifetime %d " 1077 + "max_rx_lifetime %d frag_threshold %d rts_threshold %d " 1078 + "cwmin %d cwmax %d short_retry_time %d long_retry_time %d " 1079 + "scan_type %d scan_channel %d probe_delay %u " 1080 + "min_channel_time %d max_channel_time %d listen_int %d " 1081 + "desired_ssid %s desired_bssid %s desired_bsstype %d", 1082 + wiphy_name(priv->hw->wiphy), 1083 + le32_to_cpu(m->max_tx_msdu_lifetime), 1084 + le32_to_cpu(m->max_rx_lifetime), 1085 + le16_to_cpu(m->frag_threshold), le16_to_cpu(m->rts_threshold), 1086 + le16_to_cpu(m->cwmin), le16_to_cpu(m->cwmax), 1087 + m->short_retry_time, m->long_retry_time, m->scan_type, 1088 + m->scan_channel, le16_to_cpu(m->probe_delay), 1089 + le16_to_cpu(m->min_channel_time), 1090 + le16_to_cpu(m->max_channel_time), 1091 + le16_to_cpu(m->listen_interval), 1092 + hex2str(m->desired_ssid, IW_ESSID_MAX_SIZE), 1093 + mac2str(m->desired_bssid), m->desired_bsstype); 1094 + exit: 1095 + kfree(m); 1096 + } 1097 + 1098 + static void at76_dump_mib_phy(struct at76_priv *priv) 1099 + { 1100 + int ret; 1101 + struct mib_phy *m = kmalloc(sizeof(struct mib_phy), GFP_KERNEL); 1102 + 1103 + if (!m) 1104 + return; 1105 + 1106 + ret = at76_get_mib(priv->udev, MIB_PHY, m, sizeof(struct mib_phy)); 1107 + if (ret < 0) { 1108 + printk(KERN_ERR "%s: at76_get_mib (PHY) failed: %d\n", 1109 + wiphy_name(priv->hw->wiphy), ret); 1110 + goto exit; 1111 + } 1112 + 1113 + at76_dbg(DBG_MIB, "%s: MIB PHY: ed_threshold %d slot_time %d " 1114 + "sifs_time %d preamble_length %d plcp_header_length %d " 1115 + "mpdu_max_length %d cca_mode_supported %d operation_rate_set " 1116 + "0x%x 0x%x 0x%x 0x%x channel_id %d current_cca_mode %d " 1117 + "phy_type %d current_reg_domain %d", 1118 + wiphy_name(priv->hw->wiphy), le32_to_cpu(m->ed_threshold), 1119 + le16_to_cpu(m->slot_time), le16_to_cpu(m->sifs_time), 1120 + le16_to_cpu(m->preamble_length), 1121 + le16_to_cpu(m->plcp_header_length), 1122 + le16_to_cpu(m->mpdu_max_length), 1123 + le16_to_cpu(m->cca_mode_supported), m->operation_rate_set[0], 1124 + m->operation_rate_set[1], m->operation_rate_set[2], 1125 + m->operation_rate_set[3], m->channel_id, m->current_cca_mode, 1126 + m->phy_type, m->current_reg_domain); 1127 + exit: 1128 + kfree(m); 1129 + } 1130 + 1131 + static void at76_dump_mib_local(struct at76_priv *priv) 1132 + { 1133 + int ret; 1134 + struct mib_local *m = kmalloc(sizeof(struct mib_phy), GFP_KERNEL); 1135 + 1136 + if (!m) 1137 + return; 1138 + 1139 + ret = at76_get_mib(priv->udev, MIB_LOCAL, m, sizeof(struct mib_local)); 1140 + if (ret < 0) { 1141 + printk(KERN_ERR "%s: at76_get_mib (LOCAL) failed: %d\n", 1142 + wiphy_name(priv->hw->wiphy), ret); 1143 + goto exit; 1144 + } 1145 + 1146 + at76_dbg(DBG_MIB, "%s: MIB LOCAL: beacon_enable %d " 1147 + "txautorate_fallback %d ssid_size %d promiscuous_mode %d " 1148 + "preamble_type %d", wiphy_name(priv->hw->wiphy), 1149 + m->beacon_enable, 1150 + m->txautorate_fallback, m->ssid_size, m->promiscuous_mode, 1151 + m->preamble_type); 1152 + exit: 1153 + kfree(m); 1154 + } 1155 + 1156 + static void at76_dump_mib_mdomain(struct at76_priv *priv) 1157 + { 1158 + int ret; 1159 + struct mib_mdomain *m = kmalloc(sizeof(struct mib_mdomain), GFP_KERNEL); 1160 + 1161 + if (!m) 1162 + return; 1163 + 1164 + ret = at76_get_mib(priv->udev, MIB_MDOMAIN, m, 1165 + sizeof(struct mib_mdomain)); 1166 + if (ret < 0) { 1167 + printk(KERN_ERR "%s: at76_get_mib (MDOMAIN) failed: %d\n", 1168 + wiphy_name(priv->hw->wiphy), ret); 1169 + goto exit; 1170 + } 1171 + 1172 + at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: channel_list %s", 1173 + wiphy_name(priv->hw->wiphy), 1174 + hex2str(m->channel_list, sizeof(m->channel_list))); 1175 + 1176 + at76_dbg(DBG_MIB, "%s: MIB MDOMAIN: tx_powerlevel %s", 1177 + wiphy_name(priv->hw->wiphy), 1178 + hex2str(m->tx_powerlevel, sizeof(m->tx_powerlevel))); 1179 + exit: 1180 + kfree(m); 1181 + } 1182 + 1183 + /* Enable monitor mode */ 1184 + static int at76_start_monitor(struct at76_priv *priv) 1185 + { 1186 + struct at76_req_scan scan; 1187 + int ret; 1188 + 1189 + memset(&scan, 0, sizeof(struct at76_req_scan)); 1190 + memset(scan.bssid, 0xff, ETH_ALEN); 1191 + 1192 + scan.channel = priv->channel; 1193 + scan.scan_type = SCAN_TYPE_PASSIVE; 1194 + scan.international_scan = 0; 1195 + 1196 + ret = at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan)); 1197 + if (ret >= 0) 1198 + ret = at76_get_cmd_status(priv->udev, CMD_SCAN); 1199 + 1200 + return ret; 1201 + } 1202 + 1203 + /* Calculate padding from txbuf->wlength (which excludes the USB TX header), 1204 + likely to compensate a flaw in the AT76C503A USB part ... */ 1205 + static inline int at76_calc_padding(int wlen) 1206 + { 1207 + /* add the USB TX header */ 1208 + wlen += AT76_TX_HDRLEN; 1209 + 1210 + wlen = wlen % 64; 1211 + 1212 + if (wlen < 50) 1213 + return 50 - wlen; 1214 + 1215 + if (wlen >= 61) 1216 + return 64 + 50 - wlen; 1217 + 1218 + return 0; 1219 + } 1220 + 1221 + static void at76_rx_callback(struct urb *urb) 1222 + { 1223 + struct at76_priv *priv = urb->context; 1224 + 1225 + priv->rx_tasklet.data = (unsigned long)urb; 1226 + tasklet_schedule(&priv->rx_tasklet); 1227 + return; 1228 + } 1229 + 1230 + static int at76_submit_rx_urb(struct at76_priv *priv) 1231 + { 1232 + int ret; 1233 + int size; 1234 + struct sk_buff *skb = priv->rx_skb; 1235 + 1236 + if (!priv->rx_urb) { 1237 + printk(KERN_ERR "%s: %s: priv->rx_urb is NULL\n", 1238 + wiphy_name(priv->hw->wiphy), __func__); 1239 + return -EFAULT; 1240 + } 1241 + 1242 + if (!skb) { 1243 + skb = dev_alloc_skb(sizeof(struct at76_rx_buffer)); 1244 + if (!skb) { 1245 + printk(KERN_ERR "%s: cannot allocate rx skbuff\n", 1246 + wiphy_name(priv->hw->wiphy)); 1247 + ret = -ENOMEM; 1248 + goto exit; 1249 + } 1250 + priv->rx_skb = skb; 1251 + } else { 1252 + skb_push(skb, skb_headroom(skb)); 1253 + skb_trim(skb, 0); 1254 + } 1255 + 1256 + size = skb_tailroom(skb); 1257 + usb_fill_bulk_urb(priv->rx_urb, priv->udev, priv->rx_pipe, 1258 + skb_put(skb, size), size, at76_rx_callback, priv); 1259 + ret = usb_submit_urb(priv->rx_urb, GFP_ATOMIC); 1260 + if (ret < 0) { 1261 + if (ret == -ENODEV) 1262 + at76_dbg(DBG_DEVSTART, 1263 + "usb_submit_urb returned -ENODEV"); 1264 + else 1265 + printk(KERN_ERR "%s: rx, usb_submit_urb failed: %d\n", 1266 + wiphy_name(priv->hw->wiphy), ret); 1267 + } 1268 + 1269 + exit: 1270 + if (ret < 0 && ret != -ENODEV) 1271 + printk(KERN_ERR "%s: cannot submit rx urb - please unload the " 1272 + "driver and/or power cycle the device\n", 1273 + wiphy_name(priv->hw->wiphy)); 1274 + 1275 + return ret; 1276 + } 1277 + 1278 + /* Download external firmware */ 1279 + static int at76_load_external_fw(struct usb_device *udev, struct fwentry *fwe) 1280 + { 1281 + int ret; 1282 + int op_mode; 1283 + int blockno = 0; 1284 + int bsize; 1285 + u8 *block; 1286 + u8 *buf = fwe->extfw; 1287 + int size = fwe->extfw_size; 1288 + 1289 + if (!buf || !size) 1290 + return -ENOENT; 1291 + 1292 + op_mode = at76_get_op_mode(udev); 1293 + at76_dbg(DBG_DEVSTART, "opmode %d", op_mode); 1294 + 1295 + if (op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) { 1296 + dev_printk(KERN_ERR, &udev->dev, "unexpected opmode %d\n", 1297 + op_mode); 1298 + return -EINVAL; 1299 + } 1300 + 1301 + block = kmalloc(FW_BLOCK_SIZE, GFP_KERNEL); 1302 + if (!block) 1303 + return -ENOMEM; 1304 + 1305 + at76_dbg(DBG_DEVSTART, "downloading external firmware"); 1306 + 1307 + /* for fw >= 0.100, the device needs an extra empty block */ 1308 + do { 1309 + bsize = min_t(int, size, FW_BLOCK_SIZE); 1310 + memcpy(block, buf, bsize); 1311 + at76_dbg(DBG_DEVSTART, 1312 + "ext fw, size left = %5d, bsize = %4d, blockno = %2d", 1313 + size, bsize, blockno); 1314 + ret = at76_load_ext_fw_block(udev, blockno, block, bsize); 1315 + if (ret != bsize) { 1316 + dev_printk(KERN_ERR, &udev->dev, 1317 + "loading %dth firmware block failed: %d\n", 1318 + blockno, ret); 1319 + goto exit; 1320 + } 1321 + buf += bsize; 1322 + size -= bsize; 1323 + blockno++; 1324 + } while (bsize > 0); 1325 + 1326 + if (at76_is_505a(fwe->board_type)) { 1327 + at76_dbg(DBG_DEVSTART, "200 ms delay for 505a"); 1328 + schedule_timeout_interruptible(HZ / 5 + 1); 1329 + } 1330 + 1331 + exit: 1332 + kfree(block); 1333 + if (ret < 0) 1334 + dev_printk(KERN_ERR, &udev->dev, 1335 + "downloading external firmware failed: %d\n", ret); 1336 + return ret; 1337 + } 1338 + 1339 + /* Download internal firmware */ 1340 + static int at76_load_internal_fw(struct usb_device *udev, struct fwentry *fwe) 1341 + { 1342 + int ret; 1343 + int need_remap = !at76_is_505a(fwe->board_type); 1344 + 1345 + ret = at76_usbdfu_download(udev, fwe->intfw, fwe->intfw_size, 1346 + need_remap ? 0 : 2 * HZ); 1347 + 1348 + if (ret < 0) { 1349 + dev_printk(KERN_ERR, &udev->dev, 1350 + "downloading internal fw failed with %d\n", ret); 1351 + goto exit; 1352 + } 1353 + 1354 + at76_dbg(DBG_DEVSTART, "sending REMAP"); 1355 + 1356 + /* no REMAP for 505A (see SF driver) */ 1357 + if (need_remap) { 1358 + ret = at76_remap(udev); 1359 + if (ret < 0) { 1360 + dev_printk(KERN_ERR, &udev->dev, 1361 + "sending REMAP failed with %d\n", ret); 1362 + goto exit; 1363 + } 1364 + } 1365 + 1366 + at76_dbg(DBG_DEVSTART, "sleeping for 2 seconds"); 1367 + schedule_timeout_interruptible(2 * HZ + 1); 1368 + usb_reset_device(udev); 1369 + 1370 + exit: 1371 + return ret; 1372 + } 1373 + 1374 + static int at76_startup_device(struct at76_priv *priv) 1375 + { 1376 + struct at76_card_config *ccfg = &priv->card_config; 1377 + int ret; 1378 + 1379 + at76_dbg(DBG_PARAMS, 1380 + "%s param: ssid %.*s (%s) mode %s ch %d wep %s key %d " 1381 + "keylen %d", wiphy_name(priv->hw->wiphy), priv->essid_size, 1382 + priv->essid, hex2str(priv->essid, IW_ESSID_MAX_SIZE), 1383 + priv->iw_mode == IW_MODE_ADHOC ? "adhoc" : "infra", 1384 + priv->channel, priv->wep_enabled ? "enabled" : "disabled", 1385 + priv->wep_key_id, priv->wep_keys_len[priv->wep_key_id]); 1386 + at76_dbg(DBG_PARAMS, 1387 + "%s param: preamble %s rts %d retry %d frag %d " 1388 + "txrate %s auth_mode %d", wiphy_name(priv->hw->wiphy), 1389 + preambles[priv->preamble_type], priv->rts_threshold, 1390 + priv->short_retry_limit, priv->frag_threshold, 1391 + priv->txrate == TX_RATE_1MBIT ? "1MBit" : priv->txrate == 1392 + TX_RATE_2MBIT ? "2MBit" : priv->txrate == 1393 + TX_RATE_5_5MBIT ? "5.5MBit" : priv->txrate == 1394 + TX_RATE_11MBIT ? "11MBit" : priv->txrate == 1395 + TX_RATE_AUTO ? "auto" : "<invalid>", priv->auth_mode); 1396 + at76_dbg(DBG_PARAMS, 1397 + "%s param: pm_mode %d pm_period %d auth_mode %s " 1398 + "scan_times %d %d scan_mode %s", 1399 + wiphy_name(priv->hw->wiphy), priv->pm_mode, priv->pm_period, 1400 + priv->auth_mode == WLAN_AUTH_OPEN ? "open" : "shared_secret", 1401 + priv->scan_min_time, priv->scan_max_time, 1402 + priv->scan_mode == SCAN_TYPE_ACTIVE ? "active" : "passive"); 1403 + 1404 + memset(ccfg, 0, sizeof(struct at76_card_config)); 1405 + ccfg->promiscuous_mode = 0; 1406 + ccfg->short_retry_limit = priv->short_retry_limit; 1407 + 1408 + if (priv->wep_enabled) { 1409 + if (priv->wep_keys_len[priv->wep_key_id] > WEP_SMALL_KEY_LEN) 1410 + ccfg->encryption_type = 2; 1411 + else 1412 + ccfg->encryption_type = 1; 1413 + 1414 + /* jal: always exclude unencrypted if WEP is active */ 1415 + ccfg->exclude_unencrypted = 1; 1416 + } else { 1417 + ccfg->exclude_unencrypted = 0; 1418 + ccfg->encryption_type = 0; 1419 + } 1420 + 1421 + ccfg->rts_threshold = cpu_to_le16(priv->rts_threshold); 1422 + ccfg->fragmentation_threshold = cpu_to_le16(priv->frag_threshold); 1423 + 1424 + memcpy(ccfg->basic_rate_set, hw_rates, 4); 1425 + /* jal: really needed, we do a set_mib for autorate later ??? */ 1426 + ccfg->auto_rate_fallback = (priv->txrate == TX_RATE_AUTO ? 1 : 0); 1427 + ccfg->channel = priv->channel; 1428 + ccfg->privacy_invoked = priv->wep_enabled; 1429 + memcpy(ccfg->current_ssid, priv->essid, IW_ESSID_MAX_SIZE); 1430 + ccfg->ssid_len = priv->essid_size; 1431 + 1432 + ccfg->wep_default_key_id = priv->wep_key_id; 1433 + memcpy(ccfg->wep_default_key_value, priv->wep_keys, 1434 + sizeof(priv->wep_keys)); 1435 + 1436 + ccfg->short_preamble = priv->preamble_type; 1437 + ccfg->beacon_period = cpu_to_le16(priv->beacon_period); 1438 + 1439 + ret = at76_set_card_command(priv->udev, CMD_STARTUP, &priv->card_config, 1440 + sizeof(struct at76_card_config)); 1441 + if (ret < 0) { 1442 + printk(KERN_ERR "%s: at76_set_card_command failed: %d\n", 1443 + wiphy_name(priv->hw->wiphy), ret); 1444 + return ret; 1445 + } 1446 + 1447 + at76_wait_completion(priv, CMD_STARTUP); 1448 + 1449 + /* remove BSSID from previous run */ 1450 + memset(priv->bssid, 0, ETH_ALEN); 1451 + 1452 + if (at76_set_radio(priv, 1) == 1) 1453 + at76_wait_completion(priv, CMD_RADIO_ON); 1454 + 1455 + ret = at76_set_preamble(priv, priv->preamble_type); 1456 + if (ret < 0) 1457 + return ret; 1458 + 1459 + ret = at76_set_frag(priv, priv->frag_threshold); 1460 + if (ret < 0) 1461 + return ret; 1462 + 1463 + ret = at76_set_rts(priv, priv->rts_threshold); 1464 + if (ret < 0) 1465 + return ret; 1466 + 1467 + ret = at76_set_autorate_fallback(priv, 1468 + priv->txrate == TX_RATE_AUTO ? 1 : 0); 1469 + if (ret < 0) 1470 + return ret; 1471 + 1472 + ret = at76_set_pm_mode(priv); 1473 + if (ret < 0) 1474 + return ret; 1475 + 1476 + if (at76_debug & DBG_MIB) { 1477 + at76_dump_mib_mac(priv); 1478 + at76_dump_mib_mac_addr(priv); 1479 + at76_dump_mib_mac_mgmt(priv); 1480 + at76_dump_mib_mac_wep(priv); 1481 + at76_dump_mib_mdomain(priv); 1482 + at76_dump_mib_phy(priv); 1483 + at76_dump_mib_local(priv); 1484 + } 1485 + 1486 + return 0; 1487 + } 1488 + 1489 + /* Enable or disable promiscuous mode */ 1490 + static void at76_work_set_promisc(struct work_struct *work) 1491 + { 1492 + struct at76_priv *priv = container_of(work, struct at76_priv, 1493 + work_set_promisc); 1494 + int ret = 0; 1495 + 1496 + if (priv->device_unplugged) 1497 + return; 1498 + 1499 + mutex_lock(&priv->mtx); 1500 + 1501 + priv->mib_buf.type = MIB_LOCAL; 1502 + priv->mib_buf.size = 1; 1503 + priv->mib_buf.index = offsetof(struct mib_local, promiscuous_mode); 1504 + priv->mib_buf.data.byte = priv->promisc ? 1 : 0; 1505 + 1506 + ret = at76_set_mib(priv, &priv->mib_buf); 1507 + if (ret < 0) 1508 + printk(KERN_ERR "%s: set_mib (promiscuous_mode) failed: %d\n", 1509 + wiphy_name(priv->hw->wiphy), ret); 1510 + 1511 + mutex_unlock(&priv->mtx); 1512 + } 1513 + 1514 + /* Submit Rx urb back to the device */ 1515 + static void at76_work_submit_rx(struct work_struct *work) 1516 + { 1517 + struct at76_priv *priv = container_of(work, struct at76_priv, 1518 + work_submit_rx); 1519 + 1520 + mutex_lock(&priv->mtx); 1521 + at76_submit_rx_urb(priv); 1522 + mutex_unlock(&priv->mtx); 1523 + } 1524 + 1525 + static void at76_rx_tasklet(unsigned long param) 1526 + { 1527 + struct urb *urb = (struct urb *)param; 1528 + struct at76_priv *priv = urb->context; 1529 + struct at76_rx_buffer *buf; 1530 + struct ieee80211_rx_status rx_status = { 0 }; 1531 + 1532 + if (priv->device_unplugged) { 1533 + at76_dbg(DBG_DEVSTART, "device unplugged"); 1534 + if (urb) 1535 + at76_dbg(DBG_DEVSTART, "urb status %d", urb->status); 1536 + return; 1537 + } 1538 + 1539 + if (!priv->rx_skb || !priv->rx_skb->data) 1540 + return; 1541 + 1542 + buf = (struct at76_rx_buffer *)priv->rx_skb->data; 1543 + 1544 + if (urb->status != 0) { 1545 + if (urb->status != -ENOENT && urb->status != -ECONNRESET) 1546 + at76_dbg(DBG_URB, 1547 + "%s %s: - nonzero Rx bulk status received: %d", 1548 + __func__, wiphy_name(priv->hw->wiphy), 1549 + urb->status); 1550 + return; 1551 + } 1552 + 1553 + at76_dbg(DBG_RX_ATMEL_HDR, 1554 + "%s: rx frame: rate %d rssi %d noise %d link %d", 1555 + wiphy_name(priv->hw->wiphy), buf->rx_rate, buf->rssi, 1556 + buf->noise_level, buf->link_quality); 1557 + 1558 + skb_pull(priv->rx_skb, AT76_RX_HDRLEN); 1559 + skb_trim(priv->rx_skb, le16_to_cpu(buf->wlength)); 1560 + at76_dbg_dump(DBG_RX_DATA, priv->rx_skb->data, 1561 + priv->rx_skb->len, "RX: len=%d", priv->rx_skb->len); 1562 + 1563 + rx_status.signal = buf->rssi; 1564 + rx_status.flag |= RX_FLAG_DECRYPTED; 1565 + rx_status.flag |= RX_FLAG_IV_STRIPPED; 1566 + 1567 + at76_dbg(DBG_MAC80211, "calling ieee80211_rx_irqsafe(): %d/%d", 1568 + priv->rx_skb->len, priv->rx_skb->data_len); 1569 + ieee80211_rx_irqsafe(priv->hw, priv->rx_skb, &rx_status); 1570 + 1571 + /* Use a new skb for the next receive */ 1572 + priv->rx_skb = NULL; 1573 + 1574 + at76_submit_rx_urb(priv); 1575 + } 1576 + 1577 + /* Load firmware into kernel memory and parse it */ 1578 + static struct fwentry *at76_load_firmware(struct usb_device *udev, 1579 + enum board_type board_type) 1580 + { 1581 + int ret; 1582 + char *str; 1583 + struct at76_fw_header *fwh; 1584 + struct fwentry *fwe = &firmwares[board_type]; 1585 + 1586 + mutex_lock(&fw_mutex); 1587 + 1588 + if (fwe->loaded) { 1589 + at76_dbg(DBG_FW, "re-using previously loaded fw"); 1590 + goto exit; 1591 + } 1592 + 1593 + at76_dbg(DBG_FW, "downloading firmware %s", fwe->fwname); 1594 + ret = request_firmware(&fwe->fw, fwe->fwname, &udev->dev); 1595 + if (ret < 0) { 1596 + dev_printk(KERN_ERR, &udev->dev, "firmware %s not found!\n", 1597 + fwe->fwname); 1598 + dev_printk(KERN_ERR, &udev->dev, 1599 + "you may need to download the firmware from " 1600 + "http://developer.berlios.de/projects/at76c503a/\n"); 1601 + goto exit; 1602 + } 1603 + 1604 + at76_dbg(DBG_FW, "got it."); 1605 + fwh = (struct at76_fw_header *)(fwe->fw->data); 1606 + 1607 + if (fwe->fw->size <= sizeof(*fwh)) { 1608 + dev_printk(KERN_ERR, &udev->dev, 1609 + "firmware is too short (0x%zx)\n", fwe->fw->size); 1610 + goto exit; 1611 + } 1612 + 1613 + /* CRC currently not checked */ 1614 + fwe->board_type = le32_to_cpu(fwh->board_type); 1615 + if (fwe->board_type != board_type) { 1616 + dev_printk(KERN_ERR, &udev->dev, 1617 + "board type mismatch, requested %u, got %u\n", 1618 + board_type, fwe->board_type); 1619 + goto exit; 1620 + } 1621 + 1622 + fwe->fw_version.major = fwh->major; 1623 + fwe->fw_version.minor = fwh->minor; 1624 + fwe->fw_version.patch = fwh->patch; 1625 + fwe->fw_version.build = fwh->build; 1626 + 1627 + str = (char *)fwh + le32_to_cpu(fwh->str_offset); 1628 + fwe->intfw = (u8 *)fwh + le32_to_cpu(fwh->int_fw_offset); 1629 + fwe->intfw_size = le32_to_cpu(fwh->int_fw_len); 1630 + fwe->extfw = (u8 *)fwh + le32_to_cpu(fwh->ext_fw_offset); 1631 + fwe->extfw_size = le32_to_cpu(fwh->ext_fw_len); 1632 + 1633 + fwe->loaded = 1; 1634 + 1635 + dev_printk(KERN_DEBUG, &udev->dev, 1636 + "using firmware %s (version %d.%d.%d-%d)\n", 1637 + fwe->fwname, fwh->major, fwh->minor, fwh->patch, fwh->build); 1638 + 1639 + at76_dbg(DBG_DEVSTART, "board %u, int %d:%d, ext %d:%d", board_type, 1640 + le32_to_cpu(fwh->int_fw_offset), le32_to_cpu(fwh->int_fw_len), 1641 + le32_to_cpu(fwh->ext_fw_offset), le32_to_cpu(fwh->ext_fw_len)); 1642 + at76_dbg(DBG_DEVSTART, "firmware id %s", str); 1643 + 1644 + exit: 1645 + mutex_unlock(&fw_mutex); 1646 + 1647 + if (fwe->loaded) 1648 + return fwe; 1649 + else 1650 + return NULL; 1651 + } 1652 + 1653 + static void at76_mac80211_tx_callback(struct urb *urb) 1654 + { 1655 + struct at76_priv *priv = urb->context; 1656 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(priv->tx_skb); 1657 + 1658 + at76_dbg(DBG_MAC80211, "%s()", __func__); 1659 + 1660 + switch (urb->status) { 1661 + case 0: 1662 + /* success */ 1663 + info->flags |= IEEE80211_TX_STAT_ACK; 1664 + break; 1665 + case -ENOENT: 1666 + case -ECONNRESET: 1667 + /* fail, urb has been unlinked */ 1668 + /* FIXME: add error message */ 1669 + break; 1670 + default: 1671 + at76_dbg(DBG_URB, "%s - nonzero tx status received: %d", 1672 + __func__, urb->status); 1673 + break; 1674 + } 1675 + 1676 + memset(&info->status, 0, sizeof(info->status)); 1677 + 1678 + ieee80211_tx_status_irqsafe(priv->hw, priv->tx_skb); 1679 + 1680 + priv->tx_skb = NULL; 1681 + 1682 + ieee80211_wake_queues(priv->hw); 1683 + } 1684 + 1685 + static int at76_mac80211_tx(struct ieee80211_hw *hw, struct sk_buff *skb) 1686 + { 1687 + struct at76_priv *priv = hw->priv; 1688 + struct at76_tx_buffer *tx_buffer = priv->bulk_out_buffer; 1689 + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); 1690 + int padding, submit_len, ret; 1691 + 1692 + at76_dbg(DBG_MAC80211, "%s()", __func__); 1693 + 1694 + if (priv->tx_urb->status == -EINPROGRESS) { 1695 + printk(KERN_ERR "%s: %s called while tx urb is pending\n", 1696 + wiphy_name(priv->hw->wiphy), __func__); 1697 + return NETDEV_TX_BUSY; 1698 + } 1699 + 1700 + ieee80211_stop_queues(hw); 1701 + 1702 + at76_ledtrig_tx_activity(); /* tell ledtrigger we send a packet */ 1703 + 1704 + WARN_ON(priv->tx_skb != NULL); 1705 + 1706 + priv->tx_skb = skb; 1707 + padding = at76_calc_padding(skb->len); 1708 + submit_len = AT76_TX_HDRLEN + skb->len + padding; 1709 + 1710 + /* setup 'Atmel' header */ 1711 + memset(tx_buffer, 0, sizeof(*tx_buffer)); 1712 + tx_buffer->padding = padding; 1713 + tx_buffer->wlength = cpu_to_le16(skb->len); 1714 + tx_buffer->tx_rate = ieee80211_get_tx_rate(hw, info)->hw_value; 1715 + memset(tx_buffer->reserved, 0, sizeof(tx_buffer->reserved)); 1716 + memcpy(tx_buffer->packet, skb->data, skb->len); 1717 + 1718 + at76_dbg(DBG_TX_DATA, "%s tx: wlen 0x%x pad 0x%x rate %d hdr", 1719 + wiphy_name(priv->hw->wiphy), le16_to_cpu(tx_buffer->wlength), 1720 + tx_buffer->padding, tx_buffer->tx_rate); 1721 + 1722 + /* send stuff */ 1723 + at76_dbg_dump(DBG_TX_DATA_CONTENT, tx_buffer, submit_len, 1724 + "%s(): tx_buffer %d bytes:", __func__, submit_len); 1725 + usb_fill_bulk_urb(priv->tx_urb, priv->udev, priv->tx_pipe, tx_buffer, 1726 + submit_len, at76_mac80211_tx_callback, priv); 1727 + ret = usb_submit_urb(priv->tx_urb, GFP_ATOMIC); 1728 + if (ret) { 1729 + printk(KERN_ERR "%s: error in tx submit urb: %d\n", 1730 + wiphy_name(priv->hw->wiphy), ret); 1731 + if (ret == -EINVAL) 1732 + printk(KERN_ERR 1733 + "%s: -EINVAL: tx urb %p hcpriv %p complete %p\n", 1734 + wiphy_name(priv->hw->wiphy), priv->tx_urb, 1735 + priv->tx_urb->hcpriv, priv->tx_urb->complete); 1736 + } 1737 + 1738 + return 0; 1739 + } 1740 + 1741 + static int at76_mac80211_start(struct ieee80211_hw *hw) 1742 + { 1743 + struct at76_priv *priv = hw->priv; 1744 + int ret; 1745 + 1746 + at76_dbg(DBG_MAC80211, "%s()", __func__); 1747 + 1748 + mutex_lock(&priv->mtx); 1749 + 1750 + ret = at76_submit_rx_urb(priv); 1751 + if (ret < 0) { 1752 + printk(KERN_ERR "%s: open: submit_rx_urb failed: %d\n", 1753 + wiphy_name(priv->hw->wiphy), ret); 1754 + goto error; 1755 + } 1756 + 1757 + at76_startup_device(priv); 1758 + 1759 + at76_start_monitor(priv); 1760 + 1761 + error: 1762 + mutex_unlock(&priv->mtx); 1763 + 1764 + return 0; 1765 + } 1766 + 1767 + static void at76_mac80211_stop(struct ieee80211_hw *hw) 1768 + { 1769 + struct at76_priv *priv = hw->priv; 1770 + 1771 + at76_dbg(DBG_MAC80211, "%s()", __func__); 1772 + 1773 + mutex_lock(&priv->mtx); 1774 + 1775 + if (!priv->device_unplugged) { 1776 + /* We are called by "ifconfig ethX down", not because the 1777 + * device is not available anymore. */ 1778 + at76_set_radio(priv, 0); 1779 + 1780 + /* We unlink rx_urb because at76_open() re-submits it. 1781 + * If unplugged, at76_delete_device() takes care of it. */ 1782 + usb_kill_urb(priv->rx_urb); 1783 + } 1784 + 1785 + mutex_unlock(&priv->mtx); 1786 + } 1787 + 1788 + static int at76_add_interface(struct ieee80211_hw *hw, 1789 + struct ieee80211_if_init_conf *conf) 1790 + { 1791 + struct at76_priv *priv = hw->priv; 1792 + int ret = 0; 1793 + 1794 + at76_dbg(DBG_MAC80211, "%s()", __func__); 1795 + 1796 + mutex_lock(&priv->mtx); 1797 + 1798 + switch (conf->type) { 1799 + case NL80211_IFTYPE_STATION: 1800 + priv->iw_mode = IW_MODE_INFRA; 1801 + break; 1802 + default: 1803 + ret = -EOPNOTSUPP; 1804 + goto exit; 1805 + } 1806 + 1807 + exit: 1808 + mutex_unlock(&priv->mtx); 1809 + 1810 + return ret; 1811 + } 1812 + 1813 + static void at76_remove_interface(struct ieee80211_hw *hw, 1814 + struct ieee80211_if_init_conf *conf) 1815 + { 1816 + at76_dbg(DBG_MAC80211, "%s()", __func__); 1817 + } 1818 + 1819 + static int at76_join(struct at76_priv *priv) 1820 + { 1821 + struct at76_req_join join; 1822 + int ret; 1823 + 1824 + memset(&join, 0, sizeof(struct at76_req_join)); 1825 + memcpy(join.essid, priv->essid, priv->essid_size); 1826 + join.essid_size = priv->essid_size; 1827 + memcpy(join.bssid, priv->bssid, ETH_ALEN); 1828 + join.bss_type = INFRASTRUCTURE_MODE; 1829 + join.channel = priv->channel; 1830 + join.timeout = cpu_to_le16(2000); 1831 + 1832 + at76_dbg(DBG_MAC80211, "%s: sending CMD_JOIN", __func__); 1833 + ret = at76_set_card_command(priv->udev, CMD_JOIN, &join, 1834 + sizeof(struct at76_req_join)); 1835 + 1836 + if (ret < 0) { 1837 + printk(KERN_ERR "%s: at76_set_card_command failed: %d\n", 1838 + wiphy_name(priv->hw->wiphy), ret); 1839 + return 0; 1840 + } 1841 + 1842 + ret = at76_wait_completion(priv, CMD_JOIN); 1843 + at76_dbg(DBG_MAC80211, "%s: CMD_JOIN returned: 0x%02x", __func__, ret); 1844 + if (ret != CMD_STATUS_COMPLETE) { 1845 + printk(KERN_ERR "%s: at76_wait_completion failed: %d\n", 1846 + wiphy_name(priv->hw->wiphy), ret); 1847 + return 0; 1848 + } 1849 + 1850 + at76_set_pm_mode(priv); 1851 + 1852 + return 0; 1853 + } 1854 + 1855 + static void at76_dwork_hw_scan(struct work_struct *work) 1856 + { 1857 + struct at76_priv *priv = container_of(work, struct at76_priv, 1858 + dwork_hw_scan.work); 1859 + int ret; 1860 + 1861 + if (priv->device_unplugged) 1862 + return; 1863 + 1864 + mutex_lock(&priv->mtx); 1865 + 1866 + ret = at76_get_cmd_status(priv->udev, CMD_SCAN); 1867 + at76_dbg(DBG_MAC80211, "%s: CMD_SCAN status 0x%02x", __func__, ret); 1868 + 1869 + /* FIXME: add maximum time for scan to complete */ 1870 + 1871 + if (ret != CMD_STATUS_COMPLETE) { 1872 + queue_delayed_work(priv->hw->workqueue, &priv->dwork_hw_scan, 1873 + SCAN_POLL_INTERVAL); 1874 + goto exit; 1875 + } 1876 + 1877 + ieee80211_scan_completed(priv->hw, false); 1878 + 1879 + if (is_valid_ether_addr(priv->bssid)) 1880 + at76_join(priv); 1881 + 1882 + ieee80211_wake_queues(priv->hw); 1883 + 1884 + exit: 1885 + mutex_unlock(&priv->mtx); 1886 + } 1887 + 1888 + static int at76_hw_scan(struct ieee80211_hw *hw, 1889 + struct cfg80211_scan_request *req) 1890 + { 1891 + struct at76_priv *priv = hw->priv; 1892 + struct at76_req_scan scan; 1893 + u8 *ssid = NULL; 1894 + int ret, len = 0; 1895 + 1896 + at76_dbg(DBG_MAC80211, "%s():", __func__); 1897 + 1898 + if (priv->device_unplugged) 1899 + return 0; 1900 + 1901 + mutex_lock(&priv->mtx); 1902 + 1903 + ieee80211_stop_queues(hw); 1904 + 1905 + memset(&scan, 0, sizeof(struct at76_req_scan)); 1906 + memset(scan.bssid, 0xFF, ETH_ALEN); 1907 + 1908 + if (req->n_ssids) { 1909 + scan.scan_type = SCAN_TYPE_ACTIVE; 1910 + ssid = req->ssids[0].ssid; 1911 + len = req->ssids[0].ssid_len; 1912 + } else { 1913 + scan.scan_type = SCAN_TYPE_PASSIVE; 1914 + } 1915 + 1916 + if (len) { 1917 + memcpy(scan.essid, ssid, len); 1918 + scan.essid_size = len; 1919 + } 1920 + 1921 + scan.min_channel_time = cpu_to_le16(priv->scan_min_time); 1922 + scan.max_channel_time = cpu_to_le16(priv->scan_max_time); 1923 + scan.probe_delay = cpu_to_le16(priv->scan_min_time * 1000); 1924 + scan.international_scan = 0; 1925 + 1926 + at76_dbg(DBG_MAC80211, "%s: sending CMD_SCAN", __func__); 1927 + ret = at76_set_card_command(priv->udev, CMD_SCAN, &scan, sizeof(scan)); 1928 + 1929 + if (ret < 0) { 1930 + err("CMD_SCAN failed: %d", ret); 1931 + goto exit; 1932 + } 1933 + 1934 + queue_delayed_work(priv->hw->workqueue, &priv->dwork_hw_scan, 1935 + SCAN_POLL_INTERVAL); 1936 + 1937 + exit: 1938 + mutex_unlock(&priv->mtx); 1939 + 1940 + return 0; 1941 + } 1942 + 1943 + static int at76_config(struct ieee80211_hw *hw, u32 changed) 1944 + { 1945 + struct at76_priv *priv = hw->priv; 1946 + 1947 + at76_dbg(DBG_MAC80211, "%s(): channel %d radio %d", 1948 + __func__, hw->conf.channel->hw_value, 1949 + hw->conf.radio_enabled); 1950 + at76_dbg_dump(DBG_MAC80211, priv->bssid, ETH_ALEN, "bssid:"); 1951 + 1952 + mutex_lock(&priv->mtx); 1953 + 1954 + priv->channel = hw->conf.channel->hw_value; 1955 + 1956 + if (is_valid_ether_addr(priv->bssid)) 1957 + at76_join(priv); 1958 + else 1959 + at76_start_monitor(priv); 1960 + 1961 + mutex_unlock(&priv->mtx); 1962 + 1963 + return 0; 1964 + } 1965 + 1966 + static int at76_config_interface(struct ieee80211_hw *hw, 1967 + struct ieee80211_vif *vif, 1968 + struct ieee80211_if_conf *conf) 1969 + { 1970 + struct at76_priv *priv = hw->priv; 1971 + 1972 + at76_dbg(DBG_MAC80211, "%s():", __func__); 1973 + at76_dbg_dump(DBG_MAC80211, conf->bssid, ETH_ALEN, "bssid:"); 1974 + 1975 + mutex_lock(&priv->mtx); 1976 + 1977 + memcpy(priv->bssid, conf->bssid, ETH_ALEN); 1978 + 1979 + if (is_valid_ether_addr(priv->bssid)) 1980 + /* mac80211 is joining a bss */ 1981 + at76_join(priv); 1982 + 1983 + mutex_unlock(&priv->mtx); 1984 + 1985 + return 0; 1986 + } 1987 + 1988 + /* must be atomic */ 1989 + static void at76_configure_filter(struct ieee80211_hw *hw, 1990 + unsigned int changed_flags, 1991 + unsigned int *total_flags, int mc_count, 1992 + struct dev_addr_list *mc_list) 1993 + { 1994 + struct at76_priv *priv = hw->priv; 1995 + int flags; 1996 + 1997 + at76_dbg(DBG_MAC80211, "%s(): changed_flags=0x%08x " 1998 + "total_flags=0x%08x mc_count=%d", 1999 + __func__, changed_flags, *total_flags, mc_count); 2000 + 2001 + flags = changed_flags & AT76_SUPPORTED_FILTERS; 2002 + *total_flags = AT76_SUPPORTED_FILTERS; 2003 + 2004 + /* Bail out after updating flags to prevent a WARN_ON in mac80211. */ 2005 + if (priv->device_unplugged) 2006 + return; 2007 + 2008 + /* FIXME: access to priv->promisc should be protected with 2009 + * priv->mtx, but it's impossible because this function needs to be 2010 + * atomic */ 2011 + 2012 + if (flags && !priv->promisc) { 2013 + /* mac80211 wants us to enable promiscuous mode */ 2014 + priv->promisc = 1; 2015 + } else if (!flags && priv->promisc) { 2016 + /* we need to disable promiscuous mode */ 2017 + priv->promisc = 0; 2018 + } else 2019 + return; 2020 + 2021 + queue_work(hw->workqueue, &priv->work_set_promisc); 2022 + } 2023 + 2024 + static int at76_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, 2025 + struct ieee80211_vif *vif, struct ieee80211_sta *sta, 2026 + struct ieee80211_key_conf *key) 2027 + { 2028 + struct at76_priv *priv = hw->priv; 2029 + 2030 + int i; 2031 + 2032 + at76_dbg(DBG_MAC80211, "%s(): cmd %d key->alg %d key->keyidx %d " 2033 + "key->keylen %d", 2034 + __func__, cmd, key->alg, key->keyidx, key->keylen); 2035 + 2036 + if (key->alg != ALG_WEP) 2037 + return -EOPNOTSUPP; 2038 + 2039 + key->hw_key_idx = key->keyidx; 2040 + 2041 + mutex_lock(&priv->mtx); 2042 + 2043 + switch (cmd) { 2044 + case SET_KEY: 2045 + memcpy(priv->wep_keys[key->keyidx], key->key, key->keylen); 2046 + priv->wep_keys_len[key->keyidx] = key->keylen; 2047 + 2048 + /* FIXME: find out how to do this properly */ 2049 + priv->wep_key_id = key->keyidx; 2050 + 2051 + break; 2052 + case DISABLE_KEY: 2053 + default: 2054 + priv->wep_keys_len[key->keyidx] = 0; 2055 + break; 2056 + } 2057 + 2058 + priv->wep_enabled = 0; 2059 + 2060 + for (i = 0; i < WEP_KEYS; i++) { 2061 + if (priv->wep_keys_len[i] != 0) 2062 + priv->wep_enabled = 1; 2063 + } 2064 + 2065 + at76_startup_device(priv); 2066 + 2067 + mutex_unlock(&priv->mtx); 2068 + 2069 + return 0; 2070 + } 2071 + 2072 + static const struct ieee80211_ops at76_ops = { 2073 + .tx = at76_mac80211_tx, 2074 + .add_interface = at76_add_interface, 2075 + .remove_interface = at76_remove_interface, 2076 + .config = at76_config, 2077 + .config_interface = at76_config_interface, 2078 + .configure_filter = at76_configure_filter, 2079 + .start = at76_mac80211_start, 2080 + .stop = at76_mac80211_stop, 2081 + .hw_scan = at76_hw_scan, 2082 + .set_key = at76_set_key, 2083 + }; 2084 + 2085 + /* Allocate network device and initialize private data */ 2086 + static struct at76_priv *at76_alloc_new_device(struct usb_device *udev) 2087 + { 2088 + struct ieee80211_hw *hw; 2089 + struct at76_priv *priv; 2090 + 2091 + hw = ieee80211_alloc_hw(sizeof(struct at76_priv), &at76_ops); 2092 + if (!hw) { 2093 + printk(KERN_ERR DRIVER_NAME ": could not register" 2094 + " ieee80211_hw\n"); 2095 + return NULL; 2096 + } 2097 + 2098 + priv = hw->priv; 2099 + priv->hw = hw; 2100 + 2101 + priv->udev = udev; 2102 + 2103 + mutex_init(&priv->mtx); 2104 + INIT_WORK(&priv->work_set_promisc, at76_work_set_promisc); 2105 + INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx); 2106 + INIT_DELAYED_WORK(&priv->dwork_hw_scan, at76_dwork_hw_scan); 2107 + 2108 + tasklet_init(&priv->rx_tasklet, at76_rx_tasklet, 0); 2109 + 2110 + priv->pm_mode = AT76_PM_OFF; 2111 + priv->pm_period = 0; 2112 + 2113 + /* unit us */ 2114 + priv->hw->channel_change_time = 100000; 2115 + 2116 + return priv; 2117 + } 2118 + 2119 + static int at76_alloc_urbs(struct at76_priv *priv, 2120 + struct usb_interface *interface) 2121 + { 2122 + struct usb_endpoint_descriptor *endpoint, *ep_in, *ep_out; 2123 + int i; 2124 + int buffer_size; 2125 + struct usb_host_interface *iface_desc; 2126 + 2127 + at76_dbg(DBG_PROC_ENTRY, "%s: ENTER", __func__); 2128 + 2129 + at76_dbg(DBG_URB, "%s: NumEndpoints %d ", __func__, 2130 + interface->altsetting[0].desc.bNumEndpoints); 2131 + 2132 + ep_in = NULL; 2133 + ep_out = NULL; 2134 + iface_desc = interface->cur_altsetting; 2135 + for (i = 0; i < iface_desc->desc.bNumEndpoints; i++) { 2136 + endpoint = &iface_desc->endpoint[i].desc; 2137 + 2138 + at76_dbg(DBG_URB, "%s: %d. endpoint: addr 0x%x attr 0x%x", 2139 + __func__, i, endpoint->bEndpointAddress, 2140 + endpoint->bmAttributes); 2141 + 2142 + if (!ep_in && usb_endpoint_is_bulk_in(endpoint)) 2143 + ep_in = endpoint; 2144 + 2145 + if (!ep_out && usb_endpoint_is_bulk_out(endpoint)) 2146 + ep_out = endpoint; 2147 + } 2148 + 2149 + if (!ep_in || !ep_out) { 2150 + dev_printk(KERN_ERR, &interface->dev, 2151 + "bulk endpoints missing\n"); 2152 + return -ENXIO; 2153 + } 2154 + 2155 + priv->rx_pipe = usb_rcvbulkpipe(priv->udev, ep_in->bEndpointAddress); 2156 + priv->tx_pipe = usb_sndbulkpipe(priv->udev, ep_out->bEndpointAddress); 2157 + 2158 + priv->rx_urb = usb_alloc_urb(0, GFP_KERNEL); 2159 + priv->tx_urb = usb_alloc_urb(0, GFP_KERNEL); 2160 + if (!priv->rx_urb || !priv->tx_urb) { 2161 + dev_printk(KERN_ERR, &interface->dev, "cannot allocate URB\n"); 2162 + return -ENOMEM; 2163 + } 2164 + 2165 + buffer_size = sizeof(struct at76_tx_buffer) + MAX_PADDING_SIZE; 2166 + priv->bulk_out_buffer = kmalloc(buffer_size, GFP_KERNEL); 2167 + if (!priv->bulk_out_buffer) { 2168 + dev_printk(KERN_ERR, &interface->dev, 2169 + "cannot allocate output buffer\n"); 2170 + return -ENOMEM; 2171 + } 2172 + 2173 + at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__); 2174 + 2175 + return 0; 2176 + } 2177 + 2178 + static struct ieee80211_rate at76_rates[] = { 2179 + { .bitrate = 10, .hw_value = TX_RATE_1MBIT, }, 2180 + { .bitrate = 20, .hw_value = TX_RATE_2MBIT, }, 2181 + { .bitrate = 55, .hw_value = TX_RATE_5_5MBIT, }, 2182 + { .bitrate = 110, .hw_value = TX_RATE_11MBIT, }, 2183 + }; 2184 + 2185 + static struct ieee80211_channel at76_channels[] = { 2186 + { .center_freq = 2412, .hw_value = 1 }, 2187 + { .center_freq = 2417, .hw_value = 2 }, 2188 + { .center_freq = 2422, .hw_value = 3 }, 2189 + { .center_freq = 2427, .hw_value = 4 }, 2190 + { .center_freq = 2432, .hw_value = 5 }, 2191 + { .center_freq = 2437, .hw_value = 6 }, 2192 + { .center_freq = 2442, .hw_value = 7 }, 2193 + { .center_freq = 2447, .hw_value = 8 }, 2194 + { .center_freq = 2452, .hw_value = 9 }, 2195 + { .center_freq = 2457, .hw_value = 10 }, 2196 + { .center_freq = 2462, .hw_value = 11 }, 2197 + { .center_freq = 2467, .hw_value = 12 }, 2198 + { .center_freq = 2472, .hw_value = 13 }, 2199 + { .center_freq = 2484, .hw_value = 14 } 2200 + }; 2201 + 2202 + static struct ieee80211_supported_band at76_supported_band = { 2203 + .channels = at76_channels, 2204 + .n_channels = ARRAY_SIZE(at76_channels), 2205 + .bitrates = at76_rates, 2206 + .n_bitrates = ARRAY_SIZE(at76_rates), 2207 + }; 2208 + 2209 + /* Register network device and initialize the hardware */ 2210 + static int at76_init_new_device(struct at76_priv *priv, 2211 + struct usb_interface *interface) 2212 + { 2213 + int ret; 2214 + 2215 + /* set up the endpoint information */ 2216 + /* check out the endpoints */ 2217 + 2218 + at76_dbg(DBG_DEVSTART, "USB interface: %d endpoints", 2219 + interface->cur_altsetting->desc.bNumEndpoints); 2220 + 2221 + ret = at76_alloc_urbs(priv, interface); 2222 + if (ret < 0) 2223 + goto exit; 2224 + 2225 + /* MAC address */ 2226 + ret = at76_get_hw_config(priv); 2227 + if (ret < 0) { 2228 + dev_printk(KERN_ERR, &interface->dev, 2229 + "cannot get MAC address\n"); 2230 + goto exit; 2231 + } 2232 + 2233 + priv->domain = at76_get_reg_domain(priv->regulatory_domain); 2234 + 2235 + priv->channel = DEF_CHANNEL; 2236 + priv->iw_mode = IW_MODE_INFRA; 2237 + priv->rts_threshold = DEF_RTS_THRESHOLD; 2238 + priv->frag_threshold = DEF_FRAG_THRESHOLD; 2239 + priv->short_retry_limit = DEF_SHORT_RETRY_LIMIT; 2240 + priv->txrate = TX_RATE_AUTO; 2241 + priv->preamble_type = PREAMBLE_TYPE_LONG; 2242 + priv->beacon_period = 100; 2243 + priv->auth_mode = WLAN_AUTH_OPEN; 2244 + priv->scan_min_time = DEF_SCAN_MIN_TIME; 2245 + priv->scan_max_time = DEF_SCAN_MAX_TIME; 2246 + priv->scan_mode = SCAN_TYPE_ACTIVE; 2247 + priv->device_unplugged = 0; 2248 + 2249 + /* mac80211 initialisation */ 2250 + priv->hw->wiphy->max_scan_ssids = 1; 2251 + priv->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); 2252 + priv->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &at76_supported_band; 2253 + priv->hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 2254 + IEEE80211_HW_SIGNAL_UNSPEC; 2255 + priv->hw->max_signal = 100; 2256 + 2257 + SET_IEEE80211_DEV(priv->hw, &interface->dev); 2258 + SET_IEEE80211_PERM_ADDR(priv->hw, priv->mac_addr); 2259 + 2260 + ret = ieee80211_register_hw(priv->hw); 2261 + if (ret) { 2262 + printk(KERN_ERR "cannot register mac80211 hw (status %d)!\n", 2263 + ret); 2264 + goto exit; 2265 + } 2266 + 2267 + priv->mac80211_registered = 1; 2268 + 2269 + printk(KERN_INFO "%s: USB %s, MAC %s, firmware %d.%d.%d-%d\n", 2270 + wiphy_name(priv->hw->wiphy), 2271 + dev_name(&interface->dev), mac2str(priv->mac_addr), 2272 + priv->fw_version.major, priv->fw_version.minor, 2273 + priv->fw_version.patch, priv->fw_version.build); 2274 + printk(KERN_INFO "%s: regulatory domain 0x%02x: %s\n", 2275 + wiphy_name(priv->hw->wiphy), 2276 + priv->regulatory_domain, priv->domain->name); 2277 + 2278 + exit: 2279 + return ret; 2280 + } 2281 + 2282 + static void at76_delete_device(struct at76_priv *priv) 2283 + { 2284 + at76_dbg(DBG_PROC_ENTRY, "%s: ENTER", __func__); 2285 + 2286 + /* The device is gone, don't bother turning it off */ 2287 + priv->device_unplugged = 1; 2288 + 2289 + tasklet_kill(&priv->rx_tasklet); 2290 + 2291 + if (priv->mac80211_registered) { 2292 + cancel_delayed_work(&priv->dwork_hw_scan); 2293 + flush_workqueue(priv->hw->workqueue); 2294 + ieee80211_unregister_hw(priv->hw); 2295 + } 2296 + 2297 + if (priv->tx_urb) { 2298 + usb_kill_urb(priv->tx_urb); 2299 + usb_free_urb(priv->tx_urb); 2300 + } 2301 + if (priv->rx_urb) { 2302 + usb_kill_urb(priv->rx_urb); 2303 + usb_free_urb(priv->rx_urb); 2304 + } 2305 + 2306 + at76_dbg(DBG_PROC_ENTRY, "%s: unlinked urbs", __func__); 2307 + 2308 + kfree(priv->bulk_out_buffer); 2309 + 2310 + del_timer_sync(&ledtrig_tx_timer); 2311 + 2312 + if (priv->rx_skb) 2313 + kfree_skb(priv->rx_skb); 2314 + 2315 + usb_put_dev(priv->udev); 2316 + 2317 + at76_dbg(DBG_PROC_ENTRY, "%s: before freeing priv/ieee80211_hw", 2318 + __func__); 2319 + ieee80211_free_hw(priv->hw); 2320 + 2321 + at76_dbg(DBG_PROC_ENTRY, "%s: EXIT", __func__); 2322 + } 2323 + 2324 + static int at76_probe(struct usb_interface *interface, 2325 + const struct usb_device_id *id) 2326 + { 2327 + int ret; 2328 + struct at76_priv *priv; 2329 + struct fwentry *fwe; 2330 + struct usb_device *udev; 2331 + int op_mode; 2332 + int need_ext_fw = 0; 2333 + struct mib_fw_version fwv; 2334 + int board_type = (int)id->driver_info; 2335 + 2336 + udev = usb_get_dev(interface_to_usbdev(interface)); 2337 + 2338 + /* Load firmware into kernel memory */ 2339 + fwe = at76_load_firmware(udev, board_type); 2340 + if (!fwe) { 2341 + ret = -ENOENT; 2342 + goto error; 2343 + } 2344 + 2345 + op_mode = at76_get_op_mode(udev); 2346 + 2347 + at76_dbg(DBG_DEVSTART, "opmode %d", op_mode); 2348 + 2349 + /* we get OPMODE_NONE with 2.4.23, SMC2662W-AR ??? 2350 + we get 204 with 2.4.23, Fiberline FL-WL240u (505A+RFMD2958) ??? */ 2351 + 2352 + if (op_mode == OPMODE_HW_CONFIG_MODE) { 2353 + dev_printk(KERN_ERR, &interface->dev, 2354 + "cannot handle a device in HW_CONFIG_MODE\n"); 2355 + ret = -EBUSY; 2356 + goto error; 2357 + } 2358 + 2359 + if (op_mode != OPMODE_NORMAL_NIC_WITH_FLASH 2360 + && op_mode != OPMODE_NORMAL_NIC_WITHOUT_FLASH) { 2361 + /* download internal firmware part */ 2362 + dev_printk(KERN_DEBUG, &interface->dev, 2363 + "downloading internal firmware\n"); 2364 + ret = at76_load_internal_fw(udev, fwe); 2365 + if (ret < 0) { 2366 + dev_printk(KERN_ERR, &interface->dev, 2367 + "error %d downloading internal firmware\n", 2368 + ret); 2369 + goto error; 2370 + } 2371 + usb_put_dev(udev); 2372 + return ret; 2373 + } 2374 + 2375 + /* Internal firmware already inside the device. Get firmware 2376 + * version to test if external firmware is loaded. 2377 + * This works only for newer firmware, e.g. the Intersil 0.90.x 2378 + * says "control timeout on ep0in" and subsequent 2379 + * at76_get_op_mode() fail too :-( */ 2380 + 2381 + /* if version >= 0.100.x.y or device with built-in flash we can 2382 + * query the device for the fw version */ 2383 + if ((fwe->fw_version.major > 0 || fwe->fw_version.minor >= 100) 2384 + || (op_mode == OPMODE_NORMAL_NIC_WITH_FLASH)) { 2385 + ret = at76_get_mib(udev, MIB_FW_VERSION, &fwv, sizeof(fwv)); 2386 + if (ret < 0 || (fwv.major | fwv.minor) == 0) 2387 + need_ext_fw = 1; 2388 + } else 2389 + /* No way to check firmware version, reload to be sure */ 2390 + need_ext_fw = 1; 2391 + 2392 + if (need_ext_fw) { 2393 + dev_printk(KERN_DEBUG, &interface->dev, 2394 + "downloading external firmware\n"); 2395 + 2396 + ret = at76_load_external_fw(udev, fwe); 2397 + if (ret) 2398 + goto error; 2399 + 2400 + /* Re-check firmware version */ 2401 + ret = at76_get_mib(udev, MIB_FW_VERSION, &fwv, sizeof(fwv)); 2402 + if (ret < 0) { 2403 + dev_printk(KERN_ERR, &interface->dev, 2404 + "error %d getting firmware version\n", ret); 2405 + goto error; 2406 + } 2407 + } 2408 + 2409 + priv = at76_alloc_new_device(udev); 2410 + if (!priv) { 2411 + ret = -ENOMEM; 2412 + goto error; 2413 + } 2414 + 2415 + usb_set_intfdata(interface, priv); 2416 + 2417 + memcpy(&priv->fw_version, &fwv, sizeof(struct mib_fw_version)); 2418 + priv->board_type = board_type; 2419 + 2420 + ret = at76_init_new_device(priv, interface); 2421 + if (ret < 0) 2422 + at76_delete_device(priv); 2423 + 2424 + return ret; 2425 + 2426 + error: 2427 + usb_put_dev(udev); 2428 + return ret; 2429 + } 2430 + 2431 + static void at76_disconnect(struct usb_interface *interface) 2432 + { 2433 + struct at76_priv *priv; 2434 + 2435 + priv = usb_get_intfdata(interface); 2436 + usb_set_intfdata(interface, NULL); 2437 + 2438 + /* Disconnect after loading internal firmware */ 2439 + if (!priv) 2440 + return; 2441 + 2442 + printk(KERN_INFO "%s: disconnecting\n", wiphy_name(priv->hw->wiphy)); 2443 + at76_delete_device(priv); 2444 + dev_printk(KERN_INFO, &interface->dev, "disconnected\n"); 2445 + } 2446 + 2447 + /* Structure for registering this driver with the USB subsystem */ 2448 + static struct usb_driver at76_driver = { 2449 + .name = DRIVER_NAME, 2450 + .probe = at76_probe, 2451 + .disconnect = at76_disconnect, 2452 + .id_table = dev_table, 2453 + }; 2454 + 2455 + static int __init at76_mod_init(void) 2456 + { 2457 + int result; 2458 + 2459 + printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION " loading\n"); 2460 + 2461 + mutex_init(&fw_mutex); 2462 + 2463 + /* register this driver with the USB subsystem */ 2464 + result = usb_register(&at76_driver); 2465 + if (result < 0) 2466 + printk(KERN_ERR DRIVER_NAME 2467 + ": usb_register failed (status %d)\n", result); 2468 + 2469 + led_trigger_register_simple("at76_usb-tx", &ledtrig_tx); 2470 + return result; 2471 + } 2472 + 2473 + static void __exit at76_mod_exit(void) 2474 + { 2475 + int i; 2476 + 2477 + printk(KERN_INFO DRIVER_DESC " " DRIVER_VERSION " unloading\n"); 2478 + usb_deregister(&at76_driver); 2479 + for (i = 0; i < ARRAY_SIZE(firmwares); i++) { 2480 + if (firmwares[i].fw) 2481 + release_firmware(firmwares[i].fw); 2482 + } 2483 + led_trigger_unregister_simple(ledtrig_tx); 2484 + } 2485 + 2486 + module_param_named(debug, at76_debug, uint, 0600); 2487 + MODULE_PARM_DESC(debug, "Debugging level"); 2488 + 2489 + module_init(at76_mod_init); 2490 + module_exit(at76_mod_exit); 2491 + 2492 + MODULE_AUTHOR("Oliver Kurth <oku@masqmail.cx>"); 2493 + MODULE_AUTHOR("Joerg Albert <joerg.albert@gmx.de>"); 2494 + MODULE_AUTHOR("Alex <alex@foogod.com>"); 2495 + MODULE_AUTHOR("Nick Jones"); 2496 + MODULE_AUTHOR("Balint Seeber <n0_5p4m_p13453@hotmail.com>"); 2497 + MODULE_AUTHOR("Pavel Roskin <proski@gnu.org>"); 2498 + MODULE_AUTHOR("Guido Guenther <agx@sigxcpu.org>"); 2499 + MODULE_AUTHOR("Kalle Valo <kalle.valo@iki.fi>"); 2500 + MODULE_DESCRIPTION(DRIVER_DESC); 2501 + MODULE_LICENSE("GPL");
+463
drivers/net/wireless/at76c50x-usb.h
··· 1 + /* 2 + * Copyright (c) 2002,2003 Oliver Kurth 3 + * (c) 2003,2004 Joerg Albert <joerg.albert@gmx.de> 4 + * (c) 2007 Guido Guenther <agx@sigxcpu.org> 5 + * 6 + * This program is free software; you can redistribute it and/or 7 + * modify it under the terms of the GNU General Public License as 8 + * published by the Free Software Foundation; either version 2 of 9 + * the License, or (at your option) any later version. 10 + * 11 + * This driver was based on information from the Sourceforge driver 12 + * released and maintained by Atmel: 13 + * 14 + * http://sourceforge.net/projects/atmelwlandriver/ 15 + * 16 + * Although the code was completely re-written, 17 + * it would have been impossible without Atmel's decision to 18 + * release an Open Source driver (unfortunately the firmware was 19 + * kept binary only). Thanks for that decision to Atmel! 20 + */ 21 + 22 + #ifndef _AT76_USB_H 23 + #define _AT76_USB_H 24 + 25 + /* Board types */ 26 + enum board_type { 27 + BOARD_503_ISL3861 = 1, 28 + BOARD_503_ISL3863 = 2, 29 + BOARD_503 = 3, 30 + BOARD_503_ACC = 4, 31 + BOARD_505 = 5, 32 + BOARD_505_2958 = 6, 33 + BOARD_505A = 7, 34 + BOARD_505AMX = 8 35 + }; 36 + 37 + #define CMD_STATUS_IDLE 0x00 38 + #define CMD_STATUS_COMPLETE 0x01 39 + #define CMD_STATUS_UNKNOWN 0x02 40 + #define CMD_STATUS_INVALID_PARAMETER 0x03 41 + #define CMD_STATUS_FUNCTION_NOT_SUPPORTED 0x04 42 + #define CMD_STATUS_TIME_OUT 0x07 43 + #define CMD_STATUS_IN_PROGRESS 0x08 44 + #define CMD_STATUS_HOST_FAILURE 0xff 45 + #define CMD_STATUS_SCAN_FAILED 0xf0 46 + 47 + /* answers to get op mode */ 48 + #define OPMODE_NONE 0x00 49 + #define OPMODE_NORMAL_NIC_WITH_FLASH 0x01 50 + #define OPMODE_HW_CONFIG_MODE 0x02 51 + #define OPMODE_DFU_MODE_WITH_FLASH 0x03 52 + #define OPMODE_NORMAL_NIC_WITHOUT_FLASH 0x04 53 + 54 + #define CMD_SET_MIB 0x01 55 + #define CMD_GET_MIB 0x02 56 + #define CMD_SCAN 0x03 57 + #define CMD_JOIN 0x04 58 + #define CMD_START_IBSS 0x05 59 + #define CMD_RADIO_ON 0x06 60 + #define CMD_RADIO_OFF 0x07 61 + #define CMD_STARTUP 0x0B 62 + 63 + #define MIB_LOCAL 0x01 64 + #define MIB_MAC_ADDR 0x02 65 + #define MIB_MAC 0x03 66 + #define MIB_MAC_MGMT 0x05 67 + #define MIB_MAC_WEP 0x06 68 + #define MIB_PHY 0x07 69 + #define MIB_FW_VERSION 0x08 70 + #define MIB_MDOMAIN 0x09 71 + 72 + #define ADHOC_MODE 1 73 + #define INFRASTRUCTURE_MODE 2 74 + 75 + /* values for struct mib_local, field preamble_type */ 76 + #define PREAMBLE_TYPE_LONG 0 77 + #define PREAMBLE_TYPE_SHORT 1 78 + #define PREAMBLE_TYPE_AUTO 2 79 + 80 + /* values for tx_rate */ 81 + #define TX_RATE_1MBIT 0 82 + #define TX_RATE_2MBIT 1 83 + #define TX_RATE_5_5MBIT 2 84 + #define TX_RATE_11MBIT 3 85 + #define TX_RATE_AUTO 4 86 + 87 + /* power management modes */ 88 + #define AT76_PM_OFF 1 89 + #define AT76_PM_ON 2 90 + #define AT76_PM_SMART 3 91 + 92 + struct hwcfg_r505 { 93 + u8 cr39_values[14]; 94 + u8 reserved1[14]; 95 + u8 bb_cr[14]; 96 + u8 pidvid[4]; 97 + u8 mac_addr[ETH_ALEN]; 98 + u8 regulatory_domain; 99 + u8 reserved2[14]; 100 + u8 cr15_values[14]; 101 + u8 reserved3[3]; 102 + } __attribute__((packed)); 103 + 104 + struct hwcfg_rfmd { 105 + u8 cr20_values[14]; 106 + u8 cr21_values[14]; 107 + u8 bb_cr[14]; 108 + u8 pidvid[4]; 109 + u8 mac_addr[ETH_ALEN]; 110 + u8 regulatory_domain; 111 + u8 low_power_values[14]; 112 + u8 normal_power_values[14]; 113 + u8 reserved1[3]; 114 + } __attribute__((packed)); 115 + 116 + struct hwcfg_intersil { 117 + u8 mac_addr[ETH_ALEN]; 118 + u8 cr31_values[14]; 119 + u8 cr58_values[14]; 120 + u8 pidvid[4]; 121 + u8 regulatory_domain; 122 + u8 reserved[1]; 123 + } __attribute__((packed)); 124 + 125 + union at76_hwcfg { 126 + struct hwcfg_intersil i; 127 + struct hwcfg_rfmd r3; 128 + struct hwcfg_r505 r5; 129 + }; 130 + 131 + #define WEP_SMALL_KEY_LEN (40 / 8) 132 + #define WEP_LARGE_KEY_LEN (104 / 8) 133 + #define WEP_KEYS (4) 134 + 135 + struct at76_card_config { 136 + u8 exclude_unencrypted; 137 + u8 promiscuous_mode; 138 + u8 short_retry_limit; 139 + u8 encryption_type; 140 + __le16 rts_threshold; 141 + __le16 fragmentation_threshold; /* 256..2346 */ 142 + u8 basic_rate_set[4]; 143 + u8 auto_rate_fallback; /* 0,1 */ 144 + u8 channel; 145 + u8 privacy_invoked; 146 + u8 wep_default_key_id; /* 0..3 */ 147 + u8 current_ssid[32]; 148 + u8 wep_default_key_value[4][WEP_LARGE_KEY_LEN]; 149 + u8 ssid_len; 150 + u8 short_preamble; 151 + __le16 beacon_period; 152 + } __attribute__((packed)); 153 + 154 + struct at76_command { 155 + u8 cmd; 156 + u8 reserved; 157 + __le16 size; 158 + u8 data[0]; 159 + } __attribute__((packed)); 160 + 161 + /* Length of Atmel-specific Rx header before 802.11 frame */ 162 + #define AT76_RX_HDRLEN offsetof(struct at76_rx_buffer, packet) 163 + 164 + struct at76_rx_buffer { 165 + __le16 wlength; 166 + u8 rx_rate; 167 + u8 newbss; 168 + u8 fragmentation; 169 + u8 rssi; 170 + u8 link_quality; 171 + u8 noise_level; 172 + __le32 rx_time; 173 + u8 packet[IEEE80211_MAX_FRAG_THRESHOLD]; 174 + } __attribute__((packed)); 175 + 176 + /* Length of Atmel-specific Tx header before 802.11 frame */ 177 + #define AT76_TX_HDRLEN offsetof(struct at76_tx_buffer, packet) 178 + 179 + struct at76_tx_buffer { 180 + __le16 wlength; 181 + u8 tx_rate; 182 + u8 padding; 183 + u8 reserved[4]; 184 + u8 packet[IEEE80211_MAX_FRAG_THRESHOLD]; 185 + } __attribute__((packed)); 186 + 187 + /* defines for scan_type below */ 188 + #define SCAN_TYPE_ACTIVE 0 189 + #define SCAN_TYPE_PASSIVE 1 190 + 191 + struct at76_req_scan { 192 + u8 bssid[ETH_ALEN]; 193 + u8 essid[32]; 194 + u8 scan_type; 195 + u8 channel; 196 + __le16 probe_delay; 197 + __le16 min_channel_time; 198 + __le16 max_channel_time; 199 + u8 essid_size; 200 + u8 international_scan; 201 + } __attribute__((packed)); 202 + 203 + struct at76_req_ibss { 204 + u8 bssid[ETH_ALEN]; 205 + u8 essid[32]; 206 + u8 bss_type; 207 + u8 channel; 208 + u8 essid_size; 209 + u8 reserved[3]; 210 + } __attribute__((packed)); 211 + 212 + struct at76_req_join { 213 + u8 bssid[ETH_ALEN]; 214 + u8 essid[32]; 215 + u8 bss_type; 216 + u8 channel; 217 + __le16 timeout; 218 + u8 essid_size; 219 + u8 reserved; 220 + } __attribute__((packed)); 221 + 222 + struct set_mib_buffer { 223 + u8 type; 224 + u8 size; 225 + u8 index; 226 + u8 reserved; 227 + union { 228 + u8 byte; 229 + __le16 word; 230 + u8 addr[ETH_ALEN]; 231 + } data; 232 + } __attribute__((packed)); 233 + 234 + struct mib_local { 235 + u16 reserved0; 236 + u8 beacon_enable; 237 + u8 txautorate_fallback; 238 + u8 reserved1; 239 + u8 ssid_size; 240 + u8 promiscuous_mode; 241 + u16 reserved2; 242 + u8 preamble_type; 243 + u16 reserved3; 244 + } __attribute__((packed)); 245 + 246 + struct mib_mac_addr { 247 + u8 mac_addr[ETH_ALEN]; 248 + u8 res[2]; /* ??? */ 249 + u8 group_addr[4][ETH_ALEN]; 250 + u8 group_addr_status[4]; 251 + } __attribute__((packed)); 252 + 253 + struct mib_mac { 254 + __le32 max_tx_msdu_lifetime; 255 + __le32 max_rx_lifetime; 256 + __le16 frag_threshold; 257 + __le16 rts_threshold; 258 + __le16 cwmin; 259 + __le16 cwmax; 260 + u8 short_retry_time; 261 + u8 long_retry_time; 262 + u8 scan_type; /* active or passive */ 263 + u8 scan_channel; 264 + __le16 probe_delay; /* delay before ProbeReq in active scan, RO */ 265 + __le16 min_channel_time; 266 + __le16 max_channel_time; 267 + __le16 listen_interval; 268 + u8 desired_ssid[32]; 269 + u8 desired_bssid[ETH_ALEN]; 270 + u8 desired_bsstype; /* ad-hoc or infrastructure */ 271 + u8 reserved2; 272 + } __attribute__((packed)); 273 + 274 + struct mib_mac_mgmt { 275 + __le16 beacon_period; 276 + __le16 CFP_max_duration; 277 + __le16 medium_occupancy_limit; 278 + __le16 station_id; /* assoc id */ 279 + __le16 ATIM_window; 280 + u8 CFP_mode; 281 + u8 privacy_option_implemented; 282 + u8 DTIM_period; 283 + u8 CFP_period; 284 + u8 current_bssid[ETH_ALEN]; 285 + u8 current_essid[32]; 286 + u8 current_bss_type; 287 + u8 power_mgmt_mode; 288 + /* rfmd and 505 */ 289 + u8 ibss_change; 290 + u8 res; 291 + u8 multi_domain_capability_implemented; 292 + u8 multi_domain_capability_enabled; 293 + u8 country_string[3]; 294 + u8 reserved[3]; 295 + } __attribute__((packed)); 296 + 297 + struct mib_mac_wep { 298 + u8 privacy_invoked; /* 0 disable encr., 1 enable encr */ 299 + u8 wep_default_key_id; 300 + u8 wep_key_mapping_len; 301 + u8 exclude_unencrypted; 302 + __le32 wep_icv_error_count; 303 + __le32 wep_excluded_count; 304 + u8 wep_default_keyvalue[WEP_KEYS][WEP_LARGE_KEY_LEN]; 305 + u8 encryption_level; /* 1 for 40bit, 2 for 104bit encryption */ 306 + } __attribute__((packed)); 307 + 308 + struct mib_phy { 309 + __le32 ed_threshold; 310 + 311 + __le16 slot_time; 312 + __le16 sifs_time; 313 + __le16 preamble_length; 314 + __le16 plcp_header_length; 315 + __le16 mpdu_max_length; 316 + __le16 cca_mode_supported; 317 + 318 + u8 operation_rate_set[4]; 319 + u8 channel_id; 320 + u8 current_cca_mode; 321 + u8 phy_type; 322 + u8 current_reg_domain; 323 + } __attribute__((packed)); 324 + 325 + struct mib_fw_version { 326 + u8 major; 327 + u8 minor; 328 + u8 patch; 329 + u8 build; 330 + } __attribute__((packed)); 331 + 332 + struct mib_mdomain { 333 + u8 tx_powerlevel[14]; 334 + u8 channel_list[14]; /* 0 for invalid channels */ 335 + } __attribute__((packed)); 336 + 337 + struct at76_fw_header { 338 + __le32 crc; /* CRC32 of the whole image */ 339 + __le32 board_type; /* firmware compatibility code */ 340 + u8 build; /* firmware build number */ 341 + u8 patch; /* firmware patch level */ 342 + u8 minor; /* firmware minor version */ 343 + u8 major; /* firmware major version */ 344 + __le32 str_offset; /* offset of the copyright string */ 345 + __le32 int_fw_offset; /* internal firmware image offset */ 346 + __le32 int_fw_len; /* internal firmware image length */ 347 + __le32 ext_fw_offset; /* external firmware image offset */ 348 + __le32 ext_fw_len; /* external firmware image length */ 349 + } __attribute__((packed)); 350 + 351 + /* a description of a regulatory domain and the allowed channels */ 352 + struct reg_domain { 353 + u16 code; 354 + char const *name; 355 + u32 channel_map; /* if bit N is set, channel (N+1) is allowed */ 356 + }; 357 + 358 + /* Data for one loaded firmware file */ 359 + struct fwentry { 360 + const char *const fwname; 361 + const struct firmware *fw; 362 + int extfw_size; 363 + int intfw_size; 364 + /* pointer to loaded firmware, no need to free */ 365 + u8 *extfw; /* external firmware, extfw_size bytes long */ 366 + u8 *intfw; /* internal firmware, intfw_size bytes long */ 367 + enum board_type board_type; /* board type */ 368 + struct mib_fw_version fw_version; 369 + int loaded; /* Loaded and parsed successfully */ 370 + }; 371 + 372 + struct at76_priv { 373 + struct usb_device *udev; /* USB device pointer */ 374 + 375 + struct sk_buff *rx_skb; /* skbuff for receiving data */ 376 + struct sk_buff *tx_skb; /* skbuff for transmitting data */ 377 + void *bulk_out_buffer; /* buffer for sending data */ 378 + 379 + struct urb *tx_urb; /* URB for sending data */ 380 + struct urb *rx_urb; /* URB for receiving data */ 381 + 382 + unsigned int tx_pipe; /* bulk out pipe */ 383 + unsigned int rx_pipe; /* bulk in pipe */ 384 + 385 + struct mutex mtx; /* locks this structure */ 386 + 387 + /* work queues */ 388 + struct work_struct work_set_promisc; 389 + struct work_struct work_submit_rx; 390 + struct delayed_work dwork_hw_scan; 391 + 392 + struct tasklet_struct rx_tasklet; 393 + 394 + /* the WEP stuff */ 395 + int wep_enabled; /* 1 if WEP is enabled */ 396 + int wep_key_id; /* key id to be used */ 397 + u8 wep_keys[WEP_KEYS][WEP_LARGE_KEY_LEN]; /* WEP keys */ 398 + u8 wep_keys_len[WEP_KEYS]; /* length of WEP keys */ 399 + 400 + int channel; 401 + int iw_mode; 402 + u8 bssid[ETH_ALEN]; 403 + u8 essid[IW_ESSID_MAX_SIZE]; 404 + int essid_size; 405 + int radio_on; 406 + int promisc; 407 + 408 + int preamble_type; /* 0 - long, 1 - short, 2 - auto */ 409 + int auth_mode; /* authentication type: 0 open, 1 shared key */ 410 + int txrate; /* 0,1,2,3 = 1,2,5.5,11 Mbps, 4 is auto */ 411 + int frag_threshold; /* threshold for fragmentation of tx packets */ 412 + int rts_threshold; /* threshold for RTS mechanism */ 413 + int short_retry_limit; 414 + 415 + int scan_min_time; /* scan min channel time */ 416 + int scan_max_time; /* scan max channel time */ 417 + int scan_mode; /* SCAN_TYPE_ACTIVE, SCAN_TYPE_PASSIVE */ 418 + int scan_need_any; /* if set, need to scan for any ESSID */ 419 + 420 + u16 assoc_id; /* current association ID, if associated */ 421 + 422 + u8 pm_mode; /* power management mode */ 423 + u32 pm_period; /* power management period in microseconds */ 424 + 425 + struct reg_domain const *domain; /* reg domain description */ 426 + 427 + /* These fields contain HW config provided by the device (not all of 428 + * these fields are used by all board types) */ 429 + u8 mac_addr[ETH_ALEN]; 430 + u8 regulatory_domain; 431 + 432 + struct at76_card_config card_config; 433 + 434 + enum board_type board_type; 435 + struct mib_fw_version fw_version; 436 + 437 + unsigned int device_unplugged:1; 438 + unsigned int netdev_registered:1; 439 + struct set_mib_buffer mib_buf; /* global buffer for set_mib calls */ 440 + 441 + int beacon_period; /* period of mgmt beacons, Kus */ 442 + 443 + struct ieee80211_hw *hw; 444 + int mac80211_registered; 445 + }; 446 + 447 + #define AT76_SUPPORTED_FILTERS FIF_PROMISC_IN_BSS 448 + 449 + #define SCAN_POLL_INTERVAL (HZ / 4) 450 + 451 + #define CMD_COMPLETION_TIMEOUT (5 * HZ) 452 + 453 + #define DEF_RTS_THRESHOLD 1536 454 + #define DEF_FRAG_THRESHOLD 1536 455 + #define DEF_SHORT_RETRY_LIMIT 8 456 + #define DEF_CHANNEL 10 457 + #define DEF_SCAN_MIN_TIME 10 458 + #define DEF_SCAN_MAX_TIME 120 459 + 460 + /* the max padding size for tx in bytes (see calc_padding) */ 461 + #define MAX_PADDING_SIZE 53 462 + 463 + #endif /* _AT76_USB_H */
+41 -43
drivers/net/wireless/ath5k/base.c
··· 350 350 static void ath5k_beacon_send(struct ath5k_softc *sc); 351 351 static void ath5k_beacon_config(struct ath5k_softc *sc); 352 352 static void ath5k_beacon_update_timers(struct ath5k_softc *sc, u64 bc_tsf); 353 + static void ath5k_tasklet_beacon(unsigned long data); 353 354 354 355 static inline u64 ath5k_extend_tsf(struct ath5k_hw *ah, u32 rstamp) 355 356 { ··· 790 789 tasklet_init(&sc->rxtq, ath5k_tasklet_rx, (unsigned long)sc); 791 790 tasklet_init(&sc->txtq, ath5k_tasklet_tx, (unsigned long)sc); 792 791 tasklet_init(&sc->restq, ath5k_tasklet_reset, (unsigned long)sc); 792 + tasklet_init(&sc->beacontq, ath5k_tasklet_beacon, (unsigned long)sc); 793 793 setup_timer(&sc->calib_tim, ath5k_calibrate, (unsigned long)sc); 794 794 795 795 ret = ath5k_eeprom_read_mac(ah, mac); ··· 1220 1218 1221 1219 pktlen = skb->len; 1222 1220 1221 + if (info->control.hw_key) { 1222 + keyidx = info->control.hw_key->hw_key_idx; 1223 + pktlen += info->control.hw_key->icv_len; 1224 + } 1223 1225 if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) { 1224 1226 flags |= AR5K_TXDESC_RTSENA; 1225 1227 cts_rate = ieee80211_get_rts_cts_rate(sc->hw, info)->hw_value; ··· 1235 1229 cts_rate = ieee80211_get_rts_cts_rate(sc->hw, info)->hw_value; 1236 1230 duration = le16_to_cpu(ieee80211_ctstoself_duration(sc->hw, 1237 1231 sc->vif, pktlen, info)); 1238 - } 1239 - 1240 - if (info->control.hw_key) { 1241 - keyidx = info->control.hw_key->hw_key_idx; 1242 - pktlen += info->control.hw_key->icv_len; 1243 1232 } 1244 1233 ret = ah->ah_setup_tx_desc(ah, ds, pktlen, 1245 1234 ieee80211_get_hdrlen_from_skb(skb), AR5K_PKT_TYPE_NORMAL, ··· 1701 1700 } 1702 1701 } 1703 1702 1703 + static void ath5k_tasklet_beacon(unsigned long data) 1704 + { 1705 + struct ath5k_softc *sc = (struct ath5k_softc *) data; 1706 + 1707 + /* 1708 + * Software beacon alert--time to send a beacon. 1709 + * 1710 + * In IBSS mode we use this interrupt just to 1711 + * keep track of the next TBTT (target beacon 1712 + * transmission time) in order to detect wether 1713 + * automatic TSF updates happened. 1714 + */ 1715 + if (sc->opmode == NL80211_IFTYPE_ADHOC) { 1716 + /* XXX: only if VEOL suppported */ 1717 + u64 tsf = ath5k_hw_get_tsf64(sc->ah); 1718 + sc->nexttbtt += sc->bintval; 1719 + ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 1720 + "SWBA nexttbtt: %x hw_tu: %x " 1721 + "TSF: %llx\n", 1722 + sc->nexttbtt, 1723 + TSF_TO_TU(tsf), 1724 + (unsigned long long) tsf); 1725 + } else { 1726 + spin_lock(&sc->block); 1727 + ath5k_beacon_send(sc); 1728 + spin_unlock(&sc->block); 1729 + } 1730 + } 1704 1731 1705 1732 static void 1706 1733 ath5k_tasklet_rx(unsigned long data) ··· 2069 2040 * frame contents are done as needed and the slot time is 2070 2041 * also adjusted based on current state. 2071 2042 * 2072 - * this is usually called from interrupt context (ath5k_intr()) 2073 - * but also from ath5k_beacon_config() in IBSS mode which in turn 2074 - * can be called from a tasklet and user context 2043 + * This is called from software irq context (beacontq or restq 2044 + * tasklets) or user context from ath5k_beacon_config. 2075 2045 */ 2076 2046 static void 2077 2047 ath5k_beacon_send(struct ath5k_softc *sc) ··· 2244 2216 ath5k_beacon_config(struct ath5k_softc *sc) 2245 2217 { 2246 2218 struct ath5k_hw *ah = sc->ah; 2219 + unsigned long flags; 2247 2220 2248 2221 ath5k_hw_set_imr(ah, 0); 2249 2222 sc->bmisscount = 0; ··· 2266 2237 2267 2238 if (sc->opmode == NL80211_IFTYPE_ADHOC) { 2268 2239 if (ath5k_hw_hasveol(ah)) { 2269 - spin_lock(&sc->block); 2240 + spin_lock_irqsave(&sc->block, flags); 2270 2241 ath5k_beacon_send(sc); 2271 - spin_unlock(&sc->block); 2242 + spin_unlock_irqrestore(&sc->block, flags); 2272 2243 } 2273 2244 } else 2274 2245 ath5k_beacon_update_timers(sc, -1); ··· 2420 2391 tasklet_kill(&sc->rxtq); 2421 2392 tasklet_kill(&sc->txtq); 2422 2393 tasklet_kill(&sc->restq); 2394 + tasklet_kill(&sc->beacontq); 2423 2395 2424 2396 return ret; 2425 2397 } ··· 2438 2408 return IRQ_NONE; 2439 2409 2440 2410 do { 2441 - /* 2442 - * Figure out the reason(s) for the interrupt. Note 2443 - * that get_isr returns a pseudo-ISR that may include 2444 - * bits we haven't explicitly enabled so we mask the 2445 - * value to insure we only process bits we requested. 2446 - */ 2447 2411 ath5k_hw_get_isr(ah, &status); /* NB: clears IRQ too */ 2448 2412 ATH5K_DBG(sc, ATH5K_DEBUG_INTR, "status 0x%x/0x%x\n", 2449 2413 status, sc->imask); 2450 - status &= sc->imask; /* discard unasked for bits */ 2451 2414 if (unlikely(status & AR5K_INT_FATAL)) { 2452 2415 /* 2453 2416 * Fatal errors are unrecoverable. ··· 2451 2428 tasklet_schedule(&sc->restq); 2452 2429 } else { 2453 2430 if (status & AR5K_INT_SWBA) { 2454 - /* 2455 - * Software beacon alert--time to send a beacon. 2456 - * Handle beacon transmission directly; deferring 2457 - * this is too slow to meet timing constraints 2458 - * under load. 2459 - * 2460 - * In IBSS mode we use this interrupt just to 2461 - * keep track of the next TBTT (target beacon 2462 - * transmission time) in order to detect wether 2463 - * automatic TSF updates happened. 2464 - */ 2465 - if (sc->opmode == NL80211_IFTYPE_ADHOC) { 2466 - /* XXX: only if VEOL suppported */ 2467 - u64 tsf = ath5k_hw_get_tsf64(ah); 2468 - sc->nexttbtt += sc->bintval; 2469 - ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, 2470 - "SWBA nexttbtt: %x hw_tu: %x " 2471 - "TSF: %llx\n", 2472 - sc->nexttbtt, 2473 - TSF_TO_TU(tsf), 2474 - (unsigned long long) tsf); 2475 - } else { 2476 - spin_lock(&sc->block); 2477 - ath5k_beacon_send(sc); 2478 - spin_unlock(&sc->block); 2479 - } 2431 + tasklet_schedule(&sc->beacontq); 2480 2432 } 2481 2433 if (status & AR5K_INT_RXEOL) { 2482 2434 /*
+1
drivers/net/wireless/ath5k/base.h
··· 169 169 struct ath5k_led tx_led; /* tx led */ 170 170 171 171 spinlock_t block; /* protects beacon */ 172 + struct tasklet_struct beacontq; /* beacon intr tasklet */ 172 173 struct ath5k_buf *bbuf; /* beacon buffer */ 173 174 unsigned int bhalq, /* SW q for outgoing beacons */ 174 175 bmisscount, /* missed beacon transmits */
+3 -4
drivers/net/wireless/ath9k/ani.c
··· 642 642 REG_WRITE(ah, AR_PHY_ERR_MASK_2, AR_PHY_ERR_CCK_TIMING); 643 643 } 644 644 645 + /* Freeze the MIB counters, get the stats and then clear them */ 645 646 void ath9k_hw_disable_mib_counters(struct ath_hw *ah) 646 647 { 647 648 DPRINTF(ah->ah_sc, ATH_DBG_ANI, "Disable MIB counters\n"); 648 - 649 - REG_WRITE(ah, AR_MIBC, AR_MIBC_FMC | AR_MIBC_CMC); 650 - 649 + REG_WRITE(ah, AR_MIBC, AR_MIBC_FMC); 651 650 ath9k_hw_update_mibstats(ah, &ah->ah_mibStats); 652 - 651 + REG_WRITE(ah, AR_MIBC, AR_MIBC_CMC); 653 652 REG_WRITE(ah, AR_FILT_OFDM, 0); 654 653 REG_WRITE(ah, AR_FILT_CCK, 0); 655 654 }
+5 -7
drivers/net/wireless/ath9k/ath9k.h
··· 464 464 /* ANI */ 465 465 /*******/ 466 466 467 - /* ANI values for STA only. 468 - FIXME: Add appropriate values for AP later */ 469 - 470 - #define ATH_ANI_POLLINTERVAL 100 /* 100 milliseconds between ANI poll */ 471 - #define ATH_SHORT_CALINTERVAL 1000 /* 1 second between calibrations */ 472 - #define ATH_LONG_CALINTERVAL 30000 /* 30 seconds between calibrations */ 473 - #define ATH_RESTART_CALINTERVAL 1200000 /* 20 minutes between calibrations */ 467 + #define ATH_STA_SHORT_CALINTERVAL 1000 /* 1 second */ 468 + #define ATH_AP_SHORT_CALINTERVAL 100 /* 100 ms */ 469 + #define ATH_ANI_POLLINTERVAL 100 /* 100 ms */ 470 + #define ATH_LONG_CALINTERVAL 30000 /* 30 seconds */ 471 + #define ATH_RESTART_CALINTERVAL 1200000 /* 20 minutes */ 474 472 475 473 struct ath_ani { 476 474 bool caldone;
+6 -2
drivers/net/wireless/ath9k/beacon.c
··· 753 753 if (bs.bs_sleepduration > bs.bs_dtimperiod) 754 754 bs.bs_sleepduration = bs.bs_dtimperiod; 755 755 756 + /* TSF out of range threshold fixed at 1 second */ 757 + bs.bs_tsfoor_threshold = ATH9K_TSFOOR_THRESHOLD; 758 + 756 759 DPRINTF(sc, ATH_DBG_BEACON, 757 760 "tsf %llu " 758 761 "tsf:tu %u " ··· 790 787 u64 tsf; 791 788 u32 tsftu; 792 789 ath9k_hw_set_interrupts(ah, 0); 793 - if (nexttbtt == intval) 794 - intval |= ATH9K_BEACON_RESET_TSF; 795 790 if (sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) { 796 791 /* 797 792 * Pull nexttbtt forward to reflect the current ··· 823 822 sc->imask |= ATH9K_INT_SWBA; 824 823 ath_beaconq_config(sc); 825 824 } else if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) { 825 + if (nexttbtt == intval) 826 + intval |= ATH9K_BEACON_RESET_TSF; 827 + 826 828 /* 827 829 * In AP mode we enable the beacon timers and 828 830 * SWBA interrupts to prepare beacon frames.
+63 -1
drivers/net/wireless/ath9k/calib.c
··· 718 718 return nf; 719 719 } 720 720 721 + static void ath9k_olc_temp_compensation(struct ath_hw *ah) 722 + { 723 + u32 rddata, i; 724 + int delta, currPDADC, regval; 725 + 726 + rddata = REG_READ(ah, AR_PHY_TX_PWRCTRL4); 727 + 728 + currPDADC = MS(rddata, AR_PHY_TX_PWRCTRL_PD_AVG_OUT); 729 + 730 + if (ah->eep_ops->get_eeprom(ah, EEP_DAC_HPWR_5G)) 731 + delta = (currPDADC - ah->initPDADC + 4) / 8; 732 + else 733 + delta = (currPDADC - ah->initPDADC + 5) / 10; 734 + 735 + if (delta != ah->PDADCdelta) { 736 + ah->PDADCdelta = delta; 737 + for (i = 1; i < AR9280_TX_GAIN_TABLE_SIZE; i++) { 738 + regval = ah->originalGain[i] - delta; 739 + if (regval < 0) 740 + regval = 0; 741 + 742 + REG_RMW_FIELD(ah, AR_PHY_TX_GAIN_TBL1 + i * 4, 743 + AR_PHY_TX_GAIN, regval); 744 + } 745 + } 746 + } 747 + 721 748 bool ath9k_hw_calibrate(struct ath_hw *ah, struct ath9k_channel *chan, 722 749 u8 rxchainmask, bool longcal, 723 750 bool *isCalDone) ··· 769 742 } 770 743 771 744 if (longcal) { 745 + if (OLC_FOR_AR9280_20_LATER) 746 + ath9k_olc_temp_compensation(ah); 772 747 ath9k_hw_getnf(ah, chan); 773 748 ath9k_hw_loadnf(ah, ah->curchan); 774 749 ath9k_hw_start_nfcal(ah); ··· 880 851 bool ath9k_hw_init_cal(struct ath_hw *ah, 881 852 struct ath9k_channel *chan) 882 853 { 854 + if (AR_SREV_9280_10_OR_LATER(ah)) { 855 + REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); 856 + REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); 857 + REG_CLR_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE); 858 + 859 + /* Kick off the cal */ 860 + REG_WRITE(ah, AR_PHY_AGC_CONTROL, 861 + REG_READ(ah, AR_PHY_AGC_CONTROL) | 862 + AR_PHY_AGC_CONTROL_CAL); 863 + 864 + if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, 865 + AR_PHY_AGC_CONTROL_CAL, 0, 866 + AH_WAIT_TIMEOUT)) { 867 + DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 868 + "offset calibration failed to complete in 1ms; " 869 + "noisy environment?\n"); 870 + return false; 871 + } 872 + 873 + REG_CLR_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); 874 + REG_SET_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); 875 + REG_SET_BIT(ah, AR_PHY_CL_CAL_CTL, AR_PHY_CL_CAL_ENABLE); 876 + } 877 + 878 + /* Calibrate the AGC */ 883 879 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 884 880 REG_READ(ah, AR_PHY_AGC_CONTROL) | 885 881 AR_PHY_AGC_CONTROL_CAL); 886 882 887 - if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 0)) { 883 + if (!ath9k_hw_wait(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_CAL, 884 + 0, AH_WAIT_TIMEOUT)) { 888 885 DPRINTF(ah->ah_sc, ATH_DBG_CALIBRATE, 889 886 "offset calibration failed to complete in 1ms; " 890 887 "noisy environment?\n"); 891 888 return false; 892 889 } 893 890 891 + if (AR_SREV_9280_10_OR_LATER(ah)) { 892 + REG_SET_BIT(ah, AR_PHY_ADC_CTL, AR_PHY_ADC_CTL_OFF_PWDADC); 893 + REG_CLR_BIT(ah, AR_PHY_AGC_CONTROL, AR_PHY_AGC_CONTROL_FLTR_CAL); 894 + } 895 + 896 + /* Do PA Calibration */ 894 897 if (AR_SREV_9285(ah) && AR_SREV_9285_11_OR_LATER(ah)) 895 898 ath9k_hw_9285_pa_cal(ah); 896 899 900 + /* Do NF Calibration */ 897 901 REG_WRITE(ah, AR_PHY_AGC_CONTROL, 898 902 REG_READ(ah, AR_PHY_AGC_CONTROL) | 899 903 AR_PHY_AGC_CONTROL_NF);
+1 -1
drivers/net/wireless/ath9k/calib.h
··· 27 27 28 28 #define AR_PHY_CCA_MAX_GOOD_VALUE -85 29 29 #define AR_PHY_CCA_MAX_HIGH_VALUE -62 30 - #define AR_PHY_CCA_MIN_BAD_VALUE -121 30 + #define AR_PHY_CCA_MIN_BAD_VALUE -140 31 31 #define AR_PHY_CCA_FILTERWINDOW_LENGTH_INIT 3 32 32 #define AR_PHY_CCA_FILTERWINDOW_LENGTH 5 33 33
+7 -5
drivers/net/wireless/ath9k/debug.c
··· 258 258 259 259 /* FIXME: legacy rates, later on .. */ 260 260 void ath_debug_stat_retries(struct ath_softc *sc, int rix, 261 - int xretries, int retries) 261 + int xretries, int retries, u8 per) 262 262 { 263 263 if (conf_is_ht(&sc->hw->conf)) { 264 264 int idx = sc->cur_rate_table->info[rix].dot11rate; 265 265 266 266 sc->debug.stats.n_rcstats[idx].xretries += xretries; 267 267 sc->debug.stats.n_rcstats[idx].retries += retries; 268 + sc->debug.stats.n_rcstats[idx].per = per; 268 269 } 269 270 } 270 271 ··· 278 277 unsigned int len = 0; 279 278 int i = 0; 280 279 281 - len += sprintf(buf, "%7s %13s %8s %8s\n\n", "Rate", "Success", 282 - "Retries", "XRetries"); 280 + len += sprintf(buf, "%7s %13s %8s %8s %6s\n\n", "Rate", "Success", 281 + "Retries", "XRetries", "PER"); 283 282 284 283 for (i = 0; i <= 15; i++) { 285 284 len += snprintf(buf + len, sizeof(buf) - len, 286 - "%5s%3d: %8u %8u %8u\n", "MCS", i, 285 + "%5s%3d: %8u %8u %8u %8u\n", "MCS", i, 287 286 sc->debug.stats.n_rcstats[i].success, 288 287 sc->debug.stats.n_rcstats[i].retries, 289 - sc->debug.stats.n_rcstats[i].xretries); 288 + sc->debug.stats.n_rcstats[i].xretries, 289 + sc->debug.stats.n_rcstats[i].per); 290 290 } 291 291 292 292 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
+5 -4
drivers/net/wireless/ath9k/debug.h
··· 91 91 u32 success; 92 92 u32 retries; 93 93 u32 xretries; 94 + u8 per; 94 95 }; 95 96 96 97 struct ath_stats { 97 98 struct ath_interrupt_stats istats; 98 - struct ath_legacy_rc_stats legacy_rcstats[12]; /* max(11a,11b,11g) */ 99 - struct ath_11n_rc_stats n_rcstats[16]; /* 0..15 MCS rates */ 99 + struct ath_legacy_rc_stats legacy_rcstats[12]; /* max(11a,11b,11g) */ 100 + struct ath_11n_rc_stats n_rcstats[16]; /* 0..15 MCS rates */ 100 101 }; 101 102 102 103 struct ath9k_debug { ··· 116 115 void ath_debug_stat_interrupt(struct ath_softc *sc, enum ath9k_int status); 117 116 void ath_debug_stat_rc(struct ath_softc *sc, struct sk_buff *skb); 118 117 void ath_debug_stat_retries(struct ath_softc *sc, int rix, 119 - int xretries, int retries); 118 + int xretries, int retries, u8 per); 120 119 121 120 #else 122 121 ··· 145 144 } 146 145 147 146 static inline void ath_debug_stat_retries(struct ath_softc *sc, int rix, 148 - int xretries, int retries) 147 + int xretries, int retries, u8 per) 149 148 { 150 149 } 151 150
+196 -36
drivers/net/wireless/ath9k/eeprom.c
··· 179 179 } 180 180 } 181 181 182 + static void ath9k_get_txgain_index(struct ath_hw *ah, 183 + struct ath9k_channel *chan, 184 + struct calDataPerFreqOpLoop *rawDatasetOpLoop, 185 + u8 *calChans, u16 availPiers, u8 *pwr, u8 *pcdacIdx) 186 + { 187 + u8 pcdac, i = 0; 188 + u16 idxL = 0, idxR = 0, numPiers; 189 + bool match; 190 + struct chan_centers centers; 191 + 192 + ath9k_hw_get_channel_centers(ah, chan, &centers); 193 + 194 + for (numPiers = 0; numPiers < availPiers; numPiers++) 195 + if (calChans[numPiers] == AR5416_BCHAN_UNUSED) 196 + break; 197 + 198 + match = ath9k_hw_get_lower_upper_index( 199 + (u8)FREQ2FBIN(centers.synth_center, IS_CHAN_2GHZ(chan)), 200 + calChans, numPiers, &idxL, &idxR); 201 + if (match) { 202 + pcdac = rawDatasetOpLoop[idxL].pcdac[0][0]; 203 + *pwr = rawDatasetOpLoop[idxL].pwrPdg[0][0]; 204 + } else { 205 + pcdac = rawDatasetOpLoop[idxR].pcdac[0][0]; 206 + *pwr = (rawDatasetOpLoop[idxL].pwrPdg[0][0] + 207 + rawDatasetOpLoop[idxR].pwrPdg[0][0])/2; 208 + } 209 + 210 + while (pcdac > ah->originalGain[i] && 211 + i < (AR9280_TX_GAIN_TABLE_SIZE - 1)) 212 + i++; 213 + 214 + *pcdacIdx = i; 215 + return; 216 + } 217 + 218 + static void ath9k_olc_get_pdadcs(struct ath_hw *ah, 219 + u32 initTxGain, 220 + int txPower, 221 + u8 *pPDADCValues) 222 + { 223 + u32 i; 224 + u32 offset; 225 + 226 + REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL6_0, 227 + AR_PHY_TX_PWRCTRL_ERR_EST_MODE, 3); 228 + REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL6_1, 229 + AR_PHY_TX_PWRCTRL_ERR_EST_MODE, 3); 230 + 231 + REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL7, 232 + AR_PHY_TX_PWRCTRL_INIT_TX_GAIN, initTxGain); 233 + 234 + offset = txPower; 235 + for (i = 0; i < AR5416_NUM_PDADC_VALUES; i++) 236 + if (i < offset) 237 + pPDADCValues[i] = 0x0; 238 + else 239 + pPDADCValues[i] = 0xFF; 240 + } 241 + 242 + 243 + 244 + 182 245 static void ath9k_hw_get_target_powers(struct ath_hw *ah, 183 246 struct ath9k_channel *chan, 184 247 struct cal_target_power_ht *powInfo, ··· 502 439 503 440 switch (param) { 504 441 case EEP_NFTHRESH_2: 505 - return pModal[1].noiseFloorThreshCh[0]; 442 + return pModal->noiseFloorThreshCh[0]; 506 443 case AR_EEPROM_MAC(0): 507 444 return pBase->macAddr[0] << 8 | pBase->macAddr[1]; 508 445 case AR_EEPROM_MAC(1): ··· 529 466 return pBase->txMask; 530 467 case EEP_RX_MASK: 531 468 return pBase->rxMask; 469 + case EEP_FRAC_N_5G: 470 + return 0; 532 471 default: 533 472 return 0; 534 473 } ··· 1659 1594 return pBase->rxGainType; 1660 1595 case EEP_TXGAIN_TYPE: 1661 1596 return pBase->txGainType; 1597 + case EEP_OL_PWRCTRL: 1598 + if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19) 1599 + return pBase->openLoopPwrCntl ? true : false; 1600 + else 1601 + return false; 1602 + case EEP_RC_CHAIN_MASK: 1603 + if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19) 1604 + return pBase->rcChainMask; 1605 + else 1606 + return 0; 1662 1607 case EEP_DAC_HPWR_5G: 1663 1608 if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20) 1664 1609 return pBase->dacHiPwrMode_5G; 1610 + else 1611 + return 0; 1612 + case EEP_FRAC_N_5G: 1613 + if (AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_22) 1614 + return pBase->frac_n_5g; 1665 1615 else 1666 1616 return 0; 1667 1617 default: ··· 1912 1832 pModal->swSettleHt40); 1913 1833 } 1914 1834 1835 + if (AR_SREV_9280_20_OR_LATER(ah) && 1836 + AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_19) 1837 + REG_RMW_FIELD(ah, AR_PHY_CCK_TX_CTRL, 1838 + AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK, 1839 + pModal->miscBits); 1840 + 1841 + 1915 1842 if (AR_SREV_9280_20(ah) && AR5416_VER_MASK >= AR5416_EEP_MINOR_VER_20) { 1916 - if (IS_CHAN_HT20(chan)) 1843 + if (IS_CHAN_2GHZ(chan)) 1917 1844 REG_RMW_FIELD(ah, AR_AN_TOP1, AR_AN_TOP1_DACIPMODE, 1918 1845 eep->baseEepHeader.dacLpMode); 1919 1846 else if (eep->baseEepHeader.dacHiPwrMode_5G) ··· 1931 1844 1932 1845 REG_RMW_FIELD(ah, AR_PHY_FRAME_CTL, AR_PHY_FRAME_CTL_TX_CLIP, 1933 1846 pModal->miscBits >> 2); 1847 + 1848 + REG_RMW_FIELD(ah, AR_PHY_TX_PWRCTRL9, 1849 + AR_PHY_TX_DESIRED_SCALE_CCK, 1850 + eep->baseEepHeader.desiredScaleCCK); 1934 1851 } 1935 1852 1936 1853 return true; ··· 2164 2073 struct ath9k_channel *chan, 2165 2074 int16_t *pTxPowerIndexOffset) 2166 2075 { 2076 + #define SM_PD_GAIN(x) SM(0x38, AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_##x) 2077 + #define SM_PDGAIN_B(x, y) \ 2078 + SM((gainBoundaries[x]), AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_##y) 2079 + 2167 2080 struct ar5416_eeprom_def *pEepData = &ah->eeprom.def; 2168 2081 struct cal_data_per_freq *pRawDataset; 2169 2082 u8 *pCalBChans = NULL; ··· 2199 2104 } else { 2200 2105 pCalBChans = pEepData->calFreqPier5G; 2201 2106 numPiers = AR5416_NUM_5G_CAL_PIERS; 2107 + } 2108 + 2109 + if (OLC_FOR_AR9280_20_LATER && IS_CHAN_2GHZ(chan)) { 2110 + pRawDataset = pEepData->calPierData2G[0]; 2111 + ah->initPDADC = ((struct calDataPerFreqOpLoop *) 2112 + pRawDataset)->vpdPdg[0][0]; 2202 2113 } 2203 2114 2204 2115 numXpdGain = 0; ··· 2242 2141 else 2243 2142 pRawDataset = pEepData->calPierData5G[i]; 2244 2143 2245 - ath9k_hw_get_def_gain_boundaries_pdadcs(ah, chan, 2246 - pRawDataset, pCalBChans, 2247 - numPiers, pdGainOverlap_t2, 2248 - &tMinCalPower, gainBoundaries, 2249 - pdadcValues, numXpdGain); 2144 + 2145 + if (OLC_FOR_AR9280_20_LATER) { 2146 + u8 pcdacIdx; 2147 + u8 txPower; 2148 + 2149 + ath9k_get_txgain_index(ah, chan, 2150 + (struct calDataPerFreqOpLoop *)pRawDataset, 2151 + pCalBChans, numPiers, &txPower, &pcdacIdx); 2152 + ath9k_olc_get_pdadcs(ah, pcdacIdx, 2153 + txPower/2, pdadcValues); 2154 + } else { 2155 + ath9k_hw_get_def_gain_boundaries_pdadcs(ah, 2156 + chan, pRawDataset, 2157 + pCalBChans, numPiers, 2158 + pdGainOverlap_t2, 2159 + &tMinCalPower, 2160 + gainBoundaries, 2161 + pdadcValues, 2162 + numXpdGain); 2163 + } 2250 2164 2251 2165 if ((i == 0) || AR_SREV_5416_V20_OR_LATER(ah)) { 2252 - REG_WRITE(ah, 2253 - AR_PHY_TPCRG5 + regChainOffset, 2254 - SM(pdGainOverlap_t2, 2255 - AR_PHY_TPCRG5_PD_GAIN_OVERLAP) 2256 - | SM(gainBoundaries[0], 2257 - AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_1) 2258 - | SM(gainBoundaries[1], 2259 - AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_2) 2260 - | SM(gainBoundaries[2], 2261 - AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_3) 2262 - | SM(gainBoundaries[3], 2263 - AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_4)); 2166 + if (OLC_FOR_AR9280_20_LATER) { 2167 + REG_WRITE(ah, 2168 + AR_PHY_TPCRG5 + regChainOffset, 2169 + SM(0x6, 2170 + AR_PHY_TPCRG5_PD_GAIN_OVERLAP) | 2171 + SM_PD_GAIN(1) | SM_PD_GAIN(2) | 2172 + SM_PD_GAIN(3) | SM_PD_GAIN(4)); 2173 + } else { 2174 + REG_WRITE(ah, 2175 + AR_PHY_TPCRG5 + regChainOffset, 2176 + SM(pdGainOverlap_t2, 2177 + AR_PHY_TPCRG5_PD_GAIN_OVERLAP)| 2178 + SM_PDGAIN_B(0, 1) | 2179 + SM_PDGAIN_B(1, 2) | 2180 + SM_PDGAIN_B(2, 3) | 2181 + SM_PDGAIN_B(3, 4)); 2182 + } 2264 2183 } 2265 2184 2266 2185 regOffset = AR_PHY_BASE + (672 << 2) + regChainOffset; ··· 2314 2193 *pTxPowerIndexOffset = 0; 2315 2194 2316 2195 return true; 2196 + #undef SM_PD_GAIN 2197 + #undef SM_PDGAIN_B 2317 2198 } 2318 2199 2319 2200 static bool ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah, ··· 2616 2493 u8 twiceMaxRegulatoryPower, 2617 2494 u8 powerLimit) 2618 2495 { 2496 + #define RT_AR_DELTA(x) (ratesArray[x] - cck_ofdm_delta) 2619 2497 struct ar5416_eeprom_def *pEepData = &ah->eeprom.def; 2620 2498 struct modal_eep_header *pModal = 2621 2499 &(pEepData->modalHeader[IS_CHAN_2GHZ(chan)]); 2622 2500 int16_t ratesArray[Ar5416RateSize]; 2623 2501 int16_t txPowerIndexOffset = 0; 2624 2502 u8 ht40PowerIncForPdadc = 2; 2625 - int i; 2503 + int i, cck_ofdm_delta = 0; 2626 2504 2627 2505 memset(ratesArray, 0, sizeof(ratesArray)); 2628 2506 ··· 2672 2548 | ATH9K_POW_SM(ratesArray[rate24mb], 0)); 2673 2549 2674 2550 if (IS_CHAN_2GHZ(chan)) { 2675 - REG_WRITE(ah, AR_PHY_POWER_TX_RATE3, 2676 - ATH9K_POW_SM(ratesArray[rate2s], 24) 2677 - | ATH9K_POW_SM(ratesArray[rate2l], 16) 2678 - | ATH9K_POW_SM(ratesArray[rateXr], 8) 2679 - | ATH9K_POW_SM(ratesArray[rate1l], 0)); 2680 - REG_WRITE(ah, AR_PHY_POWER_TX_RATE4, 2681 - ATH9K_POW_SM(ratesArray[rate11s], 24) 2682 - | ATH9K_POW_SM(ratesArray[rate11l], 16) 2683 - | ATH9K_POW_SM(ratesArray[rate5_5s], 8) 2684 - | ATH9K_POW_SM(ratesArray[rate5_5l], 0)); 2551 + if (OLC_FOR_AR9280_20_LATER) { 2552 + cck_ofdm_delta = 2; 2553 + REG_WRITE(ah, AR_PHY_POWER_TX_RATE3, 2554 + ATH9K_POW_SM(RT_AR_DELTA(rate2s), 24) 2555 + | ATH9K_POW_SM(RT_AR_DELTA(rate2l), 16) 2556 + | ATH9K_POW_SM(ratesArray[rateXr], 8) 2557 + | ATH9K_POW_SM(RT_AR_DELTA(rate1l), 0)); 2558 + REG_WRITE(ah, AR_PHY_POWER_TX_RATE4, 2559 + ATH9K_POW_SM(RT_AR_DELTA(rate11s), 24) 2560 + | ATH9K_POW_SM(RT_AR_DELTA(rate11l), 16) 2561 + | ATH9K_POW_SM(RT_AR_DELTA(rate5_5s), 8) 2562 + | ATH9K_POW_SM(RT_AR_DELTA(rate5_5l), 0)); 2563 + } else { 2564 + REG_WRITE(ah, AR_PHY_POWER_TX_RATE3, 2565 + ATH9K_POW_SM(ratesArray[rate2s], 24) 2566 + | ATH9K_POW_SM(ratesArray[rate2l], 16) 2567 + | ATH9K_POW_SM(ratesArray[rateXr], 8) 2568 + | ATH9K_POW_SM(ratesArray[rate1l], 0)); 2569 + REG_WRITE(ah, AR_PHY_POWER_TX_RATE4, 2570 + ATH9K_POW_SM(ratesArray[rate11s], 24) 2571 + | ATH9K_POW_SM(ratesArray[rate11l], 16) 2572 + | ATH9K_POW_SM(ratesArray[rate5_5s], 8) 2573 + | ATH9K_POW_SM(ratesArray[rate5_5l], 0)); 2574 + } 2685 2575 } 2686 2576 2687 2577 REG_WRITE(ah, AR_PHY_POWER_TX_RATE5, ··· 2728 2590 ht40PowerIncForPdadc, 8) 2729 2591 | ATH9K_POW_SM(ratesArray[rateHt40_4] + 2730 2592 ht40PowerIncForPdadc, 0)); 2731 - 2732 - REG_WRITE(ah, AR_PHY_POWER_TX_RATE9, 2733 - ATH9K_POW_SM(ratesArray[rateExtOfdm], 24) 2734 - | ATH9K_POW_SM(ratesArray[rateExtCck], 16) 2735 - | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8) 2736 - | ATH9K_POW_SM(ratesArray[rateDupCck], 0)); 2593 + if (OLC_FOR_AR9280_20_LATER) { 2594 + REG_WRITE(ah, AR_PHY_POWER_TX_RATE9, 2595 + ATH9K_POW_SM(ratesArray[rateExtOfdm], 24) 2596 + | ATH9K_POW_SM(RT_AR_DELTA(rateExtCck), 16) 2597 + | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8) 2598 + | ATH9K_POW_SM(RT_AR_DELTA(rateDupCck), 0)); 2599 + } else { 2600 + REG_WRITE(ah, AR_PHY_POWER_TX_RATE9, 2601 + ATH9K_POW_SM(ratesArray[rateExtOfdm], 24) 2602 + | ATH9K_POW_SM(ratesArray[rateExtCck], 16) 2603 + | ATH9K_POW_SM(ratesArray[rateDupOfdm], 8) 2604 + | ATH9K_POW_SM(ratesArray[rateDupCck], 0)); 2605 + } 2737 2606 } 2738 2607 2739 2608 REG_WRITE(ah, AR_PHY_POWER_TX_SUB, ··· 2759 2614 ratesArray[i] + AR5416_PWR_TABLE_OFFSET * 2; 2760 2615 else 2761 2616 ah->regulatory.max_power_level = ratesArray[i]; 2617 + 2618 + switch(ar5416_get_ntxchains(ah->txchainmask)) { 2619 + case 1: 2620 + break; 2621 + case 2: 2622 + ah->regulatory.max_power_level += INCREASE_MAXPOW_BY_TWO_CHAIN; 2623 + break; 2624 + case 3: 2625 + ah->regulatory.max_power_level += INCREASE_MAXPOW_BY_THREE_CHAIN; 2626 + break; 2627 + default: 2628 + DPRINTF(ah->ah_sc, ATH_DBG_EEPROM, 2629 + "Invalid chainmask configuration\n"); 2630 + break; 2631 + } 2762 2632 2763 2633 return 0; 2764 2634 }
+35 -2
drivers/net/wireless/ath9k/eeprom.h
··· 75 75 #define SUB_NUM_CTL_MODES_AT_5G_40 2 76 76 #define SUB_NUM_CTL_MODES_AT_2G_40 3 77 77 78 + #define INCREASE_MAXPOW_BY_TWO_CHAIN 6 /* 10*log10(2)*2 */ 79 + #define INCREASE_MAXPOW_BY_THREE_CHAIN 10 /* 10*log10(3)*2 */ 80 + 81 + /* 82 + * For AR9285 and later chipsets, the following bits are not being programmed 83 + * in EEPROM and so need to be enabled always. 84 + * 85 + * Bit 0: en_fcc_mid 86 + * Bit 1: en_jap_mid 87 + * Bit 2: en_fcc_dfs_ht40 88 + * Bit 3: en_jap_ht40 89 + * Bit 4: en_jap_dfs_ht40 90 + */ 91 + #define AR9285_RDEXT_DEFAULT 0x1F 92 + 78 93 #define AR_EEPROM_MAC(i) (0x1d+(i)) 79 94 #define ATH9K_POW_SM(_r, _s) (((_r) & 0x3f) << (_s)) 80 95 #define FREQ2FBIN(x, y) ((y) ? ((x) - 2300) : (((x) - 4800) / 5)) 81 96 #define ath9k_hw_use_flash(_ah) (!(_ah->ah_flags & AH_USE_EEPROM)) 97 + 98 + #define OLC_FOR_AR9280_20_LATER (AR_SREV_9280_20_OR_LATER(ah) && \ 99 + ah->eep_ops->get_eeprom(ah, EEP_OL_PWRCTRL)) 82 100 83 101 #define AR_EEPROM_RFSILENT_GPIO_SEL 0x001c 84 102 #define AR_EEPROM_RFSILENT_GPIO_SEL_S 2 ··· 128 110 #define AR5416_EEP_MINOR_VER_17 0x11 129 111 #define AR5416_EEP_MINOR_VER_19 0x13 130 112 #define AR5416_EEP_MINOR_VER_20 0x14 113 + #define AR5416_EEP_MINOR_VER_22 0x16 131 114 132 115 #define AR5416_NUM_5G_CAL_PIERS 8 133 116 #define AR5416_NUM_2G_CAL_PIERS 4 ··· 171 152 #define AR5416_EEP4K_PD_GAIN_ICEPTS 5 172 153 #define AR5416_EEP4K_MAX_CHAINS 1 173 154 155 + #define AR9280_TX_GAIN_TABLE_SIZE 22 156 + 174 157 enum eeprom_param { 175 158 EEP_NFTHRESH_5, 176 159 EEP_NFTHRESH_2, ··· 193 172 EEP_RX_MASK, 194 173 EEP_RXGAIN_TYPE, 195 174 EEP_TXGAIN_TYPE, 175 + EEP_OL_PWRCTRL, 176 + EEP_RC_CHAIN_MASK, 196 177 EEP_DAC_HPWR_5G, 178 + EEP_FRAC_N_5G 197 179 }; 198 180 199 181 enum ar5416_rates { ··· 236 212 u8 futureBase_1[2]; 237 213 u8 rxGainType; 238 214 u8 dacHiPwrMode_5G; 239 - u8 futureBase_2; 215 + u8 openLoopPwrCntl; 240 216 u8 dacLpMode; 241 217 u8 txGainType; 242 218 u8 rcChainMask; 243 219 u8 desiredScaleCCK; 244 - u8 futureBase_3[23]; 220 + u8 power_table_offset; 221 + u8 frac_n_5g; 222 + u8 futureBase_3[21]; 245 223 } __packed; 246 224 247 225 struct base_eep_header_4k { ··· 315 289 u8 futureModal[6]; 316 290 317 291 struct spur_chan spurChans[AR5416_EEPROM_MODAL_SPURS]; 292 + } __packed; 293 + 294 + struct calDataPerFreqOpLoop { 295 + u8 pwrPdg[2][5]; 296 + u8 vpdPdg[2][5]; 297 + u8 pcdac[2][5]; 298 + u8 empty[2][5]; 318 299 } __packed; 319 300 320 301 struct modal_eep_4k_header {
+65 -52
drivers/net/wireless/ath9k/hw.c
··· 84 84 return ath9k_hw_mac_clks(ah, usecs); 85 85 } 86 86 87 - bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val) 87 + bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout) 88 88 { 89 89 int i; 90 90 91 - for (i = 0; i < (AH_TIMEOUT / AH_TIME_QUANTUM); i++) { 91 + BUG_ON(timeout < AH_TIME_QUANTUM); 92 + 93 + for (i = 0; i < (timeout / AH_TIME_QUANTUM); i++) { 92 94 if ((REG_READ(ah, reg) & mask) == val) 93 95 return true; 94 96 ··· 98 96 } 99 97 100 98 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, 101 - "timeout on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n", 102 - reg, REG_READ(ah, reg), mask, val); 99 + "timeout (%d us) on reg 0x%x: 0x%08x & 0x%08x != 0x%08x\n", 100 + timeout, reg, REG_READ(ah, reg), mask, val); 103 101 104 102 return false; 105 103 } ··· 825 823 if (AR_SREV_9280_20(ah)) 826 824 ath9k_hw_init_txgain_ini(ah); 827 825 828 - if (ah->hw_version.devid == AR9280_DEVID_PCI) { 826 + if (!ath9k_hw_fill_cap_info(ah)) { 827 + DPRINTF(sc, ATH_DBG_RESET, "failed ath9k_hw_fill_cap_info\n"); 828 + ecode = -EINVAL; 829 + goto bad; 830 + } 831 + 832 + if ((ah->hw_version.devid == AR9280_DEVID_PCI) && 833 + test_bit(ATH9K_MODE_11A, ah->caps.wireless_modes)) { 834 + 835 + /* EEPROM Fixup */ 829 836 for (i = 0; i < ah->iniModes.ia_rows; i++) { 830 837 u32 reg = INI_RA(&ah->iniModes, i, 0); 831 838 ··· 847 836 reg, val); 848 837 } 849 838 } 850 - } 851 - 852 - if (!ath9k_hw_fill_cap_info(ah)) { 853 - DPRINTF(sc, ATH_DBG_RESET, 854 - "failed ath9k_hw_fill_cap_info\n"); 855 - ecode = -EINVAL; 856 - goto bad; 857 839 } 858 840 859 841 ecode = ath9k_hw_init_macaddr(ah); ··· 1204 1200 return ath9k_hw_def_ini_fixup(ah, pEepData, reg, value); 1205 1201 } 1206 1202 1203 + static void ath9k_olc_init(struct ath_hw *ah) 1204 + { 1205 + u32 i; 1206 + 1207 + for (i = 0; i < AR9280_TX_GAIN_TABLE_SIZE; i++) 1208 + ah->originalGain[i] = 1209 + MS(REG_READ(ah, AR_PHY_TX_GAIN_TBL1 + i * 4), 1210 + AR_PHY_TX_GAIN); 1211 + ah->PDADCdelta = 0; 1212 + } 1213 + 1207 1214 static int ath9k_hw_process_ini(struct ath_hw *ah, 1208 1215 struct ath9k_channel *chan, 1209 1216 enum ath9k_ht_macmode macmode) ··· 1320 1305 ath9k_hw_override_ini(ah, chan); 1321 1306 ath9k_hw_set_regs(ah, chan, macmode); 1322 1307 ath9k_hw_init_chain_masks(ah); 1308 + 1309 + if (OLC_FOR_AR9280_20_LATER) 1310 + ath9k_olc_init(ah); 1323 1311 1324 1312 status = ah->eep_ops->set_txpower(ah, chan, 1325 1313 ath9k_regd_get_ctl(ah, chan), ··· 1482 1464 u32 rst_flags; 1483 1465 u32 tmpReg; 1484 1466 1467 + if (AR_SREV_9100(ah)) { 1468 + u32 val = REG_READ(ah, AR_RTC_DERIVED_CLK); 1469 + val &= ~AR_RTC_DERIVED_CLK_PERIOD; 1470 + val |= SM(1, AR_RTC_DERIVED_CLK_PERIOD); 1471 + REG_WRITE(ah, AR_RTC_DERIVED_CLK, val); 1472 + (void)REG_READ(ah, AR_RTC_DERIVED_CLK); 1473 + } 1474 + 1485 1475 REG_WRITE(ah, AR_RTC_FORCE_WAKE, AR_RTC_FORCE_WAKE_EN | 1486 1476 AR_RTC_FORCE_WAKE_ON_INT); 1487 1477 ··· 1516 1490 udelay(50); 1517 1491 1518 1492 REG_WRITE(ah, AR_RTC_RC, 0); 1519 - if (!ath9k_hw_wait(ah, AR_RTC_RC, AR_RTC_RC_M, 0)) { 1493 + if (!ath9k_hw_wait(ah, AR_RTC_RC, AR_RTC_RC_M, 0, AH_WAIT_TIMEOUT)) { 1520 1494 DPRINTF(ah->ah_sc, ATH_DBG_RESET, 1521 1495 "RTC stuck in MAC reset\n"); 1522 1496 return false; ··· 1539 1513 AR_RTC_FORCE_WAKE_ON_INT); 1540 1514 1541 1515 REG_WRITE(ah, AR_RTC_RESET, 0); 1516 + udelay(2); 1542 1517 REG_WRITE(ah, AR_RTC_RESET, 1); 1543 1518 1544 1519 if (!ath9k_hw_wait(ah, 1545 1520 AR_RTC_STATUS, 1546 1521 AR_RTC_STATUS_M, 1547 - AR_RTC_STATUS_ON)) { 1522 + AR_RTC_STATUS_ON, 1523 + AH_WAIT_TIMEOUT)) { 1548 1524 DPRINTF(ah->ah_sc, ATH_DBG_RESET, "RTC not waking up\n"); 1549 1525 return false; 1550 1526 } ··· 1608 1580 static bool ath9k_hw_chip_reset(struct ath_hw *ah, 1609 1581 struct ath9k_channel *chan) 1610 1582 { 1611 - if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM)) 1583 + if (OLC_FOR_AR9280_20_LATER) { 1584 + if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_POWER_ON)) 1585 + return false; 1586 + } else if (!ath9k_hw_set_reset_reg(ah, ATH9K_RESET_WARM)) 1612 1587 return false; 1613 1588 1614 1589 if (!ath9k_hw_setpower(ah, ATH9K_PM_AWAKE)) ··· 1641 1610 1642 1611 REG_WRITE(ah, AR_PHY_RFBUS_REQ, AR_PHY_RFBUS_REQ_EN); 1643 1612 if (!ath9k_hw_wait(ah, AR_PHY_RFBUS_GRANT, AR_PHY_RFBUS_GRANT_EN, 1644 - AR_PHY_RFBUS_GRANT_EN)) { 1613 + AR_PHY_RFBUS_GRANT_EN, AH_WAIT_TIMEOUT)) { 1645 1614 DPRINTF(ah->ah_sc, ATH_DBG_REG_IO, 1646 1615 "Could not kill baseband RX\n"); 1647 1616 return false; ··· 2832 2801 mask2 |= ATH9K_INT_GTT; 2833 2802 if (isr2 & AR_ISR_S2_CST) 2834 2803 mask2 |= ATH9K_INT_CST; 2804 + if (isr2 & AR_ISR_S2_TSFOOR) 2805 + mask2 |= ATH9K_INT_TSFOOR; 2835 2806 } 2836 2807 2837 2808 isr = REG_READ(ah, AR_ISR_RAC); ··· 2979 2946 if (ints & ATH9K_INT_DTIMSYNC) 2980 2947 mask2 |= AR_IMR_S2_DTIMSYNC; 2981 2948 if (ints & ATH9K_INT_CABEND) 2982 - mask2 |= (AR_IMR_S2_CABEND); 2949 + mask2 |= AR_IMR_S2_CABEND; 2950 + if (ints & ATH9K_INT_TSFOOR) 2951 + mask2 |= AR_IMR_S2_TSFOOR; 2983 2952 } 2984 2953 2985 2954 if (ints & (ATH9K_INT_GTT | ATH9K_INT_CST)) { ··· 3151 3116 AR_TBTT_TIMER_EN | AR_TIM_TIMER_EN | 3152 3117 AR_DTIM_TIMER_EN); 3153 3118 3119 + /* TSF Out of Range Threshold */ 3120 + REG_WRITE(ah, AR_TSFOOR_THRESHOLD, bs->bs_tsfoor_threshold); 3154 3121 } 3155 3122 3156 3123 /*******************/ ··· 3165 3128 u16 capField = 0, eeval; 3166 3129 3167 3130 eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_0); 3168 - 3169 3131 ah->regulatory.current_rd = eeval; 3170 3132 3171 3133 eeval = ah->eep_ops->get_eeprom(ah, EEP_REG_1); 3134 + if (AR_SREV_9285_10_OR_LATER(ah)) 3135 + eeval |= AR9285_RDEXT_DEFAULT; 3172 3136 ah->regulatory.current_rd_ext = eeval; 3173 3137 3174 3138 capField = ah->eep_ops->get_eeprom(ah, EEP_OP_CAP); ··· 3220 3182 } 3221 3183 3222 3184 pCap->tx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_TX_MASK); 3223 - if ((ah->is_pciexpress) 3224 - || (eeval & AR5416_OPFLAGS_11A)) { 3225 - pCap->rx_chainmask = 3226 - ah->eep_ops->get_eeprom(ah, EEP_RX_MASK); 3227 - } else { 3228 - pCap->rx_chainmask = 3229 - (ath9k_hw_gpio_get(ah, 0)) ? 0x5 : 0x7; 3230 - } 3185 + if ((ah->hw_version.devid == AR5416_DEVID_PCI) && 3186 + !(eeval & AR5416_OPFLAGS_11A)) 3187 + pCap->rx_chainmask = ath9k_hw_gpio_get(ah, 0) ? 0x5 : 0x7; 3188 + else 3189 + pCap->rx_chainmask = ah->eep_ops->get_eeprom(ah, EEP_RX_MASK); 3231 3190 3232 3191 if (!(AR_SREV_9280(ah) && (ah->hw_version.macRev == 0))) 3233 3192 ah->misc_mode |= AR_PCU_MIC_NEW_LOC_ENA; ··· 3352 3317 bool ath9k_hw_getcapability(struct ath_hw *ah, enum ath9k_capability_type type, 3353 3318 u32 capability, u32 *result) 3354 3319 { 3355 - const struct ath9k_hw_capabilities *pCap = &ah->caps; 3356 - 3357 3320 switch (type) { 3358 3321 case ATH9K_CAP_CIPHER: 3359 3322 switch (capability) { ··· 3377 3344 case ATH9K_CAP_TKIP_SPLIT: 3378 3345 return (ah->misc_mode & AR_PCU_MIC_NEW_LOC_ENA) ? 3379 3346 false : true; 3380 - case ATH9K_CAP_WME_TKIPMIC: 3381 - return 0; 3382 - case ATH9K_CAP_PHYCOUNTERS: 3383 - return ah->has_hw_phycounters ? 0 : -ENXIO; 3384 3347 case ATH9K_CAP_DIVERSITY: 3385 3348 return (REG_READ(ah, AR_PHY_CCK_DETECT) & 3386 3349 AR_PHY_CCK_DETECT_BB_ENABLE_ANT_FAST_DIV) ? 3387 3350 true : false; 3388 - case ATH9K_CAP_PHYDIAG: 3389 - return true; 3390 3351 case ATH9K_CAP_MCAST_KEYSRCH: 3391 3352 switch (capability) { 3392 3353 case 0: ··· 3395 3368 } 3396 3369 } 3397 3370 return false; 3398 - case ATH9K_CAP_TSF_ADJUST: 3399 - return (ah->misc_mode & AR_PCU_TX_ADD_TSF) ? 3400 - true : false; 3401 - case ATH9K_CAP_RFSILENT: 3402 - if (capability == 3) 3403 - return false; 3404 - case ATH9K_CAP_ANT_CFG_2GHZ: 3405 - *result = pCap->num_antcfg_2ghz; 3406 - return true; 3407 - case ATH9K_CAP_ANT_CFG_5GHZ: 3408 - *result = pCap->num_antcfg_5ghz; 3409 - return true; 3410 3371 case ATH9K_CAP_TXPOW: 3411 3372 switch (capability) { 3412 3373 case 0: ··· 3410 3395 return 0; 3411 3396 } 3412 3397 return false; 3398 + case ATH9K_CAP_DS: 3399 + return (AR_SREV_9280_20_OR_LATER(ah) && 3400 + (ah->eep_ops->get_eeprom(ah, EEP_RC_CHAIN_MASK) == 1)) 3401 + ? false : true; 3413 3402 default: 3414 3403 return false; 3415 3404 } ··· 3446 3427 ah->sta_id1_defaults |= AR_STA_ID1_MCAST_KSRCH; 3447 3428 else 3448 3429 ah->sta_id1_defaults &= ~AR_STA_ID1_MCAST_KSRCH; 3449 - return true; 3450 - case ATH9K_CAP_TSF_ADJUST: 3451 - if (setting) 3452 - ah->misc_mode |= AR_PCU_TX_ADD_TSF; 3453 - else 3454 - ah->misc_mode &= ~AR_PCU_TX_ADD_TSF; 3455 3430 return true; 3456 3431 default: 3457 3432 return false;
+11 -9
drivers/net/wireless/ath9k/hw.h
··· 93 93 #define ATH9K_NUM_QUEUES 10 94 94 95 95 #define MAX_RATE_POWER 63 96 - #define AH_TIMEOUT 100000 96 + #define AH_WAIT_TIMEOUT 100000 /* (us) */ 97 97 #define AH_TIME_QUANTUM 10 98 98 #define AR_KEYTABLE_SIZE 128 99 99 #define POWER_UP_TIME 200000 ··· 153 153 ATH9K_CAP_CIPHER = 0, 154 154 ATH9K_CAP_TKIP_MIC, 155 155 ATH9K_CAP_TKIP_SPLIT, 156 - ATH9K_CAP_PHYCOUNTERS, 157 156 ATH9K_CAP_DIVERSITY, 158 157 ATH9K_CAP_TXPOW, 159 - ATH9K_CAP_PHYDIAG, 160 158 ATH9K_CAP_MCAST_KEYSRCH, 161 - ATH9K_CAP_TSF_ADJUST, 162 - ATH9K_CAP_WME_TKIPMIC, 163 - ATH9K_CAP_RFSILENT, 164 - ATH9K_CAP_ANT_CFG_2GHZ, 165 - ATH9K_CAP_ANT_CFG_5GHZ 159 + ATH9K_CAP_DS 166 160 }; 167 161 168 162 struct ath9k_hw_capabilities { ··· 243 249 ATH9K_INT_DTIMSYNC = 0x00800000, 244 250 ATH9K_INT_GPIO = 0x01000000, 245 251 ATH9K_INT_CABEND = 0x02000000, 252 + ATH9K_INT_TSFOOR = 0x04000000, 246 253 ATH9K_INT_CST = 0x10000000, 247 254 ATH9K_INT_GTT = 0x20000000, 248 255 ATH9K_INT_FATAL = 0x40000000, ··· 251 256 ATH9K_INT_BMISC = ATH9K_INT_TIM | 252 257 ATH9K_INT_DTIM | 253 258 ATH9K_INT_DTIMSYNC | 259 + ATH9K_INT_TSFOOR | 254 260 ATH9K_INT_CABEND, 255 261 ATH9K_INT_COMMON = ATH9K_INT_RXNOFRM | 256 262 ATH9K_INT_RXDESC | ··· 381 385 #define ATH9K_BEACON_PERIOD 0x0000ffff 382 386 #define ATH9K_BEACON_ENA 0x00800000 383 387 #define ATH9K_BEACON_RESET_TSF 0x01000000 388 + #define ATH9K_TSFOOR_THRESHOLD 0x00004240 /* 16k us */ 384 389 u32 bs_dtimperiod; 385 390 u16 bs_cfpperiod; 386 391 u16 bs_cfpmaxduration; ··· 389 392 u16 bs_timoffset; 390 393 u16 bs_bmissthreshold; 391 394 u32 bs_sleepduration; 395 + u32 bs_tsfoor_threshold; 392 396 }; 393 397 394 398 struct chan_centers { ··· 545 547 u8 txchainmask; 546 548 u8 rxchainmask; 547 549 550 + u32 originalGain[22]; 551 + int initPDADC; 552 + int PDADCdelta; 553 + 548 554 struct ar5416IniArray iniModes; 549 555 struct ar5416IniArray iniCommon; 550 556 struct ar5416IniArray iniBank0; ··· 605 603 u8 *antenna_cfgd); 606 604 607 605 /* General Operation */ 608 - bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val); 606 + bool ath9k_hw_wait(struct ath_hw *ah, u32 reg, u32 mask, u32 val, u32 timeout); 609 607 u32 ath9k_hw_reverse_bits(u32 val, u32 n); 610 608 bool ath9k_get_channel_edges(struct ath_hw *ah, u16 flags, u16 *low, u16 *high); 611 609 u16 ath9k_hw_computetxtime(struct ath_hw *ah, struct ath_rate_table *rates,
+24 -6
drivers/net/wireless/ath9k/mac.c
··· 285 285 ds->ds_txstat.ts_shortretry = MS(ads->ds_txstatus1, AR_RTSFailCnt); 286 286 ds->ds_txstat.ts_longretry = MS(ads->ds_txstatus1, AR_DataFailCnt); 287 287 ds->ds_txstat.ts_virtcol = MS(ads->ds_txstatus1, AR_VirtRetryCnt); 288 - ds->ds_txstat.ts_antenna = 1; 288 + ds->ds_txstat.ts_antenna = 0; 289 289 290 290 return 0; 291 291 } ··· 886 886 REG_SET_BIT(ah, AR_DIAG_SW, 887 887 (AR_DIAG_RX_DIS | AR_DIAG_RX_ABORT)); 888 888 889 - if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE, 0)) { 889 + if (!ath9k_hw_wait(ah, AR_OBS_BUS_1, AR_OBS_BUS_1_RX_STATE, 890 + 0, AH_WAIT_TIMEOUT)) { 890 891 REG_CLR_BIT(ah, AR_DIAG_SW, 891 892 (AR_DIAG_RX_DIS | 892 893 AR_DIAG_RX_ABORT)); ··· 934 933 935 934 bool ath9k_hw_stopdmarecv(struct ath_hw *ah) 936 935 { 936 + #define AH_RX_STOP_DMA_TIMEOUT 10000 /* usec */ 937 + #define AH_RX_TIME_QUANTUM 100 /* usec */ 938 + 939 + int i; 940 + 937 941 REG_WRITE(ah, AR_CR, AR_CR_RXD); 938 942 939 - if (!ath9k_hw_wait(ah, AR_CR, AR_CR_RXE, 0)) { 943 + /* Wait for rx enable bit to go low */ 944 + for (i = AH_RX_STOP_DMA_TIMEOUT / AH_TIME_QUANTUM; i != 0; i--) { 945 + if ((REG_READ(ah, AR_CR) & AR_CR_RXE) == 0) 946 + break; 947 + udelay(AH_TIME_QUANTUM); 948 + } 949 + 950 + if (i == 0) { 940 951 DPRINTF(ah->ah_sc, ATH_DBG_QUEUE, 941 - "dma failed to stop in 10ms\n" 942 - "AR_CR=0x%08x\nAR_DIAG_SW=0x%08x\n", 943 - REG_READ(ah, AR_CR), REG_READ(ah, AR_DIAG_SW)); 952 + "dma failed to stop in %d ms " 953 + "AR_CR=0x%08x AR_DIAG_SW=0x%08x\n", 954 + AH_RX_STOP_DMA_TIMEOUT / 1000, 955 + REG_READ(ah, AR_CR), 956 + REG_READ(ah, AR_DIAG_SW)); 944 957 return false; 945 958 } else { 946 959 return true; 947 960 } 961 + 962 + #undef AH_RX_TIME_QUANTUM 963 + #undef AH_RX_STOP_DMA_TIMEOUT 948 964 }
+2 -1
drivers/net/wireless/ath9k/mac.h
··· 566 566 ATH9K_RX_FILTER_BEACON = 0x00000010, 567 567 ATH9K_RX_FILTER_PROM = 0x00000020, 568 568 ATH9K_RX_FILTER_PROBEREQ = 0x00000080, 569 - ATH9K_RX_FILTER_PSPOLL = 0x00004000, 570 569 ATH9K_RX_FILTER_PHYERR = 0x00000100, 570 + ATH9K_RX_FILTER_MYBEACON = 0x00000200, 571 + ATH9K_RX_FILTER_PSPOLL = 0x00004000, 571 572 ATH9K_RX_FILTER_PHYRADAR = 0x00002000, 572 573 }; 573 574
+39 -33
drivers/net/wireless/ath9k/main.c
··· 308 308 */ 309 309 static void ath_ani_calibrate(unsigned long data) 310 310 { 311 - struct ath_softc *sc; 312 - struct ath_hw *ah; 311 + struct ath_softc *sc = (struct ath_softc *)data; 312 + struct ath_hw *ah = sc->sc_ah; 313 313 bool longcal = false; 314 314 bool shortcal = false; 315 315 bool aniflag = false; 316 316 unsigned int timestamp = jiffies_to_msecs(jiffies); 317 - u32 cal_interval; 317 + u32 cal_interval, short_cal_interval; 318 318 319 - sc = (struct ath_softc *)data; 320 - ah = sc->sc_ah; 319 + short_cal_interval = (ah->opmode == NL80211_IFTYPE_AP) ? 320 + ATH_AP_SHORT_CALINTERVAL : ATH_STA_SHORT_CALINTERVAL; 321 321 322 322 /* 323 323 * don't calibrate when we're scanning. 324 324 * we are most likely not on our home channel. 325 325 */ 326 326 if (sc->rx.rxfilter & FIF_BCN_PRBRESP_PROMISC) 327 - return; 327 + goto set_timer; 328 328 329 329 /* Long calibration runs independently of short calibration. */ 330 330 if ((timestamp - sc->ani.longcal_timer) >= ATH_LONG_CALINTERVAL) { ··· 335 335 336 336 /* Short calibration applies only while caldone is false */ 337 337 if (!sc->ani.caldone) { 338 - if ((timestamp - sc->ani.shortcal_timer) >= 339 - ATH_SHORT_CALINTERVAL) { 338 + if ((timestamp - sc->ani.shortcal_timer) >= short_cal_interval) { 340 339 shortcal = true; 341 340 DPRINTF(sc, ATH_DBG_ANI, "shortcal @%lu\n", jiffies); 342 341 sc->ani.shortcal_timer = timestamp; ··· 351 352 } 352 353 353 354 /* Verify whether we must check ANI */ 354 - if ((timestamp - sc->ani.checkani_timer) >= 355 - ATH_ANI_POLLINTERVAL) { 355 + if ((timestamp - sc->ani.checkani_timer) >= ATH_ANI_POLLINTERVAL) { 356 356 aniflag = true; 357 357 sc->ani.checkani_timer = timestamp; 358 358 } ··· 360 362 if (longcal || shortcal || aniflag) { 361 363 /* Call ANI routine if necessary */ 362 364 if (aniflag) 363 - ath9k_hw_ani_monitor(ah, &sc->nodestats, 364 - ah->curchan); 365 + ath9k_hw_ani_monitor(ah, &sc->nodestats, ah->curchan); 365 366 366 367 /* Perform calibration if necessary */ 367 368 if (longcal || shortcal) { ··· 389 392 } 390 393 } 391 394 395 + set_timer: 392 396 /* 393 397 * Set timer interval based on previous results. 394 398 * The interval must be the shortest necessary to satisfy ANI, ··· 399 401 if (sc->sc_ah->config.enable_ani) 400 402 cal_interval = min(cal_interval, (u32)ATH_ANI_POLLINTERVAL); 401 403 if (!sc->ani.caldone) 402 - cal_interval = min(cal_interval, (u32)ATH_SHORT_CALINTERVAL); 404 + cal_interval = min(cal_interval, (u32)short_cal_interval); 403 405 404 406 mod_timer(&sc->ani.timer, jiffies + msecs_to_jiffies(cal_interval)); 405 407 } ··· 571 573 sched = true; 572 574 sc->sc_flags |= SC_OP_WAIT_FOR_BEACON; 573 575 } 576 + } 577 + if (status & ATH9K_INT_TSFOOR) { 578 + /* FIXME: Handle this interrupt for power save */ 579 + sched = true; 574 580 } 575 581 } 576 582 } while (0); ··· 922 920 923 921 /* Start ANI */ 924 922 mod_timer(&sc->ani.timer, 925 - jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL)); 926 - 923 + jiffies + msecs_to_jiffies(ATH_ANI_POLLINTERVAL)); 927 924 } else { 928 925 DPRINTF(sc, ATH_DBG_CONFIG, "Bss Info DISSOC\n"); 929 926 sc->curaid = 0; ··· 1567 1566 int ath_attach(u16 devid, struct ath_softc *sc) 1568 1567 { 1569 1568 struct ieee80211_hw *hw = sc->hw; 1569 + const struct ieee80211_regdomain *regd; 1570 1570 int error = 0, i; 1571 1571 1572 1572 DPRINTF(sc, ATH_DBG_CONFIG, "Attach ATH hw\n"); ··· 1600 1598 1601 1599 hw->queues = 4; 1602 1600 hw->max_rates = 4; 1601 + hw->channel_change_time = 5000; 1603 1602 hw->max_rate_tries = ATH_11N_TXMAXTRY; 1604 1603 hw->sta_data_size = sizeof(struct ath_node); 1605 1604 hw->vif_data_size = sizeof(struct ath_vif); ··· 1639 1636 #endif 1640 1637 1641 1638 if (ath9k_is_world_regd(sc->sc_ah)) { 1642 - /* Anything applied here (prior to wiphy registratoin) gets 1639 + /* Anything applied here (prior to wiphy registration) gets 1643 1640 * saved on the wiphy orig_* parameters */ 1644 - const struct ieee80211_regdomain *regd = 1645 - ath9k_world_regdomain(sc->sc_ah); 1641 + regd = ath9k_world_regdomain(sc->sc_ah); 1646 1642 hw->wiphy->custom_regulatory = true; 1647 1643 hw->wiphy->strict_regulatory = false; 1648 - wiphy_apply_custom_regulatory(sc->hw->wiphy, regd); 1649 - ath9k_reg_apply_radar_flags(hw->wiphy); 1650 - ath9k_reg_apply_world_flags(hw->wiphy, REGDOM_SET_BY_INIT); 1651 1644 } else { 1652 1645 /* This gets applied in the case of the absense of CRDA, 1653 - * its our own custom world regulatory domain, similar to 1646 + * it's our own custom world regulatory domain, similar to 1654 1647 * cfg80211's but we enable passive scanning */ 1655 - const struct ieee80211_regdomain *regd = 1656 - ath9k_default_world_regdomain(); 1657 - wiphy_apply_custom_regulatory(sc->hw->wiphy, regd); 1658 - ath9k_reg_apply_radar_flags(hw->wiphy); 1659 - ath9k_reg_apply_world_flags(hw->wiphy, REGDOM_SET_BY_INIT); 1648 + regd = ath9k_default_world_regdomain(); 1660 1649 } 1650 + wiphy_apply_custom_regulatory(hw->wiphy, regd); 1651 + ath9k_reg_apply_radar_flags(hw->wiphy); 1652 + ath9k_reg_apply_world_flags(hw->wiphy, REGDOM_SET_BY_INIT); 1661 1653 1662 1654 error = ieee80211_register_hw(hw); 1663 1655 1664 - if (!ath9k_is_world_regd(sc->sc_ah)) 1665 - regulatory_hint(hw->wiphy, sc->sc_ah->regulatory.alpha2); 1656 + if (!ath9k_is_world_regd(sc->sc_ah)) { 1657 + error = regulatory_hint(hw->wiphy, 1658 + sc->sc_ah->regulatory.alpha2); 1659 + if (error) 1660 + goto error_attach; 1661 + } 1666 1662 1667 1663 /* Initialize LED control */ 1668 1664 ath_init_leds(sc); ··· 2145 2143 default: 2146 2144 DPRINTF(sc, ATH_DBG_FATAL, 2147 2145 "Interface type %d not yet supported\n", conf->type); 2146 + mutex_unlock(&sc->mutex); 2148 2147 return -EOPNOTSUPP; 2149 2148 } 2150 2149 ··· 2168 2165 * Enable MIB interrupts when there are hardware phy counters. 2169 2166 * Note we only do this (at the moment) for station mode. 2170 2167 */ 2171 - if (ath9k_hw_phycounters(sc->sc_ah) && 2172 - ((conf->type == NL80211_IFTYPE_STATION) || 2173 - (conf->type == NL80211_IFTYPE_ADHOC))) 2174 - sc->imask |= ATH9K_INT_MIB; 2168 + if ((conf->type == NL80211_IFTYPE_STATION) || 2169 + (conf->type == NL80211_IFTYPE_ADHOC)) { 2170 + if (ath9k_hw_phycounters(sc->sc_ah)) 2171 + sc->imask |= ATH9K_INT_MIB; 2172 + sc->imask |= ATH9K_INT_TSFOOR; 2173 + } 2174 + 2175 2175 /* 2176 2176 * Some hardware processes the TIM IE and fires an 2177 2177 * interrupt when the TIM bit is set. For hardware
+4 -3
drivers/net/wireless/ath9k/pci.c
··· 52 52 struct pci_dev *pdev = to_pci_dev(sc->dev); 53 53 54 54 pci_iounmap(pdev, sc->mem); 55 - pci_release_region(pdev, 0); 56 55 pci_disable_device(pdev); 56 + pci_release_region(pdev, 0); 57 57 } 58 58 59 59 static bool ath_pci_eeprom_read(struct ath_hw *ah, u32 off, u16 *data) ··· 63 63 if (!ath9k_hw_wait(ah, 64 64 AR_EEPROM_STATUS_DATA, 65 65 AR_EEPROM_STATUS_DATA_BUSY | 66 - AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0)) { 66 + AR_EEPROM_STATUS_DATA_PROT_ACCESS, 0, 67 + AH_WAIT_TIMEOUT)) { 67 68 return false; 68 69 } 69 70 ··· 293 292 #endif /* CONFIG_PM */ 294 293 }; 295 294 296 - int __init ath_pci_init(void) 295 + int ath_pci_init(void) 297 296 { 298 297 return pci_register_driver(&ath_pci_driver); 299 298 }
+13 -6
drivers/net/wireless/ath9k/phy.c
··· 132 132 bMode = 0; 133 133 fracMode = 0; 134 134 135 - if ((freq % 20) == 0) { 136 - aModeRefSel = 3; 137 - } else if ((freq % 10) == 0) { 138 - aModeRefSel = 2; 139 - } else { 135 + switch(ah->eep_ops->get_eeprom(ah, EEP_FRAC_N_5G)) { 136 + case 0: 137 + if ((freq % 20) == 0) { 138 + aModeRefSel = 3; 139 + } else if ((freq % 10) == 0) { 140 + aModeRefSel = 2; 141 + } 142 + if (aModeRefSel) 143 + break; 144 + case 1: 145 + default: 140 146 aModeRefSel = 0; 141 - 142 147 fracMode = 1; 143 148 refDivA = 1; 144 149 channelSel = (freq * 0x8000) / 15; 145 150 146 151 REG_RMW_FIELD(ah, AR_AN_SYNTH9, 147 152 AR_AN_SYNTH9_REFDIVA, refDivA); 153 + 148 154 } 155 + 149 156 if (!fracMode) { 150 157 ndiv = (freq * (refDivA >> aModeRefSel)) / 60; 151 158 channelSel = ndiv & 0x1ff;
+29
drivers/net/wireless/ath9k/phy.h
··· 387 387 388 388 #define AR_PHY_CCK_TX_CTRL 0xA204 389 389 #define AR_PHY_CCK_TX_CTRL_JAPAN 0x00000010 390 + #define AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK 0x0000000C 391 + #define AR_PHY_CCK_TX_CTRL_TX_DAC_SCALE_CCK_S 2 390 392 391 393 #define AR_PHY_CCK_DETECT 0xA208 392 394 #define AR_PHY_CCK_DETECT_WEAK_SIG_THR_CCK 0x0000003F ··· 446 444 #define AR_PHY_TPCRG1_PD_GAIN_3 0x00300000 447 445 #define AR_PHY_TPCRG1_PD_GAIN_3_S 20 448 446 447 + #define AR_PHY_TX_PWRCTRL4 0xa264 448 + #define AR_PHY_TX_PWRCTRL_PD_AVG_VALID 0x00000001 449 + #define AR_PHY_TX_PWRCTRL_PD_AVG_VALID_S 0 450 + #define AR_PHY_TX_PWRCTRL_PD_AVG_OUT 0x000001FE 451 + #define AR_PHY_TX_PWRCTRL_PD_AVG_OUT_S 1 452 + 453 + #define AR_PHY_TX_PWRCTRL6_0 0xa270 454 + #define AR_PHY_TX_PWRCTRL6_1 0xb270 455 + #define AR_PHY_TX_PWRCTRL_ERR_EST_MODE 0x03000000 456 + #define AR_PHY_TX_PWRCTRL_ERR_EST_MODE_S 24 457 + 458 + #define AR_PHY_TX_PWRCTRL7 0xa274 459 + #define AR_PHY_TX_PWRCTRL_INIT_TX_GAIN 0x01F80000 460 + #define AR_PHY_TX_PWRCTRL_INIT_TX_GAIN_S 19 461 + 462 + #define AR_PHY_TX_PWRCTRL9 0xa27C 463 + #define AR_PHY_TX_DESIRED_SCALE_CCK 0x00007C00 464 + #define AR_PHY_TX_DESIRED_SCALE_CCK_S 10 465 + 466 + #define AR_PHY_TX_GAIN_TBL1 0xa300 467 + #define AR_PHY_TX_GAIN 0x0007F000 468 + #define AR_PHY_TX_GAIN_S 12 469 + 449 470 #define AR_PHY_VIT_MASK2_M_46_61 0xa3a0 450 471 #define AR_PHY_MASK2_M_31_45 0xa3a4 451 472 #define AR_PHY_MASK2_M_16_30 0xa3a8 ··· 509 484 #define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_3_S 16 510 485 #define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_4 0x0FC00000 511 486 #define AR_PHY_TPCRG5_PD_GAIN_BOUNDARY_4_S 22 487 + 488 + /* Carrier leak calibration control, do it after AGC calibration */ 489 + #define AR_PHY_CL_CAL_CTL 0xA358 490 + #define AR_PHY_CL_CAL_ENABLE 0x00000002 512 491 513 492 #define AR_PHY_POWER_TX_RATE5 0xA38C 514 493 #define AR_PHY_POWER_TX_RATE6 0xA390
+7 -3
drivers/net/wireless/ath9k/rc.c
··· 1267 1267 ath_rc_priv->per_down_time = now_msec; 1268 1268 } 1269 1269 1270 - ath_debug_stat_retries(sc, tx_rate, xretries, retries); 1270 + ath_debug_stat_retries(sc, tx_rate, xretries, retries, 1271 + ath_rc_priv->state[tx_rate].per); 1271 1272 1272 1273 #undef CHK_RSSI 1273 1274 } ··· 1393 1392 struct ath_rateset *rateset = &ath_rc_priv->neg_rates; 1394 1393 u8 *ht_mcs = (u8 *)&ath_rc_priv->neg_ht_rates; 1395 1394 u8 i, j, k, hi = 0, hthi = 0; 1395 + struct ath_hw *ah = sc->sc_ah; 1396 1396 1397 1397 /* FIXME: Adhoc */ 1398 1398 if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) || ··· 1414 1412 1415 1413 if (sta->ht_cap.ht_supported) { 1416 1414 ath_rc_priv->ht_cap = WLAN_RC_HT_FLAG; 1417 - if (sc->sc_ah->caps.tx_chainmask != 1) 1415 + if (sc->sc_ah->caps.tx_chainmask != 1 && 1416 + ath9k_hw_getcapability(ah, ATH9K_CAP_DS, 0, NULL)) 1418 1417 ath_rc_priv->ht_cap |= WLAN_RC_DS_FLAG; 1419 1418 if (sta->ht_cap.cap & IEEE80211_HT_CAP_SUP_WIDTH_20_40) 1420 1419 ath_rc_priv->ht_cap |= WLAN_RC_40_FLAG; ··· 1536 1533 tx_info_priv->tx.ts_longretry); 1537 1534 1538 1535 /* Check if aggregation has to be enabled for this tid */ 1539 - if (conf_is_ht(&sc->hw->conf)) { 1536 + if (conf_is_ht(&sc->hw->conf) && 1537 + !(skb->protocol == cpu_to_be16(ETH_P_PAE))) { 1540 1538 if (ieee80211_is_data_qos(fc)) { 1541 1539 u8 *qc, tid; 1542 1540 struct ath_node *an;
+6 -6
drivers/net/wireless/ath9k/recv.c
··· 375 375 if (sc->rx.rxfilter & FIF_CONTROL) 376 376 rfilt |= ATH9K_RX_FILTER_CONTROL; 377 377 378 - if (sc->sc_ah->opmode == NL80211_IFTYPE_STATION || 379 - sc->sc_ah->opmode == NL80211_IFTYPE_ADHOC) 378 + if ((sc->sc_ah->opmode == NL80211_IFTYPE_STATION) && 379 + !(sc->rx.rxfilter & FIF_BCN_PRBRESP_PROMISC)) 380 + rfilt |= ATH9K_RX_FILTER_MYBEACON; 381 + else 380 382 rfilt |= ATH9K_RX_FILTER_BEACON; 381 383 382 - /* If in HOSTAP mode, want to enable reception of PSPOLL frames 383 - & beacon frames */ 384 + /* If in HOSTAP mode, want to enable reception of PSPOLL frames */ 384 385 if (sc->sc_ah->opmode == NL80211_IFTYPE_AP) 385 - rfilt |= (ATH9K_RX_FILTER_BEACON | ATH9K_RX_FILTER_PSPOLL); 386 + rfilt |= ATH9K_RX_FILTER_PSPOLL; 386 387 387 388 return rfilt; 388 389 ··· 428 427 ath9k_hw_stoppcurecv(ah); 429 428 ath9k_hw_setrxfilter(ah, 0); 430 429 stopped = ath9k_hw_stopdmarecv(ah); 431 - mdelay(3); /* 3ms is long enough for 1 frame */ 432 430 sc->rx.rxlink = NULL; 433 431 434 432 return stopped;
+8 -4
drivers/net/wireless/ath9k/reg.h
··· 977 977 #define AR_RTC_PLL_CLKSEL 0x00000300 978 978 #define AR_RTC_PLL_CLKSEL_S 8 979 979 980 - 981 - 982 980 #define AR_RTC_RESET \ 983 981 ((AR_SREV_9100(ah)) ? (AR_RTC_BASE + 0x0040) : 0x7040) 984 982 #define AR_RTC_RESET_EN (0x00000001) ··· 1012 1014 1013 1015 #define AR_RTC_INTR_MASK \ 1014 1016 ((AR_SREV_9100(ah)) ? (AR_RTC_BASE + 0x0058) : 0x7058) 1017 + 1018 + /* RTC_DERIVED_* - only for AR9100 */ 1019 + 1020 + #define AR_RTC_DERIVED_CLK (AR_RTC_BASE + 0x0038) 1021 + #define AR_RTC_DERIVED_CLK_PERIOD 0x0000fffe 1022 + #define AR_RTC_DERIVED_CLK_PERIOD_S 1 1015 1023 1016 1024 #define AR_SEQ_MASK 0x8060 1017 1025 ··· 1389 1385 #define AR_PHY_COUNTMAX (3 << 22) 1390 1386 #define AR_MIBCNT_INTRMASK (3 << 22) 1391 1387 1392 - #define AR_TSF_THRESHOLD 0x813c 1393 - #define AR_TSF_THRESHOLD_VAL 0x0000FFFF 1388 + #define AR_TSFOOR_THRESHOLD 0x813c 1389 + #define AR_TSFOOR_THRESHOLD_VAL 0x0000FFFF 1394 1390 1395 1391 #define AR_PHY_ERR_EIFS_MASK 8144 1396 1392
+76 -49
drivers/net/wireless/ath9k/regd.c
··· 106 106 } 107 107 }; 108 108 109 + static inline bool is_wwr_sku(u16 regd) 110 + { 111 + return ((regd & WORLD_SKU_MASK) == WORLD_SKU_PREFIX) || 112 + (regd == WORLD); 113 + } 114 + 109 115 static u16 ath9k_regd_get_eepromRD(struct ath_hw *ah) 110 116 { 111 117 return ah->regulatory.current_rd & ~WORLDWIDE_ROAMING_FLAG; 112 118 } 113 119 114 - u16 ath9k_regd_get_rd(struct ath_hw *ah) 115 - { 116 - return ath9k_regd_get_eepromRD(ah); 117 - } 118 - 119 120 bool ath9k_is_world_regd(struct ath_hw *ah) 120 121 { 121 - return isWwrSKU(ah); 122 + return is_wwr_sku(ath9k_regd_get_eepromRD(ah)); 122 123 } 123 124 124 125 const struct ieee80211_regdomain *ath9k_default_world_regdomain(void) ··· 160 159 } 161 160 162 161 /* 163 - * Enable adhoc on 5 GHz if allowed by 11d. 164 - * Remove passive scan if channel is allowed by 11d, 165 - * except when on radar frequencies. 162 + * N.B: These exception rules do not apply radar freqs. 163 + * 164 + * - We enable adhoc (or beaconing) if allowed by 11d 165 + * - We enable active scan if the channel is allowed by 11d 166 + * - If no country IE has been processed and a we determine we have 167 + * received a beacon on a channel we can enable active scan and 168 + * adhoc (or beaconing). 166 169 */ 167 - static void ath9k_reg_apply_5ghz_beaconing_flags(struct wiphy *wiphy, 170 + static void ath9k_reg_apply_beaconing_flags(struct wiphy *wiphy, 168 171 enum reg_set_by setby) 169 172 { 173 + enum ieee80211_band band; 170 174 struct ieee80211_supported_band *sband; 171 175 const struct ieee80211_reg_rule *reg_rule; 172 176 struct ieee80211_channel *ch; ··· 179 173 u32 bandwidth = 0; 180 174 int r; 181 175 182 - if (setby != REGDOM_SET_BY_COUNTRY_IE) 183 - return; 184 - if (!wiphy->bands[IEEE80211_BAND_5GHZ]) 185 - return; 176 + for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 186 177 187 - sband = wiphy->bands[IEEE80211_BAND_5GHZ]; 188 - for (i = 0; i < sband->n_channels; i++) { 189 - ch = &sband->channels[i]; 190 - r = freq_reg_info(wiphy, ch->center_freq, 191 - &bandwidth, &reg_rule); 192 - if (r) 178 + if (!wiphy->bands[band]) 193 179 continue; 194 - /* If 11d had a rule for this channel ensure we enable adhoc 195 - * if it allows us to use it. Note that we would have disabled 196 - * it by applying our static world regdomain by default during 197 - * probe */ 198 - if (!(reg_rule->flags & NL80211_RRF_NO_IBSS)) 199 - ch->flags &= ~IEEE80211_CHAN_NO_IBSS; 200 - if (!ath9k_is_radar_freq(ch->center_freq)) 201 - continue; 202 - if (!(reg_rule->flags & NL80211_RRF_PASSIVE_SCAN)) 203 - ch->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; 180 + 181 + sband = wiphy->bands[band]; 182 + 183 + for (i = 0; i < sband->n_channels; i++) { 184 + 185 + ch = &sband->channels[i]; 186 + 187 + if (ath9k_is_radar_freq(ch->center_freq) || 188 + (ch->flags & IEEE80211_CHAN_RADAR)) 189 + continue; 190 + 191 + if (setby == REGDOM_SET_BY_COUNTRY_IE) { 192 + r = freq_reg_info(wiphy, ch->center_freq, 193 + &bandwidth, &reg_rule); 194 + if (r) 195 + continue; 196 + /* 197 + * If 11d had a rule for this channel ensure 198 + * we enable adhoc/beaconing if it allows us to 199 + * use it. Note that we would have disabled it 200 + * by applying our static world regdomain by 201 + * default during init, prior to calling our 202 + * regulatory_hint(). 203 + */ 204 + if (!(reg_rule->flags & 205 + NL80211_RRF_NO_IBSS)) 206 + ch->flags &= 207 + ~IEEE80211_CHAN_NO_IBSS; 208 + if (!(reg_rule->flags & 209 + NL80211_RRF_PASSIVE_SCAN)) 210 + ch->flags &= 211 + ~IEEE80211_CHAN_PASSIVE_SCAN; 212 + } else { 213 + if (ch->beacon_found) 214 + ch->flags &= ~(IEEE80211_CHAN_NO_IBSS | 215 + IEEE80211_CHAN_PASSIVE_SCAN); 216 + } 217 + } 204 218 } 219 + 205 220 } 206 221 207 222 /* Allows active scan scan on Ch 12 and 13 */ ··· 235 208 u32 bandwidth = 0; 236 209 int r; 237 210 238 - /* Force passive scan on Channels 12-13 */ 239 211 sband = wiphy->bands[IEEE80211_BAND_2GHZ]; 240 212 241 - /* If no country IE has been received always enable active scan 242 - * on these channels */ 213 + /* 214 + * If no country IE has been received always enable active scan 215 + * on these channels. This is only done for specific regulatory SKUs 216 + */ 243 217 if (setby != REGDOM_SET_BY_COUNTRY_IE) { 244 218 ch = &sband->channels[11]; /* CH 12 */ 245 219 if (ch->flags & IEEE80211_CHAN_PASSIVE_SCAN) ··· 251 223 return; 252 224 } 253 225 254 - /* If a country IE has been recieved check its rule for this 226 + /* 227 + * If a country IE has been recieved check its rule for this 255 228 * channel first before enabling active scan. The passive scan 256 - * would have been enforced by the initial probe processing on 257 - * our custom regulatory domain. */ 229 + * would have been enforced by the initial processing of our 230 + * custom regulatory domain. 231 + */ 258 232 259 233 ch = &sband->channels[11]; /* CH 12 */ 260 234 r = freq_reg_info(wiphy, ch->center_freq, &bandwidth, &reg_rule); ··· 319 289 case 0x63: 320 290 case 0x66: 321 291 case 0x67: 322 - ath9k_reg_apply_5ghz_beaconing_flags(wiphy, setby); 292 + ath9k_reg_apply_beaconing_flags(wiphy, setby); 323 293 break; 324 294 case 0x68: 325 - ath9k_reg_apply_5ghz_beaconing_flags(wiphy, setby); 295 + ath9k_reg_apply_beaconing_flags(wiphy, setby); 326 296 ath9k_reg_apply_active_scan_flags(wiphy, setby); 327 297 break; 328 298 } ··· 401 371 } 402 372 403 373 /* Returns the map of the EEPROM set RD to a country code */ 404 - static u16 ath9k_regd_get_default_country(struct ath_hw *ah) 374 + static u16 ath9k_regd_get_default_country(u16 rd) 405 375 { 406 - u16 rd; 407 - 408 - rd = ath9k_regd_get_eepromRD(ah); 409 376 if (rd & COUNTRY_ERD_FLAG) { 410 377 struct country_code_to_enum_rd *country = NULL; 411 378 u16 cc = rd & ~COUNTRY_ERD_FLAG; ··· 432 405 int ath9k_regd_init(struct ath_hw *ah) 433 406 { 434 407 struct country_code_to_enum_rd *country = NULL; 435 - int regdmn; 408 + u16 regdmn; 436 409 437 410 if (!ath9k_regd_is_eeprom_valid(ah)) { 438 411 DPRINTF(ah->ah_sc, ATH_DBG_REGULATORY, ··· 440 413 return -EINVAL; 441 414 } 442 415 443 - ah->regulatory.country_code = ath9k_regd_get_default_country(ah); 416 + regdmn = ath9k_regd_get_eepromRD(ah); 417 + ah->regulatory.country_code = ath9k_regd_get_default_country(regdmn); 444 418 445 419 if (ah->regulatory.country_code == CTRY_DEFAULT && 446 - ath9k_regd_get_eepromRD(ah) == CTRY_DEFAULT) 420 + regdmn == CTRY_DEFAULT) 447 421 ah->regulatory.country_code = CTRY_UNITED_STATES; 448 422 449 423 if (ah->regulatory.country_code == CTRY_DEFAULT) { 450 - regdmn = ath9k_regd_get_eepromRD(ah); 451 424 country = NULL; 452 425 } else { 453 426 country = ath9k_regd_find_country(ah->regulatory.country_code); ··· 460 433 regdmn = country->regDmnEnum; 461 434 } 462 435 463 - ah->regulatory.current_rd_inuse = regdmn; 464 436 ah->regulatory.regpair = ath9k_get_regpair(regdmn); 465 437 466 438 if (!ah->regulatory.regpair) { ··· 493 467 u32 ctl = NO_CTL; 494 468 495 469 if (!ah->regulatory.regpair || 496 - (ah->regulatory.country_code == CTRY_DEFAULT && isWwrSKU(ah))) { 470 + (ah->regulatory.country_code == CTRY_DEFAULT && 471 + is_wwr_sku(ath9k_regd_get_eepromRD(ah)))) { 497 472 if (IS_CHAN_B(chan)) 498 473 ctl = SD_NO_CTL | CTL_11B; 499 474 else if (IS_CHAN_G(chan)) ··· 507 480 if (IS_CHAN_B(chan)) 508 481 ctl = ah->regulatory.regpair->reg_2ghz_ctl | CTL_11B; 509 482 else if (IS_CHAN_G(chan)) 510 - ctl = ah->regulatory.regpair->reg_5ghz_ctl | CTL_11G; 483 + ctl = ah->regulatory.regpair->reg_2ghz_ctl | CTL_11G; 511 484 else 512 485 ctl = ah->regulatory.regpair->reg_5ghz_ctl | CTL_11A; 513 486
-9
drivers/net/wireless/ath9k/regd.h
··· 20 20 #define COUNTRY_ERD_FLAG 0x8000 21 21 #define WORLDWIDE_ROAMING_FLAG 0x4000 22 22 23 - #define isWwrSKU(_ah) \ 24 - (((ath9k_regd_get_eepromRD((_ah)) & WORLD_SKU_MASK) == \ 25 - WORLD_SKU_PREFIX) || \ 26 - (ath9k_regd_get_eepromRD(_ah) == WORLD)) 27 - 28 23 #define MULTI_DOMAIN_MASK 0xFF00 29 24 30 25 #define WORLD_SKU_MASK 0x00F0 ··· 47 52 u32 tp_scale; 48 53 u16 current_rd; 49 54 u16 current_rd_ext; 50 - u16 current_rd_inuse; 51 55 int16_t power_limit; 52 56 struct reg_dmn_pair_mapping *regpair; 53 57 }; ··· 233 239 CTRY_BELGIUM2 = 5002 234 240 }; 235 241 236 - u16 ath9k_regd_get_rd(struct ath_hw *ah); 237 242 bool ath9k_is_world_regd(struct ath_hw *ah); 238 243 const struct ieee80211_regdomain *ath9k_world_regdomain(struct ath_hw *ah); 239 244 const struct ieee80211_regdomain *ath9k_default_world_regdomain(void); ··· 242 249 bool ath9k_regd_is_eeprom_valid(struct ath_hw *ah); 243 250 u32 ath9k_regd_get_ctl(struct ath_hw *ah, struct ath9k_channel *chan); 244 251 int ath9k_reg_notifier(struct wiphy *wiphy, struct regulatory_request *request); 245 - void ath9k_regd_get_current_country(struct ath_hw *ah, 246 - struct ath9k_country_entry *ctry); 247 252 248 253 #endif
+4 -24
drivers/net/wireless/ath9k/xmit.c
··· 772 772 /* Queue Management */ 773 773 /********************/ 774 774 775 - static u32 ath_txq_depth(struct ath_softc *sc, int qnum) 776 - { 777 - return sc->tx.txq[qnum].axq_depth; 778 - } 779 - 780 - static void ath_get_beaconconfig(struct ath_softc *sc, int if_id, 781 - struct ath_beacon_config *conf) 782 - { 783 - struct ieee80211_hw *hw = sc->hw; 784 - 785 - /* fill in beacon config data */ 786 - 787 - conf->beacon_interval = hw->conf.beacon_int; 788 - conf->listen_interval = 100; 789 - conf->dtim_count = 1; 790 - conf->bmiss_timeout = ATH_DEFAULT_BMISS_LIMIT * conf->listen_interval; 791 - } 792 - 793 775 static void ath_txq_drain_pending_buffers(struct ath_softc *sc, 794 776 struct ath_txq *txq) 795 777 { ··· 946 964 { 947 965 struct ath9k_tx_queue_info qi; 948 966 int qnum = sc->beacon.cabq->axq_qnum; 949 - struct ath_beacon_config conf; 950 967 951 968 ath9k_hw_get_txq_props(sc->sc_ah, qnum, &qi); 952 969 /* ··· 956 975 else if (sc->config.cabqReadytime > ATH9K_READY_TIME_HI_BOUND) 957 976 sc->config.cabqReadytime = ATH9K_READY_TIME_HI_BOUND; 958 977 959 - ath_get_beaconconfig(sc, ATH_IF_ID_ANY, &conf); 960 - qi.tqi_readyTime = 961 - (conf.beacon_interval * sc->config.cabqReadytime) / 100; 978 + qi.tqi_readyTime = (sc->hw->conf.beacon_int * 979 + sc->config.cabqReadytime) / 100; 962 980 ath_txq_update(sc, qnum, &qi); 963 981 964 982 return 0; ··· 1637 1657 * we will at least have to run TX completionon one buffer 1638 1658 * on the queue */ 1639 1659 spin_lock_bh(&txq->axq_lock); 1640 - if (ath_txq_depth(sc, txq->axq_qnum) > 1) { 1660 + if (sc->tx.txq[txq->axq_qnum].axq_depth > 1) { 1641 1661 ieee80211_stop_queue(sc->hw, 1642 1662 skb_get_queue_mapping(skb)); 1643 1663 txq->stopped = 1; ··· 1847 1867 1848 1868 spin_lock_bh(&txq->axq_lock); 1849 1869 if (txq->stopped && 1850 - ath_txq_depth(sc, txq->axq_qnum) <= (ATH_TXBUF - 20)) { 1870 + sc->tx.txq[txq->axq_qnum].axq_depth <= (ATH_TXBUF - 20)) { 1851 1871 qnum = ath_get_mac80211_qnum(txq->axq_qnum, sc); 1852 1872 if (qnum != -1) { 1853 1873 ieee80211_wake_queue(sc->hw, qnum);
+2 -2
drivers/net/wireless/b43/debugfs.c
··· 51 51 }; 52 52 53 53 static inline 54 - struct b43_dfs_file * fops_to_dfs_file(struct b43_wldev *dev, 55 - const struct b43_debugfs_fops *dfops) 54 + struct b43_dfs_file *fops_to_dfs_file(struct b43_wldev *dev, 55 + const struct b43_debugfs_fops *dfops) 56 56 { 57 57 void *p; 58 58
+36 -28
drivers/net/wireless/b43/dma.c
··· 41 41 #include <asm/div64.h> 42 42 43 43 44 + /* Required number of TX DMA slots per TX frame. 45 + * This currently is 2, because we put the header and the ieee80211 frame 46 + * into separate slots. */ 47 + #define TX_SLOTS_PER_FRAME 2 48 + 49 + 44 50 /* 32bit DMA ops. */ 45 51 static 46 52 struct b43_dmadesc_generic *op32_idx2desc(struct b43_dmaring *ring, ··· 80 74 addrext = (u32) (dmaaddr & SSB_DMA_TRANSLATION_MASK) 81 75 >> SSB_DMA_TRANSLATION_SHIFT; 82 76 addr |= ssb_dma_translation(ring->dev->dev); 83 - ctl = (bufsize - ring->frameoffset) 84 - & B43_DMA32_DCTL_BYTECNT; 77 + ctl = bufsize & B43_DMA32_DCTL_BYTECNT; 85 78 if (slot == ring->nr_slots - 1) 86 79 ctl |= B43_DMA32_DCTL_DTABLEEND; 87 80 if (start) ··· 182 177 ctl0 |= B43_DMA64_DCTL0_FRAMEEND; 183 178 if (irq) 184 179 ctl0 |= B43_DMA64_DCTL0_IRQ; 185 - ctl1 |= (bufsize - ring->frameoffset) 186 - & B43_DMA64_DCTL1_BYTECNT; 180 + ctl1 |= bufsize & B43_DMA64_DCTL1_BYTECNT; 187 181 ctl1 |= (addrext << B43_DMA64_DCTL1_ADDREXT_SHIFT) 188 182 & B43_DMA64_DCTL1_ADDREXT_MASK; 189 183 ··· 580 576 return -ENOMEM; 581 577 dmaaddr = map_descbuffer(ring, skb->data, 582 578 ring->rx_buffersize, 0); 583 - } 584 - 585 - if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize, 0)) { 586 - b43err(ring->dev->wl, "RX DMA buffer allocation failed\n"); 587 - dev_kfree_skb_any(skb); 588 - return -EIO; 579 + if (b43_dma_mapping_error(ring, dmaaddr, ring->rx_buffersize, 0)) { 580 + b43err(ring->dev->wl, "RX DMA buffer allocation failed\n"); 581 + dev_kfree_skb_any(skb); 582 + return -EIO; 583 + } 589 584 } 590 585 591 586 meta->skb = skb; ··· 833 830 if (ring->index == 0) { 834 831 ring->rx_buffersize = B43_DMA0_RX_BUFFERSIZE; 835 832 ring->frameoffset = B43_DMA0_RX_FRAMEOFFSET; 836 - } else if (ring->index == 3) { 837 - ring->rx_buffersize = B43_DMA3_RX_BUFFERSIZE; 838 - ring->frameoffset = B43_DMA3_RX_FRAMEOFFSET; 839 833 } else 840 834 B43_WARN_ON(1); 841 835 } ··· 842 842 #endif 843 843 844 844 if (for_tx) { 845 - ring->txhdr_cache = kcalloc(ring->nr_slots, 845 + /* Assumption: B43_TXRING_SLOTS can be divided by TX_SLOTS_PER_FRAME */ 846 + BUILD_BUG_ON(B43_TXRING_SLOTS % TX_SLOTS_PER_FRAME != 0); 847 + 848 + ring->txhdr_cache = kcalloc(ring->nr_slots / TX_SLOTS_PER_FRAME, 846 849 b43_txhdr_size(dev), 847 850 GFP_KERNEL); 848 851 if (!ring->txhdr_cache) ··· 861 858 b43_txhdr_size(dev), 1)) { 862 859 /* ugh realloc */ 863 860 kfree(ring->txhdr_cache); 864 - ring->txhdr_cache = kcalloc(ring->nr_slots, 861 + ring->txhdr_cache = kcalloc(ring->nr_slots / TX_SLOTS_PER_FRAME, 865 862 b43_txhdr_size(dev), 866 863 GFP_KERNEL | GFP_DMA); 867 864 if (!ring->txhdr_cache) ··· 1152 1149 u16 cookie; 1153 1150 size_t hdrsize = b43_txhdr_size(ring->dev); 1154 1151 1155 - #define SLOTS_PER_PACKET 2 1152 + /* Important note: If the number of used DMA slots per TX frame 1153 + * is changed here, the TX_SLOTS_PER_FRAME definition at the top of 1154 + * the file has to be updated, too! 1155 + */ 1156 1156 1157 1157 old_top_slot = ring->current_slot; 1158 1158 old_used_slots = ring->used_slots; ··· 1165 1159 desc = ops->idx2desc(ring, slot, &meta_hdr); 1166 1160 memset(meta_hdr, 0, sizeof(*meta_hdr)); 1167 1161 1168 - header = &(ring->txhdr_cache[slot * hdrsize]); 1162 + header = &(ring->txhdr_cache[(slot / TX_SLOTS_PER_FRAME) * hdrsize]); 1169 1163 cookie = generate_cookie(ring, slot); 1170 1164 err = b43_generate_txhdr(ring->dev, header, 1171 1165 skb->data, skb->len, info, cookie); ··· 1260 1254 } 1261 1255 1262 1256 /* Static mapping of mac80211's queues (priorities) to b43 DMA rings. */ 1263 - static struct b43_dmaring * select_ring_by_priority(struct b43_wldev *dev, 1264 - u8 queue_prio) 1257 + static struct b43_dmaring *select_ring_by_priority(struct b43_wldev *dev, 1258 + u8 queue_prio) 1265 1259 { 1266 1260 struct b43_dmaring *ring; 1267 1261 ··· 1312 1306 } 1313 1307 1314 1308 spin_lock_irqsave(&ring->lock, flags); 1309 + 1315 1310 B43_WARN_ON(!ring->tx); 1316 - if (unlikely(free_slots(ring) < SLOTS_PER_PACKET)) { 1317 - b43warn(dev->wl, "DMA queue overflow\n"); 1318 - err = -ENOSPC; 1319 - goto out_unlock; 1320 - } 1321 1311 /* Check if the queue was stopped in mac80211, 1322 1312 * but we got called nevertheless. 1323 1313 * That would be a mac80211 bug. */ 1324 1314 B43_WARN_ON(ring->stopped); 1315 + 1316 + if (unlikely(free_slots(ring) < TX_SLOTS_PER_FRAME)) { 1317 + b43warn(dev->wl, "DMA queue overflow\n"); 1318 + err = -ENOSPC; 1319 + goto out_unlock; 1320 + } 1325 1321 1326 1322 /* Assign the queue number to the ring (if not already done before) 1327 1323 * so TX status handling can use it. The queue to ring mapping is ··· 1343 1335 goto out_unlock; 1344 1336 } 1345 1337 ring->nr_tx_packets++; 1346 - if ((free_slots(ring) < SLOTS_PER_PACKET) || 1338 + if ((free_slots(ring) < TX_SLOTS_PER_FRAME) || 1347 1339 should_inject_overflow(ring)) { 1348 1340 /* This TX ring is full. */ 1349 1341 ieee80211_stop_queue(dev->wl->hw, skb_get_queue_mapping(skb)); ··· 1427 1419 } 1428 1420 dev->stats.last_tx = jiffies; 1429 1421 if (ring->stopped) { 1430 - B43_WARN_ON(free_slots(ring) < SLOTS_PER_PACKET); 1422 + B43_WARN_ON(free_slots(ring) < TX_SLOTS_PER_FRAME); 1431 1423 ieee80211_wake_queue(dev->wl->hw, ring->queue_prio); 1432 1424 ring->stopped = 0; 1433 1425 if (b43_debug(dev, B43_DBG_DMAVERBOSE)) { ··· 1450 1442 ring = select_ring_by_priority(dev, i); 1451 1443 1452 1444 spin_lock_irqsave(&ring->lock, flags); 1453 - stats[i].len = ring->used_slots / SLOTS_PER_PACKET; 1454 - stats[i].limit = ring->nr_slots / SLOTS_PER_PACKET; 1445 + stats[i].len = ring->used_slots / TX_SLOTS_PER_FRAME; 1446 + stats[i].limit = ring->nr_slots / TX_SLOTS_PER_FRAME; 1455 1447 stats[i].count = ring->nr_tx_packets; 1456 1448 spin_unlock_irqrestore(&ring->lock, flags); 1457 1449 }
+7 -10
drivers/net/wireless/b43/dma.h
··· 1 1 #ifndef B43_DMA_H_ 2 2 #define B43_DMA_H_ 3 3 4 - #include <linux/list.h> 4 + #include <linux/ieee80211.h> 5 5 #include <linux/spinlock.h> 6 - #include <linux/workqueue.h> 7 - #include <linux/linkage.h> 8 - #include <asm/atomic.h> 9 6 10 7 #include "b43.h" 8 + 11 9 12 10 /* DMA-Interrupt reasons. */ 13 11 #define B43_DMAIRQ_FATALMASK ((1 << 10) | (1 << 11) | (1 << 12) \ ··· 159 161 160 162 /* Misc DMA constants */ 161 163 #define B43_DMA_RINGMEMSIZE PAGE_SIZE 162 - #define B43_DMA0_RX_FRAMEOFFSET 30 163 - #define B43_DMA3_RX_FRAMEOFFSET 0 164 + #define B43_DMA0_RX_FRAMEOFFSET 30 164 165 165 166 /* DMA engine tuning knobs */ 166 - #define B43_TXRING_SLOTS 128 167 + #define B43_TXRING_SLOTS 256 167 168 #define B43_RXRING_SLOTS 64 168 - #define B43_DMA0_RX_BUFFERSIZE (2304 + 100) 169 - #define B43_DMA3_RX_BUFFERSIZE 16 169 + #define B43_DMA0_RX_BUFFERSIZE IEEE80211_MAX_FRAME_LEN 170 + 170 171 171 172 struct sk_buff; 172 173 struct b43_private; ··· 212 215 void *descbase; 213 216 /* Meta data about all descriptors. */ 214 217 struct b43_dmadesc_meta *meta; 215 - /* Cache of TX headers for each slot. 218 + /* Cache of TX headers for each TX frame. 216 219 * This is to avoid an allocation on each TX. 217 220 * This is NULL for an RX ring. 218 221 */
+25 -52
drivers/net/wireless/b43/lo.c
··· 36 36 #include <linux/sched.h> 37 37 38 38 39 - static struct b43_lo_calib * b43_find_lo_calib(struct b43_txpower_lo_control *lo, 40 - const struct b43_bbatt *bbatt, 39 + static struct b43_lo_calib *b43_find_lo_calib(struct b43_txpower_lo_control *lo, 40 + const struct b43_bbatt *bbatt, 41 41 const struct b43_rfatt *rfatt) 42 42 { 43 43 struct b43_lo_calib *c; ··· 138 138 * "pad_mix_gain" is the PAD Mixer Gain. 139 139 */ 140 140 static u16 lo_txctl_register_table(struct b43_wldev *dev, 141 - u16 * value, u16 * pad_mix_gain) 141 + u16 *value, u16 *pad_mix_gain) 142 142 { 143 143 struct b43_phy *phy = &dev->phy; 144 144 u16 reg, v, padmix; ··· 225 225 radio_pctl_reg = tmp; 226 226 } 227 227 } 228 - b43_radio_write16(dev, 0x43, (b43_radio_read16(dev, 0x43) 229 - & 0xFFF0) | radio_pctl_reg); 228 + b43_radio_maskset(dev, 0x43, 0xFFF0, radio_pctl_reg); 230 229 b43_gphy_set_baseband_attenuation(dev, 2); 231 230 232 231 reg = lo_txctl_register_table(dev, &mask, NULL); 233 232 mask = ~mask; 234 - b43_radio_write16(dev, reg, b43_radio_read16(dev, reg) 235 - & mask); 233 + b43_radio_mask(dev, reg, mask); 236 234 237 235 if (has_tx_magnification(phy)) { 238 236 int i, j; ··· 240 242 241 243 for (i = 0; i < ARRAY_SIZE(tx_magn_values); i++) { 242 244 tx_magn = tx_magn_values[i]; 243 - b43_radio_write16(dev, 0x52, 244 - (b43_radio_read16(dev, 0x52) 245 - & 0xFF0F) | tx_magn); 245 + b43_radio_maskset(dev, 0x52, 0xFF0F, tx_magn); 246 246 for (j = 0; j < ARRAY_SIZE(tx_bias_values); j++) { 247 247 tx_bias = tx_bias_values[j]; 248 - b43_radio_write16(dev, 0x52, 249 - (b43_radio_read16(dev, 0x52) 250 - & 0xFFF0) | tx_bias); 248 + b43_radio_maskset(dev, 0x52, 0xFFF0, tx_bias); 251 249 feedthrough = 252 250 lo_measure_feedthrough(dev, 0, pga, 253 251 trsw_rx); ··· 263 269 } else { 264 270 lo->tx_magn = 0; 265 271 lo->tx_bias = 0; 266 - b43_radio_write16(dev, 0x52, b43_radio_read16(dev, 0x52) 267 - & 0xFFF0); /* TX bias == 0 */ 272 + b43_radio_mask(dev, 0x52, 0xFFF0); /* TX bias == 0 */ 268 273 } 269 274 lo->txctl_measured_time = jiffies; 270 275 } ··· 399 406 sav->phy_cck_14 = b43_phy_read(dev, B43_PHY_CCK(0x14)); 400 407 sav->phy_hpwr_tssictl = b43_phy_read(dev, B43_PHY_HPWR_TSSICTL); 401 408 402 - b43_phy_write(dev, B43_PHY_HPWR_TSSICTL, 403 - b43_phy_read(dev, B43_PHY_HPWR_TSSICTL) 404 - | 0x100); 405 - b43_phy_write(dev, B43_PHY_EXTG(0x01), 406 - b43_phy_read(dev, B43_PHY_EXTG(0x01)) 407 - | 0x40); 408 - b43_phy_write(dev, B43_PHY_DACCTL, 409 - b43_phy_read(dev, B43_PHY_DACCTL) 410 - | 0x40); 411 - b43_phy_write(dev, B43_PHY_CCK(0x14), 412 - b43_phy_read(dev, B43_PHY_CCK(0x14)) 413 - | 0x200); 409 + b43_phy_set(dev, B43_PHY_HPWR_TSSICTL, 0x100); 410 + b43_phy_set(dev, B43_PHY_EXTG(0x01), 0x40); 411 + b43_phy_set(dev, B43_PHY_DACCTL, 0x40); 412 + b43_phy_set(dev, B43_PHY_CCK(0x14), 0x200); 414 413 } 415 414 if (phy->type == B43_PHYTYPE_B && 416 415 phy->radio_ver == 0x2050 && phy->radio_rev < 6) { ··· 419 434 sav->phy_cck_3E = b43_phy_read(dev, B43_PHY_CCK(0x3E)); 420 435 sav->phy_crs0 = b43_phy_read(dev, B43_PHY_CRS0); 421 436 422 - b43_phy_write(dev, B43_PHY_CLASSCTL, 423 - b43_phy_read(dev, B43_PHY_CLASSCTL) 424 - & 0xFFFC); 425 - b43_phy_write(dev, B43_PHY_CRS0, b43_phy_read(dev, B43_PHY_CRS0) 426 - & 0x7FFF); 427 - b43_phy_write(dev, B43_PHY_ANALOGOVER, 428 - b43_phy_read(dev, B43_PHY_ANALOGOVER) 429 - | 0x0003); 430 - b43_phy_write(dev, B43_PHY_ANALOGOVERVAL, 431 - b43_phy_read(dev, B43_PHY_ANALOGOVERVAL) 432 - & 0xFFFC); 437 + b43_phy_mask(dev, B43_PHY_CLASSCTL, 0xFFFC); 438 + b43_phy_mask(dev, B43_PHY_CRS0, 0x7FFF); 439 + b43_phy_set(dev, B43_PHY_ANALOGOVER, 0x0003); 440 + b43_phy_mask(dev, B43_PHY_ANALOGOVERVAL, 0xFFFC); 433 441 if (phy->type == B43_PHYTYPE_G) { 434 442 if ((phy->rev >= 7) && 435 443 (sprom->boardflags_lo & B43_BFL_EXTLNA)) { ··· 536 558 b43_radio_write16(dev, 0x7A, sav->radio_7A); 537 559 if (!has_tx_magnification(phy)) { 538 560 tmp = sav->radio_52; 539 - b43_radio_write16(dev, 0x52, (b43_radio_read16(dev, 0x52) 540 - & 0xFF0F) | tmp); 561 + b43_radio_maskset(dev, 0x52, 0xFF0F, tmp); 541 562 } 542 563 b43_write16(dev, 0x3E2, sav->reg_3E2); 543 564 if (phy->type == B43_PHYTYPE_B && ··· 731 754 } 732 755 733 756 static 734 - struct b43_lo_calib * b43_calibrate_lo_setting(struct b43_wldev *dev, 735 - const struct b43_bbatt *bbatt, 736 - const struct b43_rfatt *rfatt) 757 + struct b43_lo_calib *b43_calibrate_lo_setting(struct b43_wldev *dev, 758 + const struct b43_bbatt *bbatt, 759 + const struct b43_rfatt *rfatt) 737 760 { 738 761 struct b43_phy *phy = &dev->phy; 739 762 struct b43_phy_g *gphy = phy->g; ··· 755 778 756 779 txctl_reg = lo_txctl_register_table(dev, &txctl_value, &pad_mix_gain); 757 780 758 - b43_radio_write16(dev, 0x43, 759 - (b43_radio_read16(dev, 0x43) & 0xFFF0) 760 - | rfatt->att); 761 - b43_radio_write16(dev, txctl_reg, 762 - (b43_radio_read16(dev, txctl_reg) & ~txctl_value) 763 - | (rfatt->with_padmix) ? txctl_value : 0); 781 + b43_radio_maskset(dev, 0x43, 0xFFF0, rfatt->att); 782 + b43_radio_maskset(dev, txctl_reg, ~txctl_value, (rfatt->with_padmix ? txctl_value :0)); 764 783 765 784 max_rx_gain = rfatt->att * 2; 766 785 max_rx_gain += bbatt->att / 2; ··· 797 824 /* Get a calibrated LO setting for the given attenuation values. 798 825 * Might return a NULL pointer under OOM! */ 799 826 static 800 - struct b43_lo_calib * b43_get_calib_lo_settings(struct b43_wldev *dev, 801 - const struct b43_bbatt *bbatt, 802 - const struct b43_rfatt *rfatt) 827 + struct b43_lo_calib *b43_get_calib_lo_settings(struct b43_wldev *dev, 828 + const struct b43_bbatt *bbatt, 829 + const struct b43_rfatt *rfatt) 803 830 { 804 831 struct b43_txpower_lo_control *lo = dev->phy.g->lo_control; 805 832 struct b43_lo_calib *c;
+56 -18
drivers/net/wireless/b43/main.c
··· 512 512 } 513 513 514 514 /* Read HostFlags */ 515 - u64 b43_hf_read(struct b43_wldev * dev) 515 + u64 b43_hf_read(struct b43_wldev *dev) 516 516 { 517 517 u64 ret; 518 518 ··· 600 600 } 601 601 602 602 static 603 - void b43_macfilter_set(struct b43_wldev *dev, u16 offset, const u8 * mac) 603 + void b43_macfilter_set(struct b43_wldev *dev, u16 offset, const u8 *mac) 604 604 { 605 605 static const u8 zero_addr[ETH_ALEN] = { 0 }; 606 606 u16 data; ··· 790 790 } 791 791 792 792 static void key_write(struct b43_wldev *dev, 793 - u8 index, u8 algorithm, const u8 * key) 793 + u8 index, u8 algorithm, const u8 *key) 794 794 { 795 795 unsigned int i; 796 796 u32 offset; ··· 812 812 } 813 813 } 814 814 815 - static void keymac_write(struct b43_wldev *dev, u8 index, const u8 * addr) 815 + static void keymac_write(struct b43_wldev *dev, u8 index, const u8 *addr) 816 816 { 817 817 u32 addrtmp[2] = { 0, 0, }; 818 818 u8 per_sta_keys_start = 8; ··· 862 862 863 863 static void do_key_write(struct b43_wldev *dev, 864 864 u8 index, u8 algorithm, 865 - const u8 * key, size_t key_len, const u8 * mac_addr) 865 + const u8 *key, size_t key_len, const u8 *mac_addr) 866 866 { 867 867 u8 buf[B43_SEC_KEYSIZE] = { 0, }; 868 868 u8 per_sta_keys_start = 8; ··· 886 886 887 887 static int b43_key_write(struct b43_wldev *dev, 888 888 int index, u8 algorithm, 889 - const u8 * key, size_t key_len, 890 - const u8 * mac_addr, 889 + const u8 *key, size_t key_len, 890 + const u8 *mac_addr, 891 891 struct ieee80211_key_conf *keyconf) 892 892 { 893 893 int i; ··· 1286 1286 } 1287 1287 1288 1288 static void b43_write_template_common(struct b43_wldev *dev, 1289 - const u8 * data, u16 size, 1289 + const u8 *data, u16 size, 1290 1290 u16 ram_offset, 1291 1291 u16 shm_size_offset, u8 rate) 1292 1292 { ··· 1476 1476 * 2) Patching duration field 1477 1477 * 3) Stripping TIM 1478 1478 */ 1479 - static const u8 * b43_generate_probe_resp(struct b43_wldev *dev, 1480 - u16 *dest_size, 1481 - struct ieee80211_rate *rate) 1479 + static const u8 *b43_generate_probe_resp(struct b43_wldev *dev, 1480 + u16 *dest_size, 1481 + struct ieee80211_rate *rate) 1482 1482 { 1483 1483 const u8 *src_data; 1484 1484 u8 *dest_data; ··· 2980 2980 b43_clear_keys(dev); 2981 2981 } 2982 2982 2983 - static int b43_rng_read(struct hwrng *rng, u32 * data) 2983 + static int b43_rng_read(struct hwrng *rng, u32 *data) 2984 2984 { 2985 2985 struct b43_wl *wl = (struct b43_wl *)rng->priv; 2986 2986 unsigned long flags; ··· 3311 3311 msleep(1); 3312 3312 } 3313 3313 3314 - static const char * band_to_string(enum ieee80211_band band) 3314 + static const char *band_to_string(enum ieee80211_band band) 3315 3315 { 3316 3316 switch (band) { 3317 3317 case IEEE80211_BAND_5GHZ: ··· 4170 4170 hf |= B43_HF_GDCW; 4171 4171 if (sprom->boardflags_lo & B43_BFL_PACTRL) 4172 4172 hf |= B43_HF_OFDMPABOOST; 4173 - } else if (phy->type == B43_PHYTYPE_B) { 4174 - hf |= B43_HF_SYMW; 4175 - if (phy->rev >= 2 && phy->radio_ver == 0x2050) 4176 - hf &= ~B43_HF_GDCW; 4177 4173 } 4174 + if (phy->radio_ver == 0x2050) { 4175 + if (phy->radio_rev == 6) 4176 + hf |= B43_HF_4318TSSI; 4177 + if (phy->radio_rev < 6) 4178 + hf |= B43_HF_VCORECALC; 4179 + } 4180 + if (sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW) 4181 + hf |= B43_HF_DSCRQ; /* Disable slowclock requests from ucode. */ 4182 + if ((bus->bustype == SSB_BUSTYPE_PCI) && 4183 + (bus->pcicore.dev->id.revision <= 10)) 4184 + hf |= B43_HF_PCISCW; /* PCI slow clock workaround. */ 4185 + hf &= ~B43_HF_SKCFPUP; 4178 4186 b43_hf_write(dev, hf); 4179 4187 4180 4188 b43_set_retry_limits(dev, B43_DEFAULT_SHORT_RETRY_LIMIT, ··· 4221 4213 b43_set_synth_pu_delay(dev, 1); 4222 4214 b43_bluetooth_coext_enable(dev); 4223 4215 4224 - ssb_bus_powerup(bus, 1); /* Enable dynamic PCTL */ 4216 + ssb_bus_powerup(bus, !(sprom->boardflags_lo & B43_BFL_XTAL_NOSLOW)); 4225 4217 b43_upload_card_macaddress(dev); 4226 4218 b43_security_init(dev); 4227 4219 if (!dev->suspend_in_progress) ··· 4405 4397 B43_WARN_ON(!vif || wl->vif != vif); 4406 4398 } 4407 4399 4400 + static void b43_op_sw_scan_start_notifier(struct ieee80211_hw *hw) 4401 + { 4402 + struct b43_wl *wl = hw_to_b43_wl(hw); 4403 + struct b43_wldev *dev; 4404 + 4405 + mutex_lock(&wl->mutex); 4406 + dev = wl->current_dev; 4407 + if (dev && (b43_status(dev) >= B43_STAT_INITIALIZED)) { 4408 + /* Disable CFP update during scan on other channels. */ 4409 + b43_hf_write(dev, b43_hf_read(dev) | B43_HF_SKCFPUP); 4410 + } 4411 + mutex_unlock(&wl->mutex); 4412 + } 4413 + 4414 + static void b43_op_sw_scan_complete_notifier(struct ieee80211_hw *hw) 4415 + { 4416 + struct b43_wl *wl = hw_to_b43_wl(hw); 4417 + struct b43_wldev *dev; 4418 + 4419 + mutex_lock(&wl->mutex); 4420 + dev = wl->current_dev; 4421 + if (dev && (b43_status(dev) >= B43_STAT_INITIALIZED)) { 4422 + /* Re-enable CFP update. */ 4423 + b43_hf_write(dev, b43_hf_read(dev) & ~B43_HF_SKCFPUP); 4424 + } 4425 + mutex_unlock(&wl->mutex); 4426 + } 4427 + 4408 4428 static const struct ieee80211_ops b43_hw_ops = { 4409 4429 .tx = b43_op_tx, 4410 4430 .conf_tx = b43_op_conf_tx, ··· 4451 4415 .stop = b43_op_stop, 4452 4416 .set_tim = b43_op_beacon_set_tim, 4453 4417 .sta_notify = b43_op_sta_notify, 4418 + .sw_scan_start = b43_op_sw_scan_start_notifier, 4419 + .sw_scan_complete = b43_op_sw_scan_complete_notifier, 4454 4420 }; 4455 4421 4456 4422 /* Hard-reset the chip. Do not call this directly.
+40 -71
drivers/net/wireless/b43/phy_a.c
··· 121 121 b43_radio_write16(dev, 0x0007, (r8 << 4) | r8); 122 122 b43_radio_write16(dev, 0x0020, (r8 << 4) | r8); 123 123 b43_radio_write16(dev, 0x0021, (r8 << 4) | r8); 124 - b43_radio_write16(dev, 0x0022, (b43_radio_read16(dev, 0x0022) 125 - & 0x000F) | (r8 << 4)); 124 + b43_radio_maskset(dev, 0x0022, 0x000F, (r8 << 4)); 126 125 b43_radio_write16(dev, 0x002A, (r8 << 4)); 127 126 b43_radio_write16(dev, 0x002B, (r8 << 4)); 128 - b43_radio_write16(dev, 0x0008, (b43_radio_read16(dev, 0x0008) 129 - & 0x00F0) | (r8 << 4)); 130 - b43_radio_write16(dev, 0x0029, (b43_radio_read16(dev, 0x0029) 131 - & 0xFF0F) | 0x00B0); 127 + b43_radio_maskset(dev, 0x0008, 0x00F0, (r8 << 4)); 128 + b43_radio_maskset(dev, 0x0029, 0xFF0F, 0x00B0); 132 129 b43_radio_write16(dev, 0x0035, 0x00AA); 133 130 b43_radio_write16(dev, 0x0036, 0x0085); 134 - b43_radio_write16(dev, 0x003A, (b43_radio_read16(dev, 0x003A) 135 - & 0xFF20) | 136 - freq_r3A_value(freq)); 137 - b43_radio_write16(dev, 0x003D, 138 - b43_radio_read16(dev, 0x003D) & 0x00FF); 139 - b43_radio_write16(dev, 0x0081, (b43_radio_read16(dev, 0x0081) 140 - & 0xFF7F) | 0x0080); 141 - b43_radio_write16(dev, 0x0035, 142 - b43_radio_read16(dev, 0x0035) & 0xFFEF); 143 - b43_radio_write16(dev, 0x0035, (b43_radio_read16(dev, 0x0035) 144 - & 0xFFEF) | 0x0010); 131 + b43_radio_maskset(dev, 0x003A, 0xFF20, freq_r3A_value(freq)); 132 + b43_radio_mask(dev, 0x003D, 0x00FF); 133 + b43_radio_maskset(dev, 0x0081, 0xFF7F, 0x0080); 134 + b43_radio_mask(dev, 0x0035, 0xFFEF); 135 + b43_radio_maskset(dev, 0x0035, 0xFFEF, 0x0010); 145 136 b43_radio_set_tx_iq(dev); 146 137 //TODO: TSSI2dbm workaround 147 138 //FIXME b43_phy_xmitpower(dev); ··· 151 160 b43_radio_write16(dev, 0x0082, 0x0080); 152 161 b43_radio_write16(dev, 0x0080, 0x0000); 153 162 b43_radio_write16(dev, 0x003F, 0x00DA); 154 - b43_radio_write16(dev, 0x0005, b43_radio_read16(dev, 0x0005) & ~0x0008); 155 - b43_radio_write16(dev, 0x0081, b43_radio_read16(dev, 0x0081) & ~0x0010); 156 - b43_radio_write16(dev, 0x0081, b43_radio_read16(dev, 0x0081) & ~0x0020); 157 - b43_radio_write16(dev, 0x0081, b43_radio_read16(dev, 0x0081) & ~0x0020); 163 + b43_radio_mask(dev, 0x0005, ~0x0008); 164 + b43_radio_mask(dev, 0x0081, ~0x0010); 165 + b43_radio_mask(dev, 0x0081, ~0x0020); 166 + b43_radio_mask(dev, 0x0081, ~0x0020); 158 167 msleep(1); /* delay 400usec */ 159 168 160 - b43_radio_write16(dev, 0x0081, 161 - (b43_radio_read16(dev, 0x0081) & ~0x0020) | 0x0010); 169 + b43_radio_maskset(dev, 0x0081, ~0x0020, 0x0010); 162 170 msleep(1); /* delay 400usec */ 163 171 164 - b43_radio_write16(dev, 0x0005, 165 - (b43_radio_read16(dev, 0x0005) & ~0x0008) | 0x0008); 166 - b43_radio_write16(dev, 0x0085, b43_radio_read16(dev, 0x0085) & ~0x0010); 167 - b43_radio_write16(dev, 0x0005, b43_radio_read16(dev, 0x0005) & ~0x0008); 168 - b43_radio_write16(dev, 0x0081, b43_radio_read16(dev, 0x0081) & ~0x0040); 169 - b43_radio_write16(dev, 0x0081, 170 - (b43_radio_read16(dev, 0x0081) & ~0x0040) | 0x0040); 172 + b43_radio_maskset(dev, 0x0005, ~0x0008, 0x0008); 173 + b43_radio_mask(dev, 0x0085, ~0x0010); 174 + b43_radio_mask(dev, 0x0005, ~0x0008); 175 + b43_radio_mask(dev, 0x0081, ~0x0040); 176 + b43_radio_maskset(dev, 0x0081, ~0x0040, 0x0040); 171 177 b43_radio_write16(dev, 0x0005, 172 178 (b43_radio_read16(dev, 0x0081) & ~0x0008) | 0x0008); 173 179 b43_phy_write(dev, 0x0063, 0xDDC6); ··· 212 224 u16 b, curr_s, best_s = 0xFFFF; 213 225 int i; 214 226 215 - b43_phy_write(dev, B43_PHY_CRS0, 216 - b43_phy_read(dev, B43_PHY_CRS0) & ~B43_PHY_CRS0_EN); 217 - b43_phy_write(dev, B43_PHY_OFDM(0x1B), 218 - b43_phy_read(dev, B43_PHY_OFDM(0x1B)) | 0x1000); 219 - b43_phy_write(dev, B43_PHY_OFDM(0x82), 220 - (b43_phy_read(dev, B43_PHY_OFDM(0x82)) & 0xF0FF) | 0x0300); 221 - b43_radio_write16(dev, 0x0009, 222 - b43_radio_read16(dev, 0x0009) | 0x0080); 223 - b43_radio_write16(dev, 0x0012, 224 - (b43_radio_read16(dev, 0x0012) & 0xFFFC) | 0x0002); 227 + b43_phy_mask(dev, B43_PHY_CRS0, ~B43_PHY_CRS0_EN); 228 + b43_phy_set(dev, B43_PHY_OFDM(0x1B), 0x1000); 229 + b43_phy_maskset(dev, B43_PHY_OFDM(0x82), 0xF0FF, 0x0300); 230 + b43_radio_set(dev, 0x0009, 0x0080); 231 + b43_radio_maskset(dev, 0x0012, 0xFFFC, 0x0002); 225 232 b43_wa_initgains(dev); 226 233 b43_phy_write(dev, B43_PHY_OFDM(0xBA), 0x3ED5); 227 234 b = b43_phy_read(dev, B43_PHY_PWRDOWN); 228 235 b43_phy_write(dev, B43_PHY_PWRDOWN, (b & 0xFFF8) | 0x0005); 229 - b43_radio_write16(dev, 0x0004, 230 - b43_radio_read16(dev, 0x0004) | 0x0004); 236 + b43_radio_set(dev, 0x0004, 0x0004); 231 237 for (i = 0x10; i <= 0x20; i++) { 232 238 b43_radio_write16(dev, 0x0013, i); 233 239 curr_s = b43_phy_read(dev, B43_PHY_OTABLEQ) & 0x00FF; ··· 234 252 best_s = curr_s; 235 253 } 236 254 b43_phy_write(dev, B43_PHY_PWRDOWN, b); 237 - b43_radio_write16(dev, 0x0004, 238 - b43_radio_read16(dev, 0x0004) & 0xFFFB); 255 + b43_radio_mask(dev, 0x0004, 0xFFFB); 239 256 b43_radio_write16(dev, 0x0013, best_s); 240 257 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1_R1, 0, 0xFFEC); 241 258 b43_phy_write(dev, B43_PHY_OFDM(0xB7), 0x1E80); ··· 242 261 b43_phy_write(dev, B43_PHY_OFDM(0xB5), 0x0EC0); 243 262 b43_phy_write(dev, B43_PHY_OFDM(0xB2), 0x00C0); 244 263 b43_phy_write(dev, B43_PHY_OFDM(0xB9), 0x1FFF); 245 - b43_phy_write(dev, B43_PHY_OFDM(0xBB), 246 - (b43_phy_read(dev, B43_PHY_OFDM(0xBB)) & 0xF000) | 0x0053); 247 - b43_phy_write(dev, B43_PHY_OFDM61, 248 - (b43_phy_read(dev, B43_PHY_OFDM61) & 0xFE1F) | 0x0120); 249 - b43_phy_write(dev, B43_PHY_OFDM(0x13), 250 - (b43_phy_read(dev, B43_PHY_OFDM(0x13)) & 0x0FFF) | 0x3000); 251 - b43_phy_write(dev, B43_PHY_OFDM(0x14), 252 - (b43_phy_read(dev, B43_PHY_OFDM(0x14)) & 0x0FFF) | 0x3000); 264 + b43_phy_maskset(dev, B43_PHY_OFDM(0xBB), 0xF000, 0x0053); 265 + b43_phy_maskset(dev, B43_PHY_OFDM61, 0xFE1F, 0x0120); 266 + b43_phy_maskset(dev, B43_PHY_OFDM(0x13), 0x0FFF, 0x3000); 267 + b43_phy_maskset(dev, B43_PHY_OFDM(0x14), 0x0FFF, 0x3000); 253 268 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 6, 0x0017); 254 269 for (i = 0; i < 6; i++) 255 270 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, i, 0x000F); ··· 253 276 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 0x0E, 0x0011); 254 277 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 0x0F, 0x0013); 255 278 b43_phy_write(dev, B43_PHY_OFDM(0x33), 0x5030); 256 - b43_phy_write(dev, B43_PHY_CRS0, 257 - b43_phy_read(dev, B43_PHY_CRS0) | B43_PHY_CRS0_EN); 279 + b43_phy_set(dev, B43_PHY_CRS0, B43_PHY_CRS0_EN); 258 280 } 259 281 260 282 static void hardware_pctl_init_aphy(struct b43_wldev *dev) ··· 276 300 277 301 if (phy->rev >= 6) { 278 302 if (phy->type == B43_PHYTYPE_A) 279 - b43_phy_write(dev, B43_PHY_OFDM(0x1B), 280 - b43_phy_read(dev, B43_PHY_OFDM(0x1B)) & ~0x1000); 303 + b43_phy_mask(dev, B43_PHY_OFDM(0x1B), ~0x1000); 281 304 if (b43_phy_read(dev, B43_PHY_ENCORE) & B43_PHY_ENCORE_EN) 282 - b43_phy_write(dev, B43_PHY_ENCORE, 283 - b43_phy_read(dev, B43_PHY_ENCORE) | 0x0010); 305 + b43_phy_set(dev, B43_PHY_ENCORE, 0x0010); 284 306 else 285 - b43_phy_write(dev, B43_PHY_ENCORE, 286 - b43_phy_read(dev, B43_PHY_ENCORE) & ~0x1010); 307 + b43_phy_mask(dev, B43_PHY_ENCORE, ~0x1010); 287 308 } 288 309 289 310 b43_wa_all(dev); 290 311 291 312 if (phy->type == B43_PHYTYPE_A) { 292 313 if (phy->gmode && (phy->rev < 3)) 293 - b43_phy_write(dev, 0x0034, 294 - b43_phy_read(dev, 0x0034) | 0x0001); 314 + b43_phy_set(dev, 0x0034, 0x0001); 295 315 b43_phy_rssiagc(dev, 0); 296 316 297 - b43_phy_write(dev, B43_PHY_CRS0, 298 - b43_phy_read(dev, B43_PHY_CRS0) | B43_PHY_CRS0_EN); 317 + b43_phy_set(dev, B43_PHY_CRS0, B43_PHY_CRS0_EN); 299 318 300 319 b43_radio_init2060(dev); 301 320 ··· 310 339 311 340 if ((phy->type == B43_PHYTYPE_G) && 312 341 (dev->dev->bus->sprom.boardflags_lo & B43_BFL_PACTRL)) { 313 - b43_phy_write(dev, B43_PHY_OFDM(0x6E), 314 - (b43_phy_read(dev, B43_PHY_OFDM(0x6E)) 315 - & 0xE000) | 0x3CF); 342 + b43_phy_maskset(dev, B43_PHY_OFDM(0x6E), 0xE000, 0x3CF); 316 343 } 317 344 } 318 345 ··· 489 520 return; 490 521 b43_radio_write16(dev, 0x0004, 0x00C0); 491 522 b43_radio_write16(dev, 0x0005, 0x0008); 492 - b43_phy_write(dev, 0x0010, b43_phy_read(dev, 0x0010) & 0xFFF7); 493 - b43_phy_write(dev, 0x0011, b43_phy_read(dev, 0x0011) & 0xFFF7); 523 + b43_phy_mask(dev, 0x0010, 0xFFF7); 524 + b43_phy_mask(dev, 0x0011, 0xFFF7); 494 525 b43_radio_init2060(dev); 495 526 } else { 496 527 b43_radio_write16(dev, 0x0004, 0x00FF); 497 528 b43_radio_write16(dev, 0x0005, 0x00FB); 498 - b43_phy_write(dev, 0x0010, b43_phy_read(dev, 0x0010) | 0x0008); 499 - b43_phy_write(dev, 0x0011, b43_phy_read(dev, 0x0011) | 0x0008); 529 + b43_phy_set(dev, 0x0010, 0x0008); 530 + b43_phy_set(dev, 0x0011, 0x0008); 500 531 } 501 532 } 502 533
+197 -412
drivers/net/wireless/b43/phy_g.c
··· 204 204 & 0xFFF0) | 205 205 baseband_attenuation); 206 206 } else if (phy->analog > 1) { 207 - b43_phy_write(dev, B43_PHY_DACCTL, 208 - (b43_phy_read(dev, B43_PHY_DACCTL) 209 - & 0xFFC3) | (baseband_attenuation << 2)); 207 + b43_phy_maskset(dev, B43_PHY_DACCTL, 0xFFC3, (baseband_attenuation << 2)); 210 208 } else { 211 - b43_phy_write(dev, B43_PHY_DACCTL, 212 - (b43_phy_read(dev, B43_PHY_DACCTL) 213 - & 0xFF87) | (baseband_attenuation << 3)); 209 + b43_phy_maskset(dev, B43_PHY_DACCTL, 0xFF87, (baseband_attenuation << 3)); 214 210 } 215 211 } 216 212 ··· 248 252 b43_radio_write16(dev, 0x43, 249 253 (rf & 0x000F) | (tx_control & 0x0070)); 250 254 } else { 251 - b43_radio_write16(dev, 0x43, (b43_radio_read16(dev, 0x43) 252 - & 0xFFF0) | (rf & 0x000F)); 253 - b43_radio_write16(dev, 0x52, (b43_radio_read16(dev, 0x52) 254 - & ~0x0070) | (tx_control & 255 - 0x0070)); 255 + b43_radio_maskset(dev, 0x43, 0xFFF0, (rf & 0x000F)); 256 + b43_radio_maskset(dev, 0x52, ~0x0070, (tx_control & 0x0070)); 256 257 } 257 258 if (has_tx_magnification(phy)) { 258 259 b43_radio_write16(dev, 0x52, tx_magn | tx_bias); 259 260 } else { 260 - b43_radio_write16(dev, 0x52, (b43_radio_read16(dev, 0x52) 261 - & 0xFFF0) | (tx_bias & 0x000F)); 261 + b43_radio_maskset(dev, 0x52, 0xFFF0, (tx_bias & 0x000F)); 262 262 } 263 263 b43_lo_g_adjust(dev); 264 264 } ··· 329 337 330 338 if (third != -1) { 331 339 tmp = ((u16) third << 14) | ((u16) third << 6); 332 - b43_phy_write(dev, 0x04A0, 333 - (b43_phy_read(dev, 0x04A0) & 0xBFBF) | tmp); 334 - b43_phy_write(dev, 0x04A1, 335 - (b43_phy_read(dev, 0x04A1) & 0xBFBF) | tmp); 336 - b43_phy_write(dev, 0x04A2, 337 - (b43_phy_read(dev, 0x04A2) & 0xBFBF) | tmp); 340 + b43_phy_maskset(dev, 0x04A0, 0xBFBF, tmp); 341 + b43_phy_maskset(dev, 0x04A1, 0xBFBF, tmp); 342 + b43_phy_maskset(dev, 0x04A2, 0xBFBF, tmp); 338 343 } 339 344 b43_dummy_transmission(dev); 340 345 } ··· 362 373 for (i = start; i < end; i++) 363 374 b43_ofdmtab_write16(dev, table, i, i - start); 364 375 365 - b43_phy_write(dev, 0x04A0, 366 - (b43_phy_read(dev, 0x04A0) & 0xBFBF) | 0x4040); 367 - b43_phy_write(dev, 0x04A1, 368 - (b43_phy_read(dev, 0x04A1) & 0xBFBF) | 0x4040); 369 - b43_phy_write(dev, 0x04A2, 370 - (b43_phy_read(dev, 0x04A2) & 0xBFBF) | 0x4000); 376 + b43_phy_maskset(dev, 0x04A0, 0xBFBF, 0x4040); 377 + b43_phy_maskset(dev, 0x04A1, 0xBFBF, 0x4040); 378 + b43_phy_maskset(dev, 0x04A2, 0xBFBF, 0x4000); 371 379 b43_dummy_transmission(dev); 372 380 } 373 381 ··· 440 454 backup[10] = b43_radio_read16(dev, 0x007A); 441 455 backup[11] = b43_radio_read16(dev, 0x0043); 442 456 443 - b43_phy_write(dev, 0x0429, b43_phy_read(dev, 0x0429) & 0x7FFF); 444 - b43_phy_write(dev, 0x0001, 445 - (b43_phy_read(dev, 0x0001) & 0x3FFF) | 0x4000); 446 - b43_phy_write(dev, 0x0811, b43_phy_read(dev, 0x0811) | 0x000C); 447 - b43_phy_write(dev, 0x0812, 448 - (b43_phy_read(dev, 0x0812) & 0xFFF3) | 0x0004); 449 - b43_phy_write(dev, 0x0802, b43_phy_read(dev, 0x0802) & ~(0x1 | 0x2)); 457 + b43_phy_mask(dev, 0x0429, 0x7FFF); 458 + b43_phy_maskset(dev, 0x0001, 0x3FFF, 0x4000); 459 + b43_phy_set(dev, 0x0811, 0x000C); 460 + b43_phy_maskset(dev, 0x0812, 0xFFF3, 0x0004); 461 + b43_phy_mask(dev, 0x0802, ~(0x1 | 0x2)); 450 462 if (phy->rev >= 6) { 451 463 backup[12] = b43_phy_read(dev, 0x002E); 452 464 backup[13] = b43_phy_read(dev, 0x002F); ··· 459 475 b43_phy_write(dev, 0x002F, 0); 460 476 b43_phy_write(dev, 0x080F, 0); 461 477 b43_phy_write(dev, 0x0810, 0); 462 - b43_phy_write(dev, 0x0478, b43_phy_read(dev, 0x0478) | 0x0100); 463 - b43_phy_write(dev, 0x0801, b43_phy_read(dev, 0x0801) | 0x0040); 464 - b43_phy_write(dev, 0x0060, b43_phy_read(dev, 0x0060) | 0x0040); 465 - b43_phy_write(dev, 0x0014, b43_phy_read(dev, 0x0014) | 0x0200); 478 + b43_phy_set(dev, 0x0478, 0x0100); 479 + b43_phy_set(dev, 0x0801, 0x0040); 480 + b43_phy_set(dev, 0x0060, 0x0040); 481 + b43_phy_set(dev, 0x0014, 0x0200); 466 482 } 467 - b43_radio_write16(dev, 0x007A, b43_radio_read16(dev, 0x007A) | 0x0070); 468 - b43_radio_write16(dev, 0x007A, b43_radio_read16(dev, 0x007A) | 0x0080); 483 + b43_radio_set(dev, 0x007A, 0x0070); 484 + b43_radio_set(dev, 0x007A, 0x0080); 469 485 udelay(30); 470 486 471 487 v47F = (s16) ((b43_phy_read(dev, 0x047F) >> 8) & 0x003F); ··· 485 501 if (saved == 0xFFFF) 486 502 saved = 4; 487 503 } else { 488 - b43_radio_write16(dev, 0x007A, 489 - b43_radio_read16(dev, 0x007A) & 0x007F); 504 + b43_radio_mask(dev, 0x007A, 0x007F); 490 505 if (phy->rev != 1) { /* Not in specs, but needed to prevent PPC machine check */ 491 - b43_phy_write(dev, 0x0814, 492 - b43_phy_read(dev, 0x0814) | 0x0001); 493 - b43_phy_write(dev, 0x0815, 494 - b43_phy_read(dev, 0x0815) & 0xFFFE); 506 + b43_phy_set(dev, 0x0814, 0x0001); 507 + b43_phy_mask(dev, 0x0815, 0xFFFE); 495 508 } 496 - b43_phy_write(dev, 0x0811, b43_phy_read(dev, 0x0811) | 0x000C); 497 - b43_phy_write(dev, 0x0812, b43_phy_read(dev, 0x0812) | 0x000C); 498 - b43_phy_write(dev, 0x0811, b43_phy_read(dev, 0x0811) | 0x0030); 499 - b43_phy_write(dev, 0x0812, b43_phy_read(dev, 0x0812) | 0x0030); 509 + b43_phy_set(dev, 0x0811, 0x000C); 510 + b43_phy_set(dev, 0x0812, 0x000C); 511 + b43_phy_set(dev, 0x0811, 0x0030); 512 + b43_phy_set(dev, 0x0812, 0x0030); 500 513 b43_phy_write(dev, 0x005A, 0x0480); 501 514 b43_phy_write(dev, 0x0059, 0x0810); 502 515 b43_phy_write(dev, 0x0058, 0x000D); 503 516 if (phy->rev == 0) { 504 517 b43_phy_write(dev, 0x0003, 0x0122); 505 518 } else { 506 - b43_phy_write(dev, 0x000A, b43_phy_read(dev, 0x000A) 507 - | 0x2000); 519 + b43_phy_set(dev, 0x000A, 0x2000); 508 520 } 509 521 if (phy->rev != 1) { /* Not in specs, but needed to prevent PPC machine check */ 510 - b43_phy_write(dev, 0x0814, 511 - b43_phy_read(dev, 0x0814) | 0x0004); 512 - b43_phy_write(dev, 0x0815, 513 - b43_phy_read(dev, 0x0815) & 0xFFFB); 522 + b43_phy_set(dev, 0x0814, 0x0004); 523 + b43_phy_mask(dev, 0x0815, 0xFFFB); 514 524 } 515 - b43_phy_write(dev, 0x0003, (b43_phy_read(dev, 0x0003) & 0xFF9F) 516 - | 0x0040); 517 - b43_radio_write16(dev, 0x007A, 518 - b43_radio_read16(dev, 0x007A) | 0x000F); 525 + b43_phy_maskset(dev, 0x0003, 0xFF9F, 0x0040); 526 + b43_radio_set(dev, 0x007A, 0x000F); 519 527 b43_set_all_gains(dev, 3, 0, 1); 520 - b43_radio_write16(dev, 0x0043, (b43_radio_read16(dev, 0x0043) 521 - & 0x00F0) | 0x000F); 528 + b43_radio_maskset(dev, 0x0043, 0x00F0, 0x000F); 522 529 udelay(30); 523 530 v47F = (s16) ((b43_phy_read(dev, 0x047F) >> 8) & 0x003F); 524 531 if (v47F >= 0x20) ··· 551 576 b43_radio_write16(dev, 0x0043, backup[11]); 552 577 b43_radio_write16(dev, 0x007A, backup[10]); 553 578 b43_phy_write(dev, 0x0802, b43_phy_read(dev, 0x0802) | 0x1 | 0x2); 554 - b43_phy_write(dev, 0x0429, b43_phy_read(dev, 0x0429) | 0x8000); 579 + b43_phy_set(dev, 0x0429, 0x8000); 555 580 b43_set_original_gains(dev); 556 581 if (phy->rev >= 6) { 557 582 b43_phy_write(dev, 0x0801, backup[16]); ··· 579 604 if (phy->radio_rev == 8) 580 605 b43_calc_nrssi_offset(dev); 581 606 582 - b43_phy_write(dev, B43_PHY_G_CRS, 583 - b43_phy_read(dev, B43_PHY_G_CRS) & 0x7FFF); 584 - b43_phy_write(dev, 0x0802, b43_phy_read(dev, 0x0802) & 0xFFFC); 607 + b43_phy_mask(dev, B43_PHY_G_CRS, 0x7FFF); 608 + b43_phy_mask(dev, 0x0802, 0xFFFC); 585 609 backup[7] = b43_read16(dev, 0x03E2); 586 610 b43_write16(dev, 0x03E2, b43_read16(dev, 0x03E2) | 0x8000); 587 611 backup[0] = b43_radio_read16(dev, 0x007A); ··· 607 633 case 4: 608 634 case 6: 609 635 case 7: 610 - b43_phy_write(dev, 0x0478, 611 - b43_phy_read(dev, 0x0478) 612 - | 0x0100); 613 - b43_phy_write(dev, 0x0801, 614 - b43_phy_read(dev, 0x0801) 615 - | 0x0040); 636 + b43_phy_set(dev, 0x0478, 0x0100); 637 + b43_phy_set(dev, 0x0801, 0x0040); 616 638 break; 617 639 case 3: 618 640 case 5: 619 - b43_phy_write(dev, 0x0801, 620 - b43_phy_read(dev, 0x0801) 621 - & 0xFFBF); 641 + b43_phy_mask(dev, 0x0801, 0xFFBF); 622 642 break; 623 643 } 624 - b43_phy_write(dev, 0x0060, b43_phy_read(dev, 0x0060) 625 - | 0x0040); 626 - b43_phy_write(dev, 0x0014, b43_phy_read(dev, 0x0014) 627 - | 0x0200); 644 + b43_phy_set(dev, 0x0060, 0x0040); 645 + b43_phy_set(dev, 0x0014, 0x0200); 628 646 } 629 - b43_radio_write16(dev, 0x007A, 630 - b43_radio_read16(dev, 0x007A) | 0x0070); 647 + b43_radio_set(dev, 0x007A, 0x0070); 631 648 b43_set_all_gains(dev, 0, 8, 0); 632 - b43_radio_write16(dev, 0x007A, 633 - b43_radio_read16(dev, 0x007A) & 0x00F7); 649 + b43_radio_mask(dev, 0x007A, 0x00F7); 634 650 if (phy->rev >= 2) { 635 - b43_phy_write(dev, 0x0811, 636 - (b43_phy_read(dev, 0x0811) & 0xFFCF) | 637 - 0x0030); 638 - b43_phy_write(dev, 0x0812, 639 - (b43_phy_read(dev, 0x0812) & 0xFFCF) | 640 - 0x0010); 651 + b43_phy_maskset(dev, 0x0811, 0xFFCF, 0x0030); 652 + b43_phy_maskset(dev, 0x0812, 0xFFCF, 0x0010); 641 653 } 642 - b43_radio_write16(dev, 0x007A, 643 - b43_radio_read16(dev, 0x007A) | 0x0080); 654 + b43_radio_set(dev, 0x007A, 0x0080); 644 655 udelay(20); 645 656 646 657 nrssi0 = (s16) ((b43_phy_read(dev, 0x047F) >> 8) & 0x003F); 647 658 if (nrssi0 >= 0x0020) 648 659 nrssi0 -= 0x0040; 649 660 650 - b43_radio_write16(dev, 0x007A, 651 - b43_radio_read16(dev, 0x007A) & 0x007F); 661 + b43_radio_mask(dev, 0x007A, 0x007F); 652 662 if (phy->rev >= 2) { 653 - b43_phy_write(dev, 0x0003, (b43_phy_read(dev, 0x0003) 654 - & 0xFF9F) | 0x0040); 663 + b43_phy_maskset(dev, 0x0003, 0xFF9F, 0x0040); 655 664 } 656 665 657 666 b43_write16(dev, B43_MMIO_CHANNEL_EXT, 658 667 b43_read16(dev, B43_MMIO_CHANNEL_EXT) 659 668 | 0x2000); 660 - b43_radio_write16(dev, 0x007A, 661 - b43_radio_read16(dev, 0x007A) | 0x000F); 669 + b43_radio_set(dev, 0x007A, 0x000F); 662 670 b43_phy_write(dev, 0x0015, 0xF330); 663 671 if (phy->rev >= 2) { 664 - b43_phy_write(dev, 0x0812, 665 - (b43_phy_read(dev, 0x0812) & 0xFFCF) | 666 - 0x0020); 667 - b43_phy_write(dev, 0x0811, 668 - (b43_phy_read(dev, 0x0811) & 0xFFCF) | 669 - 0x0020); 672 + b43_phy_maskset(dev, 0x0812, 0xFFCF, 0x0020); 673 + b43_phy_maskset(dev, 0x0811, 0xFFCF, 0x0020); 670 674 } 671 675 672 676 b43_set_all_gains(dev, 3, 0, 1); ··· 678 726 b43_phy_write(dev, B43_PHY_G_LO_CONTROL, backup[13]); 679 727 } 680 728 if (phy->rev >= 2) { 681 - b43_phy_write(dev, 0x0812, 682 - b43_phy_read(dev, 0x0812) & 0xFFCF); 683 - b43_phy_write(dev, 0x0811, 684 - b43_phy_read(dev, 0x0811) & 0xFFCF); 729 + b43_phy_mask(dev, 0x0812, 0xFFCF); 730 + b43_phy_mask(dev, 0x0811, 0xFFCF); 685 731 } 686 732 687 733 b43_radio_write16(dev, 0x007A, backup[0]); ··· 693 743 b43_phy_write(dev, 0x0059, backup[5]); 694 744 b43_phy_write(dev, 0x0058, backup[6]); 695 745 b43_synth_pu_workaround(dev, phy->channel); 696 - b43_phy_write(dev, 0x0802, 697 - b43_phy_read(dev, 0x0802) | (0x0001 | 0x0002)); 746 + b43_phy_set(dev, 0x0802, (0x0001 | 0x0002)); 698 747 b43_set_original_gains(dev); 699 - b43_phy_write(dev, B43_PHY_G_CRS, 700 - b43_phy_read(dev, B43_PHY_G_CRS) | 0x8000); 748 + b43_phy_set(dev, B43_PHY_G_CRS, 0x8000); 701 749 if (phy->rev >= 3) { 702 750 b43_phy_write(dev, 0x0801, backup[14]); 703 751 b43_phy_write(dev, 0x0060, backup[15]); ··· 722 774 if (tmp16 >= 0x20) 723 775 tmp16 -= 0x40; 724 776 if (tmp16 < 3) { 725 - b43_phy_write(dev, 0x048A, 726 - (b43_phy_read(dev, 0x048A) 727 - & 0xF000) | 0x09EB); 777 + b43_phy_maskset(dev, 0x048A, 0xF000, 0x09EB); 728 778 } else { 729 - b43_phy_write(dev, 0x048A, 730 - (b43_phy_read(dev, 0x048A) 731 - & 0xF000) | 0x0AED); 779 + b43_phy_maskset(dev, 0x048A, 0xF000, 0x0AED); 732 780 } 733 781 } else { 734 782 if (gphy->interfmode == B43_INTERFMODE_NONWLAN) { ··· 767 823 * interference mitigation code. 768 824 * It is save to restore values in random order. 769 825 */ 770 - static void _stack_save(u32 * _stackptr, size_t * stackidx, 826 + static void _stack_save(u32 *_stackptr, size_t *stackidx, 771 827 u8 id, u16 offset, u16 value) 772 828 { 773 829 u32 *stackptr = &(_stackptr[*stackidx]); ··· 781 837 B43_WARN_ON(*stackidx >= B43_INTERFSTACK_SIZE); 782 838 } 783 839 784 - static u16 _stack_restore(u32 * stackptr, u8 id, u16 offset) 840 + static u16 _stack_restore(u32 *stackptr, u8 id, u16 offset) 785 841 { 786 842 size_t i; 787 843 ··· 845 901 switch (mode) { 846 902 case B43_INTERFMODE_NONWLAN: 847 903 if (phy->rev != 1) { 848 - b43_phy_write(dev, 0x042B, 849 - b43_phy_read(dev, 0x042B) | 0x0800); 850 - b43_phy_write(dev, B43_PHY_G_CRS, 851 - b43_phy_read(dev, 852 - B43_PHY_G_CRS) & ~0x4000); 904 + b43_phy_set(dev, 0x042B, 0x0800); 905 + b43_phy_mask(dev, B43_PHY_G_CRS, ~0x4000); 853 906 break; 854 907 } 855 908 radio_stacksave(0x0078); ··· 865 924 phy_stacksave(0x0406); 866 925 b43_phy_write(dev, 0x0406, 0x7E28); 867 926 868 - b43_phy_write(dev, 0x042B, b43_phy_read(dev, 0x042B) | 0x0800); 869 - b43_phy_write(dev, B43_PHY_RADIO_BITFIELD, 870 - b43_phy_read(dev, 871 - B43_PHY_RADIO_BITFIELD) | 0x1000); 927 + b43_phy_set(dev, 0x042B, 0x0800); 928 + b43_phy_set(dev, B43_PHY_RADIO_BITFIELD, 0x1000); 872 929 873 930 phy_stacksave(0x04A0); 874 - b43_phy_write(dev, 0x04A0, 875 - (b43_phy_read(dev, 0x04A0) & 0xC0C0) | 0x0008); 931 + b43_phy_maskset(dev, 0x04A0, 0xC0C0, 0x0008); 876 932 phy_stacksave(0x04A1); 877 - b43_phy_write(dev, 0x04A1, 878 - (b43_phy_read(dev, 0x04A1) & 0xC0C0) | 0x0605); 933 + b43_phy_maskset(dev, 0x04A1, 0xC0C0, 0x0605); 879 934 phy_stacksave(0x04A2); 880 - b43_phy_write(dev, 0x04A2, 881 - (b43_phy_read(dev, 0x04A2) & 0xC0C0) | 0x0204); 935 + b43_phy_maskset(dev, 0x04A2, 0xC0C0, 0x0204); 882 936 phy_stacksave(0x04A8); 883 - b43_phy_write(dev, 0x04A8, 884 - (b43_phy_read(dev, 0x04A8) & 0xC0C0) | 0x0803); 937 + b43_phy_maskset(dev, 0x04A8, 0xC0C0, 0x0803); 885 938 phy_stacksave(0x04AB); 886 - b43_phy_write(dev, 0x04AB, 887 - (b43_phy_read(dev, 0x04AB) & 0xC0C0) | 0x0605); 939 + b43_phy_maskset(dev, 0x04AB, 0xC0C0, 0x0605); 888 940 889 941 phy_stacksave(0x04A7); 890 942 b43_phy_write(dev, 0x04A7, 0x0002); ··· 933 999 phy_stacksave(0x042B); 934 1000 phy_stacksave(0x048C); 935 1001 936 - b43_phy_write(dev, B43_PHY_RADIO_BITFIELD, 937 - b43_phy_read(dev, B43_PHY_RADIO_BITFIELD) 938 - & ~0x1000); 939 - b43_phy_write(dev, B43_PHY_G_CRS, 940 - (b43_phy_read(dev, B43_PHY_G_CRS) 941 - & 0xFFFC) | 0x0002); 1002 + b43_phy_mask(dev, B43_PHY_RADIO_BITFIELD, ~0x1000); 1003 + b43_phy_maskset(dev, B43_PHY_G_CRS, 0xFFFC, 0x0002); 942 1004 943 1005 b43_phy_write(dev, 0x0033, 0x0800); 944 1006 b43_phy_write(dev, 0x04A3, 0x2027); ··· 943 1013 b43_phy_write(dev, 0x04AA, 0x1CA8); 944 1014 b43_phy_write(dev, 0x04AC, 0x287A); 945 1015 946 - b43_phy_write(dev, 0x04A0, (b43_phy_read(dev, 0x04A0) 947 - & 0xFFC0) | 0x001A); 1016 + b43_phy_maskset(dev, 0x04A0, 0xFFC0, 0x001A); 948 1017 b43_phy_write(dev, 0x04A7, 0x000D); 949 1018 950 1019 if (phy->rev < 2) { ··· 956 1027 b43_phy_write(dev, 0x04C1, 0x0059); 957 1028 } 958 1029 959 - b43_phy_write(dev, 0x04A1, (b43_phy_read(dev, 0x04A1) 960 - & 0xC0FF) | 0x1800); 961 - b43_phy_write(dev, 0x04A1, (b43_phy_read(dev, 0x04A1) 962 - & 0xFFC0) | 0x0015); 963 - b43_phy_write(dev, 0x04A8, (b43_phy_read(dev, 0x04A8) 964 - & 0xCFFF) | 0x1000); 965 - b43_phy_write(dev, 0x04A8, (b43_phy_read(dev, 0x04A8) 966 - & 0xF0FF) | 0x0A00); 967 - b43_phy_write(dev, 0x04AB, (b43_phy_read(dev, 0x04AB) 968 - & 0xCFFF) | 0x1000); 969 - b43_phy_write(dev, 0x04AB, (b43_phy_read(dev, 0x04AB) 970 - & 0xF0FF) | 0x0800); 971 - b43_phy_write(dev, 0x04AB, (b43_phy_read(dev, 0x04AB) 972 - & 0xFFCF) | 0x0010); 973 - b43_phy_write(dev, 0x04AB, (b43_phy_read(dev, 0x04AB) 974 - & 0xFFF0) | 0x0005); 975 - b43_phy_write(dev, 0x04A8, (b43_phy_read(dev, 0x04A8) 976 - & 0xFFCF) | 0x0010); 977 - b43_phy_write(dev, 0x04A8, (b43_phy_read(dev, 0x04A8) 978 - & 0xFFF0) | 0x0006); 979 - b43_phy_write(dev, 0x04A2, (b43_phy_read(dev, 0x04A2) 980 - & 0xF0FF) | 0x0800); 981 - b43_phy_write(dev, 0x04A0, (b43_phy_read(dev, 0x04A0) 982 - & 0xF0FF) | 0x0500); 983 - b43_phy_write(dev, 0x04A2, (b43_phy_read(dev, 0x04A2) 984 - & 0xFFF0) | 0x000B); 1030 + b43_phy_maskset(dev, 0x04A1, 0xC0FF, 0x1800); 1031 + b43_phy_maskset(dev, 0x04A1, 0xFFC0, 0x0015); 1032 + b43_phy_maskset(dev, 0x04A8, 0xCFFF, 0x1000); 1033 + b43_phy_maskset(dev, 0x04A8, 0xF0FF, 0x0A00); 1034 + b43_phy_maskset(dev, 0x04AB, 0xCFFF, 0x1000); 1035 + b43_phy_maskset(dev, 0x04AB, 0xF0FF, 0x0800); 1036 + b43_phy_maskset(dev, 0x04AB, 0xFFCF, 0x0010); 1037 + b43_phy_maskset(dev, 0x04AB, 0xFFF0, 0x0005); 1038 + b43_phy_maskset(dev, 0x04A8, 0xFFCF, 0x0010); 1039 + b43_phy_maskset(dev, 0x04A8, 0xFFF0, 0x0006); 1040 + b43_phy_maskset(dev, 0x04A2, 0xF0FF, 0x0800); 1041 + b43_phy_maskset(dev, 0x04A0, 0xF0FF, 0x0500); 1042 + b43_phy_maskset(dev, 0x04A2, 0xFFF0, 0x000B); 985 1043 986 1044 if (phy->rev >= 3) { 987 - b43_phy_write(dev, 0x048A, b43_phy_read(dev, 0x048A) 988 - & ~0x8000); 989 - b43_phy_write(dev, 0x0415, (b43_phy_read(dev, 0x0415) 990 - & 0x8000) | 0x36D8); 991 - b43_phy_write(dev, 0x0416, (b43_phy_read(dev, 0x0416) 992 - & 0x8000) | 0x36D8); 993 - b43_phy_write(dev, 0x0417, (b43_phy_read(dev, 0x0417) 994 - & 0xFE00) | 0x016D); 1045 + b43_phy_mask(dev, 0x048A, (u16)~0x8000); 1046 + b43_phy_maskset(dev, 0x0415, 0x8000, 0x36D8); 1047 + b43_phy_maskset(dev, 0x0416, 0x8000, 0x36D8); 1048 + b43_phy_maskset(dev, 0x0417, 0xFE00, 0x016D); 995 1049 } else { 996 - b43_phy_write(dev, 0x048A, b43_phy_read(dev, 0x048A) 997 - | 0x1000); 998 - b43_phy_write(dev, 0x048A, (b43_phy_read(dev, 0x048A) 999 - & 0x9FFF) | 0x2000); 1050 + b43_phy_set(dev, 0x048A, 0x1000); 1051 + b43_phy_maskset(dev, 0x048A, 0x9FFF, 0x2000); 1000 1052 b43_hf_write(dev, b43_hf_read(dev) | B43_HF_ACIW); 1001 1053 } 1002 1054 if (phy->rev >= 2) { 1003 - b43_phy_write(dev, 0x042B, b43_phy_read(dev, 0x042B) 1004 - | 0x0800); 1055 + b43_phy_set(dev, 0x042B, 0x0800); 1005 1056 } 1006 - b43_phy_write(dev, 0x048C, (b43_phy_read(dev, 0x048C) 1007 - & 0xF0FF) | 0x0200); 1057 + b43_phy_maskset(dev, 0x048C, 0xF0FF, 0x0200); 1008 1058 if (phy->rev == 2) { 1009 - b43_phy_write(dev, 0x04AE, (b43_phy_read(dev, 0x04AE) 1010 - & 0xFF00) | 0x007F); 1011 - b43_phy_write(dev, 0x04AD, (b43_phy_read(dev, 0x04AD) 1012 - & 0x00FF) | 0x1300); 1059 + b43_phy_maskset(dev, 0x04AE, 0xFF00, 0x007F); 1060 + b43_phy_maskset(dev, 0x04AD, 0x00FF, 0x1300); 1013 1061 } else if (phy->rev >= 6) { 1014 1062 b43_ofdmtab_write16(dev, 0x1A00, 0x3, 0x007F); 1015 1063 b43_ofdmtab_write16(dev, 0x1A00, 0x2, 0x007F); 1016 - b43_phy_write(dev, 0x04AD, b43_phy_read(dev, 0x04AD) 1017 - & 0x00FF); 1064 + b43_phy_mask(dev, 0x04AD, 0x00FF); 1018 1065 } 1019 1066 b43_calc_nrssi_slope(dev); 1020 1067 break; ··· 1009 1104 switch (mode) { 1010 1105 case B43_INTERFMODE_NONWLAN: 1011 1106 if (phy->rev != 1) { 1012 - b43_phy_write(dev, 0x042B, 1013 - b43_phy_read(dev, 0x042B) & ~0x0800); 1014 - b43_phy_write(dev, B43_PHY_G_CRS, 1015 - b43_phy_read(dev, 1016 - B43_PHY_G_CRS) | 0x4000); 1107 + b43_phy_mask(dev, 0x042B, ~0x0800); 1108 + b43_phy_set(dev, B43_PHY_G_CRS, 0x4000); 1017 1109 break; 1018 1110 } 1019 1111 radio_stackrestore(0x0078); 1020 1112 b43_calc_nrssi_threshold(dev); 1021 1113 phy_stackrestore(0x0406); 1022 - b43_phy_write(dev, 0x042B, b43_phy_read(dev, 0x042B) & ~0x0800); 1114 + b43_phy_mask(dev, 0x042B, ~0x0800); 1023 1115 if (!dev->bad_frames_preempt) { 1024 - b43_phy_write(dev, B43_PHY_RADIO_BITFIELD, 1025 - b43_phy_read(dev, B43_PHY_RADIO_BITFIELD) 1026 - & ~(1 << 11)); 1116 + b43_phy_mask(dev, B43_PHY_RADIO_BITFIELD, ~(1 << 11)); 1027 1117 } 1028 - b43_phy_write(dev, B43_PHY_G_CRS, 1029 - b43_phy_read(dev, B43_PHY_G_CRS) | 0x4000); 1118 + b43_phy_set(dev, B43_PHY_G_CRS, 0x4000); 1030 1119 phy_stackrestore(0x04A0); 1031 1120 phy_stackrestore(0x04A1); 1032 1121 phy_stackrestore(0x04A2); ··· 1288 1389 sav.phy_crs0 = b43_phy_read(dev, B43_PHY_CRS0); 1289 1390 sav.phy_classctl = b43_phy_read(dev, B43_PHY_CLASSCTL); 1290 1391 1291 - b43_phy_write(dev, B43_PHY_ANALOGOVER, 1292 - b43_phy_read(dev, B43_PHY_ANALOGOVER) 1293 - | 0x0003); 1294 - b43_phy_write(dev, B43_PHY_ANALOGOVERVAL, 1295 - b43_phy_read(dev, B43_PHY_ANALOGOVERVAL) 1296 - & 0xFFFC); 1297 - b43_phy_write(dev, B43_PHY_CRS0, b43_phy_read(dev, B43_PHY_CRS0) 1298 - & 0x7FFF); 1299 - b43_phy_write(dev, B43_PHY_CLASSCTL, 1300 - b43_phy_read(dev, B43_PHY_CLASSCTL) 1301 - & 0xFFFC); 1392 + b43_phy_set(dev, B43_PHY_ANALOGOVER, 0x0003); 1393 + b43_phy_mask(dev, B43_PHY_ANALOGOVERVAL, 0xFFFC); 1394 + b43_phy_mask(dev, B43_PHY_CRS0, 0x7FFF); 1395 + b43_phy_mask(dev, B43_PHY_CLASSCTL, 0xFFFC); 1302 1396 if (has_loopback_gain(phy)) { 1303 1397 sav.phy_lo_mask = b43_phy_read(dev, B43_PHY_LO_MASK); 1304 1398 sav.phy_lo_ctl = b43_phy_read(dev, B43_PHY_LO_CTL); ··· 1312 1420 b43_write16(dev, 0x3E2, b43_read16(dev, 0x3E2) | 0x8000); 1313 1421 1314 1422 sav.phy_syncctl = b43_phy_read(dev, B43_PHY_SYNCCTL); 1315 - b43_phy_write(dev, B43_PHY_SYNCCTL, b43_phy_read(dev, B43_PHY_SYNCCTL) 1316 - & 0xFF7F); 1423 + b43_phy_mask(dev, B43_PHY_SYNCCTL, 0xFF7F); 1317 1424 sav.reg_3E6 = b43_read16(dev, 0x3E6); 1318 1425 sav.reg_3F4 = b43_read16(dev, 0x3F4); 1319 1426 ··· 1320 1429 b43_write16(dev, 0x03E6, 0x0122); 1321 1430 } else { 1322 1431 if (phy->analog >= 2) { 1323 - b43_phy_write(dev, B43_PHY_CCK(0x03), 1324 - (b43_phy_read(dev, B43_PHY_CCK(0x03)) 1325 - & 0xFFBF) | 0x40); 1432 + b43_phy_maskset(dev, B43_PHY_CCK(0x03), 0xFFBF, 0x40); 1326 1433 } 1327 1434 b43_write16(dev, B43_MMIO_CHANNEL_EXT, 1328 1435 (b43_read16(dev, B43_MMIO_CHANNEL_EXT) | 0x2000)); ··· 1343 1454 LPD(0, 0, 1))); 1344 1455 } 1345 1456 b43_phy_write(dev, B43_PHY_PGACTL, 0xBFA0); 1346 - b43_radio_write16(dev, 0x51, b43_radio_read16(dev, 0x51) 1347 - | 0x0004); 1457 + b43_radio_set(dev, 0x51, 0x0004); 1348 1458 if (phy->radio_rev == 8) { 1349 1459 b43_radio_write16(dev, 0x43, 0x1F); 1350 1460 } else { 1351 1461 b43_radio_write16(dev, 0x52, 0); 1352 - b43_radio_write16(dev, 0x43, (b43_radio_read16(dev, 0x43) 1353 - & 0xFFF0) | 0x0009); 1462 + b43_radio_maskset(dev, 0x43, 0xFFF0, 0x0009); 1354 1463 } 1355 1464 b43_phy_write(dev, B43_PHY_CCK(0x58), 0); 1356 1465 ··· 1497 1610 u8 old_channel; 1498 1611 1499 1612 if (phy->analog == 1) { 1500 - b43_radio_write16(dev, 0x007A, b43_radio_read16(dev, 0x007A) 1501 - | 0x0050); 1613 + b43_radio_set(dev, 0x007A, 0x0050); 1502 1614 } 1503 1615 if ((bus->boardinfo.vendor != SSB_BOARDVENDOR_BCM) && 1504 1616 (bus->boardinfo.type != SSB_BOARD_BU4306)) { ··· 1507 1621 value += 0x202; 1508 1622 } 1509 1623 } 1510 - b43_phy_write(dev, 0x0035, (b43_phy_read(dev, 0x0035) & 0xF0FF) 1511 - | 0x0700); 1624 + b43_phy_maskset(dev, 0x0035, 0xF0FF, 0x0700); 1512 1625 if (phy->radio_ver == 0x2050) 1513 1626 b43_phy_write(dev, 0x0038, 0x0667); 1514 1627 1515 1628 if (phy->gmode || phy->rev >= 2) { 1516 1629 if (phy->radio_ver == 0x2050) { 1517 - b43_radio_write16(dev, 0x007A, 1518 - b43_radio_read16(dev, 0x007A) 1519 - | 0x0020); 1520 - b43_radio_write16(dev, 0x0051, 1521 - b43_radio_read16(dev, 0x0051) 1522 - | 0x0004); 1630 + b43_radio_set(dev, 0x007A, 0x0020); 1631 + b43_radio_set(dev, 0x0051, 0x0004); 1523 1632 } 1524 1633 b43_write16(dev, B43_MMIO_PHY_RADIO, 0x0000); 1525 1634 1526 - b43_phy_write(dev, 0x0802, b43_phy_read(dev, 0x0802) | 0x0100); 1527 - b43_phy_write(dev, 0x042B, b43_phy_read(dev, 0x042B) | 0x2000); 1635 + b43_phy_set(dev, 0x0802, 0x0100); 1636 + b43_phy_set(dev, 0x042B, 0x2000); 1528 1637 1529 1638 b43_phy_write(dev, 0x001C, 0x186A); 1530 1639 1531 - b43_phy_write(dev, 0x0013, 1532 - (b43_phy_read(dev, 0x0013) & 0x00FF) | 0x1900); 1533 - b43_phy_write(dev, 0x0035, 1534 - (b43_phy_read(dev, 0x0035) & 0xFFC0) | 0x0064); 1535 - b43_phy_write(dev, 0x005D, 1536 - (b43_phy_read(dev, 0x005D) & 0xFF80) | 0x000A); 1640 + b43_phy_maskset(dev, 0x0013, 0x00FF, 0x1900); 1641 + b43_phy_maskset(dev, 0x0035, 0xFFC0, 0x0064); 1642 + b43_phy_maskset(dev, 0x005D, 0xFF80, 0x000A); 1537 1643 } 1538 1644 1539 1645 if (dev->bad_frames_preempt) { 1540 - b43_phy_write(dev, B43_PHY_RADIO_BITFIELD, 1541 - b43_phy_read(dev, 1542 - B43_PHY_RADIO_BITFIELD) | (1 << 11)); 1646 + b43_phy_set(dev, B43_PHY_RADIO_BITFIELD, (1 << 11)); 1543 1647 } 1544 1648 1545 1649 if (phy->analog == 1) { ··· 1571 1695 b43_radio_write16(dev, 0x005B, 0x007B); 1572 1696 b43_radio_write16(dev, 0x005C, 0x00B0); 1573 1697 1574 - b43_radio_write16(dev, 0x007A, b43_radio_read16(dev, 0x007A) | 0x0007); 1698 + b43_radio_set(dev, 0x007A, 0x0007); 1575 1699 1576 1700 b43_gphy_channel_switch(dev, old_channel, 0); 1577 1701 ··· 1647 1771 val += 0x0202; 1648 1772 } 1649 1773 if (phy->type == B43_PHYTYPE_G) { 1650 - b43_radio_write16(dev, 0x007A, 1651 - b43_radio_read16(dev, 0x007A) | 0x0020); 1652 - b43_radio_write16(dev, 0x0051, 1653 - b43_radio_read16(dev, 0x0051) | 0x0004); 1654 - b43_phy_write(dev, 0x0802, b43_phy_read(dev, 0x0802) | 0x0100); 1655 - b43_phy_write(dev, 0x042B, b43_phy_read(dev, 0x042B) | 0x2000); 1774 + b43_radio_set(dev, 0x007A, 0x0020); 1775 + b43_radio_set(dev, 0x0051, 0x0004); 1776 + b43_phy_set(dev, 0x0802, 0x0100); 1777 + b43_phy_set(dev, 0x042B, 0x2000); 1656 1778 b43_phy_write(dev, 0x5B, 0); 1657 1779 b43_phy_write(dev, 0x5C, 0); 1658 1780 } ··· 1675 1801 b43_radio_write16(dev, 0x5B, 0x7B); 1676 1802 b43_radio_write16(dev, 0x5C, 0xB0); 1677 1803 } 1678 - b43_radio_write16(dev, 0x007A, 1679 - (b43_radio_read16(dev, 0x007A) & 0x00F8) | 0x0007); 1804 + b43_radio_maskset(dev, 0x007A, 0x00F8, 0x0007); 1680 1805 1681 1806 b43_gphy_channel_switch(dev, old_channel, 0); 1682 1807 ··· 1687 1814 b43_phy_write(dev, 0x0038, 0x0668); 1688 1815 b43_set_txpower_g(dev, &gphy->bbatt, &gphy->rfatt, gphy->tx_control); 1689 1816 if (phy->radio_rev <= 5) { 1690 - b43_phy_write(dev, 0x5D, (b43_phy_read(dev, 0x5D) 1691 - & 0xFF80) | 0x0003); 1817 + b43_phy_maskset(dev, 0x5D, 0xFF80, 0x0003); 1692 1818 } 1693 1819 if (phy->radio_rev <= 2) 1694 1820 b43_radio_write16(dev, 0x005D, 0x000D); 1695 1821 1696 1822 if (phy->analog == 4) { 1697 1823 b43_write16(dev, 0x3E4, 9); 1698 - b43_phy_write(dev, 0x61, b43_phy_read(dev, 0x61) 1699 - & 0x0FFF); 1824 + b43_phy_mask(dev, 0x61, 0x0FFF); 1700 1825 } else { 1701 - b43_phy_write(dev, 0x0002, (b43_phy_read(dev, 0x0002) & 0xFFC0) 1702 - | 0x0004); 1826 + b43_phy_maskset(dev, 0x0002, 0xFFC0, 0x0004); 1703 1827 } 1704 1828 if (phy->type == B43_PHYTYPE_B) 1705 1829 B43_WARN_ON(1); ··· 1738 1868 backup_radio[1] = b43_radio_read16(dev, 0x43); 1739 1869 backup_radio[2] = b43_radio_read16(dev, 0x7A); 1740 1870 1741 - b43_phy_write(dev, B43_PHY_CRS0, 1742 - b43_phy_read(dev, B43_PHY_CRS0) & 0x3FFF); 1743 - b43_phy_write(dev, B43_PHY_CCKBBANDCFG, 1744 - b43_phy_read(dev, B43_PHY_CCKBBANDCFG) | 0x8000); 1745 - b43_phy_write(dev, B43_PHY_RFOVER, 1746 - b43_phy_read(dev, B43_PHY_RFOVER) | 0x0002); 1747 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1748 - b43_phy_read(dev, B43_PHY_RFOVERVAL) & 0xFFFD); 1749 - b43_phy_write(dev, B43_PHY_RFOVER, 1750 - b43_phy_read(dev, B43_PHY_RFOVER) | 0x0001); 1751 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1752 - b43_phy_read(dev, B43_PHY_RFOVERVAL) & 0xFFFE); 1871 + b43_phy_mask(dev, B43_PHY_CRS0, 0x3FFF); 1872 + b43_phy_set(dev, B43_PHY_CCKBBANDCFG, 0x8000); 1873 + b43_phy_set(dev, B43_PHY_RFOVER, 0x0002); 1874 + b43_phy_mask(dev, B43_PHY_RFOVERVAL, 0xFFFD); 1875 + b43_phy_set(dev, B43_PHY_RFOVER, 0x0001); 1876 + b43_phy_mask(dev, B43_PHY_RFOVERVAL, 0xFFFE); 1753 1877 if (phy->rev != 1) { /* Not in specs, but needed to prevent PPC machine check */ 1754 - b43_phy_write(dev, B43_PHY_ANALOGOVER, 1755 - b43_phy_read(dev, B43_PHY_ANALOGOVER) | 0x0001); 1756 - b43_phy_write(dev, B43_PHY_ANALOGOVERVAL, 1757 - b43_phy_read(dev, 1758 - B43_PHY_ANALOGOVERVAL) & 0xFFFE); 1759 - b43_phy_write(dev, B43_PHY_ANALOGOVER, 1760 - b43_phy_read(dev, B43_PHY_ANALOGOVER) | 0x0002); 1761 - b43_phy_write(dev, B43_PHY_ANALOGOVERVAL, 1762 - b43_phy_read(dev, 1763 - B43_PHY_ANALOGOVERVAL) & 0xFFFD); 1878 + b43_phy_set(dev, B43_PHY_ANALOGOVER, 0x0001); 1879 + b43_phy_mask(dev, B43_PHY_ANALOGOVERVAL, 0xFFFE); 1880 + b43_phy_set(dev, B43_PHY_ANALOGOVER, 0x0002); 1881 + b43_phy_mask(dev, B43_PHY_ANALOGOVERVAL, 0xFFFD); 1764 1882 } 1765 - b43_phy_write(dev, B43_PHY_RFOVER, 1766 - b43_phy_read(dev, B43_PHY_RFOVER) | 0x000C); 1767 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1768 - b43_phy_read(dev, B43_PHY_RFOVERVAL) | 0x000C); 1769 - b43_phy_write(dev, B43_PHY_RFOVER, 1770 - b43_phy_read(dev, B43_PHY_RFOVER) | 0x0030); 1771 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1772 - (b43_phy_read(dev, B43_PHY_RFOVERVAL) 1773 - & 0xFFCF) | 0x10); 1883 + b43_phy_set(dev, B43_PHY_RFOVER, 0x000C); 1884 + b43_phy_set(dev, B43_PHY_RFOVERVAL, 0x000C); 1885 + b43_phy_set(dev, B43_PHY_RFOVER, 0x0030); 1886 + b43_phy_maskset(dev, B43_PHY_RFOVERVAL, 0xFFCF, 0x10); 1774 1887 1775 1888 b43_phy_write(dev, B43_PHY_CCK(0x5A), 0x0780); 1776 1889 b43_phy_write(dev, B43_PHY_CCK(0x59), 0xC810); 1777 1890 b43_phy_write(dev, B43_PHY_CCK(0x58), 0x000D); 1778 1891 1779 - b43_phy_write(dev, B43_PHY_CCK(0x0A), 1780 - b43_phy_read(dev, B43_PHY_CCK(0x0A)) | 0x2000); 1892 + b43_phy_set(dev, B43_PHY_CCK(0x0A), 0x2000); 1781 1893 if (phy->rev != 1) { /* Not in specs, but needed to prevent PPC machine check */ 1782 - b43_phy_write(dev, B43_PHY_ANALOGOVER, 1783 - b43_phy_read(dev, B43_PHY_ANALOGOVER) | 0x0004); 1784 - b43_phy_write(dev, B43_PHY_ANALOGOVERVAL, 1785 - b43_phy_read(dev, 1786 - B43_PHY_ANALOGOVERVAL) & 0xFFFB); 1894 + b43_phy_set(dev, B43_PHY_ANALOGOVER, 0x0004); 1895 + b43_phy_mask(dev, B43_PHY_ANALOGOVERVAL, 0xFFFB); 1787 1896 } 1788 - b43_phy_write(dev, B43_PHY_CCK(0x03), 1789 - (b43_phy_read(dev, B43_PHY_CCK(0x03)) 1790 - & 0xFF9F) | 0x40); 1897 + b43_phy_maskset(dev, B43_PHY_CCK(0x03), 0xFF9F, 0x40); 1791 1898 1792 1899 if (phy->radio_rev == 8) { 1793 1900 b43_radio_write16(dev, 0x43, 0x000F); 1794 1901 } else { 1795 1902 b43_radio_write16(dev, 0x52, 0); 1796 - b43_radio_write16(dev, 0x43, (b43_radio_read16(dev, 0x43) 1797 - & 0xFFF0) | 0x9); 1903 + b43_radio_maskset(dev, 0x43, 0xFFF0, 0x9); 1798 1904 } 1799 1905 b43_gphy_set_baseband_attenuation(dev, 11); 1800 1906 ··· 1780 1934 b43_phy_write(dev, B43_PHY_LO_MASK, 0x8020); 1781 1935 b43_phy_write(dev, B43_PHY_LO_CTL, 0); 1782 1936 1783 - b43_phy_write(dev, B43_PHY_CCK(0x2B), 1784 - (b43_phy_read(dev, B43_PHY_CCK(0x2B)) 1785 - & 0xFFC0) | 0x01); 1786 - b43_phy_write(dev, B43_PHY_CCK(0x2B), 1787 - (b43_phy_read(dev, B43_PHY_CCK(0x2B)) 1788 - & 0xC0FF) | 0x800); 1937 + b43_phy_maskset(dev, B43_PHY_CCK(0x2B), 0xFFC0, 0x01); 1938 + b43_phy_maskset(dev, B43_PHY_CCK(0x2B), 0xC0FF, 0x800); 1789 1939 1790 - b43_phy_write(dev, B43_PHY_RFOVER, 1791 - b43_phy_read(dev, B43_PHY_RFOVER) | 0x0100); 1792 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1793 - b43_phy_read(dev, B43_PHY_RFOVERVAL) & 0xCFFF); 1940 + b43_phy_set(dev, B43_PHY_RFOVER, 0x0100); 1941 + b43_phy_mask(dev, B43_PHY_RFOVERVAL, 0xCFFF); 1794 1942 1795 1943 if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_EXTLNA) { 1796 1944 if (phy->rev >= 7) { 1797 - b43_phy_write(dev, B43_PHY_RFOVER, 1798 - b43_phy_read(dev, B43_PHY_RFOVER) 1799 - | 0x0800); 1800 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1801 - b43_phy_read(dev, B43_PHY_RFOVERVAL) 1802 - | 0x8000); 1945 + b43_phy_set(dev, B43_PHY_RFOVER, 0x0800); 1946 + b43_phy_set(dev, B43_PHY_RFOVERVAL, 0x8000); 1803 1947 } 1804 1948 } 1805 - b43_radio_write16(dev, 0x7A, b43_radio_read16(dev, 0x7A) 1806 - & 0x00F7); 1949 + b43_radio_mask(dev, 0x7A, 0x00F7); 1807 1950 1808 1951 j = 0; 1809 1952 loop_i_max = (phy->radio_rev == 8) ? 15 : 9; 1810 1953 for (i = 0; i < loop_i_max; i++) { 1811 1954 for (j = 0; j < 16; j++) { 1812 1955 b43_radio_write16(dev, 0x43, i); 1813 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1814 - (b43_phy_read(dev, B43_PHY_RFOVERVAL) 1815 - & 0xF0FF) | (j << 8)); 1816 - b43_phy_write(dev, B43_PHY_PGACTL, 1817 - (b43_phy_read(dev, B43_PHY_PGACTL) 1818 - & 0x0FFF) | 0xA000); 1819 - b43_phy_write(dev, B43_PHY_PGACTL, 1820 - b43_phy_read(dev, B43_PHY_PGACTL) 1821 - | 0xF000); 1956 + b43_phy_maskset(dev, B43_PHY_RFOVERVAL, 0xF0FF, (j << 8)); 1957 + b43_phy_maskset(dev, B43_PHY_PGACTL, 0x0FFF, 0xA000); 1958 + b43_phy_set(dev, B43_PHY_PGACTL, 0xF000); 1822 1959 udelay(20); 1823 1960 if (b43_phy_read(dev, B43_PHY_LO_LEAKAGE) >= 0xDFC) 1824 1961 goto exit_loop1; ··· 1811 1982 loop1_outer_done = i; 1812 1983 loop1_inner_done = j; 1813 1984 if (j >= 8) { 1814 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1815 - b43_phy_read(dev, B43_PHY_RFOVERVAL) 1816 - | 0x30); 1985 + b43_phy_set(dev, B43_PHY_RFOVERVAL, 0x30); 1817 1986 trsw_rx = 0x1B; 1818 1987 for (j = j - 8; j < 16; j++) { 1819 - b43_phy_write(dev, B43_PHY_RFOVERVAL, 1820 - (b43_phy_read(dev, B43_PHY_RFOVERVAL) 1821 - & 0xF0FF) | (j << 8)); 1822 - b43_phy_write(dev, B43_PHY_PGACTL, 1823 - (b43_phy_read(dev, B43_PHY_PGACTL) 1824 - & 0x0FFF) | 0xA000); 1825 - b43_phy_write(dev, B43_PHY_PGACTL, 1826 - b43_phy_read(dev, B43_PHY_PGACTL) 1827 - | 0xF000); 1988 + b43_phy_maskset(dev, B43_PHY_RFOVERVAL, 0xF0FF, (j << 8)); 1989 + b43_phy_maskset(dev, B43_PHY_PGACTL, 0x0FFF, 0xA000); 1990 + b43_phy_set(dev, B43_PHY_PGACTL, 0xF000); 1828 1991 udelay(20); 1829 1992 trsw_rx -= 3; 1830 1993 if (b43_phy_read(dev, B43_PHY_LO_LEAKAGE) >= 0xDFC) ··· 1867 2046 return; 1868 2047 } 1869 2048 1870 - b43_phy_write(dev, 0x0036, b43_phy_read(dev, 0x0036) & 0xFEFF); 2049 + b43_phy_mask(dev, 0x0036, 0xFEFF); 1871 2050 b43_phy_write(dev, 0x002F, 0x0202); 1872 - b43_phy_write(dev, 0x047C, b43_phy_read(dev, 0x047C) | 0x0002); 1873 - b43_phy_write(dev, 0x047A, b43_phy_read(dev, 0x047A) | 0xF000); 2051 + b43_phy_set(dev, 0x047C, 0x0002); 2052 + b43_phy_set(dev, 0x047A, 0xF000); 1874 2053 if (phy->radio_ver == 0x2050 && phy->radio_rev == 8) { 1875 - b43_phy_write(dev, 0x047A, (b43_phy_read(dev, 0x047A) 1876 - & 0xFF0F) | 0x0010); 1877 - b43_phy_write(dev, 0x005D, b43_phy_read(dev, 0x005D) 1878 - | 0x8000); 1879 - b43_phy_write(dev, 0x004E, (b43_phy_read(dev, 0x004E) 1880 - & 0xFFC0) | 0x0010); 2054 + b43_phy_maskset(dev, 0x047A, 0xFF0F, 0x0010); 2055 + b43_phy_set(dev, 0x005D, 0x8000); 2056 + b43_phy_maskset(dev, 0x004E, 0xFFC0, 0x0010); 1881 2057 b43_phy_write(dev, 0x002E, 0xC07F); 1882 - b43_phy_write(dev, 0x0036, b43_phy_read(dev, 0x0036) 1883 - | 0x0400); 2058 + b43_phy_set(dev, 0x0036, 0x0400); 1884 2059 } else { 1885 - b43_phy_write(dev, 0x0036, b43_phy_read(dev, 0x0036) 1886 - | 0x0200); 1887 - b43_phy_write(dev, 0x0036, b43_phy_read(dev, 0x0036) 1888 - | 0x0400); 1889 - b43_phy_write(dev, 0x005D, b43_phy_read(dev, 0x005D) 1890 - & 0x7FFF); 1891 - b43_phy_write(dev, 0x004F, b43_phy_read(dev, 0x004F) 1892 - & 0xFFFE); 1893 - b43_phy_write(dev, 0x004E, (b43_phy_read(dev, 0x004E) 1894 - & 0xFFC0) | 0x0010); 2060 + b43_phy_set(dev, 0x0036, 0x0200); 2061 + b43_phy_set(dev, 0x0036, 0x0400); 2062 + b43_phy_mask(dev, 0x005D, 0x7FFF); 2063 + b43_phy_mask(dev, 0x004F, 0xFFFE); 2064 + b43_phy_maskset(dev, 0x004E, 0xFFC0, 0x0010); 1895 2065 b43_phy_write(dev, 0x002E, 0xC07F); 1896 - b43_phy_write(dev, 0x047A, (b43_phy_read(dev, 0x047A) 1897 - & 0xFF0F) | 0x0010); 2066 + b43_phy_maskset(dev, 0x047A, 0xFF0F, 0x0010); 1898 2067 } 1899 2068 } 1900 2069 ··· 1900 2089 return; 1901 2090 } 1902 2091 1903 - b43_phy_write(dev, 0x0036, (b43_phy_read(dev, 0x0036) & 0xFFC0) 1904 - | (gphy->tgt_idle_tssi - gphy->cur_idle_tssi)); 1905 - b43_phy_write(dev, 0x0478, (b43_phy_read(dev, 0x0478) & 0xFF00) 1906 - | (gphy->tgt_idle_tssi - gphy->cur_idle_tssi)); 2092 + b43_phy_maskset(dev, 0x0036, 0xFFC0, (gphy->tgt_idle_tssi - gphy->cur_idle_tssi)); 2093 + b43_phy_maskset(dev, 0x0478, 0xFF00, (gphy->tgt_idle_tssi - gphy->cur_idle_tssi)); 1907 2094 b43_gphy_tssi_power_lt_init(dev); 1908 2095 b43_gphy_gain_lt_init(dev); 1909 - b43_phy_write(dev, 0x0060, b43_phy_read(dev, 0x0060) & 0xFFBF); 2096 + b43_phy_mask(dev, 0x0060, 0xFFBF); 1910 2097 b43_phy_write(dev, 0x0014, 0x0000); 1911 2098 1912 2099 B43_WARN_ON(phy->rev < 6); 1913 - b43_phy_write(dev, 0x0478, b43_phy_read(dev, 0x0478) 1914 - | 0x0800); 1915 - b43_phy_write(dev, 0x0478, b43_phy_read(dev, 0x0478) 1916 - & 0xFEFF); 1917 - b43_phy_write(dev, 0x0801, b43_phy_read(dev, 0x0801) 1918 - & 0xFFBF); 2100 + b43_phy_set(dev, 0x0478, 0x0800); 2101 + b43_phy_mask(dev, 0x0478, 0xFEFF); 2102 + b43_phy_mask(dev, 0x0801, 0xFFBF); 1919 2103 1920 2104 b43_gphy_dc_lt_init(dev, 1); 1921 2105 ··· 1945 2139 b43_hardware_pctl_early_init(dev); 1946 2140 if (gphy->cur_idle_tssi == 0) { 1947 2141 if (phy->radio_ver == 0x2050 && phy->analog == 0) { 1948 - b43_radio_write16(dev, 0x0076, 1949 - (b43_radio_read16(dev, 0x0076) 1950 - & 0x00F7) | 0x0084); 2142 + b43_radio_maskset(dev, 0x0076, 0x00F7, 0x0084); 1951 2143 } else { 1952 2144 struct b43_rfatt rfatt; 1953 2145 struct b43_bbatt bbatt; ··· 1978 2174 } 1979 2175 } 1980 2176 if (phy->radio_ver == 0x2050 && phy->analog == 0) { 1981 - b43_radio_write16(dev, 0x0076, 1982 - b43_radio_read16(dev, 0x0076) 1983 - & 0xFF7B); 2177 + b43_radio_mask(dev, 0x0076, 0xFF7B); 1984 2178 } else { 1985 2179 b43_set_txpower_g(dev, &old_bbatt, 1986 2180 &old_rfatt, old_tx_control); ··· 2022 2220 b43_phy_write(dev, B43_PHY_OFDM(0xC3), 0x8006); 2023 2221 } 2024 2222 if (tmp == 5) { 2025 - b43_phy_write(dev, B43_PHY_OFDM(0xCC), 2026 - (b43_phy_read(dev, B43_PHY_OFDM(0xCC)) 2027 - & 0x00FF) | 0x1F00); 2223 + b43_phy_maskset(dev, B43_PHY_OFDM(0xCC), 0x00FF, 0x1F00); 2028 2224 } 2029 2225 } 2030 2226 if ((phy->rev <= 2 && phy->gmode) || phy->rev >= 2) 2031 2227 b43_phy_write(dev, B43_PHY_OFDM(0x7E), 0x78); 2032 2228 if (phy->radio_rev == 8) { 2033 - b43_phy_write(dev, B43_PHY_EXTG(0x01), 2034 - b43_phy_read(dev, B43_PHY_EXTG(0x01)) 2035 - | 0x80); 2036 - b43_phy_write(dev, B43_PHY_OFDM(0x3E), 2037 - b43_phy_read(dev, B43_PHY_OFDM(0x3E)) 2038 - | 0x4); 2229 + b43_phy_set(dev, B43_PHY_EXTG(0x01), 0x80); 2230 + b43_phy_set(dev, B43_PHY_OFDM(0x3E), 0x4); 2039 2231 } 2040 2232 if (has_loopback_gain(phy)) 2041 2233 b43_calc_loopback_gain(dev); ··· 2047 2251 | gphy->lo_control->tx_bias | gphy-> 2048 2252 lo_control->tx_magn); 2049 2253 } else { 2050 - b43_radio_write16(dev, 0x52, 2051 - (b43_radio_read16(dev, 0x52) & 0xFFF0) 2052 - | gphy->lo_control->tx_bias); 2254 + b43_radio_maskset(dev, 0x52, 0xFFF0, gphy->lo_control->tx_bias); 2053 2255 } 2054 2256 if (phy->rev >= 6) { 2055 - b43_phy_write(dev, B43_PHY_CCK(0x36), 2056 - (b43_phy_read(dev, B43_PHY_CCK(0x36)) 2057 - & 0x0FFF) | (gphy->lo_control-> 2058 - tx_bias << 12)); 2257 + b43_phy_maskset(dev, B43_PHY_CCK(0x36), 0x0FFF, (gphy->lo_control->tx_bias << 12)); 2059 2258 } 2060 2259 if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_PACTRL) 2061 2260 b43_phy_write(dev, B43_PHY_CCK(0x2E), 0x8075); ··· 2089 2298 but OFDM is legal everywhere */ 2090 2299 if ((dev->dev->bus->chip_id == 0x4306 2091 2300 && dev->dev->bus->chip_package == 2) || 0) { 2092 - b43_phy_write(dev, B43_PHY_CRS0, b43_phy_read(dev, B43_PHY_CRS0) 2093 - & 0xBFFF); 2094 - b43_phy_write(dev, B43_PHY_OFDM(0xC3), 2095 - b43_phy_read(dev, B43_PHY_OFDM(0xC3)) 2096 - & 0x7FFF); 2301 + b43_phy_mask(dev, B43_PHY_CRS0, 0xBFFF); 2302 + b43_phy_mask(dev, B43_PHY_OFDM(0xC3), 0x7FFF); 2097 2303 } 2098 2304 } 2099 2305 ··· 2292 2504 2293 2505 b43_phy_lock(dev); 2294 2506 b43_radio_lock(dev); 2295 - b43_phy_write(dev, 0x0802, b43_phy_read(dev, 0x0802) & 0xFFFC); 2296 - b43_phy_write(dev, B43_PHY_G_CRS, 2297 - b43_phy_read(dev, B43_PHY_G_CRS) & 0x7FFF); 2507 + b43_phy_mask(dev, 0x0802, 0xFFFC); 2508 + b43_phy_mask(dev, B43_PHY_G_CRS, 0x7FFF); 2298 2509 b43_set_all_gains(dev, 3, 8, 1); 2299 2510 2300 2511 start = (channel - 5 > 0) ? channel - 5 : 1; ··· 2304 2517 ret[i - 1] = b43_gphy_aci_detect(dev, i); 2305 2518 } 2306 2519 b43_switch_channel(dev, channel); 2307 - b43_phy_write(dev, 0x0802, 2308 - (b43_phy_read(dev, 0x0802) & 0xFFFC) | 0x0003); 2309 - b43_phy_write(dev, 0x0403, b43_phy_read(dev, 0x0403) & 0xFFF8); 2310 - b43_phy_write(dev, B43_PHY_G_CRS, 2311 - b43_phy_read(dev, B43_PHY_G_CRS) | 0x8000); 2520 + b43_phy_maskset(dev, 0x0802, 0xFFFC, 0x0003); 2521 + b43_phy_mask(dev, 0x0403, 0xFFF8); 2522 + b43_phy_set(dev, B43_PHY_G_CRS, 0x8000); 2312 2523 b43_set_original_gains(dev); 2313 2524 for (i = 0; i < 13; i++) { 2314 2525 if (!ret[i]) ··· 2350 2565 return 0; 2351 2566 } 2352 2567 2353 - u8 * b43_generate_dyn_tssi2dbm_tab(struct b43_wldev *dev, 2354 - s16 pab0, s16 pab1, s16 pab2) 2568 + u8 *b43_generate_dyn_tssi2dbm_tab(struct b43_wldev *dev, 2569 + s16 pab0, s16 pab1, s16 pab2) 2355 2570 { 2356 2571 unsigned int i; 2357 2572 u8 *tab;
+8 -8
drivers/net/wireless/b43/pio.c
··· 55 55 } 56 56 57 57 static 58 - struct b43_pio_txqueue * parse_cookie(struct b43_wldev *dev, 59 - u16 cookie, 58 + struct b43_pio_txqueue *parse_cookie(struct b43_wldev *dev, 59 + u16 cookie, 60 60 struct b43_pio_txpacket **pack) 61 61 { 62 62 struct b43_pio *pio = &dev->pio; ··· 134 134 return 8; 135 135 } 136 136 137 - static struct b43_pio_txqueue * b43_setup_pioqueue_tx(struct b43_wldev *dev, 138 - unsigned int index) 137 + static struct b43_pio_txqueue *b43_setup_pioqueue_tx(struct b43_wldev *dev, 138 + unsigned int index) 139 139 { 140 140 struct b43_pio_txqueue *q; 141 141 struct b43_pio_txpacket *p; ··· 171 171 return q; 172 172 } 173 173 174 - static struct b43_pio_rxqueue * b43_setup_pioqueue_rx(struct b43_wldev *dev, 175 - unsigned int index) 174 + static struct b43_pio_rxqueue *b43_setup_pioqueue_rx(struct b43_wldev *dev, 175 + unsigned int index) 176 176 { 177 177 struct b43_pio_rxqueue *q; 178 178 ··· 308 308 } 309 309 310 310 /* Static mapping of mac80211's queues (priorities) to b43 PIO queues. */ 311 - static struct b43_pio_txqueue * select_queue_by_priority(struct b43_wldev *dev, 312 - u8 queue_prio) 311 + static struct b43_pio_txqueue *select_queue_by_priority(struct b43_wldev *dev, 312 + u8 queue_prio) 313 313 { 314 314 struct b43_pio_txqueue *q; 315 315
+1 -1
drivers/net/wireless/b43/rfkill.c
··· 113 113 return err; 114 114 } 115 115 116 - char * b43_rfkill_led_name(struct b43_wldev *dev) 116 + char *b43_rfkill_led_name(struct b43_wldev *dev) 117 117 { 118 118 struct b43_rfkill *rfk = &(dev->wl->rfkill); 119 119
+37 -76
drivers/net/wireless/b43/wa.c
··· 62 62 struct b43_phy *phy = &dev->phy; 63 63 64 64 b43_phy_write(dev, B43_PHY_LNAHPFCTL, 0x1FF9); 65 - b43_phy_write(dev, B43_PHY_LPFGAINCTL, 66 - b43_phy_read(dev, B43_PHY_LPFGAINCTL) & 0xFF0F); 65 + b43_phy_mask(dev, B43_PHY_LPFGAINCTL, 0xFF0F); 67 66 if (phy->rev <= 2) 68 67 b43_ofdmtab_write16(dev, B43_OFDMTAB_LPFGAIN, 0, 0x1FBF); 69 68 b43_radio_write16(dev, 0x0002, 0x1FBF); ··· 72 73 b43_phy_write(dev, 0x001D, 0x0F40); 73 74 b43_phy_write(dev, 0x001F, 0x1C00); 74 75 if (phy->rev <= 3) 75 - b43_phy_write(dev, 0x002A, 76 - (b43_phy_read(dev, 0x002A) & 0x00FF) | 0x0400); 76 + b43_phy_maskset(dev, 0x002A, 0x00FF, 0x0400); 77 77 else if (phy->rev == 5) { 78 - b43_phy_write(dev, 0x002A, 79 - (b43_phy_read(dev, 0x002A) & 0x00FF) | 0x1A00); 78 + b43_phy_maskset(dev, 0x002A, 0x00FF, 0x1A00); 80 79 b43_phy_write(dev, 0x00CC, 0x2121); 81 80 } 82 81 if (phy->rev >= 3) ··· 83 86 84 87 static void b43_wa_divider(struct b43_wldev *dev) 85 88 { 86 - b43_phy_write(dev, 0x002B, b43_phy_read(dev, 0x002B) & ~0x0100); 89 + b43_phy_mask(dev, 0x002B, ~0x0100); 87 90 b43_phy_write(dev, 0x008E, 0x58C1); 88 91 } 89 92 ··· 269 272 270 273 static void b43_wa_lms(struct b43_wldev *dev) 271 274 { 272 - b43_phy_write(dev, 0x0055, 273 - (b43_phy_read(dev, 0x0055) & 0xFFC0) | 0x0004); 275 + b43_phy_maskset(dev, 0x0055, 0xFFC0, 0x0004); 274 276 } 275 277 276 278 static void b43_wa_mixedsignal(struct b43_wldev *dev) ··· 314 318 } else if (phy->rev == 2) { 315 319 b43_phy_write(dev, B43_PHY_CRSTHRES1, 0x1861); 316 320 b43_phy_write(dev, B43_PHY_CRSTHRES2, 0x0271); 317 - b43_phy_write(dev, B43_PHY_ANTDWELL, 318 - b43_phy_read(dev, B43_PHY_ANTDWELL) 319 - | 0x0800); 321 + b43_phy_set(dev, B43_PHY_ANTDWELL, 0x0800); 320 322 } else { 321 323 b43_phy_write(dev, B43_PHY_CRSTHRES1, 0x0098); 322 324 b43_phy_write(dev, B43_PHY_CRSTHRES2, 0x0070); 323 325 b43_phy_write(dev, B43_PHY_OFDM(0xC9), 0x0080); 324 - b43_phy_write(dev, B43_PHY_ANTDWELL, 325 - b43_phy_read(dev, B43_PHY_ANTDWELL) 326 - | 0x0800); 326 + b43_phy_set(dev, B43_PHY_ANTDWELL, 0x0800); 327 327 } 328 328 } 329 329 330 330 static void b43_wa_crs_thr(struct b43_wldev *dev) 331 331 { 332 - b43_phy_write(dev, B43_PHY_CRS0, 333 - (b43_phy_read(dev, B43_PHY_CRS0) & ~0x03C0) | 0xD000); 332 + b43_phy_maskset(dev, B43_PHY_CRS0, ~0x03C0, 0xD000); 334 333 } 335 334 336 335 static void b43_wa_crs_blank(struct b43_wldev *dev) ··· 382 391 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 3, 25); 383 392 } 384 393 385 - b43_phy_write(dev, B43_PHY_CCKSHIFTBITS_WA, 386 - (b43_phy_read(dev, B43_PHY_CCKSHIFTBITS_WA) & ~0xFF00) | 0x5700); 387 - b43_phy_write(dev, B43_PHY_OFDM(0x1A), 388 - (b43_phy_read(dev, B43_PHY_OFDM(0x1A)) & ~0x007F) | 0x000F); 389 - b43_phy_write(dev, B43_PHY_OFDM(0x1A), 390 - (b43_phy_read(dev, B43_PHY_OFDM(0x1A)) & ~0x3F80) | 0x2B80); 391 - b43_phy_write(dev, B43_PHY_ANTWRSETT, 392 - (b43_phy_read(dev, B43_PHY_ANTWRSETT) & 0xF0FF) | 0x0300); 393 - b43_radio_write16(dev, 0x7A, 394 - b43_radio_read16(dev, 0x7A) | 0x0008); 395 - b43_phy_write(dev, B43_PHY_N1P1GAIN, 396 - (b43_phy_read(dev, B43_PHY_N1P1GAIN) & ~0x000F) | 0x0008); 397 - b43_phy_write(dev, B43_PHY_P1P2GAIN, 398 - (b43_phy_read(dev, B43_PHY_P1P2GAIN) & ~0x0F00) | 0x0600); 399 - b43_phy_write(dev, B43_PHY_N1N2GAIN, 400 - (b43_phy_read(dev, B43_PHY_N1N2GAIN) & ~0x0F00) | 0x0700); 401 - b43_phy_write(dev, B43_PHY_N1P1GAIN, 402 - (b43_phy_read(dev, B43_PHY_N1P1GAIN) & ~0x0F00) | 0x0100); 394 + b43_phy_maskset(dev, B43_PHY_CCKSHIFTBITS_WA, (u16)~0xFF00, 0x5700); 395 + b43_phy_maskset(dev, B43_PHY_OFDM(0x1A), ~0x007F, 0x000F); 396 + b43_phy_maskset(dev, B43_PHY_OFDM(0x1A), ~0x3F80, 0x2B80); 397 + b43_phy_maskset(dev, B43_PHY_ANTWRSETT, 0xF0FF, 0x0300); 398 + b43_radio_set(dev, 0x7A, 0x0008); 399 + b43_phy_maskset(dev, B43_PHY_N1P1GAIN, ~0x000F, 0x0008); 400 + b43_phy_maskset(dev, B43_PHY_P1P2GAIN, ~0x0F00, 0x0600); 401 + b43_phy_maskset(dev, B43_PHY_N1N2GAIN, ~0x0F00, 0x0700); 402 + b43_phy_maskset(dev, B43_PHY_N1P1GAIN, ~0x0F00, 0x0100); 403 403 if (phy->rev == 1) { 404 - b43_phy_write(dev, B43_PHY_N1N2GAIN, 405 - (b43_phy_read(dev, B43_PHY_N1N2GAIN) 406 - & ~0x000F) | 0x0007); 404 + b43_phy_maskset(dev, B43_PHY_N1N2GAIN, ~0x000F, 0x0007); 407 405 } 408 - b43_phy_write(dev, B43_PHY_OFDM(0x88), 409 - (b43_phy_read(dev, B43_PHY_OFDM(0x88)) & ~0x00FF) | 0x001C); 410 - b43_phy_write(dev, B43_PHY_OFDM(0x88), 411 - (b43_phy_read(dev, B43_PHY_OFDM(0x88)) & ~0x3F00) | 0x0200); 412 - b43_phy_write(dev, B43_PHY_OFDM(0x96), 413 - (b43_phy_read(dev, B43_PHY_OFDM(0x96)) & ~0x00FF) | 0x001C); 414 - b43_phy_write(dev, B43_PHY_OFDM(0x89), 415 - (b43_phy_read(dev, B43_PHY_OFDM(0x89)) & ~0x00FF) | 0x0020); 416 - b43_phy_write(dev, B43_PHY_OFDM(0x89), 417 - (b43_phy_read(dev, B43_PHY_OFDM(0x89)) & ~0x3F00) | 0x0200); 418 - b43_phy_write(dev, B43_PHY_OFDM(0x82), 419 - (b43_phy_read(dev, B43_PHY_OFDM(0x82)) & ~0x00FF) | 0x002E); 420 - b43_phy_write(dev, B43_PHY_OFDM(0x96), 421 - (b43_phy_read(dev, B43_PHY_OFDM(0x96)) & ~0xFF00) | 0x1A00); 422 - b43_phy_write(dev, B43_PHY_OFDM(0x81), 423 - (b43_phy_read(dev, B43_PHY_OFDM(0x81)) & ~0x00FF) | 0x0028); 424 - b43_phy_write(dev, B43_PHY_OFDM(0x81), 425 - (b43_phy_read(dev, B43_PHY_OFDM(0x81)) & ~0xFF00) | 0x2C00); 406 + b43_phy_maskset(dev, B43_PHY_OFDM(0x88), ~0x00FF, 0x001C); 407 + b43_phy_maskset(dev, B43_PHY_OFDM(0x88), ~0x3F00, 0x0200); 408 + b43_phy_maskset(dev, B43_PHY_OFDM(0x96), ~0x00FF, 0x001C); 409 + b43_phy_maskset(dev, B43_PHY_OFDM(0x89), ~0x00FF, 0x0020); 410 + b43_phy_maskset(dev, B43_PHY_OFDM(0x89), ~0x3F00, 0x0200); 411 + b43_phy_maskset(dev, B43_PHY_OFDM(0x82), ~0x00FF, 0x002E); 412 + b43_phy_maskset(dev, B43_PHY_OFDM(0x96), (u16)~0xFF00, 0x1A00); 413 + b43_phy_maskset(dev, B43_PHY_OFDM(0x81), ~0x00FF, 0x0028); 414 + b43_phy_maskset(dev, B43_PHY_OFDM(0x81), (u16)~0xFF00, 0x2C00); 426 415 if (phy->rev == 1) { 427 416 b43_phy_write(dev, B43_PHY_PEAK_COUNT, 0x092B); 428 - b43_phy_write(dev, B43_PHY_OFDM(0x1B), 429 - (b43_phy_read(dev, B43_PHY_OFDM(0x1B)) & ~0x001E) | 0x0002); 417 + b43_phy_maskset(dev, B43_PHY_OFDM(0x1B), ~0x001E, 0x0002); 430 418 } else { 431 - b43_phy_write(dev, B43_PHY_OFDM(0x1B), 432 - b43_phy_read(dev, B43_PHY_OFDM(0x1B)) & ~0x001E); 419 + b43_phy_mask(dev, B43_PHY_OFDM(0x1B), ~0x001E); 433 420 b43_phy_write(dev, B43_PHY_OFDM(0x1F), 0x287A); 434 - b43_phy_write(dev, B43_PHY_LPFGAINCTL, 435 - (b43_phy_read(dev, B43_PHY_LPFGAINCTL) & ~0x000F) | 0x0004); 421 + b43_phy_maskset(dev, B43_PHY_LPFGAINCTL, ~0x000F, 0x0004); 436 422 if (phy->rev >= 6) { 437 423 b43_phy_write(dev, B43_PHY_OFDM(0x22), 0x287A); 438 - b43_phy_write(dev, B43_PHY_LPFGAINCTL, 439 - (b43_phy_read(dev, B43_PHY_LPFGAINCTL) & ~0xF000) | 0x3000); 424 + b43_phy_maskset(dev, B43_PHY_LPFGAINCTL, (u16)~0xF000, 0x3000); 440 425 } 441 426 } 442 - b43_phy_write(dev, B43_PHY_DIVSRCHIDX, 443 - (b43_phy_read(dev, B43_PHY_DIVSRCHIDX) & 0x8080) | 0x7874); 427 + b43_phy_maskset(dev, B43_PHY_DIVSRCHIDX, 0x8080, 0x7874); 444 428 b43_phy_write(dev, B43_PHY_OFDM(0x8E), 0x1C00); 445 429 if (phy->rev == 1) { 446 - b43_phy_write(dev, B43_PHY_DIVP1P2GAIN, 447 - (b43_phy_read(dev, B43_PHY_DIVP1P2GAIN) & ~0x0F00) | 0x0600); 430 + b43_phy_maskset(dev, B43_PHY_DIVP1P2GAIN, ~0x0F00, 0x0600); 448 431 b43_phy_write(dev, B43_PHY_OFDM(0x8B), 0x005E); 449 - b43_phy_write(dev, B43_PHY_ANTWRSETT, 450 - (b43_phy_read(dev, B43_PHY_ANTWRSETT) & ~0x00FF) | 0x001E); 432 + b43_phy_maskset(dev, B43_PHY_ANTWRSETT, ~0x00FF, 0x001E); 451 433 b43_phy_write(dev, B43_PHY_OFDM(0x8D), 0x0002); 452 434 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3_R1, 0, 0); 453 435 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3_R1, 1, 7); ··· 433 469 b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3, 3, 28); 434 470 } 435 471 if (phy->rev >= 6) { 436 - b43_phy_write(dev, B43_PHY_OFDM(0x26), 437 - b43_phy_read(dev, B43_PHY_OFDM(0x26)) & ~0x0003); 438 - b43_phy_write(dev, B43_PHY_OFDM(0x26), 439 - b43_phy_read(dev, B43_PHY_OFDM(0x26)) & ~0x1000); 472 + b43_phy_mask(dev, B43_PHY_OFDM(0x26), ~0x0003); 473 + b43_phy_mask(dev, B43_PHY_OFDM(0x26), ~0x1000); 440 474 } 441 475 b43_phy_read(dev, B43_PHY_VERSION_OFDM); /* Dummy read */ 442 476 } ··· 500 538 b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 2, 0x0001); 501 539 if ((bus->sprom.boardflags_lo & B43_BFL_EXTLNA) && 502 540 (phy->rev >= 7)) { 503 - b43_phy_write(dev, B43_PHY_EXTG(0x11), 504 - b43_phy_read(dev, B43_PHY_EXTG(0x11)) & 0xF7FF); 541 + b43_phy_mask(dev, B43_PHY_EXTG(0x11), 0xF7FF); 505 542 b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0020, 0x0001); 506 543 b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0021, 0x0001); 507 544 b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0022, 0x0001);
+1 -1
drivers/net/wireless/hostap/hostap.h
··· 31 31 void hostap_dump_tx_header(const char *name, 32 32 const struct hfa384x_tx_frame *tx); 33 33 extern const struct header_ops hostap_80211_ops; 34 - int hostap_80211_get_hdrlen(u16 fc); 34 + int hostap_80211_get_hdrlen(__le16 fc); 35 35 struct net_device_stats *hostap_get_stats(struct net_device *dev); 36 36 void hostap_setup_dev(struct net_device *dev, local_info_t *local, 37 37 int type);
+1 -1
drivers/net/wireless/hostap/hostap_80211.h
··· 2 2 #define HOSTAP_80211_H 3 3 4 4 #include <linux/types.h> 5 - #include <net/ieee80211.h> 5 + #include <linux/skbuff.h> 6 6 7 7 struct hostap_ieee80211_mgmt { 8 8 __le16 frame_control;
+44 -44
drivers/net/wireless/hostap/hostap_80211_rx.c
··· 1 1 #include <linux/etherdevice.h> 2 2 #include <net/lib80211.h> 3 + #include <linux/if_arp.h> 3 4 4 5 #include "hostap_80211.h" 5 6 #include "hostap.h" ··· 18 17 void hostap_dump_rx_80211(const char *name, struct sk_buff *skb, 19 18 struct hostap_80211_rx_status *rx_stats) 20 19 { 21 - struct ieee80211_hdr_4addr *hdr; 20 + struct ieee80211_hdr *hdr; 22 21 u16 fc; 23 22 24 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 23 + hdr = (struct ieee80211_hdr *) skb->data; 25 24 26 25 printk(KERN_DEBUG "%s: RX signal=%d noise=%d rate=%d len=%d " 27 26 "jiffies=%ld\n", ··· 31 30 if (skb->len < 2) 32 31 return; 33 32 34 - fc = le16_to_cpu(hdr->frame_ctl); 33 + fc = le16_to_cpu(hdr->frame_control); 35 34 printk(KERN_DEBUG " FC=0x%04x (type=%d:%d)%s%s", 36 - fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4, 35 + fc, (fc & IEEE80211_FCTL_FTYPE) >> 2, 36 + (fc & IEEE80211_FCTL_STYPE) >> 4, 37 37 fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", 38 38 fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : ""); 39 39 ··· 44 42 } 45 43 46 44 printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id), 47 - le16_to_cpu(hdr->seq_ctl)); 45 + le16_to_cpu(hdr->seq_ctrl)); 48 46 49 47 printk(KERN_DEBUG " A1=%pM", hdr->addr1); 50 48 printk(" A2=%pM", hdr->addr2); ··· 65 63 int hdrlen, phdrlen, head_need, tail_need; 66 64 u16 fc; 67 65 int prism_header, ret; 68 - struct ieee80211_hdr_4addr *fhdr; 66 + struct ieee80211_hdr *fhdr; 69 67 70 68 iface = netdev_priv(dev); 71 69 local = iface->local; ··· 86 84 phdrlen = 0; 87 85 } 88 86 89 - fhdr = (struct ieee80211_hdr_4addr *) skb->data; 90 - fc = le16_to_cpu(fhdr->frame_ctl); 87 + fhdr = (struct ieee80211_hdr *) skb->data; 88 + fc = le16_to_cpu(fhdr->frame_control); 91 89 92 90 if (type == PRISM2_RX_MGMT && (fc & IEEE80211_FCTL_VERS)) { 93 91 printk(KERN_DEBUG "%s: dropped management frame with header " ··· 96 94 return 0; 97 95 } 98 96 99 - hdrlen = hostap_80211_get_hdrlen(fc); 97 + hdrlen = hostap_80211_get_hdrlen(fhdr->frame_control); 100 98 101 99 /* check if there is enough room for extra data; if not, expand skb 102 100 * buffer to be large enough for the changes */ ··· 249 247 250 248 /* Called only as a tasklet (software IRQ) */ 251 249 static struct sk_buff * 252 - prism2_frag_cache_get(local_info_t *local, struct ieee80211_hdr_4addr *hdr) 250 + prism2_frag_cache_get(local_info_t *local, struct ieee80211_hdr *hdr) 253 251 { 254 252 struct sk_buff *skb = NULL; 255 253 u16 sc; 256 254 unsigned int frag, seq; 257 255 struct prism2_frag_entry *entry; 258 256 259 - sc = le16_to_cpu(hdr->seq_ctl); 260 - frag = WLAN_GET_SEQ_FRAG(sc); 261 - seq = WLAN_GET_SEQ_SEQ(sc) >> 4; 257 + sc = le16_to_cpu(hdr->seq_ctrl); 258 + frag = sc & IEEE80211_SCTL_FRAG; 259 + seq = (sc & IEEE80211_SCTL_SEQ) >> 4; 262 260 263 261 if (frag == 0) { 264 262 /* Reserve enough space to fit maximum frame length */ 265 263 skb = dev_alloc_skb(local->dev->mtu + 266 - sizeof(struct ieee80211_hdr_4addr) + 264 + sizeof(struct ieee80211_hdr) + 267 265 8 /* LLC */ + 268 266 2 /* alignment */ + 269 267 8 /* WEP */ + ETH_ALEN /* WDS */); ··· 301 299 302 300 /* Called only as a tasklet (software IRQ) */ 303 301 static int prism2_frag_cache_invalidate(local_info_t *local, 304 - struct ieee80211_hdr_4addr *hdr) 302 + struct ieee80211_hdr *hdr) 305 303 { 306 304 u16 sc; 307 305 unsigned int seq; 308 306 struct prism2_frag_entry *entry; 309 307 310 - sc = le16_to_cpu(hdr->seq_ctl); 311 - seq = WLAN_GET_SEQ_SEQ(sc) >> 4; 308 + sc = le16_to_cpu(hdr->seq_ctrl); 309 + seq = (sc & IEEE80211_SCTL_SEQ) >> 4; 312 310 313 311 entry = prism2_frag_cache_find(local, seq, -1, hdr->addr2, hdr->addr1); 314 312 ··· 474 472 struct hostap_80211_rx_status *rx_stats, u16 type, 475 473 u16 stype) 476 474 { 477 - if (local->iw_mode == IW_MODE_MASTER) { 478 - hostap_update_sta_ps(local, (struct ieee80211_hdr_4addr *) 479 - skb->data); 480 - } 475 + if (local->iw_mode == IW_MODE_MASTER) 476 + hostap_update_sta_ps(local, (struct ieee80211_hdr *) skb->data); 481 477 482 478 if (local->hostapd && type == IEEE80211_FTYPE_MGMT) { 483 479 if (stype == IEEE80211_STYPE_BEACON && ··· 552 552 553 553 554 554 static int 555 - hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr_4addr *hdr, 556 - u16 fc, struct net_device **wds) 555 + hostap_rx_frame_wds(local_info_t *local, struct ieee80211_hdr *hdr, u16 fc, 556 + struct net_device **wds) 557 557 { 558 558 /* FIX: is this really supposed to accept WDS frames only in Master 559 559 * mode? What about Repeater or Managed with WDS frames? */ ··· 611 611 { 612 612 struct net_device *dev = local->dev; 613 613 u16 fc, ethertype; 614 - struct ieee80211_hdr_4addr *hdr; 614 + struct ieee80211_hdr *hdr; 615 615 u8 *pos; 616 616 617 617 if (skb->len < 24) 618 618 return 0; 619 619 620 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 621 - fc = le16_to_cpu(hdr->frame_ctl); 620 + hdr = (struct ieee80211_hdr *) skb->data; 621 + fc = le16_to_cpu(hdr->frame_control); 622 622 623 623 /* check that the frame is unicast frame to us */ 624 624 if ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == ··· 651 651 hostap_rx_frame_decrypt(local_info_t *local, struct sk_buff *skb, 652 652 struct lib80211_crypt_data *crypt) 653 653 { 654 - struct ieee80211_hdr_4addr *hdr; 654 + struct ieee80211_hdr *hdr; 655 655 int res, hdrlen; 656 656 657 657 if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) 658 658 return 0; 659 659 660 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 661 - hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 660 + hdr = (struct ieee80211_hdr *) skb->data; 661 + hdrlen = hostap_80211_get_hdrlen(hdr->frame_control); 662 662 663 663 if (local->tkip_countermeasures && 664 664 strcmp(crypt->ops->name, "TKIP") == 0) { ··· 689 689 hostap_rx_frame_decrypt_msdu(local_info_t *local, struct sk_buff *skb, 690 690 int keyidx, struct lib80211_crypt_data *crypt) 691 691 { 692 - struct ieee80211_hdr_4addr *hdr; 692 + struct ieee80211_hdr *hdr; 693 693 int res, hdrlen; 694 694 695 695 if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) 696 696 return 0; 697 697 698 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 699 - hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); 698 + hdr = (struct ieee80211_hdr *) skb->data; 699 + hdrlen = hostap_80211_get_hdrlen(hdr->frame_control); 700 700 701 701 atomic_inc(&crypt->refcnt); 702 702 res = crypt->ops->decrypt_msdu(skb, keyidx, hdrlen, crypt->priv); ··· 720 720 { 721 721 struct hostap_interface *iface; 722 722 local_info_t *local; 723 - struct ieee80211_hdr_4addr *hdr; 723 + struct ieee80211_hdr *hdr; 724 724 size_t hdrlen; 725 725 u16 fc, type, stype, sc; 726 726 struct net_device *wds = NULL; ··· 747 747 dev = local->ddev; 748 748 iface = netdev_priv(dev); 749 749 750 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 750 + hdr = (struct ieee80211_hdr *) skb->data; 751 751 stats = hostap_get_stats(dev); 752 752 753 753 if (skb->len < 10) 754 754 goto rx_dropped; 755 755 756 - fc = le16_to_cpu(hdr->frame_ctl); 757 - type = WLAN_FC_GET_TYPE(fc); 758 - stype = WLAN_FC_GET_STYPE(fc); 759 - sc = le16_to_cpu(hdr->seq_ctl); 760 - frag = WLAN_GET_SEQ_FRAG(sc); 761 - hdrlen = hostap_80211_get_hdrlen(fc); 756 + fc = le16_to_cpu(hdr->frame_control); 757 + type = fc & IEEE80211_FCTL_FTYPE; 758 + stype = fc & IEEE80211_FCTL_STYPE; 759 + sc = le16_to_cpu(hdr->seq_ctrl); 760 + frag = sc & IEEE80211_SCTL_FRAG; 761 + hdrlen = hostap_80211_get_hdrlen(hdr->frame_control); 762 762 763 763 /* Put this code here so that we avoid duplicating it in all 764 764 * Rx paths. - Jean II */ ··· 918 918 if (local->host_decrypt && (fc & IEEE80211_FCTL_PROTECTED) && 919 919 (keyidx = hostap_rx_frame_decrypt(local, skb, crypt)) < 0) 920 920 goto rx_dropped; 921 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 921 + hdr = (struct ieee80211_hdr *) skb->data; 922 922 923 923 /* skb: hdr + (possibly fragmented) plaintext payload */ 924 924 ··· 931 931 printk(KERN_DEBUG "%s: Rx cannot get skb from " 932 932 "fragment cache (morefrag=%d seq=%u frag=%u)\n", 933 933 dev->name, (fc & IEEE80211_FCTL_MOREFRAGS) != 0, 934 - WLAN_GET_SEQ_SEQ(sc) >> 4, frag); 934 + (sc & IEEE80211_SCTL_SEQ) >> 4, frag); 935 935 goto rx_dropped; 936 936 } 937 937 ··· 972 972 /* this was the last fragment and the frame will be 973 973 * delivered, so remove skb from fragment cache */ 974 974 skb = frag_skb; 975 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 975 + hdr = (struct ieee80211_hdr *) skb->data; 976 976 prism2_frag_cache_invalidate(local, hdr); 977 977 } 978 978 ··· 983 983 hostap_rx_frame_decrypt_msdu(local, skb, keyidx, crypt)) 984 984 goto rx_dropped; 985 985 986 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 986 + hdr = (struct ieee80211_hdr *) skb->data; 987 987 if (crypt && !(fc & IEEE80211_FCTL_PROTECTED) && !local->open_wep) { 988 988 if (local->ieee_802_1x && 989 989 hostap_is_eapol_frame(local, skb)) {
+25 -26
drivers/net/wireless/hostap/hostap_80211_tx.c
··· 15 15 16 16 void hostap_dump_tx_80211(const char *name, struct sk_buff *skb) 17 17 { 18 - struct ieee80211_hdr_4addr *hdr; 18 + struct ieee80211_hdr *hdr; 19 19 u16 fc; 20 20 21 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 21 + hdr = (struct ieee80211_hdr *) skb->data; 22 22 23 23 printk(KERN_DEBUG "%s: TX len=%d jiffies=%ld\n", 24 24 name, skb->len, jiffies); ··· 26 26 if (skb->len < 2) 27 27 return; 28 28 29 - fc = le16_to_cpu(hdr->frame_ctl); 29 + fc = le16_to_cpu(hdr->frame_control); 30 30 printk(KERN_DEBUG " FC=0x%04x (type=%d:%d)%s%s", 31 - fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4, 31 + fc, (fc & IEEE80211_FCTL_FTYPE) >> 2, 32 + (fc & IEEE80211_FCTL_STYPE) >> 4, 32 33 fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", 33 34 fc & IEEE80211_FCTL_FROMDS ? " [FromDS]" : ""); 34 35 ··· 39 38 } 40 39 41 40 printk(" dur=0x%04x seq=0x%04x\n", le16_to_cpu(hdr->duration_id), 42 - le16_to_cpu(hdr->seq_ctl)); 41 + le16_to_cpu(hdr->seq_ctrl)); 43 42 44 43 printk(KERN_DEBUG " A1=%pM", hdr->addr1); 45 44 printk(" A2=%pM", hdr->addr2); ··· 58 57 struct hostap_interface *iface; 59 58 local_info_t *local; 60 59 int need_headroom, need_tailroom = 0; 61 - struct ieee80211_hdr_4addr hdr; 60 + struct ieee80211_hdr hdr; 62 61 u16 fc, ethertype = 0; 63 62 enum { 64 63 WDS_NO = 0, WDS_OWN_FRAME, WDS_COMPLIANT_FRAME ··· 202 201 memcpy(&hdr.addr3, local->bssid, ETH_ALEN); 203 202 } 204 203 205 - hdr.frame_ctl = cpu_to_le16(fc); 204 + hdr.frame_control = cpu_to_le16(fc); 206 205 207 206 skb_pull(skb, skip_header_bytes); 208 207 need_headroom = local->func->need_tx_headroom + hdr_len + encaps_len; ··· 266 265 struct hostap_interface *iface; 267 266 local_info_t *local; 268 267 struct hostap_skb_tx_data *meta; 269 - struct ieee80211_hdr_4addr *hdr; 268 + struct ieee80211_hdr *hdr; 270 269 u16 fc; 271 270 272 271 iface = netdev_priv(dev); ··· 288 287 meta->iface = iface; 289 288 290 289 if (skb->len >= IEEE80211_DATA_HDR3_LEN + sizeof(rfc1042_header) + 2) { 291 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 292 - fc = le16_to_cpu(hdr->frame_ctl); 293 - if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA && 294 - WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_DATA) { 290 + hdr = (struct ieee80211_hdr *) skb->data; 291 + fc = le16_to_cpu(hdr->frame_control); 292 + if (ieee80211_is_data(hdr->frame_control) && 293 + (fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_DATA) { 295 294 u8 *pos = &skb->data[IEEE80211_DATA_HDR3_LEN + 296 295 sizeof(rfc1042_header)]; 297 296 meta->ethertype = (pos[0] << 8) | pos[1]; ··· 311 310 { 312 311 struct hostap_interface *iface; 313 312 local_info_t *local; 314 - struct ieee80211_hdr_4addr *hdr; 315 - u16 fc; 313 + struct ieee80211_hdr *hdr; 316 314 int prefix_len, postfix_len, hdr_len, res; 317 315 318 316 iface = netdev_priv(skb->dev); ··· 324 324 325 325 if (local->tkip_countermeasures && 326 326 strcmp(crypt->ops->name, "TKIP") == 0) { 327 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 327 + hdr = (struct ieee80211_hdr *) skb->data; 328 328 if (net_ratelimit()) { 329 329 printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " 330 330 "TX packet to %pM\n", ··· 349 349 return NULL; 350 350 } 351 351 352 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 353 - fc = le16_to_cpu(hdr->frame_ctl); 354 - hdr_len = hostap_80211_get_hdrlen(fc); 352 + hdr = (struct ieee80211_hdr *) skb->data; 353 + hdr_len = hostap_80211_get_hdrlen(hdr->frame_control); 355 354 356 355 /* Host-based IEEE 802.11 fragmentation for TX is not yet supported, so 357 356 * call both MSDU and MPDU encryption functions from here. */ ··· 383 384 ap_tx_ret tx_ret; 384 385 struct hostap_skb_tx_data *meta; 385 386 int no_encrypt = 0; 386 - struct ieee80211_hdr_4addr *hdr; 387 + struct ieee80211_hdr *hdr; 387 388 388 389 iface = netdev_priv(dev); 389 390 local = iface->local; ··· 426 427 tx_ret = hostap_handle_sta_tx(local, &tx); 427 428 skb = tx.skb; 428 429 meta = (struct hostap_skb_tx_data *) skb->cb; 429 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 430 - fc = le16_to_cpu(hdr->frame_ctl); 430 + hdr = (struct ieee80211_hdr *) skb->data; 431 + fc = le16_to_cpu(hdr->frame_control); 431 432 switch (tx_ret) { 432 433 case AP_TX_CONTINUE: 433 434 break; 434 435 case AP_TX_CONTINUE_NOT_AUTHORIZED: 435 436 if (local->ieee_802_1x && 436 - WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA && 437 + ieee80211_is_data(hdr->frame_control) && 437 438 meta->ethertype != ETH_P_PAE && 438 439 !(meta->flags & HOSTAP_TX_FLAGS_WDS)) { 439 440 printk(KERN_DEBUG "%s: dropped frame to unauthorized " ··· 468 469 469 470 /* remove special version from the frame header */ 470 471 fc &= ~IEEE80211_FCTL_VERS; 471 - hdr->frame_ctl = cpu_to_le16(fc); 472 + hdr->frame_control = cpu_to_le16(fc); 472 473 } 473 474 474 - if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_DATA) { 475 + if (!ieee80211_is_data(hdr->frame_control)) { 475 476 no_encrypt = 1; 476 477 tx.crypt = NULL; 477 478 } ··· 492 493 /* Add ISWEP flag both for firmware and host based encryption 493 494 */ 494 495 fc |= IEEE80211_FCTL_PROTECTED; 495 - hdr->frame_ctl = cpu_to_le16(fc); 496 + hdr->frame_control = cpu_to_le16(fc); 496 497 } else if (local->drop_unencrypted && 497 - WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA && 498 + ieee80211_is_data(hdr->frame_control) && 498 499 meta->ethertype != ETH_P_PAE) { 499 500 if (net_ratelimit()) { 500 501 printk(KERN_DEBUG "%s: dropped unencrypted TX data "
+64 -74
drivers/net/wireless/hostap/hostap_ap.c
··· 19 19 #include <linux/proc_fs.h> 20 20 #include <linux/delay.h> 21 21 #include <linux/random.h> 22 + #include <linux/if_arp.h> 22 23 23 24 #include "hostap_wlan.h" 24 25 #include "hostap.h" ··· 589 588 static void hostap_ap_tx_cb(struct sk_buff *skb, int ok, void *data) 590 589 { 591 590 struct ap_data *ap = data; 592 - u16 fc; 593 - struct ieee80211_hdr_4addr *hdr; 591 + struct ieee80211_hdr *hdr; 594 592 595 593 if (!ap->local->hostapd || !ap->local->apdev) { 596 594 dev_kfree_skb(skb); 597 595 return; 598 596 } 599 597 600 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 601 - fc = le16_to_cpu(hdr->frame_ctl); 602 - 603 598 /* Pass the TX callback frame to the hostapd; use 802.11 header version 604 599 * 1 to indicate failure (no ACK) and 2 success (frame ACKed) */ 605 600 606 - fc &= ~IEEE80211_FCTL_VERS; 607 - fc |= ok ? BIT(1) : BIT(0); 608 - hdr->frame_ctl = cpu_to_le16(fc); 601 + hdr = (struct ieee80211_hdr *) skb->data; 602 + hdr->frame_control &= cpu_to_le16(~IEEE80211_FCTL_VERS); 603 + hdr->frame_control |= cpu_to_le16(ok ? BIT(1) : BIT(0)); 609 604 610 605 skb->dev = ap->local->apdev; 611 - skb_pull(skb, hostap_80211_get_hdrlen(fc)); 606 + skb_pull(skb, hostap_80211_get_hdrlen(hdr->frame_control)); 612 607 skb->pkt_type = PACKET_OTHERHOST; 613 608 skb->protocol = cpu_to_be16(ETH_P_802_2); 614 609 memset(skb->cb, 0, sizeof(skb->cb)); ··· 618 621 { 619 622 struct ap_data *ap = data; 620 623 struct net_device *dev = ap->local->dev; 621 - struct ieee80211_hdr_4addr *hdr; 622 - u16 fc, auth_alg, auth_transaction, status; 624 + struct ieee80211_hdr *hdr; 625 + u16 auth_alg, auth_transaction, status; 623 626 __le16 *pos; 624 627 struct sta_info *sta = NULL; 625 628 char *txt = NULL; ··· 629 632 return; 630 633 } 631 634 632 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 633 - fc = le16_to_cpu(hdr->frame_ctl); 634 - if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_MGMT || 635 - WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_AUTH || 635 + hdr = (struct ieee80211_hdr *) skb->data; 636 + if (!ieee80211_is_auth(hdr->frame_control) || 636 637 skb->len < IEEE80211_MGMT_HDR_LEN + 6) { 637 638 printk(KERN_DEBUG "%s: hostap_ap_tx_cb_auth received invalid " 638 639 "frame\n", dev->name); ··· 686 691 { 687 692 struct ap_data *ap = data; 688 693 struct net_device *dev = ap->local->dev; 689 - struct ieee80211_hdr_4addr *hdr; 694 + struct ieee80211_hdr *hdr; 690 695 u16 fc, status; 691 696 __le16 *pos; 692 697 struct sta_info *sta = NULL; ··· 697 702 return; 698 703 } 699 704 700 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 701 - fc = le16_to_cpu(hdr->frame_ctl); 702 - if (WLAN_FC_GET_TYPE(fc) != IEEE80211_FTYPE_MGMT || 703 - (WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_ASSOC_RESP && 704 - WLAN_FC_GET_STYPE(fc) != IEEE80211_STYPE_REASSOC_RESP) || 705 + hdr = (struct ieee80211_hdr *) skb->data; 706 + fc = le16_to_cpu(hdr->frame_control); 707 + if ((!ieee80211_is_assoc_resp(hdr->frame_control) && 708 + !ieee80211_is_reassoc_resp(hdr->frame_control)) || 705 709 skb->len < IEEE80211_MGMT_HDR_LEN + 4) { 706 710 printk(KERN_DEBUG "%s: hostap_ap_tx_cb_assoc received invalid " 707 711 "frame\n", dev->name); ··· 751 757 static void hostap_ap_tx_cb_poll(struct sk_buff *skb, int ok, void *data) 752 758 { 753 759 struct ap_data *ap = data; 754 - struct ieee80211_hdr_4addr *hdr; 760 + struct ieee80211_hdr *hdr; 755 761 struct sta_info *sta; 756 762 757 763 if (skb->len < 24) 758 764 goto fail; 759 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 765 + hdr = (struct ieee80211_hdr *) skb->data; 760 766 if (ok) { 761 767 spin_lock(&ap->sta_table_lock); 762 768 sta = ap_get_sta(ap, hdr->addr1); ··· 911 917 { 912 918 struct hostap_interface *iface; 913 919 local_info_t *local; 914 - struct ieee80211_hdr_4addr *hdr; 920 + struct ieee80211_hdr *hdr; 915 921 u16 fc; 916 922 struct sk_buff *skb; 917 923 struct hostap_skb_tx_data *meta; ··· 936 942 } 937 943 938 944 fc = type_subtype; 939 - hdrlen = hostap_80211_get_hdrlen(fc); 940 - hdr = (struct ieee80211_hdr_4addr *) skb_put(skb, hdrlen); 945 + hdrlen = hostap_80211_get_hdrlen(cpu_to_le16(type_subtype)); 946 + hdr = (struct ieee80211_hdr *) skb_put(skb, hdrlen); 941 947 if (body) 942 948 memcpy(skb_put(skb, body_len), body, body_len); 943 949 ··· 948 954 949 955 950 956 memcpy(hdr->addr1, addr, ETH_ALEN); /* DA / RA */ 951 - if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) { 957 + if (ieee80211_is_data(hdr->frame_control)) { 952 958 fc |= IEEE80211_FCTL_FROMDS; 953 959 memcpy(hdr->addr2, dev->dev_addr, ETH_ALEN); /* BSSID */ 954 960 memcpy(hdr->addr3, dev->dev_addr, ETH_ALEN); /* SA */ 955 - } else if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_CTL) { 961 + } else if (ieee80211_is_ctl(hdr->frame_control)) { 956 962 /* control:ACK does not have addr2 or addr3 */ 957 963 memset(hdr->addr2, 0, ETH_ALEN); 958 964 memset(hdr->addr3, 0, ETH_ALEN); ··· 961 967 memcpy(hdr->addr3, dev->dev_addr, ETH_ALEN); /* BSSID */ 962 968 } 963 969 964 - hdr->frame_ctl = cpu_to_le16(fc); 970 + hdr->frame_control = cpu_to_le16(fc); 965 971 966 972 meta = (struct hostap_skb_tx_data *) skb->cb; 967 973 memset(meta, 0, sizeof(*meta)); ··· 1278 1284 struct hostap_80211_rx_status *rx_stats) 1279 1285 { 1280 1286 struct net_device *dev = local->dev; 1281 - struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data; 1287 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1282 1288 size_t hdrlen; 1283 1289 struct ap_data *ap = local->ap; 1284 1290 char body[8 + WLAN_AUTH_CHALLENGE_LEN], *challenge = NULL; 1285 1291 int len, olen; 1286 1292 u16 auth_alg, auth_transaction, status_code; 1287 1293 __le16 *pos; 1288 - u16 resp = WLAN_STATUS_SUCCESS, fc; 1294 + u16 resp = WLAN_STATUS_SUCCESS; 1289 1295 struct sta_info *sta = NULL; 1290 1296 struct lib80211_crypt_data *crypt; 1291 1297 char *txt = ""; 1292 1298 1293 1299 len = skb->len - IEEE80211_MGMT_HDR_LEN; 1294 1300 1295 - fc = le16_to_cpu(hdr->frame_ctl); 1296 - hdrlen = hostap_80211_get_hdrlen(fc); 1301 + hdrlen = hostap_80211_get_hdrlen(hdr->frame_control); 1297 1302 1298 1303 if (len < 6) { 1299 1304 PDEBUG(DEBUG_AP, "%s: handle_authen - too short payload " ··· 1428 1435 challenge == NULL || 1429 1436 memcmp(sta->u.sta.challenge, challenge, 1430 1437 WLAN_AUTH_CHALLENGE_LEN) != 0 || 1431 - !(fc & IEEE80211_FCTL_PROTECTED)) { 1438 + !ieee80211_has_protected(hdr->frame_control)) { 1432 1439 txt = "challenge response incorrect"; 1433 1440 resp = WLAN_STATUS_CHALLENGE_FAIL; 1434 1441 goto fail; ··· 1481 1488 "trans#=%d stat=%d len=%d fc=%04x) ==> %d (%s)\n", 1482 1489 dev->name, hdr->addr2, 1483 1490 auth_alg, auth_transaction, status_code, len, 1484 - fc, resp, txt); 1491 + le16_to_cpu(hdr->frame_control), resp, txt); 1485 1492 } 1486 1493 } 1487 1494 ··· 1491 1498 struct hostap_80211_rx_status *rx_stats, int reassoc) 1492 1499 { 1493 1500 struct net_device *dev = local->dev; 1494 - struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data; 1501 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1495 1502 char body[12], *p, *lpos; 1496 1503 int len, left; 1497 1504 __le16 *pos; ··· 1700 1707 struct hostap_80211_rx_status *rx_stats) 1701 1708 { 1702 1709 struct net_device *dev = local->dev; 1703 - struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data; 1710 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1704 1711 char *body = (char *) (skb->data + IEEE80211_MGMT_HDR_LEN); 1705 1712 int len; 1706 1713 u16 reason_code; ··· 1742 1749 struct hostap_80211_rx_status *rx_stats) 1743 1750 { 1744 1751 struct net_device *dev = local->dev; 1745 - struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data; 1752 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1746 1753 char *body = skb->data + IEEE80211_MGMT_HDR_LEN; 1747 1754 int len; 1748 1755 u16 reason_code; ··· 1781 1788 1782 1789 /* Called only as a scheduled task for pending AP frames. */ 1783 1790 static void ap_handle_data_nullfunc(local_info_t *local, 1784 - struct ieee80211_hdr_4addr *hdr) 1791 + struct ieee80211_hdr *hdr) 1785 1792 { 1786 1793 struct net_device *dev = local->dev; 1787 1794 ··· 1798 1805 1799 1806 /* Called only as a scheduled task for pending AP frames. */ 1800 1807 static void ap_handle_dropped_data(local_info_t *local, 1801 - struct ieee80211_hdr_4addr *hdr) 1808 + struct ieee80211_hdr *hdr) 1802 1809 { 1803 1810 struct net_device *dev = local->dev; 1804 1811 struct sta_info *sta; ··· 1856 1863 1857 1864 /* Called only as a scheduled task for pending AP frames. */ 1858 1865 static void handle_pspoll(local_info_t *local, 1859 - struct ieee80211_hdr_4addr *hdr, 1866 + struct ieee80211_hdr *hdr, 1860 1867 struct hostap_80211_rx_status *rx_stats) 1861 1868 { 1862 1869 struct net_device *dev = local->dev; ··· 1865 1872 struct sk_buff *skb; 1866 1873 1867 1874 PDEBUG(DEBUG_PS2, "handle_pspoll: BSSID=%pM, TA=%pM PWRMGT=%d\n", 1868 - hdr->addr1, hdr->addr2, 1869 - !!(le16_to_cpu(hdr->frame_ctl) & IEEE80211_FCTL_PM)); 1875 + hdr->addr1, hdr->addr2, !!ieee80211_has_pm(hdr->frame_control)); 1870 1876 1871 1877 if (memcmp(hdr->addr1, dev->dev_addr, ETH_ALEN)) { 1872 1878 PDEBUG(DEBUG_AP, ··· 1976 1984 static void handle_beacon(local_info_t *local, struct sk_buff *skb, 1977 1985 struct hostap_80211_rx_status *rx_stats) 1978 1986 { 1979 - struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *) skb->data; 1987 + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 1980 1988 char *body = skb->data + IEEE80211_MGMT_HDR_LEN; 1981 1989 int len, left; 1982 1990 u16 beacon_int, capability; ··· 2135 2143 struct net_device *dev = local->dev; 2136 2144 #endif /* PRISM2_NO_KERNEL_IEEE80211_MGMT */ 2137 2145 u16 fc, type, stype; 2138 - struct ieee80211_hdr_4addr *hdr; 2146 + struct ieee80211_hdr *hdr; 2139 2147 2140 2148 /* FIX: should give skb->len to handler functions and check that the 2141 2149 * buffer is long enough */ 2142 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 2143 - fc = le16_to_cpu(hdr->frame_ctl); 2144 - type = WLAN_FC_GET_TYPE(fc); 2145 - stype = WLAN_FC_GET_STYPE(fc); 2150 + hdr = (struct ieee80211_hdr *) skb->data; 2151 + fc = le16_to_cpu(hdr->frame_control); 2152 + type = fc & IEEE80211_FCTL_FTYPE; 2153 + stype = fc & IEEE80211_FCTL_STYPE; 2146 2154 2147 2155 #ifndef PRISM2_NO_KERNEL_IEEE80211_MGMT 2148 2156 if (!local->hostapd && type == IEEE80211_FTYPE_DATA) { ··· 2254 2262 { 2255 2263 struct hostap_interface *iface; 2256 2264 local_info_t *local; 2257 - u16 fc; 2258 - struct ieee80211_hdr_4addr *hdr; 2265 + struct ieee80211_hdr *hdr; 2259 2266 2260 2267 iface = netdev_priv(dev); 2261 2268 local = iface->local; ··· 2264 2273 2265 2274 local->stats.rx_packets++; 2266 2275 2267 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 2268 - fc = le16_to_cpu(hdr->frame_ctl); 2276 + hdr = (struct ieee80211_hdr *) skb->data; 2269 2277 2270 2278 if (local->ap->ap_policy == AP_OTHER_AP_SKIP_ALL && 2271 - WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT && 2272 - WLAN_FC_GET_STYPE(fc) == IEEE80211_STYPE_BEACON) 2279 + ieee80211_is_beacon(hdr->frame_control)) 2273 2280 goto drop; 2274 2281 2275 2282 skb->protocol = cpu_to_be16(ETH_P_HOSTAP); ··· 2283 2294 static void schedule_packet_send(local_info_t *local, struct sta_info *sta) 2284 2295 { 2285 2296 struct sk_buff *skb; 2286 - struct ieee80211_hdr_4addr *hdr; 2297 + struct ieee80211_hdr *hdr; 2287 2298 struct hostap_80211_rx_status rx_stats; 2288 2299 2289 2300 if (skb_queue_empty(&sta->tx_buf)) ··· 2296 2307 return; 2297 2308 } 2298 2309 2299 - hdr = (struct ieee80211_hdr_4addr *) skb_put(skb, 16); 2310 + hdr = (struct ieee80211_hdr *) skb_put(skb, 16); 2300 2311 2301 2312 /* Generate a fake pspoll frame to start packet delivery */ 2302 - hdr->frame_ctl = cpu_to_le16( 2313 + hdr->frame_control = cpu_to_le16( 2303 2314 IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); 2304 2315 memcpy(hdr->addr1, local->dev->dev_addr, ETH_ALEN); 2305 2316 memcpy(hdr->addr2, sta->addr, ETH_ALEN); ··· 2678 2689 struct sta_info *sta = NULL; 2679 2690 struct sk_buff *skb = tx->skb; 2680 2691 int set_tim, ret; 2681 - struct ieee80211_hdr_4addr *hdr; 2692 + struct ieee80211_hdr *hdr; 2682 2693 struct hostap_skb_tx_data *meta; 2683 2694 2684 2695 meta = (struct hostap_skb_tx_data *) skb->cb; ··· 2687 2698 meta->iface->type == HOSTAP_INTERFACE_STA) 2688 2699 goto out; 2689 2700 2690 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 2701 + hdr = (struct ieee80211_hdr *) skb->data; 2691 2702 2692 2703 if (hdr->addr1[0] & 0x01) { 2693 2704 /* broadcast/multicast frame - no AP related processing */ ··· 2742 2753 2743 2754 if (meta->flags & HOSTAP_TX_FLAGS_ADD_MOREDATA) { 2744 2755 /* indicate to STA that more frames follow */ 2745 - hdr->frame_ctl |= 2756 + hdr->frame_control |= 2746 2757 cpu_to_le16(IEEE80211_FCTL_MOREDATA); 2747 2758 } 2748 2759 ··· 2817 2828 void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb) 2818 2829 { 2819 2830 struct sta_info *sta; 2820 - struct ieee80211_hdr_4addr *hdr; 2831 + struct ieee80211_hdr *hdr; 2821 2832 struct hostap_skb_tx_data *meta; 2822 2833 2823 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 2834 + hdr = (struct ieee80211_hdr *) skb->data; 2824 2835 meta = (struct hostap_skb_tx_data *) skb->cb; 2825 2836 2826 2837 spin_lock(&local->ap->sta_table_lock); ··· 2887 2898 2888 2899 2889 2900 /* Called only as a tasklet (software IRQ). Called for each RX frame to update 2890 - * STA power saving state. pwrmgt is a flag from 802.11 frame_ctl field. */ 2891 - int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr_4addr *hdr) 2901 + * STA power saving state. pwrmgt is a flag from 802.11 frame_control field. */ 2902 + int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr *hdr) 2892 2903 { 2893 2904 struct sta_info *sta; 2894 2905 u16 fc; ··· 2902 2913 if (!sta) 2903 2914 return -1; 2904 2915 2905 - fc = le16_to_cpu(hdr->frame_ctl); 2916 + fc = le16_to_cpu(hdr->frame_control); 2906 2917 hostap_update_sta_ps2(local, sta, fc & IEEE80211_FCTL_PM, 2907 - WLAN_FC_GET_TYPE(fc), WLAN_FC_GET_STYPE(fc)); 2918 + fc & IEEE80211_FCTL_FTYPE, 2919 + fc & IEEE80211_FCTL_STYPE); 2908 2920 2909 2921 atomic_dec(&sta->users); 2910 2922 return 0; ··· 2922 2932 int ret; 2923 2933 struct sta_info *sta; 2924 2934 u16 fc, type, stype; 2925 - struct ieee80211_hdr_4addr *hdr; 2935 + struct ieee80211_hdr *hdr; 2926 2936 2927 2937 if (local->ap == NULL) 2928 2938 return AP_RX_CONTINUE; 2929 2939 2930 - hdr = (struct ieee80211_hdr_4addr *) skb->data; 2940 + hdr = (struct ieee80211_hdr *) skb->data; 2931 2941 2932 - fc = le16_to_cpu(hdr->frame_ctl); 2933 - type = WLAN_FC_GET_TYPE(fc); 2934 - stype = WLAN_FC_GET_STYPE(fc); 2942 + fc = le16_to_cpu(hdr->frame_control); 2943 + type = fc & IEEE80211_FCTL_FTYPE; 2944 + stype = fc & IEEE80211_FCTL_STYPE; 2935 2945 2936 2946 spin_lock(&local->ap->sta_table_lock); 2937 2947 sta = ap_get_sta(local->ap, hdr->addr2); ··· 3054 3064 3055 3065 /* Called only as a tasklet (software IRQ) */ 3056 3066 int hostap_handle_sta_crypto(local_info_t *local, 3057 - struct ieee80211_hdr_4addr *hdr, 3067 + struct ieee80211_hdr *hdr, 3058 3068 struct lib80211_crypt_data **crypt, 3059 3069 void **sta_ptr) 3060 3070 { ··· 3156 3166 3157 3167 /* Called only as a tasklet (software IRQ) */ 3158 3168 int hostap_update_rx_stats(struct ap_data *ap, 3159 - struct ieee80211_hdr_4addr *hdr, 3169 + struct ieee80211_hdr *hdr, 3160 3170 struct hostap_80211_rx_status *rx_stats) 3161 3171 { 3162 3172 struct sta_info *sta;
+3 -3
drivers/net/wireless/hostap/hostap_ap.h
··· 235 235 ap_tx_ret hostap_handle_sta_tx(local_info_t *local, struct hostap_tx_data *tx); 236 236 void hostap_handle_sta_release(void *ptr); 237 237 void hostap_handle_sta_tx_exc(local_info_t *local, struct sk_buff *skb); 238 - int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr_4addr *hdr); 238 + int hostap_update_sta_ps(local_info_t *local, struct ieee80211_hdr *hdr); 239 239 typedef enum { 240 240 AP_RX_CONTINUE, AP_RX_DROP, AP_RX_EXIT, AP_RX_CONTINUE_NOT_AUTHORIZED 241 241 } ap_rx_ret; ··· 243 243 struct sk_buff *skb, 244 244 struct hostap_80211_rx_status *rx_stats, 245 245 int wds); 246 - int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr_4addr *hdr, 246 + int hostap_handle_sta_crypto(local_info_t *local, struct ieee80211_hdr *hdr, 247 247 struct lib80211_crypt_data **crypt, 248 248 void **sta_ptr); 249 249 int hostap_is_sta_assoc(struct ap_data *ap, u8 *sta_addr); 250 250 int hostap_is_sta_authorized(struct ap_data *ap, u8 *sta_addr); 251 251 int hostap_add_sta(struct ap_data *ap, u8 *sta_addr); 252 - int hostap_update_rx_stats(struct ap_data *ap, struct ieee80211_hdr_4addr *hdr, 252 + int hostap_update_rx_stats(struct ap_data *ap, struct ieee80211_hdr *hdr, 253 253 struct hostap_80211_rx_status *rx_stats); 254 254 void hostap_update_rates(local_info_t *local); 255 255 void hostap_add_wds_links(local_info_t *local);
+11 -13
drivers/net/wireless/hostap/hostap_hw.c
··· 46 46 #include <linux/rtnetlink.h> 47 47 #include <linux/wireless.h> 48 48 #include <net/iw_handler.h> 49 - #include <net/ieee80211.h> 50 49 #include <net/lib80211.h> 51 50 #include <asm/irq.h> 52 51 ··· 1839 1840 hdr_len = 24; 1840 1841 skb_copy_from_linear_data(skb, &txdesc.frame_control, hdr_len); 1841 1842 fc = le16_to_cpu(txdesc.frame_control); 1842 - if (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA && 1843 - (fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS) && 1843 + if (ieee80211_is_data(txdesc.frame_control) && 1844 + ieee80211_has_a4(txdesc.frame_control) && 1844 1845 skb->len >= 30) { 1845 1846 /* Addr4 */ 1846 1847 skb_copy_from_linear_data_offset(skb, hdr_len, txdesc.addr4, ··· 2081 2082 stats.rate = rxdesc->rate; 2082 2083 2083 2084 /* Convert Prism2 RX structure into IEEE 802.11 header */ 2084 - hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(rxdesc->frame_control)); 2085 + hdrlen = hostap_80211_get_hdrlen(rxdesc->frame_control); 2085 2086 if (hdrlen > rx_hdrlen) 2086 2087 hdrlen = rx_hdrlen; 2087 2088 ··· 2203 2204 return; 2204 2205 } 2205 2206 2206 - hdrlen = hostap_80211_get_hdrlen(le16_to_cpu(txdesc->frame_control)); 2207 + hdrlen = hostap_80211_get_hdrlen(txdesc->frame_control); 2207 2208 len = le16_to_cpu(txdesc->data_len); 2208 2209 skb = dev_alloc_skb(hdrlen + len); 2209 2210 if (skb == NULL) { ··· 2314 2315 if (skb->len >= sizeof(*txdesc)) { 2315 2316 /* Convert Prism2 RX structure into IEEE 802.11 header 2316 2317 */ 2317 - u16 fc = le16_to_cpu(txdesc->frame_control); 2318 - int hdrlen = hostap_80211_get_hdrlen(fc); 2318 + int hdrlen = hostap_80211_get_hdrlen(txdesc->frame_control); 2319 2319 memmove(skb_pull(skb, sizeof(*txdesc) - hdrlen), 2320 2320 &txdesc->frame_control, hdrlen); 2321 2321 ··· 2392 2394 PDEBUG(DEBUG_EXTRA, " retry_count=%d tx_rate=%d fc=0x%04x " 2393 2395 "(%s%s%s::%d%s%s)\n", 2394 2396 txdesc.retry_count, txdesc.tx_rate, fc, 2395 - WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_MGMT ? "Mgmt" : "", 2396 - WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_CTL ? "Ctrl" : "", 2397 - WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA ? "Data" : "", 2398 - WLAN_FC_GET_STYPE(fc) >> 4, 2399 - fc & IEEE80211_FCTL_TODS ? " ToDS" : "", 2400 - fc & IEEE80211_FCTL_FROMDS ? " FromDS" : ""); 2397 + ieee80211_is_mgmt(txdesc.frame_control) ? "Mgmt" : "", 2398 + ieee80211_is_ctl(txdesc.frame_control) ? "Ctrl" : "", 2399 + ieee80211_is_data(txdesc.frame_control) ? "Data" : "", 2400 + (fc & IEEE80211_FCTL_STYPE) >> 4, 2401 + ieee80211_has_tods(txdesc.frame_control) ? " ToDS" : "", 2402 + ieee80211_has_fromds(txdesc.frame_control) ? " FromDS" : ""); 2401 2403 PDEBUG(DEBUG_EXTRA, " A1=%pM A2=%pM A3=%pM A4=%pM\n", 2402 2404 txdesc.addr1, txdesc.addr2, 2403 2405 txdesc.addr3, txdesc.addr4);
+1
drivers/net/wireless/hostap/hostap_info.c
··· 1 1 /* Host AP driver Info Frame processing (part of hostap.o module) */ 2 2 3 + #include <linux/if_arp.h> 3 4 #include "hostap_wlan.h" 4 5 #include "hostap.h" 5 6 #include "hostap_ap.h"
+1
drivers/net/wireless/hostap/hostap_ioctl.c
··· 2 2 3 3 #include <linux/types.h> 4 4 #include <linux/ethtool.h> 5 + #include <linux/if_arp.h> 5 6 #include <net/lib80211.h> 6 7 7 8 #include "hostap_wlan.h"
+12 -24
drivers/net/wireless/hostap/hostap_main.c
··· 26 26 #include <linux/etherdevice.h> 27 27 #include <net/net_namespace.h> 28 28 #include <net/iw_handler.h> 29 - #include <net/ieee80211.h> 30 29 #include <net/lib80211.h> 31 30 #include <asm/uaccess.h> 32 31 ··· 542 543 fc = __le16_to_cpu(rx->frame_control); 543 544 printk(KERN_DEBUG " FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x " 544 545 "data_len=%d%s%s\n", 545 - fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4, 546 + fc, (fc & IEEE80211_FCTL_FTYPE) >> 2, 547 + (fc & IEEE80211_FCTL_STYPE) >> 4, 546 548 __le16_to_cpu(rx->duration_id), __le16_to_cpu(rx->seq_ctrl), 547 549 __le16_to_cpu(rx->data_len), 548 550 fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", ··· 570 570 fc = __le16_to_cpu(tx->frame_control); 571 571 printk(KERN_DEBUG " FC=0x%04x (type=%d:%d) dur=0x%04x seq=0x%04x " 572 572 "data_len=%d%s%s\n", 573 - fc, WLAN_FC_GET_TYPE(fc) >> 2, WLAN_FC_GET_STYPE(fc) >> 4, 573 + fc, (fc & IEEE80211_FCTL_FTYPE) >> 2, 574 + (fc & IEEE80211_FCTL_STYPE) >> 4, 574 575 __le16_to_cpu(tx->duration_id), __le16_to_cpu(tx->seq_ctrl), 575 576 __le16_to_cpu(tx->data_len), 576 577 fc & IEEE80211_FCTL_TODS ? " [ToDS]" : "", ··· 594 593 } 595 594 596 595 597 - int hostap_80211_get_hdrlen(u16 fc) 596 + int hostap_80211_get_hdrlen(__le16 fc) 598 597 { 599 - int hdrlen = 24; 598 + if (ieee80211_is_data(fc) && ieee80211_has_a4 (fc)) 599 + return 30; /* Addr4 */ 600 + else if (ieee80211_is_cts(fc) || ieee80211_is_ack(fc)) 601 + return 10; 602 + else if (ieee80211_is_ctl(fc)) 603 + return 16; 600 604 601 - switch (WLAN_FC_GET_TYPE(fc)) { 602 - case IEEE80211_FTYPE_DATA: 603 - if ((fc & IEEE80211_FCTL_FROMDS) && (fc & IEEE80211_FCTL_TODS)) 604 - hdrlen = 30; /* Addr4 */ 605 - break; 606 - case IEEE80211_FTYPE_CTL: 607 - switch (WLAN_FC_GET_STYPE(fc)) { 608 - case IEEE80211_STYPE_CTS: 609 - case IEEE80211_STYPE_ACK: 610 - hdrlen = 10; 611 - break; 612 - default: 613 - hdrlen = 16; 614 - break; 615 - } 616 - break; 617 - } 618 - 619 - return hdrlen; 605 + return 24; 620 606 } 621 607 622 608
+1 -1
drivers/net/wireless/ipw2x00/Kconfig
··· 186 186 % echo 0x00000FFO > /proc/net/ieee80211/debug_level 187 187 188 188 For a list of values you can assign to debug_level, you 189 - can look at the bit mask values in <net/ieee80211.h> 189 + can look at the bit mask values in ieee80211.h 190 190 191 191 If you are not trying to debug or develop the libipw 192 192 component, you most likely want to say N here.
+11 -1
drivers/net/wireless/ipw2x00/ipw2100.c
··· 1692 1692 u32 lock; 1693 1693 u32 ord_len = sizeof(lock); 1694 1694 1695 - /* Quite if manually disabled. */ 1695 + /* Age scan list entries found before suspend */ 1696 + if (priv->suspend_time) { 1697 + ieee80211_networks_age(priv->ieee, priv->suspend_time); 1698 + priv->suspend_time = 0; 1699 + } 1700 + 1701 + /* Quiet if manually disabled. */ 1696 1702 if (priv->status & STATUS_RF_KILL_SW) { 1697 1703 IPW_DEBUG_INFO("%s: Radio is disabled by Manual Disable " 1698 1704 "switch\n", priv->net_dev->name); ··· 6421 6415 pci_disable_device(pci_dev); 6422 6416 pci_set_power_state(pci_dev, PCI_D3hot); 6423 6417 6418 + priv->suspend_at = get_seconds(); 6419 + 6424 6420 mutex_unlock(&priv->action_mutex); 6425 6421 6426 6422 return 0; ··· 6465 6457 /* Set the device back into the PRESENT state; this will also wake 6466 6458 * the queue of needed */ 6467 6459 netif_device_attach(dev); 6460 + 6461 + priv->suspend_time = get_seconds() - priv->suspend_at; 6468 6462 6469 6463 /* Bring the device back up */ 6470 6464 if (!(priv->status & STATUS_RF_KILL_SW))
+6 -2
drivers/net/wireless/ipw2x00/ipw2100.h
··· 39 39 #include <linux/wireless.h> 40 40 #include <net/iw_handler.h> // new driver API 41 41 42 - #include <net/ieee80211.h> 43 - 44 42 #ifdef CONFIG_IPW2100_MONITOR 45 43 #include <net/ieee80211_radiotap.h> 46 44 #endif 47 45 48 46 #include <linux/workqueue.h> 49 47 #include <linux/mutex.h> 48 + 49 + #include "ieee80211.h" 50 50 51 51 struct ipw2100_priv; 52 52 struct ipw2100_tx_packet; ··· 590 590 struct delayed_work scan_event_later; 591 591 592 592 int user_requested_scan; 593 + 594 + /* Track time in suspend */ 595 + unsigned long suspend_at; 596 + unsigned long suspend_time; 593 597 594 598 u32 interrupts; 595 599 int tx_interrupts;
+70 -46
drivers/net/wireless/ipw2x00/ipw2200.c
··· 301 301 } 302 302 303 303 /* 8-bit direct write (low 4K) */ 304 - #define _ipw_write8(ipw, ofs, val) writeb((val), (ipw)->hw_base + (ofs)) 304 + static inline void _ipw_write8(struct ipw_priv *ipw, unsigned long ofs, 305 + u8 val) 306 + { 307 + writeb(val, ipw->hw_base + ofs); 308 + } 305 309 306 310 /* 8-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ 307 311 #define ipw_write8(ipw, ofs, val) do { \ 308 - IPW_DEBUG_IO("%s %d: write_direct8(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ 309 - _ipw_write8(ipw, ofs, val); \ 310 - } while (0) 312 + IPW_DEBUG_IO("%s %d: write_direct8(0x%08X, 0x%08X)\n", __FILE__, \ 313 + __LINE__, (u32)(ofs), (u32)(val)); \ 314 + _ipw_write8(ipw, ofs, val); \ 315 + } while (0) 311 316 312 317 /* 16-bit direct write (low 4K) */ 313 - #define _ipw_write16(ipw, ofs, val) writew((val), (ipw)->hw_base + (ofs)) 318 + static inline void _ipw_write16(struct ipw_priv *ipw, unsigned long ofs, 319 + u16 val) 320 + { 321 + writew(val, ipw->hw_base + ofs); 322 + } 314 323 315 324 /* 16-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ 316 - #define ipw_write16(ipw, ofs, val) \ 317 - IPW_DEBUG_IO("%s %d: write_direct16(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ 318 - _ipw_write16(ipw, ofs, val) 325 + #define ipw_write16(ipw, ofs, val) do { \ 326 + IPW_DEBUG_IO("%s %d: write_direct16(0x%08X, 0x%08X)\n", __FILE__, \ 327 + __LINE__, (u32)(ofs), (u32)(val)); \ 328 + _ipw_write16(ipw, ofs, val); \ 329 + } while (0) 319 330 320 331 /* 32-bit direct write (low 4K) */ 321 - #define _ipw_write32(ipw, ofs, val) writel((val), (ipw)->hw_base + (ofs)) 332 + static inline void _ipw_write32(struct ipw_priv *ipw, unsigned long ofs, 333 + u32 val) 334 + { 335 + writel(val, ipw->hw_base + ofs); 336 + } 322 337 323 338 /* 32-bit direct write (for low 4K of SRAM/regs), with debug wrapper */ 324 - #define ipw_write32(ipw, ofs, val) \ 325 - IPW_DEBUG_IO("%s %d: write_direct32(0x%08X, 0x%08X)\n", __FILE__, __LINE__, (u32)(ofs), (u32)(val)); \ 326 - _ipw_write32(ipw, ofs, val) 339 + #define ipw_write32(ipw, ofs, val) do { \ 340 + IPW_DEBUG_IO("%s %d: write_direct32(0x%08X, 0x%08X)\n", __FILE__, \ 341 + __LINE__, (u32)(ofs), (u32)(val)); \ 342 + _ipw_write32(ipw, ofs, val); \ 343 + } while (0) 327 344 328 345 /* 8-bit direct read (low 4K) */ 329 - #define _ipw_read8(ipw, ofs) readb((ipw)->hw_base + (ofs)) 330 - 331 - /* 8-bit direct read (low 4K), with debug wrapper */ 332 - static inline u8 __ipw_read8(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) 346 + static inline u8 _ipw_read8(struct ipw_priv *ipw, unsigned long ofs) 333 347 { 334 - IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", f, l, (u32) (ofs)); 335 - return _ipw_read8(ipw, ofs); 348 + return readb(ipw->hw_base + ofs); 336 349 } 337 350 338 351 /* alias to 8-bit direct read (low 4K of SRAM/regs), with debug wrapper */ 339 - #define ipw_read8(ipw, ofs) __ipw_read8(__FILE__, __LINE__, ipw, ofs) 352 + #define ipw_read8(ipw, ofs) ({ \ 353 + IPW_DEBUG_IO("%s %d: read_direct8(0x%08X)\n", __FILE__, __LINE__, \ 354 + (u32)(ofs)); \ 355 + _ipw_read8(ipw, ofs); \ 356 + }) 340 357 341 358 /* 16-bit direct read (low 4K) */ 342 - #define _ipw_read16(ipw, ofs) readw((ipw)->hw_base + (ofs)) 343 - 344 - /* 16-bit direct read (low 4K), with debug wrapper */ 345 - static inline u16 __ipw_read16(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) 359 + static inline u16 _ipw_read16(struct ipw_priv *ipw, unsigned long ofs) 346 360 { 347 - IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", f, l, (u32) (ofs)); 348 - return _ipw_read16(ipw, ofs); 361 + return readw(ipw->hw_base + ofs); 349 362 } 350 363 351 364 /* alias to 16-bit direct read (low 4K of SRAM/regs), with debug wrapper */ 352 - #define ipw_read16(ipw, ofs) __ipw_read16(__FILE__, __LINE__, ipw, ofs) 365 + #define ipw_read16(ipw, ofs) ({ \ 366 + IPW_DEBUG_IO("%s %d: read_direct16(0x%08X)\n", __FILE__, __LINE__, \ 367 + (u32)(ofs)); \ 368 + _ipw_read16(ipw, ofs); \ 369 + }) 353 370 354 371 /* 32-bit direct read (low 4K) */ 355 - #define _ipw_read32(ipw, ofs) readl((ipw)->hw_base + (ofs)) 356 - 357 - /* 32-bit direct read (low 4K), with debug wrapper */ 358 - static inline u32 __ipw_read32(char *f, u32 l, struct ipw_priv *ipw, u32 ofs) 372 + static inline u32 _ipw_read32(struct ipw_priv *ipw, unsigned long ofs) 359 373 { 360 - IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", f, l, (u32) (ofs)); 361 - return _ipw_read32(ipw, ofs); 374 + return readl(ipw->hw_base + ofs); 362 375 } 363 376 364 377 /* alias to 32-bit direct read (low 4K of SRAM/regs), with debug wrapper */ 365 - #define ipw_read32(ipw, ofs) __ipw_read32(__FILE__, __LINE__, ipw, ofs) 378 + #define ipw_read32(ipw, ofs) ({ \ 379 + IPW_DEBUG_IO("%s %d: read_direct32(0x%08X)\n", __FILE__, __LINE__, \ 380 + (u32)(ofs)); \ 381 + _ipw_read32(ipw, ofs); \ 382 + }) 366 383 367 - /* multi-byte read (above 4K), with debug wrapper */ 368 384 static void _ipw_read_indirect(struct ipw_priv *, u32, u8 *, int); 369 - static inline void __ipw_read_indirect(const char *f, int l, 370 - struct ipw_priv *a, u32 b, u8 * c, int d) 371 - { 372 - IPW_DEBUG_IO("%s %d: read_indirect(0x%08X) %d bytes\n", f, l, (u32) (b), 373 - d); 374 - _ipw_read_indirect(a, b, c, d); 375 - } 376 - 377 385 /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */ 378 - #define ipw_read_indirect(a, b, c, d) __ipw_read_indirect(__FILE__, __LINE__, a, b, c, d) 386 + #define ipw_read_indirect(a, b, c, d) ({ \ 387 + IPW_DEBUG_IO("%s %d: read_indirect(0x%08X) %u bytes\n", __FILE__, \ 388 + __LINE__, (u32)(b), (u32)(d)); \ 389 + _ipw_read_indirect(a, b, c, d); \ 390 + }) 379 391 380 392 /* alias to multi-byte read (SRAM/regs above 4K), with debug wrapper */ 381 393 static void _ipw_write_indirect(struct ipw_priv *priv, u32 addr, u8 * data, 382 394 int num); 383 - #define ipw_write_indirect(a, b, c, d) \ 384 - IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %d bytes\n", __FILE__, __LINE__, (u32)(b), d); \ 385 - _ipw_write_indirect(a, b, c, d) 395 + #define ipw_write_indirect(a, b, c, d) do { \ 396 + IPW_DEBUG_IO("%s %d: write_indirect(0x%08X) %u bytes\n", __FILE__, \ 397 + __LINE__, (u32)(b), (u32)(d)); \ 398 + _ipw_write_indirect(a, b, c, d); \ 399 + } while (0) 386 400 387 401 /* 32-bit indirect write (above 4K) */ 388 402 static void _ipw_write_reg32(struct ipw_priv *priv, u32 reg, u32 value) ··· 11238 11224 { 11239 11225 int rc, i, j; 11240 11226 11227 + /* Age scan list entries found before suspend */ 11228 + if (priv->suspend_time) { 11229 + ieee80211_networks_age(priv->ieee, priv->suspend_time); 11230 + priv->suspend_time = 0; 11231 + } 11232 + 11241 11233 if (priv->status & STATUS_EXIT_PENDING) 11242 11234 return -EIO; 11243 11235 ··· 11844 11824 pci_disable_device(pdev); 11845 11825 pci_set_power_state(pdev, pci_choose_state(pdev, state)); 11846 11826 11827 + priv->suspend_at = get_seconds(); 11828 + 11847 11829 return 0; 11848 11830 } 11849 11831 ··· 11880 11858 /* Set the device back into the PRESENT state; this will also wake 11881 11859 * the queue of needed */ 11882 11860 netif_device_attach(dev); 11861 + 11862 + priv->suspend_time = get_seconds() - priv->suspend_at; 11883 11863 11884 11864 /* Bring the device back up */ 11885 11865 queue_work(priv->workqueue, &priv->up);
+6 -1
drivers/net/wireless/ipw2x00/ipw2200.h
··· 49 49 #include <asm/io.h> 50 50 51 51 #include <net/lib80211.h> 52 - #include <net/ieee80211.h> 53 52 #include <net/ieee80211_radiotap.h> 54 53 55 54 #define DRV_NAME "ipw2200" 56 55 57 56 #include <linux/workqueue.h> 57 + 58 + #include "ieee80211.h" 58 59 59 60 /* Authentication and Association States */ 60 61 enum connection_manager_assoc_states { ··· 1346 1345 u8 adapter; 1347 1346 1348 1347 s8 tx_power; 1348 + 1349 + /* Track time in suspend */ 1350 + unsigned long suspend_at; 1351 + unsigned long suspend_time; 1349 1352 1350 1353 #ifdef CONFIG_PM 1351 1354 u32 pm_state[16];
+1 -1
drivers/net/wireless/ipw2x00/libipw_geo.c
··· 41 41 #include <linux/etherdevice.h> 42 42 #include <asm/uaccess.h> 43 43 44 - #include <net/ieee80211.h> 44 + #include "ieee80211.h" 45 45 46 46 int ieee80211_is_valid_channel(struct ieee80211_device *ieee, u8 channel) 47 47 {
+16 -1
drivers/net/wireless/ipw2x00/libipw_module.c
··· 50 50 #include <net/net_namespace.h> 51 51 #include <net/arp.h> 52 52 53 - #include <net/ieee80211.h> 53 + #include "ieee80211.h" 54 54 55 55 #define DRV_DESCRIPTION "802.11 data/management/control stack" 56 56 #define DRV_NAME "ieee80211" ··· 104 104 kfree(ieee->networks); 105 105 ieee->networks = NULL; 106 106 } 107 + 108 + void ieee80211_networks_age(struct ieee80211_device *ieee, 109 + unsigned long age_secs) 110 + { 111 + struct ieee80211_network *network = NULL; 112 + unsigned long flags; 113 + unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC); 114 + 115 + spin_lock_irqsave(&ieee->lock, flags); 116 + list_for_each_entry(network, &ieee->network_list, list) { 117 + network->last_scanned -= age_jiffies; 118 + } 119 + spin_unlock_irqrestore(&ieee->lock, flags); 120 + } 121 + EXPORT_SYMBOL(ieee80211_networks_age); 107 122 108 123 static void ieee80211_networks_initialize(struct ieee80211_device *ieee) 109 124 {
+3 -2
drivers/net/wireless/ipw2x00/libipw_rx.c
··· 33 33 #include <linux/ctype.h> 34 34 35 35 #include <net/lib80211.h> 36 - #include <net/ieee80211.h> 36 + 37 + #include "ieee80211.h" 37 38 38 39 static void ieee80211_monitor_rx(struct ieee80211_device *ieee, 39 40 struct sk_buff *skb, ··· 1616 1615 break; 1617 1616 1618 1617 if ((oldest == NULL) || 1619 - (target->last_scanned < oldest->last_scanned)) 1618 + time_before(target->last_scanned, oldest->last_scanned)) 1620 1619 oldest = target; 1621 1620 } 1622 1621
+1 -1
drivers/net/wireless/ipw2x00/libipw_tx.c
··· 41 41 #include <linux/etherdevice.h> 42 42 #include <asm/uaccess.h> 43 43 44 - #include <net/ieee80211.h> 44 + #include "ieee80211.h" 45 45 46 46 /* 47 47
+19 -8
drivers/net/wireless/ipw2x00/libipw_wx.c
··· 35 35 #include <linux/jiffies.h> 36 36 37 37 #include <net/lib80211.h> 38 - #include <net/ieee80211.h> 39 38 #include <linux/wireless.h> 39 + 40 + #include "ieee80211.h" 40 41 41 42 static const char *ieee80211_modes[] = { 42 43 "?", "a", "b", "ab", "g", "ag", "bg", "abg" 43 44 }; 45 + 46 + static inline unsigned int elapsed_jiffies_msecs(unsigned long start) 47 + { 48 + unsigned long end = jiffies; 49 + 50 + if (end >= start) 51 + return jiffies_to_msecs(end - start); 52 + 53 + return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1); 54 + } 44 55 45 56 #define MAX_CUSTOM_LEN 64 46 57 static char *ieee80211_translate_scan(struct ieee80211_device *ieee, ··· 226 215 iwe.cmd = IWEVCUSTOM; 227 216 p = custom; 228 217 p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), 229 - " Last beacon: %dms ago", 230 - jiffies_to_msecs(jiffies - network->last_scanned)); 218 + " Last beacon: %ums ago", 219 + elapsed_jiffies_msecs(network->last_scanned)); 231 220 iwe.u.data.length = p - custom; 232 221 if (iwe.u.data.length) 233 222 start = iwe_stream_add_point(info, start, stop, &iwe, custom); ··· 287 276 time_after(network->last_scanned + ieee->scan_age, jiffies)) 288 277 ev = ieee80211_translate_scan(ieee, ev, stop, network, 289 278 info); 290 - else 279 + else { 291 280 IEEE80211_DEBUG_SCAN("Not showing network '%s (" 292 - "%pM)' due to age (%dms).\n", 281 + "%pM)' due to age (%ums).\n", 293 282 print_ssid(ssid, network->ssid, 294 283 network->ssid_len), 295 284 network->bssid, 296 - jiffies_to_msecs(jiffies - 297 - network-> 298 - last_scanned)); 285 + elapsed_jiffies_msecs( 286 + network->last_scanned)); 287 + } 299 288 } 300 289 301 290 spin_unlock_irqrestore(&ieee->lock, flags);
+20 -36
drivers/net/wireless/iwlwifi/Kconfig
··· 1 1 config IWLWIFI 2 - bool "Intel Wireless Wifi" 2 + tristate "Intel Wireless Wifi" 3 3 depends on PCI && MAC80211 && WLAN_80211 && EXPERIMENTAL 4 - default y 5 - 6 - config IWLCORE 7 - tristate "Intel Wireless Wifi Core" 8 - depends on IWLWIFI 9 4 select LIB80211 5 + select FW_LOADER 10 6 select MAC80211_LEDS if IWLWIFI_LEDS 11 7 select LEDS_CLASS if IWLWIFI_LEDS 12 8 select RFKILL if IWLWIFI_RFKILL 9 + select MAC80211_LEDS if IWL3945_LEDS 10 + select LEDS_CLASS if IWL3945_LEDS 13 11 14 12 config IWLWIFI_LEDS 15 13 bool "Enable LED support in iwlagn driver" 16 - depends on IWLCORE 14 + depends on IWLWIFI 17 15 18 16 config IWLWIFI_RFKILL 19 - bool "Enable RF kill support in iwlagn driver" 20 - depends on IWLCORE 17 + bool "Enable RF kill support in iwlagn and iwl3945 drivers" 18 + depends on IWLWIFI 19 + 20 + config IWLWIFI_SPECTRUM_MEASUREMENT 21 + bool "Enable Spectrum Measurement in iwlagn driver" 22 + depends on IWLWIFI 23 + ---help--- 24 + This option will enable spectrum measurement for the iwlagn driver. 21 25 22 26 config IWLWIFI_DEBUG 23 27 bool "Enable full debugging output in iwlagn and iwl3945 drivers" 24 - depends on IWLCORE 28 + depends on IWLWIFI 25 29 ---help--- 26 30 This option will enable debug tracing output for the iwlwifi drivers 27 31 ··· 49 45 any problems you may encounter. 50 46 51 47 config IWLWIFI_DEBUGFS 52 - bool "Iwlwifi debugfs support" 53 - depends on IWLCORE && IWLWIFI_DEBUG && MAC80211_DEBUGFS 48 + bool "iwlagn debugfs support" 49 + depends on IWLWIFI && IWLWIFI_DEBUG && MAC80211_DEBUGFS 54 50 ---help--- 55 51 Enable creation of debugfs files for the iwlwifi drivers. 56 52 57 53 config IWLAGN 58 - tristate "Intel Wireless WiFi Next Gen AGN" 54 + tristate "Intel Wireless WiFi Next Gen AGN (iwlagn)" 59 55 depends on IWLWIFI 60 - select FW_LOADER 61 - select IWLCORE 62 56 ---help--- 63 57 Select to build the driver supporting the: 64 58 ··· 79 77 say M here and read <file:Documentation/kbuild/modules.txt>. The 80 78 module will be called iwlagn.ko. 81 79 82 - config IWLAGN_SPECTRUM_MEASUREMENT 83 - bool "Enable Spectrum Measurement in iwlagn driver" 84 - depends on IWLAGN 85 - ---help--- 86 - This option will enable spectrum measurement for the iwlagn driver. 87 - 88 - config IWLAGN_LEDS 89 - bool "Enable LEDS features in iwlagn driver" 90 - depends on IWLAGN 91 - select IWLWIFI_LEDS 92 - ---help--- 93 - This option enables LEDS for the iwlagn drivers 94 - 95 80 96 81 config IWL4965 97 82 bool "Intel Wireless WiFi 4965AGN" ··· 87 98 This option enables support for Intel Wireless WiFi Link 4965AGN 88 99 89 100 config IWL5000 90 - bool "Intel Wireless WiFi 5000AGN" 101 + bool "Intel Wireless WiFi 5000AGN; Intel WiFi Link 100, 6000, and 6050 Series" 91 102 depends on IWLAGN 92 103 ---help--- 93 104 This option enables support for Intel Wireless WiFi Link 5000AGN Family 94 105 95 106 config IWL3945 96 - tristate "Intel PRO/Wireless 3945ABG/BG Network Connection" 107 + tristate "Intel PRO/Wireless 3945ABG/BG Network Connection (iwl3945)" 97 108 depends on IWLWIFI 98 - select FW_LOADER 99 - select LIB80211 100 - select MAC80211_LEDS if IWL3945_LEDS 101 - select LEDS_CLASS if IWL3945_LEDS 102 - select RFKILL if IWLWIFI_RFKILL 103 109 ---help--- 104 110 Select to build the driver supporting the: 105 111 ··· 118 134 module will be called iwl3945.ko. 119 135 120 136 config IWL3945_SPECTRUM_MEASUREMENT 121 - bool "Enable Spectrum Measurement in iwl3945 drivers" 137 + bool "Enable Spectrum Measurement in iwl3945 driver" 122 138 depends on IWL3945 123 139 ---help--- 124 140 This option will enable spectrum measurement for the iwl3945 driver.
+2 -2
drivers/net/wireless/iwlwifi/Makefile
··· 1 - obj-$(CONFIG_IWLCORE) += iwlcore.o 1 + obj-$(CONFIG_IWLWIFI) += iwlcore.o 2 2 iwlcore-objs := iwl-core.o iwl-eeprom.o iwl-hcmd.o iwl-power.o 3 3 iwlcore-objs += iwl-rx.o iwl-tx.o iwl-sta.o iwl-calib.o 4 4 iwlcore-objs += iwl-scan.o 5 5 iwlcore-$(CONFIG_IWLWIFI_DEBUGFS) += iwl-debugfs.o 6 6 iwlcore-$(CONFIG_IWLWIFI_LEDS) += iwl-led.o 7 7 iwlcore-$(CONFIG_IWLWIFI_RFKILL) += iwl-rfkill.o 8 - iwlcore-$(CONFIG_IWLAGN_SPECTRUM_MEASUREMENT) += iwl-spectrum.o 8 + iwlcore-$(CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT) += iwl-spectrum.o 9 9 10 10 obj-$(CONFIG_IWLAGN) += iwlagn.o 11 11 iwlagn-objs := iwl-agn.o iwl-agn-rs.o
+2 -1
drivers/net/wireless/iwlwifi/iwl-3945.c
··· 1073 1073 * D0U* --> D0A* state */ 1074 1074 iwl_set_bit(priv, CSR_GP_CNTRL, CSR_GP_CNTRL_REG_FLAG_INIT_DONE); 1075 1075 1076 - iwl_poll_direct_bit(priv, CSR_GP_CNTRL, 1076 + ret = iwl_poll_direct_bit(priv, CSR_GP_CNTRL, 1077 1077 CSR_GP_CNTRL_REG_FLAG_MAC_CLOCK_READY, 25000); 1078 1078 if (ret < 0) { 1079 1079 IWL_DEBUG_INFO(priv, "Failed to init the card\n"); ··· 2747 2747 .query_addr = iwlcore_eeprom_query_addr, 2748 2748 }, 2749 2749 .send_tx_power = iwl3945_send_tx_power, 2750 + .is_valid_rtc_data_addr = iwl3945_hw_valid_rtc_data_addr, 2750 2751 }; 2751 2752 2752 2753 static struct iwl_hcmd_utils_ops iwl3945_hcmd_utils = {
+9 -164
drivers/net/wireless/iwlwifi/iwl-agn.c
··· 72 72 #define VD 73 73 #endif 74 74 75 - #ifdef CONFIG_IWLAGN_SPECTRUM_MEASUREMENT 75 + #ifdef CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT 76 76 #define VS "s" 77 77 #else 78 78 #define VS ··· 444 444 pci_unmap_single(dev, 445 445 pci_unmap_addr(&txq->cmd[index]->meta, mapping), 446 446 pci_unmap_len(&txq->cmd[index]->meta, len), 447 - PCI_DMA_TODEVICE); 447 + PCI_DMA_BIDIRECTIONAL); 448 448 449 449 /* Unmap chunks, if any. */ 450 450 for (i = 1; i < num_tbs; i++) { ··· 644 644 / MAX_UCODE_BEACON_INTERVAL; 645 645 new_val = beacon_val / beacon_factor; 646 646 647 + if (!new_val) 648 + new_val = MAX_UCODE_BEACON_INTERVAL; 649 + 647 650 return new_val; 648 651 } 649 652 ··· 752 749 msecs_to_jiffies(5)); 753 750 else 754 751 IWL_WARN(priv, "uCode did not respond OK.\n"); 755 - } 756 - 757 - static void iwl_rx_reply_error(struct iwl_priv *priv, 758 - struct iwl_rx_mem_buffer *rxb) 759 - { 760 - struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 761 - 762 - IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " 763 - "seq 0x%04X ser 0x%08X\n", 764 - le32_to_cpu(pkt->u.err_resp.error_type), 765 - get_cmd_string(pkt->u.err_resp.cmd_id), 766 - pkt->u.err_resp.cmd_id, 767 - le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), 768 - le32_to_cpu(pkt->u.err_resp.error_info)); 769 - } 770 - 771 - static void iwl_rx_pm_sleep_notif(struct iwl_priv *priv, 772 - struct iwl_rx_mem_buffer *rxb) 773 - { 774 - #ifdef CONFIG_IWLWIFI_DEBUG 775 - struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 776 - struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); 777 - IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", 778 - sleep->pm_sleep_mode, sleep->pm_wakeup_src); 779 - #endif 780 - } 781 - 782 - static void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv, 783 - struct iwl_rx_mem_buffer *rxb) 784 - { 785 - struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 786 - IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " 787 - "notification for %s:\n", 788 - le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd)); 789 - iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len)); 790 752 } 791 753 792 754 static void iwl_bg_beacon_update(struct work_struct *work) ··· 1278 1310 } 1279 1311 #endif 1280 1312 spin_unlock_irqrestore(&priv->lock, flags); 1281 - } 1282 - 1283 - static irqreturn_t iwl_isr(int irq, void *data) 1284 - { 1285 - struct iwl_priv *priv = data; 1286 - u32 inta, inta_mask; 1287 - u32 inta_fh; 1288 - if (!priv) 1289 - return IRQ_NONE; 1290 - 1291 - spin_lock(&priv->lock); 1292 - 1293 - /* Disable (but don't clear!) interrupts here to avoid 1294 - * back-to-back ISRs and sporadic interrupts from our NIC. 1295 - * If we have something to service, the tasklet will re-enable ints. 1296 - * If we *don't* have something, we'll re-enable before leaving here. */ 1297 - inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */ 1298 - iwl_write32(priv, CSR_INT_MASK, 0x00000000); 1299 - 1300 - /* Discover which interrupts are active/pending */ 1301 - inta = iwl_read32(priv, CSR_INT); 1302 - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); 1303 - 1304 - /* Ignore interrupt if there's nothing in NIC to service. 1305 - * This may be due to IRQ shared with another device, 1306 - * or due to sporadic interrupts thrown from our NIC. */ 1307 - if (!inta && !inta_fh) { 1308 - IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n"); 1309 - goto none; 1310 - } 1311 - 1312 - if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { 1313 - /* Hardware disappeared. It might have already raised 1314 - * an interrupt */ 1315 - IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); 1316 - goto unplugged; 1317 - } 1318 - 1319 - IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 1320 - inta, inta_mask, inta_fh); 1321 - 1322 - inta &= ~CSR_INT_BIT_SCD; 1323 - 1324 - /* iwl_irq_tasklet() will service interrupts and re-enable them */ 1325 - if (likely(inta || inta_fh)) 1326 - tasklet_schedule(&priv->irq_tasklet); 1327 - 1328 - unplugged: 1329 - spin_unlock(&priv->lock); 1330 - return IRQ_HANDLED; 1331 - 1332 - none: 1333 - /* re-enable interrupts here since we don't have anything to service. */ 1334 - /* only Re-enable if diabled by irq */ 1335 - if (test_bit(STATUS_INT_ENABLED, &priv->status)) 1336 - iwl_enable_interrupts(priv); 1337 - spin_unlock(&priv->lock); 1338 - return IRQ_NONE; 1339 1313 } 1340 1314 1341 1315 /****************************************************************************** ··· 2584 2674 2585 2675 } 2586 2676 2587 - static int iwl_mac_hw_scan(struct ieee80211_hw *hw, 2588 - struct cfg80211_scan_request *req) 2589 - { 2590 - unsigned long flags; 2591 - struct iwl_priv *priv = hw->priv; 2592 - int ret; 2593 - u8 *ssid = NULL; 2594 - size_t ssid_len = 0; 2595 - 2596 - if (req->n_ssids) { 2597 - ssid = req->ssids[0].ssid; 2598 - ssid_len = req->ssids[0].ssid_len; 2599 - } 2600 - 2601 - IWL_DEBUG_MAC80211(priv, "enter\n"); 2602 - 2603 - mutex_lock(&priv->mutex); 2604 - spin_lock_irqsave(&priv->lock, flags); 2605 - 2606 - if (!iwl_is_ready_rf(priv)) { 2607 - ret = -EIO; 2608 - IWL_DEBUG_MAC80211(priv, "leave - not ready or exit pending\n"); 2609 - goto out_unlock; 2610 - } 2611 - 2612 - /* We don't schedule scan within next_scan_jiffies period. 2613 - * Avoid scanning during possible EAPOL exchange, return 2614 - * success immediately. 2615 - */ 2616 - if (priv->next_scan_jiffies && 2617 - time_after(priv->next_scan_jiffies, jiffies)) { 2618 - IWL_DEBUG_SCAN(priv, "scan rejected: within next scan period\n"); 2619 - queue_work(priv->workqueue, &priv->scan_completed); 2620 - ret = 0; 2621 - goto out_unlock; 2622 - } 2623 - 2624 - /* if we just finished scan ask for delay */ 2625 - if (iwl_is_associated(priv) && priv->last_scan_jiffies && 2626 - time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN, jiffies)) { 2627 - IWL_DEBUG_SCAN(priv, "scan rejected: within previous scan period\n"); 2628 - queue_work(priv->workqueue, &priv->scan_completed); 2629 - ret = 0; 2630 - goto out_unlock; 2631 - } 2632 - 2633 - if (ssid_len) { 2634 - priv->one_direct_scan = 1; 2635 - priv->direct_ssid_len = ssid_len; 2636 - memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); 2637 - } else { 2638 - priv->one_direct_scan = 0; 2639 - } 2640 - 2641 - ret = iwl_scan_initiate(priv); 2642 - 2643 - IWL_DEBUG_MAC80211(priv, "leave\n"); 2644 - 2645 - out_unlock: 2646 - spin_unlock_irqrestore(&priv->lock, flags); 2647 - mutex_unlock(&priv->mutex); 2648 - 2649 - return ret; 2650 - } 2651 - 2652 2677 static void iwl_mac_update_tkip_key(struct ieee80211_hw *hw, 2653 2678 struct ieee80211_key_conf *keyconf, const u8 *addr, 2654 2679 u32 iv32, u16 *phase1key) ··· 3215 3370 3216 3371 static void iwl_setup_deferred_work(struct iwl_priv *priv) 3217 3372 { 3218 - priv->workqueue = create_workqueue(DRV_NAME); 3373 + priv->workqueue = create_singlethread_workqueue(DRV_NAME); 3219 3374 3220 3375 init_waitqueue_head(&priv->wait_command_queue); 3221 3376 ··· 3457 3612 err = sysfs_create_group(&pdev->dev.kobj, &iwl_attribute_group); 3458 3613 if (err) { 3459 3614 IWL_ERR(priv, "failed to create sysfs device attributes\n"); 3460 - goto out_uninit_drv; 3615 + goto out_free_irq; 3461 3616 } 3462 3617 3463 3618 iwl_setup_deferred_work(priv); ··· 3502 3657 3503 3658 out_remove_sysfs: 3504 3659 sysfs_remove_group(&pdev->dev.kobj, &iwl_attribute_group); 3660 + out_free_irq: 3661 + free_irq(priv->pci_dev->irq, priv); 3505 3662 out_disable_msi: 3506 3663 pci_disable_msi(priv->pci_dev); 3507 - pci_disable_device(priv->pci_dev); 3508 - out_uninit_drv: 3509 3664 iwl_uninit_drv(priv); 3510 3665 out_free_eeprom: 3511 3666 iwl_eeprom_free(priv);
+104 -4
drivers/net/wireless/iwlwifi/iwl-core.c
··· 1386 1386 { 1387 1387 int ret = 0; 1388 1388 if (tx_power < IWL_TX_POWER_TARGET_POWER_MIN) { 1389 - IWL_WARN(priv, "Requested user TXPOWER %d below limit.\n", 1390 - priv->tx_power_user_lmt); 1389 + IWL_WARN(priv, "Requested user TXPOWER %d below lower limit %d.\n", 1390 + tx_power, 1391 + IWL_TX_POWER_TARGET_POWER_MIN); 1391 1392 return -EINVAL; 1392 1393 } 1393 1394 1394 1395 if (tx_power > IWL_TX_POWER_TARGET_POWER_MAX) { 1395 - IWL_WARN(priv, "Requested user TXPOWER %d above limit.\n", 1396 - priv->tx_power_user_lmt); 1396 + IWL_WARN(priv, "Requested user TXPOWER %d above upper limit %d.\n", 1397 + tx_power, 1398 + IWL_TX_POWER_TARGET_POWER_MAX); 1397 1399 return -EINVAL; 1398 1400 } 1399 1401 ··· 1443 1441 iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK); 1444 1442 } 1445 1443 EXPORT_SYMBOL(iwl_enable_interrupts); 1444 + 1445 + irqreturn_t iwl_isr(int irq, void *data) 1446 + { 1447 + struct iwl_priv *priv = data; 1448 + u32 inta, inta_mask; 1449 + u32 inta_fh; 1450 + if (!priv) 1451 + return IRQ_NONE; 1452 + 1453 + spin_lock(&priv->lock); 1454 + 1455 + /* Disable (but don't clear!) interrupts here to avoid 1456 + * back-to-back ISRs and sporadic interrupts from our NIC. 1457 + * If we have something to service, the tasklet will re-enable ints. 1458 + * If we *don't* have something, we'll re-enable before leaving here. */ 1459 + inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */ 1460 + iwl_write32(priv, CSR_INT_MASK, 0x00000000); 1461 + 1462 + /* Discover which interrupts are active/pending */ 1463 + inta = iwl_read32(priv, CSR_INT); 1464 + inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); 1465 + 1466 + /* Ignore interrupt if there's nothing in NIC to service. 1467 + * This may be due to IRQ shared with another device, 1468 + * or due to sporadic interrupts thrown from our NIC. */ 1469 + if (!inta && !inta_fh) { 1470 + IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n"); 1471 + goto none; 1472 + } 1473 + 1474 + if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { 1475 + /* Hardware disappeared. It might have already raised 1476 + * an interrupt */ 1477 + IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); 1478 + goto unplugged; 1479 + } 1480 + 1481 + IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 1482 + inta, inta_mask, inta_fh); 1483 + 1484 + inta &= ~CSR_INT_BIT_SCD; 1485 + 1486 + /* iwl_irq_tasklet() will service interrupts and re-enable them */ 1487 + if (likely(inta || inta_fh)) 1488 + tasklet_schedule(&priv->irq_tasklet); 1489 + 1490 + unplugged: 1491 + spin_unlock(&priv->lock); 1492 + return IRQ_HANDLED; 1493 + 1494 + none: 1495 + /* re-enable interrupts here since we don't have anything to service. */ 1496 + /* only Re-enable if diabled by irq */ 1497 + if (test_bit(STATUS_INT_ENABLED, &priv->status)) 1498 + iwl_enable_interrupts(priv); 1499 + spin_unlock(&priv->lock); 1500 + return IRQ_NONE; 1501 + } 1502 + EXPORT_SYMBOL(iwl_isr); 1446 1503 1447 1504 int iwl_send_bt_config(struct iwl_priv *priv) 1448 1505 { ··· 2038 1977 iwl_rfkill_set_hw_state(priv); 2039 1978 } 2040 1979 EXPORT_SYMBOL(iwl_bg_rf_kill); 1980 + 1981 + void iwl_rx_pm_sleep_notif(struct iwl_priv *priv, 1982 + struct iwl_rx_mem_buffer *rxb) 1983 + { 1984 + #ifdef CONFIG_IWLWIFI_DEBUG 1985 + struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1986 + struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); 1987 + IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", 1988 + sleep->pm_sleep_mode, sleep->pm_wakeup_src); 1989 + #endif 1990 + } 1991 + EXPORT_SYMBOL(iwl_rx_pm_sleep_notif); 1992 + 1993 + void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv, 1994 + struct iwl_rx_mem_buffer *rxb) 1995 + { 1996 + struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 1997 + IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " 1998 + "notification for %s:\n", 1999 + le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd)); 2000 + iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, le32_to_cpu(pkt->len)); 2001 + } 2002 + EXPORT_SYMBOL(iwl_rx_pm_debug_statistics_notif); 2003 + 2004 + void iwl_rx_reply_error(struct iwl_priv *priv, 2005 + struct iwl_rx_mem_buffer *rxb) 2006 + { 2007 + struct iwl_rx_packet *pkt = (struct iwl_rx_packet *)rxb->skb->data; 2008 + 2009 + IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " 2010 + "seq 0x%04X ser 0x%08X\n", 2011 + le32_to_cpu(pkt->u.err_resp.error_type), 2012 + get_cmd_string(pkt->u.err_resp.cmd_id), 2013 + pkt->u.err_resp.cmd_id, 2014 + le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), 2015 + le32_to_cpu(pkt->u.err_resp.error_info)); 2016 + } 2017 + EXPORT_SYMBOL(iwl_rx_reply_error); 2018 +
+13 -1
drivers/net/wireless/iwlwifi/iwl-core.h
··· 250 250 void iwl_uninit_drv(struct iwl_priv *priv); 251 251 252 252 /***************************************************** 253 + * RX handlers. 254 + * **************************************************/ 255 + void iwl_rx_pm_sleep_notif(struct iwl_priv *priv, 256 + struct iwl_rx_mem_buffer *rxb); 257 + void iwl_rx_pm_debug_statistics_notif(struct iwl_priv *priv, 258 + struct iwl_rx_mem_buffer *rxb); 259 + void iwl_rx_reply_error(struct iwl_priv *priv, 260 + struct iwl_rx_mem_buffer *rxb); 261 + 262 + /***************************************************** 253 263 * RX 254 264 ******************************************************/ 255 265 void iwl_rx_queue_free(struct iwl_priv *priv, struct iwl_rx_queue *rxq); ··· 355 345 int iwl_scan_cancel(struct iwl_priv *priv); 356 346 int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); 357 347 int iwl_scan_initiate(struct iwl_priv *priv); 348 + int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); 358 349 u16 iwl_fill_probe_req(struct iwl_priv *priv, enum ieee80211_band band, 359 350 struct ieee80211_mgmt *frame, int left); 360 351 void iwl_setup_rx_scan_handlers(struct iwl_priv *priv); ··· 390 379 /******************************************************************************* 391 380 * Spectrum Measureemtns in iwl-spectrum.c 392 381 ******************************************************************************/ 393 - #ifdef CONFIG_IWLAGN_SPECTRUM_MEASUREMENT 382 + #ifdef CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT 394 383 void iwl_setup_spectrum_handlers(struct iwl_priv *priv); 395 384 #else 396 385 static inline void iwl_setup_spectrum_handlers(struct iwl_priv *priv) {} ··· 421 410 *****************************************************/ 422 411 void iwl_disable_interrupts(struct iwl_priv *priv); 423 412 void iwl_enable_interrupts(struct iwl_priv *priv); 413 + irqreturn_t iwl_isr(int irq, void *data); 424 414 static inline u16 iwl_pcie_link_ctl(struct iwl_priv *priv) 425 415 { 426 416 int pos;
+2 -2
drivers/net/wireless/iwlwifi/iwl-dev.h
··· 841 841 842 842 struct ieee80211_supported_band bands[IEEE80211_NUM_BANDS]; 843 843 844 - #if defined(CONFIG_IWLAGN_SPECTRUM_MEASUREMENT) || defined(CONFIG_IWL3945_SPECTRUM_MEASUREMENT) 844 + #if defined(CONFIG_IWLWIFI_SPECTRUM_MEASUREMENT) || defined(CONFIG_IWL3945_SPECTRUM_MEASUREMENT) 845 845 /* spectrum measurement report caching */ 846 846 struct iwl_spectrum_notification measure_report; 847 847 u8 measurement_status; ··· 922 922 * 4965's initialize alive response contains some calibration data. */ 923 923 struct iwl_init_alive_resp card_alive_init; 924 924 struct iwl_alive_resp card_alive; 925 - #if defined(CONFIG_IWLWIFI_RFKILL) || defined(CONFIG_IWL3945_RFKILL) 925 + #if defined(CONFIG_IWLWIFI_RFKILL) 926 926 struct rfkill *rfkill; 927 927 #endif 928 928
+68
drivers/net/wireless/iwlwifi/iwl-scan.c
··· 440 440 } 441 441 EXPORT_SYMBOL(iwl_scan_initiate); 442 442 443 + #define IWL_DELAY_NEXT_SCAN (HZ*2) 444 + 445 + int iwl_mac_hw_scan(struct ieee80211_hw *hw, 446 + struct cfg80211_scan_request *req) 447 + { 448 + unsigned long flags; 449 + struct iwl_priv *priv = hw->priv; 450 + int ret; 451 + u8 *ssid = NULL; 452 + size_t ssid_len = 0; 453 + 454 + if (req->n_ssids) { 455 + ssid = req->ssids[0].ssid; 456 + ssid_len = req->ssids[0].ssid_len; 457 + } 458 + 459 + IWL_DEBUG_MAC80211(priv, "enter\n"); 460 + 461 + mutex_lock(&priv->mutex); 462 + spin_lock_irqsave(&priv->lock, flags); 463 + 464 + if (!iwl_is_ready_rf(priv)) { 465 + ret = -EIO; 466 + IWL_DEBUG_MAC80211(priv, "leave - not ready or exit pending\n"); 467 + goto out_unlock; 468 + } 469 + 470 + /* We don't schedule scan within next_scan_jiffies period. 471 + * Avoid scanning during possible EAPOL exchange, return 472 + * success immediately. 473 + */ 474 + if (priv->next_scan_jiffies && 475 + time_after(priv->next_scan_jiffies, jiffies)) { 476 + IWL_DEBUG_SCAN(priv, "scan rejected: within next scan period\n"); 477 + queue_work(priv->workqueue, &priv->scan_completed); 478 + ret = 0; 479 + goto out_unlock; 480 + } 481 + 482 + /* if we just finished scan ask for delay */ 483 + if (iwl_is_associated(priv) && priv->last_scan_jiffies && 484 + time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN, jiffies)) { 485 + IWL_DEBUG_SCAN(priv, "scan rejected: within previous scan period\n"); 486 + queue_work(priv->workqueue, &priv->scan_completed); 487 + ret = 0; 488 + goto out_unlock; 489 + } 490 + 491 + if (ssid_len) { 492 + priv->one_direct_scan = 1; 493 + priv->direct_ssid_len = ssid_len; 494 + memcpy(priv->direct_ssid, ssid, priv->direct_ssid_len); 495 + } else { 496 + priv->one_direct_scan = 0; 497 + } 498 + 499 + ret = iwl_scan_initiate(priv); 500 + 501 + IWL_DEBUG_MAC80211(priv, "leave\n"); 502 + 503 + out_unlock: 504 + spin_unlock_irqrestore(&priv->lock, flags); 505 + mutex_unlock(&priv->mutex); 506 + 507 + return ret; 508 + } 509 + EXPORT_SYMBOL(iwl_mac_hw_scan); 510 + 443 511 #define IWL_SCAN_CHECK_WATCHDOG (7 * HZ) 444 512 445 513 void iwl_bg_scan_check(struct work_struct *data)
+3 -3
drivers/net/wireless/iwlwifi/iwl-tx.c
··· 819 819 * within command buffer array. */ 820 820 txcmd_phys = pci_map_single(priv->pci_dev, 821 821 out_cmd, sizeof(struct iwl_cmd), 822 - PCI_DMA_TODEVICE); 822 + PCI_DMA_BIDIRECTIONAL); 823 823 pci_unmap_addr_set(&out_cmd->meta, mapping, txcmd_phys); 824 824 pci_unmap_len_set(&out_cmd->meta, len, sizeof(struct iwl_cmd)); 825 825 /* Add buffer containing Tx command and MAC(!) header to TFD's ··· 968 968 IWL_MAX_SCAN_SIZE : sizeof(struct iwl_cmd); 969 969 970 970 phys_addr = pci_map_single(priv->pci_dev, out_cmd, 971 - len, PCI_DMA_TODEVICE); 971 + len, PCI_DMA_BIDIRECTIONAL); 972 972 pci_unmap_addr_set(&out_cmd->meta, mapping, phys_addr); 973 973 pci_unmap_len_set(&out_cmd->meta, len, len); 974 974 phys_addr += offsetof(struct iwl_cmd, hdr); ··· 1068 1068 pci_unmap_single(priv->pci_dev, 1069 1069 pci_unmap_addr(&txq->cmd[cmd_idx]->meta, mapping), 1070 1070 pci_unmap_len(&txq->cmd[cmd_idx]->meta, len), 1071 - PCI_DMA_TODEVICE); 1071 + PCI_DMA_BIDIRECTIONAL); 1072 1072 1073 1073 for (idx = iwl_queue_inc_wrap(idx, q->n_bd); q->read_ptr != idx; 1074 1074 q->read_ptr = iwl_queue_inc_wrap(q->read_ptr, q->n_bd)) {
+19 -418
drivers/net/wireless/iwlwifi/iwl3945-base.c
··· 726 726 le16_to_cpu(priv->rxon_timing.atim_window)); 727 727 } 728 728 729 - static int iwl3945_scan_initiate(struct iwl_priv *priv) 730 - { 731 - if (!iwl_is_ready_rf(priv)) { 732 - IWL_DEBUG_SCAN(priv, "Aborting scan due to not ready.\n"); 733 - return -EIO; 734 - } 735 - 736 - if (test_bit(STATUS_SCANNING, &priv->status)) { 737 - IWL_DEBUG_SCAN(priv, "Scan already in progress.\n"); 738 - return -EAGAIN; 739 - } 740 - 741 - if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 742 - IWL_DEBUG_SCAN(priv, "Scan request while abort pending. " 743 - "Queuing.\n"); 744 - return -EAGAIN; 745 - } 746 - 747 - IWL_DEBUG_INFO(priv, "Starting scan...\n"); 748 - if (priv->cfg->sku & IWL_SKU_G) 749 - priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ); 750 - if (priv->cfg->sku & IWL_SKU_A) 751 - priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ); 752 - set_bit(STATUS_SCANNING, &priv->status); 753 - priv->scan_start = jiffies; 754 - priv->scan_pass_start = priv->scan_start; 755 - 756 - queue_work(priv->workqueue, &priv->request_scan); 757 - 758 - return 0; 759 - } 760 - 761 729 static int iwl3945_set_mode(struct iwl_priv *priv, int mode) 762 730 { 763 731 if (mode == NL80211_IFTYPE_ADHOC) { ··· 1156 1188 return -1; 1157 1189 } 1158 1190 1159 - static void iwl3945_radio_kill_sw(struct iwl_priv *priv, int disable_radio) 1160 - { 1161 - unsigned long flags; 1162 - 1163 - if (!!disable_radio == test_bit(STATUS_RF_KILL_SW, &priv->status)) 1164 - return; 1165 - 1166 - IWL_DEBUG_RF_KILL(priv, "Manual SW RF KILL set to: RADIO %s\n", 1167 - disable_radio ? "OFF" : "ON"); 1168 - 1169 - if (disable_radio) { 1170 - iwl_scan_cancel(priv); 1171 - /* FIXME: This is a workaround for AP */ 1172 - if (priv->iw_mode != NL80211_IFTYPE_AP) { 1173 - spin_lock_irqsave(&priv->lock, flags); 1174 - iwl_write32(priv, CSR_UCODE_DRV_GP1_SET, 1175 - CSR_UCODE_SW_BIT_RFKILL); 1176 - spin_unlock_irqrestore(&priv->lock, flags); 1177 - iwl_send_card_state(priv, CARD_STATE_CMD_DISABLE, 0); 1178 - set_bit(STATUS_RF_KILL_SW, &priv->status); 1179 - } 1180 - return; 1181 - } 1182 - 1183 - spin_lock_irqsave(&priv->lock, flags); 1184 - iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); 1185 - 1186 - clear_bit(STATUS_RF_KILL_SW, &priv->status); 1187 - spin_unlock_irqrestore(&priv->lock, flags); 1188 - 1189 - /* wake up ucode */ 1190 - msleep(10); 1191 - 1192 - spin_lock_irqsave(&priv->lock, flags); 1193 - iwl_read32(priv, CSR_UCODE_DRV_GP1); 1194 - if (!iwl_grab_nic_access(priv)) 1195 - iwl_release_nic_access(priv); 1196 - spin_unlock_irqrestore(&priv->lock, flags); 1197 - 1198 - if (test_bit(STATUS_RF_KILL_HW, &priv->status)) { 1199 - IWL_DEBUG_RF_KILL(priv, "Can not turn radio back on - " 1200 - "disabled by HW switch\n"); 1201 - return; 1202 - } 1203 - 1204 - if (priv->is_open) 1205 - queue_work(priv->workqueue, &priv->restart); 1206 - return; 1207 - } 1208 - 1209 1191 #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT 1210 1192 1211 1193 #include "iwl-spectrum.h" ··· 1335 1417 return; 1336 1418 } 1337 1419 1338 - static void iwl3945_rx_reply_error(struct iwl_priv *priv, 1339 - struct iwl_rx_mem_buffer *rxb) 1340 - { 1341 - struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1342 - 1343 - IWL_ERR(priv, "Error Reply type 0x%08X cmd %s (0x%02X) " 1344 - "seq 0x%04X ser 0x%08X\n", 1345 - le32_to_cpu(pkt->u.err_resp.error_type), 1346 - get_cmd_string(pkt->u.err_resp.cmd_id), 1347 - pkt->u.err_resp.cmd_id, 1348 - le16_to_cpu(pkt->u.err_resp.bad_cmd_seq_num), 1349 - le32_to_cpu(pkt->u.err_resp.error_info)); 1350 - } 1351 - 1352 - static void iwl3945_rx_spectrum_measure_notif(struct iwl_priv *priv, 1353 - struct iwl_rx_mem_buffer *rxb) 1354 - { 1355 - #ifdef CONFIG_IWL3945_SPECTRUM_MEASUREMENT 1356 - struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1357 - struct iwl_spectrum_notification *report = &(pkt->u.spectrum_notif); 1358 - 1359 - if (!report->state) { 1360 - IWL_DEBUG(priv, IWL_DL_11H | IWL_DL_INFO, 1361 - "Spectrum Measure Notification: Start\n"); 1362 - return; 1363 - } 1364 - 1365 - memcpy(&priv->measure_report, report, sizeof(*report)); 1366 - priv->measurement_status |= MEASUREMENT_READY; 1367 - #endif 1368 - } 1369 - 1370 - static void iwl3945_rx_pm_sleep_notif(struct iwl_priv *priv, 1371 - struct iwl_rx_mem_buffer *rxb) 1372 - { 1373 - #ifdef CONFIG_IWLWIFI_DEBUG 1374 - struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1375 - struct iwl_sleep_notification *sleep = &(pkt->u.sleep_notif); 1376 - IWL_DEBUG_RX(priv, "sleep mode: %d, src: %d\n", 1377 - sleep->pm_sleep_mode, sleep->pm_wakeup_src); 1378 - #endif 1379 - } 1380 - 1381 - static void iwl3945_rx_pm_debug_statistics_notif(struct iwl_priv *priv, 1382 - struct iwl_rx_mem_buffer *rxb) 1383 - { 1384 - struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1385 - IWL_DEBUG_RADIO(priv, "Dumping %d bytes of unhandled " 1386 - "notification for %s:\n", 1387 - le32_to_cpu(pkt->len), get_cmd_string(pkt->hdr.cmd)); 1388 - iwl_print_hex_dump(priv, IWL_DL_RADIO, pkt->u.raw, 1389 - le32_to_cpu(pkt->len)); 1390 - } 1391 - 1392 1420 static void iwl3945_bg_beacon_update(struct work_struct *work) 1393 1421 { 1394 1422 struct iwl_priv *priv = ··· 1380 1516 if ((priv->iw_mode == NL80211_IFTYPE_AP) && 1381 1517 (!test_bit(STATUS_EXIT_PENDING, &priv->status))) 1382 1518 queue_work(priv->workqueue, &priv->beacon_update); 1383 - } 1384 - 1385 - /* Service response to REPLY_SCAN_CMD (0x80) */ 1386 - static void iwl3945_rx_reply_scan(struct iwl_priv *priv, 1387 - struct iwl_rx_mem_buffer *rxb) 1388 - { 1389 - #ifdef CONFIG_IWLWIFI_DEBUG 1390 - struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1391 - struct iwl_scanreq_notification *notif = 1392 - (struct iwl_scanreq_notification *)pkt->u.raw; 1393 - 1394 - IWL_DEBUG_RX(priv, "Scan request status = 0x%x\n", notif->status); 1395 - #endif 1396 - } 1397 - 1398 - /* Service SCAN_START_NOTIFICATION (0x82) */ 1399 - static void iwl3945_rx_scan_start_notif(struct iwl_priv *priv, 1400 - struct iwl_rx_mem_buffer *rxb) 1401 - { 1402 - struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1403 - struct iwl_scanstart_notification *notif = 1404 - (struct iwl_scanstart_notification *)pkt->u.raw; 1405 - priv->scan_start_tsf = le32_to_cpu(notif->tsf_low); 1406 - IWL_DEBUG_SCAN(priv, "Scan start: " 1407 - "%d [802.11%s] " 1408 - "(TSF: 0x%08X:%08X) - %d (beacon timer %u)\n", 1409 - notif->channel, 1410 - notif->band ? "bg" : "a", 1411 - notif->tsf_high, 1412 - notif->tsf_low, notif->status, notif->beacon_timer); 1413 - } 1414 - 1415 - /* Service SCAN_RESULTS_NOTIFICATION (0x83) */ 1416 - static void iwl3945_rx_scan_results_notif(struct iwl_priv *priv, 1417 - struct iwl_rx_mem_buffer *rxb) 1418 - { 1419 - #ifdef CONFIG_IWLWIFI_DEBUG 1420 - struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1421 - struct iwl_scanresults_notification *notif = 1422 - (struct iwl_scanresults_notification *)pkt->u.raw; 1423 - #endif 1424 - 1425 - IWL_DEBUG_SCAN(priv, "Scan ch.res: " 1426 - "%d [802.11%s] " 1427 - "(TSF: 0x%08X:%08X) - %d " 1428 - "elapsed=%lu usec (%dms since last)\n", 1429 - notif->channel, 1430 - notif->band ? "bg" : "a", 1431 - le32_to_cpu(notif->tsf_high), 1432 - le32_to_cpu(notif->tsf_low), 1433 - le32_to_cpu(notif->statistics[0]), 1434 - le32_to_cpu(notif->tsf_low) - priv->scan_start_tsf, 1435 - jiffies_to_msecs(elapsed_jiffies 1436 - (priv->last_scan_jiffies, jiffies))); 1437 - 1438 - priv->last_scan_jiffies = jiffies; 1439 - priv->next_scan_jiffies = 0; 1440 - } 1441 - 1442 - /* Service SCAN_COMPLETE_NOTIFICATION (0x84) */ 1443 - static void iwl3945_rx_scan_complete_notif(struct iwl_priv *priv, 1444 - struct iwl_rx_mem_buffer *rxb) 1445 - { 1446 - #ifdef CONFIG_IWLWIFI_DEBUG 1447 - struct iwl_rx_packet *pkt = (void *)rxb->skb->data; 1448 - struct iwl_scancomplete_notification *scan_notif = (void *)pkt->u.raw; 1449 - #endif 1450 - 1451 - IWL_DEBUG_SCAN(priv, "Scan complete: %d channels (TSF 0x%08X:%08X) - %d\n", 1452 - scan_notif->scanned_channels, 1453 - scan_notif->tsf_low, 1454 - scan_notif->tsf_high, scan_notif->status); 1455 - 1456 - /* The HW is no longer scanning */ 1457 - clear_bit(STATUS_SCAN_HW, &priv->status); 1458 - 1459 - /* The scan completion notification came in, so kill that timer... */ 1460 - cancel_delayed_work(&priv->scan_check); 1461 - 1462 - IWL_DEBUG_INFO(priv, "Scan pass on %sGHz took %dms\n", 1463 - (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) ? 1464 - "2.4" : "5.2", 1465 - jiffies_to_msecs(elapsed_jiffies 1466 - (priv->scan_pass_start, jiffies))); 1467 - 1468 - /* Remove this scanned band from the list of pending 1469 - * bands to scan, band G precedes A in order of scanning 1470 - * as seen in iwl3945_bg_request_scan */ 1471 - if (priv->scan_bands & BIT(IEEE80211_BAND_2GHZ)) 1472 - priv->scan_bands &= ~BIT(IEEE80211_BAND_2GHZ); 1473 - else if (priv->scan_bands & BIT(IEEE80211_BAND_5GHZ)) 1474 - priv->scan_bands &= ~BIT(IEEE80211_BAND_5GHZ); 1475 - 1476 - /* If a request to abort was given, or the scan did not succeed 1477 - * then we reset the scan state machine and terminate, 1478 - * re-queuing another scan if one has been requested */ 1479 - if (test_bit(STATUS_SCAN_ABORTING, &priv->status)) { 1480 - IWL_DEBUG_INFO(priv, "Aborted scan completed.\n"); 1481 - clear_bit(STATUS_SCAN_ABORTING, &priv->status); 1482 - } else { 1483 - /* If there are more bands on this scan pass reschedule */ 1484 - if (priv->scan_bands > 0) 1485 - goto reschedule; 1486 - } 1487 - 1488 - priv->last_scan_jiffies = jiffies; 1489 - priv->next_scan_jiffies = 0; 1490 - IWL_DEBUG_INFO(priv, "Setting scan to off\n"); 1491 - 1492 - clear_bit(STATUS_SCANNING, &priv->status); 1493 - 1494 - IWL_DEBUG_INFO(priv, "Scan took %dms\n", 1495 - jiffies_to_msecs(elapsed_jiffies(priv->scan_start, jiffies))); 1496 - 1497 - queue_work(priv->workqueue, &priv->scan_completed); 1498 - 1499 - return; 1500 - 1501 - reschedule: 1502 - priv->scan_pass_start = jiffies; 1503 - queue_work(priv->workqueue, &priv->request_scan); 1504 1519 } 1505 1520 1506 1521 /* Handle notification from uCode that card's power state is changing ··· 1433 1690 { 1434 1691 priv->rx_handlers[REPLY_ALIVE] = iwl3945_rx_reply_alive; 1435 1692 priv->rx_handlers[REPLY_ADD_STA] = iwl3945_rx_reply_add_sta; 1436 - priv->rx_handlers[REPLY_ERROR] = iwl3945_rx_reply_error; 1693 + priv->rx_handlers[REPLY_ERROR] = iwl_rx_reply_error; 1437 1694 priv->rx_handlers[CHANNEL_SWITCH_NOTIFICATION] = iwl_rx_csa; 1438 - priv->rx_handlers[SPECTRUM_MEASURE_NOTIFICATION] = 1439 - iwl3945_rx_spectrum_measure_notif; 1440 - priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl3945_rx_pm_sleep_notif; 1695 + priv->rx_handlers[PM_SLEEP_NOTIFICATION] = iwl_rx_pm_sleep_notif; 1441 1696 priv->rx_handlers[PM_DEBUG_STATISTIC_NOTIFIC] = 1442 - iwl3945_rx_pm_debug_statistics_notif; 1697 + iwl_rx_pm_debug_statistics_notif; 1443 1698 priv->rx_handlers[BEACON_NOTIFICATION] = iwl3945_rx_beacon_notif; 1444 1699 1445 1700 /* ··· 1448 1707 priv->rx_handlers[REPLY_STATISTICS_CMD] = iwl3945_hw_rx_statistics; 1449 1708 priv->rx_handlers[STATISTICS_NOTIFICATION] = iwl3945_hw_rx_statistics; 1450 1709 1451 - priv->rx_handlers[REPLY_SCAN_CMD] = iwl3945_rx_reply_scan; 1452 - priv->rx_handlers[SCAN_START_NOTIFICATION] = iwl3945_rx_scan_start_notif; 1453 - priv->rx_handlers[SCAN_RESULTS_NOTIFICATION] = 1454 - iwl3945_rx_scan_results_notif; 1455 - priv->rx_handlers[SCAN_COMPLETE_NOTIFICATION] = 1456 - iwl3945_rx_scan_complete_notif; 1710 + iwl_setup_spectrum_handlers(priv); 1711 + iwl_setup_rx_scan_handlers(priv); 1457 1712 priv->rx_handlers[CARD_STATE_NOTIFICATION] = iwl3945_rx_card_state_notif; 1458 1713 1459 1714 /* Set up hardware specific Rx handlers */ ··· 1932 2195 iwl3945_rx_queue_restock(priv); 1933 2196 } 1934 2197 1935 - static void iwl3945_enable_interrupts(struct iwl_priv *priv) 1936 - { 1937 - IWL_DEBUG_ISR(priv, "Enabling interrupts\n"); 1938 - set_bit(STATUS_INT_ENABLED, &priv->status); 1939 - iwl_write32(priv, CSR_INT_MASK, CSR_INI_SET_MASK); 1940 - } 1941 - 1942 - 1943 2198 /* call this function to flush any scheduled tasklet */ 1944 2199 static inline void iwl_synchronize_irq(struct iwl_priv *priv) 1945 2200 { 1946 2201 /* wait to make sure we flush pending tasklet*/ 1947 2202 synchronize_irq(priv->pci_dev->irq); 1948 2203 tasklet_kill(&priv->irq_tasklet); 1949 - } 1950 - 1951 - 1952 - static inline void iwl3945_disable_interrupts(struct iwl_priv *priv) 1953 - { 1954 - clear_bit(STATUS_INT_ENABLED, &priv->status); 1955 - 1956 - /* disable interrupts from uCode/NIC to host */ 1957 - iwl_write32(priv, CSR_INT_MASK, 0x00000000); 1958 - 1959 - /* acknowledge/clear/reset any interrupts still pending 1960 - * from uCode or flow handler (Rx/Tx DMA) */ 1961 - iwl_write32(priv, CSR_INT, 0xffffffff); 1962 - iwl_write32(priv, CSR_FH_INT_STATUS, 0xffffffff); 1963 - IWL_DEBUG_ISR(priv, "Disabled interrupts\n"); 1964 2204 } 1965 2205 1966 2206 static const char *desc_lookup(int i) ··· 2181 2467 IWL_ERR(priv, "Microcode HW error detected. Restarting.\n"); 2182 2468 2183 2469 /* Tell the device to stop sending interrupts */ 2184 - iwl3945_disable_interrupts(priv); 2470 + iwl_disable_interrupts(priv); 2185 2471 2186 2472 iwl_irq_handle_error(priv); 2187 2473 ··· 2261 2547 /* Re-enable all interrupts */ 2262 2548 /* only Re-enable if disabled by irq */ 2263 2549 if (test_bit(STATUS_INT_ENABLED, &priv->status)) 2264 - iwl3945_enable_interrupts(priv); 2550 + iwl_enable_interrupts(priv); 2265 2551 2266 2552 #ifdef CONFIG_IWLWIFI_DEBUG 2267 2553 if (priv->debug_level & (IWL_DL_ISR)) { ··· 2273 2559 } 2274 2560 #endif 2275 2561 spin_unlock_irqrestore(&priv->lock, flags); 2276 - } 2277 - 2278 - static irqreturn_t iwl3945_isr(int irq, void *data) 2279 - { 2280 - struct iwl_priv *priv = data; 2281 - u32 inta, inta_mask; 2282 - u32 inta_fh; 2283 - if (!priv) 2284 - return IRQ_NONE; 2285 - 2286 - spin_lock(&priv->lock); 2287 - 2288 - /* Disable (but don't clear!) interrupts here to avoid 2289 - * back-to-back ISRs and sporadic interrupts from our NIC. 2290 - * If we have something to service, the tasklet will re-enable ints. 2291 - * If we *don't* have something, we'll re-enable before leaving here. */ 2292 - inta_mask = iwl_read32(priv, CSR_INT_MASK); /* just for debug */ 2293 - iwl_write32(priv, CSR_INT_MASK, 0x00000000); 2294 - 2295 - /* Discover which interrupts are active/pending */ 2296 - inta = iwl_read32(priv, CSR_INT); 2297 - inta_fh = iwl_read32(priv, CSR_FH_INT_STATUS); 2298 - 2299 - /* Ignore interrupt if there's nothing in NIC to service. 2300 - * This may be due to IRQ shared with another device, 2301 - * or due to sporadic interrupts thrown from our NIC. */ 2302 - if (!inta && !inta_fh) { 2303 - IWL_DEBUG_ISR(priv, "Ignore interrupt, inta == 0, inta_fh == 0\n"); 2304 - goto none; 2305 - } 2306 - 2307 - if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { 2308 - /* Hardware disappeared */ 2309 - IWL_WARN(priv, "HARDWARE GONE?? INTA == 0x%08x\n", inta); 2310 - goto unplugged; 2311 - } 2312 - 2313 - IWL_DEBUG_ISR(priv, "ISR inta 0x%08x, enabled 0x%08x, fh 0x%08x\n", 2314 - inta, inta_mask, inta_fh); 2315 - 2316 - inta &= ~CSR_INT_BIT_SCD; 2317 - 2318 - /* iwl3945_irq_tasklet() will service interrupts and re-enable them */ 2319 - if (likely(inta || inta_fh)) 2320 - tasklet_schedule(&priv->irq_tasklet); 2321 - unplugged: 2322 - spin_unlock(&priv->lock); 2323 - 2324 - return IRQ_HANDLED; 2325 - 2326 - none: 2327 - /* re-enable interrupts here since we don't have anything to service. */ 2328 - /* only Re-enable if disabled by irq */ 2329 - if (test_bit(STATUS_INT_ENABLED, &priv->status)) 2330 - iwl3945_enable_interrupts(priv); 2331 - spin_unlock(&priv->lock); 2332 - return IRQ_NONE; 2333 2562 } 2334 2563 2335 2564 static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, ··· 3044 3387 3045 3388 /* tell the device to stop sending interrupts */ 3046 3389 spin_lock_irqsave(&priv->lock, flags); 3047 - iwl3945_disable_interrupts(priv); 3390 + iwl_disable_interrupts(priv); 3048 3391 spin_unlock_irqrestore(&priv->lock, flags); 3049 3392 iwl_synchronize_irq(priv); 3050 3393 ··· 3174 3517 3175 3518 /* clear (again), then enable host interrupts */ 3176 3519 iwl_write32(priv, CSR_INT, 0xFFFFFFFF); 3177 - iwl3945_enable_interrupts(priv); 3520 + iwl_enable_interrupts(priv); 3178 3521 3179 3522 /* really make sure rfkill handshake bits are cleared */ 3180 3523 iwl_write32(priv, CSR_UCODE_DRV_GP1_CLR, CSR_UCODE_SW_BIT_RFKILL); ··· 3829 4172 } 3830 4173 #endif 3831 4174 3832 - iwl3945_radio_kill_sw(priv, !conf->radio_enabled); 4175 + if (conf->radio_enabled && iwl_radio_kill_sw_enable_radio(priv)) { 4176 + IWL_DEBUG_MAC80211(priv, "leave - RF-KILL - waiting for uCode\n"); 4177 + goto out; 4178 + } 3833 4179 3834 4180 if (!conf->radio_enabled) { 4181 + iwl_radio_kill_sw_disable_radio(priv); 3835 4182 IWL_DEBUG_MAC80211(priv, "leave - radio disabled\n"); 3836 4183 goto out; 3837 4184 } ··· 4101 4440 iwl3945_send_rxon_assoc(priv); 4102 4441 } 4103 4442 4104 - } 4105 - 4106 - static int iwl3945_mac_hw_scan(struct ieee80211_hw *hw, 4107 - struct cfg80211_scan_request *req) 4108 - { 4109 - int rc = 0; 4110 - unsigned long flags; 4111 - struct iwl_priv *priv = hw->priv; 4112 - size_t len = 0; 4113 - u8 *ssid = NULL; 4114 - DECLARE_SSID_BUF(ssid_buf); 4115 - 4116 - IWL_DEBUG_MAC80211(priv, "enter\n"); 4117 - 4118 - if (req->n_ssids) { 4119 - ssid = req->ssids[0].ssid; 4120 - len = req->ssids[0].ssid_len; 4121 - } 4122 - 4123 - mutex_lock(&priv->mutex); 4124 - spin_lock_irqsave(&priv->lock, flags); 4125 - 4126 - if (!iwl_is_ready_rf(priv)) { 4127 - rc = -EIO; 4128 - IWL_DEBUG_MAC80211(priv, "leave - not ready or exit pending\n"); 4129 - goto out_unlock; 4130 - } 4131 - 4132 - /* we don't schedule scan within next_scan_jiffies period */ 4133 - if (priv->next_scan_jiffies && 4134 - time_after(priv->next_scan_jiffies, jiffies)) { 4135 - rc = -EAGAIN; 4136 - goto out_unlock; 4137 - } 4138 - /* if we just finished scan ask for delay for a broadcast scan */ 4139 - if ((len == 0) && priv->last_scan_jiffies && 4140 - time_after(priv->last_scan_jiffies + IWL_DELAY_NEXT_SCAN, 4141 - jiffies)) { 4142 - rc = -EAGAIN; 4143 - goto out_unlock; 4144 - } 4145 - if (len) { 4146 - IWL_DEBUG_SCAN(priv, "direct scan for %s [%zd]\n ", 4147 - print_ssid(ssid_buf, ssid, len), len); 4148 - 4149 - priv->one_direct_scan = 1; 4150 - priv->direct_ssid_len = len; 4151 - memcpy(priv->direct_ssid, ssid, len); 4152 - } else 4153 - priv->one_direct_scan = 0; 4154 - 4155 - rc = iwl3945_scan_initiate(priv); 4156 - 4157 - IWL_DEBUG_MAC80211(priv, "leave\n"); 4158 - 4159 - out_unlock: 4160 - spin_unlock_irqrestore(&priv->lock, flags); 4161 - mutex_unlock(&priv->mutex); 4162 - 4163 - return rc; 4164 4443 } 4165 4444 4166 4445 static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, ··· 4802 5201 4803 5202 static void iwl3945_setup_deferred_work(struct iwl_priv *priv) 4804 5203 { 4805 - priv->workqueue = create_workqueue(DRV_NAME); 5204 + priv->workqueue = create_singlethread_workqueue(DRV_NAME); 4806 5205 4807 5206 init_waitqueue_head(&priv->wait_command_queue); 4808 5207 ··· 4876 5275 .conf_tx = iwl3945_mac_conf_tx, 4877 5276 .reset_tsf = iwl3945_mac_reset_tsf, 4878 5277 .bss_info_changed = iwl3945_bss_info_changed, 4879 - .hw_scan = iwl3945_mac_hw_scan 5278 + .hw_scan = iwl_mac_hw_scan 4880 5279 }; 4881 5280 4882 5281 static int iwl3945_init_drv(struct iwl_priv *priv) ··· 5127 5526 * ********************/ 5128 5527 5129 5528 spin_lock_irqsave(&priv->lock, flags); 5130 - iwl3945_disable_interrupts(priv); 5529 + iwl_disable_interrupts(priv); 5131 5530 spin_unlock_irqrestore(&priv->lock, flags); 5132 5531 5133 5532 pci_enable_msi(priv->pci_dev); 5134 5533 5135 - err = request_irq(priv->pci_dev->irq, iwl3945_isr, IRQF_SHARED, 5534 + err = request_irq(priv->pci_dev->irq, iwl_isr, IRQF_SHARED, 5136 5535 DRV_NAME, priv); 5137 5536 if (err) { 5138 5537 IWL_ERR(priv, "Error allocating IRQ %d\n", priv->pci_dev->irq); ··· 5222 5621 * tasklet for the driver 5223 5622 */ 5224 5623 spin_lock_irqsave(&priv->lock, flags); 5225 - iwl3945_disable_interrupts(priv); 5624 + iwl_disable_interrupts(priv); 5226 5625 spin_unlock_irqrestore(&priv->lock, flags); 5227 5626 5228 5627 iwl_synchronize_irq(priv);
+1
drivers/net/wireless/libertas/defs.h
··· 265 265 266 266 #define CMD_F_HOSTCMD (1 << 0) 267 267 #define FW_CAPINFO_WPA (1 << 0) 268 + #define FW_CAPINFO_PS (1 << 1) 268 269 #define FW_CAPINFO_FIRMWARE_UPGRADE (1 << 13) 269 270 #define FW_CAPINFO_BOOT2_UPGRADE (1<<14) 270 271 #define FW_CAPINFO_PERSISTENT_CONFIG (1<<15)
+15 -5
drivers/net/wireless/libertas/if_sdio.c
··· 95 95 96 96 spinlock_t lock; 97 97 struct if_sdio_packet *packets; 98 + 99 + struct workqueue_struct *workqueue; 98 100 struct work_struct packet_worker; 99 101 }; 100 102 ··· 211 209 event = sdio_readb(card->func, IF_SDIO_EVENT, &ret); 212 210 if (ret) 213 211 goto out; 212 + 213 + /* right shift 3 bits to get the event id */ 214 + event >>= 3; 214 215 } else { 215 216 if (size < 4) { 216 217 lbs_deb_sdio("event packet too small (%d bytes)\n", ··· 748 743 749 744 spin_unlock_irqrestore(&card->lock, flags); 750 745 751 - schedule_work(&card->packet_worker); 746 + queue_work(card->workqueue, &card->packet_worker); 752 747 753 748 ret = 0; 754 749 ··· 838 833 card->func = func; 839 834 card->model = model; 840 835 spin_lock_init(&card->lock); 836 + card->workqueue = create_workqueue("libertas_sdio"); 841 837 INIT_WORK(&card->packet_worker, if_sdio_host_to_card_worker); 842 838 843 839 for (i = 0;i < ARRAY_SIZE(if_sdio_models);i++) { ··· 927 921 if (ret) 928 922 goto err_activate_card; 929 923 924 + if (priv->fwcapinfo & FW_CAPINFO_PS) 925 + priv->ps_supported = 1; 926 + 930 927 out: 931 928 lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret); 932 929 933 930 return ret; 934 931 935 932 err_activate_card: 936 - flush_scheduled_work(); 937 - free_netdev(priv->dev); 938 - kfree(priv); 933 + flush_workqueue(card->workqueue); 934 + lbs_remove_card(priv); 939 935 reclaim: 940 936 sdio_claim_host(func); 941 937 release_int: ··· 947 939 release: 948 940 sdio_release_host(func); 949 941 free: 942 + destroy_workqueue(card->workqueue); 950 943 while (card->packets) { 951 944 packet = card->packets; 952 945 card->packets = card->packets->next; ··· 974 965 lbs_stop_card(card->priv); 975 966 lbs_remove_card(card->priv); 976 967 977 - flush_scheduled_work(); 968 + flush_workqueue(card->workqueue); 969 + destroy_workqueue(card->workqueue); 978 970 979 971 sdio_claim_host(func); 980 972 sdio_release_irq(func);
+44 -5
drivers/net/wireless/orinoco/fw.c
··· 43 43 char signature[0]; /* FW signature length headersize-20 */ 44 44 } __attribute__ ((packed)); 45 45 46 + /* Check the range of various header entries. Return a pointer to a 47 + * description of the problem, or NULL if everything checks out. */ 48 + static const char *validate_fw(const struct orinoco_fw_header *hdr, size_t len) 49 + { 50 + u16 hdrsize; 51 + 52 + if (len < sizeof(*hdr)) 53 + return "image too small"; 54 + if (memcmp(hdr->hdr_vers, "HFW", 3) != 0) 55 + return "format not recognised"; 56 + 57 + hdrsize = le16_to_cpu(hdr->headersize); 58 + if (hdrsize > len) 59 + return "bad headersize"; 60 + if ((hdrsize + le32_to_cpu(hdr->block_offset)) > len) 61 + return "bad block offset"; 62 + if ((hdrsize + le32_to_cpu(hdr->pdr_offset)) > len) 63 + return "bad PDR offset"; 64 + if ((hdrsize + le32_to_cpu(hdr->pri_offset)) > len) 65 + return "bad PRI offset"; 66 + if ((hdrsize + le32_to_cpu(hdr->compat_offset)) > len) 67 + return "bad compat offset"; 68 + 69 + /* TODO: consider adding a checksum or CRC to the firmware format */ 70 + return NULL; 71 + } 72 + 46 73 /* Download either STA or AP firmware into the card. */ 47 74 static int 48 75 orinoco_dl_firmware(struct orinoco_private *priv, ··· 83 56 const struct firmware *fw_entry; 84 57 const struct orinoco_fw_header *hdr; 85 58 const unsigned char *first_block; 86 - const unsigned char *end; 59 + const void *end; 87 60 const char *firmware; 61 + const char *fw_err; 88 62 struct net_device *dev = priv->ndev; 89 63 int err = 0; 90 64 ··· 121 93 122 94 hdr = (const struct orinoco_fw_header *) fw_entry->data; 123 95 96 + fw_err = validate_fw(hdr, fw_entry->size); 97 + if (fw_err) { 98 + printk(KERN_WARNING "%s: Invalid firmware image detected (%s). " 99 + "Aborting download\n", 100 + dev->name, fw_err); 101 + err = -EINVAL; 102 + goto abort; 103 + } 104 + 124 105 /* Enable aux port to allow programming */ 125 106 err = hermesi_program_init(hw, le32_to_cpu(hdr->entry_point)); 126 107 printk(KERN_DEBUG "%s: Program init returned %d\n", dev->name, err); ··· 152 115 le16_to_cpu(hdr->headersize) + 153 116 le32_to_cpu(hdr->pdr_offset)); 154 117 155 - err = hermes_apply_pda_with_defaults(hw, first_block, pda); 118 + err = hermes_apply_pda_with_defaults(hw, first_block, end, pda, 119 + &pda[fw->pda_size / sizeof(*pda)]); 156 120 printk(KERN_DEBUG "%s: Apply PDA returned %d\n", dev->name, err); 157 121 if (err) 158 122 goto abort; ··· 185 147 */ 186 148 static int 187 149 symbol_dl_image(struct orinoco_private *priv, const struct fw_info *fw, 188 - const unsigned char *image, const unsigned char *end, 150 + const unsigned char *image, const void *end, 189 151 int secondary) 190 152 { 191 153 hermes_t *hw = &priv->hw; ··· 226 188 227 189 /* Write the PDA to the adapter */ 228 190 if (secondary) { 229 - size_t len = hermes_blocks_length(first_block); 191 + size_t len = hermes_blocks_length(first_block, end); 230 192 ptr = first_block + len; 231 - ret = hermes_apply_pda(hw, ptr, pda); 193 + ret = hermes_apply_pda(hw, ptr, end, pda, 194 + &pda[fw->pda_size / sizeof(*pda)]); 232 195 kfree(pda); 233 196 if (ret) 234 197 return ret;
+52 -47
drivers/net/wireless/orinoco/hermes_dld.c
··· 71 71 #define BLOCK_END 0xFFFFFFFF /* Last image block */ 72 72 #define TEXT_END 0x1A /* End of text header */ 73 73 74 - /* 75 - * PDA == Production Data Area 76 - * 77 - * In principle, the max. size of the PDA is is 4096 words. Currently, 78 - * however, only about 500 bytes of this area are used. 79 - * 80 - * Some USB implementations can't handle sizes in excess of 1016. Note 81 - * that PDA is not actually used in those USB environments, but may be 82 - * retrieved by common code. 83 - */ 84 - #define MAX_PDA_SIZE 1000 85 - 86 74 /* Limit the amout we try to download in a single shot. 87 75 * Size is in bytes. 88 76 */ ··· 206 218 * Scan PDR for the record with the specified RECORD_ID. 207 219 * If it's not found, return NULL. 208 220 */ 209 - static struct pdr * 210 - hermes_find_pdr(struct pdr *first_pdr, u32 record_id) 221 + static const struct pdr * 222 + hermes_find_pdr(const struct pdr *first_pdr, u32 record_id, const void *end) 211 223 { 212 - struct pdr *pdr = first_pdr; 213 - void *end = (void *)first_pdr + MAX_PDA_SIZE; 224 + const struct pdr *pdr = first_pdr; 214 225 215 - while (((void *)pdr < end) && 226 + end -= sizeof(struct pdr); 227 + 228 + while (((void *) pdr <= end) && 216 229 (pdr_id(pdr) != PDI_END)) { 217 230 /* 218 231 * PDR area is currently not terminated by PDI_END. ··· 233 244 } 234 245 235 246 /* Scan production data items for a particular entry */ 236 - static struct pdi * 237 - hermes_find_pdi(struct pdi *first_pdi, u32 record_id) 247 + static const struct pdi * 248 + hermes_find_pdi(const struct pdi *first_pdi, u32 record_id, const void *end) 238 249 { 239 - struct pdi *pdi = first_pdi; 250 + const struct pdi *pdi = first_pdi; 240 251 241 - while (pdi_id(pdi) != PDI_END) { 252 + end -= sizeof(struct pdi); 253 + 254 + while (((void *) pdi <= end) && 255 + (pdi_id(pdi) != PDI_END)) { 242 256 243 257 /* If the record ID matches, we are done */ 244 258 if (pdi_id(pdi) == record_id) ··· 254 262 255 263 /* Process one Plug Data Item - find corresponding PDR and plug it */ 256 264 static int 257 - hermes_plug_pdi(hermes_t *hw, struct pdr *first_pdr, const struct pdi *pdi) 265 + hermes_plug_pdi(hermes_t *hw, const struct pdr *first_pdr, 266 + const struct pdi *pdi, const void *pdr_end) 258 267 { 259 - struct pdr *pdr; 268 + const struct pdr *pdr; 260 269 261 270 /* Find the PDR corresponding to this PDI */ 262 - pdr = hermes_find_pdr(first_pdr, pdi_id(pdi)); 271 + pdr = hermes_find_pdr(first_pdr, pdi_id(pdi), pdr_end); 263 272 264 273 /* No match is found, safe to ignore */ 265 274 if (!pdr) ··· 338 345 */ 339 346 int hermes_apply_pda(hermes_t *hw, 340 347 const char *first_pdr, 341 - const __le16 *pda) 348 + const void *pdr_end, 349 + const __le16 *pda, 350 + const void *pda_end) 342 351 { 343 352 int ret; 344 353 const struct pdi *pdi; 345 - struct pdr *pdr; 354 + const struct pdr *pdr; 346 355 347 - pdr = (struct pdr *) first_pdr; 356 + pdr = (const struct pdr *) first_pdr; 357 + pda_end -= sizeof(struct pdi); 348 358 349 359 /* Go through every PDI and plug them into the adapter */ 350 360 pdi = (const struct pdi *) (pda + 2); 351 - while (pdi_id(pdi) != PDI_END) { 352 - ret = hermes_plug_pdi(hw, pdr, pdi); 361 + while (((void *) pdi <= pda_end) && 362 + (pdi_id(pdi) != PDI_END)) { 363 + ret = hermes_plug_pdi(hw, pdr, pdi, pdr_end); 353 364 if (ret) 354 365 return ret; 355 366 ··· 367 370 * including the header data. 368 371 */ 369 372 size_t 370 - hermes_blocks_length(const char *first_block) 373 + hermes_blocks_length(const char *first_block, const void *end) 371 374 { 372 375 const struct dblock *blk = (const struct dblock *) first_block; 373 376 int total_len = 0; 374 377 int len; 375 378 379 + end -= sizeof(*blk); 380 + 376 381 /* Skip all blocks to locate Plug Data References 377 382 * (Spectrum CS) */ 378 - while (dblock_addr(blk) != BLOCK_END) { 383 + while (((void *) blk <= end) && 384 + (dblock_addr(blk) != BLOCK_END)) { 379 385 len = dblock_len(blk); 380 386 total_len += sizeof(*blk) + len; 381 387 blk = (struct dblock *) &blk->data[len]; ··· 476 476 } 477 477 478 478 /* Program the data blocks */ 479 - int hermes_program(hermes_t *hw, const char *first_block, const char *end) 479 + int hermes_program(hermes_t *hw, const char *first_block, const void *end) 480 480 { 481 481 const struct dblock *blk; 482 482 u32 blkaddr; ··· 488 488 489 489 blk = (const struct dblock *) first_block; 490 490 491 - if ((const char *) blk > (end - sizeof(*blk))) 491 + if ((void *) blk > (end - sizeof(*blk))) 492 492 return -EIO; 493 493 494 494 blkaddr = dblock_addr(blk); 495 495 blklen = dblock_len(blk); 496 496 497 497 while ((blkaddr != BLOCK_END) && 498 - (((const char *) blk + blklen) <= end)) { 498 + (((void *) blk + blklen) <= end)) { 499 499 printk(KERN_DEBUG PFX 500 500 "Programming block of length %d to address 0x%08x\n", 501 501 blklen, blkaddr); ··· 527 527 #endif 528 528 blk = (const struct dblock *) &blk->data[blklen]; 529 529 530 - if ((const char *) blk > (end - sizeof(*blk))) 530 + if ((void *) blk > (end - sizeof(*blk))) 531 531 return -EIO; 532 532 533 533 blkaddr = dblock_addr(blk); ··· 545 545 __le16 id; \ 546 546 u8 val[length]; \ 547 547 } __attribute__ ((packed)) default_pdr_data_##pid = { \ 548 - cpu_to_le16((sizeof(default_pdr_data_##pid)/ \ 548 + cpu_to_le16((sizeof(default_pdr_data_##pid)/ \ 549 549 sizeof(__le16)) - 1), \ 550 - cpu_to_le16(pid), \ 550 + cpu_to_le16(pid), \ 551 551 data \ 552 552 } 553 553 ··· 616 616 */ 617 617 int hermes_apply_pda_with_defaults(hermes_t *hw, 618 618 const char *first_pdr, 619 - const __le16 *pda) 619 + const void *pdr_end, 620 + const __le16 *pda, 621 + const void *pda_end) 620 622 { 621 623 const struct pdr *pdr = (const struct pdr *) first_pdr; 622 - struct pdi *first_pdi = (struct pdi *) &pda[2]; 623 - struct pdi *pdi; 624 - struct pdi *default_pdi = NULL; 625 - struct pdi *outdoor_pdi; 626 - void *end = (void *)first_pdr + MAX_PDA_SIZE; 624 + const struct pdi *first_pdi = (const struct pdi *) &pda[2]; 625 + const struct pdi *pdi; 626 + const struct pdi *default_pdi = NULL; 627 + const struct pdi *outdoor_pdi; 627 628 int record_id; 628 629 629 - while (((void *)pdr < end) && 630 + pdr_end -= sizeof(struct pdr); 631 + 632 + while (((void *) pdr <= pdr_end) && 630 633 (pdr_id(pdr) != PDI_END)) { 631 634 /* 632 635 * For spectrum_cs firmwares, ··· 641 638 break; 642 639 record_id = pdr_id(pdr); 643 640 644 - pdi = hermes_find_pdi(first_pdi, record_id); 641 + pdi = hermes_find_pdi(first_pdi, record_id, pda_end); 645 642 if (pdi) 646 643 printk(KERN_DEBUG PFX "Found record 0x%04x at %p\n", 647 644 record_id, pdi); ··· 649 646 switch (record_id) { 650 647 case 0x110: /* Modem REFDAC values */ 651 648 case 0x120: /* Modem VGDAC values */ 652 - outdoor_pdi = hermes_find_pdi(first_pdi, record_id + 1); 649 + outdoor_pdi = hermes_find_pdi(first_pdi, record_id + 1, 650 + pda_end); 653 651 default_pdi = NULL; 654 652 if (outdoor_pdi) { 655 653 pdi = outdoor_pdi; ··· 691 687 692 688 if (pdi) { 693 689 /* Lengths of the data in PDI and PDR must match */ 694 - if (pdi_len(pdi) == pdr_len(pdr)) { 690 + if ((pdi_len(pdi) == pdr_len(pdr)) && 691 + ((void *) pdi->data + pdi_len(pdi) < pda_end)) { 695 692 /* do the actual plugging */ 696 693 hermes_aux_setaddr(hw, pdr_addr(pdr)); 697 694 hermes_write_bytes(hw, HERMES_AUXDATA,
+8 -4
drivers/net/wireless/orinoco/hermes_dld.h
··· 29 29 30 30 int hermesi_program_init(hermes_t *hw, u32 offset); 31 31 int hermesi_program_end(hermes_t *hw); 32 - int hermes_program(hermes_t *hw, const char *first_block, const char *end); 32 + int hermes_program(hermes_t *hw, const char *first_block, const void *end); 33 33 34 34 int hermes_read_pda(hermes_t *hw, 35 35 __le16 *pda, ··· 38 38 int use_eeprom); 39 39 int hermes_apply_pda(hermes_t *hw, 40 40 const char *first_pdr, 41 - const __le16 *pda); 41 + const void *pdr_end, 42 + const __le16 *pda, 43 + const void *pda_end); 42 44 int hermes_apply_pda_with_defaults(hermes_t *hw, 43 45 const char *first_pdr, 44 - const __le16 *pda); 46 + const void *pdr_end, 47 + const __le16 *pda, 48 + const void *pda_end); 45 49 46 - size_t hermes_blocks_length(const char *first_block); 50 + size_t hermes_blocks_length(const char *first_block, const void *end); 47 51 48 52 #endif /* _HERMES_DLD_H */
+2 -2
drivers/net/wireless/p54/p54common.c
··· 2212 2212 2213 2213 *total_flags &= FIF_PROMISC_IN_BSS | 2214 2214 FIF_OTHER_BSS | 2215 - (*total_flags & FIF_PROMISC_IN_BSS) ? 2216 - FIF_FCSFAIL : 0; 2215 + (*total_flags & FIF_PROMISC_IN_BSS ? 2216 + FIF_FCSFAIL : 0); 2217 2217 2218 2218 priv->filter_flags = *total_flags; 2219 2219
-3
drivers/net/wireless/rt2x00/rt2400pci.c
··· 114 114 { 115 115 u32 reg; 116 116 117 - if (!word) 118 - return; 119 - 120 117 mutex_lock(&rt2x00dev->csr_mutex); 121 118 122 119 /*
+2 -2
drivers/net/wireless/rt2x00/rt2400pci.h
··· 48 48 #define EEPROM_SIZE 0x0100 49 49 #define BBP_BASE 0x0000 50 50 #define BBP_SIZE 0x0020 51 - #define RF_BASE 0x0000 52 - #define RF_SIZE 0x0010 51 + #define RF_BASE 0x0004 52 + #define RF_SIZE 0x000c 53 53 54 54 /* 55 55 * Number of TX queues.
-3
drivers/net/wireless/rt2x00/rt2500pci.c
··· 114 114 { 115 115 u32 reg; 116 116 117 - if (!word) 118 - return; 119 - 120 117 mutex_lock(&rt2x00dev->csr_mutex); 121 118 122 119 /*
+2 -2
drivers/net/wireless/rt2x00/rt2500pci.h
··· 59 59 #define EEPROM_SIZE 0x0200 60 60 #define BBP_BASE 0x0000 61 61 #define BBP_SIZE 0x0040 62 - #define RF_BASE 0x0000 63 - #define RF_SIZE 0x0014 62 + #define RF_BASE 0x0004 63 + #define RF_SIZE 0x0010 64 64 65 65 /* 66 66 * Number of TX queues.
-3
drivers/net/wireless/rt2x00/rt2500usb.c
··· 204 204 { 205 205 u16 reg; 206 206 207 - if (!word) 208 - return; 209 - 210 207 mutex_lock(&rt2x00dev->csr_mutex); 211 208 212 209 /*
+2 -2
drivers/net/wireless/rt2x00/rt2500usb.h
··· 59 59 #define EEPROM_SIZE 0x006a 60 60 #define BBP_BASE 0x0000 61 61 #define BBP_SIZE 0x0060 62 - #define RF_BASE 0x0000 63 - #define RF_SIZE 0x0014 62 + #define RF_BASE 0x0004 63 + #define RF_SIZE 0x0010 64 64 65 65 /* 66 66 * Number of TX queues.
+6 -4
drivers/net/wireless/rt2x00/rt2x00debug.c
··· 435 435 if (index >= debug->__name.word_count) \ 436 436 return -EINVAL; \ 437 437 \ 438 + index += (debug->__name.word_base / \ 439 + debug->__name.word_size); \ 440 + \ 438 441 if (debug->__name.flags & RT2X00DEBUGFS_OFFSET) \ 439 442 index *= debug->__name.word_size; \ 440 - \ 441 - index += debug->__name.word_base; \ 442 443 \ 443 444 debug->__name.read(intf->rt2x00dev, index, &value); \ 444 445 \ ··· 477 476 size = strlen(line); \ 478 477 value = simple_strtoul(line, NULL, 0); \ 479 478 \ 479 + index += (debug->__name.word_base / \ 480 + debug->__name.word_size); \ 481 + \ 480 482 if (debug->__name.flags & RT2X00DEBUGFS_OFFSET) \ 481 483 index *= debug->__name.word_size; \ 482 - \ 483 - index += debug->__name.word_base; \ 484 484 \ 485 485 debug->__name.write(intf->rt2x00dev, index, value); \ 486 486 \
-3
drivers/net/wireless/rt2x00/rt61pci.c
··· 123 123 { 124 124 u32 reg; 125 125 126 - if (!word) 127 - return; 128 - 129 126 mutex_lock(&rt2x00dev->csr_mutex); 130 127 131 128 /*
+2 -2
drivers/net/wireless/rt2x00/rt61pci.h
··· 50 50 #define EEPROM_SIZE 0x0100 51 51 #define BBP_BASE 0x0000 52 52 #define BBP_SIZE 0x0080 53 - #define RF_BASE 0x0000 54 - #define RF_SIZE 0x0014 53 + #define RF_BASE 0x0004 54 + #define RF_SIZE 0x0010 55 55 56 56 /* 57 57 * Number of TX queues.
+6 -13
drivers/net/wireless/rt2x00/rt73usb.c
··· 122 122 { 123 123 u32 reg; 124 124 125 - if (!word) 126 - return; 127 - 128 125 mutex_lock(&rt2x00dev->csr_mutex); 129 126 130 127 /* ··· 2238 2241 return 0; 2239 2242 } 2240 2243 2241 - #if 0 2242 - /* 2243 - * Mac80211 demands get_tsf must be atomic. 2244 - * This is not possible for rt73usb since all register access 2245 - * functions require sleeping. Untill mac80211 no longer needs 2246 - * get_tsf to be atomic, this function should be disabled. 2247 - */ 2248 2244 static u64 rt73usb_get_tsf(struct ieee80211_hw *hw) 2249 2245 { 2250 2246 struct rt2x00_dev *rt2x00dev = hw->priv; ··· 2251 2261 2252 2262 return tsf; 2253 2263 } 2254 - #else 2255 - #define rt73usb_get_tsf NULL 2256 - #endif 2257 2264 2258 2265 static const struct ieee80211_ops rt73usb_mac80211_ops = { 2259 2266 .tx = rt2x00mac_tx, ··· 2342 2355 static struct usb_device_id rt73usb_device_table[] = { 2343 2356 /* AboCom */ 2344 2357 { USB_DEVICE(0x07b8, 0xb21d), USB_DEVICE_DATA(&rt73usb_ops) }, 2358 + /* Amigo */ 2359 + { USB_DEVICE(0x148f, 0x9021), USB_DEVICE_DATA(&rt73usb_ops) }, 2360 + { USB_DEVICE(0x0eb0, 0x9021), USB_DEVICE_DATA(&rt73usb_ops) }, 2345 2361 /* Askey */ 2346 2362 { USB_DEVICE(0x1690, 0x0722), USB_DEVICE_DATA(&rt73usb_ops) }, 2347 2363 /* ASUS */ ··· 2392 2402 { USB_DEVICE(0x0db0, 0xa861), USB_DEVICE_DATA(&rt73usb_ops) }, 2393 2403 { USB_DEVICE(0x0db0, 0xa874), USB_DEVICE_DATA(&rt73usb_ops) }, 2394 2404 /* Ralink */ 2405 + { USB_DEVICE(0x04bb, 0x093d), USB_DEVICE_DATA(&rt73usb_ops) }, 2395 2406 { USB_DEVICE(0x148f, 0x2573), USB_DEVICE_DATA(&rt73usb_ops) }, 2396 2407 { USB_DEVICE(0x148f, 0x2671), USB_DEVICE_DATA(&rt73usb_ops) }, 2397 2408 /* Qcom */ ··· 2409 2418 /* Planex */ 2410 2419 { USB_DEVICE(0x2019, 0xab01), USB_DEVICE_DATA(&rt73usb_ops) }, 2411 2420 { USB_DEVICE(0x2019, 0xab50), USB_DEVICE_DATA(&rt73usb_ops) }, 2421 + /* ZyXEL */ 2422 + { USB_DEVICE(0x0586, 0x3415), USB_DEVICE_DATA(&rt73usb_ops) }, 2412 2423 { 0, } 2413 2424 }; 2414 2425
+2 -2
drivers/net/wireless/rt2x00/rt73usb.h
··· 50 50 #define EEPROM_SIZE 0x0100 51 51 #define BBP_BASE 0x0000 52 52 #define BBP_SIZE 0x0080 53 - #define RF_BASE 0x0000 54 - #define RF_SIZE 0x0014 53 + #define RF_BASE 0x0004 54 + #define RF_SIZE 0x0010 55 55 56 56 /* 57 57 * Number of TX queues.
+1 -2
drivers/net/wireless/wavelan.c
··· 4281 4281 4282 4282 4283 4283 /* Loop on all possible base addresses. */ 4284 - i = -1; 4285 - while ((io[++i] != 0) && (i < ARRAY_SIZE(io))) { 4284 + for (i = 0; i < ARRAY_SIZE(io) && io[i] != 0; i++) { 4286 4285 struct net_device *dev = alloc_etherdev(sizeof(net_local)); 4287 4286 if (!dev) 4288 4287 break;
+3 -3
drivers/net/wireless/zd1211rw/zd_mac.c
··· 170 170 goto disable_int; 171 171 172 172 r = zd_reg2alpha2(mac->regdomain, alpha2); 173 - if (!r) 174 - regulatory_hint(hw->wiphy, alpha2); 173 + if (r) 174 + goto disable_int; 175 175 176 - r = 0; 176 + r = regulatory_hint(hw->wiphy, alpha2); 177 177 disable_int: 178 178 zd_chip_disable_int(chip); 179 179 out:
+5
include/linux/nl80211.h
··· 526 526 * @NL80211_STA_INFO_SIGNAL: signal strength of last received PPDU (u8, dBm) 527 527 * @NL80211_STA_INFO_TX_BITRATE: current unicast tx rate, nested attribute 528 528 * containing info as possible, see &enum nl80211_sta_info_txrate. 529 + * @NL80211_STA_INFO_RX_PACKETS: total received packet (u32, from this station) 530 + * @NL80211_STA_INFO_TX_PACKETS: total transmitted packets (u32, to this 531 + * station) 529 532 */ 530 533 enum nl80211_sta_info { 531 534 __NL80211_STA_INFO_INVALID, ··· 540 537 NL80211_STA_INFO_PLINK_STATE, 541 538 NL80211_STA_INFO_SIGNAL, 542 539 NL80211_STA_INFO_TX_BITRATE, 540 + NL80211_STA_INFO_RX_PACKETS, 541 + NL80211_STA_INFO_TX_PACKETS, 543 542 544 543 /* keep last */ 545 544 __NL80211_STA_INFO_AFTER_LAST,
+23 -8
include/net/cfg80211.h
··· 178 178 * @STATION_INFO_SIGNAL: @signal filled 179 179 * @STATION_INFO_TX_BITRATE: @tx_bitrate fields are filled 180 180 * (tx_bitrate, tx_bitrate_flags and tx_bitrate_mcs) 181 + * @STATION_INFO_RX_PACKETS: @rx_packets filled 182 + * @STATION_INFO_TX_PACKETS: @tx_packets filled 181 183 */ 182 184 enum station_info_flags { 183 185 STATION_INFO_INACTIVE_TIME = 1<<0, ··· 190 188 STATION_INFO_PLINK_STATE = 1<<5, 191 189 STATION_INFO_SIGNAL = 1<<6, 192 190 STATION_INFO_TX_BITRATE = 1<<7, 191 + STATION_INFO_RX_PACKETS = 1<<8, 192 + STATION_INFO_TX_PACKETS = 1<<9, 193 193 }; 194 194 195 195 /** ··· 239 235 * @plink_state: mesh peer link state 240 236 * @signal: signal strength of last received packet in dBm 241 237 * @txrate: current unicast bitrate to this station 238 + * @rx_packets: packets received from this station 239 + * @tx_packets: packets transmitted to this station 242 240 */ 243 241 struct station_info { 244 242 u32 filled; ··· 252 246 u8 plink_state; 253 247 s8 signal; 254 248 struct rate_info txrate; 249 + u32 rx_packets; 250 + u32 tx_packets; 255 251 }; 256 252 257 253 /** ··· 383 375 }; 384 376 385 377 /** 386 - * struct regulatory_request - receipt of last regulatory request 378 + * struct regulatory_request - used to keep track of regulatory requests 387 379 * 388 - * @wiphy: this is set if this request's initiator is 380 + * @wiphy_idx: this is set if this request's initiator is 389 381 * %REGDOM_SET_BY_COUNTRY_IE or %REGDOM_SET_BY_DRIVER. This 390 382 * can be used by the wireless core to deal with conflicts 391 383 * and potentially inform users of which devices specifically ··· 404 396 * country IE 405 397 * @country_ie_env: lets us know if the AP is telling us we are outdoor, 406 398 * indoor, or if it doesn't matter 399 + * @list: used to insert into the reg_requests_list linked list 407 400 */ 408 401 struct regulatory_request { 409 - struct wiphy *wiphy; 402 + int wiphy_idx; 410 403 enum reg_set_by initiator; 411 404 char alpha2[2]; 412 405 bool intersect; 413 406 u32 country_ie_checksum; 414 407 enum environment_cap country_ie_env; 408 + struct list_head list; 415 409 }; 416 410 417 411 struct ieee80211_freq_range { ··· 535 525 * @n_ssids: number of SSIDs 536 526 * @channels: channels to scan on. 537 527 * @n_channels: number of channels for each band 528 + * @ie: optional information element(s) to add into Probe Request or %NULL 529 + * @ie_len: length of ie in octets 538 530 * @wiphy: the wiphy this was for 539 531 * @ifidx: the interface index 540 532 */ ··· 545 533 int n_ssids; 546 534 struct ieee80211_channel **channels; 547 535 u32 n_channels; 536 + u8 *ie; 537 + size_t ie_len; 548 538 549 539 /* internal */ 550 540 struct wiphy *wiphy; ··· 579 565 * @information_elements: the information elements (Note that there 580 566 * is no guarantee that these are well-formed!) 581 567 * @len_information_elements: total length of the information elements 582 - * @signal: signal strength value 583 - * @signal_type: signal type 568 + * @signal: signal strength value (type depends on the wiphy's signal_type) 584 569 * @free_priv: function pointer to free private data 585 570 * @priv: private area for driver use, has at least wiphy->bss_priv_size bytes 586 571 */ ··· 594 581 size_t len_information_elements; 595 582 596 583 s32 signal; 597 - enum cfg80211_signal_type signal_type; 598 584 599 585 void (*free_priv)(struct cfg80211_bss *bss); 600 586 u8 priv[0] __attribute__((__aligned__(sizeof(void *)))); ··· 767 755 int cfg80211_wext_giwscan(struct net_device *dev, 768 756 struct iw_request_info *info, 769 757 struct iw_point *data, char *extra); 758 + int cfg80211_wext_giwrange(struct net_device *dev, 759 + struct iw_request_info *info, 760 + struct iw_point *data, char *extra); 770 761 771 762 /** 772 763 * cfg80211_scan_done - notify that scan finished ··· 785 770 * 786 771 * @wiphy: the wiphy reporting the BSS 787 772 * @bss: the found BSS 773 + * @signal: the signal strength, type depends on the wiphy's signal_type 788 774 * @gfp: context flags 789 775 * 790 776 * This informs cfg80211 that BSS information was found and ··· 795 779 cfg80211_inform_bss_frame(struct wiphy *wiphy, 796 780 struct ieee80211_channel *channel, 797 781 struct ieee80211_mgmt *mgmt, size_t len, 798 - s32 signal, enum cfg80211_signal_type sigtype, 799 - gfp_t gfp); 782 + s32 signal, gfp_t gfp); 800 783 801 784 struct cfg80211_bss *cfg80211_get_bss(struct wiphy *wiphy, 802 785 struct ieee80211_channel *channel,
+3
include/net/ieee80211.h drivers/net/wireless/ipw2x00/ieee80211.h
··· 1119 1119 extern void free_ieee80211(struct net_device *dev); 1120 1120 extern struct net_device *alloc_ieee80211(int sizeof_priv); 1121 1121 1122 + extern void ieee80211_networks_age(struct ieee80211_device *ieee, 1123 + unsigned long age_secs); 1124 + 1122 1125 extern int ieee80211_set_encryption(struct ieee80211_device *ieee); 1123 1126 1124 1127 /* ieee80211_tx.c */
+21 -5
include/net/mac80211.h
··· 1022 1022 return hw->queues; 1023 1023 } 1024 1024 1025 - static inline int ieee80211_num_queues(struct ieee80211_hw *hw) 1026 - { 1027 - return hw->queues + hw->ampdu_queues; 1028 - } 1029 - 1030 1025 static inline struct ieee80211_rate * 1031 1026 ieee80211_get_tx_rate(const struct ieee80211_hw *hw, 1032 1027 const struct ieee80211_tx_info *c) ··· 1324 1329 * because the hardware is turned off! Anything else is a bug! 1325 1330 * Returns a negative error code which will be seen in userspace. 1326 1331 * 1332 + * @sw_scan_start: Notifier function that is called just before a software scan 1333 + * is started. Can be NULL, if the driver doesn't need this notification. 1334 + * 1335 + * @sw_scan_complete: Notifier function that is called just after a software scan 1336 + * finished. Can be NULL, if the driver doesn't need this notification. 1337 + * 1327 1338 * @get_stats: Return low-level statistics. 1328 1339 * Returns zero if statistics are available. 1329 1340 * ··· 1409 1408 u32 iv32, u16 *phase1key); 1410 1409 int (*hw_scan)(struct ieee80211_hw *hw, 1411 1410 struct cfg80211_scan_request *req); 1411 + void (*sw_scan_start)(struct ieee80211_hw *hw); 1412 + void (*sw_scan_complete)(struct ieee80211_hw *hw); 1412 1413 int (*get_stats)(struct ieee80211_hw *hw, 1413 1414 struct ieee80211_low_level_stats *stats); 1414 1415 void (*get_tkip_seq)(struct ieee80211_hw *hw, u8 hw_key_idx, ··· 1983 1980 /* Rate control API */ 1984 1981 1985 1982 /** 1983 + * enum rate_control_changed - flags to indicate which parameter changed 1984 + * 1985 + * @IEEE80211_RC_HT_CHANGED: The HT parameters of the operating channel have 1986 + * changed, rate control algorithm can update its internal state if needed. 1987 + */ 1988 + enum rate_control_changed { 1989 + IEEE80211_RC_HT_CHANGED = BIT(0) 1990 + }; 1991 + 1992 + /** 1986 1993 * struct ieee80211_tx_rate_control - rate control information for/from RC algo 1987 1994 * 1988 1995 * @hw: The hardware the algorithm is invoked for. ··· 2028 2015 void *(*alloc_sta)(void *priv, struct ieee80211_sta *sta, gfp_t gfp); 2029 2016 void (*rate_init)(void *priv, struct ieee80211_supported_band *sband, 2030 2017 struct ieee80211_sta *sta, void *priv_sta); 2018 + void (*rate_update)(void *priv, struct ieee80211_supported_band *sband, 2019 + struct ieee80211_sta *sta, 2020 + void *priv_sta, u32 changed); 2031 2021 void (*free_sta)(void *priv, struct ieee80211_sta *sta, 2032 2022 void *priv_sta); 2033 2023
+15 -2
include/net/wireless.h
··· 69 69 * @band: band this channel belongs to. 70 70 * @max_antenna_gain: maximum antenna gain in dBi 71 71 * @max_power: maximum transmission power (in dBm) 72 + * @beacon_found: helper to regulatory code to indicate when a beacon 73 + * has been found on this channel. Use regulatory_hint_found_beacon() 74 + * to enable this, this is is useful only on 5 GHz band. 72 75 * @orig_mag: internal use 73 76 * @orig_mpwr: internal use 74 77 */ ··· 83 80 u32 flags; 84 81 int max_antenna_gain; 85 82 int max_power; 83 + bool beacon_found; 86 84 u32 orig_flags; 87 85 int orig_mag, orig_mpwr; 88 86 }; ··· 204 200 * the regulatory_hint() API. This can be used by the driver 205 201 * on the reg_notifier() if it chooses to ignore future 206 202 * regulatory domain changes caused by other drivers. 203 + * @signal_type: signal type reported in &struct cfg80211_bss. 207 204 */ 208 205 struct wiphy { 209 206 /* assign these fields before you register the wiphy */ ··· 217 212 218 213 bool custom_regulatory; 219 214 bool strict_regulatory; 215 + 216 + enum cfg80211_signal_type signal_type; 220 217 221 218 int bss_priv_size; 222 219 u8 max_scan_ssids; ··· 405 398 * domain should be in or by providing a completely build regulatory domain. 406 399 * If the driver provides an ISO/IEC 3166 alpha2 userspace will be queried 407 400 * for a regulatory domain structure for the respective country. 401 + * 402 + * The wiphy must have been registered to cfg80211 prior to this call. 403 + * For cfg80211 drivers this means you must first use wiphy_register(), 404 + * for mac80211 drivers you must first use ieee80211_register_hw(). 405 + * 406 + * Drivers should check the return value, its possible you can get 407 + * an -ENOMEM. 408 408 */ 409 - extern void regulatory_hint(struct wiphy *wiphy, const char *alpha2); 409 + extern int regulatory_hint(struct wiphy *wiphy, const char *alpha2); 410 410 411 411 /** 412 412 * regulatory_hint_11d - hints a country IE as a regulatory domain ··· 429 415 extern void regulatory_hint_11d(struct wiphy *wiphy, 430 416 u8 *country_ie, 431 417 u8 country_ie_len); 432 - 433 418 /** 434 419 * wiphy_apply_custom_regulatory - apply a custom driver regulatory domain 435 420 * @wiphy: the wireless device we want to process the regulatory domain on
+1
net/mac80211/Makefile
··· 9 9 wpa.o \ 10 10 scan.o \ 11 11 ht.o agg-tx.o agg-rx.o \ 12 + ibss.o \ 12 13 mlme.o \ 13 14 iface.o \ 14 15 rate.o \
+3 -3
net/mac80211/agg-rx.c
··· 129 129 u8 dialog_token, u16 status, u16 policy, 130 130 u16 buf_size, u16 timeout) 131 131 { 132 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 133 132 struct ieee80211_local *local = sdata->local; 134 133 struct sk_buff *skb; 135 134 struct ieee80211_mgmt *mgmt; ··· 150 151 if (sdata->vif.type == NL80211_IFTYPE_AP || 151 152 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 152 153 memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); 153 - else 154 - memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); 154 + else if (sdata->vif.type == NL80211_IFTYPE_STATION) 155 + memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); 156 + 155 157 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 156 158 IEEE80211_STYPE_ACTION); 157 159
+131 -66
net/mac80211/agg-tx.c
··· 49 49 u16 agg_size, u16 timeout) 50 50 { 51 51 struct ieee80211_local *local = sdata->local; 52 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 53 52 struct sk_buff *skb; 54 53 struct ieee80211_mgmt *mgmt; 55 54 u16 capab; ··· 68 69 if (sdata->vif.type == NL80211_IFTYPE_AP || 69 70 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 70 71 memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); 71 - else 72 - memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); 72 + else if (sdata->vif.type == NL80211_IFTYPE_STATION) 73 + memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); 73 74 74 75 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 75 76 IEEE80211_STYPE_ACTION); ··· 131 132 132 133 state = &sta->ampdu_mlme.tid_state_tx[tid]; 133 134 134 - if (local->hw.ampdu_queues) 135 - ieee80211_stop_queue(&local->hw, sta->tid_to_tx_q[tid]); 135 + if (local->hw.ampdu_queues) { 136 + if (initiator) { 137 + /* 138 + * Stop the AC queue to avoid issues where we send 139 + * unaggregated frames already before the delba. 140 + */ 141 + ieee80211_stop_queue_by_reason(&local->hw, 142 + local->hw.queues + sta->tid_to_tx_q[tid], 143 + IEEE80211_QUEUE_STOP_REASON_AGGREGATION); 144 + } 136 145 146 + /* 147 + * Pretend the driver woke the queue, just in case 148 + * it disabled it before the session was stopped. 149 + */ 150 + ieee80211_wake_queue( 151 + &local->hw, local->hw.queues + sta->tid_to_tx_q[tid]); 152 + } 137 153 *state = HT_AGG_STATE_REQ_STOP_BA_MSK | 138 154 (initiator << HT_AGG_STATE_INITIATOR_SHIFT); 139 155 ··· 158 144 /* HW shall not deny going back to legacy */ 159 145 if (WARN_ON(ret)) { 160 146 *state = HT_AGG_STATE_OPERATIONAL; 161 - if (local->hw.ampdu_queues) 162 - ieee80211_wake_queue(&local->hw, sta->tid_to_tx_q[tid]); 163 147 } 164 148 165 149 return ret; ··· 201 189 spin_unlock_bh(&sta->lock); 202 190 } 203 191 192 + static inline int ieee80211_ac_from_tid(int tid) 193 + { 194 + return ieee802_1d_to_ac[tid & 7]; 195 + } 196 + 204 197 int ieee80211_start_tx_ba_session(struct ieee80211_hw *hw, u8 *ra, u16 tid) 205 198 { 206 199 struct ieee80211_local *local = hw_to_local(hw); 207 200 struct sta_info *sta; 208 201 struct ieee80211_sub_if_data *sdata; 209 - u16 start_seq_num; 210 202 u8 *state; 211 - int ret = 0; 203 + int i, qn = -1, ret = 0; 204 + u16 start_seq_num; 212 205 213 206 if (WARN_ON(!local->ops->ampdu_action)) 214 207 return -EINVAL; ··· 226 209 ra, tid); 227 210 #endif /* CONFIG_MAC80211_HT_DEBUG */ 228 211 212 + if (hw->ampdu_queues && ieee80211_ac_from_tid(tid) == 0) { 213 + #ifdef CONFIG_MAC80211_HT_DEBUG 214 + printk(KERN_DEBUG "rejecting on voice AC\n"); 215 + #endif 216 + return -EINVAL; 217 + } 218 + 229 219 rcu_read_lock(); 230 220 231 221 sta = sta_info_get(local, ra); ··· 241 217 printk(KERN_DEBUG "Could not find the station\n"); 242 218 #endif 243 219 ret = -ENOENT; 244 - goto exit; 220 + goto unlock; 245 221 } 246 222 247 223 /* ··· 254 230 sta->sdata->vif.type != NL80211_IFTYPE_AP_VLAN && 255 231 sta->sdata->vif.type != NL80211_IFTYPE_AP) { 256 232 ret = -EINVAL; 257 - goto exit; 233 + goto unlock; 258 234 } 259 235 260 236 spin_lock_bh(&sta->lock); 237 + 238 + sdata = sta->sdata; 261 239 262 240 /* we have tried too many times, receiver does not want A-MPDU */ 263 241 if (sta->ampdu_mlme.addba_req_num[tid] > HT_AGG_MAX_RETRIES) { ··· 278 252 goto err_unlock_sta; 279 253 } 280 254 255 + if (hw->ampdu_queues) { 256 + spin_lock(&local->queue_stop_reason_lock); 257 + /* reserve a new queue for this session */ 258 + for (i = 0; i < local->hw.ampdu_queues; i++) { 259 + if (local->ampdu_ac_queue[i] < 0) { 260 + qn = i; 261 + local->ampdu_ac_queue[qn] = 262 + ieee80211_ac_from_tid(tid); 263 + break; 264 + } 265 + } 266 + spin_unlock(&local->queue_stop_reason_lock); 267 + 268 + if (qn < 0) { 269 + #ifdef CONFIG_MAC80211_HT_DEBUG 270 + printk(KERN_DEBUG "BA request denied - " 271 + "queue unavailable for tid %d\n", tid); 272 + #endif /* CONFIG_MAC80211_HT_DEBUG */ 273 + ret = -ENOSPC; 274 + goto err_unlock_sta; 275 + } 276 + 277 + /* 278 + * If we successfully allocate the session, we can't have 279 + * anything going on on the queue this TID maps into, so 280 + * stop it for now. This is a "virtual" stop using the same 281 + * mechanism that drivers will use. 282 + * 283 + * XXX: queue up frames for this session in the sta_info 284 + * struct instead to avoid hitting all other STAs. 285 + */ 286 + ieee80211_stop_queue_by_reason( 287 + &local->hw, hw->queues + qn, 288 + IEEE80211_QUEUE_STOP_REASON_AGGREGATION); 289 + } 290 + 281 291 /* prepare A-MPDU MLME for Tx aggregation */ 282 292 sta->ampdu_mlme.tid_tx[tid] = 283 293 kmalloc(sizeof(struct tid_ampdu_tx), GFP_ATOMIC); ··· 324 262 tid); 325 263 #endif 326 264 ret = -ENOMEM; 327 - goto err_unlock_sta; 265 + goto err_return_queue; 328 266 } 267 + 329 268 /* Tx timer */ 330 269 sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer.function = 331 270 sta_addba_resp_timer_expired; ··· 334 271 (unsigned long)&sta->timer_to_tid[tid]; 335 272 init_timer(&sta->ampdu_mlme.tid_tx[tid]->addba_resp_timer); 336 273 337 - if (hw->ampdu_queues) { 338 - /* create a new queue for this aggregation */ 339 - ret = ieee80211_ht_agg_queue_add(local, sta, tid); 340 - 341 - /* case no queue is available to aggregation 342 - * don't switch to aggregation */ 343 - if (ret) { 344 - #ifdef CONFIG_MAC80211_HT_DEBUG 345 - printk(KERN_DEBUG "BA request denied - " 346 - "queue unavailable for tid %d\n", tid); 347 - #endif /* CONFIG_MAC80211_HT_DEBUG */ 348 - goto err_unlock_queue; 349 - } 350 - } 351 - sdata = sta->sdata; 352 - 353 274 /* Ok, the Addba frame hasn't been sent yet, but if the driver calls the 354 275 * call back right away, it must see that the flow has begun */ 355 276 *state |= HT_ADDBA_REQUESTED_MSK; 356 277 357 - /* This is slightly racy because the queue isn't stopped */ 358 278 start_seq_num = sta->tid_seq[tid]; 359 279 360 280 ret = local->ops->ampdu_action(hw, IEEE80211_AMPDU_TX_START, 361 281 &sta->sta, tid, &start_seq_num); 362 282 363 283 if (ret) { 364 - /* No need to requeue the packets in the agg queue, since we 365 - * held the tx lock: no packet could be enqueued to the newly 366 - * allocated queue */ 367 - if (hw->ampdu_queues) 368 - ieee80211_ht_agg_queue_remove(local, sta, tid, 0); 369 284 #ifdef CONFIG_MAC80211_HT_DEBUG 370 285 printk(KERN_DEBUG "BA request denied - HW unavailable for" 371 286 " tid %d\n", tid); 372 287 #endif /* CONFIG_MAC80211_HT_DEBUG */ 373 288 *state = HT_AGG_STATE_IDLE; 374 - goto err_unlock_queue; 289 + goto err_free; 375 290 } 291 + sta->tid_to_tx_q[tid] = qn; 376 292 377 - /* Will put all the packets in the new SW queue */ 378 - if (hw->ampdu_queues) 379 - ieee80211_requeue(local, ieee802_1d_to_ac[tid]); 380 293 spin_unlock_bh(&sta->lock); 381 294 382 295 /* send an addBA request */ ··· 360 321 sta->ampdu_mlme.tid_tx[tid]->dialog_token = 361 322 sta->ampdu_mlme.dialog_token_allocator; 362 323 sta->ampdu_mlme.tid_tx[tid]->ssn = start_seq_num; 363 - 364 324 365 325 ieee80211_send_addba_request(sta->sdata, ra, tid, 366 326 sta->ampdu_mlme.tid_tx[tid]->dialog_token, ··· 372 334 #ifdef CONFIG_MAC80211_HT_DEBUG 373 335 printk(KERN_DEBUG "activated addBA response timer on tid %d\n", tid); 374 336 #endif 375 - goto exit; 337 + goto unlock; 376 338 377 - err_unlock_queue: 339 + err_free: 378 340 kfree(sta->ampdu_mlme.tid_tx[tid]); 379 341 sta->ampdu_mlme.tid_tx[tid] = NULL; 380 - ret = -EBUSY; 381 - err_unlock_sta: 342 + err_return_queue: 343 + if (qn >= 0) { 344 + /* We failed, so start queue again right away. */ 345 + ieee80211_wake_queue_by_reason(hw, hw->queues + qn, 346 + IEEE80211_QUEUE_STOP_REASON_AGGREGATION); 347 + /* give queue back to pool */ 348 + spin_lock(&local->queue_stop_reason_lock); 349 + local->ampdu_ac_queue[qn] = -1; 350 + spin_unlock(&local->queue_stop_reason_lock); 351 + } 352 + err_unlock_sta: 382 353 spin_unlock_bh(&sta->lock); 383 - exit: 354 + unlock: 384 355 rcu_read_unlock(); 385 356 return ret; 386 357 } ··· 422 375 state = &sta->ampdu_mlme.tid_state_tx[tid]; 423 376 spin_lock_bh(&sta->lock); 424 377 425 - if (!(*state & HT_ADDBA_REQUESTED_MSK)) { 378 + if (WARN_ON(!(*state & HT_ADDBA_REQUESTED_MSK))) { 426 379 #ifdef CONFIG_MAC80211_HT_DEBUG 427 380 printk(KERN_DEBUG "addBA was not requested yet, state is %d\n", 428 381 *state); ··· 432 385 return; 433 386 } 434 387 435 - WARN_ON_ONCE(*state & HT_ADDBA_DRV_READY_MSK); 388 + if (WARN_ON(*state & HT_ADDBA_DRV_READY_MSK)) 389 + goto out; 436 390 437 391 *state |= HT_ADDBA_DRV_READY_MSK; 438 392 ··· 441 393 #ifdef CONFIG_MAC80211_HT_DEBUG 442 394 printk(KERN_DEBUG "Aggregation is on for tid %d \n", tid); 443 395 #endif 444 - if (hw->ampdu_queues) 445 - ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); 396 + if (hw->ampdu_queues) { 397 + /* 398 + * Wake up this queue, we stopped it earlier, 399 + * this will in turn wake the entire AC. 400 + */ 401 + ieee80211_wake_queue_by_reason(hw, 402 + hw->queues + sta->tid_to_tx_q[tid], 403 + IEEE80211_QUEUE_STOP_REASON_AGGREGATION); 404 + } 446 405 } 406 + 407 + out: 447 408 spin_unlock_bh(&sta->lock); 448 409 rcu_read_unlock(); 449 410 } ··· 542 485 struct ieee80211_local *local = hw_to_local(hw); 543 486 struct sta_info *sta; 544 487 u8 *state; 545 - int agg_queue; 546 488 547 489 if (tid >= STA_TID_NUM) { 548 490 #ifdef CONFIG_MAC80211_HT_DEBUG ··· 583 527 ieee80211_send_delba(sta->sdata, ra, tid, 584 528 WLAN_BACK_INITIATOR, WLAN_REASON_QSTA_NOT_USE); 585 529 586 - if (hw->ampdu_queues) { 587 - agg_queue = sta->tid_to_tx_q[tid]; 588 - ieee80211_ht_agg_queue_remove(local, sta, tid, 1); 589 - 590 - /* We just requeued the all the frames that were in the 591 - * removed queue, and since we might miss a softirq we do 592 - * netif_schedule_queue. ieee80211_wake_queue is not used 593 - * here as this queue is not necessarily stopped 594 - */ 595 - netif_schedule_queue(netdev_get_tx_queue(local->mdev, 596 - agg_queue)); 597 - } 598 530 spin_lock_bh(&sta->lock); 531 + 532 + if (*state & HT_AGG_STATE_INITIATOR_MSK && 533 + hw->ampdu_queues) { 534 + /* 535 + * Wake up this queue, we stopped it earlier, 536 + * this will in turn wake the entire AC. 537 + */ 538 + ieee80211_wake_queue_by_reason(hw, 539 + hw->queues + sta->tid_to_tx_q[tid], 540 + IEEE80211_QUEUE_STOP_REASON_AGGREGATION); 541 + } 542 + 599 543 *state = HT_AGG_STATE_IDLE; 600 544 sta->ampdu_mlme.addba_req_num[tid] = 0; 601 545 kfree(sta->ampdu_mlme.tid_tx[tid]); ··· 669 613 #endif /* CONFIG_MAC80211_HT_DEBUG */ 670 614 if (le16_to_cpu(mgmt->u.action.u.addba_resp.status) 671 615 == WLAN_STATUS_SUCCESS) { 672 - *state |= HT_ADDBA_RECEIVED_MSK; 673 - sta->ampdu_mlme.addba_req_num[tid] = 0; 616 + u8 curstate = *state; 674 617 675 - if (*state == HT_AGG_STATE_OPERATIONAL && 676 - local->hw.ampdu_queues) 677 - ieee80211_wake_queue(hw, sta->tid_to_tx_q[tid]); 618 + *state |= HT_ADDBA_RECEIVED_MSK; 619 + 620 + if (hw->ampdu_queues && *state != curstate && 621 + *state == HT_AGG_STATE_OPERATIONAL) { 622 + /* 623 + * Wake up this queue, we stopped it earlier, 624 + * this will in turn wake the entire AC. 625 + */ 626 + ieee80211_wake_queue_by_reason(hw, 627 + hw->queues + sta->tid_to_tx_q[tid], 628 + IEEE80211_QUEUE_STOP_REASON_AGGREGATION); 629 + } 630 + sta->ampdu_mlme.addba_req_num[tid] = 0; 678 631 679 632 if (local->ops->ampdu_action) { 680 633 (void)local->ops->ampdu_action(hw,
+26 -23
net/mac80211/cfg.c
··· 341 341 sinfo->filled = STATION_INFO_INACTIVE_TIME | 342 342 STATION_INFO_RX_BYTES | 343 343 STATION_INFO_TX_BYTES | 344 + STATION_INFO_RX_PACKETS | 345 + STATION_INFO_TX_PACKETS | 344 346 STATION_INFO_TX_BITRATE; 345 347 346 348 sinfo->inactive_time = jiffies_to_msecs(jiffies - sta->last_rx); 347 349 sinfo->rx_bytes = sta->rx_bytes; 348 350 sinfo->tx_bytes = sta->tx_bytes; 351 + sinfo->rx_packets = sta->rx_packets; 352 + sinfo->tx_packets = sta->tx_packets; 349 353 350 354 if (sta->local->hw.flags & IEEE80211_HW_SIGNAL_DBM) { 351 355 sinfo->filled |= STATION_INFO_SIGNAL; ··· 1184 1180 u8 subtype, u8 *ies, size_t ies_len) 1185 1181 { 1186 1182 struct ieee80211_local *local = sdata->local; 1187 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 1183 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1188 1184 1189 1185 switch (subtype) { 1190 1186 case IEEE80211_STYPE_PROBE_REQ >> 4: 1191 1187 if (local->ops->hw_scan) 1192 1188 break; 1193 - kfree(ifsta->ie_probereq); 1194 - ifsta->ie_probereq = ies; 1195 - ifsta->ie_probereq_len = ies_len; 1189 + kfree(ifmgd->ie_probereq); 1190 + ifmgd->ie_probereq = ies; 1191 + ifmgd->ie_probereq_len = ies_len; 1196 1192 return 0; 1197 1193 case IEEE80211_STYPE_PROBE_RESP >> 4: 1198 - kfree(ifsta->ie_proberesp); 1199 - ifsta->ie_proberesp = ies; 1200 - ifsta->ie_proberesp_len = ies_len; 1194 + kfree(ifmgd->ie_proberesp); 1195 + ifmgd->ie_proberesp = ies; 1196 + ifmgd->ie_proberesp_len = ies_len; 1201 1197 return 0; 1202 1198 case IEEE80211_STYPE_AUTH >> 4: 1203 - kfree(ifsta->ie_auth); 1204 - ifsta->ie_auth = ies; 1205 - ifsta->ie_auth_len = ies_len; 1199 + kfree(ifmgd->ie_auth); 1200 + ifmgd->ie_auth = ies; 1201 + ifmgd->ie_auth_len = ies_len; 1206 1202 return 0; 1207 1203 case IEEE80211_STYPE_ASSOC_REQ >> 4: 1208 - kfree(ifsta->ie_assocreq); 1209 - ifsta->ie_assocreq = ies; 1210 - ifsta->ie_assocreq_len = ies_len; 1204 + kfree(ifmgd->ie_assocreq); 1205 + ifmgd->ie_assocreq = ies; 1206 + ifmgd->ie_assocreq_len = ies_len; 1211 1207 return 0; 1212 1208 case IEEE80211_STYPE_REASSOC_REQ >> 4: 1213 - kfree(ifsta->ie_reassocreq); 1214 - ifsta->ie_reassocreq = ies; 1215 - ifsta->ie_reassocreq_len = ies_len; 1209 + kfree(ifmgd->ie_reassocreq); 1210 + ifmgd->ie_reassocreq = ies; 1211 + ifmgd->ie_reassocreq_len = ies_len; 1216 1212 return 0; 1217 1213 case IEEE80211_STYPE_DEAUTH >> 4: 1218 - kfree(ifsta->ie_deauth); 1219 - ifsta->ie_deauth = ies; 1220 - ifsta->ie_deauth_len = ies_len; 1214 + kfree(ifmgd->ie_deauth); 1215 + ifmgd->ie_deauth = ies; 1216 + ifmgd->ie_deauth_len = ies_len; 1221 1217 return 0; 1222 1218 case IEEE80211_STYPE_DISASSOC >> 4: 1223 - kfree(ifsta->ie_disassoc); 1224 - ifsta->ie_disassoc = ies; 1225 - ifsta->ie_disassoc_len = ies_len; 1219 + kfree(ifmgd->ie_disassoc); 1220 + ifmgd->ie_disassoc = ies; 1221 + ifmgd->ie_disassoc_len = ies_len; 1226 1222 return 0; 1227 1223 } 1228 1224 ··· 1252 1248 1253 1249 switch (sdata->vif.type) { 1254 1250 case NL80211_IFTYPE_STATION: 1255 - case NL80211_IFTYPE_ADHOC: 1256 1251 ret = set_mgmt_extra_ie_sta(sdata, params->subtype, 1257 1252 ies, ies_len); 1258 1253 break;
+26 -22
net/mac80211/debugfs_netdev.c
··· 94 94 IEEE80211_IF_FILE(force_unicast_rateidx, force_unicast_rateidx, DEC); 95 95 IEEE80211_IF_FILE(max_ratectrl_rateidx, max_ratectrl_rateidx, DEC); 96 96 97 - /* STA/IBSS attributes */ 98 - IEEE80211_IF_FILE(state, u.sta.state, DEC); 99 - IEEE80211_IF_FILE(bssid, u.sta.bssid, MAC); 100 - IEEE80211_IF_FILE(prev_bssid, u.sta.prev_bssid, MAC); 101 - IEEE80211_IF_FILE(ssid_len, u.sta.ssid_len, SIZE); 102 - IEEE80211_IF_FILE(aid, u.sta.aid, DEC); 103 - IEEE80211_IF_FILE(ap_capab, u.sta.ap_capab, HEX); 104 - IEEE80211_IF_FILE(capab, u.sta.capab, HEX); 105 - IEEE80211_IF_FILE(extra_ie_len, u.sta.extra_ie_len, SIZE); 106 - IEEE80211_IF_FILE(auth_tries, u.sta.auth_tries, DEC); 107 - IEEE80211_IF_FILE(assoc_tries, u.sta.assoc_tries, DEC); 108 - IEEE80211_IF_FILE(auth_algs, u.sta.auth_algs, HEX); 109 - IEEE80211_IF_FILE(auth_alg, u.sta.auth_alg, DEC); 110 - IEEE80211_IF_FILE(auth_transaction, u.sta.auth_transaction, DEC); 97 + /* STA attributes */ 98 + IEEE80211_IF_FILE(state, u.mgd.state, DEC); 99 + IEEE80211_IF_FILE(bssid, u.mgd.bssid, MAC); 100 + IEEE80211_IF_FILE(prev_bssid, u.mgd.prev_bssid, MAC); 101 + IEEE80211_IF_FILE(ssid_len, u.mgd.ssid_len, SIZE); 102 + IEEE80211_IF_FILE(aid, u.mgd.aid, DEC); 103 + IEEE80211_IF_FILE(ap_capab, u.mgd.ap_capab, HEX); 104 + IEEE80211_IF_FILE(capab, u.mgd.capab, HEX); 105 + IEEE80211_IF_FILE(extra_ie_len, u.mgd.extra_ie_len, SIZE); 106 + IEEE80211_IF_FILE(auth_tries, u.mgd.auth_tries, DEC); 107 + IEEE80211_IF_FILE(assoc_tries, u.mgd.assoc_tries, DEC); 108 + IEEE80211_IF_FILE(auth_algs, u.mgd.auth_algs, HEX); 109 + IEEE80211_IF_FILE(auth_alg, u.mgd.auth_alg, DEC); 110 + IEEE80211_IF_FILE(auth_transaction, u.mgd.auth_transaction, DEC); 111 111 112 112 static ssize_t ieee80211_if_fmt_flags( 113 113 const struct ieee80211_sub_if_data *sdata, char *buf, int buflen) 114 114 { 115 115 return scnprintf(buf, buflen, "%s%s%s%s%s%s%s\n", 116 - sdata->u.sta.flags & IEEE80211_STA_SSID_SET ? "SSID\n" : "", 117 - sdata->u.sta.flags & IEEE80211_STA_BSSID_SET ? "BSSID\n" : "", 118 - sdata->u.sta.flags & IEEE80211_STA_PREV_BSSID_SET ? "prev BSSID\n" : "", 119 - sdata->u.sta.flags & IEEE80211_STA_AUTHENTICATED ? "AUTH\n" : "", 120 - sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED ? "ASSOC\n" : "", 121 - sdata->u.sta.flags & IEEE80211_STA_PROBEREQ_POLL ? "PROBEREQ POLL\n" : "", 116 + sdata->u.mgd.flags & IEEE80211_STA_SSID_SET ? "SSID\n" : "", 117 + sdata->u.mgd.flags & IEEE80211_STA_BSSID_SET ? "BSSID\n" : "", 118 + sdata->u.mgd.flags & IEEE80211_STA_PREV_BSSID_SET ? "prev BSSID\n" : "", 119 + sdata->u.mgd.flags & IEEE80211_STA_AUTHENTICATED ? "AUTH\n" : "", 120 + sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED ? "ASSOC\n" : "", 121 + sdata->u.mgd.flags & IEEE80211_STA_PROBEREQ_POLL ? "PROBEREQ POLL\n" : "", 122 122 sdata->vif.bss_conf.use_cts_prot ? "CTS prot\n" : ""); 123 123 } 124 124 __IEEE80211_IF_FILE(flags); ··· 283 283 #endif 284 284 break; 285 285 case NL80211_IFTYPE_STATION: 286 - case NL80211_IFTYPE_ADHOC: 287 286 add_sta_files(sdata); 287 + break; 288 + case NL80211_IFTYPE_ADHOC: 289 + /* XXX */ 288 290 break; 289 291 case NL80211_IFTYPE_AP: 290 292 add_ap_files(sdata); ··· 420 418 #endif 421 419 break; 422 420 case NL80211_IFTYPE_STATION: 423 - case NL80211_IFTYPE_ADHOC: 424 421 del_sta_files(sdata); 422 + break; 423 + case NL80211_IFTYPE_ADHOC: 424 + /* XXX */ 425 425 break; 426 426 case NL80211_IFTYPE_AP: 427 427 del_ap_files(sdata);
+16 -3
net/mac80211/ht.c
··· 17 17 #include <net/wireless.h> 18 18 #include <net/mac80211.h> 19 19 #include "ieee80211_i.h" 20 + #include "rate.h" 20 21 21 22 void ieee80211_ht_cap_ie_to_sta_ht_cap(struct ieee80211_supported_band *sband, 22 23 struct ieee80211_ht_cap *ht_cap_ie, ··· 94 93 { 95 94 struct ieee80211_local *local = sdata->local; 96 95 struct ieee80211_supported_band *sband; 96 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 97 97 struct ieee80211_bss_ht_conf ht; 98 + struct sta_info *sta; 98 99 u32 changed = 0; 99 100 bool enable_ht = true, ht_changed; 100 101 enum nl80211_channel_type channel_type = NL80211_CHAN_NO_HT; ··· 139 136 if (ht_changed) { 140 137 /* channel_type change automatically detected */ 141 138 ieee80211_hw_config(local, 0); 139 + 140 + rcu_read_lock(); 141 + 142 + sta = sta_info_get(local, ifmgd->bssid); 143 + if (sta) 144 + rate_control_rate_update(local, sband, sta, 145 + IEEE80211_RC_HT_CHANGED); 146 + 147 + rcu_read_unlock(); 148 + 142 149 } 143 150 144 151 /* disable HT */ ··· 182 169 u16 initiator, u16 reason_code) 183 170 { 184 171 struct ieee80211_local *local = sdata->local; 185 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 186 172 struct sk_buff *skb; 187 173 struct ieee80211_mgmt *mgmt; 188 174 u16 params; ··· 202 190 if (sdata->vif.type == NL80211_IFTYPE_AP || 203 191 sdata->vif.type == NL80211_IFTYPE_AP_VLAN) 204 192 memcpy(mgmt->bssid, sdata->dev->dev_addr, ETH_ALEN); 205 - else 206 - memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); 193 + else if (sdata->vif.type == NL80211_IFTYPE_STATION) 194 + memcpy(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN); 195 + 207 196 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 208 197 IEEE80211_STYPE_ACTION); 209 198
+905
net/mac80211/ibss.c
··· 1 + /* 2 + * IBSS mode implementation 3 + * Copyright 2003-2008, Jouni Malinen <j@w1.fi> 4 + * Copyright 2004, Instant802 Networks, Inc. 5 + * Copyright 2005, Devicescape Software, Inc. 6 + * Copyright 2006-2007 Jiri Benc <jbenc@suse.cz> 7 + * Copyright 2007, Michael Wu <flamingice@sourmilk.net> 8 + * Copyright 2009, Johannes Berg <johannes@sipsolutions.net> 9 + * 10 + * This program is free software; you can redistribute it and/or modify 11 + * it under the terms of the GNU General Public License version 2 as 12 + * published by the Free Software Foundation. 13 + */ 14 + 15 + #include <linux/delay.h> 16 + #include <linux/if_ether.h> 17 + #include <linux/skbuff.h> 18 + #include <linux/if_arp.h> 19 + #include <linux/etherdevice.h> 20 + #include <linux/rtnetlink.h> 21 + #include <net/mac80211.h> 22 + #include <asm/unaligned.h> 23 + 24 + #include "ieee80211_i.h" 25 + #include "rate.h" 26 + 27 + #define IEEE80211_SCAN_INTERVAL (2 * HZ) 28 + #define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ) 29 + #define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ) 30 + 31 + #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ) 32 + #define IEEE80211_IBSS_MERGE_DELAY 0x400000 33 + #define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ) 34 + 35 + #define IEEE80211_IBSS_MAX_STA_ENTRIES 128 36 + 37 + 38 + static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, 39 + struct ieee80211_mgmt *mgmt, 40 + size_t len) 41 + { 42 + u16 auth_alg, auth_transaction, status_code; 43 + 44 + if (len < 24 + 6) 45 + return; 46 + 47 + auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); 48 + auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); 49 + status_code = le16_to_cpu(mgmt->u.auth.status_code); 50 + 51 + /* 52 + * IEEE 802.11 standard does not require authentication in IBSS 53 + * networks and most implementations do not seem to use it. 54 + * However, try to reply to authentication attempts if someone 55 + * has actually implemented this. 56 + */ 57 + if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) 58 + ieee80211_send_auth(sdata, 2, WLAN_AUTH_OPEN, NULL, 0, 59 + sdata->u.ibss.bssid, 0); 60 + } 61 + 62 + static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, 63 + const u8 *bssid, const int beacon_int, 64 + const int freq, 65 + const size_t supp_rates_len, 66 + const u8 *supp_rates, 67 + const u16 capability) 68 + { 69 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 70 + struct ieee80211_local *local = sdata->local; 71 + int res = 0, rates, i, j; 72 + struct sk_buff *skb; 73 + struct ieee80211_mgmt *mgmt; 74 + u8 *pos; 75 + struct ieee80211_supported_band *sband; 76 + union iwreq_data wrqu; 77 + 78 + if (local->ops->reset_tsf) { 79 + /* Reset own TSF to allow time synchronization work. */ 80 + local->ops->reset_tsf(local_to_hw(local)); 81 + } 82 + 83 + if ((ifibss->flags & IEEE80211_IBSS_PREV_BSSID_SET) && 84 + memcmp(ifibss->bssid, bssid, ETH_ALEN) == 0) 85 + return res; 86 + 87 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400); 88 + if (!skb) { 89 + printk(KERN_DEBUG "%s: failed to allocate buffer for probe " 90 + "response\n", sdata->dev->name); 91 + return -ENOMEM; 92 + } 93 + 94 + if (!(ifibss->flags & IEEE80211_IBSS_PREV_BSSID_SET)) { 95 + /* Remove possible STA entries from other IBSS networks. */ 96 + sta_info_flush_delayed(sdata); 97 + } 98 + 99 + memcpy(ifibss->bssid, bssid, ETH_ALEN); 100 + res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); 101 + if (res) 102 + return res; 103 + 104 + local->hw.conf.beacon_int = beacon_int >= 10 ? beacon_int : 10; 105 + 106 + sdata->drop_unencrypted = capability & 107 + WLAN_CAPABILITY_PRIVACY ? 1 : 0; 108 + 109 + res = ieee80211_set_freq(sdata, freq); 110 + 111 + if (res) 112 + return res; 113 + 114 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 115 + 116 + /* Build IBSS probe response */ 117 + 118 + skb_reserve(skb, local->hw.extra_tx_headroom); 119 + 120 + mgmt = (struct ieee80211_mgmt *) 121 + skb_put(skb, 24 + sizeof(mgmt->u.beacon)); 122 + memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); 123 + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 124 + IEEE80211_STYPE_PROBE_RESP); 125 + memset(mgmt->da, 0xff, ETH_ALEN); 126 + memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 127 + memcpy(mgmt->bssid, ifibss->bssid, ETH_ALEN); 128 + mgmt->u.beacon.beacon_int = 129 + cpu_to_le16(local->hw.conf.beacon_int); 130 + mgmt->u.beacon.capab_info = cpu_to_le16(capability); 131 + 132 + pos = skb_put(skb, 2 + ifibss->ssid_len); 133 + *pos++ = WLAN_EID_SSID; 134 + *pos++ = ifibss->ssid_len; 135 + memcpy(pos, ifibss->ssid, ifibss->ssid_len); 136 + 137 + rates = supp_rates_len; 138 + if (rates > 8) 139 + rates = 8; 140 + pos = skb_put(skb, 2 + rates); 141 + *pos++ = WLAN_EID_SUPP_RATES; 142 + *pos++ = rates; 143 + memcpy(pos, supp_rates, rates); 144 + 145 + if (sband->band == IEEE80211_BAND_2GHZ) { 146 + pos = skb_put(skb, 2 + 1); 147 + *pos++ = WLAN_EID_DS_PARAMS; 148 + *pos++ = 1; 149 + *pos++ = ieee80211_frequency_to_channel(freq); 150 + } 151 + 152 + pos = skb_put(skb, 2 + 2); 153 + *pos++ = WLAN_EID_IBSS_PARAMS; 154 + *pos++ = 2; 155 + /* FIX: set ATIM window based on scan results */ 156 + *pos++ = 0; 157 + *pos++ = 0; 158 + 159 + if (supp_rates_len > 8) { 160 + rates = supp_rates_len - 8; 161 + pos = skb_put(skb, 2 + rates); 162 + *pos++ = WLAN_EID_EXT_SUPP_RATES; 163 + *pos++ = rates; 164 + memcpy(pos, &supp_rates[8], rates); 165 + } 166 + 167 + ifibss->probe_resp = skb; 168 + 169 + ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON | 170 + IEEE80211_IFCC_BEACON_ENABLED); 171 + 172 + 173 + rates = 0; 174 + for (i = 0; i < supp_rates_len; i++) { 175 + int bitrate = (supp_rates[i] & 0x7f) * 5; 176 + for (j = 0; j < sband->n_bitrates; j++) 177 + if (sband->bitrates[j].bitrate == bitrate) 178 + rates |= BIT(j); 179 + } 180 + 181 + ieee80211_sta_def_wmm_params(sdata, supp_rates_len, supp_rates); 182 + 183 + ifibss->flags |= IEEE80211_IBSS_PREV_BSSID_SET; 184 + ifibss->state = IEEE80211_IBSS_MLME_JOINED; 185 + mod_timer(&ifibss->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); 186 + 187 + memset(&wrqu, 0, sizeof(wrqu)); 188 + memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); 189 + wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL); 190 + 191 + return res; 192 + } 193 + 194 + static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, 195 + struct ieee80211_bss *bss) 196 + { 197 + return __ieee80211_sta_join_ibss(sdata, 198 + bss->cbss.bssid, 199 + bss->cbss.beacon_interval, 200 + bss->cbss.channel->center_freq, 201 + bss->supp_rates_len, bss->supp_rates, 202 + bss->cbss.capability); 203 + } 204 + 205 + static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, 206 + struct ieee80211_mgmt *mgmt, 207 + size_t len, 208 + struct ieee80211_rx_status *rx_status, 209 + struct ieee802_11_elems *elems, 210 + bool beacon) 211 + { 212 + struct ieee80211_local *local = sdata->local; 213 + int freq; 214 + struct ieee80211_bss *bss; 215 + struct sta_info *sta; 216 + struct ieee80211_channel *channel; 217 + u64 beacon_timestamp, rx_timestamp; 218 + u32 supp_rates = 0; 219 + enum ieee80211_band band = rx_status->band; 220 + 221 + if (elems->ds_params && elems->ds_params_len == 1) 222 + freq = ieee80211_channel_to_frequency(elems->ds_params[0]); 223 + else 224 + freq = rx_status->freq; 225 + 226 + channel = ieee80211_get_channel(local->hw.wiphy, freq); 227 + 228 + if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) 229 + return; 230 + 231 + if (sdata->vif.type == NL80211_IFTYPE_ADHOC && elems->supp_rates && 232 + memcmp(mgmt->bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) { 233 + supp_rates = ieee80211_sta_get_rates(local, elems, band); 234 + 235 + rcu_read_lock(); 236 + 237 + sta = sta_info_get(local, mgmt->sa); 238 + if (sta) { 239 + u32 prev_rates; 240 + 241 + prev_rates = sta->sta.supp_rates[band]; 242 + /* make sure mandatory rates are always added */ 243 + sta->sta.supp_rates[band] = supp_rates | 244 + ieee80211_mandatory_rates(local, band); 245 + 246 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 247 + if (sta->sta.supp_rates[band] != prev_rates) 248 + printk(KERN_DEBUG "%s: updated supp_rates set " 249 + "for %pM based on beacon info (0x%llx | " 250 + "0x%llx -> 0x%llx)\n", 251 + sdata->dev->name, 252 + sta->sta.addr, 253 + (unsigned long long) prev_rates, 254 + (unsigned long long) supp_rates, 255 + (unsigned long long) sta->sta.supp_rates[band]); 256 + #endif 257 + } else 258 + ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); 259 + 260 + rcu_read_unlock(); 261 + } 262 + 263 + bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, 264 + channel, beacon); 265 + if (!bss) 266 + return; 267 + 268 + /* was just updated in ieee80211_bss_info_update */ 269 + beacon_timestamp = bss->cbss.tsf; 270 + 271 + /* check if we need to merge IBSS */ 272 + 273 + /* merge only on beacons (???) */ 274 + if (!beacon) 275 + goto put_bss; 276 + 277 + /* we use a fixed BSSID */ 278 + if (sdata->u.ibss.flags & IEEE80211_IBSS_BSSID_SET) 279 + goto put_bss; 280 + 281 + /* not an IBSS */ 282 + if (!(bss->cbss.capability & WLAN_CAPABILITY_IBSS)) 283 + goto put_bss; 284 + 285 + /* different channel */ 286 + if (bss->cbss.channel != local->oper_channel) 287 + goto put_bss; 288 + 289 + /* different SSID */ 290 + if (elems->ssid_len != sdata->u.ibss.ssid_len || 291 + memcmp(elems->ssid, sdata->u.ibss.ssid, 292 + sdata->u.ibss.ssid_len)) 293 + goto put_bss; 294 + 295 + /* same BSSID */ 296 + if (memcmp(bss->cbss.bssid, sdata->u.ibss.bssid, ETH_ALEN) == 0) 297 + goto put_bss; 298 + 299 + if (rx_status->flag & RX_FLAG_TSFT) { 300 + /* 301 + * For correct IBSS merging we need mactime; since mactime is 302 + * defined as the time the first data symbol of the frame hits 303 + * the PHY, and the timestamp of the beacon is defined as "the 304 + * time that the data symbol containing the first bit of the 305 + * timestamp is transmitted to the PHY plus the transmitting 306 + * STA's delays through its local PHY from the MAC-PHY 307 + * interface to its interface with the WM" (802.11 11.1.2) 308 + * - equals the time this bit arrives at the receiver - we have 309 + * to take into account the offset between the two. 310 + * 311 + * E.g. at 1 MBit that means mactime is 192 usec earlier 312 + * (=24 bytes * 8 usecs/byte) than the beacon timestamp. 313 + */ 314 + int rate; 315 + 316 + if (rx_status->flag & RX_FLAG_HT) 317 + rate = 65; /* TODO: HT rates */ 318 + else 319 + rate = local->hw.wiphy->bands[band]-> 320 + bitrates[rx_status->rate_idx].bitrate; 321 + 322 + rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate); 323 + } else if (local && local->ops && local->ops->get_tsf) 324 + /* second best option: get current TSF */ 325 + rx_timestamp = local->ops->get_tsf(local_to_hw(local)); 326 + else 327 + /* can't merge without knowing the TSF */ 328 + rx_timestamp = -1LLU; 329 + 330 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 331 + printk(KERN_DEBUG "RX beacon SA=%pM BSSID=" 332 + "%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n", 333 + mgmt->sa, mgmt->bssid, 334 + (unsigned long long)rx_timestamp, 335 + (unsigned long long)beacon_timestamp, 336 + (unsigned long long)(rx_timestamp - beacon_timestamp), 337 + jiffies); 338 + #endif 339 + 340 + /* give slow hardware some time to do the TSF sync */ 341 + if (rx_timestamp < IEEE80211_IBSS_MERGE_DELAY) 342 + goto put_bss; 343 + 344 + if (beacon_timestamp > rx_timestamp) { 345 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 346 + printk(KERN_DEBUG "%s: beacon TSF higher than " 347 + "local TSF - IBSS merge with BSSID %pM\n", 348 + sdata->dev->name, mgmt->bssid); 349 + #endif 350 + ieee80211_sta_join_ibss(sdata, bss); 351 + ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); 352 + } 353 + 354 + put_bss: 355 + ieee80211_rx_bss_put(local, bss); 356 + } 357 + 358 + /* 359 + * Add a new IBSS station, will also be called by the RX code when, 360 + * in IBSS mode, receiving a frame from a yet-unknown station, hence 361 + * must be callable in atomic context. 362 + */ 363 + struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 364 + u8 *bssid,u8 *addr, u32 supp_rates) 365 + { 366 + struct ieee80211_local *local = sdata->local; 367 + struct sta_info *sta; 368 + int band = local->hw.conf.channel->band; 369 + 370 + /* TODO: Could consider removing the least recently used entry and 371 + * allow new one to be added. */ 372 + if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) { 373 + if (net_ratelimit()) { 374 + printk(KERN_DEBUG "%s: No room for a new IBSS STA " 375 + "entry %pM\n", sdata->dev->name, addr); 376 + } 377 + return NULL; 378 + } 379 + 380 + if (compare_ether_addr(bssid, sdata->u.ibss.bssid)) 381 + return NULL; 382 + 383 + #ifdef CONFIG_MAC80211_VERBOSE_DEBUG 384 + printk(KERN_DEBUG "%s: Adding new IBSS station %pM (dev=%s)\n", 385 + wiphy_name(local->hw.wiphy), addr, sdata->dev->name); 386 + #endif 387 + 388 + sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); 389 + if (!sta) 390 + return NULL; 391 + 392 + set_sta_flags(sta, WLAN_STA_AUTHORIZED); 393 + 394 + /* make sure mandatory rates are always added */ 395 + sta->sta.supp_rates[band] = supp_rates | 396 + ieee80211_mandatory_rates(local, band); 397 + 398 + rate_control_rate_init(sta); 399 + 400 + if (sta_info_insert(sta)) 401 + return NULL; 402 + 403 + return sta; 404 + } 405 + 406 + static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata) 407 + { 408 + struct ieee80211_local *local = sdata->local; 409 + int active = 0; 410 + struct sta_info *sta; 411 + 412 + rcu_read_lock(); 413 + 414 + list_for_each_entry_rcu(sta, &local->sta_list, list) { 415 + if (sta->sdata == sdata && 416 + time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL, 417 + jiffies)) { 418 + active++; 419 + break; 420 + } 421 + } 422 + 423 + rcu_read_unlock(); 424 + 425 + return active; 426 + } 427 + 428 + 429 + static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata) 430 + { 431 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 432 + 433 + mod_timer(&ifibss->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); 434 + 435 + ieee80211_sta_expire(sdata, IEEE80211_IBSS_INACTIVITY_LIMIT); 436 + if (ieee80211_sta_active_ibss(sdata)) 437 + return; 438 + 439 + if ((ifibss->flags & IEEE80211_IBSS_BSSID_SET) && 440 + (!(ifibss->flags & IEEE80211_IBSS_AUTO_CHANNEL_SEL))) 441 + return; 442 + 443 + printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " 444 + "IBSS networks with same SSID (merge)\n", sdata->dev->name); 445 + 446 + /* XXX maybe racy? */ 447 + if (sdata->local->scan_req) 448 + return; 449 + 450 + memcpy(sdata->local->int_scan_req.ssids[0].ssid, 451 + ifibss->ssid, IEEE80211_MAX_SSID_LEN); 452 + sdata->local->int_scan_req.ssids[0].ssid_len = ifibss->ssid_len; 453 + ieee80211_request_scan(sdata, &sdata->local->int_scan_req); 454 + } 455 + 456 + static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata) 457 + { 458 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 459 + struct ieee80211_local *local = sdata->local; 460 + struct ieee80211_supported_band *sband; 461 + u8 *pos; 462 + u8 bssid[ETH_ALEN]; 463 + u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; 464 + u16 capability; 465 + int i; 466 + 467 + if (ifibss->flags & IEEE80211_IBSS_BSSID_SET) { 468 + memcpy(bssid, ifibss->bssid, ETH_ALEN); 469 + } else { 470 + /* Generate random, not broadcast, locally administered BSSID. Mix in 471 + * own MAC address to make sure that devices that do not have proper 472 + * random number generator get different BSSID. */ 473 + get_random_bytes(bssid, ETH_ALEN); 474 + for (i = 0; i < ETH_ALEN; i++) 475 + bssid[i] ^= sdata->dev->dev_addr[i]; 476 + bssid[0] &= ~0x01; 477 + bssid[0] |= 0x02; 478 + } 479 + 480 + printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", 481 + sdata->dev->name, bssid); 482 + 483 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 484 + 485 + if (local->hw.conf.beacon_int == 0) 486 + local->hw.conf.beacon_int = 100; 487 + 488 + capability = WLAN_CAPABILITY_IBSS; 489 + 490 + if (sdata->default_key) 491 + capability |= WLAN_CAPABILITY_PRIVACY; 492 + else 493 + sdata->drop_unencrypted = 0; 494 + 495 + pos = supp_rates; 496 + for (i = 0; i < sband->n_bitrates; i++) { 497 + int rate = sband->bitrates[i].bitrate; 498 + *pos++ = (u8) (rate / 5); 499 + } 500 + 501 + return __ieee80211_sta_join_ibss(sdata, 502 + bssid, local->hw.conf.beacon_int, 503 + local->hw.conf.channel->center_freq, 504 + sband->n_bitrates, supp_rates, 505 + capability); 506 + } 507 + 508 + static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata) 509 + { 510 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 511 + struct ieee80211_local *local = sdata->local; 512 + struct ieee80211_bss *bss; 513 + const u8 *bssid = NULL; 514 + int active_ibss; 515 + 516 + if (ifibss->ssid_len == 0) 517 + return -EINVAL; 518 + 519 + active_ibss = ieee80211_sta_active_ibss(sdata); 520 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 521 + printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", 522 + sdata->dev->name, active_ibss); 523 + #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 524 + 525 + if (active_ibss) 526 + return 0; 527 + 528 + if (ifibss->flags & IEEE80211_IBSS_BSSID_SET) 529 + bssid = ifibss->bssid; 530 + bss = (void *)cfg80211_get_bss(local->hw.wiphy, NULL, bssid, 531 + ifibss->ssid, ifibss->ssid_len, 532 + WLAN_CAPABILITY_IBSS, 533 + WLAN_CAPABILITY_IBSS); 534 + 535 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 536 + if (bss) 537 + printk(KERN_DEBUG " sta_find_ibss: selected %pM current " 538 + "%pM\n", bss->cbss.bssid, ifibss->bssid); 539 + #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 540 + 541 + if (bss && 542 + (!(ifibss->flags & IEEE80211_IBSS_PREV_BSSID_SET) || 543 + memcmp(ifibss->bssid, bss->cbss.bssid, ETH_ALEN))) { 544 + int ret; 545 + 546 + printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" 547 + " based on configured SSID\n", 548 + sdata->dev->name, bss->cbss.bssid); 549 + 550 + ret = ieee80211_sta_join_ibss(sdata, bss); 551 + ieee80211_rx_bss_put(local, bss); 552 + return ret; 553 + } else if (bss) 554 + ieee80211_rx_bss_put(local, bss); 555 + 556 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 557 + printk(KERN_DEBUG " did not try to join ibss\n"); 558 + #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 559 + 560 + /* Selected IBSS not found in current scan results - try to scan */ 561 + if (ifibss->state == IEEE80211_IBSS_MLME_JOINED && 562 + !ieee80211_sta_active_ibss(sdata)) { 563 + mod_timer(&ifibss->timer, jiffies + 564 + IEEE80211_IBSS_MERGE_INTERVAL); 565 + } else if (time_after(jiffies, local->last_scan_completed + 566 + IEEE80211_SCAN_INTERVAL)) { 567 + printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " 568 + "join\n", sdata->dev->name); 569 + 570 + /* XXX maybe racy? */ 571 + if (local->scan_req) 572 + return -EBUSY; 573 + 574 + memcpy(local->int_scan_req.ssids[0].ssid, 575 + ifibss->ssid, IEEE80211_MAX_SSID_LEN); 576 + local->int_scan_req.ssids[0].ssid_len = ifibss->ssid_len; 577 + return ieee80211_request_scan(sdata, &local->int_scan_req); 578 + } else if (ifibss->state != IEEE80211_IBSS_MLME_JOINED) { 579 + int interval = IEEE80211_SCAN_INTERVAL; 580 + 581 + if (time_after(jiffies, ifibss->ibss_join_req + 582 + IEEE80211_IBSS_JOIN_TIMEOUT)) { 583 + if (!(local->oper_channel->flags & 584 + IEEE80211_CHAN_NO_IBSS)) 585 + return ieee80211_sta_create_ibss(sdata); 586 + printk(KERN_DEBUG "%s: IBSS not allowed on" 587 + " %d MHz\n", sdata->dev->name, 588 + local->hw.conf.channel->center_freq); 589 + 590 + /* No IBSS found - decrease scan interval and continue 591 + * scanning. */ 592 + interval = IEEE80211_SCAN_INTERVAL_SLOW; 593 + } 594 + 595 + ifibss->state = IEEE80211_IBSS_MLME_SEARCH; 596 + mod_timer(&ifibss->timer, jiffies + interval); 597 + return 0; 598 + } 599 + 600 + return 0; 601 + } 602 + 603 + static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, 604 + struct ieee80211_mgmt *mgmt, 605 + size_t len) 606 + { 607 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 608 + struct ieee80211_local *local = sdata->local; 609 + int tx_last_beacon; 610 + struct sk_buff *skb; 611 + struct ieee80211_mgmt *resp; 612 + u8 *pos, *end; 613 + 614 + if (ifibss->state != IEEE80211_IBSS_MLME_JOINED || 615 + len < 24 + 2 || !ifibss->probe_resp) 616 + return; 617 + 618 + if (local->ops->tx_last_beacon) 619 + tx_last_beacon = local->ops->tx_last_beacon(local_to_hw(local)); 620 + else 621 + tx_last_beacon = 1; 622 + 623 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 624 + printk(KERN_DEBUG "%s: RX ProbeReq SA=%pM DA=%pM BSSID=%pM" 625 + " (tx_last_beacon=%d)\n", 626 + sdata->dev->name, mgmt->sa, mgmt->da, 627 + mgmt->bssid, tx_last_beacon); 628 + #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 629 + 630 + if (!tx_last_beacon) 631 + return; 632 + 633 + if (memcmp(mgmt->bssid, ifibss->bssid, ETH_ALEN) != 0 && 634 + memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0) 635 + return; 636 + 637 + end = ((u8 *) mgmt) + len; 638 + pos = mgmt->u.probe_req.variable; 639 + if (pos[0] != WLAN_EID_SSID || 640 + pos + 2 + pos[1] > end) { 641 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 642 + printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " 643 + "from %pM\n", 644 + sdata->dev->name, mgmt->sa); 645 + #endif 646 + return; 647 + } 648 + if (pos[1] != 0 && 649 + (pos[1] != ifibss->ssid_len || 650 + memcmp(pos + 2, ifibss->ssid, ifibss->ssid_len) != 0)) { 651 + /* Ignore ProbeReq for foreign SSID */ 652 + return; 653 + } 654 + 655 + /* Reply with ProbeResp */ 656 + skb = skb_copy(ifibss->probe_resp, GFP_KERNEL); 657 + if (!skb) 658 + return; 659 + 660 + resp = (struct ieee80211_mgmt *) skb->data; 661 + memcpy(resp->da, mgmt->sa, ETH_ALEN); 662 + #ifdef CONFIG_MAC80211_IBSS_DEBUG 663 + printk(KERN_DEBUG "%s: Sending ProbeResp to %pM\n", 664 + sdata->dev->name, resp->da); 665 + #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 666 + ieee80211_tx_skb(sdata, skb, 0); 667 + } 668 + 669 + static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, 670 + struct ieee80211_mgmt *mgmt, 671 + size_t len, 672 + struct ieee80211_rx_status *rx_status) 673 + { 674 + size_t baselen; 675 + struct ieee802_11_elems elems; 676 + 677 + if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) 678 + return; /* ignore ProbeResp to foreign address */ 679 + 680 + baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; 681 + if (baselen > len) 682 + return; 683 + 684 + ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, 685 + &elems); 686 + 687 + ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); 688 + } 689 + 690 + static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, 691 + struct ieee80211_mgmt *mgmt, 692 + size_t len, 693 + struct ieee80211_rx_status *rx_status) 694 + { 695 + size_t baselen; 696 + struct ieee802_11_elems elems; 697 + 698 + /* Process beacon from the current BSS */ 699 + baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt; 700 + if (baselen > len) 701 + return; 702 + 703 + ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); 704 + 705 + ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, true); 706 + } 707 + 708 + static void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, 709 + struct sk_buff *skb) 710 + { 711 + struct ieee80211_rx_status *rx_status; 712 + struct ieee80211_mgmt *mgmt; 713 + u16 fc; 714 + 715 + rx_status = (struct ieee80211_rx_status *) skb->cb; 716 + mgmt = (struct ieee80211_mgmt *) skb->data; 717 + fc = le16_to_cpu(mgmt->frame_control); 718 + 719 + switch (fc & IEEE80211_FCTL_STYPE) { 720 + case IEEE80211_STYPE_PROBE_REQ: 721 + ieee80211_rx_mgmt_probe_req(sdata, mgmt, skb->len); 722 + break; 723 + case IEEE80211_STYPE_PROBE_RESP: 724 + ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, 725 + rx_status); 726 + break; 727 + case IEEE80211_STYPE_BEACON: 728 + ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, 729 + rx_status); 730 + break; 731 + case IEEE80211_STYPE_AUTH: 732 + ieee80211_rx_mgmt_auth_ibss(sdata, mgmt, skb->len); 733 + break; 734 + } 735 + 736 + kfree_skb(skb); 737 + } 738 + 739 + static void ieee80211_ibss_work(struct work_struct *work) 740 + { 741 + struct ieee80211_sub_if_data *sdata = 742 + container_of(work, struct ieee80211_sub_if_data, u.ibss.work); 743 + struct ieee80211_local *local = sdata->local; 744 + struct ieee80211_if_ibss *ifibss; 745 + struct sk_buff *skb; 746 + 747 + if (!netif_running(sdata->dev)) 748 + return; 749 + 750 + if (local->sw_scanning || local->hw_scanning) 751 + return; 752 + 753 + if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_ADHOC)) 754 + return; 755 + ifibss = &sdata->u.ibss; 756 + 757 + while ((skb = skb_dequeue(&ifibss->skb_queue))) 758 + ieee80211_ibss_rx_queued_mgmt(sdata, skb); 759 + 760 + if (!test_and_clear_bit(IEEE80211_IBSS_REQ_RUN, &ifibss->request)) 761 + return; 762 + 763 + switch (ifibss->state) { 764 + case IEEE80211_IBSS_MLME_SEARCH: 765 + ieee80211_sta_find_ibss(sdata); 766 + break; 767 + case IEEE80211_IBSS_MLME_JOINED: 768 + ieee80211_sta_merge_ibss(sdata); 769 + break; 770 + default: 771 + WARN_ON(1); 772 + break; 773 + } 774 + } 775 + 776 + static void ieee80211_ibss_timer(unsigned long data) 777 + { 778 + struct ieee80211_sub_if_data *sdata = 779 + (struct ieee80211_sub_if_data *) data; 780 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 781 + struct ieee80211_local *local = sdata->local; 782 + 783 + set_bit(IEEE80211_IBSS_REQ_RUN, &ifibss->request); 784 + queue_work(local->hw.workqueue, &ifibss->work); 785 + } 786 + 787 + void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata) 788 + { 789 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 790 + 791 + INIT_WORK(&ifibss->work, ieee80211_ibss_work); 792 + setup_timer(&ifibss->timer, ieee80211_ibss_timer, 793 + (unsigned long) sdata); 794 + skb_queue_head_init(&ifibss->skb_queue); 795 + 796 + ifibss->flags |= IEEE80211_IBSS_AUTO_BSSID_SEL | 797 + IEEE80211_IBSS_AUTO_CHANNEL_SEL; 798 + } 799 + 800 + int ieee80211_ibss_commit(struct ieee80211_sub_if_data *sdata) 801 + { 802 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 803 + 804 + ifibss->flags &= ~IEEE80211_IBSS_PREV_BSSID_SET; 805 + 806 + if (ifibss->ssid_len) 807 + ifibss->flags |= IEEE80211_IBSS_SSID_SET; 808 + else 809 + ifibss->flags &= ~IEEE80211_IBSS_SSID_SET; 810 + 811 + ifibss->ibss_join_req = jiffies; 812 + ifibss->state = IEEE80211_IBSS_MLME_SEARCH; 813 + 814 + return ieee80211_sta_find_ibss(sdata); 815 + } 816 + 817 + int ieee80211_ibss_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len) 818 + { 819 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 820 + 821 + if (len > IEEE80211_MAX_SSID_LEN) 822 + return -EINVAL; 823 + 824 + if (ifibss->ssid_len != len || memcmp(ifibss->ssid, ssid, len) != 0) { 825 + memset(ifibss->ssid, 0, sizeof(ifibss->ssid)); 826 + memcpy(ifibss->ssid, ssid, len); 827 + ifibss->ssid_len = len; 828 + } 829 + 830 + return ieee80211_ibss_commit(sdata); 831 + } 832 + 833 + int ieee80211_ibss_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len) 834 + { 835 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 836 + 837 + memcpy(ssid, ifibss->ssid, ifibss->ssid_len); 838 + *len = ifibss->ssid_len; 839 + 840 + return 0; 841 + } 842 + 843 + int ieee80211_ibss_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid) 844 + { 845 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 846 + 847 + if (is_valid_ether_addr(bssid)) { 848 + memcpy(ifibss->bssid, bssid, ETH_ALEN); 849 + ifibss->flags |= IEEE80211_IBSS_BSSID_SET; 850 + } else { 851 + memset(ifibss->bssid, 0, ETH_ALEN); 852 + ifibss->flags &= ~IEEE80211_IBSS_BSSID_SET; 853 + } 854 + 855 + if (netif_running(sdata->dev)) { 856 + if (ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID)) { 857 + printk(KERN_DEBUG "%s: Failed to config new BSSID to " 858 + "the low-level driver\n", sdata->dev->name); 859 + } 860 + } 861 + 862 + return ieee80211_ibss_commit(sdata); 863 + } 864 + 865 + /* scan finished notification */ 866 + void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local) 867 + { 868 + struct ieee80211_sub_if_data *sdata = local->scan_sdata; 869 + struct ieee80211_if_ibss *ifibss; 870 + 871 + if (sdata && sdata->vif.type == NL80211_IFTYPE_ADHOC) { 872 + ifibss = &sdata->u.ibss; 873 + if ((!(ifibss->flags & IEEE80211_IBSS_PREV_BSSID_SET)) || 874 + !ieee80211_sta_active_ibss(sdata)) 875 + ieee80211_sta_find_ibss(sdata); 876 + } 877 + } 878 + 879 + ieee80211_rx_result 880 + ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 881 + struct ieee80211_rx_status *rx_status) 882 + { 883 + struct ieee80211_local *local = sdata->local; 884 + struct ieee80211_mgmt *mgmt; 885 + u16 fc; 886 + 887 + if (skb->len < 24) 888 + return RX_DROP_MONITOR; 889 + 890 + mgmt = (struct ieee80211_mgmt *) skb->data; 891 + fc = le16_to_cpu(mgmt->frame_control); 892 + 893 + switch (fc & IEEE80211_FCTL_STYPE) { 894 + case IEEE80211_STYPE_PROBE_RESP: 895 + case IEEE80211_STYPE_BEACON: 896 + memcpy(skb->cb, rx_status, sizeof(*rx_status)); 897 + case IEEE80211_STYPE_PROBE_REQ: 898 + case IEEE80211_STYPE_AUTH: 899 + skb_queue_tail(&sdata->u.ibss.skb_queue, skb); 900 + queue_work(local->hw.workqueue, &sdata->u.ibss.work); 901 + return RX_QUEUED; 902 + } 903 + 904 + return RX_DROP_MONITOR; 905 + }
+101 -39
net/mac80211/ieee80211_i.h
··· 239 239 u8 flags; 240 240 }; 241 241 242 - /* flags used in struct ieee80211_if_sta.flags */ 242 + /* flags used in struct ieee80211_if_managed.flags */ 243 243 #define IEEE80211_STA_SSID_SET BIT(0) 244 244 #define IEEE80211_STA_BSSID_SET BIT(1) 245 245 #define IEEE80211_STA_PREV_BSSID_SET BIT(2) ··· 262 262 #define IEEE80211_STA_REQ_AUTH 2 263 263 #define IEEE80211_STA_REQ_RUN 3 264 264 265 - /* STA/IBSS MLME states */ 266 - enum ieee80211_sta_mlme_state { 267 - IEEE80211_STA_MLME_DISABLED, 268 - IEEE80211_STA_MLME_DIRECT_PROBE, 269 - IEEE80211_STA_MLME_AUTHENTICATE, 270 - IEEE80211_STA_MLME_ASSOCIATE, 271 - IEEE80211_STA_MLME_ASSOCIATED, 272 - IEEE80211_STA_MLME_IBSS_SEARCH, 273 - IEEE80211_STA_MLME_IBSS_JOINED, 274 - }; 275 - 276 265 /* bitfield of allowed auth algs */ 277 266 #define IEEE80211_AUTH_ALG_OPEN BIT(0) 278 267 #define IEEE80211_AUTH_ALG_SHARED_KEY BIT(1) 279 268 #define IEEE80211_AUTH_ALG_LEAP BIT(2) 280 269 281 - struct ieee80211_if_sta { 270 + struct ieee80211_if_managed { 282 271 struct timer_list timer; 283 272 struct timer_list chswitch_timer; 284 273 struct work_struct work; 285 274 struct work_struct chswitch_work; 275 + 286 276 u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; 277 + 287 278 u8 ssid[IEEE80211_MAX_SSID_LEN]; 288 - enum ieee80211_sta_mlme_state state; 289 279 size_t ssid_len; 280 + 281 + enum { 282 + IEEE80211_STA_MLME_DISABLED, 283 + IEEE80211_STA_MLME_DIRECT_PROBE, 284 + IEEE80211_STA_MLME_AUTHENTICATE, 285 + IEEE80211_STA_MLME_ASSOCIATE, 286 + IEEE80211_STA_MLME_ASSOCIATED, 287 + } state; 288 + 290 289 u16 aid; 291 290 u16 ap_capab, capab; 292 291 u8 *extra_ie; /* to be added to the end of AssocReq */ ··· 318 319 IEEE80211_MFP_REQUIRED 319 320 } mfp; /* management frame protection */ 320 321 321 - unsigned long ibss_join_req; 322 - struct sk_buff *probe_resp; /* ProbeResp template for IBSS */ 323 - u32 supp_rates_bits[IEEE80211_NUM_BANDS]; 324 - 325 322 int wmm_last_param_set; 326 323 327 324 /* Extra IE data for management frames */ ··· 335 340 size_t ie_deauth_len; 336 341 u8 *ie_disassoc; 337 342 size_t ie_disassoc_len; 343 + }; 344 + 345 + enum ieee80211_ibss_flags { 346 + IEEE80211_IBSS_AUTO_CHANNEL_SEL = BIT(0), 347 + IEEE80211_IBSS_AUTO_BSSID_SEL = BIT(1), 348 + IEEE80211_IBSS_BSSID_SET = BIT(2), 349 + IEEE80211_IBSS_PREV_BSSID_SET = BIT(3), 350 + IEEE80211_IBSS_SSID_SET = BIT(4), 351 + }; 352 + 353 + enum ieee80211_ibss_request { 354 + IEEE80211_IBSS_REQ_RUN = 0, 355 + }; 356 + 357 + struct ieee80211_if_ibss { 358 + struct timer_list timer; 359 + struct work_struct work; 360 + 361 + struct sk_buff_head skb_queue; 362 + 363 + u8 ssid[IEEE80211_MAX_SSID_LEN]; 364 + u8 ssid_len; 365 + 366 + u32 flags; 367 + 368 + u8 bssid[ETH_ALEN]; 369 + 370 + unsigned long request; 371 + 372 + unsigned long ibss_join_req; 373 + struct sk_buff *probe_resp; /* ProbeResp template for IBSS */ 374 + 375 + enum { 376 + IEEE80211_IBSS_MLME_SEARCH, 377 + IEEE80211_IBSS_MLME_JOINED, 378 + } state; 338 379 }; 339 380 340 381 struct ieee80211_if_mesh { ··· 476 445 struct ieee80211_if_ap ap; 477 446 struct ieee80211_if_wds wds; 478 447 struct ieee80211_if_vlan vlan; 479 - struct ieee80211_if_sta sta; 448 + struct ieee80211_if_managed mgd; 449 + struct ieee80211_if_ibss ibss; 480 450 #ifdef CONFIG_MAC80211_MESH 481 451 struct ieee80211_if_mesh mesh; 482 452 #endif ··· 596 564 enum queue_stop_reason { 597 565 IEEE80211_QUEUE_STOP_REASON_DRIVER, 598 566 IEEE80211_QUEUE_STOP_REASON_PS, 599 - IEEE80211_QUEUE_STOP_REASON_CSA 567 + IEEE80211_QUEUE_STOP_REASON_CSA, 568 + IEEE80211_QUEUE_STOP_REASON_AGGREGATION, 600 569 }; 601 - 602 - /* maximum number of hardware queues we support. */ 603 - #define QD_MAX_QUEUES (IEEE80211_MAX_AMPDU_QUEUES + IEEE80211_MAX_QUEUES) 604 570 605 571 struct ieee80211_master_priv { 606 572 struct ieee80211_local *local; ··· 612 582 613 583 const struct ieee80211_ops *ops; 614 584 615 - unsigned long queue_pool[BITS_TO_LONGS(QD_MAX_QUEUES)]; 616 - unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES]; 585 + /* AC queue corresponding to each AMPDU queue */ 586 + s8 ampdu_ac_queue[IEEE80211_MAX_AMPDU_QUEUES]; 587 + unsigned int amdpu_ac_stop_refcnt[IEEE80211_MAX_AMPDU_QUEUES]; 588 + 589 + unsigned long queue_stop_reasons[IEEE80211_MAX_QUEUES + 590 + IEEE80211_MAX_AMPDU_QUEUES]; 591 + /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */ 617 592 spinlock_t queue_stop_reason_lock; 593 + 618 594 struct net_device *mdev; /* wmaster# - "master" 802.11 device */ 619 595 int open_count; 620 596 int monitors, cooked_mntrs; ··· 924 888 void ieee80211_bss_info_change_notify(struct ieee80211_sub_if_data *sdata, 925 889 u32 changed); 926 890 void ieee80211_configure_filter(struct ieee80211_local *local); 891 + u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); 927 892 928 893 /* wireless extensions */ 929 894 extern const struct iw_handler_def ieee80211_iw_handler_def; 930 895 931 - /* STA/IBSS code */ 896 + /* STA code */ 932 897 void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata); 933 - void ieee80211_scan_work(struct work_struct *work); 934 - void ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 935 - struct ieee80211_rx_status *rx_status); 898 + ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, 899 + struct sk_buff *skb, 900 + struct ieee80211_rx_status *rx_status); 901 + int ieee80211_sta_commit(struct ieee80211_sub_if_data *sdata); 936 902 int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len); 937 903 int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len); 938 904 int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid); 939 - void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata, 940 - struct ieee80211_if_sta *ifsta); 941 - struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 942 - u8 *bssid, u8 *addr, u32 supp_rates); 905 + void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata); 943 906 int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason); 944 907 int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason); 945 - u32 ieee80211_reset_erp_info(struct ieee80211_sub_if_data *sdata); 946 - u32 ieee80211_sta_get_rates(struct ieee80211_local *local, 947 - struct ieee802_11_elems *elems, 948 - enum ieee80211_band band); 949 - void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 950 - u8 *ssid, size_t ssid_len); 951 908 void ieee80211_send_pspoll(struct ieee80211_local *local, 952 909 struct ieee80211_sub_if_data *sdata); 953 910 911 + /* IBSS code */ 912 + int ieee80211_ibss_commit(struct ieee80211_sub_if_data *sdata); 913 + int ieee80211_ibss_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len); 914 + int ieee80211_ibss_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len); 915 + int ieee80211_ibss_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid); 916 + void ieee80211_ibss_notify_scan_completed(struct ieee80211_local *local); 917 + void ieee80211_ibss_setup_sdata(struct ieee80211_sub_if_data *sdata); 918 + ieee80211_rx_result 919 + ieee80211_ibss_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 920 + struct ieee80211_rx_status *rx_status); 921 + struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 922 + u8 *bssid, u8 *addr, u32 supp_rates); 923 + 954 924 /* scan/BSS handling */ 925 + void ieee80211_scan_work(struct work_struct *work); 955 926 int ieee80211_request_scan(struct ieee80211_sub_if_data *sdata, 956 927 struct cfg80211_scan_request *req); 957 928 int ieee80211_scan_results(struct ieee80211_local *local, ··· 1085 1042 enum queue_stop_reason reason); 1086 1043 void ieee80211_stop_queues_by_reason(struct ieee80211_hw *hw, 1087 1044 enum queue_stop_reason reason); 1045 + void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, 1046 + enum queue_stop_reason reason); 1047 + void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue, 1048 + enum queue_stop_reason reason); 1049 + 1050 + void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 1051 + u16 transaction, u16 auth_alg, 1052 + u8 *extra, size_t extra_len, 1053 + const u8 *bssid, int encrypt); 1054 + void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 1055 + u8 *ssid, size_t ssid_len, 1056 + u8 *ie, size_t ie_len); 1057 + 1058 + void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, 1059 + const size_t supp_rates_len, 1060 + const u8 *supp_rates); 1061 + u32 ieee80211_sta_get_rates(struct ieee80211_local *local, 1062 + struct ieee802_11_elems *elems, 1063 + enum ieee80211_band band); 1088 1064 1089 1065 #ifdef CONFIG_MAC80211_NOINLINE 1090 1066 #define debug_noinline noinline
+45 -32
net/mac80211/iface.c
··· 236 236 break; 237 237 case NL80211_IFTYPE_STATION: 238 238 case NL80211_IFTYPE_ADHOC: 239 - sdata->u.sta.flags &= ~IEEE80211_STA_PREV_BSSID_SET; 239 + if (sdata->vif.type == NL80211_IFTYPE_STATION) 240 + sdata->u.mgd.flags &= ~IEEE80211_STA_PREV_BSSID_SET; 241 + else 242 + sdata->u.ibss.flags &= ~IEEE80211_IBSS_PREV_BSSID_SET; 240 243 /* fall through */ 241 244 default: 242 245 conf.vif = &sdata->vif; ··· 324 321 * yet be effective. Trigger execution of ieee80211_sta_work 325 322 * to fix this. 326 323 */ 327 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 328 - sdata->vif.type == NL80211_IFTYPE_ADHOC) { 329 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 330 - queue_work(local->hw.workqueue, &ifsta->work); 331 - } 324 + if (sdata->vif.type == NL80211_IFTYPE_STATION) 325 + queue_work(local->hw.workqueue, &sdata->u.mgd.work); 326 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 327 + queue_work(local->hw.workqueue, &sdata->u.ibss.work); 332 328 333 329 netif_tx_start_all_queues(dev); 334 330 ··· 454 452 netif_addr_unlock_bh(local->mdev); 455 453 break; 456 454 case NL80211_IFTYPE_STATION: 457 - case NL80211_IFTYPE_ADHOC: 458 455 /* Announce that we are leaving the network. */ 459 - if (sdata->u.sta.state != IEEE80211_STA_MLME_DISABLED) 456 + if (sdata->u.mgd.state != IEEE80211_STA_MLME_DISABLED) 460 457 ieee80211_sta_deauthenticate(sdata, 461 458 WLAN_REASON_DEAUTH_LEAVING); 462 - 463 - memset(sdata->u.sta.bssid, 0, ETH_ALEN); 464 - del_timer_sync(&sdata->u.sta.chswitch_timer); 465 - del_timer_sync(&sdata->u.sta.timer); 459 + memset(sdata->u.mgd.bssid, 0, ETH_ALEN); 460 + del_timer_sync(&sdata->u.mgd.chswitch_timer); 461 + del_timer_sync(&sdata->u.mgd.timer); 466 462 /* 467 463 * If the timer fired while we waited for it, it will have 468 464 * requeued the work. Now the work will be running again ··· 468 468 * whether the interface is running, which, at this point, 469 469 * it no longer is. 470 470 */ 471 - cancel_work_sync(&sdata->u.sta.work); 472 - cancel_work_sync(&sdata->u.sta.chswitch_work); 471 + cancel_work_sync(&sdata->u.mgd.work); 472 + cancel_work_sync(&sdata->u.mgd.chswitch_work); 473 473 /* 474 474 * When we get here, the interface is marked down. 475 475 * Call synchronize_rcu() to wait for the RX path ··· 477 477 * frames at this very time on another CPU. 478 478 */ 479 479 synchronize_rcu(); 480 - skb_queue_purge(&sdata->u.sta.skb_queue); 480 + skb_queue_purge(&sdata->u.mgd.skb_queue); 481 481 482 - sdata->u.sta.flags &= ~(IEEE80211_STA_PRIVACY_INVOKED | 482 + sdata->u.mgd.flags &= ~(IEEE80211_STA_PRIVACY_INVOKED | 483 483 IEEE80211_STA_TKIP_WEP_USED); 484 - kfree(sdata->u.sta.extra_ie); 485 - sdata->u.sta.extra_ie = NULL; 486 - sdata->u.sta.extra_ie_len = 0; 484 + kfree(sdata->u.mgd.extra_ie); 485 + sdata->u.mgd.extra_ie = NULL; 486 + sdata->u.mgd.extra_ie_len = 0; 487 + /* fall through */ 488 + case NL80211_IFTYPE_ADHOC: 489 + if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 490 + memset(sdata->u.ibss.bssid, 0, ETH_ALEN); 491 + del_timer_sync(&sdata->u.ibss.timer); 492 + cancel_work_sync(&sdata->u.ibss.work); 493 + synchronize_rcu(); 494 + skb_queue_purge(&sdata->u.ibss.skb_queue); 495 + } 487 496 /* fall through */ 488 497 case NL80211_IFTYPE_MESH_POINT: 489 498 if (ieee80211_vif_is_mesh(&sdata->vif)) { ··· 638 629 if (ieee80211_vif_is_mesh(&sdata->vif)) 639 630 mesh_rmc_free(sdata); 640 631 break; 641 - case NL80211_IFTYPE_STATION: 642 632 case NL80211_IFTYPE_ADHOC: 643 - kfree(sdata->u.sta.extra_ie); 644 - kfree(sdata->u.sta.assocreq_ies); 645 - kfree(sdata->u.sta.assocresp_ies); 646 - kfree_skb(sdata->u.sta.probe_resp); 647 - kfree(sdata->u.sta.ie_probereq); 648 - kfree(sdata->u.sta.ie_proberesp); 649 - kfree(sdata->u.sta.ie_auth); 650 - kfree(sdata->u.sta.ie_assocreq); 651 - kfree(sdata->u.sta.ie_reassocreq); 652 - kfree(sdata->u.sta.ie_deauth); 653 - kfree(sdata->u.sta.ie_disassoc); 633 + kfree_skb(sdata->u.ibss.probe_resp); 634 + break; 635 + case NL80211_IFTYPE_STATION: 636 + kfree(sdata->u.mgd.extra_ie); 637 + kfree(sdata->u.mgd.assocreq_ies); 638 + kfree(sdata->u.mgd.assocresp_ies); 639 + kfree(sdata->u.mgd.ie_probereq); 640 + kfree(sdata->u.mgd.ie_proberesp); 641 + kfree(sdata->u.mgd.ie_auth); 642 + kfree(sdata->u.mgd.ie_assocreq); 643 + kfree(sdata->u.mgd.ie_reassocreq); 644 + kfree(sdata->u.mgd.ie_deauth); 645 + kfree(sdata->u.mgd.ie_disassoc); 654 646 break; 655 647 case NL80211_IFTYPE_WDS: 656 648 case NL80211_IFTYPE_AP_VLAN: ··· 718 708 INIT_LIST_HEAD(&sdata->u.ap.vlans); 719 709 break; 720 710 case NL80211_IFTYPE_STATION: 721 - case NL80211_IFTYPE_ADHOC: 722 711 ieee80211_sta_setup_sdata(sdata); 712 + break; 713 + case NL80211_IFTYPE_ADHOC: 714 + ieee80211_ibss_setup_sdata(sdata); 723 715 break; 724 716 case NL80211_IFTYPE_MESH_POINT: 725 717 if (ieee80211_vif_is_mesh(&sdata->vif)) ··· 810 798 811 799 memcpy(ndev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN); 812 800 SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy)); 801 + ndev->features |= NETIF_F_NETNS_LOCAL; 813 802 814 803 /* don't use IEEE80211_DEV_TO_SUB_IF because it checks too much */ 815 804 sdata = netdev_priv(ndev);
+1 -1
net/mac80211/key.c
··· 400 400 */ 401 401 402 402 /* same here, the AP could be using QoS */ 403 - ap = sta_info_get(key->local, key->sdata->u.sta.bssid); 403 + ap = sta_info_get(key->local, key->sdata->u.mgd.bssid); 404 404 if (ap) { 405 405 if (test_sta_flags(ap, WLAN_STA_WME)) 406 406 key->conf.flags |=
+18 -6
net/mac80211/main.c
··· 169 169 170 170 memset(&conf, 0, sizeof(conf)); 171 171 172 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 173 - sdata->vif.type == NL80211_IFTYPE_ADHOC) 174 - conf.bssid = sdata->u.sta.bssid; 172 + if (sdata->vif.type == NL80211_IFTYPE_STATION) 173 + conf.bssid = sdata->u.mgd.bssid; 174 + else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 175 + conf.bssid = sdata->u.ibss.bssid; 175 176 else if (sdata->vif.type == NL80211_IFTYPE_AP) 176 177 conf.bssid = sdata->dev->dev_addr; 177 178 else if (ieee80211_vif_is_mesh(&sdata->vif)) { ··· 211 210 !!rcu_dereference(sdata->u.ap.beacon); 212 211 break; 213 212 case NL80211_IFTYPE_ADHOC: 214 - conf.enable_beacon = !!sdata->u.sta.probe_resp; 213 + conf.enable_beacon = !!sdata->u.ibss.probe_resp; 215 214 break; 216 215 case NL80211_IFTYPE_MESH_POINT: 217 216 conf.enable_beacon = true; ··· 706 705 const struct ieee80211_ops *ops) 707 706 { 708 707 struct ieee80211_local *local; 709 - int priv_size; 708 + int priv_size, i; 710 709 struct wiphy *wiphy; 711 710 712 711 /* Ensure 32-byte alignment of our private data and hw private data. ··· 779 778 ieee80211_dynamic_ps_disable_work); 780 779 setup_timer(&local->dynamic_ps_timer, 781 780 ieee80211_dynamic_ps_timer, (unsigned long) local); 781 + 782 + for (i = 0; i < IEEE80211_MAX_AMPDU_QUEUES; i++) 783 + local->ampdu_ac_queue[i] = -1; 784 + /* using an s8 won't work with more than that */ 785 + BUILD_BUG_ON(IEEE80211_MAX_AMPDU_QUEUES > 127); 782 786 783 787 sta_info_init(local); 784 788 ··· 861 855 /* mac80211 always supports monitor */ 862 856 local->hw.wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR); 863 857 858 + if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) 859 + local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; 860 + else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) 861 + local->hw.wiphy->signal_type = CFG80211_SIGNAL_TYPE_UNSPEC; 862 + 864 863 result = wiphy_register(local->hw.wiphy); 865 864 if (result < 0) 866 865 goto fail_wiphy_register; ··· 883 872 884 873 mdev = alloc_netdev_mq(sizeof(struct ieee80211_master_priv), 885 874 "wmaster%d", ieee80211_master_setup, 886 - ieee80211_num_queues(hw)); 875 + hw->queues); 887 876 if (!mdev) 888 877 goto fail_mdev_alloc; 889 878 ··· 927 916 928 917 memcpy(local->mdev->dev_addr, local->hw.wiphy->perm_addr, ETH_ALEN); 929 918 SET_NETDEV_DEV(local->mdev, wiphy_dev(local->hw.wiphy)); 919 + local->mdev->features |= NETIF_F_NETNS_LOCAL; 930 920 931 921 result = register_netdevice(local->mdev); 932 922 if (result < 0)
+439 -1232
net/mac80211/mlme.c
··· 15 15 #include <linux/if_ether.h> 16 16 #include <linux/skbuff.h> 17 17 #include <linux/if_arp.h> 18 - #include <linux/wireless.h> 19 - #include <linux/random.h> 20 18 #include <linux/etherdevice.h> 21 19 #include <linux/rtnetlink.h> 22 - #include <net/iw_handler.h> 23 20 #include <net/mac80211.h> 24 21 #include <asm/unaligned.h> 25 22 ··· 32 35 #define IEEE80211_MONITORING_INTERVAL (2 * HZ) 33 36 #define IEEE80211_PROBE_INTERVAL (60 * HZ) 34 37 #define IEEE80211_RETRY_AUTH_INTERVAL (1 * HZ) 35 - #define IEEE80211_SCAN_INTERVAL (2 * HZ) 36 - #define IEEE80211_SCAN_INTERVAL_SLOW (15 * HZ) 37 - #define IEEE80211_IBSS_JOIN_TIMEOUT (7 * HZ) 38 - 39 - #define IEEE80211_IBSS_MERGE_INTERVAL (30 * HZ) 40 - #define IEEE80211_IBSS_INACTIVITY_LIMIT (60 * HZ) 41 - 42 - #define IEEE80211_IBSS_MAX_STA_ENTRIES 128 43 - 44 38 45 39 /* utils */ 46 40 static int ecw2cw(int ecw) ··· 80 92 return count; 81 93 } 82 94 83 - /* also used by mesh code */ 84 - u32 ieee80211_sta_get_rates(struct ieee80211_local *local, 85 - struct ieee802_11_elems *elems, 86 - enum ieee80211_band band) 87 - { 88 - struct ieee80211_supported_band *sband; 89 - struct ieee80211_rate *bitrates; 90 - size_t num_rates; 91 - u32 supp_rates; 92 - int i, j; 93 - sband = local->hw.wiphy->bands[band]; 94 - 95 - if (!sband) { 96 - WARN_ON(1); 97 - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 98 - } 99 - 100 - bitrates = sband->bitrates; 101 - num_rates = sband->n_bitrates; 102 - supp_rates = 0; 103 - for (i = 0; i < elems->supp_rates_len + 104 - elems->ext_supp_rates_len; i++) { 105 - u8 rate = 0; 106 - int own_rate; 107 - if (i < elems->supp_rates_len) 108 - rate = elems->supp_rates[i]; 109 - else if (elems->ext_supp_rates) 110 - rate = elems->ext_supp_rates 111 - [i - elems->supp_rates_len]; 112 - own_rate = 5 * (rate & 0x7f); 113 - for (j = 0; j < num_rates; j++) 114 - if (bitrates[j].bitrate == own_rate) 115 - supp_rates |= BIT(j); 116 - } 117 - return supp_rates; 118 - } 119 - 120 95 /* frame sending functions */ 121 96 122 97 static void add_extra_ies(struct sk_buff *skb, u8 *ies, size_t ies_len) ··· 88 137 memcpy(skb_put(skb, ies_len), ies, ies_len); 89 138 } 90 139 91 - /* also used by scanning code */ 92 - void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 93 - u8 *ssid, size_t ssid_len) 140 + static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata) 94 141 { 95 - struct ieee80211_local *local = sdata->local; 96 - struct ieee80211_supported_band *sband; 97 - struct sk_buff *skb; 98 - struct ieee80211_mgmt *mgmt; 99 - u8 *pos, *supp_rates, *esupp_rates = NULL; 100 - int i; 101 - 102 - skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + 200 + 103 - sdata->u.sta.ie_probereq_len); 104 - if (!skb) { 105 - printk(KERN_DEBUG "%s: failed to allocate buffer for probe " 106 - "request\n", sdata->dev->name); 107 - return; 108 - } 109 - skb_reserve(skb, local->hw.extra_tx_headroom); 110 - 111 - mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); 112 - memset(mgmt, 0, 24); 113 - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 114 - IEEE80211_STYPE_PROBE_REQ); 115 - memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 116 - if (dst) { 117 - memcpy(mgmt->da, dst, ETH_ALEN); 118 - memcpy(mgmt->bssid, dst, ETH_ALEN); 119 - } else { 120 - memset(mgmt->da, 0xff, ETH_ALEN); 121 - memset(mgmt->bssid, 0xff, ETH_ALEN); 122 - } 123 - pos = skb_put(skb, 2 + ssid_len); 124 - *pos++ = WLAN_EID_SSID; 125 - *pos++ = ssid_len; 126 - memcpy(pos, ssid, ssid_len); 127 - 128 - supp_rates = skb_put(skb, 2); 129 - supp_rates[0] = WLAN_EID_SUPP_RATES; 130 - supp_rates[1] = 0; 131 - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 132 - 133 - for (i = 0; i < sband->n_bitrates; i++) { 134 - struct ieee80211_rate *rate = &sband->bitrates[i]; 135 - if (esupp_rates) { 136 - pos = skb_put(skb, 1); 137 - esupp_rates[1]++; 138 - } else if (supp_rates[1] == 8) { 139 - esupp_rates = skb_put(skb, 3); 140 - esupp_rates[0] = WLAN_EID_EXT_SUPP_RATES; 141 - esupp_rates[1] = 1; 142 - pos = &esupp_rates[2]; 143 - } else { 144 - pos = skb_put(skb, 1); 145 - supp_rates[1]++; 146 - } 147 - *pos = rate->bitrate / 5; 148 - } 149 - 150 - add_extra_ies(skb, sdata->u.sta.ie_probereq, 151 - sdata->u.sta.ie_probereq_len); 152 - 153 - ieee80211_tx_skb(sdata, skb, 0); 154 - } 155 - 156 - static void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 157 - struct ieee80211_if_sta *ifsta, 158 - int transaction, u8 *extra, size_t extra_len, 159 - int encrypt) 160 - { 161 - struct ieee80211_local *local = sdata->local; 162 - struct sk_buff *skb; 163 - struct ieee80211_mgmt *mgmt; 164 - 165 - skb = dev_alloc_skb(local->hw.extra_tx_headroom + 166 - sizeof(*mgmt) + 6 + extra_len + 167 - sdata->u.sta.ie_auth_len); 168 - if (!skb) { 169 - printk(KERN_DEBUG "%s: failed to allocate buffer for auth " 170 - "frame\n", sdata->dev->name); 171 - return; 172 - } 173 - skb_reserve(skb, local->hw.extra_tx_headroom); 174 - 175 - mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24 + 6); 176 - memset(mgmt, 0, 24 + 6); 177 - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 178 - IEEE80211_STYPE_AUTH); 179 - if (encrypt) 180 - mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); 181 - memcpy(mgmt->da, ifsta->bssid, ETH_ALEN); 182 - memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 183 - memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); 184 - mgmt->u.auth.auth_alg = cpu_to_le16(ifsta->auth_alg); 185 - mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); 186 - ifsta->auth_transaction = transaction + 1; 187 - mgmt->u.auth.status_code = cpu_to_le16(0); 188 - if (extra) 189 - memcpy(skb_put(skb, extra_len), extra, extra_len); 190 - add_extra_ies(skb, sdata->u.sta.ie_auth, sdata->u.sta.ie_auth_len); 191 - 192 - ieee80211_tx_skb(sdata, skb, encrypt); 193 - } 194 - 195 - static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata, 196 - struct ieee80211_if_sta *ifsta) 197 - { 142 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 198 143 struct ieee80211_local *local = sdata->local; 199 144 struct sk_buff *skb; 200 145 struct ieee80211_mgmt *mgmt; ··· 103 256 u32 rates = 0; 104 257 size_t e_ies_len; 105 258 106 - if (ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) { 107 - e_ies = sdata->u.sta.ie_reassocreq; 108 - e_ies_len = sdata->u.sta.ie_reassocreq_len; 259 + if (ifmgd->flags & IEEE80211_IBSS_PREV_BSSID_SET) { 260 + e_ies = sdata->u.mgd.ie_reassocreq; 261 + e_ies_len = sdata->u.mgd.ie_reassocreq_len; 109 262 } else { 110 - e_ies = sdata->u.sta.ie_assocreq; 111 - e_ies_len = sdata->u.sta.ie_assocreq_len; 263 + e_ies = sdata->u.mgd.ie_assocreq; 264 + e_ies_len = sdata->u.mgd.ie_assocreq_len; 112 265 } 113 266 114 267 skb = dev_alloc_skb(local->hw.extra_tx_headroom + 115 - sizeof(*mgmt) + 200 + ifsta->extra_ie_len + 116 - ifsta->ssid_len + e_ies_len); 268 + sizeof(*mgmt) + 200 + ifmgd->extra_ie_len + 269 + ifmgd->ssid_len + e_ies_len); 117 270 if (!skb) { 118 271 printk(KERN_DEBUG "%s: failed to allocate buffer for assoc " 119 272 "frame\n", sdata->dev->name); ··· 123 276 124 277 sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 125 278 126 - capab = ifsta->capab; 279 + capab = ifmgd->capab; 127 280 128 281 if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ) { 129 282 if (!(local->hw.flags & IEEE80211_HW_2GHZ_SHORT_SLOT_INCAPABLE)) ··· 132 285 capab |= WLAN_CAPABILITY_SHORT_PREAMBLE; 133 286 } 134 287 135 - bss = ieee80211_rx_bss_get(local, ifsta->bssid, 288 + bss = ieee80211_rx_bss_get(local, ifmgd->bssid, 136 289 local->hw.conf.channel->center_freq, 137 - ifsta->ssid, ifsta->ssid_len); 290 + ifmgd->ssid, ifmgd->ssid_len); 138 291 if (bss) { 139 292 if (bss->cbss.capability & WLAN_CAPABILITY_PRIVACY) 140 293 capab |= WLAN_CAPABILITY_PRIVACY; ··· 159 312 160 313 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); 161 314 memset(mgmt, 0, 24); 162 - memcpy(mgmt->da, ifsta->bssid, ETH_ALEN); 315 + memcpy(mgmt->da, ifmgd->bssid, ETH_ALEN); 163 316 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 164 - memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); 317 + memcpy(mgmt->bssid, ifmgd->bssid, ETH_ALEN); 165 318 166 - if (ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) { 319 + if (ifmgd->flags & IEEE80211_STA_PREV_BSSID_SET) { 167 320 skb_put(skb, 10); 168 321 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 169 322 IEEE80211_STYPE_REASSOC_REQ); 170 323 mgmt->u.reassoc_req.capab_info = cpu_to_le16(capab); 171 324 mgmt->u.reassoc_req.listen_interval = 172 325 cpu_to_le16(local->hw.conf.listen_interval); 173 - memcpy(mgmt->u.reassoc_req.current_ap, ifsta->prev_bssid, 326 + memcpy(mgmt->u.reassoc_req.current_ap, ifmgd->prev_bssid, 174 327 ETH_ALEN); 175 328 } else { 176 329 skb_put(skb, 4); ··· 182 335 } 183 336 184 337 /* SSID */ 185 - ies = pos = skb_put(skb, 2 + ifsta->ssid_len); 338 + ies = pos = skb_put(skb, 2 + ifmgd->ssid_len); 186 339 *pos++ = WLAN_EID_SSID; 187 - *pos++ = ifsta->ssid_len; 188 - memcpy(pos, ifsta->ssid, ifsta->ssid_len); 340 + *pos++ = ifmgd->ssid_len; 341 + memcpy(pos, ifmgd->ssid, ifmgd->ssid_len); 189 342 190 343 /* add all rates which were marked to be used above */ 191 344 supp_rates_len = rates_len; ··· 240 393 } 241 394 } 242 395 243 - if (ifsta->extra_ie) { 244 - pos = skb_put(skb, ifsta->extra_ie_len); 245 - memcpy(pos, ifsta->extra_ie, ifsta->extra_ie_len); 396 + if (ifmgd->extra_ie) { 397 + pos = skb_put(skb, ifmgd->extra_ie_len); 398 + memcpy(pos, ifmgd->extra_ie, ifmgd->extra_ie_len); 246 399 } 247 400 248 - if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) { 401 + if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) { 249 402 pos = skb_put(skb, 9); 250 403 *pos++ = WLAN_EID_VENDOR_SPECIFIC; 251 404 *pos++ = 7; /* len */ ··· 265 418 * mode (11a/b/g) if any one of these ciphers is 266 419 * configured as pairwise. 267 420 */ 268 - if (wmm && (ifsta->flags & IEEE80211_STA_WMM_ENABLED) && 421 + if (wmm && (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && 269 422 sband->ht_cap.ht_supported && 270 423 (ht_ie = ieee80211_bss_get_ie(bss, WLAN_EID_HT_INFORMATION)) && 271 424 ht_ie[1] >= sizeof(struct ieee80211_ht_info) && 272 - (!(ifsta->flags & IEEE80211_STA_TKIP_WEP_USED))) { 425 + (!(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED))) { 273 426 struct ieee80211_ht_info *ht_info = 274 427 (struct ieee80211_ht_info *)(ht_ie + 2); 275 428 u16 cap = sband->ht_cap.cap; ··· 306 459 307 460 add_extra_ies(skb, e_ies, e_ies_len); 308 461 309 - kfree(ifsta->assocreq_ies); 310 - ifsta->assocreq_ies_len = (skb->data + skb->len) - ies; 311 - ifsta->assocreq_ies = kmalloc(ifsta->assocreq_ies_len, GFP_KERNEL); 312 - if (ifsta->assocreq_ies) 313 - memcpy(ifsta->assocreq_ies, ies, ifsta->assocreq_ies_len); 462 + kfree(ifmgd->assocreq_ies); 463 + ifmgd->assocreq_ies_len = (skb->data + skb->len) - ies; 464 + ifmgd->assocreq_ies = kmalloc(ifmgd->assocreq_ies_len, GFP_KERNEL); 465 + if (ifmgd->assocreq_ies) 466 + memcpy(ifmgd->assocreq_ies, ies, ifmgd->assocreq_ies_len); 314 467 315 468 ieee80211_tx_skb(sdata, skb, 0); 316 469 } ··· 320 473 u16 stype, u16 reason) 321 474 { 322 475 struct ieee80211_local *local = sdata->local; 323 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 476 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 324 477 struct sk_buff *skb; 325 478 struct ieee80211_mgmt *mgmt; 326 479 u8 *ies; 327 480 size_t ies_len; 328 481 329 482 if (stype == IEEE80211_STYPE_DEAUTH) { 330 - ies = sdata->u.sta.ie_deauth; 331 - ies_len = sdata->u.sta.ie_deauth_len; 483 + ies = sdata->u.mgd.ie_deauth; 484 + ies_len = sdata->u.mgd.ie_deauth_len; 332 485 } else { 333 - ies = sdata->u.sta.ie_disassoc; 334 - ies_len = sdata->u.sta.ie_disassoc_len; 486 + ies = sdata->u.mgd.ie_disassoc; 487 + ies_len = sdata->u.mgd.ie_disassoc_len; 335 488 } 336 489 337 490 skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + ··· 345 498 346 499 mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); 347 500 memset(mgmt, 0, 24); 348 - memcpy(mgmt->da, ifsta->bssid, ETH_ALEN); 501 + memcpy(mgmt->da, ifmgd->bssid, ETH_ALEN); 349 502 memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 350 - memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); 503 + memcpy(mgmt->bssid, ifmgd->bssid, ETH_ALEN); 351 504 mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | stype); 352 505 skb_put(skb, 2); 353 506 /* u.deauth.reason_code == u.disassoc.reason_code */ ··· 355 508 356 509 add_extra_ies(skb, ies, ies_len); 357 510 358 - ieee80211_tx_skb(sdata, skb, ifsta->flags & IEEE80211_STA_MFP_ENABLED); 511 + ieee80211_tx_skb(sdata, skb, ifmgd->flags & IEEE80211_STA_MFP_ENABLED); 359 512 } 360 513 361 514 void ieee80211_send_pspoll(struct ieee80211_local *local, 362 515 struct ieee80211_sub_if_data *sdata) 363 516 { 364 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 517 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 365 518 struct ieee80211_pspoll *pspoll; 366 519 struct sk_buff *skb; 367 520 u16 fc; ··· 378 531 memset(pspoll, 0, sizeof(*pspoll)); 379 532 fc = IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL | IEEE80211_FCTL_PM; 380 533 pspoll->frame_control = cpu_to_le16(fc); 381 - pspoll->aid = cpu_to_le16(ifsta->aid); 534 + pspoll->aid = cpu_to_le16(ifmgd->aid); 382 535 383 536 /* aid in PS-Poll has its two MSBs each set to 1 */ 384 537 pspoll->aid |= cpu_to_le16(1 << 15 | 1 << 14); 385 538 386 - memcpy(pspoll->bssid, ifsta->bssid, ETH_ALEN); 539 + memcpy(pspoll->bssid, ifmgd->bssid, ETH_ALEN); 387 540 memcpy(pspoll->ta, sdata->dev->dev_addr, ETH_ALEN); 388 541 389 542 ieee80211_tx_skb(sdata, skb, 0); 390 - 391 - return; 392 543 } 393 544 394 545 /* MLME */ 395 - static void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, 396 - const size_t supp_rates_len, 397 - const u8 *supp_rates) 398 - { 399 - struct ieee80211_local *local = sdata->local; 400 - int i, have_higher_than_11mbit = 0; 401 - 402 - /* cf. IEEE 802.11 9.2.12 */ 403 - for (i = 0; i < supp_rates_len; i++) 404 - if ((supp_rates[i] & 0x7f) * 5 > 110) 405 - have_higher_than_11mbit = 1; 406 - 407 - if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && 408 - have_higher_than_11mbit) 409 - sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; 410 - else 411 - sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; 412 - 413 - ieee80211_set_wmm_default(sdata); 414 - } 415 - 416 546 static void ieee80211_sta_wmm_params(struct ieee80211_local *local, 417 - struct ieee80211_if_sta *ifsta, 547 + struct ieee80211_if_managed *ifmgd, 418 548 u8 *wmm_param, size_t wmm_param_len) 419 549 { 420 550 struct ieee80211_tx_queue_params params; ··· 399 575 int count; 400 576 u8 *pos; 401 577 402 - if (!(ifsta->flags & IEEE80211_STA_WMM_ENABLED)) 578 + if (!(ifmgd->flags & IEEE80211_STA_WMM_ENABLED)) 403 579 return; 404 580 405 581 if (!wmm_param) ··· 408 584 if (wmm_param_len < 8 || wmm_param[5] /* version */ != 1) 409 585 return; 410 586 count = wmm_param[6] & 0x0f; 411 - if (count == ifsta->wmm_last_param_set) 587 + if (count == ifmgd->wmm_last_param_set) 412 588 return; 413 - ifsta->wmm_last_param_set = count; 589 + ifmgd->wmm_last_param_set = count; 414 590 415 591 pos = wmm_param + 8; 416 592 left = wmm_param_len - 8; ··· 495 671 { 496 672 struct ieee80211_bss_conf *bss_conf = &sdata->vif.bss_conf; 497 673 #ifdef CONFIG_MAC80211_VERBOSE_DEBUG 498 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 674 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 499 675 #endif 500 676 u32 changed = 0; 501 677 bool use_protection; ··· 518 694 printk(KERN_DEBUG "%s: CTS protection %s (BSSID=%pM)\n", 519 695 sdata->dev->name, 520 696 use_protection ? "enabled" : "disabled", 521 - ifsta->bssid); 697 + ifmgd->bssid); 522 698 } 523 699 #endif 524 700 bss_conf->use_cts_prot = use_protection; ··· 532 708 " (BSSID=%pM)\n", 533 709 sdata->dev->name, 534 710 use_short_preamble ? "short" : "long", 535 - ifsta->bssid); 711 + ifmgd->bssid); 536 712 } 537 713 #endif 538 714 bss_conf->use_short_preamble = use_short_preamble; ··· 546 722 " (BSSID=%pM)\n", 547 723 sdata->dev->name, 548 724 use_short_slot ? "short" : "long", 549 - ifsta->bssid); 725 + ifmgd->bssid); 550 726 } 551 727 #endif 552 728 bss_conf->use_short_slot = use_short_slot; ··· 556 732 return changed; 557 733 } 558 734 559 - static void ieee80211_sta_send_apinfo(struct ieee80211_sub_if_data *sdata, 560 - struct ieee80211_if_sta *ifsta) 735 + static void ieee80211_sta_send_apinfo(struct ieee80211_sub_if_data *sdata) 561 736 { 562 737 union iwreq_data wrqu; 738 + 563 739 memset(&wrqu, 0, sizeof(wrqu)); 564 - if (ifsta->flags & IEEE80211_STA_ASSOCIATED) 565 - memcpy(wrqu.ap_addr.sa_data, sdata->u.sta.bssid, ETH_ALEN); 740 + if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) 741 + memcpy(wrqu.ap_addr.sa_data, sdata->u.mgd.bssid, ETH_ALEN); 566 742 wrqu.ap_addr.sa_family = ARPHRD_ETHER; 567 743 wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL); 568 744 } 569 745 570 - static void ieee80211_sta_send_associnfo(struct ieee80211_sub_if_data *sdata, 571 - struct ieee80211_if_sta *ifsta) 746 + static void ieee80211_sta_send_associnfo(struct ieee80211_sub_if_data *sdata) 572 747 { 748 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 573 749 char *buf; 574 750 size_t len; 575 751 int i; 576 752 union iwreq_data wrqu; 577 753 578 - if (!ifsta->assocreq_ies && !ifsta->assocresp_ies) 754 + if (!ifmgd->assocreq_ies && !ifmgd->assocresp_ies) 579 755 return; 580 756 581 - buf = kmalloc(50 + 2 * (ifsta->assocreq_ies_len + 582 - ifsta->assocresp_ies_len), GFP_KERNEL); 757 + buf = kmalloc(50 + 2 * (ifmgd->assocreq_ies_len + 758 + ifmgd->assocresp_ies_len), GFP_KERNEL); 583 759 if (!buf) 584 760 return; 585 761 586 762 len = sprintf(buf, "ASSOCINFO("); 587 - if (ifsta->assocreq_ies) { 763 + if (ifmgd->assocreq_ies) { 588 764 len += sprintf(buf + len, "ReqIEs="); 589 - for (i = 0; i < ifsta->assocreq_ies_len; i++) { 765 + for (i = 0; i < ifmgd->assocreq_ies_len; i++) { 590 766 len += sprintf(buf + len, "%02x", 591 - ifsta->assocreq_ies[i]); 767 + ifmgd->assocreq_ies[i]); 592 768 } 593 769 } 594 - if (ifsta->assocresp_ies) { 595 - if (ifsta->assocreq_ies) 770 + if (ifmgd->assocresp_ies) { 771 + if (ifmgd->assocreq_ies) 596 772 len += sprintf(buf + len, " "); 597 773 len += sprintf(buf + len, "RespIEs="); 598 - for (i = 0; i < ifsta->assocresp_ies_len; i++) { 774 + for (i = 0; i < ifmgd->assocresp_ies_len; i++) { 599 775 len += sprintf(buf + len, "%02x", 600 - ifsta->assocresp_ies[i]); 776 + ifmgd->assocresp_ies[i]); 601 777 } 602 778 } 603 779 len += sprintf(buf + len, ")"); 604 780 605 781 if (len > IW_CUSTOM_MAX) { 606 782 len = sprintf(buf, "ASSOCRESPIE="); 607 - for (i = 0; i < ifsta->assocresp_ies_len; i++) { 783 + for (i = 0; i < ifmgd->assocresp_ies_len; i++) { 608 784 len += sprintf(buf + len, "%02x", 609 - ifsta->assocresp_ies[i]); 785 + ifmgd->assocresp_ies[i]); 610 786 } 611 787 } 612 788 ··· 621 797 622 798 623 799 static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, 624 - struct ieee80211_if_sta *ifsta, 625 800 u32 bss_info_changed) 626 801 { 802 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 627 803 struct ieee80211_local *local = sdata->local; 628 804 struct ieee80211_conf *conf = &local_to_hw(local)->conf; 629 805 630 806 struct ieee80211_bss *bss; 631 807 632 808 bss_info_changed |= BSS_CHANGED_ASSOC; 633 - ifsta->flags |= IEEE80211_STA_ASSOCIATED; 809 + ifmgd->flags |= IEEE80211_STA_ASSOCIATED; 634 810 635 - bss = ieee80211_rx_bss_get(local, ifsta->bssid, 811 + bss = ieee80211_rx_bss_get(local, ifmgd->bssid, 636 812 conf->channel->center_freq, 637 - ifsta->ssid, ifsta->ssid_len); 813 + ifmgd->ssid, ifmgd->ssid_len); 638 814 if (bss) { 639 815 /* set timing information */ 640 816 sdata->vif.bss_conf.beacon_int = bss->cbss.beacon_interval; ··· 647 823 ieee80211_rx_bss_put(local, bss); 648 824 } 649 825 650 - ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET; 651 - memcpy(ifsta->prev_bssid, sdata->u.sta.bssid, ETH_ALEN); 652 - ieee80211_sta_send_associnfo(sdata, ifsta); 826 + ifmgd->flags |= IEEE80211_STA_PREV_BSSID_SET; 827 + memcpy(ifmgd->prev_bssid, sdata->u.mgd.bssid, ETH_ALEN); 828 + ieee80211_sta_send_associnfo(sdata); 653 829 654 - ifsta->last_probe = jiffies; 830 + ifmgd->last_probe = jiffies; 655 831 ieee80211_led_assoc(local, 1); 656 832 657 833 sdata->vif.bss_conf.assoc = 1; ··· 680 856 netif_tx_start_all_queues(sdata->dev); 681 857 netif_carrier_on(sdata->dev); 682 858 683 - ieee80211_sta_send_apinfo(sdata, ifsta); 859 + ieee80211_sta_send_apinfo(sdata); 684 860 } 685 861 686 - static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata, 687 - struct ieee80211_if_sta *ifsta) 862 + static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata) 688 863 { 689 - ifsta->direct_probe_tries++; 690 - if (ifsta->direct_probe_tries > IEEE80211_AUTH_MAX_TRIES) { 864 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 865 + 866 + ifmgd->direct_probe_tries++; 867 + if (ifmgd->direct_probe_tries > IEEE80211_AUTH_MAX_TRIES) { 691 868 printk(KERN_DEBUG "%s: direct probe to AP %pM timed out\n", 692 - sdata->dev->name, ifsta->bssid); 693 - ifsta->state = IEEE80211_STA_MLME_DISABLED; 694 - ieee80211_sta_send_apinfo(sdata, ifsta); 869 + sdata->dev->name, ifmgd->bssid); 870 + ifmgd->state = IEEE80211_STA_MLME_DISABLED; 871 + ieee80211_sta_send_apinfo(sdata); 695 872 696 873 /* 697 874 * Most likely AP is not in the range so remove the 698 875 * bss information associated to the AP 699 876 */ 700 - ieee80211_rx_bss_remove(sdata, ifsta->bssid, 877 + ieee80211_rx_bss_remove(sdata, ifmgd->bssid, 701 878 sdata->local->hw.conf.channel->center_freq, 702 - ifsta->ssid, ifsta->ssid_len); 879 + ifmgd->ssid, ifmgd->ssid_len); 703 880 return; 704 881 } 705 882 706 883 printk(KERN_DEBUG "%s: direct probe to AP %pM try %d\n", 707 - sdata->dev->name, ifsta->bssid, 708 - ifsta->direct_probe_tries); 884 + sdata->dev->name, ifmgd->bssid, 885 + ifmgd->direct_probe_tries); 709 886 710 - ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE; 887 + ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE; 711 888 712 - set_bit(IEEE80211_STA_REQ_DIRECT_PROBE, &ifsta->request); 889 + set_bit(IEEE80211_STA_REQ_DIRECT_PROBE, &ifmgd->request); 713 890 714 891 /* Direct probe is sent to broadcast address as some APs 715 892 * will not answer to direct packet in unassociated state. 716 893 */ 717 894 ieee80211_send_probe_req(sdata, NULL, 718 - ifsta->ssid, ifsta->ssid_len); 895 + ifmgd->ssid, ifmgd->ssid_len, NULL, 0); 719 896 720 - mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); 897 + mod_timer(&ifmgd->timer, jiffies + IEEE80211_AUTH_TIMEOUT); 721 898 } 722 899 723 900 724 - static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata, 725 - struct ieee80211_if_sta *ifsta) 901 + static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata) 726 902 { 727 - ifsta->auth_tries++; 728 - if (ifsta->auth_tries > IEEE80211_AUTH_MAX_TRIES) { 903 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 904 + 905 + ifmgd->auth_tries++; 906 + if (ifmgd->auth_tries > IEEE80211_AUTH_MAX_TRIES) { 729 907 printk(KERN_DEBUG "%s: authentication with AP %pM" 730 908 " timed out\n", 731 - sdata->dev->name, ifsta->bssid); 732 - ifsta->state = IEEE80211_STA_MLME_DISABLED; 733 - ieee80211_sta_send_apinfo(sdata, ifsta); 734 - ieee80211_rx_bss_remove(sdata, ifsta->bssid, 909 + sdata->dev->name, ifmgd->bssid); 910 + ifmgd->state = IEEE80211_STA_MLME_DISABLED; 911 + ieee80211_sta_send_apinfo(sdata); 912 + ieee80211_rx_bss_remove(sdata, ifmgd->bssid, 735 913 sdata->local->hw.conf.channel->center_freq, 736 - ifsta->ssid, ifsta->ssid_len); 914 + ifmgd->ssid, ifmgd->ssid_len); 737 915 return; 738 916 } 739 917 740 - ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; 918 + ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE; 741 919 printk(KERN_DEBUG "%s: authenticate with AP %pM\n", 742 - sdata->dev->name, ifsta->bssid); 920 + sdata->dev->name, ifmgd->bssid); 743 921 744 - ieee80211_send_auth(sdata, ifsta, 1, NULL, 0, 0); 922 + ieee80211_send_auth(sdata, 1, ifmgd->auth_alg, NULL, 0, 923 + ifmgd->bssid, 0); 924 + ifmgd->auth_transaction = 2; 745 925 746 - mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); 926 + mod_timer(&ifmgd->timer, jiffies + IEEE80211_AUTH_TIMEOUT); 747 927 } 748 928 749 929 /* ··· 755 927 * if self disconnected or a reason code from the AP. 756 928 */ 757 929 static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, 758 - struct ieee80211_if_sta *ifsta, bool deauth, 759 - bool self_disconnected, u16 reason) 930 + bool deauth, bool self_disconnected, 931 + u16 reason) 760 932 { 933 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 761 934 struct ieee80211_local *local = sdata->local; 762 935 struct sta_info *sta; 763 936 u32 changed = 0, config_changed = 0; 764 937 765 938 rcu_read_lock(); 766 939 767 - sta = sta_info_get(local, ifsta->bssid); 940 + sta = sta_info_get(local, ifmgd->bssid); 768 941 if (!sta) { 769 942 rcu_read_unlock(); 770 943 return; 771 944 } 772 945 773 946 if (deauth) { 774 - ifsta->direct_probe_tries = 0; 775 - ifsta->auth_tries = 0; 947 + ifmgd->direct_probe_tries = 0; 948 + ifmgd->auth_tries = 0; 776 949 } 777 - ifsta->assoc_scan_tries = 0; 778 - ifsta->assoc_tries = 0; 950 + ifmgd->assoc_scan_tries = 0; 951 + ifmgd->assoc_tries = 0; 779 952 780 953 netif_tx_stop_all_queues(sdata->dev); 781 954 netif_carrier_off(sdata->dev); ··· 792 963 IEEE80211_STYPE_DISASSOC, reason); 793 964 } 794 965 795 - ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; 966 + ifmgd->flags &= ~IEEE80211_STA_ASSOCIATED; 796 967 changed |= ieee80211_reset_erp_info(sdata); 797 968 798 969 ieee80211_led_assoc(local, 0); 799 970 changed |= BSS_CHANGED_ASSOC; 800 971 sdata->vif.bss_conf.assoc = false; 801 972 802 - ieee80211_sta_send_apinfo(sdata, ifsta); 973 + ieee80211_sta_send_apinfo(sdata); 803 974 804 975 if (self_disconnected || reason == WLAN_REASON_DISASSOC_STA_HAS_LEFT) { 805 - ifsta->state = IEEE80211_STA_MLME_DISABLED; 806 - ieee80211_rx_bss_remove(sdata, ifsta->bssid, 976 + ifmgd->state = IEEE80211_STA_MLME_DISABLED; 977 + ieee80211_rx_bss_remove(sdata, ifmgd->bssid, 807 978 sdata->local->hw.conf.channel->center_freq, 808 - ifsta->ssid, ifsta->ssid_len); 979 + ifmgd->ssid, ifmgd->ssid_len); 809 980 } 810 981 811 982 rcu_read_unlock(); ··· 828 999 829 1000 rcu_read_lock(); 830 1001 831 - sta = sta_info_get(local, ifsta->bssid); 1002 + sta = sta_info_get(local, ifmgd->bssid); 832 1003 if (!sta) { 833 1004 rcu_read_unlock(); 834 1005 return; ··· 849 1020 return 1; 850 1021 } 851 1022 852 - static int ieee80211_privacy_mismatch(struct ieee80211_sub_if_data *sdata, 853 - struct ieee80211_if_sta *ifsta) 1023 + static int ieee80211_privacy_mismatch(struct ieee80211_sub_if_data *sdata) 854 1024 { 1025 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 855 1026 struct ieee80211_local *local = sdata->local; 856 1027 struct ieee80211_bss *bss; 857 1028 int bss_privacy; 858 1029 int wep_privacy; 859 1030 int privacy_invoked; 860 1031 861 - if (!ifsta || (ifsta->flags & IEEE80211_STA_MIXED_CELL)) 1032 + if (!ifmgd || (ifmgd->flags & IEEE80211_STA_MIXED_CELL)) 862 1033 return 0; 863 1034 864 - bss = ieee80211_rx_bss_get(local, ifsta->bssid, 1035 + bss = ieee80211_rx_bss_get(local, ifmgd->bssid, 865 1036 local->hw.conf.channel->center_freq, 866 - ifsta->ssid, ifsta->ssid_len); 1037 + ifmgd->ssid, ifmgd->ssid_len); 867 1038 if (!bss) 868 1039 return 0; 869 1040 870 1041 bss_privacy = !!(bss->cbss.capability & WLAN_CAPABILITY_PRIVACY); 871 1042 wep_privacy = !!ieee80211_sta_wep_configured(sdata); 872 - privacy_invoked = !!(ifsta->flags & IEEE80211_STA_PRIVACY_INVOKED); 1043 + privacy_invoked = !!(ifmgd->flags & IEEE80211_STA_PRIVACY_INVOKED); 873 1044 874 1045 ieee80211_rx_bss_put(local, bss); 875 1046 ··· 879 1050 return 1; 880 1051 } 881 1052 882 - static void ieee80211_associate(struct ieee80211_sub_if_data *sdata, 883 - struct ieee80211_if_sta *ifsta) 1053 + static void ieee80211_associate(struct ieee80211_sub_if_data *sdata) 884 1054 { 885 - ifsta->assoc_tries++; 886 - if (ifsta->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) { 1055 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1056 + 1057 + ifmgd->assoc_tries++; 1058 + if (ifmgd->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) { 887 1059 printk(KERN_DEBUG "%s: association with AP %pM" 888 1060 " timed out\n", 889 - sdata->dev->name, ifsta->bssid); 890 - ifsta->state = IEEE80211_STA_MLME_DISABLED; 891 - ieee80211_sta_send_apinfo(sdata, ifsta); 892 - ieee80211_rx_bss_remove(sdata, ifsta->bssid, 1061 + sdata->dev->name, ifmgd->bssid); 1062 + ifmgd->state = IEEE80211_STA_MLME_DISABLED; 1063 + ieee80211_sta_send_apinfo(sdata); 1064 + ieee80211_rx_bss_remove(sdata, ifmgd->bssid, 893 1065 sdata->local->hw.conf.channel->center_freq, 894 - ifsta->ssid, ifsta->ssid_len); 1066 + ifmgd->ssid, ifmgd->ssid_len); 895 1067 return; 896 1068 } 897 1069 898 - ifsta->state = IEEE80211_STA_MLME_ASSOCIATE; 1070 + ifmgd->state = IEEE80211_STA_MLME_ASSOCIATE; 899 1071 printk(KERN_DEBUG "%s: associate with AP %pM\n", 900 - sdata->dev->name, ifsta->bssid); 901 - if (ieee80211_privacy_mismatch(sdata, ifsta)) { 1072 + sdata->dev->name, ifmgd->bssid); 1073 + if (ieee80211_privacy_mismatch(sdata)) { 902 1074 printk(KERN_DEBUG "%s: mismatch in privacy configuration and " 903 1075 "mixed-cell disabled - abort association\n", sdata->dev->name); 904 - ifsta->state = IEEE80211_STA_MLME_DISABLED; 1076 + ifmgd->state = IEEE80211_STA_MLME_DISABLED; 905 1077 return; 906 1078 } 907 1079 908 - ieee80211_send_assoc(sdata, ifsta); 1080 + ieee80211_send_assoc(sdata); 909 1081 910 - mod_timer(&ifsta->timer, jiffies + IEEE80211_ASSOC_TIMEOUT); 1082 + mod_timer(&ifmgd->timer, jiffies + IEEE80211_ASSOC_TIMEOUT); 911 1083 } 912 1084 913 1085 914 - static void ieee80211_associated(struct ieee80211_sub_if_data *sdata, 915 - struct ieee80211_if_sta *ifsta) 1086 + static void ieee80211_associated(struct ieee80211_sub_if_data *sdata) 916 1087 { 1088 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 917 1089 struct ieee80211_local *local = sdata->local; 918 1090 struct sta_info *sta; 919 1091 int disassoc; ··· 924 1094 * for better APs. */ 925 1095 /* TODO: remove expired BSSes */ 926 1096 927 - ifsta->state = IEEE80211_STA_MLME_ASSOCIATED; 1097 + ifmgd->state = IEEE80211_STA_MLME_ASSOCIATED; 928 1098 929 1099 rcu_read_lock(); 930 1100 931 - sta = sta_info_get(local, ifsta->bssid); 1101 + sta = sta_info_get(local, ifmgd->bssid); 932 1102 if (!sta) { 933 1103 printk(KERN_DEBUG "%s: No STA entry for own AP %pM\n", 934 - sdata->dev->name, ifsta->bssid); 1104 + sdata->dev->name, ifmgd->bssid); 935 1105 disassoc = 1; 936 1106 } else { 937 1107 disassoc = 0; 938 1108 if (time_after(jiffies, 939 1109 sta->last_rx + IEEE80211_MONITORING_INTERVAL)) { 940 - if (ifsta->flags & IEEE80211_STA_PROBEREQ_POLL) { 1110 + if (ifmgd->flags & IEEE80211_STA_PROBEREQ_POLL) { 941 1111 printk(KERN_DEBUG "%s: No ProbeResp from " 942 1112 "current AP %pM - assume out of " 943 1113 "range\n", 944 - sdata->dev->name, ifsta->bssid); 1114 + sdata->dev->name, ifmgd->bssid); 945 1115 disassoc = 1; 946 1116 } else 947 - ieee80211_send_probe_req(sdata, ifsta->bssid, 948 - ifsta->ssid, 949 - ifsta->ssid_len); 950 - ifsta->flags ^= IEEE80211_STA_PROBEREQ_POLL; 1117 + ieee80211_send_probe_req(sdata, ifmgd->bssid, 1118 + ifmgd->ssid, 1119 + ifmgd->ssid_len, 1120 + NULL, 0); 1121 + ifmgd->flags ^= IEEE80211_STA_PROBEREQ_POLL; 951 1122 } else { 952 - ifsta->flags &= ~IEEE80211_STA_PROBEREQ_POLL; 953 - if (time_after(jiffies, ifsta->last_probe + 1123 + ifmgd->flags &= ~IEEE80211_STA_PROBEREQ_POLL; 1124 + if (time_after(jiffies, ifmgd->last_probe + 954 1125 IEEE80211_PROBE_INTERVAL)) { 955 - ifsta->last_probe = jiffies; 956 - ieee80211_send_probe_req(sdata, ifsta->bssid, 957 - ifsta->ssid, 958 - ifsta->ssid_len); 1126 + ifmgd->last_probe = jiffies; 1127 + ieee80211_send_probe_req(sdata, ifmgd->bssid, 1128 + ifmgd->ssid, 1129 + ifmgd->ssid_len, 1130 + NULL, 0); 959 1131 } 960 1132 } 961 1133 } ··· 965 1133 rcu_read_unlock(); 966 1134 967 1135 if (disassoc) 968 - ieee80211_set_disassoc(sdata, ifsta, true, true, 1136 + ieee80211_set_disassoc(sdata, true, true, 969 1137 WLAN_REASON_PREV_AUTH_NOT_VALID); 970 1138 else 971 - mod_timer(&ifsta->timer, jiffies + 1139 + mod_timer(&ifmgd->timer, jiffies + 972 1140 IEEE80211_MONITORING_INTERVAL); 973 1141 } 974 1142 975 1143 976 - static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata, 977 - struct ieee80211_if_sta *ifsta) 1144 + static void ieee80211_auth_completed(struct ieee80211_sub_if_data *sdata) 978 1145 { 1146 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1147 + 979 1148 printk(KERN_DEBUG "%s: authenticated\n", sdata->dev->name); 980 - ifsta->flags |= IEEE80211_STA_AUTHENTICATED; 981 - ieee80211_associate(sdata, ifsta); 1149 + ifmgd->flags |= IEEE80211_STA_AUTHENTICATED; 1150 + ieee80211_associate(sdata); 982 1151 } 983 1152 984 1153 985 1154 static void ieee80211_auth_challenge(struct ieee80211_sub_if_data *sdata, 986 - struct ieee80211_if_sta *ifsta, 987 1155 struct ieee80211_mgmt *mgmt, 988 1156 size_t len) 989 1157 { ··· 994 1162 ieee802_11_parse_elems(pos, len - (pos - (u8 *) mgmt), &elems); 995 1163 if (!elems.challenge) 996 1164 return; 997 - ieee80211_send_auth(sdata, ifsta, 3, elems.challenge - 2, 998 - elems.challenge_len + 2, 1); 999 - } 1000 - 1001 - static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, 1002 - struct ieee80211_if_sta *ifsta, 1003 - struct ieee80211_mgmt *mgmt, 1004 - size_t len) 1005 - { 1006 - u16 auth_alg, auth_transaction, status_code; 1007 - 1008 - if (len < 24 + 6) 1009 - return; 1010 - 1011 - auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); 1012 - auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); 1013 - status_code = le16_to_cpu(mgmt->u.auth.status_code); 1014 - 1015 - /* 1016 - * IEEE 802.11 standard does not require authentication in IBSS 1017 - * networks and most implementations do not seem to use it. 1018 - * However, try to reply to authentication attempts if someone 1019 - * has actually implemented this. 1020 - */ 1021 - if (auth_alg == WLAN_AUTH_OPEN && auth_transaction == 1) 1022 - ieee80211_send_auth(sdata, ifsta, 2, NULL, 0, 0); 1165 + ieee80211_send_auth(sdata, 3, sdata->u.mgd.auth_alg, 1166 + elems.challenge - 2, elems.challenge_len + 2, 1167 + sdata->u.mgd.bssid, 1); 1168 + sdata->u.mgd.auth_transaction = 4; 1023 1169 } 1024 1170 1025 1171 static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, 1026 - struct ieee80211_if_sta *ifsta, 1027 1172 struct ieee80211_mgmt *mgmt, 1028 1173 size_t len) 1029 1174 { 1175 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1030 1176 u16 auth_alg, auth_transaction, status_code; 1031 1177 1032 - if (ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE) 1178 + if (ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE) 1033 1179 return; 1034 1180 1035 1181 if (len < 24 + 6) 1036 1182 return; 1037 1183 1038 - if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) 1184 + if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN) != 0) 1039 1185 return; 1040 1186 1041 - if (memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) 1187 + if (memcmp(ifmgd->bssid, mgmt->bssid, ETH_ALEN) != 0) 1042 1188 return; 1043 1189 1044 1190 auth_alg = le16_to_cpu(mgmt->u.auth.auth_alg); 1045 1191 auth_transaction = le16_to_cpu(mgmt->u.auth.auth_transaction); 1046 1192 status_code = le16_to_cpu(mgmt->u.auth.status_code); 1047 1193 1048 - if (auth_alg != ifsta->auth_alg || 1049 - auth_transaction != ifsta->auth_transaction) 1194 + if (auth_alg != ifmgd->auth_alg || 1195 + auth_transaction != ifmgd->auth_transaction) 1050 1196 return; 1051 1197 1052 1198 if (status_code != WLAN_STATUS_SUCCESS) { ··· 1033 1223 const int num_algs = ARRAY_SIZE(algs); 1034 1224 int i, pos; 1035 1225 algs[0] = algs[1] = algs[2] = 0xff; 1036 - if (ifsta->auth_algs & IEEE80211_AUTH_ALG_OPEN) 1226 + if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_OPEN) 1037 1227 algs[0] = WLAN_AUTH_OPEN; 1038 - if (ifsta->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY) 1228 + if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY) 1039 1229 algs[1] = WLAN_AUTH_SHARED_KEY; 1040 - if (ifsta->auth_algs & IEEE80211_AUTH_ALG_LEAP) 1230 + if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_LEAP) 1041 1231 algs[2] = WLAN_AUTH_LEAP; 1042 - if (ifsta->auth_alg == WLAN_AUTH_OPEN) 1232 + if (ifmgd->auth_alg == WLAN_AUTH_OPEN) 1043 1233 pos = 0; 1044 - else if (ifsta->auth_alg == WLAN_AUTH_SHARED_KEY) 1234 + else if (ifmgd->auth_alg == WLAN_AUTH_SHARED_KEY) 1045 1235 pos = 1; 1046 1236 else 1047 1237 pos = 2; ··· 1049 1239 pos++; 1050 1240 if (pos >= num_algs) 1051 1241 pos = 0; 1052 - if (algs[pos] == ifsta->auth_alg || 1242 + if (algs[pos] == ifmgd->auth_alg || 1053 1243 algs[pos] == 0xff) 1054 1244 continue; 1055 1245 if (algs[pos] == WLAN_AUTH_SHARED_KEY && 1056 1246 !ieee80211_sta_wep_configured(sdata)) 1057 1247 continue; 1058 - ifsta->auth_alg = algs[pos]; 1248 + ifmgd->auth_alg = algs[pos]; 1059 1249 break; 1060 1250 } 1061 1251 } 1062 1252 return; 1063 1253 } 1064 1254 1065 - switch (ifsta->auth_alg) { 1255 + switch (ifmgd->auth_alg) { 1066 1256 case WLAN_AUTH_OPEN: 1067 1257 case WLAN_AUTH_LEAP: 1068 - ieee80211_auth_completed(sdata, ifsta); 1258 + ieee80211_auth_completed(sdata); 1069 1259 break; 1070 1260 case WLAN_AUTH_SHARED_KEY: 1071 - if (ifsta->auth_transaction == 4) 1072 - ieee80211_auth_completed(sdata, ifsta); 1261 + if (ifmgd->auth_transaction == 4) 1262 + ieee80211_auth_completed(sdata); 1073 1263 else 1074 - ieee80211_auth_challenge(sdata, ifsta, mgmt, len); 1264 + ieee80211_auth_challenge(sdata, mgmt, len); 1075 1265 break; 1076 1266 } 1077 1267 } 1078 1268 1079 1269 1080 1270 static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, 1081 - struct ieee80211_if_sta *ifsta, 1082 1271 struct ieee80211_mgmt *mgmt, 1083 1272 size_t len) 1084 1273 { 1274 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1085 1275 u16 reason_code; 1086 1276 1087 1277 if (len < 24 + 2) 1088 1278 return; 1089 1279 1090 - if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN)) 1280 + if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN)) 1091 1281 return; 1092 1282 1093 1283 reason_code = le16_to_cpu(mgmt->u.deauth.reason_code); 1094 1284 1095 - if (ifsta->flags & IEEE80211_STA_AUTHENTICATED) 1285 + if (ifmgd->flags & IEEE80211_STA_AUTHENTICATED) 1096 1286 printk(KERN_DEBUG "%s: deauthenticated (Reason: %u)\n", 1097 1287 sdata->dev->name, reason_code); 1098 1288 1099 - if (ifsta->state == IEEE80211_STA_MLME_AUTHENTICATE || 1100 - ifsta->state == IEEE80211_STA_MLME_ASSOCIATE || 1101 - ifsta->state == IEEE80211_STA_MLME_ASSOCIATED) { 1102 - ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE; 1103 - mod_timer(&ifsta->timer, jiffies + 1289 + if (ifmgd->state == IEEE80211_STA_MLME_AUTHENTICATE || 1290 + ifmgd->state == IEEE80211_STA_MLME_ASSOCIATE || 1291 + ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED) { 1292 + ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE; 1293 + mod_timer(&ifmgd->timer, jiffies + 1104 1294 IEEE80211_RETRY_AUTH_INTERVAL); 1105 1295 } 1106 1296 1107 - ieee80211_set_disassoc(sdata, ifsta, true, false, 0); 1108 - ifsta->flags &= ~IEEE80211_STA_AUTHENTICATED; 1297 + ieee80211_set_disassoc(sdata, true, false, 0); 1298 + ifmgd->flags &= ~IEEE80211_STA_AUTHENTICATED; 1109 1299 } 1110 1300 1111 1301 1112 1302 static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, 1113 - struct ieee80211_if_sta *ifsta, 1114 1303 struct ieee80211_mgmt *mgmt, 1115 1304 size_t len) 1116 1305 { 1306 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1117 1307 u16 reason_code; 1118 1308 1119 1309 if (len < 24 + 2) 1120 1310 return; 1121 1311 1122 - if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN)) 1312 + if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN)) 1123 1313 return; 1124 1314 1125 1315 reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); 1126 1316 1127 - if (ifsta->flags & IEEE80211_STA_ASSOCIATED) 1317 + if (ifmgd->flags & IEEE80211_STA_ASSOCIATED) 1128 1318 printk(KERN_DEBUG "%s: disassociated (Reason: %u)\n", 1129 1319 sdata->dev->name, reason_code); 1130 1320 1131 - if (ifsta->state == IEEE80211_STA_MLME_ASSOCIATED) { 1132 - ifsta->state = IEEE80211_STA_MLME_ASSOCIATE; 1133 - mod_timer(&ifsta->timer, jiffies + 1321 + if (ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED) { 1322 + ifmgd->state = IEEE80211_STA_MLME_ASSOCIATE; 1323 + mod_timer(&ifmgd->timer, jiffies + 1134 1324 IEEE80211_RETRY_AUTH_INTERVAL); 1135 1325 } 1136 1326 1137 - ieee80211_set_disassoc(sdata, ifsta, false, false, reason_code); 1327 + ieee80211_set_disassoc(sdata, false, false, reason_code); 1138 1328 } 1139 1329 1140 1330 1141 1331 static void ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, 1142 - struct ieee80211_if_sta *ifsta, 1143 1332 struct ieee80211_mgmt *mgmt, 1144 1333 size_t len, 1145 1334 int reassoc) 1146 1335 { 1336 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1147 1337 struct ieee80211_local *local = sdata->local; 1148 1338 struct ieee80211_supported_band *sband; 1149 1339 struct sta_info *sta; ··· 1160 1350 /* AssocResp and ReassocResp have identical structure, so process both 1161 1351 * of them in this function. */ 1162 1352 1163 - if (ifsta->state != IEEE80211_STA_MLME_ASSOCIATE) 1353 + if (ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE) 1164 1354 return; 1165 1355 1166 1356 if (len < 24 + 6) 1167 1357 return; 1168 1358 1169 - if (memcmp(ifsta->bssid, mgmt->sa, ETH_ALEN) != 0) 1359 + if (memcmp(ifmgd->bssid, mgmt->sa, ETH_ALEN) != 0) 1170 1360 return; 1171 1361 1172 1362 capab_info = le16_to_cpu(mgmt->u.assoc_resp.capab_info); ··· 1191 1381 "comeback duration %u TU (%u ms)\n", 1192 1382 sdata->dev->name, tu, ms); 1193 1383 if (ms > IEEE80211_ASSOC_TIMEOUT) 1194 - mod_timer(&ifsta->timer, 1384 + mod_timer(&ifmgd->timer, 1195 1385 jiffies + msecs_to_jiffies(ms)); 1196 1386 return; 1197 1387 } ··· 1202 1392 /* if this was a reassociation, ensure we try a "full" 1203 1393 * association next time. This works around some broken APs 1204 1394 * which do not correctly reject reassociation requests. */ 1205 - ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET; 1395 + ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET; 1206 1396 return; 1207 1397 } 1208 1398 ··· 1218 1408 } 1219 1409 1220 1410 printk(KERN_DEBUG "%s: associated\n", sdata->dev->name); 1221 - ifsta->aid = aid; 1222 - ifsta->ap_capab = capab_info; 1411 + ifmgd->aid = aid; 1412 + ifmgd->ap_capab = capab_info; 1223 1413 1224 - kfree(ifsta->assocresp_ies); 1225 - ifsta->assocresp_ies_len = len - (pos - (u8 *) mgmt); 1226 - ifsta->assocresp_ies = kmalloc(ifsta->assocresp_ies_len, GFP_KERNEL); 1227 - if (ifsta->assocresp_ies) 1228 - memcpy(ifsta->assocresp_ies, pos, ifsta->assocresp_ies_len); 1414 + kfree(ifmgd->assocresp_ies); 1415 + ifmgd->assocresp_ies_len = len - (pos - (u8 *) mgmt); 1416 + ifmgd->assocresp_ies = kmalloc(ifmgd->assocresp_ies_len, GFP_KERNEL); 1417 + if (ifmgd->assocresp_ies) 1418 + memcpy(ifmgd->assocresp_ies, pos, ifmgd->assocresp_ies_len); 1229 1419 1230 1420 rcu_read_lock(); 1231 1421 1232 1422 /* Add STA entry for the AP */ 1233 - sta = sta_info_get(local, ifsta->bssid); 1423 + sta = sta_info_get(local, ifmgd->bssid); 1234 1424 if (!sta) { 1235 1425 newsta = true; 1236 1426 1237 - sta = sta_info_alloc(sdata, ifsta->bssid, GFP_ATOMIC); 1427 + sta = sta_info_alloc(sdata, ifmgd->bssid, GFP_ATOMIC); 1238 1428 if (!sta) { 1239 1429 printk(KERN_DEBUG "%s: failed to alloc STA entry for" 1240 1430 " the AP\n", sdata->dev->name); ··· 1315 1505 1316 1506 rate_control_rate_init(sta); 1317 1507 1318 - if (ifsta->flags & IEEE80211_STA_MFP_ENABLED) 1508 + if (ifmgd->flags & IEEE80211_STA_MFP_ENABLED) 1319 1509 set_sta_flags(sta, WLAN_STA_MFP); 1320 1510 1321 1511 if (elems.wmm_param) ··· 1334 1524 rcu_read_unlock(); 1335 1525 1336 1526 if (elems.wmm_param) 1337 - ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param, 1527 + ieee80211_sta_wmm_params(local, ifmgd, elems.wmm_param, 1338 1528 elems.wmm_param_len); 1339 1529 1340 1530 if (elems.ht_info_elem && elems.wmm_param && 1341 - (ifsta->flags & IEEE80211_STA_WMM_ENABLED)) 1531 + (ifmgd->flags & IEEE80211_STA_WMM_ENABLED) && 1532 + !(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED)) 1342 1533 changed |= ieee80211_enable_ht(sdata, elems.ht_info_elem, 1343 1534 ap_ht_cap_flags); 1344 1535 ··· 1347 1536 * ieee80211_set_associated() will tell the driver */ 1348 1537 bss_conf->aid = aid; 1349 1538 bss_conf->assoc_capability = capab_info; 1350 - ieee80211_set_associated(sdata, ifsta, changed); 1539 + ieee80211_set_associated(sdata, changed); 1351 1540 1352 - ieee80211_associated(sdata, ifsta); 1541 + ieee80211_associated(sdata); 1353 1542 } 1354 1543 1355 - 1356 - static int __ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, 1357 - struct ieee80211_if_sta *ifsta, 1358 - const u8 *bssid, const int beacon_int, 1359 - const int freq, 1360 - const size_t supp_rates_len, 1361 - const u8 *supp_rates, 1362 - const u16 capability) 1363 - { 1364 - struct ieee80211_local *local = sdata->local; 1365 - int res = 0, rates, i, j; 1366 - struct sk_buff *skb; 1367 - struct ieee80211_mgmt *mgmt; 1368 - u8 *pos; 1369 - struct ieee80211_supported_band *sband; 1370 - union iwreq_data wrqu; 1371 - 1372 - if (local->ops->reset_tsf) { 1373 - /* Reset own TSF to allow time synchronization work. */ 1374 - local->ops->reset_tsf(local_to_hw(local)); 1375 - } 1376 - 1377 - if ((ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) && 1378 - memcmp(ifsta->bssid, bssid, ETH_ALEN) == 0) 1379 - return res; 1380 - 1381 - skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400 + 1382 - sdata->u.sta.ie_proberesp_len); 1383 - if (!skb) { 1384 - printk(KERN_DEBUG "%s: failed to allocate buffer for probe " 1385 - "response\n", sdata->dev->name); 1386 - return -ENOMEM; 1387 - } 1388 - 1389 - if (!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET)) { 1390 - /* Remove possible STA entries from other IBSS networks. */ 1391 - sta_info_flush_delayed(sdata); 1392 - } 1393 - 1394 - memcpy(ifsta->bssid, bssid, ETH_ALEN); 1395 - res = ieee80211_if_config(sdata, IEEE80211_IFCC_BSSID); 1396 - if (res) 1397 - return res; 1398 - 1399 - local->hw.conf.beacon_int = beacon_int >= 10 ? beacon_int : 10; 1400 - 1401 - sdata->drop_unencrypted = capability & 1402 - WLAN_CAPABILITY_PRIVACY ? 1 : 0; 1403 - 1404 - res = ieee80211_set_freq(sdata, freq); 1405 - 1406 - if (res) 1407 - return res; 1408 - 1409 - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1410 - 1411 - /* Build IBSS probe response */ 1412 - 1413 - skb_reserve(skb, local->hw.extra_tx_headroom); 1414 - 1415 - mgmt = (struct ieee80211_mgmt *) 1416 - skb_put(skb, 24 + sizeof(mgmt->u.beacon)); 1417 - memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon)); 1418 - mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 1419 - IEEE80211_STYPE_PROBE_RESP); 1420 - memset(mgmt->da, 0xff, ETH_ALEN); 1421 - memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 1422 - memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN); 1423 - mgmt->u.beacon.beacon_int = 1424 - cpu_to_le16(local->hw.conf.beacon_int); 1425 - mgmt->u.beacon.capab_info = cpu_to_le16(capability); 1426 - 1427 - pos = skb_put(skb, 2 + ifsta->ssid_len); 1428 - *pos++ = WLAN_EID_SSID; 1429 - *pos++ = ifsta->ssid_len; 1430 - memcpy(pos, ifsta->ssid, ifsta->ssid_len); 1431 - 1432 - rates = supp_rates_len; 1433 - if (rates > 8) 1434 - rates = 8; 1435 - pos = skb_put(skb, 2 + rates); 1436 - *pos++ = WLAN_EID_SUPP_RATES; 1437 - *pos++ = rates; 1438 - memcpy(pos, supp_rates, rates); 1439 - 1440 - if (sband->band == IEEE80211_BAND_2GHZ) { 1441 - pos = skb_put(skb, 2 + 1); 1442 - *pos++ = WLAN_EID_DS_PARAMS; 1443 - *pos++ = 1; 1444 - *pos++ = ieee80211_frequency_to_channel(freq); 1445 - } 1446 - 1447 - pos = skb_put(skb, 2 + 2); 1448 - *pos++ = WLAN_EID_IBSS_PARAMS; 1449 - *pos++ = 2; 1450 - /* FIX: set ATIM window based on scan results */ 1451 - *pos++ = 0; 1452 - *pos++ = 0; 1453 - 1454 - if (supp_rates_len > 8) { 1455 - rates = supp_rates_len - 8; 1456 - pos = skb_put(skb, 2 + rates); 1457 - *pos++ = WLAN_EID_EXT_SUPP_RATES; 1458 - *pos++ = rates; 1459 - memcpy(pos, &supp_rates[8], rates); 1460 - } 1461 - 1462 - add_extra_ies(skb, sdata->u.sta.ie_proberesp, 1463 - sdata->u.sta.ie_proberesp_len); 1464 - 1465 - ifsta->probe_resp = skb; 1466 - 1467 - ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON | 1468 - IEEE80211_IFCC_BEACON_ENABLED); 1469 - 1470 - 1471 - rates = 0; 1472 - for (i = 0; i < supp_rates_len; i++) { 1473 - int bitrate = (supp_rates[i] & 0x7f) * 5; 1474 - for (j = 0; j < sband->n_bitrates; j++) 1475 - if (sband->bitrates[j].bitrate == bitrate) 1476 - rates |= BIT(j); 1477 - } 1478 - ifsta->supp_rates_bits[local->hw.conf.channel->band] = rates; 1479 - 1480 - ieee80211_sta_def_wmm_params(sdata, supp_rates_len, supp_rates); 1481 - 1482 - ifsta->flags |= IEEE80211_STA_PREV_BSSID_SET; 1483 - ifsta->state = IEEE80211_STA_MLME_IBSS_JOINED; 1484 - mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); 1485 - 1486 - ieee80211_led_assoc(local, true); 1487 - 1488 - memset(&wrqu, 0, sizeof(wrqu)); 1489 - memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); 1490 - wireless_send_event(sdata->dev, SIOCGIWAP, &wrqu, NULL); 1491 - 1492 - return res; 1493 - } 1494 - 1495 - static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata, 1496 - struct ieee80211_if_sta *ifsta, 1497 - struct ieee80211_bss *bss) 1498 - { 1499 - return __ieee80211_sta_join_ibss(sdata, ifsta, 1500 - bss->cbss.bssid, 1501 - bss->cbss.beacon_interval, 1502 - bss->cbss.channel->center_freq, 1503 - bss->supp_rates_len, bss->supp_rates, 1504 - bss->cbss.capability); 1505 - } 1506 1544 1507 1545 static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, 1508 1546 struct ieee80211_mgmt *mgmt, ··· 1363 1703 struct ieee80211_local *local = sdata->local; 1364 1704 int freq; 1365 1705 struct ieee80211_bss *bss; 1366 - struct sta_info *sta; 1367 1706 struct ieee80211_channel *channel; 1368 - u64 beacon_timestamp, rx_timestamp; 1369 - u32 supp_rates = 0; 1370 - enum ieee80211_band band = rx_status->band; 1371 1707 1372 1708 if (elems->ds_params && elems->ds_params_len == 1) 1373 1709 freq = ieee80211_channel_to_frequency(elems->ds_params[0]); ··· 1375 1719 if (!channel || channel->flags & IEEE80211_CHAN_DISABLED) 1376 1720 return; 1377 1721 1378 - if (sdata->vif.type == NL80211_IFTYPE_ADHOC && elems->supp_rates && 1379 - memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0) { 1380 - supp_rates = ieee80211_sta_get_rates(local, elems, band); 1381 - 1382 - rcu_read_lock(); 1383 - 1384 - sta = sta_info_get(local, mgmt->sa); 1385 - if (sta) { 1386 - u32 prev_rates; 1387 - 1388 - prev_rates = sta->sta.supp_rates[band]; 1389 - /* make sure mandatory rates are always added */ 1390 - sta->sta.supp_rates[band] = supp_rates | 1391 - ieee80211_mandatory_rates(local, band); 1392 - 1393 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1394 - if (sta->sta.supp_rates[band] != prev_rates) 1395 - printk(KERN_DEBUG "%s: updated supp_rates set " 1396 - "for %pM based on beacon info (0x%llx | " 1397 - "0x%llx -> 0x%llx)\n", 1398 - sdata->dev->name, 1399 - sta->sta.addr, 1400 - (unsigned long long) prev_rates, 1401 - (unsigned long long) supp_rates, 1402 - (unsigned long long) sta->sta.supp_rates[band]); 1403 - #endif 1404 - } else { 1405 - ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); 1406 - } 1407 - 1408 - rcu_read_unlock(); 1409 - } 1410 - 1411 1722 bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, 1412 1723 channel, beacon); 1413 1724 if (!bss) 1414 1725 return; 1415 1726 1416 1727 if (elems->ch_switch_elem && (elems->ch_switch_elem_len == 3) && 1417 - (memcmp(mgmt->bssid, sdata->u.sta.bssid, ETH_ALEN) == 0)) { 1728 + (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN) == 0)) { 1418 1729 struct ieee80211_channel_sw_ie *sw_elem = 1419 1730 (struct ieee80211_channel_sw_ie *)elems->ch_switch_elem; 1420 1731 ieee80211_process_chanswitch(sdata, sw_elem, bss); 1421 1732 } 1422 1733 1423 - /* was just updated in ieee80211_bss_info_update */ 1424 - beacon_timestamp = bss->cbss.tsf; 1425 - 1426 - if (sdata->vif.type != NL80211_IFTYPE_ADHOC) 1427 - goto put_bss; 1428 - 1429 - /* check if we need to merge IBSS */ 1430 - 1431 - /* merge only on beacons (???) */ 1432 - if (!beacon) 1433 - goto put_bss; 1434 - 1435 - /* we use a fixed BSSID */ 1436 - if (sdata->u.sta.flags & IEEE80211_STA_BSSID_SET) 1437 - goto put_bss; 1438 - 1439 - /* not an IBSS */ 1440 - if (!(bss->cbss.capability & WLAN_CAPABILITY_IBSS)) 1441 - goto put_bss; 1442 - 1443 - /* different channel */ 1444 - if (bss->cbss.channel != local->oper_channel) 1445 - goto put_bss; 1446 - 1447 - /* different SSID */ 1448 - if (elems->ssid_len != sdata->u.sta.ssid_len || 1449 - memcmp(elems->ssid, sdata->u.sta.ssid, 1450 - sdata->u.sta.ssid_len)) 1451 - goto put_bss; 1452 - 1453 - if (rx_status->flag & RX_FLAG_TSFT) { 1454 - /* 1455 - * For correct IBSS merging we need mactime; since mactime is 1456 - * defined as the time the first data symbol of the frame hits 1457 - * the PHY, and the timestamp of the beacon is defined as "the 1458 - * time that the data symbol containing the first bit of the 1459 - * timestamp is transmitted to the PHY plus the transmitting 1460 - * STA's delays through its local PHY from the MAC-PHY 1461 - * interface to its interface with the WM" (802.11 11.1.2) 1462 - * - equals the time this bit arrives at the receiver - we have 1463 - * to take into account the offset between the two. 1464 - * 1465 - * E.g. at 1 MBit that means mactime is 192 usec earlier 1466 - * (=24 bytes * 8 usecs/byte) than the beacon timestamp. 1467 - */ 1468 - int rate; 1469 - 1470 - if (rx_status->flag & RX_FLAG_HT) 1471 - rate = 65; /* TODO: HT rates */ 1472 - else 1473 - rate = local->hw.wiphy->bands[band]-> 1474 - bitrates[rx_status->rate_idx].bitrate; 1475 - 1476 - rx_timestamp = rx_status->mactime + (24 * 8 * 10 / rate); 1477 - } else if (local && local->ops && local->ops->get_tsf) 1478 - /* second best option: get current TSF */ 1479 - rx_timestamp = local->ops->get_tsf(local_to_hw(local)); 1480 - else 1481 - /* can't merge without knowing the TSF */ 1482 - rx_timestamp = -1LLU; 1483 - 1484 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1485 - printk(KERN_DEBUG "RX beacon SA=%pM BSSID=" 1486 - "%pM TSF=0x%llx BCN=0x%llx diff=%lld @%lu\n", 1487 - mgmt->sa, mgmt->bssid, 1488 - (unsigned long long)rx_timestamp, 1489 - (unsigned long long)beacon_timestamp, 1490 - (unsigned long long)(rx_timestamp - beacon_timestamp), 1491 - jiffies); 1492 - #endif 1493 - 1494 - if (beacon_timestamp > rx_timestamp) { 1495 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1496 - printk(KERN_DEBUG "%s: beacon TSF higher than " 1497 - "local TSF - IBSS merge with BSSID %pM\n", 1498 - sdata->dev->name, mgmt->bssid); 1499 - #endif 1500 - ieee80211_sta_join_ibss(sdata, &sdata->u.sta, bss); 1501 - ieee80211_ibss_add_sta(sdata, mgmt->bssid, mgmt->sa, supp_rates); 1502 - } 1503 - 1504 - put_bss: 1505 1734 ieee80211_rx_bss_put(local, bss); 1506 1735 } 1507 1736 ··· 1398 1857 { 1399 1858 size_t baselen; 1400 1859 struct ieee802_11_elems elems; 1401 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 1402 1860 1403 1861 if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) 1404 1862 return; /* ignore ProbeResp to foreign address */ ··· 1413 1873 1414 1874 /* direct probe may be part of the association flow */ 1415 1875 if (test_and_clear_bit(IEEE80211_STA_REQ_DIRECT_PROBE, 1416 - &ifsta->request)) { 1876 + &sdata->u.mgd.request)) { 1417 1877 printk(KERN_DEBUG "%s direct probe responded\n", 1418 1878 sdata->dev->name); 1419 - ieee80211_authenticate(sdata, ifsta); 1879 + ieee80211_authenticate(sdata); 1420 1880 } 1421 1881 } 1422 - 1423 1882 1424 1883 static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, 1425 1884 struct ieee80211_mgmt *mgmt, 1426 1885 size_t len, 1427 1886 struct ieee80211_rx_status *rx_status) 1428 1887 { 1429 - struct ieee80211_if_sta *ifsta; 1888 + struct ieee80211_if_managed *ifmgd; 1430 1889 size_t baselen; 1431 1890 struct ieee802_11_elems elems; 1432 1891 struct ieee80211_local *local = sdata->local; ··· 1444 1905 1445 1906 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1446 1907 return; 1447 - ifsta = &sdata->u.sta; 1448 1908 1449 - if (!(ifsta->flags & IEEE80211_STA_ASSOCIATED) || 1450 - memcmp(ifsta->bssid, mgmt->bssid, ETH_ALEN) != 0) 1909 + ifmgd = &sdata->u.mgd; 1910 + 1911 + if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED) || 1912 + memcmp(ifmgd->bssid, mgmt->bssid, ETH_ALEN) != 0) 1451 1913 return; 1452 1914 1453 1915 if (rx_status->freq != local->hw.conf.channel->center_freq) 1454 1916 return; 1455 1917 1456 - ieee80211_sta_wmm_params(local, ifsta, elems.wmm_param, 1918 + ieee80211_sta_wmm_params(local, ifmgd, elems.wmm_param, 1457 1919 elems.wmm_param_len); 1458 1920 1459 1921 if (local->hw.flags & IEEE80211_HW_PS_NULLFUNC_STACK && 1460 1922 local->hw.conf.flags & IEEE80211_CONF_PS) { 1461 - directed_tim = ieee80211_check_tim(&elems, ifsta->aid); 1923 + directed_tim = ieee80211_check_tim(&elems, ifmgd->aid); 1462 1924 1463 1925 if (directed_tim) { 1464 1926 if (local->hw.conf.dynamic_ps_timeout > 0) { ··· 1494 1954 erp_valid, erp_value); 1495 1955 1496 1956 1497 - if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param) { 1957 + if (elems.ht_cap_elem && elems.ht_info_elem && elems.wmm_param && 1958 + !(ifmgd->flags & IEEE80211_STA_TKIP_WEP_USED)) { 1498 1959 struct sta_info *sta; 1499 1960 struct ieee80211_supported_band *sband; 1500 1961 u16 ap_ht_cap_flags; 1501 1962 1502 1963 rcu_read_lock(); 1503 1964 1504 - sta = sta_info_get(local, ifsta->bssid); 1965 + sta = sta_info_get(local, ifmgd->bssid); 1505 1966 if (!sta) { 1506 1967 rcu_read_unlock(); 1507 1968 return; ··· 1538 1997 ieee80211_bss_info_change_notify(sdata, changed); 1539 1998 } 1540 1999 1541 - 1542 - static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, 1543 - struct ieee80211_if_sta *ifsta, 1544 - struct ieee80211_mgmt *mgmt, 1545 - size_t len) 2000 + ieee80211_rx_result ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, 2001 + struct sk_buff *skb, 2002 + struct ieee80211_rx_status *rx_status) 1546 2003 { 1547 2004 struct ieee80211_local *local = sdata->local; 1548 - int tx_last_beacon; 1549 - struct sk_buff *skb; 1550 - struct ieee80211_mgmt *resp; 1551 - u8 *pos, *end; 1552 - 1553 - if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED || 1554 - len < 24 + 2 || !ifsta->probe_resp) 1555 - return; 1556 - 1557 - if (local->ops->tx_last_beacon) 1558 - tx_last_beacon = local->ops->tx_last_beacon(local_to_hw(local)); 1559 - else 1560 - tx_last_beacon = 1; 1561 - 1562 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1563 - printk(KERN_DEBUG "%s: RX ProbeReq SA=%pM DA=%pM BSSID=%pM" 1564 - " (tx_last_beacon=%d)\n", 1565 - sdata->dev->name, mgmt->sa, mgmt->da, 1566 - mgmt->bssid, tx_last_beacon); 1567 - #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 1568 - 1569 - if (!tx_last_beacon) 1570 - return; 1571 - 1572 - if (memcmp(mgmt->bssid, ifsta->bssid, ETH_ALEN) != 0 && 1573 - memcmp(mgmt->bssid, "\xff\xff\xff\xff\xff\xff", ETH_ALEN) != 0) 1574 - return; 1575 - 1576 - end = ((u8 *) mgmt) + len; 1577 - pos = mgmt->u.probe_req.variable; 1578 - if (pos[0] != WLAN_EID_SSID || 1579 - pos + 2 + pos[1] > end) { 1580 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1581 - printk(KERN_DEBUG "%s: Invalid SSID IE in ProbeReq " 1582 - "from %pM\n", 1583 - sdata->dev->name, mgmt->sa); 1584 - #endif 1585 - return; 1586 - } 1587 - if (pos[1] != 0 && 1588 - (pos[1] != ifsta->ssid_len || 1589 - memcmp(pos + 2, ifsta->ssid, ifsta->ssid_len) != 0)) { 1590 - /* Ignore ProbeReq for foreign SSID */ 1591 - return; 1592 - } 1593 - 1594 - /* Reply with ProbeResp */ 1595 - skb = skb_copy(ifsta->probe_resp, GFP_KERNEL); 1596 - if (!skb) 1597 - return; 1598 - 1599 - resp = (struct ieee80211_mgmt *) skb->data; 1600 - memcpy(resp->da, mgmt->sa, ETH_ALEN); 1601 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1602 - printk(KERN_DEBUG "%s: Sending ProbeResp to %pM\n", 1603 - sdata->dev->name, resp->da); 1604 - #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 1605 - ieee80211_tx_skb(sdata, skb, 0); 1606 - } 1607 - 1608 - void ieee80211_sta_rx_mgmt(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 1609 - struct ieee80211_rx_status *rx_status) 1610 - { 1611 - struct ieee80211_local *local = sdata->local; 1612 - struct ieee80211_if_sta *ifsta; 1613 2005 struct ieee80211_mgmt *mgmt; 1614 2006 u16 fc; 1615 2007 1616 2008 if (skb->len < 24) 1617 - goto fail; 1618 - 1619 - ifsta = &sdata->u.sta; 2009 + return RX_DROP_MONITOR; 1620 2010 1621 2011 mgmt = (struct ieee80211_mgmt *) skb->data; 1622 2012 fc = le16_to_cpu(mgmt->frame_control); ··· 1562 2090 case IEEE80211_STYPE_REASSOC_RESP: 1563 2091 case IEEE80211_STYPE_DEAUTH: 1564 2092 case IEEE80211_STYPE_DISASSOC: 1565 - skb_queue_tail(&ifsta->skb_queue, skb); 1566 - queue_work(local->hw.workqueue, &ifsta->work); 1567 - return; 2093 + skb_queue_tail(&sdata->u.mgd.skb_queue, skb); 2094 + queue_work(local->hw.workqueue, &sdata->u.mgd.work); 2095 + return RX_QUEUED; 1568 2096 } 1569 2097 1570 - fail: 1571 - kfree_skb(skb); 2098 + return RX_DROP_MONITOR; 1572 2099 } 1573 2100 1574 2101 static void ieee80211_sta_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, 1575 2102 struct sk_buff *skb) 1576 2103 { 1577 2104 struct ieee80211_rx_status *rx_status; 1578 - struct ieee80211_if_sta *ifsta; 1579 2105 struct ieee80211_mgmt *mgmt; 1580 2106 u16 fc; 1581 - 1582 - ifsta = &sdata->u.sta; 1583 2107 1584 2108 rx_status = (struct ieee80211_rx_status *) skb->cb; 1585 2109 mgmt = (struct ieee80211_mgmt *) skb->data; 1586 2110 fc = le16_to_cpu(mgmt->frame_control); 1587 2111 1588 - if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 1589 - switch (fc & IEEE80211_FCTL_STYPE) { 1590 - case IEEE80211_STYPE_PROBE_REQ: 1591 - ieee80211_rx_mgmt_probe_req(sdata, ifsta, mgmt, 1592 - skb->len); 1593 - break; 1594 - case IEEE80211_STYPE_PROBE_RESP: 1595 - ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, 1596 - rx_status); 1597 - break; 1598 - case IEEE80211_STYPE_BEACON: 1599 - ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, 1600 - rx_status); 1601 - break; 1602 - case IEEE80211_STYPE_AUTH: 1603 - ieee80211_rx_mgmt_auth_ibss(sdata, ifsta, mgmt, 1604 - skb->len); 1605 - break; 1606 - } 1607 - } else { /* NL80211_IFTYPE_STATION */ 1608 - switch (fc & IEEE80211_FCTL_STYPE) { 1609 - case IEEE80211_STYPE_PROBE_RESP: 1610 - ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, 1611 - rx_status); 1612 - break; 1613 - case IEEE80211_STYPE_BEACON: 1614 - ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, 1615 - rx_status); 1616 - break; 1617 - case IEEE80211_STYPE_AUTH: 1618 - ieee80211_rx_mgmt_auth(sdata, ifsta, mgmt, skb->len); 1619 - break; 1620 - case IEEE80211_STYPE_ASSOC_RESP: 1621 - ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, 1622 - skb->len, 0); 1623 - break; 1624 - case IEEE80211_STYPE_REASSOC_RESP: 1625 - ieee80211_rx_mgmt_assoc_resp(sdata, ifsta, mgmt, 1626 - skb->len, 1); 1627 - break; 1628 - case IEEE80211_STYPE_DEAUTH: 1629 - ieee80211_rx_mgmt_deauth(sdata, ifsta, mgmt, skb->len); 1630 - break; 1631 - case IEEE80211_STYPE_DISASSOC: 1632 - ieee80211_rx_mgmt_disassoc(sdata, ifsta, mgmt, 1633 - skb->len); 1634 - break; 1635 - } 2112 + switch (fc & IEEE80211_FCTL_STYPE) { 2113 + case IEEE80211_STYPE_PROBE_RESP: 2114 + ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len, 2115 + rx_status); 2116 + break; 2117 + case IEEE80211_STYPE_BEACON: 2118 + ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, 2119 + rx_status); 2120 + break; 2121 + case IEEE80211_STYPE_AUTH: 2122 + ieee80211_rx_mgmt_auth(sdata, mgmt, skb->len); 2123 + break; 2124 + case IEEE80211_STYPE_ASSOC_RESP: 2125 + ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, 0); 2126 + break; 2127 + case IEEE80211_STYPE_REASSOC_RESP: 2128 + ieee80211_rx_mgmt_assoc_resp(sdata, mgmt, skb->len, 1); 2129 + break; 2130 + case IEEE80211_STYPE_DEAUTH: 2131 + ieee80211_rx_mgmt_deauth(sdata, mgmt, skb->len); 2132 + break; 2133 + case IEEE80211_STYPE_DISASSOC: 2134 + ieee80211_rx_mgmt_disassoc(sdata, mgmt, skb->len); 2135 + break; 1636 2136 } 1637 2137 1638 2138 kfree_skb(skb); 1639 2139 } 1640 2140 1641 - 1642 - static int ieee80211_sta_active_ibss(struct ieee80211_sub_if_data *sdata) 1643 - { 1644 - struct ieee80211_local *local = sdata->local; 1645 - int active = 0; 1646 - struct sta_info *sta; 1647 - 1648 - rcu_read_lock(); 1649 - 1650 - list_for_each_entry_rcu(sta, &local->sta_list, list) { 1651 - if (sta->sdata == sdata && 1652 - time_after(sta->last_rx + IEEE80211_IBSS_MERGE_INTERVAL, 1653 - jiffies)) { 1654 - active++; 1655 - break; 1656 - } 1657 - } 1658 - 1659 - rcu_read_unlock(); 1660 - 1661 - return active; 1662 - } 1663 - 1664 - 1665 - static void ieee80211_sta_merge_ibss(struct ieee80211_sub_if_data *sdata, 1666 - struct ieee80211_if_sta *ifsta) 1667 - { 1668 - mod_timer(&ifsta->timer, jiffies + IEEE80211_IBSS_MERGE_INTERVAL); 1669 - 1670 - ieee80211_sta_expire(sdata, IEEE80211_IBSS_INACTIVITY_LIMIT); 1671 - if (ieee80211_sta_active_ibss(sdata)) 1672 - return; 1673 - 1674 - if ((sdata->u.sta.flags & IEEE80211_STA_BSSID_SET) && 1675 - (!(sdata->u.sta.flags & IEEE80211_STA_AUTO_CHANNEL_SEL))) 1676 - return; 1677 - 1678 - printk(KERN_DEBUG "%s: No active IBSS STAs - trying to scan for other " 1679 - "IBSS networks with same SSID (merge)\n", sdata->dev->name); 1680 - 1681 - /* XXX maybe racy? */ 1682 - if (sdata->local->scan_req) 1683 - return; 1684 - 1685 - memcpy(sdata->local->int_scan_req.ssids[0].ssid, 1686 - ifsta->ssid, IEEE80211_MAX_SSID_LEN); 1687 - sdata->local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len; 1688 - ieee80211_request_scan(sdata, &sdata->local->int_scan_req); 1689 - } 1690 - 1691 - 1692 2141 static void ieee80211_sta_timer(unsigned long data) 1693 2142 { 1694 2143 struct ieee80211_sub_if_data *sdata = 1695 2144 (struct ieee80211_sub_if_data *) data; 1696 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 2145 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1697 2146 struct ieee80211_local *local = sdata->local; 1698 2147 1699 - set_bit(IEEE80211_STA_REQ_RUN, &ifsta->request); 1700 - queue_work(local->hw.workqueue, &ifsta->work); 2148 + set_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request); 2149 + queue_work(local->hw.workqueue, &ifmgd->work); 1701 2150 } 1702 2151 1703 - static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata, 1704 - struct ieee80211_if_sta *ifsta) 2152 + static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata) 1705 2153 { 2154 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1706 2155 struct ieee80211_local *local = sdata->local; 1707 2156 1708 2157 if (local->ops->reset_tsf) { ··· 1631 2238 local->ops->reset_tsf(local_to_hw(local)); 1632 2239 } 1633 2240 1634 - ifsta->wmm_last_param_set = -1; /* allow any WMM update */ 2241 + ifmgd->wmm_last_param_set = -1; /* allow any WMM update */ 1635 2242 1636 2243 1637 - if (ifsta->auth_algs & IEEE80211_AUTH_ALG_OPEN) 1638 - ifsta->auth_alg = WLAN_AUTH_OPEN; 1639 - else if (ifsta->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY) 1640 - ifsta->auth_alg = WLAN_AUTH_SHARED_KEY; 1641 - else if (ifsta->auth_algs & IEEE80211_AUTH_ALG_LEAP) 1642 - ifsta->auth_alg = WLAN_AUTH_LEAP; 2244 + if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_OPEN) 2245 + ifmgd->auth_alg = WLAN_AUTH_OPEN; 2246 + else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_SHARED_KEY) 2247 + ifmgd->auth_alg = WLAN_AUTH_SHARED_KEY; 2248 + else if (ifmgd->auth_algs & IEEE80211_AUTH_ALG_LEAP) 2249 + ifmgd->auth_alg = WLAN_AUTH_LEAP; 1643 2250 else 1644 - ifsta->auth_alg = WLAN_AUTH_OPEN; 1645 - ifsta->auth_transaction = -1; 1646 - ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; 1647 - ifsta->assoc_scan_tries = 0; 1648 - ifsta->direct_probe_tries = 0; 1649 - ifsta->auth_tries = 0; 1650 - ifsta->assoc_tries = 0; 2251 + ifmgd->auth_alg = WLAN_AUTH_OPEN; 2252 + ifmgd->auth_transaction = -1; 2253 + ifmgd->flags &= ~IEEE80211_STA_ASSOCIATED; 2254 + ifmgd->assoc_scan_tries = 0; 2255 + ifmgd->direct_probe_tries = 0; 2256 + ifmgd->auth_tries = 0; 2257 + ifmgd->assoc_tries = 0; 1651 2258 netif_tx_stop_all_queues(sdata->dev); 1652 2259 netif_carrier_off(sdata->dev); 1653 2260 } 1654 2261 1655 - static int ieee80211_sta_create_ibss(struct ieee80211_sub_if_data *sdata, 1656 - struct ieee80211_if_sta *ifsta) 2262 + static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata) 1657 2263 { 1658 - struct ieee80211_local *local = sdata->local; 1659 - struct ieee80211_supported_band *sband; 1660 - u8 *pos; 1661 - u8 bssid[ETH_ALEN]; 1662 - u8 supp_rates[IEEE80211_MAX_SUPP_RATES]; 1663 - u16 capability; 1664 - int i; 1665 - 1666 - if (sdata->u.sta.flags & IEEE80211_STA_BSSID_SET) { 1667 - memcpy(bssid, ifsta->bssid, ETH_ALEN); 1668 - } else { 1669 - /* Generate random, not broadcast, locally administered BSSID. Mix in 1670 - * own MAC address to make sure that devices that do not have proper 1671 - * random number generator get different BSSID. */ 1672 - get_random_bytes(bssid, ETH_ALEN); 1673 - for (i = 0; i < ETH_ALEN; i++) 1674 - bssid[i] ^= sdata->dev->dev_addr[i]; 1675 - bssid[0] &= ~0x01; 1676 - bssid[0] |= 0x02; 1677 - } 1678 - 1679 - printk(KERN_DEBUG "%s: Creating new IBSS network, BSSID %pM\n", 1680 - sdata->dev->name, bssid); 1681 - 1682 - sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 1683 - 1684 - if (local->hw.conf.beacon_int == 0) 1685 - local->hw.conf.beacon_int = 100; 1686 - 1687 - capability = WLAN_CAPABILITY_IBSS; 1688 - 1689 - if (sdata->default_key) 1690 - capability |= WLAN_CAPABILITY_PRIVACY; 1691 - else 1692 - sdata->drop_unencrypted = 0; 1693 - 1694 - pos = supp_rates; 1695 - for (i = 0; i < sband->n_bitrates; i++) { 1696 - int rate = sband->bitrates[i].bitrate; 1697 - *pos++ = (u8) (rate / 5); 1698 - } 1699 - 1700 - return __ieee80211_sta_join_ibss(sdata, ifsta, 1701 - bssid, local->hw.conf.beacon_int, 1702 - local->hw.conf.channel->center_freq, 1703 - sband->n_bitrates, supp_rates, 1704 - capability); 1705 - } 1706 - 1707 - 1708 - static int ieee80211_sta_find_ibss(struct ieee80211_sub_if_data *sdata, 1709 - struct ieee80211_if_sta *ifsta) 1710 - { 2264 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1711 2265 struct ieee80211_local *local = sdata->local; 1712 2266 struct ieee80211_bss *bss; 1713 - int active_ibss; 1714 - 1715 - if (ifsta->ssid_len == 0) 1716 - return -EINVAL; 1717 - 1718 - active_ibss = ieee80211_sta_active_ibss(sdata); 1719 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1720 - printk(KERN_DEBUG "%s: sta_find_ibss (active_ibss=%d)\n", 1721 - sdata->dev->name, active_ibss); 1722 - #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 1723 - 1724 - if (active_ibss) 1725 - return 0; 1726 - 1727 - if (ifsta->flags & IEEE80211_STA_BSSID_SET) 1728 - bss = ieee80211_rx_bss_get(local, ifsta->bssid, 0, 1729 - ifsta->ssid, ifsta->ssid_len); 1730 - else 1731 - bss = (void *)cfg80211_get_ibss(local->hw.wiphy, 1732 - NULL, 1733 - ifsta->ssid, ifsta->ssid_len); 1734 - 1735 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1736 - if (bss) 1737 - printk(KERN_DEBUG " sta_find_ibss: selected %pM current " 1738 - "%pM\n", bss->cbss.bssid, ifsta->bssid); 1739 - #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 1740 - 1741 - if (bss && 1742 - (!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET) || 1743 - memcmp(ifsta->bssid, bss->cbss.bssid, ETH_ALEN))) { 1744 - int ret; 1745 - 1746 - printk(KERN_DEBUG "%s: Selected IBSS BSSID %pM" 1747 - " based on configured SSID\n", 1748 - sdata->dev->name, bss->cbss.bssid); 1749 - 1750 - ret = ieee80211_sta_join_ibss(sdata, ifsta, bss); 1751 - ieee80211_rx_bss_put(local, bss); 1752 - return ret; 1753 - } else if (bss) 1754 - ieee80211_rx_bss_put(local, bss); 1755 - 1756 - #ifdef CONFIG_MAC80211_IBSS_DEBUG 1757 - printk(KERN_DEBUG " did not try to join ibss\n"); 1758 - #endif /* CONFIG_MAC80211_IBSS_DEBUG */ 1759 - 1760 - /* Selected IBSS not found in current scan results - try to scan */ 1761 - if (ifsta->state == IEEE80211_STA_MLME_IBSS_JOINED && 1762 - !ieee80211_sta_active_ibss(sdata)) { 1763 - mod_timer(&ifsta->timer, jiffies + 1764 - IEEE80211_IBSS_MERGE_INTERVAL); 1765 - } else if (time_after(jiffies, local->last_scan_completed + 1766 - IEEE80211_SCAN_INTERVAL)) { 1767 - printk(KERN_DEBUG "%s: Trigger new scan to find an IBSS to " 1768 - "join\n", sdata->dev->name); 1769 - 1770 - /* XXX maybe racy? */ 1771 - if (local->scan_req) 1772 - return -EBUSY; 1773 - 1774 - memcpy(local->int_scan_req.ssids[0].ssid, 1775 - ifsta->ssid, IEEE80211_MAX_SSID_LEN); 1776 - local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len; 1777 - return ieee80211_request_scan(sdata, &local->int_scan_req); 1778 - } else if (ifsta->state != IEEE80211_STA_MLME_IBSS_JOINED) { 1779 - int interval = IEEE80211_SCAN_INTERVAL; 1780 - 1781 - if (time_after(jiffies, ifsta->ibss_join_req + 1782 - IEEE80211_IBSS_JOIN_TIMEOUT)) { 1783 - if ((ifsta->flags & IEEE80211_STA_CREATE_IBSS) && 1784 - (!(local->oper_channel->flags & 1785 - IEEE80211_CHAN_NO_IBSS))) 1786 - return ieee80211_sta_create_ibss(sdata, ifsta); 1787 - if (ifsta->flags & IEEE80211_STA_CREATE_IBSS) { 1788 - printk(KERN_DEBUG "%s: IBSS not allowed on" 1789 - " %d MHz\n", sdata->dev->name, 1790 - local->hw.conf.channel->center_freq); 1791 - } 1792 - 1793 - /* No IBSS found - decrease scan interval and continue 1794 - * scanning. */ 1795 - interval = IEEE80211_SCAN_INTERVAL_SLOW; 1796 - } 1797 - 1798 - ifsta->state = IEEE80211_STA_MLME_IBSS_SEARCH; 1799 - mod_timer(&ifsta->timer, jiffies + interval); 1800 - return 0; 1801 - } 1802 - 1803 - return 0; 1804 - } 1805 - 1806 - 1807 - static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata, 1808 - struct ieee80211_if_sta *ifsta) 1809 - { 1810 - struct ieee80211_local *local = sdata->local; 1811 - struct ieee80211_bss *bss; 1812 - u8 *bssid = ifsta->bssid, *ssid = ifsta->ssid; 1813 - u8 ssid_len = ifsta->ssid_len; 2267 + u8 *bssid = ifmgd->bssid, *ssid = ifmgd->ssid; 2268 + u8 ssid_len = ifmgd->ssid_len; 1814 2269 u16 capa_mask = WLAN_CAPABILITY_ESS; 1815 2270 u16 capa_val = WLAN_CAPABILITY_ESS; 1816 2271 struct ieee80211_channel *chan = local->oper_channel; 1817 2272 1818 - if (ifsta->flags & (IEEE80211_STA_AUTO_SSID_SEL | 2273 + if (ifmgd->flags & (IEEE80211_STA_AUTO_SSID_SEL | 1819 2274 IEEE80211_STA_AUTO_BSSID_SEL | 1820 2275 IEEE80211_STA_AUTO_CHANNEL_SEL)) { 1821 2276 capa_mask |= WLAN_CAPABILITY_PRIVACY; ··· 1671 2430 capa_val |= WLAN_CAPABILITY_PRIVACY; 1672 2431 } 1673 2432 1674 - if (ifsta->flags & IEEE80211_STA_AUTO_CHANNEL_SEL) 2433 + if (ifmgd->flags & IEEE80211_STA_AUTO_CHANNEL_SEL) 1675 2434 chan = NULL; 1676 2435 1677 - if (ifsta->flags & IEEE80211_STA_AUTO_BSSID_SEL) 2436 + if (ifmgd->flags & IEEE80211_STA_AUTO_BSSID_SEL) 1678 2437 bssid = NULL; 1679 2438 1680 - if (ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) { 2439 + if (ifmgd->flags & IEEE80211_STA_AUTO_SSID_SEL) { 1681 2440 ssid = NULL; 1682 2441 ssid_len = 0; 1683 2442 } ··· 1688 2447 1689 2448 if (bss) { 1690 2449 ieee80211_set_freq(sdata, bss->cbss.channel->center_freq); 1691 - if (!(ifsta->flags & IEEE80211_STA_SSID_SET)) 2450 + if (!(ifmgd->flags & IEEE80211_STA_SSID_SET)) 1692 2451 ieee80211_sta_set_ssid(sdata, bss->ssid, 1693 2452 bss->ssid_len); 1694 2453 ieee80211_sta_set_bssid(sdata, bss->cbss.bssid); 1695 2454 ieee80211_sta_def_wmm_params(sdata, bss->supp_rates_len, 1696 2455 bss->supp_rates); 1697 - if (sdata->u.sta.mfp == IEEE80211_MFP_REQUIRED) 1698 - sdata->u.sta.flags |= IEEE80211_STA_MFP_ENABLED; 2456 + if (sdata->u.mgd.mfp == IEEE80211_MFP_REQUIRED) 2457 + sdata->u.mgd.flags |= IEEE80211_STA_MFP_ENABLED; 1699 2458 else 1700 - sdata->u.sta.flags &= ~IEEE80211_STA_MFP_ENABLED; 2459 + sdata->u.mgd.flags &= ~IEEE80211_STA_MFP_ENABLED; 1701 2460 1702 2461 /* Send out direct probe if no probe resp was received or 1703 2462 * the one we have is outdated ··· 1705 2464 if (!bss->last_probe_resp || 1706 2465 time_after(jiffies, bss->last_probe_resp 1707 2466 + IEEE80211_SCAN_RESULT_EXPIRE)) 1708 - ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE; 2467 + ifmgd->state = IEEE80211_STA_MLME_DIRECT_PROBE; 1709 2468 else 1710 - ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; 2469 + ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE; 1711 2470 1712 2471 ieee80211_rx_bss_put(local, bss); 1713 - ieee80211_sta_reset_auth(sdata, ifsta); 2472 + ieee80211_sta_reset_auth(sdata); 1714 2473 return 0; 1715 2474 } else { 1716 - if (ifsta->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) { 1717 - ifsta->assoc_scan_tries++; 2475 + if (ifmgd->assoc_scan_tries < IEEE80211_ASSOC_SCANS_MAX_TRIES) { 2476 + ifmgd->assoc_scan_tries++; 1718 2477 /* XXX maybe racy? */ 1719 2478 if (local->scan_req) 1720 2479 return -1; 1721 2480 memcpy(local->int_scan_req.ssids[0].ssid, 1722 - ifsta->ssid, IEEE80211_MAX_SSID_LEN); 1723 - if (ifsta->flags & IEEE80211_STA_AUTO_SSID_SEL) 2481 + ifmgd->ssid, IEEE80211_MAX_SSID_LEN); 2482 + if (ifmgd->flags & IEEE80211_STA_AUTO_SSID_SEL) 1724 2483 local->int_scan_req.ssids[0].ssid_len = 0; 1725 2484 else 1726 - local->int_scan_req.ssids[0].ssid_len = ifsta->ssid_len; 2485 + local->int_scan_req.ssids[0].ssid_len = ifmgd->ssid_len; 1727 2486 ieee80211_start_scan(sdata, &local->int_scan_req); 1728 - ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; 1729 - set_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request); 2487 + ifmgd->state = IEEE80211_STA_MLME_AUTHENTICATE; 2488 + set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request); 1730 2489 } else { 1731 - ifsta->assoc_scan_tries = 0; 1732 - ifsta->state = IEEE80211_STA_MLME_DISABLED; 2490 + ifmgd->assoc_scan_tries = 0; 2491 + ifmgd->state = IEEE80211_STA_MLME_DISABLED; 1733 2492 } 1734 2493 } 1735 2494 return -1; ··· 1739 2498 static void ieee80211_sta_work(struct work_struct *work) 1740 2499 { 1741 2500 struct ieee80211_sub_if_data *sdata = 1742 - container_of(work, struct ieee80211_sub_if_data, u.sta.work); 2501 + container_of(work, struct ieee80211_sub_if_data, u.mgd.work); 1743 2502 struct ieee80211_local *local = sdata->local; 1744 - struct ieee80211_if_sta *ifsta; 2503 + struct ieee80211_if_managed *ifmgd; 1745 2504 struct sk_buff *skb; 1746 2505 1747 2506 if (!netif_running(sdata->dev)) ··· 1750 2509 if (local->sw_scanning || local->hw_scanning) 1751 2510 return; 1752 2511 1753 - if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION && 1754 - sdata->vif.type != NL80211_IFTYPE_ADHOC)) 2512 + if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) 1755 2513 return; 1756 - ifsta = &sdata->u.sta; 2514 + ifmgd = &sdata->u.mgd; 1757 2515 1758 - while ((skb = skb_dequeue(&ifsta->skb_queue))) 2516 + while ((skb = skb_dequeue(&ifmgd->skb_queue))) 1759 2517 ieee80211_sta_rx_queued_mgmt(sdata, skb); 1760 2518 1761 - if (ifsta->state != IEEE80211_STA_MLME_DIRECT_PROBE && 1762 - ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && 1763 - ifsta->state != IEEE80211_STA_MLME_ASSOCIATE && 1764 - test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) { 2519 + if (ifmgd->state != IEEE80211_STA_MLME_DIRECT_PROBE && 2520 + ifmgd->state != IEEE80211_STA_MLME_AUTHENTICATE && 2521 + ifmgd->state != IEEE80211_STA_MLME_ASSOCIATE && 2522 + test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request)) { 1765 2523 ieee80211_start_scan(sdata, local->scan_req); 1766 2524 return; 1767 2525 } 1768 2526 1769 - if (test_and_clear_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request)) { 1770 - if (ieee80211_sta_config_auth(sdata, ifsta)) 2527 + if (test_and_clear_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request)) { 2528 + if (ieee80211_sta_config_auth(sdata)) 1771 2529 return; 1772 - clear_bit(IEEE80211_STA_REQ_RUN, &ifsta->request); 1773 - } else if (!test_and_clear_bit(IEEE80211_STA_REQ_RUN, &ifsta->request)) 2530 + clear_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request); 2531 + } else if (!test_and_clear_bit(IEEE80211_STA_REQ_RUN, &ifmgd->request)) 1774 2532 return; 1775 2533 1776 - switch (ifsta->state) { 2534 + switch (ifmgd->state) { 1777 2535 case IEEE80211_STA_MLME_DISABLED: 1778 2536 break; 1779 2537 case IEEE80211_STA_MLME_DIRECT_PROBE: 1780 - ieee80211_direct_probe(sdata, ifsta); 2538 + ieee80211_direct_probe(sdata); 1781 2539 break; 1782 2540 case IEEE80211_STA_MLME_AUTHENTICATE: 1783 - ieee80211_authenticate(sdata, ifsta); 2541 + ieee80211_authenticate(sdata); 1784 2542 break; 1785 2543 case IEEE80211_STA_MLME_ASSOCIATE: 1786 - ieee80211_associate(sdata, ifsta); 2544 + ieee80211_associate(sdata); 1787 2545 break; 1788 2546 case IEEE80211_STA_MLME_ASSOCIATED: 1789 - ieee80211_associated(sdata, ifsta); 1790 - break; 1791 - case IEEE80211_STA_MLME_IBSS_SEARCH: 1792 - ieee80211_sta_find_ibss(sdata, ifsta); 1793 - break; 1794 - case IEEE80211_STA_MLME_IBSS_JOINED: 1795 - ieee80211_sta_merge_ibss(sdata, ifsta); 2547 + ieee80211_associated(sdata); 1796 2548 break; 1797 2549 default: 1798 2550 WARN_ON(1); 1799 2551 break; 1800 2552 } 1801 2553 1802 - if (ieee80211_privacy_mismatch(sdata, ifsta)) { 2554 + if (ieee80211_privacy_mismatch(sdata)) { 1803 2555 printk(KERN_DEBUG "%s: privacy configuration mismatch and " 1804 2556 "mixed-cell disabled - disassociate\n", sdata->dev->name); 1805 2557 1806 - ieee80211_set_disassoc(sdata, ifsta, false, true, 2558 + ieee80211_set_disassoc(sdata, false, true, 1807 2559 WLAN_REASON_UNSPECIFIED); 1808 2560 } 1809 2561 } ··· 1805 2571 { 1806 2572 if (sdata->vif.type == NL80211_IFTYPE_STATION) 1807 2573 queue_work(sdata->local->hw.workqueue, 1808 - &sdata->u.sta.work); 2574 + &sdata->u.mgd.work); 1809 2575 } 1810 2576 1811 2577 /* interface setup */ 1812 2578 void ieee80211_sta_setup_sdata(struct ieee80211_sub_if_data *sdata) 1813 2579 { 1814 - struct ieee80211_if_sta *ifsta; 2580 + struct ieee80211_if_managed *ifmgd; 1815 2581 1816 - ifsta = &sdata->u.sta; 1817 - INIT_WORK(&ifsta->work, ieee80211_sta_work); 1818 - INIT_WORK(&ifsta->chswitch_work, ieee80211_chswitch_work); 1819 - setup_timer(&ifsta->timer, ieee80211_sta_timer, 2582 + ifmgd = &sdata->u.mgd; 2583 + INIT_WORK(&ifmgd->work, ieee80211_sta_work); 2584 + INIT_WORK(&ifmgd->chswitch_work, ieee80211_chswitch_work); 2585 + setup_timer(&ifmgd->timer, ieee80211_sta_timer, 1820 2586 (unsigned long) sdata); 1821 - setup_timer(&ifsta->chswitch_timer, ieee80211_chswitch_timer, 2587 + setup_timer(&ifmgd->chswitch_timer, ieee80211_chswitch_timer, 1822 2588 (unsigned long) sdata); 1823 - skb_queue_head_init(&ifsta->skb_queue); 2589 + skb_queue_head_init(&ifmgd->skb_queue); 1824 2590 1825 - ifsta->capab = WLAN_CAPABILITY_ESS; 1826 - ifsta->auth_algs = IEEE80211_AUTH_ALG_OPEN | 2591 + ifmgd->capab = WLAN_CAPABILITY_ESS; 2592 + ifmgd->auth_algs = IEEE80211_AUTH_ALG_OPEN | 1827 2593 IEEE80211_AUTH_ALG_SHARED_KEY; 1828 - ifsta->flags |= IEEE80211_STA_CREATE_IBSS | 2594 + ifmgd->flags |= IEEE80211_STA_CREATE_IBSS | 1829 2595 IEEE80211_STA_AUTO_BSSID_SEL | 1830 2596 IEEE80211_STA_AUTO_CHANNEL_SEL; 1831 2597 if (ieee80211_num_regular_queues(&sdata->local->hw) >= 4) 1832 - ifsta->flags |= IEEE80211_STA_WMM_ENABLED; 1833 - } 1834 - 1835 - /* 1836 - * Add a new IBSS station, will also be called by the RX code when, 1837 - * in IBSS mode, receiving a frame from a yet-unknown station, hence 1838 - * must be callable in atomic context. 1839 - */ 1840 - struct sta_info *ieee80211_ibss_add_sta(struct ieee80211_sub_if_data *sdata, 1841 - u8 *bssid,u8 *addr, u32 supp_rates) 1842 - { 1843 - struct ieee80211_local *local = sdata->local; 1844 - struct sta_info *sta; 1845 - int band = local->hw.conf.channel->band; 1846 - 1847 - /* TODO: Could consider removing the least recently used entry and 1848 - * allow new one to be added. */ 1849 - if (local->num_sta >= IEEE80211_IBSS_MAX_STA_ENTRIES) { 1850 - if (net_ratelimit()) { 1851 - printk(KERN_DEBUG "%s: No room for a new IBSS STA " 1852 - "entry %pM\n", sdata->dev->name, addr); 1853 - } 1854 - return NULL; 1855 - } 1856 - 1857 - if (compare_ether_addr(bssid, sdata->u.sta.bssid)) 1858 - return NULL; 1859 - 1860 - #ifdef CONFIG_MAC80211_VERBOSE_DEBUG 1861 - printk(KERN_DEBUG "%s: Adding new IBSS station %pM (dev=%s)\n", 1862 - wiphy_name(local->hw.wiphy), addr, sdata->dev->name); 1863 - #endif 1864 - 1865 - sta = sta_info_alloc(sdata, addr, GFP_ATOMIC); 1866 - if (!sta) 1867 - return NULL; 1868 - 1869 - set_sta_flags(sta, WLAN_STA_AUTHORIZED); 1870 - 1871 - /* make sure mandatory rates are always added */ 1872 - sta->sta.supp_rates[band] = supp_rates | 1873 - ieee80211_mandatory_rates(local, band); 1874 - 1875 - rate_control_rate_init(sta); 1876 - 1877 - if (sta_info_insert(sta)) 1878 - return NULL; 1879 - 1880 - return sta; 2598 + ifmgd->flags |= IEEE80211_STA_WMM_ENABLED; 1881 2599 } 1882 2600 1883 2601 /* configuration hooks */ 1884 - void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata, 1885 - struct ieee80211_if_sta *ifsta) 2602 + void ieee80211_sta_req_auth(struct ieee80211_sub_if_data *sdata) 1886 2603 { 2604 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1887 2605 struct ieee80211_local *local = sdata->local; 1888 2606 1889 - if (sdata->vif.type != NL80211_IFTYPE_STATION) 2607 + if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) 1890 2608 return; 1891 2609 1892 - if ((ifsta->flags & (IEEE80211_STA_BSSID_SET | 2610 + if ((ifmgd->flags & (IEEE80211_STA_BSSID_SET | 1893 2611 IEEE80211_STA_AUTO_BSSID_SEL)) && 1894 - (ifsta->flags & (IEEE80211_STA_SSID_SET | 2612 + (ifmgd->flags & (IEEE80211_STA_SSID_SET | 1895 2613 IEEE80211_STA_AUTO_SSID_SEL))) { 1896 2614 1897 - if (ifsta->state == IEEE80211_STA_MLME_ASSOCIATED) 1898 - ieee80211_set_disassoc(sdata, ifsta, true, true, 2615 + if (ifmgd->state == IEEE80211_STA_MLME_ASSOCIATED) 2616 + ieee80211_set_disassoc(sdata, true, true, 1899 2617 WLAN_REASON_DEAUTH_LEAVING); 1900 2618 1901 - set_bit(IEEE80211_STA_REQ_AUTH, &ifsta->request); 1902 - queue_work(local->hw.workqueue, &ifsta->work); 2619 + set_bit(IEEE80211_STA_REQ_AUTH, &ifmgd->request); 2620 + queue_work(local->hw.workqueue, &ifmgd->work); 1903 2621 } 1904 2622 } 1905 2623 1906 - int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len) 2624 + int ieee80211_sta_commit(struct ieee80211_sub_if_data *sdata) 1907 2625 { 1908 - struct ieee80211_if_sta *ifsta; 2626 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1909 2627 1910 - if (len > IEEE80211_MAX_SSID_LEN) 1911 - return -EINVAL; 2628 + ifmgd->flags &= ~IEEE80211_STA_PREV_BSSID_SET; 1912 2629 1913 - ifsta = &sdata->u.sta; 1914 - 1915 - if (ifsta->ssid_len != len || memcmp(ifsta->ssid, ssid, len) != 0) { 1916 - memset(ifsta->ssid, 0, sizeof(ifsta->ssid)); 1917 - memcpy(ifsta->ssid, ssid, len); 1918 - ifsta->ssid_len = len; 1919 - } 1920 - 1921 - ifsta->flags &= ~IEEE80211_STA_PREV_BSSID_SET; 1922 - 1923 - if (len) 1924 - ifsta->flags |= IEEE80211_STA_SSID_SET; 2630 + if (ifmgd->ssid_len) 2631 + ifmgd->flags |= IEEE80211_STA_SSID_SET; 1925 2632 else 1926 - ifsta->flags &= ~IEEE80211_STA_SSID_SET; 1927 - 1928 - if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 1929 - ifsta->ibss_join_req = jiffies; 1930 - ifsta->state = IEEE80211_STA_MLME_IBSS_SEARCH; 1931 - return ieee80211_sta_find_ibss(sdata, ifsta); 1932 - } 2633 + ifmgd->flags &= ~IEEE80211_STA_SSID_SET; 1933 2634 1934 2635 return 0; 1935 2636 } 1936 2637 2638 + int ieee80211_sta_set_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t len) 2639 + { 2640 + struct ieee80211_if_managed *ifmgd; 2641 + 2642 + if (len > IEEE80211_MAX_SSID_LEN) 2643 + return -EINVAL; 2644 + 2645 + ifmgd = &sdata->u.mgd; 2646 + 2647 + if (ifmgd->ssid_len != len || memcmp(ifmgd->ssid, ssid, len) != 0) { 2648 + memset(ifmgd->ssid, 0, sizeof(ifmgd->ssid)); 2649 + memcpy(ifmgd->ssid, ssid, len); 2650 + ifmgd->ssid_len = len; 2651 + } 2652 + 2653 + return ieee80211_sta_commit(sdata); 2654 + } 2655 + 1937 2656 int ieee80211_sta_get_ssid(struct ieee80211_sub_if_data *sdata, char *ssid, size_t *len) 1938 2657 { 1939 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 1940 - memcpy(ssid, ifsta->ssid, ifsta->ssid_len); 1941 - *len = ifsta->ssid_len; 2658 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 2659 + memcpy(ssid, ifmgd->ssid, ifmgd->ssid_len); 2660 + *len = ifmgd->ssid_len; 1942 2661 return 0; 1943 2662 } 1944 2663 1945 2664 int ieee80211_sta_set_bssid(struct ieee80211_sub_if_data *sdata, u8 *bssid) 1946 2665 { 1947 - struct ieee80211_if_sta *ifsta; 1948 - 1949 - ifsta = &sdata->u.sta; 2666 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1950 2667 1951 2668 if (is_valid_ether_addr(bssid)) { 1952 - memcpy(ifsta->bssid, bssid, ETH_ALEN); 1953 - ifsta->flags |= IEEE80211_STA_BSSID_SET; 2669 + memcpy(ifmgd->bssid, bssid, ETH_ALEN); 2670 + ifmgd->flags |= IEEE80211_STA_BSSID_SET; 1954 2671 } else { 1955 - memset(ifsta->bssid, 0, ETH_ALEN); 1956 - ifsta->flags &= ~IEEE80211_STA_BSSID_SET; 2672 + memset(ifmgd->bssid, 0, ETH_ALEN); 2673 + ifmgd->flags &= ~IEEE80211_STA_BSSID_SET; 1957 2674 } 1958 2675 1959 2676 if (netif_running(sdata->dev)) { ··· 1914 2729 } 1915 2730 } 1916 2731 1917 - return ieee80211_sta_set_ssid(sdata, ifsta->ssid, ifsta->ssid_len); 2732 + return ieee80211_sta_commit(sdata); 1918 2733 } 1919 2734 1920 2735 int ieee80211_sta_set_extra_ie(struct ieee80211_sub_if_data *sdata, char *ie, size_t len) 1921 2736 { 1922 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 2737 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1923 2738 1924 - kfree(ifsta->extra_ie); 2739 + kfree(ifmgd->extra_ie); 1925 2740 if (len == 0) { 1926 - ifsta->extra_ie = NULL; 1927 - ifsta->extra_ie_len = 0; 2741 + ifmgd->extra_ie = NULL; 2742 + ifmgd->extra_ie_len = 0; 1928 2743 return 0; 1929 2744 } 1930 - ifsta->extra_ie = kmalloc(len, GFP_KERNEL); 1931 - if (!ifsta->extra_ie) { 1932 - ifsta->extra_ie_len = 0; 2745 + ifmgd->extra_ie = kmalloc(len, GFP_KERNEL); 2746 + if (!ifmgd->extra_ie) { 2747 + ifmgd->extra_ie_len = 0; 1933 2748 return -ENOMEM; 1934 2749 } 1935 - memcpy(ifsta->extra_ie, ie, len); 1936 - ifsta->extra_ie_len = len; 2750 + memcpy(ifmgd->extra_ie, ie, len); 2751 + ifmgd->extra_ie_len = len; 1937 2752 return 0; 1938 2753 } 1939 2754 1940 2755 int ieee80211_sta_deauthenticate(struct ieee80211_sub_if_data *sdata, u16 reason) 1941 2756 { 1942 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 1943 - 1944 2757 printk(KERN_DEBUG "%s: deauthenticating by local choice (reason=%d)\n", 1945 2758 sdata->dev->name, reason); 1946 2759 1947 - if (sdata->vif.type != NL80211_IFTYPE_STATION && 1948 - sdata->vif.type != NL80211_IFTYPE_ADHOC) 2760 + if (sdata->vif.type != NL80211_IFTYPE_STATION) 1949 2761 return -EINVAL; 1950 2762 1951 - ieee80211_set_disassoc(sdata, ifsta, true, true, reason); 2763 + ieee80211_set_disassoc(sdata, true, true, reason); 1952 2764 return 0; 1953 2765 } 1954 2766 1955 2767 int ieee80211_sta_disassociate(struct ieee80211_sub_if_data *sdata, u16 reason) 1956 2768 { 1957 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 2769 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 1958 2770 1959 2771 printk(KERN_DEBUG "%s: disassociating by local choice (reason=%d)\n", 1960 2772 sdata->dev->name, reason); ··· 1959 2777 if (sdata->vif.type != NL80211_IFTYPE_STATION) 1960 2778 return -EINVAL; 1961 2779 1962 - if (!(ifsta->flags & IEEE80211_STA_ASSOCIATED)) 1963 - return -1; 2780 + if (!(ifmgd->flags & IEEE80211_STA_ASSOCIATED)) 2781 + return -ENOLINK; 1964 2782 1965 - ieee80211_set_disassoc(sdata, ifsta, false, true, reason); 2783 + ieee80211_set_disassoc(sdata, false, true, reason); 1966 2784 return 0; 1967 2785 } 1968 2786 ··· 1970 2788 void ieee80211_mlme_notify_scan_completed(struct ieee80211_local *local) 1971 2789 { 1972 2790 struct ieee80211_sub_if_data *sdata = local->scan_sdata; 1973 - struct ieee80211_if_sta *ifsta; 1974 - 1975 - if (sdata && sdata->vif.type == NL80211_IFTYPE_ADHOC) { 1976 - ifsta = &sdata->u.sta; 1977 - if ((!(ifsta->flags & IEEE80211_STA_PREV_BSSID_SET)) || 1978 - !ieee80211_sta_active_ibss(sdata)) 1979 - ieee80211_sta_find_ibss(sdata, ifsta); 1980 - } 1981 2791 1982 2792 /* Restart STA timers */ 1983 2793 rcu_read_lock(); ··· 2015 2841 struct ieee80211_local *local = (void *) data; 2016 2842 2017 2843 queue_work(local->hw.workqueue, &local->dynamic_ps_enable_work); 2844 + } 2845 + 2846 + void ieee80211_send_nullfunc(struct ieee80211_local *local, 2847 + struct ieee80211_sub_if_data *sdata, 2848 + int powersave) 2849 + { 2850 + struct sk_buff *skb; 2851 + struct ieee80211_hdr *nullfunc; 2852 + __le16 fc; 2853 + 2854 + if (WARN_ON(sdata->vif.type != NL80211_IFTYPE_STATION)) 2855 + return; 2856 + 2857 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); 2858 + if (!skb) { 2859 + printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc " 2860 + "frame\n", sdata->dev->name); 2861 + return; 2862 + } 2863 + skb_reserve(skb, local->hw.extra_tx_headroom); 2864 + 2865 + nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); 2866 + memset(nullfunc, 0, 24); 2867 + fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | 2868 + IEEE80211_FCTL_TODS); 2869 + if (powersave) 2870 + fc |= cpu_to_le16(IEEE80211_FCTL_PM); 2871 + nullfunc->frame_control = fc; 2872 + memcpy(nullfunc->addr1, sdata->u.mgd.bssid, ETH_ALEN); 2873 + memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN); 2874 + memcpy(nullfunc->addr3, sdata->u.mgd.bssid, ETH_ALEN); 2875 + 2876 + ieee80211_tx_skb(sdata, skb, 0); 2018 2877 }
+12
net/mac80211/rate.h
··· 62 62 ref->ops->rate_init(ref->priv, sband, ista, priv_sta); 63 63 } 64 64 65 + static inline void rate_control_rate_update(struct ieee80211_local *local, 66 + struct ieee80211_supported_band *sband, 67 + struct sta_info *sta, u32 changed) 68 + { 69 + struct rate_control_ref *ref = local->rate_ctrl; 70 + struct ieee80211_sta *ista = &sta->sta; 71 + void *priv_sta = sta->rate_ctrl_priv; 72 + 73 + if (ref->ops->rate_update) 74 + ref->ops->rate_update(ref->priv, sband, ista, 75 + priv_sta, changed); 76 + } 65 77 66 78 static inline void *rate_control_alloc_sta(struct rate_control_ref *ref, 67 79 struct ieee80211_sta *sta,
+22 -15
net/mac80211/rx.c
··· 838 838 if (rx->sdata->vif.type == NL80211_IFTYPE_ADHOC) { 839 839 u8 *bssid = ieee80211_get_bssid(hdr, rx->skb->len, 840 840 NL80211_IFTYPE_ADHOC); 841 - if (compare_ether_addr(bssid, rx->sdata->u.sta.bssid) == 0) 841 + if (compare_ether_addr(bssid, rx->sdata->u.ibss.bssid) == 0) 842 842 sta->last_rx = jiffies; 843 843 } else 844 844 if (!is_multicast_ether_addr(hdr->addr1) || ··· 1702 1702 return; 1703 1703 } 1704 1704 1705 - if (compare_ether_addr(mgmt->sa, sdata->u.sta.bssid) != 0 || 1706 - compare_ether_addr(mgmt->bssid, sdata->u.sta.bssid) != 0) { 1705 + if (compare_ether_addr(mgmt->sa, sdata->u.mgd.bssid) != 0 || 1706 + compare_ether_addr(mgmt->bssid, sdata->u.mgd.bssid) != 0) { 1707 1707 /* Not from the current AP. */ 1708 1708 return; 1709 1709 } 1710 1710 1711 - if (sdata->u.sta.state == IEEE80211_STA_MLME_ASSOCIATE) { 1711 + if (sdata->u.mgd.state == IEEE80211_STA_MLME_ASSOCIATE) { 1712 1712 /* Association in progress; ignore SA Query */ 1713 1713 return; 1714 1714 } ··· 1727 1727 memset(resp, 0, 24); 1728 1728 memcpy(resp->da, mgmt->sa, ETH_ALEN); 1729 1729 memcpy(resp->sa, sdata->dev->dev_addr, ETH_ALEN); 1730 - memcpy(resp->bssid, sdata->u.sta.bssid, ETH_ALEN); 1730 + memcpy(resp->bssid, sdata->u.mgd.bssid, ETH_ALEN); 1731 1731 resp->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 1732 1732 IEEE80211_STYPE_ACTION); 1733 1733 skb_put(skb, 1 + sizeof(resp->u.action.u.sa_query)); ··· 1745 1745 { 1746 1746 struct ieee80211_local *local = rx->local; 1747 1747 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(rx->dev); 1748 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 1749 1748 struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *) rx->skb->data; 1750 1749 struct ieee80211_bss *bss; 1751 1750 int len = rx->skb->len; ··· 1802 1803 case WLAN_CATEGORY_SPECTRUM_MGMT: 1803 1804 if (local->hw.conf.channel->band != IEEE80211_BAND_5GHZ) 1804 1805 return RX_DROP_MONITOR; 1806 + 1807 + if (sdata->vif.type != NL80211_IFTYPE_STATION) 1808 + return RX_DROP_MONITOR; 1809 + 1805 1810 switch (mgmt->u.action.u.measurement.action_code) { 1806 1811 case WLAN_ACTION_SPCT_MSR_REQ: 1807 1812 if (len < (IEEE80211_MIN_ACTION_SIZE + ··· 1818 1815 sizeof(mgmt->u.action.u.chan_switch))) 1819 1816 return RX_DROP_MONITOR; 1820 1817 1821 - if (memcmp(mgmt->bssid, ifsta->bssid, ETH_ALEN) != 0) 1818 + if (memcmp(mgmt->bssid, sdata->u.mgd.bssid, ETH_ALEN)) 1822 1819 return RX_DROP_MONITOR; 1823 1820 1824 - bss = ieee80211_rx_bss_get(local, ifsta->bssid, 1821 + bss = ieee80211_rx_bss_get(local, sdata->u.mgd.bssid, 1825 1822 local->hw.conf.channel->center_freq, 1826 - ifsta->ssid, ifsta->ssid_len); 1823 + sdata->u.mgd.ssid, 1824 + sdata->u.mgd.ssid_len); 1827 1825 if (!bss) 1828 1826 return RX_DROP_MONITOR; 1829 1827 ··· 1880 1876 sdata->vif.type != NL80211_IFTYPE_ADHOC) 1881 1877 return RX_DROP_MONITOR; 1882 1878 1883 - if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) 1884 - return RX_DROP_MONITOR; 1885 1879 1886 - ieee80211_sta_rx_mgmt(sdata, rx->skb, rx->status); 1887 - return RX_QUEUED; 1880 + if (sdata->vif.type == NL80211_IFTYPE_STATION) { 1881 + if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) 1882 + return RX_DROP_MONITOR; 1883 + return ieee80211_sta_rx_mgmt(sdata, rx->skb, rx->status); 1884 + } 1885 + 1886 + return ieee80211_ibss_rx_mgmt(sdata, rx->skb, rx->status); 1888 1887 } 1889 1888 1890 1889 static void ieee80211_rx_michael_mic_report(struct net_device *dev, ··· 2090 2083 case NL80211_IFTYPE_STATION: 2091 2084 if (!bssid) 2092 2085 return 0; 2093 - if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { 2086 + if (!ieee80211_bssid_match(bssid, sdata->u.mgd.bssid)) { 2094 2087 if (!(rx->flags & IEEE80211_RX_IN_SCAN)) 2095 2088 return 0; 2096 2089 rx->flags &= ~IEEE80211_RX_RA_MATCH; ··· 2108 2101 if (ieee80211_is_beacon(hdr->frame_control)) { 2109 2102 return 1; 2110 2103 } 2111 - else if (!ieee80211_bssid_match(bssid, sdata->u.sta.bssid)) { 2104 + else if (!ieee80211_bssid_match(bssid, sdata->u.ibss.bssid)) { 2112 2105 if (!(rx->flags & IEEE80211_RX_IN_SCAN)) 2113 2106 return 0; 2114 2107 rx->flags &= ~IEEE80211_RX_RA_MATCH;
+17 -45
net/mac80211/scan.c
··· 63 63 { 64 64 struct ieee80211_bss *bss; 65 65 int clen; 66 - enum cfg80211_signal_type sigtype = CFG80211_SIGNAL_TYPE_NONE; 67 66 s32 signal = 0; 68 67 69 - if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) { 70 - sigtype = CFG80211_SIGNAL_TYPE_MBM; 68 + if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) 71 69 signal = rx_status->signal * 100; 72 - } else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) { 73 - sigtype = CFG80211_SIGNAL_TYPE_UNSPEC; 70 + else if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) 74 71 signal = (rx_status->signal * 100) / local->hw.max_signal; 75 - } 76 72 77 73 bss = (void *)cfg80211_inform_bss_frame(local->hw.wiphy, channel, 78 - mgmt, len, signal, sigtype, 79 - GFP_ATOMIC); 74 + mgmt, len, signal, GFP_ATOMIC); 80 75 81 76 if (!bss) 82 77 return NULL; ··· 202 207 return RX_QUEUED; 203 208 } 204 209 205 - void ieee80211_send_nullfunc(struct ieee80211_local *local, 206 - struct ieee80211_sub_if_data *sdata, 207 - int powersave) 208 - { 209 - struct sk_buff *skb; 210 - struct ieee80211_hdr *nullfunc; 211 - __le16 fc; 212 - 213 - skb = dev_alloc_skb(local->hw.extra_tx_headroom + 24); 214 - if (!skb) { 215 - printk(KERN_DEBUG "%s: failed to allocate buffer for nullfunc " 216 - "frame\n", sdata->dev->name); 217 - return; 218 - } 219 - skb_reserve(skb, local->hw.extra_tx_headroom); 220 - 221 - nullfunc = (struct ieee80211_hdr *) skb_put(skb, 24); 222 - memset(nullfunc, 0, 24); 223 - fc = cpu_to_le16(IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC | 224 - IEEE80211_FCTL_TODS); 225 - if (powersave) 226 - fc |= cpu_to_le16(IEEE80211_FCTL_PM); 227 - nullfunc->frame_control = fc; 228 - memcpy(nullfunc->addr1, sdata->u.sta.bssid, ETH_ALEN); 229 - memcpy(nullfunc->addr2, sdata->dev->dev_addr, ETH_ALEN); 230 - memcpy(nullfunc->addr3, sdata->u.sta.bssid, ETH_ALEN); 231 - 232 - ieee80211_tx_skb(sdata, skb, 0); 233 - } 234 - 235 210 void ieee80211_scan_completed(struct ieee80211_hw *hw, bool aborted) 236 211 { 237 212 struct ieee80211_local *local = hw_to_local(hw); ··· 245 280 netif_addr_unlock(local->mdev); 246 281 netif_tx_unlock_bh(local->mdev); 247 282 283 + if (local->ops->sw_scan_complete) 284 + local->ops->sw_scan_complete(local_to_hw(local)); 285 + 248 286 mutex_lock(&local->iflist_mtx); 249 287 list_for_each_entry(sdata, &local->interfaces, list) { 250 288 if (!netif_running(sdata->dev)) ··· 255 287 256 288 /* Tell AP we're back */ 257 289 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 258 - if (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) { 290 + if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) { 259 291 ieee80211_send_nullfunc(local, sdata, 0); 260 292 netif_tx_wake_all_queues(sdata->dev); 261 293 } ··· 273 305 274 306 done: 275 307 ieee80211_mlme_notify_scan_completed(local); 308 + ieee80211_ibss_notify_scan_completed(local); 276 309 ieee80211_mesh_notify_scan_completed(local); 277 310 } 278 311 EXPORT_SYMBOL(ieee80211_scan_completed); ··· 336 367 ieee80211_send_probe_req( 337 368 sdata, NULL, 338 369 local->scan_req->ssids[i].ssid, 339 - local->scan_req->ssids[i].ssid_len); 370 + local->scan_req->ssids[i].ssid_len, 371 + local->scan_req->ie, local->scan_req->ie_len); 340 372 next_delay = IEEE80211_CHANNEL_TIME; 341 373 break; 342 374 } ··· 398 428 } 399 429 400 430 local->sw_scanning = true; 431 + if (local->ops->sw_scan_start) 432 + local->ops->sw_scan_start(local_to_hw(local)); 401 433 402 434 mutex_lock(&local->iflist_mtx); 403 435 list_for_each_entry(sdata, &local->interfaces, list) { ··· 414 442 IEEE80211_IFCC_BEACON_ENABLED); 415 443 416 444 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 417 - if (sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED) { 445 + if (sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED) { 418 446 netif_tx_stop_all_queues(sdata->dev); 419 447 ieee80211_send_nullfunc(local, sdata, 1); 420 448 } ··· 449 477 struct cfg80211_scan_request *req) 450 478 { 451 479 struct ieee80211_local *local = sdata->local; 452 - struct ieee80211_if_sta *ifsta; 480 + struct ieee80211_if_managed *ifmgd; 453 481 454 482 if (!req) 455 483 return -EINVAL; ··· 474 502 return -EBUSY; 475 503 } 476 504 477 - ifsta = &sdata->u.sta; 478 - set_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request); 479 - queue_work(local->hw.workqueue, &ifsta->work); 505 + ifmgd = &sdata->u.mgd; 506 + set_bit(IEEE80211_STA_REQ_SCAN, &ifmgd->request); 507 + queue_work(local->hw.workqueue, &ifmgd->work); 480 508 481 509 return 0; 482 510 }
+13 -13
net/mac80211/spectmgmt.c
··· 88 88 void ieee80211_chswitch_work(struct work_struct *work) 89 89 { 90 90 struct ieee80211_sub_if_data *sdata = 91 - container_of(work, struct ieee80211_sub_if_data, u.sta.chswitch_work); 91 + container_of(work, struct ieee80211_sub_if_data, u.mgd.chswitch_work); 92 92 struct ieee80211_bss *bss; 93 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 93 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 94 94 95 95 if (!netif_running(sdata->dev)) 96 96 return; 97 97 98 - bss = ieee80211_rx_bss_get(sdata->local, ifsta->bssid, 98 + bss = ieee80211_rx_bss_get(sdata->local, ifmgd->bssid, 99 99 sdata->local->hw.conf.channel->center_freq, 100 - ifsta->ssid, ifsta->ssid_len); 100 + ifmgd->ssid, ifmgd->ssid_len); 101 101 if (!bss) 102 102 goto exit; 103 103 ··· 108 108 109 109 ieee80211_rx_bss_put(sdata->local, bss); 110 110 exit: 111 - ifsta->flags &= ~IEEE80211_STA_CSA_RECEIVED; 111 + ifmgd->flags &= ~IEEE80211_STA_CSA_RECEIVED; 112 112 ieee80211_wake_queues_by_reason(&sdata->local->hw, 113 113 IEEE80211_QUEUE_STOP_REASON_CSA); 114 114 } ··· 117 117 { 118 118 struct ieee80211_sub_if_data *sdata = 119 119 (struct ieee80211_sub_if_data *) data; 120 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 120 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 121 121 122 - queue_work(sdata->local->hw.workqueue, &ifsta->chswitch_work); 122 + queue_work(sdata->local->hw.workqueue, &ifmgd->chswitch_work); 123 123 } 124 124 125 125 void ieee80211_process_chanswitch(struct ieee80211_sub_if_data *sdata, ··· 127 127 struct ieee80211_bss *bss) 128 128 { 129 129 struct ieee80211_channel *new_ch; 130 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 130 + struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; 131 131 int new_freq = ieee80211_channel_to_frequency(sw_elem->new_ch_num); 132 132 133 133 /* FIXME: Handle ADHOC later */ 134 134 if (sdata->vif.type != NL80211_IFTYPE_STATION) 135 135 return; 136 136 137 - if (ifsta->state != IEEE80211_STA_MLME_ASSOCIATED) 137 + if (ifmgd->state != IEEE80211_STA_MLME_ASSOCIATED) 138 138 return; 139 139 140 140 if (sdata->local->sw_scanning || sdata->local->hw_scanning) ··· 143 143 /* Disregard subsequent beacons if we are already running a timer 144 144 processing a CSA */ 145 145 146 - if (ifsta->flags & IEEE80211_STA_CSA_RECEIVED) 146 + if (ifmgd->flags & IEEE80211_STA_CSA_RECEIVED) 147 147 return; 148 148 149 149 new_ch = ieee80211_get_channel(sdata->local->hw.wiphy, new_freq); ··· 153 153 sdata->local->csa_channel = new_ch; 154 154 155 155 if (sw_elem->count <= 1) { 156 - queue_work(sdata->local->hw.workqueue, &ifsta->chswitch_work); 156 + queue_work(sdata->local->hw.workqueue, &ifmgd->chswitch_work); 157 157 } else { 158 158 ieee80211_stop_queues_by_reason(&sdata->local->hw, 159 159 IEEE80211_QUEUE_STOP_REASON_CSA); 160 - ifsta->flags |= IEEE80211_STA_CSA_RECEIVED; 161 - mod_timer(&ifsta->chswitch_timer, 160 + ifmgd->flags |= IEEE80211_STA_CSA_RECEIVED; 161 + mod_timer(&ifmgd->chswitch_timer, 162 162 jiffies + 163 163 msecs_to_jiffies(sw_elem->count * 164 164 bss->cbss.beacon_interval));
+13 -2
net/mac80211/sta_info.c
··· 202 202 /* Make sure timer won't free the tid_rx struct, see below */ 203 203 if (tid_rx) 204 204 tid_rx->shutdown = true; 205 + 206 + /* 207 + * The stop callback cannot find this station any more, but 208 + * it didn't complete its work -- start the queue if necessary 209 + */ 210 + if (sta->ampdu_mlme.tid_state_tx[i] & HT_AGG_STATE_INITIATOR_MSK && 211 + sta->ampdu_mlme.tid_state_tx[i] & HT_AGG_STATE_REQ_STOP_BA_MSK && 212 + local->hw.ampdu_queues) 213 + ieee80211_wake_queue_by_reason(&local->hw, 214 + local->hw.queues + sta->tid_to_tx_q[i], 215 + IEEE80211_QUEUE_STOP_REASON_AGGREGATION); 216 + 205 217 spin_unlock_bh(&sta->lock); 206 218 207 219 /* ··· 287 275 * enable session_timer's data differentiation. refer to 288 276 * sta_rx_agg_session_timer_expired for useage */ 289 277 sta->timer_to_tid[i] = i; 290 - /* tid to tx queue: initialize according to HW (0 is valid) */ 291 - sta->tid_to_tx_q[i] = ieee80211_num_queues(&local->hw); 278 + sta->tid_to_tx_q[i] = -1; 292 279 /* rx */ 293 280 sta->ampdu_mlme.tid_state_rx[i] = HT_AGG_STATE_IDLE; 294 281 sta->ampdu_mlme.tid_rx[i] = NULL;
+3 -2
net/mac80211/sta_info.h
··· 90 90 * @buf_size: buffer size for incoming A-MPDUs 91 91 * @timeout: reset timer value (in TUs). 92 92 * @dialog_token: dialog token for aggregation session 93 + * @shutdown: this session is being shut down due to STA removal 93 94 */ 94 95 struct tid_ampdu_rx { 95 96 struct sk_buff **reorder_buf; ··· 201 200 * @tid_seq: per-TID sequence numbers for sending to this STA 202 201 * @ampdu_mlme: A-MPDU state machine state 203 202 * @timer_to_tid: identity mapping to ID timers 204 - * @tid_to_tx_q: map tid to tx queue 203 + * @tid_to_tx_q: map tid to tx queue (invalid == negative values) 205 204 * @llid: Local link ID 206 205 * @plid: Peer link ID 207 206 * @reason: Cancel reason on PLINK_HOLDING state ··· 276 275 */ 277 276 struct sta_ampdu_mlme ampdu_mlme; 278 277 u8 timer_to_tid[STA_TID_NUM]; 279 - u8 tid_to_tx_q[STA_TID_NUM]; 278 + s8 tid_to_tx_q[STA_TID_NUM]; 280 279 281 280 #ifdef CONFIG_MAC80211_MESH 282 281 /*
+18 -11
net/mac80211/tx.c
··· 876 876 return TX_CONTINUE; 877 877 } 878 878 879 - 880 879 /* actual transmit path */ 881 880 882 881 /* ··· 1015 1016 tx->sta = sta_info_get(local, hdr->addr1); 1016 1017 1017 1018 if (tx->sta && ieee80211_is_data_qos(hdr->frame_control)) { 1019 + unsigned long flags; 1018 1020 qc = ieee80211_get_qos_ctl(hdr); 1019 1021 tid = *qc & IEEE80211_QOS_CTL_TID_MASK; 1020 1022 1023 + spin_lock_irqsave(&tx->sta->lock, flags); 1021 1024 state = &tx->sta->ampdu_mlme.tid_state_tx[tid]; 1022 - if (*state == HT_AGG_STATE_OPERATIONAL) 1025 + if (*state == HT_AGG_STATE_OPERATIONAL) { 1023 1026 info->flags |= IEEE80211_TX_CTL_AMPDU; 1027 + if (local->hw.ampdu_queues) 1028 + skb_set_queue_mapping( 1029 + skb, tx->local->hw.queues + 1030 + tx->sta->tid_to_tx_q[tid]); 1031 + } 1032 + spin_unlock_irqrestore(&tx->sta->lock, flags); 1024 1033 } 1025 1034 1026 1035 if (is_multicast_ether_addr(hdr->addr1)) { ··· 1092 1085 int ret, i; 1093 1086 1094 1087 if (skb) { 1095 - if (netif_subqueue_stopped(local->mdev, skb)) 1088 + if (ieee80211_queue_stopped(&local->hw, 1089 + skb_get_queue_mapping(skb))) 1096 1090 return IEEE80211_TX_PENDING; 1097 1091 1098 1092 ret = local->ops->tx(local_to_hw(local), skb); ··· 1109 1101 info = IEEE80211_SKB_CB(tx->extra_frag[i]); 1110 1102 info->flags &= ~(IEEE80211_TX_CTL_CLEAR_PS_FILT | 1111 1103 IEEE80211_TX_CTL_FIRST_FRAGMENT); 1112 - if (netif_subqueue_stopped(local->mdev, 1113 - tx->extra_frag[i])) 1104 + if (ieee80211_queue_stopped(&local->hw, 1105 + skb_get_queue_mapping(tx->extra_frag[i]))) 1114 1106 return IEEE80211_TX_FRAG_AGAIN; 1115 1107 1116 1108 ret = local->ops->tx(local_to_hw(local), ··· 1633 1625 case NL80211_IFTYPE_STATION: 1634 1626 fc |= cpu_to_le16(IEEE80211_FCTL_TODS); 1635 1627 /* BSSID SA DA */ 1636 - memcpy(hdr.addr1, sdata->u.sta.bssid, ETH_ALEN); 1628 + memcpy(hdr.addr1, sdata->u.mgd.bssid, ETH_ALEN); 1637 1629 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); 1638 1630 memcpy(hdr.addr3, skb->data, ETH_ALEN); 1639 1631 hdrlen = 24; ··· 1642 1634 /* DA SA BSSID */ 1643 1635 memcpy(hdr.addr1, skb->data, ETH_ALEN); 1644 1636 memcpy(hdr.addr2, skb->data + ETH_ALEN, ETH_ALEN); 1645 - memcpy(hdr.addr3, sdata->u.sta.bssid, ETH_ALEN); 1637 + memcpy(hdr.addr3, sdata->u.ibss.bssid, ETH_ALEN); 1646 1638 hdrlen = 24; 1647 1639 break; 1648 1640 default: ··· 1928 1920 struct ieee80211_tx_info *info; 1929 1921 struct ieee80211_sub_if_data *sdata = NULL; 1930 1922 struct ieee80211_if_ap *ap = NULL; 1931 - struct ieee80211_if_sta *ifsta = NULL; 1932 1923 struct beacon_data *beacon; 1933 1924 struct ieee80211_supported_band *sband; 1934 1925 enum ieee80211_band band = local->hw.conf.channel->band; ··· 1979 1972 } else 1980 1973 goto out; 1981 1974 } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 1975 + struct ieee80211_if_ibss *ifibss = &sdata->u.ibss; 1982 1976 struct ieee80211_hdr *hdr; 1983 - ifsta = &sdata->u.sta; 1984 1977 1985 - if (!ifsta->probe_resp) 1978 + if (!ifibss->probe_resp) 1986 1979 goto out; 1987 1980 1988 - skb = skb_copy(ifsta->probe_resp, GFP_ATOMIC); 1981 + skb = skb_copy(ifibss->probe_resp, GFP_ATOMIC); 1989 1982 if (!skb) 1990 1983 goto out; 1991 1984
+242 -14
net/mac80211/util.c
··· 344 344 { 345 345 struct ieee80211_local *local = hw_to_local(hw); 346 346 347 - /* we don't need to track ampdu queues */ 348 - if (queue < ieee80211_num_regular_queues(hw)) { 349 - __clear_bit(reason, &local->queue_stop_reasons[queue]); 350 - 351 - if (local->queue_stop_reasons[queue] != 0) 352 - /* someone still has this queue stopped */ 347 + if (queue >= hw->queues) { 348 + if (local->ampdu_ac_queue[queue - hw->queues] < 0) 353 349 return; 350 + 351 + /* 352 + * for virtual aggregation queues, we need to refcount the 353 + * internal mac80211 disable (multiple times!), keep track of 354 + * driver disable _and_ make sure the regular queue is 355 + * actually enabled. 356 + */ 357 + if (reason == IEEE80211_QUEUE_STOP_REASON_AGGREGATION) 358 + local->amdpu_ac_stop_refcnt[queue - hw->queues]--; 359 + else 360 + __clear_bit(reason, &local->queue_stop_reasons[queue]); 361 + 362 + if (local->queue_stop_reasons[queue] || 363 + local->amdpu_ac_stop_refcnt[queue - hw->queues]) 364 + return; 365 + 366 + /* now go on to treat the corresponding regular queue */ 367 + queue = local->ampdu_ac_queue[queue - hw->queues]; 368 + reason = IEEE80211_QUEUE_STOP_REASON_AGGREGATION; 354 369 } 370 + 371 + __clear_bit(reason, &local->queue_stop_reasons[queue]); 372 + 373 + if (local->queue_stop_reasons[queue] != 0) 374 + /* someone still has this queue stopped */ 375 + return; 355 376 356 377 if (test_bit(queue, local->queues_pending)) { 357 378 set_bit(queue, local->queues_pending_run); ··· 382 361 } 383 362 } 384 363 385 - static void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, 386 - enum queue_stop_reason reason) 364 + void ieee80211_wake_queue_by_reason(struct ieee80211_hw *hw, int queue, 365 + enum queue_stop_reason reason) 387 366 { 388 367 struct ieee80211_local *local = hw_to_local(hw); 389 368 unsigned long flags; ··· 405 384 { 406 385 struct ieee80211_local *local = hw_to_local(hw); 407 386 408 - /* we don't need to track ampdu queues */ 409 - if (queue < ieee80211_num_regular_queues(hw)) 410 - __set_bit(reason, &local->queue_stop_reasons[queue]); 387 + if (queue >= hw->queues) { 388 + if (local->ampdu_ac_queue[queue - hw->queues] < 0) 389 + return; 390 + 391 + /* 392 + * for virtual aggregation queues, we need to refcount the 393 + * internal mac80211 disable (multiple times!), keep track of 394 + * driver disable _and_ make sure the regular queue is 395 + * actually enabled. 396 + */ 397 + if (reason == IEEE80211_QUEUE_STOP_REASON_AGGREGATION) 398 + local->amdpu_ac_stop_refcnt[queue - hw->queues]++; 399 + else 400 + __set_bit(reason, &local->queue_stop_reasons[queue]); 401 + 402 + /* now go on to treat the corresponding regular queue */ 403 + queue = local->ampdu_ac_queue[queue - hw->queues]; 404 + reason = IEEE80211_QUEUE_STOP_REASON_AGGREGATION; 405 + } 406 + 407 + __set_bit(reason, &local->queue_stop_reasons[queue]); 411 408 412 409 netif_stop_subqueue(local->mdev, queue); 413 410 } 414 411 415 - static void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue, 416 - enum queue_stop_reason reason) 412 + void ieee80211_stop_queue_by_reason(struct ieee80211_hw *hw, int queue, 413 + enum queue_stop_reason reason) 417 414 { 418 415 struct ieee80211_local *local = hw_to_local(hw); 419 416 unsigned long flags; ··· 457 418 458 419 spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 459 420 460 - for (i = 0; i < ieee80211_num_queues(hw); i++) 421 + for (i = 0; i < hw->queues; i++) 461 422 __ieee80211_stop_queue(hw, i, reason); 462 423 463 424 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); ··· 473 434 int ieee80211_queue_stopped(struct ieee80211_hw *hw, int queue) 474 435 { 475 436 struct ieee80211_local *local = hw_to_local(hw); 437 + unsigned long flags; 438 + 439 + if (queue >= hw->queues) { 440 + spin_lock_irqsave(&local->queue_stop_reason_lock, flags); 441 + queue = local->ampdu_ac_queue[queue - hw->queues]; 442 + spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags); 443 + if (queue < 0) 444 + return true; 445 + } 446 + 476 447 return __netif_subqueue_stopped(local->mdev, queue); 477 448 } 478 449 EXPORT_SYMBOL(ieee80211_queue_stopped); ··· 750 701 local->ops->conf_tx(local_to_hw(local), i, &qparam); 751 702 } 752 703 704 + void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, 705 + const size_t supp_rates_len, 706 + const u8 *supp_rates) 707 + { 708 + struct ieee80211_local *local = sdata->local; 709 + int i, have_higher_than_11mbit = 0; 710 + 711 + /* cf. IEEE 802.11 9.2.12 */ 712 + for (i = 0; i < supp_rates_len; i++) 713 + if ((supp_rates[i] & 0x7f) * 5 > 110) 714 + have_higher_than_11mbit = 1; 715 + 716 + if (local->hw.conf.channel->band == IEEE80211_BAND_2GHZ && 717 + have_higher_than_11mbit) 718 + sdata->flags |= IEEE80211_SDATA_OPERATING_GMODE; 719 + else 720 + sdata->flags &= ~IEEE80211_SDATA_OPERATING_GMODE; 721 + 722 + ieee80211_set_wmm_default(sdata); 723 + } 724 + 753 725 void ieee80211_tx_skb(struct ieee80211_sub_if_data *sdata, struct sk_buff *skb, 754 726 int encrypt) 755 727 { ··· 836 766 if (bitrates[i].flags & mandatory_flag) 837 767 mandatory_rates |= BIT(i); 838 768 return mandatory_rates; 769 + } 770 + 771 + void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, 772 + u16 transaction, u16 auth_alg, 773 + u8 *extra, size_t extra_len, 774 + const u8 *bssid, int encrypt) 775 + { 776 + struct ieee80211_local *local = sdata->local; 777 + struct sk_buff *skb; 778 + struct ieee80211_mgmt *mgmt; 779 + const u8 *ie_auth = NULL; 780 + int ie_auth_len = 0; 781 + 782 + if (sdata->vif.type == NL80211_IFTYPE_STATION) { 783 + ie_auth_len = sdata->u.mgd.ie_auth_len; 784 + ie_auth = sdata->u.mgd.ie_auth; 785 + } 786 + 787 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + 788 + sizeof(*mgmt) + 6 + extra_len + ie_auth_len); 789 + if (!skb) { 790 + printk(KERN_DEBUG "%s: failed to allocate buffer for auth " 791 + "frame\n", sdata->dev->name); 792 + return; 793 + } 794 + skb_reserve(skb, local->hw.extra_tx_headroom); 795 + 796 + mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24 + 6); 797 + memset(mgmt, 0, 24 + 6); 798 + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 799 + IEEE80211_STYPE_AUTH); 800 + if (encrypt) 801 + mgmt->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); 802 + memcpy(mgmt->da, bssid, ETH_ALEN); 803 + memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 804 + memcpy(mgmt->bssid, bssid, ETH_ALEN); 805 + mgmt->u.auth.auth_alg = cpu_to_le16(auth_alg); 806 + mgmt->u.auth.auth_transaction = cpu_to_le16(transaction); 807 + mgmt->u.auth.status_code = cpu_to_le16(0); 808 + if (extra) 809 + memcpy(skb_put(skb, extra_len), extra, extra_len); 810 + if (ie_auth) 811 + memcpy(skb_put(skb, ie_auth_len), ie_auth, ie_auth_len); 812 + 813 + ieee80211_tx_skb(sdata, skb, encrypt); 814 + } 815 + 816 + void ieee80211_send_probe_req(struct ieee80211_sub_if_data *sdata, u8 *dst, 817 + u8 *ssid, size_t ssid_len, 818 + u8 *ie, size_t ie_len) 819 + { 820 + struct ieee80211_local *local = sdata->local; 821 + struct ieee80211_supported_band *sband; 822 + struct sk_buff *skb; 823 + struct ieee80211_mgmt *mgmt; 824 + u8 *pos, *supp_rates, *esupp_rates = NULL, *extra_preq_ie = NULL; 825 + int i, extra_preq_ie_len = 0; 826 + 827 + switch (sdata->vif.type) { 828 + case NL80211_IFTYPE_STATION: 829 + extra_preq_ie_len = sdata->u.mgd.ie_probereq_len; 830 + extra_preq_ie = sdata->u.mgd.ie_probereq; 831 + break; 832 + default: 833 + break; 834 + } 835 + 836 + skb = dev_alloc_skb(local->hw.extra_tx_headroom + sizeof(*mgmt) + 200 + 837 + ie_len + extra_preq_ie_len); 838 + if (!skb) { 839 + printk(KERN_DEBUG "%s: failed to allocate buffer for probe " 840 + "request\n", sdata->dev->name); 841 + return; 842 + } 843 + skb_reserve(skb, local->hw.extra_tx_headroom); 844 + 845 + mgmt = (struct ieee80211_mgmt *) skb_put(skb, 24); 846 + memset(mgmt, 0, 24); 847 + mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT | 848 + IEEE80211_STYPE_PROBE_REQ); 849 + memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN); 850 + if (dst) { 851 + memcpy(mgmt->da, dst, ETH_ALEN); 852 + memcpy(mgmt->bssid, dst, ETH_ALEN); 853 + } else { 854 + memset(mgmt->da, 0xff, ETH_ALEN); 855 + memset(mgmt->bssid, 0xff, ETH_ALEN); 856 + } 857 + pos = skb_put(skb, 2 + ssid_len); 858 + *pos++ = WLAN_EID_SSID; 859 + *pos++ = ssid_len; 860 + memcpy(pos, ssid, ssid_len); 861 + 862 + supp_rates = skb_put(skb, 2); 863 + supp_rates[0] = WLAN_EID_SUPP_RATES; 864 + supp_rates[1] = 0; 865 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 866 + 867 + for (i = 0; i < sband->n_bitrates; i++) { 868 + struct ieee80211_rate *rate = &sband->bitrates[i]; 869 + if (esupp_rates) { 870 + pos = skb_put(skb, 1); 871 + esupp_rates[1]++; 872 + } else if (supp_rates[1] == 8) { 873 + esupp_rates = skb_put(skb, 3); 874 + esupp_rates[0] = WLAN_EID_EXT_SUPP_RATES; 875 + esupp_rates[1] = 1; 876 + pos = &esupp_rates[2]; 877 + } else { 878 + pos = skb_put(skb, 1); 879 + supp_rates[1]++; 880 + } 881 + *pos = rate->bitrate / 5; 882 + } 883 + 884 + if (ie) 885 + memcpy(skb_put(skb, ie_len), ie, ie_len); 886 + if (extra_preq_ie) 887 + memcpy(skb_put(skb, extra_preq_ie_len), extra_preq_ie, 888 + extra_preq_ie_len); 889 + 890 + ieee80211_tx_skb(sdata, skb, 0); 891 + } 892 + 893 + u32 ieee80211_sta_get_rates(struct ieee80211_local *local, 894 + struct ieee802_11_elems *elems, 895 + enum ieee80211_band band) 896 + { 897 + struct ieee80211_supported_band *sband; 898 + struct ieee80211_rate *bitrates; 899 + size_t num_rates; 900 + u32 supp_rates; 901 + int i, j; 902 + sband = local->hw.wiphy->bands[band]; 903 + 904 + if (!sband) { 905 + WARN_ON(1); 906 + sband = local->hw.wiphy->bands[local->hw.conf.channel->band]; 907 + } 908 + 909 + bitrates = sband->bitrates; 910 + num_rates = sband->n_bitrates; 911 + supp_rates = 0; 912 + for (i = 0; i < elems->supp_rates_len + 913 + elems->ext_supp_rates_len; i++) { 914 + u8 rate = 0; 915 + int own_rate; 916 + if (i < elems->supp_rates_len) 917 + rate = elems->supp_rates[i]; 918 + else if (elems->ext_supp_rates) 919 + rate = elems->ext_supp_rates 920 + [i - elems->supp_rates_len]; 921 + own_rate = 5 * (rate & 0x7f); 922 + for (j = 0; j < num_rates; j++) 923 + if (bitrates[j].bitrate == own_rate) 924 + supp_rates |= BIT(j); 925 + } 926 + return supp_rates; 839 927 }
+96 -166
net/mac80211/wext.c
··· 132 132 if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) 133 133 return -EOPNOTSUPP; 134 134 135 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 136 - sdata->vif.type == NL80211_IFTYPE_ADHOC) { 135 + if (sdata->vif.type == NL80211_IFTYPE_STATION) { 137 136 int ret = ieee80211_sta_set_extra_ie(sdata, extra, data->length); 138 137 if (ret) 139 138 return ret; 140 - sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; 141 - ieee80211_sta_req_auth(sdata, &sdata->u.sta); 139 + sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; 140 + ieee80211_sta_req_auth(sdata); 142 141 return 0; 143 142 } 144 143 145 144 return -EOPNOTSUPP; 146 145 } 147 - 148 - static u8 ieee80211_get_wstats_flags(struct ieee80211_local *local) 149 - { 150 - u8 wstats_flags = 0; 151 - 152 - wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC | 153 - IEEE80211_HW_SIGNAL_DBM) ? 154 - IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID; 155 - wstats_flags |= local->hw.flags & IEEE80211_HW_NOISE_DBM ? 156 - IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID; 157 - if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) 158 - wstats_flags |= IW_QUAL_DBM; 159 - 160 - return wstats_flags; 161 - } 162 - 163 - static int ieee80211_ioctl_giwrange(struct net_device *dev, 164 - struct iw_request_info *info, 165 - struct iw_point *data, char *extra) 166 - { 167 - struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); 168 - struct iw_range *range = (struct iw_range *) extra; 169 - enum ieee80211_band band; 170 - int c = 0; 171 - 172 - data->length = sizeof(struct iw_range); 173 - memset(range, 0, sizeof(struct iw_range)); 174 - 175 - range->we_version_compiled = WIRELESS_EXT; 176 - range->we_version_source = 21; 177 - range->retry_capa = IW_RETRY_LIMIT; 178 - range->retry_flags = IW_RETRY_LIMIT; 179 - range->min_retry = 0; 180 - range->max_retry = 255; 181 - range->min_rts = 0; 182 - range->max_rts = 2347; 183 - range->min_frag = 256; 184 - range->max_frag = 2346; 185 - 186 - range->encoding_size[0] = 5; 187 - range->encoding_size[1] = 13; 188 - range->num_encoding_sizes = 2; 189 - range->max_encoding_tokens = NUM_DEFAULT_KEYS; 190 - 191 - /* cfg80211 requires this, and enforces 0..100 */ 192 - if (local->hw.flags & IEEE80211_HW_SIGNAL_UNSPEC) 193 - range->max_qual.level = 100; 194 - else if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) 195 - range->max_qual.level = -110; 196 - else 197 - range->max_qual.level = 0; 198 - 199 - if (local->hw.flags & IEEE80211_HW_NOISE_DBM) 200 - range->max_qual.noise = -110; 201 - else 202 - range->max_qual.noise = 0; 203 - 204 - range->max_qual.qual = 100; 205 - range->max_qual.updated = ieee80211_get_wstats_flags(local); 206 - 207 - range->avg_qual.qual = 50; 208 - /* not always true but better than nothing */ 209 - range->avg_qual.level = range->max_qual.level / 2; 210 - range->avg_qual.noise = range->max_qual.noise / 2; 211 - range->avg_qual.updated = ieee80211_get_wstats_flags(local); 212 - 213 - range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | 214 - IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; 215 - 216 - 217 - for (band = 0; band < IEEE80211_NUM_BANDS; band ++) { 218 - int i; 219 - struct ieee80211_supported_band *sband; 220 - 221 - sband = local->hw.wiphy->bands[band]; 222 - 223 - if (!sband) 224 - continue; 225 - 226 - for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { 227 - struct ieee80211_channel *chan = &sband->channels[i]; 228 - 229 - if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { 230 - range->freq[c].i = 231 - ieee80211_frequency_to_channel( 232 - chan->center_freq); 233 - range->freq[c].m = chan->center_freq; 234 - range->freq[c].e = 6; 235 - c++; 236 - } 237 - } 238 - } 239 - range->num_channels = c; 240 - range->num_frequency = c; 241 - 242 - IW_EVENT_CAPA_SET_KERNEL(range->event_capa); 243 - IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); 244 - IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); 245 - 246 - range->scan_capa |= IW_SCAN_CAPA_ESSID; 247 - 248 - return 0; 249 - } 250 - 251 146 252 147 static int ieee80211_ioctl_siwfreq(struct net_device *dev, 253 148 struct iw_request_info *info, ··· 150 255 { 151 256 struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); 152 257 153 - if (sdata->vif.type == NL80211_IFTYPE_ADHOC || 154 - sdata->vif.type == NL80211_IFTYPE_STATION) 155 - sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL; 258 + if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 259 + sdata->u.ibss.flags &= ~IEEE80211_IBSS_AUTO_CHANNEL_SEL; 260 + else if (sdata->vif.type == NL80211_IFTYPE_STATION) 261 + sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_CHANNEL_SEL; 156 262 157 263 /* freq->e == 0: freq->m = channel; otherwise freq = m * 10^e */ 158 264 if (freq->e == 0) { 159 265 if (freq->m < 0) { 160 - if (sdata->vif.type == NL80211_IFTYPE_ADHOC || 161 - sdata->vif.type == NL80211_IFTYPE_STATION) 162 - sdata->u.sta.flags |= 266 + if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 267 + sdata->u.ibss.flags |= 268 + IEEE80211_IBSS_AUTO_CHANNEL_SEL; 269 + else if (sdata->vif.type == NL80211_IFTYPE_STATION) 270 + sdata->u.mgd.flags |= 163 271 IEEE80211_STA_AUTO_CHANNEL_SEL; 164 272 return 0; 165 273 } else ··· 199 301 { 200 302 struct ieee80211_sub_if_data *sdata; 201 303 size_t len = data->length; 304 + int ret; 202 305 203 306 /* iwconfig uses nul termination in SSID.. */ 204 307 if (len > 0 && ssid[len - 1] == '\0') 205 308 len--; 206 309 207 310 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 208 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 209 - sdata->vif.type == NL80211_IFTYPE_ADHOC) { 210 - int ret; 311 + if (sdata->vif.type == NL80211_IFTYPE_STATION) { 211 312 if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) { 212 313 if (len > IEEE80211_MAX_SSID_LEN) 213 314 return -EINVAL; 214 - memcpy(sdata->u.sta.ssid, ssid, len); 215 - sdata->u.sta.ssid_len = len; 315 + memcpy(sdata->u.mgd.ssid, ssid, len); 316 + sdata->u.mgd.ssid_len = len; 216 317 return 0; 217 318 } 319 + 218 320 if (data->flags) 219 - sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_SSID_SEL; 321 + sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_SSID_SEL; 220 322 else 221 - sdata->u.sta.flags |= IEEE80211_STA_AUTO_SSID_SEL; 323 + sdata->u.mgd.flags |= IEEE80211_STA_AUTO_SSID_SEL; 324 + 222 325 ret = ieee80211_sta_set_ssid(sdata, ssid, len); 223 326 if (ret) 224 327 return ret; 225 - ieee80211_sta_req_auth(sdata, &sdata->u.sta); 328 + 329 + ieee80211_sta_req_auth(sdata); 226 330 return 0; 227 - } 331 + } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) 332 + return ieee80211_ibss_set_ssid(sdata, ssid, len); 228 333 229 334 return -EOPNOTSUPP; 230 335 } ··· 241 340 242 341 struct ieee80211_sub_if_data *sdata; 243 342 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 244 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 245 - sdata->vif.type == NL80211_IFTYPE_ADHOC) { 343 + if (sdata->vif.type == NL80211_IFTYPE_STATION) { 246 344 int res = ieee80211_sta_get_ssid(sdata, ssid, &len); 345 + if (res == 0) { 346 + data->length = len; 347 + data->flags = 1; 348 + } else 349 + data->flags = 0; 350 + return res; 351 + } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 352 + int res = ieee80211_ibss_get_ssid(sdata, ssid, &len); 247 353 if (res == 0) { 248 354 data->length = len; 249 355 data->flags = 1; ··· 270 362 struct ieee80211_sub_if_data *sdata; 271 363 272 364 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 273 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 274 - sdata->vif.type == NL80211_IFTYPE_ADHOC) { 365 + if (sdata->vif.type == NL80211_IFTYPE_STATION) { 275 366 int ret; 276 367 if (sdata->flags & IEEE80211_SDATA_USERSPACE_MLME) { 277 - memcpy(sdata->u.sta.bssid, (u8 *) &ap_addr->sa_data, 368 + memcpy(sdata->u.mgd.bssid, (u8 *) &ap_addr->sa_data, 278 369 ETH_ALEN); 279 370 return 0; 280 371 } 281 372 if (is_zero_ether_addr((u8 *) &ap_addr->sa_data)) 282 - sdata->u.sta.flags |= IEEE80211_STA_AUTO_BSSID_SEL | 373 + sdata->u.mgd.flags |= IEEE80211_STA_AUTO_BSSID_SEL | 283 374 IEEE80211_STA_AUTO_CHANNEL_SEL; 284 375 else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data)) 285 - sdata->u.sta.flags |= IEEE80211_STA_AUTO_BSSID_SEL; 376 + sdata->u.mgd.flags |= IEEE80211_STA_AUTO_BSSID_SEL; 286 377 else 287 - sdata->u.sta.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; 378 + sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL; 288 379 ret = ieee80211_sta_set_bssid(sdata, (u8 *) &ap_addr->sa_data); 289 380 if (ret) 290 381 return ret; 291 - ieee80211_sta_req_auth(sdata, &sdata->u.sta); 382 + ieee80211_sta_req_auth(sdata); 292 383 return 0; 384 + } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 385 + if (is_zero_ether_addr((u8 *) &ap_addr->sa_data)) 386 + sdata->u.ibss.flags |= IEEE80211_IBSS_AUTO_BSSID_SEL | 387 + IEEE80211_IBSS_AUTO_CHANNEL_SEL; 388 + else if (is_broadcast_ether_addr((u8 *) &ap_addr->sa_data)) 389 + sdata->u.ibss.flags |= IEEE80211_IBSS_AUTO_BSSID_SEL; 390 + else 391 + sdata->u.ibss.flags &= ~IEEE80211_IBSS_AUTO_BSSID_SEL; 392 + 393 + return ieee80211_ibss_set_bssid(sdata, (u8 *) &ap_addr->sa_data); 293 394 } else if (sdata->vif.type == NL80211_IFTYPE_WDS) { 294 395 /* 295 396 * If it is necessary to update the WDS peer address ··· 327 410 struct ieee80211_sub_if_data *sdata; 328 411 329 412 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 330 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 331 - sdata->vif.type == NL80211_IFTYPE_ADHOC) { 332 - if (sdata->u.sta.state == IEEE80211_STA_MLME_ASSOCIATED || 333 - sdata->u.sta.state == IEEE80211_STA_MLME_IBSS_JOINED) { 413 + if (sdata->vif.type == NL80211_IFTYPE_STATION) { 414 + if (sdata->u.mgd.state == IEEE80211_STA_MLME_ASSOCIATED) { 334 415 ap_addr->sa_family = ARPHRD_ETHER; 335 - memcpy(&ap_addr->sa_data, sdata->u.sta.bssid, ETH_ALEN); 336 - return 0; 337 - } else { 416 + memcpy(&ap_addr->sa_data, sdata->u.mgd.bssid, ETH_ALEN); 417 + } else 338 418 memset(&ap_addr->sa_data, 0, ETH_ALEN); 339 - return 0; 340 - } 419 + return 0; 420 + } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) { 421 + if (sdata->u.ibss.state == IEEE80211_IBSS_MLME_JOINED) { 422 + ap_addr->sa_family = ARPHRD_ETHER; 423 + memcpy(&ap_addr->sa_data, sdata->u.ibss.bssid, ETH_ALEN); 424 + } else 425 + memset(&ap_addr->sa_data, 0, ETH_ALEN); 426 + return 0; 341 427 } else if (sdata->vif.type == NL80211_IFTYPE_WDS) { 342 428 ap_addr->sa_family = ARPHRD_ETHER; 343 429 memcpy(&ap_addr->sa_data, sdata->u.wds.remote_addr, ETH_ALEN); ··· 406 486 407 487 rcu_read_lock(); 408 488 409 - sta = sta_info_get(local, sdata->u.sta.bssid); 489 + sta = sta_info_get(local, sdata->u.mgd.bssid); 410 490 411 491 if (sta && !(sta->last_tx_rate.flags & IEEE80211_TX_RC_MCS)) 412 492 rate->value = sband->bitrates[sta->last_tx_rate.idx].bitrate; ··· 607 687 struct iw_mlme *mlme = (struct iw_mlme *) extra; 608 688 609 689 sdata = IEEE80211_DEV_TO_SUB_IF(dev); 610 - if (sdata->vif.type != NL80211_IFTYPE_STATION && 611 - sdata->vif.type != NL80211_IFTYPE_ADHOC) 690 + if (!(sdata->vif.type == NL80211_IFTYPE_STATION)) 612 691 return -EINVAL; 613 692 614 693 switch (mlme->cmd) { ··· 703 784 erq->flags |= IW_ENCODE_ENABLED; 704 785 705 786 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 706 - struct ieee80211_if_sta *ifsta = &sdata->u.sta; 707 - switch (ifsta->auth_alg) { 787 + switch (sdata->u.mgd.auth_alg) { 708 788 case WLAN_AUTH_OPEN: 709 789 case WLAN_AUTH_LEAP: 710 790 erq->flags |= IW_ENCODE_OPEN; ··· 767 849 ret = ieee80211_hw_config(local, 768 850 IEEE80211_CONF_CHANGE_DYNPS_TIMEOUT); 769 851 770 - if (!(sdata->u.sta.flags & IEEE80211_STA_ASSOCIATED)) 852 + if (!(sdata->u.mgd.flags & IEEE80211_STA_ASSOCIATED)) 771 853 return ret; 772 854 773 855 if (conf->dynamic_ps_timeout > 0 && ··· 826 908 if (sdata->vif.type == NL80211_IFTYPE_STATION) { 827 909 if (data->value & (IW_AUTH_CIPHER_WEP40 | 828 910 IW_AUTH_CIPHER_WEP104 | IW_AUTH_CIPHER_TKIP)) 829 - sdata->u.sta.flags |= 911 + sdata->u.mgd.flags |= 830 912 IEEE80211_STA_TKIP_WEP_USED; 831 913 else 832 - sdata->u.sta.flags &= 914 + sdata->u.mgd.flags &= 833 915 ~IEEE80211_STA_TKIP_WEP_USED; 834 916 } 835 917 break; ··· 840 922 if (sdata->vif.type != NL80211_IFTYPE_STATION) 841 923 ret = -EINVAL; 842 924 else { 843 - sdata->u.sta.flags &= ~IEEE80211_STA_PRIVACY_INVOKED; 925 + sdata->u.mgd.flags &= ~IEEE80211_STA_PRIVACY_INVOKED; 844 926 /* 845 927 * Privacy invoked by wpa_supplicant, store the 846 928 * value and allow associating to a protected 847 929 * network without having a key up front. 848 930 */ 849 931 if (data->value) 850 - sdata->u.sta.flags |= 932 + sdata->u.mgd.flags |= 851 933 IEEE80211_STA_PRIVACY_INVOKED; 852 934 } 853 935 break; 854 936 case IW_AUTH_80211_AUTH_ALG: 855 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 856 - sdata->vif.type == NL80211_IFTYPE_ADHOC) 857 - sdata->u.sta.auth_algs = data->value; 937 + if (sdata->vif.type == NL80211_IFTYPE_STATION) 938 + sdata->u.mgd.auth_algs = data->value; 858 939 else 859 940 ret = -EOPNOTSUPP; 860 941 break; ··· 862 945 ret = -EOPNOTSUPP; 863 946 break; 864 947 } 865 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 866 - sdata->vif.type == NL80211_IFTYPE_ADHOC) { 948 + if (sdata->vif.type == NL80211_IFTYPE_STATION) { 867 949 switch (data->value) { 868 950 case IW_AUTH_MFP_DISABLED: 869 - sdata->u.sta.mfp = IEEE80211_MFP_DISABLED; 951 + sdata->u.mgd.mfp = IEEE80211_MFP_DISABLED; 870 952 break; 871 953 case IW_AUTH_MFP_OPTIONAL: 872 - sdata->u.sta.mfp = IEEE80211_MFP_OPTIONAL; 954 + sdata->u.mgd.mfp = IEEE80211_MFP_OPTIONAL; 873 955 break; 874 956 case IW_AUTH_MFP_REQUIRED: 875 - sdata->u.sta.mfp = IEEE80211_MFP_REQUIRED; 957 + sdata->u.mgd.mfp = IEEE80211_MFP_REQUIRED; 876 958 break; 877 959 default: 878 960 ret = -EINVAL; ··· 886 970 return ret; 887 971 } 888 972 973 + static u8 ieee80211_get_wstats_flags(struct ieee80211_local *local) 974 + { 975 + u8 wstats_flags = 0; 976 + 977 + wstats_flags |= local->hw.flags & (IEEE80211_HW_SIGNAL_UNSPEC | 978 + IEEE80211_HW_SIGNAL_DBM) ? 979 + IW_QUAL_QUAL_UPDATED : IW_QUAL_QUAL_INVALID; 980 + wstats_flags |= local->hw.flags & IEEE80211_HW_NOISE_DBM ? 981 + IW_QUAL_NOISE_UPDATED : IW_QUAL_NOISE_INVALID; 982 + if (local->hw.flags & IEEE80211_HW_SIGNAL_DBM) 983 + wstats_flags |= IW_QUAL_DBM; 984 + 985 + return wstats_flags; 986 + } 987 + 889 988 /* Get wireless statistics. Called by /proc/net/wireless and by SIOCGIWSTATS */ 890 989 static struct iw_statistics *ieee80211_get_wireless_stats(struct net_device *dev) 891 990 { ··· 911 980 912 981 rcu_read_lock(); 913 982 914 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 915 - sdata->vif.type == NL80211_IFTYPE_ADHOC) 916 - sta = sta_info_get(local, sdata->u.sta.bssid); 983 + if (sdata->vif.type == NL80211_IFTYPE_STATION) 984 + sta = sta_info_get(local, sdata->u.mgd.bssid); 985 + 917 986 if (!sta) { 918 987 wstats->discard.fragment = 0; 919 988 wstats->discard.misc = 0; ··· 942 1011 943 1012 switch (data->flags & IW_AUTH_INDEX) { 944 1013 case IW_AUTH_80211_AUTH_ALG: 945 - if (sdata->vif.type == NL80211_IFTYPE_STATION || 946 - sdata->vif.type == NL80211_IFTYPE_ADHOC) 947 - data->value = sdata->u.sta.auth_algs; 1014 + if (sdata->vif.type == NL80211_IFTYPE_STATION) 1015 + data->value = sdata->u.mgd.auth_algs; 948 1016 else 949 1017 ret = -EOPNOTSUPP; 950 1018 break; ··· 1046 1116 (iw_handler) NULL, /* SIOCSIWSENS */ 1047 1117 (iw_handler) NULL, /* SIOCGIWSENS */ 1048 1118 (iw_handler) NULL /* not used */, /* SIOCSIWRANGE */ 1049 - (iw_handler) ieee80211_ioctl_giwrange, /* SIOCGIWRANGE */ 1119 + (iw_handler) cfg80211_wext_giwrange, /* SIOCGIWRANGE */ 1050 1120 (iw_handler) NULL /* not used */, /* SIOCSIWPRIV */ 1051 1121 (iw_handler) NULL /* kernel code */, /* SIOCGIWPRIV */ 1052 1122 (iw_handler) NULL /* not used */, /* SIOCSIWSTATS */
+4 -157
net/mac80211/wme.c
··· 114 114 { 115 115 struct ieee80211_master_priv *mpriv = netdev_priv(dev); 116 116 struct ieee80211_local *local = mpriv->local; 117 - struct ieee80211_hw *hw = &local->hw; 118 117 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 119 - struct sta_info *sta; 120 118 u16 queue; 121 119 u8 tid; 122 120 ··· 122 124 if (unlikely(queue >= local->hw.queues)) 123 125 queue = local->hw.queues - 1; 124 126 125 - if (skb->requeue) { 126 - if (!hw->ampdu_queues) 127 - return queue; 128 - 129 - rcu_read_lock(); 130 - sta = sta_info_get(local, hdr->addr1); 131 - tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; 132 - if (sta) { 133 - int ampdu_queue = sta->tid_to_tx_q[tid]; 134 - 135 - if ((ampdu_queue < ieee80211_num_queues(hw)) && 136 - test_bit(ampdu_queue, local->queue_pool)) 137 - queue = ampdu_queue; 138 - } 139 - rcu_read_unlock(); 140 - 141 - return queue; 142 - } 143 - 144 - /* Now we know the 1d priority, fill in the QoS header if 145 - * there is one. 127 + /* 128 + * Now we know the 1d priority, fill in the QoS header if 129 + * there is one (and we haven't done this before). 146 130 */ 147 - if (ieee80211_is_data_qos(hdr->frame_control)) { 131 + if (!skb->requeue && ieee80211_is_data_qos(hdr->frame_control)) { 148 132 u8 *p = ieee80211_get_qos_ctl(hdr); 149 133 u8 ack_policy = 0; 150 134 tid = skb->priority & IEEE80211_QOS_CTL_TAG1D_MASK; ··· 136 156 /* qos header is 2 bytes, second reserved */ 137 157 *p++ = ack_policy | tid; 138 158 *p = 0; 139 - 140 - if (!hw->ampdu_queues) 141 - return queue; 142 - 143 - rcu_read_lock(); 144 - 145 - sta = sta_info_get(local, hdr->addr1); 146 - if (sta) { 147 - int ampdu_queue = sta->tid_to_tx_q[tid]; 148 - 149 - if ((ampdu_queue < ieee80211_num_queues(hw)) && 150 - test_bit(ampdu_queue, local->queue_pool)) 151 - queue = ampdu_queue; 152 - } 153 - 154 - rcu_read_unlock(); 155 159 } 156 160 157 161 return queue; 158 - } 159 - 160 - int ieee80211_ht_agg_queue_add(struct ieee80211_local *local, 161 - struct sta_info *sta, u16 tid) 162 - { 163 - int i; 164 - 165 - /* XXX: currently broken due to cb/requeue use */ 166 - return -EPERM; 167 - 168 - /* prepare the filter and save it for the SW queue 169 - * matching the received HW queue */ 170 - 171 - if (!local->hw.ampdu_queues) 172 - return -EPERM; 173 - 174 - /* try to get a Qdisc from the pool */ 175 - for (i = local->hw.queues; i < ieee80211_num_queues(&local->hw); i++) 176 - if (!test_and_set_bit(i, local->queue_pool)) { 177 - ieee80211_stop_queue(local_to_hw(local), i); 178 - sta->tid_to_tx_q[tid] = i; 179 - 180 - /* IF there are already pending packets 181 - * on this tid first we need to drain them 182 - * on the previous queue 183 - * since HT is strict in order */ 184 - #ifdef CONFIG_MAC80211_HT_DEBUG 185 - if (net_ratelimit()) 186 - printk(KERN_DEBUG "allocated aggregation queue" 187 - " %d tid %d addr %pM pool=0x%lX\n", 188 - i, tid, sta->sta.addr, 189 - local->queue_pool[0]); 190 - #endif /* CONFIG_MAC80211_HT_DEBUG */ 191 - return 0; 192 - } 193 - 194 - return -EAGAIN; 195 - } 196 - 197 - /** 198 - * the caller needs to hold netdev_get_tx_queue(local->mdev, X)->lock 199 - */ 200 - void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local, 201 - struct sta_info *sta, u16 tid, 202 - u8 requeue) 203 - { 204 - int agg_queue = sta->tid_to_tx_q[tid]; 205 - struct ieee80211_hw *hw = &local->hw; 206 - 207 - /* return the qdisc to the pool */ 208 - clear_bit(agg_queue, local->queue_pool); 209 - sta->tid_to_tx_q[tid] = ieee80211_num_queues(hw); 210 - 211 - if (requeue) { 212 - ieee80211_requeue(local, agg_queue); 213 - } else { 214 - struct netdev_queue *txq; 215 - spinlock_t *root_lock; 216 - struct Qdisc *q; 217 - 218 - txq = netdev_get_tx_queue(local->mdev, agg_queue); 219 - q = rcu_dereference(txq->qdisc); 220 - root_lock = qdisc_lock(q); 221 - 222 - spin_lock_bh(root_lock); 223 - qdisc_reset(q); 224 - spin_unlock_bh(root_lock); 225 - } 226 - } 227 - 228 - void ieee80211_requeue(struct ieee80211_local *local, int queue) 229 - { 230 - struct netdev_queue *txq = netdev_get_tx_queue(local->mdev, queue); 231 - struct sk_buff_head list; 232 - spinlock_t *root_lock; 233 - struct Qdisc *qdisc; 234 - u32 len; 235 - 236 - rcu_read_lock_bh(); 237 - 238 - qdisc = rcu_dereference(txq->qdisc); 239 - if (!qdisc || !qdisc->dequeue) 240 - goto out_unlock; 241 - 242 - skb_queue_head_init(&list); 243 - 244 - root_lock = qdisc_root_lock(qdisc); 245 - spin_lock(root_lock); 246 - for (len = qdisc->q.qlen; len > 0; len--) { 247 - struct sk_buff *skb = qdisc->dequeue(qdisc); 248 - 249 - if (skb) 250 - __skb_queue_tail(&list, skb); 251 - } 252 - spin_unlock(root_lock); 253 - 254 - for (len = list.qlen; len > 0; len--) { 255 - struct sk_buff *skb = __skb_dequeue(&list); 256 - u16 new_queue; 257 - 258 - BUG_ON(!skb); 259 - new_queue = ieee80211_select_queue(local->mdev, skb); 260 - skb_set_queue_mapping(skb, new_queue); 261 - 262 - txq = netdev_get_tx_queue(local->mdev, new_queue); 263 - 264 - 265 - qdisc = rcu_dereference(txq->qdisc); 266 - root_lock = qdisc_root_lock(qdisc); 267 - 268 - spin_lock(root_lock); 269 - qdisc_enqueue_root(skb, qdisc); 270 - spin_unlock(root_lock); 271 - } 272 - 273 - out_unlock: 274 - rcu_read_unlock_bh(); 275 162 }
-6
net/mac80211/wme.h
··· 21 21 extern const int ieee802_1d_to_ac[8]; 22 22 23 23 u16 ieee80211_select_queue(struct net_device *dev, struct sk_buff *skb); 24 - int ieee80211_ht_agg_queue_add(struct ieee80211_local *local, 25 - struct sta_info *sta, u16 tid); 26 - void ieee80211_ht_agg_queue_remove(struct ieee80211_local *local, 27 - struct sta_info *sta, u16 tid, 28 - u8 requeue); 29 - void ieee80211_requeue(struct ieee80211_local *local, int queue); 30 24 31 25 #endif /* _WME_H */
+70 -33
net/wireless/core.c
··· 7 7 #include <linux/if.h> 8 8 #include <linux/module.h> 9 9 #include <linux/err.h> 10 - #include <linux/mutex.h> 11 10 #include <linux/list.h> 12 11 #include <linux/nl80211.h> 13 12 #include <linux/debugfs.h> ··· 30 31 * only read the list, and that can happen quite 31 32 * often because we need to do it for each command */ 32 33 LIST_HEAD(cfg80211_drv_list); 33 - DEFINE_MUTEX(cfg80211_drv_mutex); 34 + 35 + /* 36 + * This is used to protect the cfg80211_drv_list, cfg80211_regdomain, 37 + * country_ie_regdomain, the reg_beacon_list and the the last regulatory 38 + * request receipt (last_request). 39 + */ 40 + DEFINE_MUTEX(cfg80211_mutex); 34 41 35 42 /* for debugfs */ 36 43 static struct dentry *ieee80211_debugfs_dir; 37 44 38 - /* requires cfg80211_drv_mutex to be held! */ 39 - static struct cfg80211_registered_device *cfg80211_drv_by_wiphy(int wiphy) 45 + /* requires cfg80211_mutex to be held! */ 46 + struct cfg80211_registered_device *cfg80211_drv_by_wiphy_idx(int wiphy_idx) 40 47 { 41 48 struct cfg80211_registered_device *result = NULL, *drv; 42 49 50 + if (!wiphy_idx_valid(wiphy_idx)) 51 + return NULL; 52 + 53 + assert_cfg80211_lock(); 54 + 43 55 list_for_each_entry(drv, &cfg80211_drv_list, list) { 44 - if (drv->idx == wiphy) { 56 + if (drv->wiphy_idx == wiphy_idx) { 45 57 result = drv; 46 58 break; 47 59 } ··· 61 51 return result; 62 52 } 63 53 54 + int get_wiphy_idx(struct wiphy *wiphy) 55 + { 56 + struct cfg80211_registered_device *drv; 57 + if (!wiphy) 58 + return WIPHY_IDX_STALE; 59 + drv = wiphy_to_dev(wiphy); 60 + return drv->wiphy_idx; 61 + } 62 + 64 63 /* requires cfg80211_drv_mutex to be held! */ 64 + struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx) 65 + { 66 + struct cfg80211_registered_device *drv; 67 + 68 + if (!wiphy_idx_valid(wiphy_idx)) 69 + return NULL; 70 + 71 + assert_cfg80211_lock(); 72 + 73 + drv = cfg80211_drv_by_wiphy_idx(wiphy_idx); 74 + if (!drv) 75 + return NULL; 76 + return &drv->wiphy; 77 + } 78 + 79 + /* requires cfg80211_mutex to be held! */ 65 80 static struct cfg80211_registered_device * 66 81 __cfg80211_drv_from_info(struct genl_info *info) 67 82 { 68 83 int ifindex; 69 - struct cfg80211_registered_device *bywiphy = NULL, *byifidx = NULL; 84 + struct cfg80211_registered_device *bywiphyidx = NULL, *byifidx = NULL; 70 85 struct net_device *dev; 71 86 int err = -EINVAL; 72 87 88 + assert_cfg80211_lock(); 89 + 73 90 if (info->attrs[NL80211_ATTR_WIPHY]) { 74 - bywiphy = cfg80211_drv_by_wiphy( 91 + bywiphyidx = cfg80211_drv_by_wiphy_idx( 75 92 nla_get_u32(info->attrs[NL80211_ATTR_WIPHY])); 76 93 err = -ENODEV; 77 94 } ··· 115 78 err = -ENODEV; 116 79 } 117 80 118 - if (bywiphy && byifidx) { 119 - if (bywiphy != byifidx) 81 + if (bywiphyidx && byifidx) { 82 + if (bywiphyidx != byifidx) 120 83 return ERR_PTR(-EINVAL); 121 84 else 122 - return bywiphy; /* == byifidx */ 85 + return bywiphyidx; /* == byifidx */ 123 86 } 124 - if (bywiphy) 125 - return bywiphy; 87 + if (bywiphyidx) 88 + return bywiphyidx; 126 89 127 90 if (byifidx) 128 91 return byifidx; ··· 135 98 { 136 99 struct cfg80211_registered_device *drv; 137 100 138 - mutex_lock(&cfg80211_drv_mutex); 101 + mutex_lock(&cfg80211_mutex); 139 102 drv = __cfg80211_drv_from_info(info); 140 103 141 104 /* if it is not an error we grab the lock on ··· 144 107 if (!IS_ERR(drv)) 145 108 mutex_lock(&drv->mtx); 146 109 147 - mutex_unlock(&cfg80211_drv_mutex); 110 + mutex_unlock(&cfg80211_mutex); 148 111 149 112 return drv; 150 113 } ··· 155 118 struct cfg80211_registered_device *drv = ERR_PTR(-ENODEV); 156 119 struct net_device *dev; 157 120 158 - mutex_lock(&cfg80211_drv_mutex); 121 + mutex_lock(&cfg80211_mutex); 159 122 dev = dev_get_by_index(&init_net, ifindex); 160 123 if (!dev) 161 124 goto out; ··· 166 129 drv = ERR_PTR(-ENODEV); 167 130 dev_put(dev); 168 131 out: 169 - mutex_unlock(&cfg80211_drv_mutex); 132 + mutex_unlock(&cfg80211_mutex); 170 133 return drv; 171 134 } 172 135 ··· 180 143 char *newname) 181 144 { 182 145 struct cfg80211_registered_device *drv; 183 - int idx, taken = -1, result, digits; 146 + int wiphy_idx, taken = -1, result, digits; 184 147 185 - mutex_lock(&cfg80211_drv_mutex); 148 + mutex_lock(&cfg80211_mutex); 186 149 187 150 /* prohibit calling the thing phy%d when %d is not its number */ 188 - sscanf(newname, PHY_NAME "%d%n", &idx, &taken); 189 - if (taken == strlen(newname) && idx != rdev->idx) { 190 - /* count number of places needed to print idx */ 151 + sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken); 152 + if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) { 153 + /* count number of places needed to print wiphy_idx */ 191 154 digits = 1; 192 - while (idx /= 10) 155 + while (wiphy_idx /= 10) 193 156 digits++; 194 157 /* 195 158 * deny the name if it is phy<idx> where <idx> is printed ··· 230 193 231 194 result = 0; 232 195 out_unlock: 233 - mutex_unlock(&cfg80211_drv_mutex); 196 + mutex_unlock(&cfg80211_mutex); 234 197 if (result == 0) 235 198 nl80211_notify_dev_rename(rdev); 236 199 ··· 257 220 258 221 drv->ops = ops; 259 222 260 - mutex_lock(&cfg80211_drv_mutex); 223 + mutex_lock(&cfg80211_mutex); 261 224 262 - drv->idx = wiphy_counter++; 225 + drv->wiphy_idx = wiphy_counter++; 263 226 264 - if (unlikely(drv->idx < 0)) { 227 + if (unlikely(!wiphy_idx_valid(drv->wiphy_idx))) { 265 228 wiphy_counter--; 266 - mutex_unlock(&cfg80211_drv_mutex); 229 + mutex_unlock(&cfg80211_mutex); 267 230 /* ugh, wrapped! */ 268 231 kfree(drv); 269 232 return NULL; 270 233 } 271 234 272 - mutex_unlock(&cfg80211_drv_mutex); 235 + mutex_unlock(&cfg80211_mutex); 273 236 274 237 /* give it a proper name */ 275 - dev_set_name(&drv->wiphy.dev, PHY_NAME "%d", drv->idx); 238 + dev_set_name(&drv->wiphy.dev, PHY_NAME "%d", drv->wiphy_idx); 276 239 277 240 mutex_init(&drv->mtx); 278 241 mutex_init(&drv->devlist_mtx); ··· 347 310 /* check and set up bitrates */ 348 311 ieee80211_set_bitrate_flags(wiphy); 349 312 350 - mutex_lock(&cfg80211_drv_mutex); 313 + mutex_lock(&cfg80211_mutex); 351 314 352 315 /* set up regulatory info */ 353 316 wiphy_update_regulatory(wiphy, REGDOM_SET_BY_CORE); ··· 367 330 368 331 res = 0; 369 332 out_unlock: 370 - mutex_unlock(&cfg80211_drv_mutex); 333 + mutex_unlock(&cfg80211_mutex); 371 334 return res; 372 335 } 373 336 EXPORT_SYMBOL(wiphy_register); ··· 377 340 struct cfg80211_registered_device *drv = wiphy_to_dev(wiphy); 378 341 379 342 /* protect the device list */ 380 - mutex_lock(&cfg80211_drv_mutex); 343 + mutex_lock(&cfg80211_mutex); 381 344 382 345 BUG_ON(!list_empty(&drv->netdev_list)); 383 346 ··· 403 366 device_del(&drv->wiphy.dev); 404 367 debugfs_remove(drv->wiphy.debugfsdir); 405 368 406 - mutex_unlock(&cfg80211_drv_mutex); 369 + mutex_unlock(&cfg80211_mutex); 407 370 } 408 371 EXPORT_SYMBOL(wiphy_unregister); 409 372
+32 -4
net/wireless/core.h
··· 10 10 #include <linux/netdevice.h> 11 11 #include <linux/kref.h> 12 12 #include <linux/rbtree.h> 13 + #include <linux/mutex.h> 13 14 #include <net/genetlink.h> 14 15 #include <net/wireless.h> 15 16 #include <net/cfg80211.h> ··· 38 37 enum environment_cap env; 39 38 40 39 /* wiphy index, internal only */ 41 - int idx; 40 + int wiphy_idx; 42 41 43 42 /* associate netdev list */ 44 43 struct mutex devlist_mtx; ··· 50 49 struct rb_root bss_tree; 51 50 u32 bss_generation; 52 51 struct cfg80211_scan_request *scan_req; /* protected by RTNL */ 52 + unsigned long suspend_at; 53 53 54 54 /* must be last because of the way we do wiphy_priv(), 55 55 * and it should at least be aligned to NETDEV_ALIGN */ ··· 64 62 return container_of(wiphy, struct cfg80211_registered_device, wiphy); 65 63 } 66 64 67 - extern struct mutex cfg80211_drv_mutex; 65 + /* Note 0 is valid, hence phy0 */ 66 + static inline 67 + bool wiphy_idx_valid(int wiphy_idx) 68 + { 69 + return (wiphy_idx >= 0); 70 + } 71 + 72 + extern struct mutex cfg80211_mutex; 68 73 extern struct list_head cfg80211_drv_list; 74 + 75 + static inline void assert_cfg80211_lock(void) 76 + { 77 + WARN_ON(!mutex_is_locked(&cfg80211_mutex)); 78 + } 79 + 80 + /* 81 + * You can use this to mark a wiphy_idx as not having an associated wiphy. 82 + * It guarantees cfg80211_drv_by_wiphy_idx(wiphy_idx) will return NULL 83 + */ 84 + #define WIPHY_IDX_STALE -1 69 85 70 86 struct cfg80211_internal_bss { 71 87 struct list_head list; ··· 94 74 struct cfg80211_bss pub; 95 75 }; 96 76 77 + struct cfg80211_registered_device *cfg80211_drv_by_wiphy_idx(int wiphy_idx); 78 + int get_wiphy_idx(struct wiphy *wiphy); 79 + 97 80 /* 98 81 * This function returns a pointer to the driver 99 82 * that the genl_info item that is passed refers to. ··· 104 81 * the driver's mutex! 105 82 * 106 83 * This means that you need to call cfg80211_put_dev() 107 - * before being allowed to acquire &cfg80211_drv_mutex! 84 + * before being allowed to acquire &cfg80211_mutex! 108 85 * 109 86 * This is necessary because we need to lock the global 110 87 * mutex to get an item off the list safely, and then 111 88 * we lock the drv mutex so it doesn't go away under us. 112 89 * 113 - * We don't want to keep cfg80211_drv_mutex locked 90 + * We don't want to keep cfg80211_mutex locked 114 91 * for all the time in order to allow requests on 115 92 * other interfaces to go through at the same time. 116 93 * ··· 119 96 */ 120 97 extern struct cfg80211_registered_device * 121 98 cfg80211_get_dev_from_info(struct genl_info *info); 99 + 100 + /* requires cfg80211_drv_mutex to be held! */ 101 + struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx); 122 102 123 103 /* identical to cfg80211_get_dev_from_info but only operate on ifindex */ 124 104 extern struct cfg80211_registered_device * ··· 139 113 void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby); 140 114 141 115 void cfg80211_bss_expire(struct cfg80211_registered_device *dev); 116 + void cfg80211_bss_age(struct cfg80211_registered_device *dev, 117 + unsigned long age_secs); 142 118 143 119 #endif /* __NET_WIRELESS_CORE_H */
+53 -22
net/wireless/nl80211.c
··· 7 7 #include <linux/if.h> 8 8 #include <linux/module.h> 9 9 #include <linux/err.h> 10 - #include <linux/mutex.h> 11 10 #include <linux/list.h> 12 11 #include <linux/if_ether.h> 13 12 #include <linux/ieee80211.h> ··· 141 142 if (!hdr) 142 143 return -1; 143 144 144 - NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->idx); 145 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, dev->wiphy_idx); 145 146 NLA_PUT_STRING(msg, NL80211_ATTR_WIPHY_NAME, wiphy_name(&dev->wiphy)); 146 147 NLA_PUT_U8(msg, NL80211_ATTR_MAX_NUM_SCAN_SSIDS, 147 148 dev->wiphy.max_scan_ssids); ··· 255 256 int start = cb->args[0]; 256 257 struct cfg80211_registered_device *dev; 257 258 258 - mutex_lock(&cfg80211_drv_mutex); 259 + mutex_lock(&cfg80211_mutex); 259 260 list_for_each_entry(dev, &cfg80211_drv_list, list) { 260 261 if (++idx <= start) 261 262 continue; ··· 266 267 break; 267 268 } 268 269 } 269 - mutex_unlock(&cfg80211_drv_mutex); 270 + mutex_unlock(&cfg80211_mutex); 270 271 271 272 cb->args[0] = idx; 272 273 ··· 469 470 struct cfg80211_registered_device *dev; 470 471 struct wireless_dev *wdev; 471 472 472 - mutex_lock(&cfg80211_drv_mutex); 473 + mutex_lock(&cfg80211_mutex); 473 474 list_for_each_entry(dev, &cfg80211_drv_list, list) { 474 475 if (wp_idx < wp_start) { 475 476 wp_idx++; ··· 496 497 wp_idx++; 497 498 } 498 499 out: 499 - mutex_unlock(&cfg80211_drv_mutex); 500 + mutex_unlock(&cfg80211_mutex); 500 501 501 502 cb->args[0] = wp_idx; 502 503 cb->args[1] = if_idx; ··· 1205 1206 1206 1207 nla_nest_end(msg, txrate); 1207 1208 } 1209 + if (sinfo->filled & STATION_INFO_RX_PACKETS) 1210 + NLA_PUT_U32(msg, NL80211_STA_INFO_RX_PACKETS, 1211 + sinfo->rx_packets); 1212 + if (sinfo->filled & STATION_INFO_TX_PACKETS) 1213 + NLA_PUT_U32(msg, NL80211_STA_INFO_TX_PACKETS, 1214 + sinfo->tx_packets); 1208 1215 nla_nest_end(msg, sinfoattr); 1209 1216 1210 1217 return genlmsg_end(msg, hdr); ··· 1905 1900 int r; 1906 1901 char *data = NULL; 1907 1902 1903 + /* 1904 + * You should only get this when cfg80211 hasn't yet initialized 1905 + * completely when built-in to the kernel right between the time 1906 + * window between nl80211_init() and regulatory_init(), if that is 1907 + * even possible. 1908 + */ 1909 + mutex_lock(&cfg80211_mutex); 1910 + if (unlikely(!cfg80211_regdomain)) { 1911 + mutex_unlock(&cfg80211_mutex); 1912 + return -EINPROGRESS; 1913 + } 1914 + mutex_unlock(&cfg80211_mutex); 1915 + 1908 1916 if (!info->attrs[NL80211_ATTR_REG_ALPHA2]) 1909 1917 return -EINVAL; 1910 1918 ··· 1928 1910 if (is_world_regdom(data)) 1929 1911 return -EINVAL; 1930 1912 #endif 1931 - mutex_lock(&cfg80211_drv_mutex); 1932 - r = __regulatory_hint(NULL, REGDOM_SET_BY_USER, data, 0, ENVIRON_ANY); 1933 - mutex_unlock(&cfg80211_drv_mutex); 1934 - /* This means the regulatory domain was already set, however 1935 - * we don't want to confuse userspace with a "successful error" 1936 - * message so lets just treat it as a success */ 1937 - if (r == -EALREADY) 1938 - r = 0; 1913 + 1914 + r = regulatory_hint_user(data); 1915 + 1939 1916 return r; 1940 1917 } 1941 1918 ··· 2119 2106 unsigned int i; 2120 2107 int err = -EINVAL; 2121 2108 2122 - mutex_lock(&cfg80211_drv_mutex); 2109 + mutex_lock(&cfg80211_mutex); 2123 2110 2124 2111 if (!cfg80211_regdomain) 2125 2112 goto out; ··· 2182 2169 genlmsg_cancel(msg, hdr); 2183 2170 err = -EMSGSIZE; 2184 2171 out: 2185 - mutex_unlock(&cfg80211_drv_mutex); 2172 + mutex_unlock(&cfg80211_mutex); 2186 2173 return err; 2187 2174 } 2188 2175 ··· 2241 2228 2242 2229 BUG_ON(rule_idx != num_rules); 2243 2230 2244 - mutex_lock(&cfg80211_drv_mutex); 2231 + mutex_lock(&cfg80211_mutex); 2245 2232 r = set_regdom(rd); 2246 - mutex_unlock(&cfg80211_drv_mutex); 2233 + mutex_unlock(&cfg80211_mutex); 2247 2234 return r; 2248 2235 2249 2236 bad_reg: ··· 2299 2286 struct wiphy *wiphy; 2300 2287 int err, tmp, n_ssids = 0, n_channels = 0, i; 2301 2288 enum ieee80211_band band; 2289 + size_t ie_len; 2302 2290 2303 2291 err = get_drv_dev_by_info_ifindex(info->attrs, &drv, &dev); 2304 2292 if (err) ··· 2341 2327 goto out_unlock; 2342 2328 } 2343 2329 2330 + if (info->attrs[NL80211_ATTR_IE]) 2331 + ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); 2332 + else 2333 + ie_len = 0; 2334 + 2344 2335 request = kzalloc(sizeof(*request) 2345 2336 + sizeof(*ssid) * n_ssids 2346 - + sizeof(channel) * n_channels, GFP_KERNEL); 2337 + + sizeof(channel) * n_channels 2338 + + ie_len, GFP_KERNEL); 2347 2339 if (!request) { 2348 2340 err = -ENOMEM; 2349 2341 goto out_unlock; ··· 2360 2340 if (n_ssids) 2361 2341 request->ssids = (void *)(request->channels + n_channels); 2362 2342 request->n_ssids = n_ssids; 2343 + if (ie_len) { 2344 + if (request->ssids) 2345 + request->ie = (void *)(request->ssids + n_ssids); 2346 + else 2347 + request->ie = (void *)(request->channels + n_channels); 2348 + } 2363 2349 2364 2350 if (info->attrs[NL80211_ATTR_SCAN_FREQUENCIES]) { 2365 2351 /* user specified, bail out if channel not found */ ··· 2404 2378 request->ssids[i].ssid_len = nla_len(attr); 2405 2379 i++; 2406 2380 } 2381 + } 2382 + 2383 + if (info->attrs[NL80211_ATTR_IE]) { 2384 + request->ie_len = nla_len(info->attrs[NL80211_ATTR_IE]); 2385 + memcpy(request->ie, nla_data(info->attrs[NL80211_ATTR_IE]), 2386 + request->ie_len); 2407 2387 } 2408 2388 2409 2389 request->ifidx = dev->ifindex; ··· 2464 2432 NLA_PUT_U16(msg, NL80211_BSS_CAPABILITY, res->capability); 2465 2433 NLA_PUT_U32(msg, NL80211_BSS_FREQUENCY, res->channel->center_freq); 2466 2434 2467 - switch (res->signal_type) { 2435 + switch (rdev->wiphy.signal_type) { 2468 2436 case CFG80211_SIGNAL_TYPE_MBM: 2469 2437 NLA_PUT_U32(msg, NL80211_BSS_SIGNAL_MBM, res->signal); 2470 2438 break; ··· 2633 2601 .doit = nl80211_get_station, 2634 2602 .dumpit = nl80211_dump_station, 2635 2603 .policy = nl80211_policy, 2636 - .flags = GENL_ADMIN_PERM, 2637 2604 }, 2638 2605 { 2639 2606 .cmd = NL80211_CMD_SET_STATION, ··· 2770 2739 if (!hdr) 2771 2740 return -1; 2772 2741 2773 - NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->idx); 2742 + NLA_PUT_U32(msg, NL80211_ATTR_WIPHY, rdev->wiphy_idx); 2774 2743 NLA_PUT_U32(msg, NL80211_ATTR_IFINDEX, netdev->ifindex); 2775 2744 2776 2745 /* XXX: we should probably bounce back the request? */
+4
net/wireless/nl80211.h
··· 27 27 nl80211_send_scan_done(struct cfg80211_registered_device *rdev, 28 28 struct net_device *netdev) 29 29 {} 30 + static inline void nl80211_send_scan_aborted( 31 + struct cfg80211_registered_device *rdev, 32 + struct net_device *netdev) 33 + {} 30 34 #endif /* CONFIG_NL80211 */ 31 35 32 36 #endif /* __NET_WIRELESS_NL80211_H */
+743 -204
net/wireless/reg.c
··· 54 54 MHZ_TO_KHZ(20), 55 55 }; 56 56 57 - /* Central wireless core regulatory domains, we only need two, 57 + /* 58 + * Central wireless core regulatory domains, we only need two, 58 59 * the current one and a world regulatory domain in case we have no 59 - * information to give us an alpha2 */ 60 + * information to give us an alpha2 61 + */ 60 62 const struct ieee80211_regdomain *cfg80211_regdomain; 61 63 62 - /* We use this as a place for the rd structure built from the 64 + /* 65 + * We use this as a place for the rd structure built from the 63 66 * last parsed country IE to rest until CRDA gets back to us with 64 - * what it thinks should apply for the same country */ 67 + * what it thinks should apply for the same country 68 + */ 65 69 static const struct ieee80211_regdomain *country_ie_regdomain; 70 + 71 + /* Used to queue up regulatory hints */ 72 + static LIST_HEAD(reg_requests_list); 73 + static spinlock_t reg_requests_lock; 74 + 75 + /* Used to queue up beacon hints for review */ 76 + static LIST_HEAD(reg_pending_beacons); 77 + static spinlock_t reg_pending_beacons_lock; 78 + 79 + /* Used to keep track of processed beacon hints */ 80 + static LIST_HEAD(reg_beacon_list); 81 + 82 + struct reg_beacon { 83 + struct list_head list; 84 + struct ieee80211_channel chan; 85 + }; 66 86 67 87 /* We keep a static world regulatory domain in case of the absence of CRDA */ 68 88 static const struct ieee80211_regdomain world_regdom = { 69 - .n_reg_rules = 1, 89 + .n_reg_rules = 3, 70 90 .alpha2 = "00", 71 91 .reg_rules = { 72 - REG_RULE(2412-10, 2462+10, 40, 6, 20, 92 + /* IEEE 802.11b/g, channels 1..11 */ 93 + REG_RULE(2412-10, 2462+10, 40, 6, 20, 0), 94 + /* IEEE 802.11a, channel 36..48 */ 95 + REG_RULE(5180-10, 5240+10, 40, 6, 23, 96 + NL80211_RRF_PASSIVE_SCAN | 97 + NL80211_RRF_NO_IBSS), 98 + 99 + /* NB: 5260 MHz - 5700 MHz requies DFS */ 100 + 101 + /* IEEE 802.11a, channel 149..165 */ 102 + REG_RULE(5745-10, 5825+10, 40, 6, 23, 73 103 NL80211_RRF_PASSIVE_SCAN | 74 104 NL80211_RRF_NO_IBSS), 75 105 } ··· 113 83 module_param(ieee80211_regdom, charp, 0444); 114 84 MODULE_PARM_DESC(ieee80211_regdom, "IEEE 802.11 regulatory domain code"); 115 85 116 - /* We assume 40 MHz bandwidth for the old regulatory work. 86 + /* 87 + * We assume 40 MHz bandwidth for the old regulatory work. 117 88 * We make emphasis we are using the exact same frequencies 118 - * as before */ 89 + * as before 90 + */ 119 91 120 92 static const struct ieee80211_regdomain us_regdom = { 121 93 .n_reg_rules = 6, ··· 156 124 157 125 static const struct ieee80211_regdomain eu_regdom = { 158 126 .n_reg_rules = 6, 159 - /* This alpha2 is bogus, we leave it here just for stupid 160 - * backward compatibility */ 127 + /* 128 + * This alpha2 is bogus, we leave it here just for stupid 129 + * backward compatibility 130 + */ 161 131 .alpha2 = "EU", 162 132 .reg_rules = { 163 133 /* IEEE 802.11b/g, channels 1..13 */ ··· 228 194 cfg80211_regdomain = NULL; 229 195 } 230 196 231 - /* Dynamic world regulatory domain requested by the wireless 232 - * core upon initialization */ 197 + /* 198 + * Dynamic world regulatory domain requested by the wireless 199 + * core upon initialization 200 + */ 233 201 static void update_world_regdomain(const struct ieee80211_regdomain *rd) 234 202 { 235 203 BUG_ON(!last_request); ··· 272 236 { 273 237 if (!alpha2) 274 238 return false; 275 - /* Special case where regulatory domain was built by driver 276 - * but a specific alpha2 cannot be determined */ 239 + /* 240 + * Special case where regulatory domain was built by driver 241 + * but a specific alpha2 cannot be determined 242 + */ 277 243 if (alpha2[0] == '9' && alpha2[1] == '9') 278 244 return true; 279 245 return false; ··· 285 247 { 286 248 if (!alpha2) 287 249 return false; 288 - /* Special case where regulatory domain is the 250 + /* 251 + * Special case where regulatory domain is the 289 252 * result of an intersection between two regulatory domain 290 - * structures */ 253 + * structures 254 + */ 291 255 if (alpha2[0] == '9' && alpha2[1] == '8') 292 256 return true; 293 257 return false; ··· 314 274 return false; 315 275 } 316 276 317 - static bool regdom_changed(const char *alpha2) 277 + static bool regdom_changes(const char *alpha2) 318 278 { 279 + assert_cfg80211_lock(); 280 + 319 281 if (!cfg80211_regdomain) 320 282 return true; 321 283 if (alpha2_equal(cfg80211_regdomain->alpha2, alpha2)) ··· 344 302 return false; 345 303 } 346 304 347 - /* This lets us keep regulatory code which is updated on a regulatory 348 - * basis in userspace. */ 305 + /* 306 + * This lets us keep regulatory code which is updated on a regulatory 307 + * basis in userspace. 308 + */ 349 309 static int call_crda(const char *alpha2) 350 310 { 351 311 char country_env[9 + 2] = "COUNTRY="; ··· 458 414 #undef ONE_GHZ_IN_KHZ 459 415 } 460 416 461 - /* Converts a country IE to a regulatory domain. A regulatory domain 417 + /* 418 + * Converts a country IE to a regulatory domain. A regulatory domain 462 419 * structure has a lot of information which the IE doesn't yet have, 463 420 * so for the other values we use upper max values as we will intersect 464 - * with our userspace regulatory agent to get lower bounds. */ 421 + * with our userspace regulatory agent to get lower bounds. 422 + */ 465 423 static struct ieee80211_regdomain *country_ie_2_rd( 466 424 u8 *country_ie, 467 425 u8 country_ie_len, ··· 508 462 509 463 *checksum ^= ((flags ^ alpha2[0] ^ alpha2[1]) << 8); 510 464 511 - /* We need to build a reg rule for each triplet, but first we must 465 + /* 466 + * We need to build a reg rule for each triplet, but first we must 512 467 * calculate the number of reg rules we will need. We will need one 513 - * for each channel subband */ 468 + * for each channel subband 469 + */ 514 470 while (country_ie_len >= 3) { 515 471 int end_channel = 0; 516 472 struct ieee80211_country_ie_triplet *triplet = ··· 550 502 if (cur_sub_max_channel < cur_channel) 551 503 return NULL; 552 504 553 - /* Do not allow overlapping channels. Also channels 505 + /* 506 + * Do not allow overlapping channels. Also channels 554 507 * passed in each subband must be monotonically 555 - * increasing */ 508 + * increasing 509 + */ 556 510 if (last_sub_max_channel) { 557 511 if (cur_channel <= last_sub_max_channel) 558 512 return NULL; ··· 562 512 return NULL; 563 513 } 564 514 565 - /* When dot11RegulatoryClassesRequired is supported 515 + /* 516 + * When dot11RegulatoryClassesRequired is supported 566 517 * we can throw ext triplets as part of this soup, 567 518 * for now we don't care when those change as we 568 - * don't support them */ 519 + * don't support them 520 + */ 569 521 *checksum ^= ((cur_channel ^ cur_sub_max_channel) << 8) | 570 522 ((cur_sub_max_channel ^ cur_sub_max_channel) << 16) | 571 523 ((triplet->chans.max_power ^ cur_sub_max_channel) << 24); ··· 578 526 country_ie_len -= 3; 579 527 num_rules++; 580 528 581 - /* Note: this is not a IEEE requirement but 582 - * simply a memory requirement */ 529 + /* 530 + * Note: this is not a IEEE requirement but 531 + * simply a memory requirement 532 + */ 583 533 if (num_rules > NL80211_MAX_SUPP_REG_RULES) 584 534 return NULL; 585 535 } ··· 609 555 struct ieee80211_freq_range *freq_range = NULL; 610 556 struct ieee80211_power_rule *power_rule = NULL; 611 557 612 - /* Must parse if dot11RegulatoryClassesRequired is true, 613 - * we don't support this yet */ 558 + /* 559 + * Must parse if dot11RegulatoryClassesRequired is true, 560 + * we don't support this yet 561 + */ 614 562 if (triplet->ext.reg_extension_id >= 615 563 IEEE80211_COUNTRY_EXTENSION_ID) { 616 564 country_ie += 3; ··· 634 578 end_channel = triplet->chans.first_channel + 635 579 (4 * (triplet->chans.num_channels - 1)); 636 580 637 - /* The +10 is since the regulatory domain expects 581 + /* 582 + * The +10 is since the regulatory domain expects 638 583 * the actual band edge, not the center of freq for 639 584 * its start and end freqs, assuming 20 MHz bandwidth on 640 - * the channels passed */ 585 + * the channels passed 586 + */ 641 587 freq_range->start_freq_khz = 642 588 MHZ_TO_KHZ(ieee80211_channel_to_frequency( 643 589 triplet->chans.first_channel) - 10); ··· 647 589 MHZ_TO_KHZ(ieee80211_channel_to_frequency( 648 590 end_channel) + 10); 649 591 650 - /* Large arbitrary values, we intersect later */ 651 - /* Increment this if we ever support >= 40 MHz channels 652 - * in IEEE 802.11 */ 592 + /* 593 + * These are large arbitrary values we use to intersect later. 594 + * Increment this if we ever support >= 40 MHz channels 595 + * in IEEE 802.11 596 + */ 653 597 freq_range->max_bandwidth_khz = MHZ_TO_KHZ(40); 654 598 power_rule->max_antenna_gain = DBI_TO_MBI(100); 655 599 power_rule->max_eirp = DBM_TO_MBM(100); ··· 667 607 } 668 608 669 609 670 - /* Helper for regdom_intersect(), this does the real 671 - * mathematical intersection fun */ 610 + /* 611 + * Helper for regdom_intersect(), this does the real 612 + * mathematical intersection fun 613 + */ 672 614 static int reg_rules_intersect( 673 615 const struct ieee80211_reg_rule *rule1, 674 616 const struct ieee80211_reg_rule *rule2, ··· 748 686 if (!rd1 || !rd2) 749 687 return NULL; 750 688 751 - /* First we get a count of the rules we'll need, then we actually 689 + /* 690 + * First we get a count of the rules we'll need, then we actually 752 691 * build them. This is to so we can malloc() and free() a 753 692 * regdomain once. The reason we use reg_rules_intersect() here 754 693 * is it will return -EINVAL if the rule computed makes no sense. 755 - * All rules that do check out OK are valid. */ 694 + * All rules that do check out OK are valid. 695 + */ 756 696 757 697 for (x = 0; x < rd1->n_reg_rules; x++) { 758 698 rule1 = &rd1->reg_rules[x]; ··· 782 718 rule1 = &rd1->reg_rules[x]; 783 719 for (y = 0; y < rd2->n_reg_rules; y++) { 784 720 rule2 = &rd2->reg_rules[y]; 785 - /* This time around instead of using the stack lets 721 + /* 722 + * This time around instead of using the stack lets 786 723 * write to the target rule directly saving ourselves 787 - * a memcpy() */ 724 + * a memcpy() 725 + */ 788 726 intersected_rule = &rd->reg_rules[rule_idx]; 789 727 r = reg_rules_intersect(rule1, rule2, 790 728 intersected_rule); 791 - /* No need to memset here the intersected rule here as 792 - * we're not using the stack anymore */ 729 + /* 730 + * No need to memset here the intersected rule here as 731 + * we're not using the stack anymore 732 + */ 793 733 if (r) 794 734 continue; 795 735 rule_idx++; ··· 812 744 return rd; 813 745 } 814 746 815 - /* XXX: add support for the rest of enum nl80211_reg_rule_flags, we may 816 - * want to just have the channel structure use these */ 747 + /* 748 + * XXX: add support for the rest of enum nl80211_reg_rule_flags, we may 749 + * want to just have the channel structure use these 750 + */ 817 751 static u32 map_regdom_flags(u32 rd_flags) 818 752 { 819 753 u32 channel_flags = 0; ··· 841 771 842 772 regd = custom_regd ? custom_regd : cfg80211_regdomain; 843 773 844 - /* Follow the driver's regulatory domain, if present, unless a country 845 - * IE has been processed or a user wants to help complaince further */ 774 + /* 775 + * Follow the driver's regulatory domain, if present, unless a country 776 + * IE has been processed or a user wants to help complaince further 777 + */ 846 778 if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE && 847 779 last_request->initiator != REGDOM_SET_BY_USER && 848 780 wiphy->regd) ··· 862 790 fr = &rr->freq_range; 863 791 pr = &rr->power_rule; 864 792 865 - /* We only need to know if one frequency rule was 793 + /* 794 + * We only need to know if one frequency rule was 866 795 * was in center_freq's band, that's enough, so lets 867 - * not overwrite it once found */ 796 + * not overwrite it once found 797 + */ 868 798 if (!band_rule_found) 869 799 band_rule_found = freq_in_rule_band(fr, center_freq); 870 800 ··· 903 829 const struct ieee80211_power_rule *power_rule = NULL; 904 830 struct ieee80211_supported_band *sband; 905 831 struct ieee80211_channel *chan; 832 + struct wiphy *request_wiphy = NULL; 833 + 834 + assert_cfg80211_lock(); 835 + 836 + request_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); 906 837 907 838 sband = wiphy->bands[band]; 908 839 BUG_ON(chan_idx >= sband->n_channels); ··· 919 840 &max_bandwidth, &reg_rule); 920 841 921 842 if (r) { 922 - /* This means no regulatory rule was found in the country IE 843 + /* 844 + * This means no regulatory rule was found in the country IE 923 845 * with a frequency range on the center_freq's band, since 924 846 * IEEE-802.11 allows for a country IE to have a subset of the 925 847 * regulatory information provided in a country we ignore ··· 939 859 chan->center_freq, wiphy_name(wiphy)); 940 860 #endif 941 861 } else { 942 - /* In this case we know the country IE has at least one reg rule 943 - * for the band so we respect its band definitions */ 862 + /* 863 + * In this case we know the country IE has at least one reg rule 864 + * for the band so we respect its band definitions 865 + */ 944 866 #ifdef CONFIG_CFG80211_REG_DEBUG 945 867 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) 946 868 printk(KERN_DEBUG "cfg80211: Disabling " ··· 959 877 power_rule = &reg_rule->power_rule; 960 878 961 879 if (last_request->initiator == REGDOM_SET_BY_DRIVER && 962 - last_request->wiphy && last_request->wiphy == wiphy && 963 - last_request->wiphy->strict_regulatory) { 964 - /* This gaurantees the driver's requested regulatory domain 880 + request_wiphy && request_wiphy == wiphy && 881 + request_wiphy->strict_regulatory) { 882 + /* 883 + * This gaurantees the driver's requested regulatory domain 965 884 * will always be used as a base for further regulatory 966 - * settings */ 885 + * settings 886 + */ 967 887 chan->flags = chan->orig_flags = 968 888 map_regdom_flags(reg_rule->flags); 969 889 chan->max_antenna_gain = chan->orig_mag = ··· 1006 922 if (setby == REGDOM_SET_BY_CORE && 1007 923 wiphy->custom_regulatory) 1008 924 return true; 1009 - /* wiphy->regd will be set once the device has its own 1010 - * desired regulatory domain set */ 925 + /* 926 + * wiphy->regd will be set once the device has its own 927 + * desired regulatory domain set 928 + */ 1011 929 if (wiphy->strict_regulatory && !wiphy->regd && 1012 930 !is_world_regdom(last_request->alpha2)) 1013 931 return true; ··· 1024 938 wiphy_update_regulatory(&drv->wiphy, setby); 1025 939 } 1026 940 941 + static void handle_reg_beacon(struct wiphy *wiphy, 942 + unsigned int chan_idx, 943 + struct reg_beacon *reg_beacon) 944 + { 945 + #ifdef CONFIG_CFG80211_REG_DEBUG 946 + #define REG_DEBUG_BEACON_FLAG(desc) \ 947 + printk(KERN_DEBUG "cfg80211: Enabling " desc " on " \ 948 + "frequency: %d MHz (Ch %d) on %s\n", \ 949 + reg_beacon->chan.center_freq, \ 950 + ieee80211_frequency_to_channel(reg_beacon->chan.center_freq), \ 951 + wiphy_name(wiphy)); 952 + #else 953 + #define REG_DEBUG_BEACON_FLAG(desc) do {} while (0) 954 + #endif 955 + struct ieee80211_supported_band *sband; 956 + struct ieee80211_channel *chan; 957 + 958 + assert_cfg80211_lock(); 959 + 960 + sband = wiphy->bands[reg_beacon->chan.band]; 961 + chan = &sband->channels[chan_idx]; 962 + 963 + if (likely(chan->center_freq != reg_beacon->chan.center_freq)) 964 + return; 965 + 966 + if (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN) { 967 + chan->flags &= ~IEEE80211_CHAN_PASSIVE_SCAN; 968 + REG_DEBUG_BEACON_FLAG("active scanning"); 969 + } 970 + 971 + if (chan->flags & IEEE80211_CHAN_NO_IBSS) { 972 + chan->flags &= ~IEEE80211_CHAN_NO_IBSS; 973 + REG_DEBUG_BEACON_FLAG("beaconing"); 974 + } 975 + 976 + chan->beacon_found = true; 977 + #undef REG_DEBUG_BEACON_FLAG 978 + } 979 + 980 + /* 981 + * Called when a scan on a wiphy finds a beacon on 982 + * new channel 983 + */ 984 + static void wiphy_update_new_beacon(struct wiphy *wiphy, 985 + struct reg_beacon *reg_beacon) 986 + { 987 + unsigned int i; 988 + struct ieee80211_supported_band *sband; 989 + 990 + assert_cfg80211_lock(); 991 + 992 + if (!wiphy->bands[reg_beacon->chan.band]) 993 + return; 994 + 995 + sband = wiphy->bands[reg_beacon->chan.band]; 996 + 997 + for (i = 0; i < sband->n_channels; i++) 998 + handle_reg_beacon(wiphy, i, reg_beacon); 999 + } 1000 + 1001 + /* 1002 + * Called upon reg changes or a new wiphy is added 1003 + */ 1004 + static void wiphy_update_beacon_reg(struct wiphy *wiphy) 1005 + { 1006 + unsigned int i; 1007 + struct ieee80211_supported_band *sband; 1008 + struct reg_beacon *reg_beacon; 1009 + 1010 + assert_cfg80211_lock(); 1011 + 1012 + if (list_empty(&reg_beacon_list)) 1013 + return; 1014 + 1015 + list_for_each_entry(reg_beacon, &reg_beacon_list, list) { 1016 + if (!wiphy->bands[reg_beacon->chan.band]) 1017 + continue; 1018 + sband = wiphy->bands[reg_beacon->chan.band]; 1019 + for (i = 0; i < sband->n_channels; i++) 1020 + handle_reg_beacon(wiphy, i, reg_beacon); 1021 + } 1022 + } 1023 + 1024 + static bool reg_is_world_roaming(struct wiphy *wiphy) 1025 + { 1026 + if (is_world_regdom(cfg80211_regdomain->alpha2) || 1027 + (wiphy->regd && is_world_regdom(wiphy->regd->alpha2))) 1028 + return true; 1029 + if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE && 1030 + wiphy->custom_regulatory) 1031 + return true; 1032 + return false; 1033 + } 1034 + 1035 + /* Reap the advantages of previously found beacons */ 1036 + static void reg_process_beacons(struct wiphy *wiphy) 1037 + { 1038 + if (!reg_is_world_roaming(wiphy)) 1039 + return; 1040 + wiphy_update_beacon_reg(wiphy); 1041 + } 1042 + 1027 1043 void wiphy_update_regulatory(struct wiphy *wiphy, enum reg_set_by setby) 1028 1044 { 1029 1045 enum ieee80211_band band; 1030 1046 1031 1047 if (ignore_reg_update(wiphy, setby)) 1032 - return; 1048 + goto out; 1033 1049 for (band = 0; band < IEEE80211_NUM_BANDS; band++) { 1034 1050 if (wiphy->bands[band]) 1035 1051 handle_band(wiphy, band); 1036 1052 } 1053 + out: 1054 + reg_process_beacons(wiphy); 1037 1055 if (wiphy->reg_notifier) 1038 1056 wiphy->reg_notifier(wiphy, last_request); 1039 1057 } ··· 1223 1033 return 0; 1224 1034 } 1225 1035 1226 - /* Return value which can be used by ignore_request() to indicate 1227 - * it has been determined we should intersect two regulatory domains */ 1036 + /* 1037 + * Return value which can be used by ignore_request() to indicate 1038 + * it has been determined we should intersect two regulatory domains 1039 + */ 1228 1040 #define REG_INTERSECT 1 1229 1041 1230 1042 /* This has the logic which determines when a new request 1231 1043 * should be ignored. */ 1232 - static int ignore_request(struct wiphy *wiphy, enum reg_set_by set_by, 1233 - const char *alpha2) 1044 + static int ignore_request(struct wiphy *wiphy, 1045 + struct regulatory_request *pending_request) 1234 1046 { 1047 + struct wiphy *last_wiphy = NULL; 1048 + 1049 + assert_cfg80211_lock(); 1050 + 1235 1051 /* All initial requests are respected */ 1236 1052 if (!last_request) 1237 1053 return 0; 1238 1054 1239 - switch (set_by) { 1055 + switch (pending_request->initiator) { 1240 1056 case REGDOM_SET_BY_INIT: 1241 1057 return -EINVAL; 1242 1058 case REGDOM_SET_BY_CORE: 1243 - /* 1244 - * Always respect new wireless core hints, should only happen 1245 - * when updating the world regulatory domain at init. 1246 - */ 1247 - return 0; 1059 + return -EINVAL; 1248 1060 case REGDOM_SET_BY_COUNTRY_IE: 1249 - if (unlikely(!is_an_alpha2(alpha2))) 1061 + 1062 + last_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); 1063 + 1064 + if (unlikely(!is_an_alpha2(pending_request->alpha2))) 1250 1065 return -EINVAL; 1251 1066 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) { 1252 - if (last_request->wiphy != wiphy) { 1067 + if (last_wiphy != wiphy) { 1253 1068 /* 1254 1069 * Two cards with two APs claiming different 1255 1070 * different Country IE alpha2s. We could 1256 1071 * intersect them, but that seems unlikely 1257 1072 * to be correct. Reject second one for now. 1258 1073 */ 1259 - if (!alpha2_equal(alpha2, 1260 - cfg80211_regdomain->alpha2)) 1074 + if (regdom_changes(pending_request->alpha2)) 1261 1075 return -EOPNOTSUPP; 1262 1076 return -EALREADY; 1263 1077 } 1264 - /* Two consecutive Country IE hints on the same wiphy. 1265 - * This should be picked up early by the driver/stack */ 1266 - if (WARN_ON(!alpha2_equal(cfg80211_regdomain->alpha2, 1267 - alpha2))) 1078 + /* 1079 + * Two consecutive Country IE hints on the same wiphy. 1080 + * This should be picked up early by the driver/stack 1081 + */ 1082 + if (WARN_ON(regdom_changes(pending_request->alpha2))) 1268 1083 return 0; 1269 1084 return -EALREADY; 1270 1085 } ··· 1278 1083 if (last_request->initiator == REGDOM_SET_BY_CORE) { 1279 1084 if (is_old_static_regdom(cfg80211_regdomain)) 1280 1085 return 0; 1281 - if (!alpha2_equal(cfg80211_regdomain->alpha2, alpha2)) 1086 + if (regdom_changes(pending_request->alpha2)) 1282 1087 return 0; 1283 1088 return -EALREADY; 1284 1089 } 1090 + 1091 + /* 1092 + * This would happen if you unplug and plug your card 1093 + * back in or if you add a new device for which the previously 1094 + * loaded card also agrees on the regulatory domain. 1095 + */ 1096 + if (last_request->initiator == REGDOM_SET_BY_DRIVER && 1097 + !regdom_changes(pending_request->alpha2)) 1098 + return -EALREADY; 1099 + 1285 1100 return REG_INTERSECT; 1286 1101 case REGDOM_SET_BY_USER: 1287 1102 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) 1288 1103 return REG_INTERSECT; 1289 - /* If the user knows better the user should set the regdom 1290 - * to their country before the IE is picked up */ 1104 + /* 1105 + * If the user knows better the user should set the regdom 1106 + * to their country before the IE is picked up 1107 + */ 1291 1108 if (last_request->initiator == REGDOM_SET_BY_USER && 1292 1109 last_request->intersect) 1293 1110 return -EOPNOTSUPP; 1294 - /* Process user requests only after previous user/driver/core 1295 - * requests have been processed */ 1111 + /* 1112 + * Process user requests only after previous user/driver/core 1113 + * requests have been processed 1114 + */ 1296 1115 if (last_request->initiator == REGDOM_SET_BY_CORE || 1297 1116 last_request->initiator == REGDOM_SET_BY_DRIVER || 1298 1117 last_request->initiator == REGDOM_SET_BY_USER) { 1299 - if (!alpha2_equal(last_request->alpha2, 1300 - cfg80211_regdomain->alpha2)) 1118 + if (regdom_changes(last_request->alpha2)) 1301 1119 return -EAGAIN; 1302 1120 } 1303 1121 1304 1122 if (!is_old_static_regdom(cfg80211_regdomain) && 1305 - alpha2_equal(cfg80211_regdomain->alpha2, alpha2)) 1123 + !regdom_changes(pending_request->alpha2)) 1306 1124 return -EALREADY; 1307 1125 1308 1126 return 0; ··· 1324 1116 return -EINVAL; 1325 1117 } 1326 1118 1327 - /* Caller must hold &cfg80211_drv_mutex */ 1328 - int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by, 1329 - const char *alpha2, 1330 - u32 country_ie_checksum, 1331 - enum environment_cap env) 1119 + /** 1120 + * __regulatory_hint - hint to the wireless core a regulatory domain 1121 + * @wiphy: if the hint comes from country information from an AP, this 1122 + * is required to be set to the wiphy that received the information 1123 + * @pending_request: the regulatory request currently being processed 1124 + * 1125 + * The Wireless subsystem can use this function to hint to the wireless core 1126 + * what it believes should be the current regulatory domain. 1127 + * 1128 + * Returns zero if all went fine, %-EALREADY if a regulatory domain had 1129 + * already been set or other standard error codes. 1130 + * 1131 + * Caller must hold &cfg80211_mutex 1132 + */ 1133 + static int __regulatory_hint(struct wiphy *wiphy, 1134 + struct regulatory_request *pending_request) 1332 1135 { 1333 - struct regulatory_request *request; 1334 1136 bool intersect = false; 1335 1137 int r = 0; 1336 1138 1337 - r = ignore_request(wiphy, set_by, alpha2); 1139 + assert_cfg80211_lock(); 1140 + 1141 + r = ignore_request(wiphy, pending_request); 1338 1142 1339 1143 if (r == REG_INTERSECT) { 1340 - if (set_by == REGDOM_SET_BY_DRIVER) { 1144 + if (pending_request->initiator == REGDOM_SET_BY_DRIVER) { 1341 1145 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); 1342 - if (r) 1146 + if (r) { 1147 + kfree(pending_request); 1343 1148 return r; 1149 + } 1344 1150 } 1345 1151 intersect = true; 1346 1152 } else if (r) { 1347 - /* If the regulatory domain being requested by the 1153 + /* 1154 + * If the regulatory domain being requested by the 1348 1155 * driver has already been set just copy it to the 1349 - * wiphy */ 1350 - if (r == -EALREADY && set_by == REGDOM_SET_BY_DRIVER) { 1156 + * wiphy 1157 + */ 1158 + if (r == -EALREADY && 1159 + pending_request->initiator == REGDOM_SET_BY_DRIVER) { 1351 1160 r = reg_copy_regd(&wiphy->regd, cfg80211_regdomain); 1352 - if (r) 1161 + if (r) { 1162 + kfree(pending_request); 1353 1163 return r; 1164 + } 1354 1165 r = -EALREADY; 1355 1166 goto new_request; 1356 1167 } 1168 + kfree(pending_request); 1357 1169 return r; 1358 1170 } 1359 1171 1360 1172 new_request: 1361 - request = kzalloc(sizeof(struct regulatory_request), 1362 - GFP_KERNEL); 1363 - if (!request) 1364 - return -ENOMEM; 1365 - 1366 - request->alpha2[0] = alpha2[0]; 1367 - request->alpha2[1] = alpha2[1]; 1368 - request->initiator = set_by; 1369 - request->wiphy = wiphy; 1370 - request->intersect = intersect; 1371 - request->country_ie_checksum = country_ie_checksum; 1372 - request->country_ie_env = env; 1373 - 1374 1173 kfree(last_request); 1375 - last_request = request; 1174 + 1175 + last_request = pending_request; 1176 + last_request->intersect = intersect; 1177 + 1178 + pending_request = NULL; 1376 1179 1377 1180 /* When r == REG_INTERSECT we do need to call CRDA */ 1378 1181 if (r < 0) ··· 1399 1180 * 1400 1181 * to intersect with the static rd 1401 1182 */ 1402 - return call_crda(alpha2); 1183 + return call_crda(last_request->alpha2); 1403 1184 } 1404 1185 1405 - void regulatory_hint(struct wiphy *wiphy, const char *alpha2) 1186 + /* This currently only processes user and driver regulatory hints */ 1187 + static void reg_process_hint(struct regulatory_request *reg_request) 1406 1188 { 1407 - int r; 1189 + int r = 0; 1190 + struct wiphy *wiphy = NULL; 1191 + 1192 + BUG_ON(!reg_request->alpha2); 1193 + 1194 + mutex_lock(&cfg80211_mutex); 1195 + 1196 + if (wiphy_idx_valid(reg_request->wiphy_idx)) 1197 + wiphy = wiphy_idx_to_wiphy(reg_request->wiphy_idx); 1198 + 1199 + if (reg_request->initiator == REGDOM_SET_BY_DRIVER && 1200 + !wiphy) { 1201 + kfree(reg_request); 1202 + goto out; 1203 + } 1204 + 1205 + r = __regulatory_hint(wiphy, reg_request); 1206 + /* This is required so that the orig_* parameters are saved */ 1207 + if (r == -EALREADY && wiphy && wiphy->strict_regulatory) 1208 + wiphy_update_regulatory(wiphy, reg_request->initiator); 1209 + out: 1210 + mutex_unlock(&cfg80211_mutex); 1211 + } 1212 + 1213 + /* Processes regulatory hints, this is all the REGDOM_SET_BY_* */ 1214 + static void reg_process_pending_hints(void) 1215 + { 1216 + struct regulatory_request *reg_request; 1217 + 1218 + spin_lock(&reg_requests_lock); 1219 + while (!list_empty(&reg_requests_list)) { 1220 + reg_request = list_first_entry(&reg_requests_list, 1221 + struct regulatory_request, 1222 + list); 1223 + list_del_init(&reg_request->list); 1224 + 1225 + spin_unlock(&reg_requests_lock); 1226 + reg_process_hint(reg_request); 1227 + spin_lock(&reg_requests_lock); 1228 + } 1229 + spin_unlock(&reg_requests_lock); 1230 + } 1231 + 1232 + /* Processes beacon hints -- this has nothing to do with country IEs */ 1233 + static void reg_process_pending_beacon_hints(void) 1234 + { 1235 + struct cfg80211_registered_device *drv; 1236 + struct reg_beacon *pending_beacon, *tmp; 1237 + 1238 + mutex_lock(&cfg80211_mutex); 1239 + 1240 + /* This goes through the _pending_ beacon list */ 1241 + spin_lock_bh(&reg_pending_beacons_lock); 1242 + 1243 + if (list_empty(&reg_pending_beacons)) { 1244 + spin_unlock_bh(&reg_pending_beacons_lock); 1245 + goto out; 1246 + } 1247 + 1248 + list_for_each_entry_safe(pending_beacon, tmp, 1249 + &reg_pending_beacons, list) { 1250 + 1251 + list_del_init(&pending_beacon->list); 1252 + 1253 + /* Applies the beacon hint to current wiphys */ 1254 + list_for_each_entry(drv, &cfg80211_drv_list, list) 1255 + wiphy_update_new_beacon(&drv->wiphy, pending_beacon); 1256 + 1257 + /* Remembers the beacon hint for new wiphys or reg changes */ 1258 + list_add_tail(&pending_beacon->list, &reg_beacon_list); 1259 + } 1260 + 1261 + spin_unlock_bh(&reg_pending_beacons_lock); 1262 + out: 1263 + mutex_unlock(&cfg80211_mutex); 1264 + } 1265 + 1266 + static void reg_todo(struct work_struct *work) 1267 + { 1268 + reg_process_pending_hints(); 1269 + reg_process_pending_beacon_hints(); 1270 + } 1271 + 1272 + static DECLARE_WORK(reg_work, reg_todo); 1273 + 1274 + static void queue_regulatory_request(struct regulatory_request *request) 1275 + { 1276 + spin_lock(&reg_requests_lock); 1277 + list_add_tail(&request->list, &reg_requests_list); 1278 + spin_unlock(&reg_requests_lock); 1279 + 1280 + schedule_work(&reg_work); 1281 + } 1282 + 1283 + /* Core regulatory hint -- happens once during cfg80211_init() */ 1284 + static int regulatory_hint_core(const char *alpha2) 1285 + { 1286 + struct regulatory_request *request; 1287 + 1288 + BUG_ON(last_request); 1289 + 1290 + request = kzalloc(sizeof(struct regulatory_request), 1291 + GFP_KERNEL); 1292 + if (!request) 1293 + return -ENOMEM; 1294 + 1295 + request->alpha2[0] = alpha2[0]; 1296 + request->alpha2[1] = alpha2[1]; 1297 + request->initiator = REGDOM_SET_BY_CORE; 1298 + 1299 + queue_regulatory_request(request); 1300 + 1301 + return 0; 1302 + } 1303 + 1304 + /* User hints */ 1305 + int regulatory_hint_user(const char *alpha2) 1306 + { 1307 + struct regulatory_request *request; 1308 + 1408 1309 BUG_ON(!alpha2); 1409 1310 1410 - mutex_lock(&cfg80211_drv_mutex); 1411 - r = __regulatory_hint(wiphy, REGDOM_SET_BY_DRIVER, 1412 - alpha2, 0, ENVIRON_ANY); 1413 - /* This is required so that the orig_* parameters are saved */ 1414 - if (r == -EALREADY && wiphy->strict_regulatory) 1415 - wiphy_update_regulatory(wiphy, REGDOM_SET_BY_DRIVER); 1416 - mutex_unlock(&cfg80211_drv_mutex); 1311 + request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); 1312 + if (!request) 1313 + return -ENOMEM; 1314 + 1315 + request->wiphy_idx = WIPHY_IDX_STALE; 1316 + request->alpha2[0] = alpha2[0]; 1317 + request->alpha2[1] = alpha2[1]; 1318 + request->initiator = REGDOM_SET_BY_USER, 1319 + 1320 + queue_regulatory_request(request); 1321 + 1322 + return 0; 1323 + } 1324 + 1325 + /* Driver hints */ 1326 + int regulatory_hint(struct wiphy *wiphy, const char *alpha2) 1327 + { 1328 + struct regulatory_request *request; 1329 + 1330 + BUG_ON(!alpha2); 1331 + BUG_ON(!wiphy); 1332 + 1333 + request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); 1334 + if (!request) 1335 + return -ENOMEM; 1336 + 1337 + request->wiphy_idx = get_wiphy_idx(wiphy); 1338 + 1339 + /* Must have registered wiphy first */ 1340 + BUG_ON(!wiphy_idx_valid(request->wiphy_idx)); 1341 + 1342 + request->alpha2[0] = alpha2[0]; 1343 + request->alpha2[1] = alpha2[1]; 1344 + request->initiator = REGDOM_SET_BY_DRIVER; 1345 + 1346 + queue_regulatory_request(request); 1347 + 1348 + return 0; 1417 1349 } 1418 1350 EXPORT_SYMBOL(regulatory_hint); 1419 1351 1420 1352 static bool reg_same_country_ie_hint(struct wiphy *wiphy, 1421 1353 u32 country_ie_checksum) 1422 1354 { 1423 - if (!last_request->wiphy) 1355 + struct wiphy *request_wiphy; 1356 + 1357 + assert_cfg80211_lock(); 1358 + 1359 + request_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); 1360 + 1361 + if (!request_wiphy) 1424 1362 return false; 1425 - if (likely(last_request->wiphy != wiphy)) 1363 + 1364 + if (likely(request_wiphy != wiphy)) 1426 1365 return !country_ie_integrity_changes(country_ie_checksum); 1427 - /* We should not have let these through at this point, they 1366 + /* 1367 + * We should not have let these through at this point, they 1428 1368 * should have been picked up earlier by the first alpha2 check 1429 - * on the device */ 1369 + * on the device 1370 + */ 1430 1371 if (WARN_ON(!country_ie_integrity_changes(country_ie_checksum))) 1431 1372 return true; 1432 1373 return false; ··· 1600 1221 char alpha2[2]; 1601 1222 u32 checksum = 0; 1602 1223 enum environment_cap env = ENVIRON_ANY; 1224 + struct regulatory_request *request; 1603 1225 1604 - if (!last_request) 1226 + mutex_lock(&cfg80211_mutex); 1227 + 1228 + if (unlikely(!last_request)) { 1229 + mutex_unlock(&cfg80211_mutex); 1605 1230 return; 1606 - 1607 - mutex_lock(&cfg80211_drv_mutex); 1231 + } 1608 1232 1609 1233 /* IE len must be evenly divisible by 2 */ 1610 1234 if (country_ie_len & 0x01) ··· 1616 1234 if (country_ie_len < IEEE80211_COUNTRY_IE_MIN_LEN) 1617 1235 goto out; 1618 1236 1619 - /* Pending country IE processing, this can happen after we 1237 + /* 1238 + * Pending country IE processing, this can happen after we 1620 1239 * call CRDA and wait for a response if a beacon was received before 1621 - * we were able to process the last regulatory_hint_11d() call */ 1240 + * we were able to process the last regulatory_hint_11d() call 1241 + */ 1622 1242 if (country_ie_regdomain) 1623 1243 goto out; 1624 1244 ··· 1632 1248 else if (country_ie[2] == 'O') 1633 1249 env = ENVIRON_OUTDOOR; 1634 1250 1635 - /* We will run this for *every* beacon processed for the BSSID, so 1251 + /* 1252 + * We will run this for *every* beacon processed for the BSSID, so 1636 1253 * we optimize an early check to exit out early if we don't have to 1637 - * do anything */ 1638 - if (likely(last_request->wiphy)) { 1254 + * do anything 1255 + */ 1256 + if (likely(wiphy_idx_valid(last_request->wiphy_idx))) { 1639 1257 struct cfg80211_registered_device *drv_last_ie; 1640 1258 1641 - drv_last_ie = wiphy_to_dev(last_request->wiphy); 1259 + drv_last_ie = 1260 + cfg80211_drv_by_wiphy_idx(last_request->wiphy_idx); 1642 1261 1643 - /* Lets keep this simple -- we trust the first AP 1644 - * after we intersect with CRDA */ 1645 - if (likely(last_request->wiphy == wiphy)) { 1646 - /* Ignore IEs coming in on this wiphy with 1647 - * the same alpha2 and environment cap */ 1262 + /* 1263 + * Lets keep this simple -- we trust the first AP 1264 + * after we intersect with CRDA 1265 + */ 1266 + if (likely(&drv_last_ie->wiphy == wiphy)) { 1267 + /* 1268 + * Ignore IEs coming in on this wiphy with 1269 + * the same alpha2 and environment cap 1270 + */ 1648 1271 if (likely(alpha2_equal(drv_last_ie->country_ie_alpha2, 1649 1272 alpha2) && 1650 1273 env == drv_last_ie->env)) { 1651 1274 goto out; 1652 1275 } 1653 - /* the wiphy moved on to another BSSID or the AP 1276 + /* 1277 + * the wiphy moved on to another BSSID or the AP 1654 1278 * was reconfigured. XXX: We need to deal with the 1655 1279 * case where the user suspends and goes to goes 1656 1280 * to another country, and then gets IEs from an 1657 - * AP with different settings */ 1281 + * AP with different settings 1282 + */ 1658 1283 goto out; 1659 1284 } else { 1660 - /* Ignore IEs coming in on two separate wiphys with 1661 - * the same alpha2 and environment cap */ 1285 + /* 1286 + * Ignore IEs coming in on two separate wiphys with 1287 + * the same alpha2 and environment cap 1288 + */ 1662 1289 if (likely(alpha2_equal(drv_last_ie->country_ie_alpha2, 1663 1290 alpha2) && 1664 1291 env == drv_last_ie->env)) { ··· 1684 1289 if (!rd) 1685 1290 goto out; 1686 1291 1687 - /* This will not happen right now but we leave it here for the 1292 + /* 1293 + * This will not happen right now but we leave it here for the 1688 1294 * the future when we want to add suspend/resume support and having 1689 1295 * the user move to another country after doing so, or having the user 1690 - * move to another AP. Right now we just trust the first AP. This is why 1691 - * this is marked as likley(). If we hit this before we add this support 1692 - * we want to be informed of it as it would indicate a mistake in the 1693 - * current design */ 1694 - if (likely(WARN_ON(reg_same_country_ie_hint(wiphy, checksum)))) 1695 - goto out; 1296 + * move to another AP. Right now we just trust the first AP. 1297 + * 1298 + * If we hit this before we add this support we want to be informed of 1299 + * it as it would indicate a mistake in the current design 1300 + */ 1301 + if (WARN_ON(reg_same_country_ie_hint(wiphy, checksum))) 1302 + goto free_rd_out; 1696 1303 1697 - /* We keep this around for when CRDA comes back with a response so 1698 - * we can intersect with that */ 1304 + request = kzalloc(sizeof(struct regulatory_request), GFP_KERNEL); 1305 + if (!request) 1306 + goto free_rd_out; 1307 + 1308 + /* 1309 + * We keep this around for when CRDA comes back with a response so 1310 + * we can intersect with that 1311 + */ 1699 1312 country_ie_regdomain = rd; 1700 1313 1701 - __regulatory_hint(wiphy, REGDOM_SET_BY_COUNTRY_IE, 1702 - country_ie_regdomain->alpha2, checksum, env); 1314 + request->wiphy_idx = get_wiphy_idx(wiphy); 1315 + request->alpha2[0] = rd->alpha2[0]; 1316 + request->alpha2[1] = rd->alpha2[1]; 1317 + request->initiator = REGDOM_SET_BY_COUNTRY_IE; 1318 + request->country_ie_checksum = checksum; 1319 + request->country_ie_env = env; 1703 1320 1321 + mutex_unlock(&cfg80211_mutex); 1322 + 1323 + queue_regulatory_request(request); 1324 + 1325 + return; 1326 + 1327 + free_rd_out: 1328 + kfree(rd); 1704 1329 out: 1705 - mutex_unlock(&cfg80211_drv_mutex); 1330 + mutex_unlock(&cfg80211_mutex); 1706 1331 } 1707 1332 EXPORT_SYMBOL(regulatory_hint_11d); 1333 + 1334 + static bool freq_is_chan_12_13_14(u16 freq) 1335 + { 1336 + if (freq == ieee80211_channel_to_frequency(12) || 1337 + freq == ieee80211_channel_to_frequency(13) || 1338 + freq == ieee80211_channel_to_frequency(14)) 1339 + return true; 1340 + return false; 1341 + } 1342 + 1343 + int regulatory_hint_found_beacon(struct wiphy *wiphy, 1344 + struct ieee80211_channel *beacon_chan, 1345 + gfp_t gfp) 1346 + { 1347 + struct reg_beacon *reg_beacon; 1348 + 1349 + if (likely((beacon_chan->beacon_found || 1350 + (beacon_chan->flags & IEEE80211_CHAN_RADAR) || 1351 + (beacon_chan->band == IEEE80211_BAND_2GHZ && 1352 + !freq_is_chan_12_13_14(beacon_chan->center_freq))))) 1353 + return 0; 1354 + 1355 + reg_beacon = kzalloc(sizeof(struct reg_beacon), gfp); 1356 + if (!reg_beacon) 1357 + return -ENOMEM; 1358 + 1359 + #ifdef CONFIG_CFG80211_REG_DEBUG 1360 + printk(KERN_DEBUG "cfg80211: Found new beacon on " 1361 + "frequency: %d MHz (Ch %d) on %s\n", 1362 + beacon_chan->center_freq, 1363 + ieee80211_frequency_to_channel(beacon_chan->center_freq), 1364 + wiphy_name(wiphy)); 1365 + #endif 1366 + memcpy(&reg_beacon->chan, beacon_chan, 1367 + sizeof(struct ieee80211_channel)); 1368 + 1369 + 1370 + /* 1371 + * Since we can be called from BH or and non-BH context 1372 + * we must use spin_lock_bh() 1373 + */ 1374 + spin_lock_bh(&reg_pending_beacons_lock); 1375 + list_add_tail(&reg_beacon->list, &reg_pending_beacons); 1376 + spin_unlock_bh(&reg_pending_beacons_lock); 1377 + 1378 + schedule_work(&reg_work); 1379 + 1380 + return 0; 1381 + } 1708 1382 1709 1383 static void print_rd_rules(const struct ieee80211_regdomain *rd) 1710 1384 { ··· 1790 1326 freq_range = &reg_rule->freq_range; 1791 1327 power_rule = &reg_rule->power_rule; 1792 1328 1793 - /* There may not be documentation for max antenna gain 1794 - * in certain regions */ 1329 + /* 1330 + * There may not be documentation for max antenna gain 1331 + * in certain regions 1332 + */ 1795 1333 if (power_rule->max_antenna_gain) 1796 1334 printk(KERN_INFO "\t(%d KHz - %d KHz @ %d KHz), " 1797 1335 "(%d mBi, %d mBm)\n", ··· 1816 1350 { 1817 1351 1818 1352 if (is_intersected_alpha2(rd->alpha2)) { 1819 - struct wiphy *wiphy = NULL; 1820 - struct cfg80211_registered_device *drv; 1821 1353 1822 1354 if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) { 1823 - if (last_request->wiphy) { 1824 - wiphy = last_request->wiphy; 1825 - drv = wiphy_to_dev(wiphy); 1355 + struct cfg80211_registered_device *drv; 1356 + drv = cfg80211_drv_by_wiphy_idx( 1357 + last_request->wiphy_idx); 1358 + if (drv) { 1826 1359 printk(KERN_INFO "cfg80211: Current regulatory " 1827 1360 "domain updated by AP to: %c%c\n", 1828 1361 drv->country_ie_alpha2[0], ··· 1887 1422 { 1888 1423 const struct ieee80211_regdomain *intersected_rd = NULL; 1889 1424 struct cfg80211_registered_device *drv = NULL; 1890 - struct wiphy *wiphy = NULL; 1425 + struct wiphy *request_wiphy; 1891 1426 /* Some basic sanity checks first */ 1892 1427 1893 1428 if (is_world_regdom(rd->alpha2)) { ··· 1904 1439 if (!last_request) 1905 1440 return -EINVAL; 1906 1441 1907 - /* Lets only bother proceeding on the same alpha2 if the current 1442 + /* 1443 + * Lets only bother proceeding on the same alpha2 if the current 1908 1444 * rd is non static (it means CRDA was present and was used last) 1909 - * and the pending request came in from a country IE */ 1445 + * and the pending request came in from a country IE 1446 + */ 1910 1447 if (last_request->initiator != REGDOM_SET_BY_COUNTRY_IE) { 1911 - /* If someone else asked us to change the rd lets only bother 1912 - * checking if the alpha2 changes if CRDA was already called */ 1448 + /* 1449 + * If someone else asked us to change the rd lets only bother 1450 + * checking if the alpha2 changes if CRDA was already called 1451 + */ 1913 1452 if (!is_old_static_regdom(cfg80211_regdomain) && 1914 - !regdom_changed(rd->alpha2)) 1453 + !regdom_changes(rd->alpha2)) 1915 1454 return -EINVAL; 1916 1455 } 1917 1456 1918 - wiphy = last_request->wiphy; 1919 - 1920 - /* Now lets set the regulatory domain, update all driver channels 1457 + /* 1458 + * Now lets set the regulatory domain, update all driver channels 1921 1459 * and finally inform them of what we have done, in case they want 1922 1460 * to review or adjust their own settings based on their own 1923 - * internal EEPROM data */ 1461 + * internal EEPROM data 1462 + */ 1924 1463 1925 1464 if (WARN_ON(!reg_is_valid_request(rd->alpha2))) 1926 1465 return -EINVAL; ··· 1936 1467 return -EINVAL; 1937 1468 } 1938 1469 1470 + request_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); 1471 + 1939 1472 if (!last_request->intersect) { 1940 1473 int r; 1941 1474 ··· 1947 1476 return 0; 1948 1477 } 1949 1478 1950 - /* For a driver hint, lets copy the regulatory domain the 1951 - * driver wanted to the wiphy to deal with conflicts */ 1479 + /* 1480 + * For a driver hint, lets copy the regulatory domain the 1481 + * driver wanted to the wiphy to deal with conflicts 1482 + */ 1952 1483 1953 - BUG_ON(last_request->wiphy->regd); 1484 + BUG_ON(request_wiphy->regd); 1954 1485 1955 - r = reg_copy_regd(&last_request->wiphy->regd, rd); 1486 + r = reg_copy_regd(&request_wiphy->regd, rd); 1956 1487 if (r) 1957 1488 return r; 1958 1489 ··· 1971 1498 if (!intersected_rd) 1972 1499 return -EINVAL; 1973 1500 1974 - /* We can trash what CRDA provided now. 1501 + /* 1502 + * We can trash what CRDA provided now. 1975 1503 * However if a driver requested this specific regulatory 1976 - * domain we keep it for its private use */ 1504 + * domain we keep it for its private use 1505 + */ 1977 1506 if (last_request->initiator == REGDOM_SET_BY_DRIVER) 1978 - last_request->wiphy->regd = rd; 1507 + request_wiphy->regd = rd; 1979 1508 else 1980 1509 kfree(rd); 1981 1510 ··· 1997 1522 BUG_ON(!country_ie_regdomain); 1998 1523 1999 1524 if (rd != country_ie_regdomain) { 2000 - /* Intersect what CRDA returned and our what we 2001 - * had built from the Country IE received */ 1525 + /* 1526 + * Intersect what CRDA returned and our what we 1527 + * had built from the Country IE received 1528 + */ 2002 1529 2003 1530 intersected_rd = regdom_intersect(rd, country_ie_regdomain); 2004 1531 ··· 2010 1533 kfree(country_ie_regdomain); 2011 1534 country_ie_regdomain = NULL; 2012 1535 } else { 2013 - /* This would happen when CRDA was not present and 1536 + /* 1537 + * This would happen when CRDA was not present and 2014 1538 * OLD_REGULATORY was enabled. We intersect our Country 2015 - * IE rd and what was set on cfg80211 originally */ 1539 + * IE rd and what was set on cfg80211 originally 1540 + */ 2016 1541 intersected_rd = regdom_intersect(rd, cfg80211_regdomain); 2017 1542 } 2018 1543 2019 1544 if (!intersected_rd) 2020 1545 return -EINVAL; 2021 1546 2022 - drv = wiphy_to_dev(wiphy); 1547 + drv = wiphy_to_dev(request_wiphy); 2023 1548 2024 1549 drv->country_ie_alpha2[0] = rd->alpha2[0]; 2025 1550 drv->country_ie_alpha2[1] = rd->alpha2[1]; ··· 2039 1560 } 2040 1561 2041 1562 2042 - /* Use this call to set the current regulatory domain. Conflicts with 1563 + /* 1564 + * Use this call to set the current regulatory domain. Conflicts with 2043 1565 * multiple drivers can be ironed out later. Caller must've already 2044 - * kmalloc'd the rd structure. Caller must hold cfg80211_drv_mutex */ 1566 + * kmalloc'd the rd structure. Caller must hold cfg80211_mutex 1567 + */ 2045 1568 int set_regdom(const struct ieee80211_regdomain *rd) 2046 1569 { 2047 1570 int r; 1571 + 1572 + assert_cfg80211_lock(); 2048 1573 2049 1574 /* Note that this doesn't update the wiphys, this is done below */ 2050 1575 r = __set_regdom(rd); ··· 2069 1586 return r; 2070 1587 } 2071 1588 2072 - /* Caller must hold cfg80211_drv_mutex */ 1589 + /* Caller must hold cfg80211_mutex */ 2073 1590 void reg_device_remove(struct wiphy *wiphy) 2074 1591 { 1592 + struct wiphy *request_wiphy; 1593 + 1594 + assert_cfg80211_lock(); 1595 + 1596 + request_wiphy = wiphy_idx_to_wiphy(last_request->wiphy_idx); 1597 + 2075 1598 kfree(wiphy->regd); 2076 - if (!last_request || !last_request->wiphy) 1599 + if (!last_request || !request_wiphy) 2077 1600 return; 2078 - if (last_request->wiphy != wiphy) 1601 + if (request_wiphy != wiphy) 2079 1602 return; 2080 - last_request->wiphy = NULL; 1603 + last_request->wiphy_idx = WIPHY_IDX_STALE; 2081 1604 last_request->country_ie_env = ENVIRON_ANY; 2082 1605 } 2083 1606 2084 1607 int regulatory_init(void) 2085 1608 { 2086 - int err; 1609 + int err = 0; 2087 1610 2088 1611 reg_pdev = platform_device_register_simple("regulatory", 0, NULL, 0); 2089 1612 if (IS_ERR(reg_pdev)) 2090 1613 return PTR_ERR(reg_pdev); 1614 + 1615 + spin_lock_init(&reg_requests_lock); 1616 + spin_lock_init(&reg_pending_beacons_lock); 2091 1617 2092 1618 #ifdef CONFIG_WIRELESS_OLD_REGULATORY 2093 1619 cfg80211_regdomain = static_regdom(ieee80211_regdom); 2094 1620 2095 1621 printk(KERN_INFO "cfg80211: Using static regulatory domain info\n"); 2096 1622 print_regdomain_info(cfg80211_regdomain); 2097 - /* The old code still requests for a new regdomain and if 1623 + /* 1624 + * The old code still requests for a new regdomain and if 2098 1625 * you have CRDA you get it updated, otherwise you get 2099 1626 * stuck with the static values. We ignore "EU" code as 2100 - * that is not a valid ISO / IEC 3166 alpha2 */ 1627 + * that is not a valid ISO / IEC 3166 alpha2 1628 + */ 2101 1629 if (ieee80211_regdom[0] != 'E' || ieee80211_regdom[1] != 'U') 2102 - err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, 2103 - ieee80211_regdom, 0, ENVIRON_ANY); 1630 + err = regulatory_hint_core(ieee80211_regdom); 2104 1631 #else 2105 1632 cfg80211_regdomain = cfg80211_world_regdom; 2106 1633 2107 - err = __regulatory_hint(NULL, REGDOM_SET_BY_CORE, "00", 0, ENVIRON_ANY); 2108 - if (err) 2109 - printk(KERN_ERR "cfg80211: calling CRDA failed - " 2110 - "unable to update world regulatory domain, " 2111 - "using static definition\n"); 1634 + err = regulatory_hint_core("00"); 2112 1635 #endif 1636 + if (err) { 1637 + if (err == -ENOMEM) 1638 + return err; 1639 + /* 1640 + * N.B. kobject_uevent_env() can fail mainly for when we're out 1641 + * memory which is handled and propagated appropriately above 1642 + * but it can also fail during a netlink_broadcast() or during 1643 + * early boot for call_usermodehelper(). For now treat these 1644 + * errors as non-fatal. 1645 + */ 1646 + printk(KERN_ERR "cfg80211: kobject_uevent_env() was unable " 1647 + "to call CRDA during init"); 1648 + #ifdef CONFIG_CFG80211_REG_DEBUG 1649 + /* We want to find out exactly why when debugging */ 1650 + WARN_ON(err); 1651 + #endif 1652 + } 2113 1653 2114 1654 return 0; 2115 1655 } 2116 1656 2117 1657 void regulatory_exit(void) 2118 1658 { 2119 - mutex_lock(&cfg80211_drv_mutex); 1659 + struct regulatory_request *reg_request, *tmp; 1660 + struct reg_beacon *reg_beacon, *btmp; 1661 + 1662 + cancel_work_sync(&reg_work); 1663 + 1664 + mutex_lock(&cfg80211_mutex); 2120 1665 2121 1666 reset_regdomains(); 2122 1667 ··· 2155 1644 2156 1645 platform_device_unregister(reg_pdev); 2157 1646 2158 - mutex_unlock(&cfg80211_drv_mutex); 1647 + spin_lock_bh(&reg_pending_beacons_lock); 1648 + if (!list_empty(&reg_pending_beacons)) { 1649 + list_for_each_entry_safe(reg_beacon, btmp, 1650 + &reg_pending_beacons, list) { 1651 + list_del(&reg_beacon->list); 1652 + kfree(reg_beacon); 1653 + } 1654 + } 1655 + spin_unlock_bh(&reg_pending_beacons_lock); 1656 + 1657 + if (!list_empty(&reg_beacon_list)) { 1658 + list_for_each_entry_safe(reg_beacon, btmp, 1659 + &reg_beacon_list, list) { 1660 + list_del(&reg_beacon->list); 1661 + kfree(reg_beacon); 1662 + } 1663 + } 1664 + 1665 + spin_lock(&reg_requests_lock); 1666 + if (!list_empty(&reg_requests_list)) { 1667 + list_for_each_entry_safe(reg_request, tmp, 1668 + &reg_requests_list, list) { 1669 + list_del(&reg_request->list); 1670 + kfree(reg_request); 1671 + } 1672 + } 1673 + spin_unlock(&reg_requests_lock); 1674 + 1675 + mutex_unlock(&cfg80211_mutex); 2159 1676 }
+18 -18
net/wireless/reg.h
··· 6 6 bool is_world_regdom(const char *alpha2); 7 7 bool reg_is_valid_request(const char *alpha2); 8 8 9 + int regulatory_hint_user(const char *alpha2); 10 + 9 11 void reg_device_remove(struct wiphy *wiphy); 10 12 11 13 int regulatory_init(void); ··· 16 14 int set_regdom(const struct ieee80211_regdomain *rd); 17 15 18 16 /** 19 - * __regulatory_hint - hint to the wireless core a regulatory domain 20 - * @wiphy: if the hint comes from country information from an AP, this 21 - * is required to be set to the wiphy that received the information 22 - * @alpha2: the ISO/IEC 3166 alpha2 being claimed the regulatory domain 23 - * should be in. 24 - * @country_ie_checksum: checksum of processed country IE, set this to 0 25 - * if the hint did not come from a country IE 26 - * @country_ie_env: the environment the IE told us we are in, %ENVIRON_* 17 + * regulatory_hint_found_beacon - hints a beacon was found on a channel 18 + * @wiphy: the wireless device where the beacon was found on 19 + * @beacon_chan: the channel on which the beacon was found on 20 + * @gfp: context flags 27 21 * 28 - * The Wireless subsystem can use this function to hint to the wireless core 29 - * what it believes should be the current regulatory domain by giving it an 30 - * ISO/IEC 3166 alpha2 country code it knows its regulatory domain should be 31 - * in. 22 + * This informs the wireless core that a beacon from an AP was found on 23 + * the channel provided. This allows the wireless core to make educated 24 + * guesses on regulatory to help with world roaming. This is only used for 25 + * world roaming -- when we do not know our current location. This is 26 + * only useful on channels 12, 13 and 14 on the 2 GHz band as channels 27 + * 1-11 are already enabled by the world regulatory domain; and on 28 + * non-radar 5 GHz channels. 32 29 * 33 - * Returns zero if all went fine, %-EALREADY if a regulatory domain had 34 - * already been set or other standard error codes. 35 - * 30 + * Drivers do not need to call this, cfg80211 will do it for after a scan 31 + * on a newly found BSS. 36 32 */ 37 - extern int __regulatory_hint(struct wiphy *wiphy, enum reg_set_by set_by, 38 - const char *alpha2, u32 country_ie_checksum, 39 - enum environment_cap country_ie_env); 33 + int regulatory_hint_found_beacon(struct wiphy *wiphy, 34 + struct ieee80211_channel *beacon_chan, 35 + gfp_t gfp); 40 36 41 37 #endif /* __NET_WIRELESS_REG_H */
+47 -17
net/wireless/scan.c
··· 62 62 } 63 63 64 64 /* must hold dev->bss_lock! */ 65 + void cfg80211_bss_age(struct cfg80211_registered_device *dev, 66 + unsigned long age_secs) 67 + { 68 + struct cfg80211_internal_bss *bss; 69 + unsigned long age_jiffies = msecs_to_jiffies(age_secs * MSEC_PER_SEC); 70 + 71 + list_for_each_entry(bss, &dev->bss_list, list) { 72 + bss->ts -= age_jiffies; 73 + } 74 + } 75 + 76 + /* must hold dev->bss_lock! */ 65 77 void cfg80211_bss_expire(struct cfg80211_registered_device *dev) 66 78 { 67 79 struct cfg80211_internal_bss *bss, *tmp; ··· 370 358 found->pub.beacon_interval = res->pub.beacon_interval; 371 359 found->pub.tsf = res->pub.tsf; 372 360 found->pub.signal = res->pub.signal; 373 - found->pub.signal_type = res->pub.signal_type; 374 361 found->pub.capability = res->pub.capability; 375 362 found->ts = res->ts; 376 363 kref_put(&res->ref, bss_release); ··· 391 380 cfg80211_inform_bss_frame(struct wiphy *wiphy, 392 381 struct ieee80211_channel *channel, 393 382 struct ieee80211_mgmt *mgmt, size_t len, 394 - s32 signal, enum cfg80211_signal_type sigtype, 395 - gfp_t gfp) 383 + s32 signal, gfp_t gfp) 396 384 { 397 385 struct cfg80211_internal_bss *res; 398 386 size_t ielen = len - offsetof(struct ieee80211_mgmt, ··· 399 389 bool overwrite; 400 390 size_t privsz = wiphy->bss_priv_size; 401 391 402 - if (WARN_ON(sigtype == NL80211_BSS_SIGNAL_UNSPEC && 392 + if (WARN_ON(wiphy->signal_type == NL80211_BSS_SIGNAL_UNSPEC && 403 393 (signal < 0 || signal > 100))) 404 394 return NULL; 405 395 ··· 413 403 414 404 memcpy(res->pub.bssid, mgmt->bssid, ETH_ALEN); 415 405 res->pub.channel = channel; 416 - res->pub.signal_type = sigtype; 417 406 res->pub.signal = signal; 418 407 res->pub.tsf = le64_to_cpu(mgmt->u.probe_resp.timestamp); 419 408 res->pub.beacon_interval = le16_to_cpu(mgmt->u.probe_resp.beacon_int); ··· 429 420 res = cfg80211_bss_update(wiphy_to_dev(wiphy), res, overwrite); 430 421 if (!res) 431 422 return NULL; 423 + 424 + if (res->pub.capability & WLAN_CAPABILITY_ESS) 425 + regulatory_hint_found_beacon(wiphy, channel, gfp); 432 426 433 427 /* cfg80211_bss_update gives us a referenced result */ 434 428 return &res->pub; ··· 596 584 } 597 585 } 598 586 587 + static inline unsigned int elapsed_jiffies_msecs(unsigned long start) 588 + { 589 + unsigned long end = jiffies; 590 + 591 + if (end >= start) 592 + return jiffies_to_msecs(end - start); 593 + 594 + return jiffies_to_msecs(end + (MAX_JIFFY_OFFSET - start) + 1); 595 + } 599 596 600 597 static char * 601 - ieee80211_bss(struct iw_request_info *info, 602 - struct cfg80211_internal_bss *bss, 603 - char *current_ev, char *end_buf) 598 + ieee80211_bss(struct wiphy *wiphy, struct iw_request_info *info, 599 + struct cfg80211_internal_bss *bss, char *current_ev, 600 + char *end_buf) 604 601 { 605 602 struct iw_event iwe; 606 603 u8 *buf, *cfg, *p; 607 604 u8 *ie = bss->pub.information_elements; 608 - int rem = bss->pub.len_information_elements, i; 605 + int rem = bss->pub.len_information_elements, i, sig; 609 606 bool ismesh = false; 610 607 611 608 memset(&iwe, 0, sizeof(iwe)); ··· 638 617 current_ev = iwe_stream_add_event(info, current_ev, end_buf, &iwe, 639 618 IW_EV_FREQ_LEN); 640 619 641 - if (bss->pub.signal_type != CFG80211_SIGNAL_TYPE_NONE) { 620 + if (wiphy->signal_type != CFG80211_SIGNAL_TYPE_NONE) { 642 621 memset(&iwe, 0, sizeof(iwe)); 643 622 iwe.cmd = IWEVQUAL; 644 623 iwe.u.qual.updated = IW_QUAL_LEVEL_UPDATED | 645 624 IW_QUAL_NOISE_INVALID | 646 - IW_QUAL_QUAL_INVALID; 647 - switch (bss->pub.signal_type) { 625 + IW_QUAL_QUAL_UPDATED; 626 + switch (wiphy->signal_type) { 648 627 case CFG80211_SIGNAL_TYPE_MBM: 649 - iwe.u.qual.level = bss->pub.signal / 100; 628 + sig = bss->pub.signal / 100; 629 + iwe.u.qual.level = sig; 650 630 iwe.u.qual.updated |= IW_QUAL_DBM; 631 + if (sig < -110) /* rather bad */ 632 + sig = -110; 633 + else if (sig > -40) /* perfect */ 634 + sig = -40; 635 + /* will give a range of 0 .. 70 */ 636 + iwe.u.qual.qual = sig + 110; 651 637 break; 652 638 case CFG80211_SIGNAL_TYPE_UNSPEC: 653 639 iwe.u.qual.level = bss->pub.signal; 640 + /* will give range 0 .. 100 */ 641 + iwe.u.qual.qual = bss->pub.signal; 654 642 break; 655 643 default: 656 644 /* not reached */ ··· 793 763 &iwe, buf); 794 764 memset(&iwe, 0, sizeof(iwe)); 795 765 iwe.cmd = IWEVCUSTOM; 796 - sprintf(buf, " Last beacon: %dms ago", 797 - jiffies_to_msecs(jiffies - bss->ts)); 766 + sprintf(buf, " Last beacon: %ums ago", 767 + elapsed_jiffies_msecs(bss->ts)); 798 768 iwe.u.data.length = strlen(buf); 799 769 current_ev = iwe_stream_add_point(info, current_ev, 800 770 end_buf, &iwe, buf); ··· 823 793 spin_unlock_bh(&dev->bss_lock); 824 794 return -E2BIG; 825 795 } 826 - current_ev = ieee80211_bss(info, bss, 827 - current_ev, end_buf); 796 + current_ev = ieee80211_bss(&dev->wiphy, info, bss, 797 + current_ev, end_buf); 828 798 } 829 799 spin_unlock_bh(&dev->bss_lock); 830 800 return current_ev - buf;
+8 -1
net/wireless/sysfs.c
··· 31 31 return sprintf(buf, fmt "\n", dev_to_rdev(dev)->member); \ 32 32 } 33 33 34 - SHOW_FMT(index, "%d", idx); 34 + SHOW_FMT(index, "%d", wiphy_idx); 35 35 SHOW_FMT(macaddress, "%pM", wiphy.perm_addr); 36 36 37 37 static struct device_attribute ieee80211_dev_attrs[] = { ··· 60 60 struct cfg80211_registered_device *rdev = dev_to_rdev(dev); 61 61 int ret = 0; 62 62 63 + rdev->suspend_at = get_seconds(); 64 + 63 65 if (rdev->ops->suspend) { 64 66 rtnl_lock(); 65 67 ret = rdev->ops->suspend(&rdev->wiphy); ··· 75 73 { 76 74 struct cfg80211_registered_device *rdev = dev_to_rdev(dev); 77 75 int ret = 0; 76 + 77 + /* Age scan results with time spent in suspend */ 78 + spin_lock_bh(&rdev->bss_lock); 79 + cfg80211_bss_age(rdev, get_seconds() - rdev->suspend_at); 80 + spin_unlock_bh(&rdev->bss_lock); 78 81 79 82 if (rdev->ops->resume) { 80 83 rtnl_lock();
+97
net/wireless/wext-compat.c
··· 137 137 return 0; 138 138 } 139 139 EXPORT_SYMBOL(cfg80211_wext_giwmode); 140 + 141 + 142 + int cfg80211_wext_giwrange(struct net_device *dev, 143 + struct iw_request_info *info, 144 + struct iw_point *data, char *extra) 145 + { 146 + struct wireless_dev *wdev = dev->ieee80211_ptr; 147 + struct iw_range *range = (struct iw_range *) extra; 148 + enum ieee80211_band band; 149 + int c = 0; 150 + 151 + if (!wdev) 152 + return -EOPNOTSUPP; 153 + 154 + data->length = sizeof(struct iw_range); 155 + memset(range, 0, sizeof(struct iw_range)); 156 + 157 + range->we_version_compiled = WIRELESS_EXT; 158 + range->we_version_source = 21; 159 + range->retry_capa = IW_RETRY_LIMIT; 160 + range->retry_flags = IW_RETRY_LIMIT; 161 + range->min_retry = 0; 162 + range->max_retry = 255; 163 + range->min_rts = 0; 164 + range->max_rts = 2347; 165 + range->min_frag = 256; 166 + range->max_frag = 2346; 167 + 168 + range->encoding_size[0] = 5; 169 + range->encoding_size[1] = 13; 170 + range->num_encoding_sizes = 2; 171 + range->max_encoding_tokens = 4; 172 + 173 + range->max_qual.updated = IW_QUAL_NOISE_INVALID; 174 + 175 + switch (wdev->wiphy->signal_type) { 176 + case CFG80211_SIGNAL_TYPE_NONE: 177 + break; 178 + case CFG80211_SIGNAL_TYPE_MBM: 179 + range->max_qual.level = -110; 180 + range->max_qual.qual = 70; 181 + range->avg_qual.qual = 35; 182 + range->max_qual.updated |= IW_QUAL_DBM; 183 + range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; 184 + range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; 185 + break; 186 + case CFG80211_SIGNAL_TYPE_UNSPEC: 187 + range->max_qual.level = 100; 188 + range->max_qual.qual = 100; 189 + range->avg_qual.qual = 50; 190 + range->max_qual.updated |= IW_QUAL_QUAL_UPDATED; 191 + range->max_qual.updated |= IW_QUAL_LEVEL_UPDATED; 192 + break; 193 + } 194 + 195 + range->avg_qual.level = range->max_qual.level / 2; 196 + range->avg_qual.noise = range->max_qual.noise / 2; 197 + range->avg_qual.updated = range->max_qual.updated; 198 + 199 + range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | 200 + IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; 201 + 202 + 203 + for (band = 0; band < IEEE80211_NUM_BANDS; band ++) { 204 + int i; 205 + struct ieee80211_supported_band *sband; 206 + 207 + sband = wdev->wiphy->bands[band]; 208 + 209 + if (!sband) 210 + continue; 211 + 212 + for (i = 0; i < sband->n_channels && c < IW_MAX_FREQUENCIES; i++) { 213 + struct ieee80211_channel *chan = &sband->channels[i]; 214 + 215 + if (!(chan->flags & IEEE80211_CHAN_DISABLED)) { 216 + range->freq[c].i = 217 + ieee80211_frequency_to_channel( 218 + chan->center_freq); 219 + range->freq[c].m = chan->center_freq; 220 + range->freq[c].e = 6; 221 + c++; 222 + } 223 + } 224 + } 225 + range->num_channels = c; 226 + range->num_frequency = c; 227 + 228 + IW_EVENT_CAPA_SET_KERNEL(range->event_capa); 229 + IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); 230 + IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); 231 + 232 + range->scan_capa |= IW_SCAN_CAPA_ESSID; 233 + 234 + return 0; 235 + } 236 + EXPORT_SYMBOL(cfg80211_wext_giwrange);